| | @@ -16,11 +16,11 @@ |
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | | -** 5495b12569c318d5020b4b5a625a392ef8e7 with changes in files: |
| 21 | +** e2bae4143afd07de1ae55a6d2606a3b541a5 with changes in files: |
| 22 | 22 | ** |
| 23 | 23 | ** |
| 24 | 24 | */ |
| 25 | 25 | #ifndef SQLITE_AMALGAMATION |
| 26 | 26 | #define SQLITE_CORE 1 |
| | @@ -27,11 +27,10 @@ |
| 27 | 27 | #define SQLITE_AMALGAMATION 1 |
| 28 | 28 | #ifndef SQLITE_PRIVATE |
| 29 | 29 | # define SQLITE_PRIVATE static |
| 30 | 30 | #endif |
| 31 | 31 | /************** Begin file sqliteInt.h ***************************************/ |
| 32 | | -#line 1 "tsrc/sqliteInt.h" |
| 33 | 32 | /* |
| 34 | 33 | ** 2001 September 15 |
| 35 | 34 | ** |
| 36 | 35 | ** The author disclaims copyright to this source code. In place of |
| 37 | 36 | ** a legal notice, here is a blessing: |
| | @@ -88,11 +87,10 @@ |
| 88 | 87 | ** compiler warnings due to subsequent content in this file and other files |
| 89 | 88 | ** that are included by this file. |
| 90 | 89 | */ |
| 91 | 90 | /************** Include msvc.h in the middle of sqliteInt.h ******************/ |
| 92 | 91 | /************** Begin file msvc.h ********************************************/ |
| 93 | | -#line 1 "tsrc/msvc.h" |
| 94 | 92 | /* |
| 95 | 93 | ** 2015 January 12 |
| 96 | 94 | ** |
| 97 | 95 | ** The author disclaims copyright to this source code. In place of |
| 98 | 96 | ** a legal notice, here is a blessing: |
| | @@ -137,18 +135,16 @@ |
| 137 | 135 | |
| 138 | 136 | #endif /* SQLITE_MSVC_H */ |
| 139 | 137 | |
| 140 | 138 | /************** End of msvc.h ************************************************/ |
| 141 | 139 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 142 | | -#line 60 "tsrc/sqliteInt.h" |
| 143 | 140 | |
| 144 | 141 | /* |
| 145 | 142 | ** Special setup for VxWorks |
| 146 | 143 | */ |
| 147 | 144 | /************** Include vxworks.h in the middle of sqliteInt.h ***************/ |
| 148 | 145 | /************** Begin file vxworks.h *****************************************/ |
| 149 | | -#line 1 "tsrc/vxworks.h" |
| 150 | 146 | /* |
| 151 | 147 | ** 2015-03-02 |
| 152 | 148 | ** |
| 153 | 149 | ** The author disclaims copyright to this source code. In place of |
| 154 | 150 | ** a legal notice, here is a blessing: |
| | @@ -180,11 +176,10 @@ |
| 180 | 176 | #define HAVE_LSTAT 1 |
| 181 | 177 | #endif /* defined(_WRS_KERNEL) */ |
| 182 | 178 | |
| 183 | 179 | /************** End of vxworks.h *********************************************/ |
| 184 | 180 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 185 | | -#line 65 "tsrc/sqliteInt.h" |
| 186 | 181 | |
| 187 | 182 | /* |
| 188 | 183 | ** These #defines should enable >2GB file support on POSIX if the |
| 189 | 184 | ** underlying operating system supports it. If the OS lacks |
| 190 | 185 | ** large file support, or if the OS is windows, these should be no-ops. |
| | @@ -320,11 +315,10 @@ |
| 320 | 315 | ** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for |
| 321 | 316 | ** MinGW. |
| 322 | 317 | */ |
| 323 | 318 | /************** Include sqlite3.h in the middle of sqliteInt.h ***************/ |
| 324 | 319 | /************** Begin file sqlite3.h *****************************************/ |
| 325 | | -#line 1 "tsrc/sqlite3.h" |
| 326 | 320 | /* |
| 327 | 321 | ** 2001-09-15 |
| 328 | 322 | ** |
| 329 | 323 | ** The author disclaims copyright to this source code. In place of |
| 330 | 324 | ** a legal notice, here is a blessing: |
| | @@ -471,11 +465,11 @@ |
| 471 | 465 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 472 | 466 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 473 | 467 | */ |
| 474 | 468 | #define SQLITE_VERSION "3.48.0" |
| 475 | 469 | #define SQLITE_VERSION_NUMBER 3048000 |
| 476 | | -#define SQLITE_SOURCE_ID "2024-11-06 12:58:31 5495b12569c318d5020b4b5a625a392ef8e777b81c0200624fbbc2a6b5eddef9" |
| 470 | +#define SQLITE_SOURCE_ID "2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653" |
| 477 | 471 | |
| 478 | 472 | /* |
| 479 | 473 | ** CAPI3REF: Run-Time Library Version Numbers |
| 480 | 474 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 481 | 475 | ** |
| | @@ -1423,10 +1417,15 @@ |
| 1423 | 1417 | ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This |
| 1424 | 1418 | ** opcode causes the xFileControl method to swap the file handle with the one |
| 1425 | 1419 | ** pointed to by the pArg argument. This capability is used during testing |
| 1426 | 1420 | ** and only needs to be supported when SQLITE_TEST is defined. |
| 1427 | 1421 | ** |
| 1422 | +** <li>[[SQLITE_FCNTL_NULL_IO]] |
| 1423 | +** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor |
| 1424 | +** or file handle for the [sqlite3_file] object such that it will no longer |
| 1425 | +** read or write to the database file. |
| 1426 | +** |
| 1428 | 1427 | ** <li>[[SQLITE_FCNTL_WAL_BLOCK]] |
| 1429 | 1428 | ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might |
| 1430 | 1429 | ** be advantageous to block on the next WAL lock if the lock is not immediately |
| 1431 | 1430 | ** available. The WAL subsystem issues this signal during rare |
| 1432 | 1431 | ** circumstances in order to fix a problem with priority inversion. |
| | @@ -1576,10 +1575,11 @@ |
| 1576 | 1575 | #define SQLITE_FCNTL_RESERVE_BYTES 38 |
| 1577 | 1576 | #define SQLITE_FCNTL_CKPT_START 39 |
| 1578 | 1577 | #define SQLITE_FCNTL_EXTERNAL_READER 40 |
| 1579 | 1578 | #define SQLITE_FCNTL_CKSM_FILE 41 |
| 1580 | 1579 | #define SQLITE_FCNTL_RESET_CACHE 42 |
| 1580 | +#define SQLITE_FCNTL_NULL_IO 43 |
| 1581 | 1581 | |
| 1582 | 1582 | /* deprecated names */ |
| 1583 | 1583 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| 1584 | 1584 | #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE |
| 1585 | 1585 | #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| | @@ -2954,14 +2954,18 @@ |
| 2954 | 2954 | ** |
| 2955 | 2955 | ** ^These functions return the number of rows modified, inserted or |
| 2956 | 2956 | ** deleted by the most recently completed INSERT, UPDATE or DELETE |
| 2957 | 2957 | ** statement on the database connection specified by the only parameter. |
| 2958 | 2958 | ** The two functions are identical except for the type of the return value |
| 2959 | | -** and that if the number of rows modified by the most recent INSERT, UPDATE |
| 2959 | +** and that if the number of rows modified by the most recent INSERT, UPDATE, |
| 2960 | 2960 | ** or DELETE is greater than the maximum value supported by type "int", then |
| 2961 | 2961 | ** the return value of sqlite3_changes() is undefined. ^Executing any other |
| 2962 | 2962 | ** type of SQL statement does not modify the value returned by these functions. |
| 2963 | +** For the purposes of this interface, a CREATE TABLE AS SELECT statement |
| 2964 | +** does not count as an INSERT, UPDATE or DELETE statement and hence the rows |
| 2965 | +** added to the new table by the CREATE TABLE AS SELECT statement are not |
| 2966 | +** counted. |
| 2963 | 2967 | ** |
| 2964 | 2968 | ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are |
| 2965 | 2969 | ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], |
| 2966 | 2970 | ** [foreign key actions] or [REPLACE] constraint resolution are not counted. |
| 2967 | 2971 | ** |
| | @@ -4517,15 +4521,26 @@ |
| 4517 | 4521 | ** |
| 4518 | 4522 | ** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt> |
| 4519 | 4523 | ** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler |
| 4520 | 4524 | ** to return an error (error code SQLITE_ERROR) if the statement uses |
| 4521 | 4525 | ** any virtual tables. |
| 4526 | +** |
| 4527 | +** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt> |
| 4528 | +** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler |
| 4529 | +** errors from being sent to the error log defined by |
| 4530 | +** [SQLITE_CONFIG_LOG]. This can be used, for example, to do test |
| 4531 | +** compiles to see if some SQL syntax is well-formed, without generating |
| 4532 | +** messages on the global error log when it is not. If the test compile |
| 4533 | +** fails, the sqlite3_prepare_v3() call returns the same error indications |
| 4534 | +** with or without this flag; it just omits the call to [sqlite3_log()] that |
| 4535 | +** logs the error. |
| 4522 | 4536 | ** </dl> |
| 4523 | 4537 | */ |
| 4524 | 4538 | #define SQLITE_PREPARE_PERSISTENT 0x01 |
| 4525 | 4539 | #define SQLITE_PREPARE_NORMALIZE 0x02 |
| 4526 | 4540 | #define SQLITE_PREPARE_NO_VTAB 0x04 |
| 4541 | +#define SQLITE_PREPARE_DONT_LOG 0x10 |
| 4527 | 4542 | |
| 4528 | 4543 | /* |
| 4529 | 4544 | ** CAPI3REF: Compiling An SQL Statement |
| 4530 | 4545 | ** KEYWORDS: {SQL statement compiler} |
| 4531 | 4546 | ** METHOD: sqlite3 |
| | @@ -13463,17 +13478,32 @@ |
| 13463 | 13478 | ** This is used to access token iToken of phrase hit iIdx within the |
| 13464 | 13479 | ** current row. If iIdx is less than zero or greater than or equal to the |
| 13465 | 13480 | ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, |
| 13466 | 13481 | ** output variable (*ppToken) is set to point to a buffer containing the |
| 13467 | 13482 | ** matching document token, and (*pnToken) to the size of that buffer in |
| 13468 | | -** bytes. This API is not available if the specified token matches a |
| 13469 | | -** prefix query term. In that case both output variables are always set |
| 13470 | | -** to 0. |
| 13483 | +** bytes. |
| 13471 | 13484 | ** |
| 13472 | 13485 | ** The output text is not a copy of the document text that was tokenized. |
| 13473 | 13486 | ** It is the output of the tokenizer module. For tokendata=1 tables, this |
| 13474 | 13487 | ** includes any embedded 0x00 and trailing data. |
| 13488 | +** |
| 13489 | +** This API may be slow in some cases if the token identified by parameters |
| 13490 | +** iIdx and iToken matched a prefix token in the query. In most cases, the |
| 13491 | +** first call to this API for each prefix token in the query is forced |
| 13492 | +** to scan the portion of the full-text index that matches the prefix |
| 13493 | +** token to collect the extra data required by this API. If the prefix |
| 13494 | +** token matches a large number of token instances in the document set, |
| 13495 | +** this may be a performance problem. |
| 13496 | +** |
| 13497 | +** If the user knows in advance that a query may use this API for a |
| 13498 | +** prefix token, FTS5 may be configured to collect all required data as part |
| 13499 | +** of the initial querying of the full-text index, avoiding the second scan |
| 13500 | +** entirely. This also causes prefix queries that do not use this API to |
| 13501 | +** run more slowly and use more memory. FTS5 may be configured in this way |
| 13502 | +** either on a per-table basis using the [FTS5 insttoken | 'insttoken'] |
| 13503 | +** option, or on a per-query basis using the |
| 13504 | +** [fts5_insttoken | fts5_insttoken()] user function. |
| 13475 | 13505 | ** |
| 13476 | 13506 | ** This API can be quite slow if used with an FTS5 table created with the |
| 13477 | 13507 | ** "detail=none" or "detail=column" option. |
| 13478 | 13508 | ** |
| 13479 | 13509 | ** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale) |
| | @@ -13908,11 +13938,10 @@ |
| 13908 | 13938 | /******** End of fts5.h *********/ |
| 13909 | 13939 | #endif /* SQLITE3_H */ |
| 13910 | 13940 | |
| 13911 | 13941 | /************** End of sqlite3.h *********************************************/ |
| 13912 | 13942 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 13913 | | -#line 203 "tsrc/sqliteInt.h" |
| 13914 | 13943 | |
| 13915 | 13944 | /* |
| 13916 | 13945 | ** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory. |
| 13917 | 13946 | */ |
| 13918 | 13947 | #define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_VFS1 |
| | @@ -13926,11 +13955,10 @@ |
| 13926 | 13955 | #define SQLITECONFIG_H 1 |
| 13927 | 13956 | #endif |
| 13928 | 13957 | |
| 13929 | 13958 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 13930 | 13959 | /************** Begin file sqliteLimit.h *************************************/ |
| 13931 | | -#line 1 "tsrc/sqliteLimit.h" |
| 13932 | 13960 | /* |
| 13933 | 13961 | ** 2007 May 7 |
| 13934 | 13962 | ** |
| 13935 | 13963 | ** The author disclaims copyright to this source code. In place of |
| 13936 | 13964 | ** a legal notice, here is a blessing: |
| | @@ -13952,10 +13980,11 @@ |
| 13952 | 13980 | ** to count the size: 2^31-1 or 2147483647. |
| 13953 | 13981 | */ |
| 13954 | 13982 | #ifndef SQLITE_MAX_LENGTH |
| 13955 | 13983 | # define SQLITE_MAX_LENGTH 1000000000 |
| 13956 | 13984 | #endif |
| 13985 | +#define SQLITE_MIN_LENGTH 30 /* Minimum value for the length limit */ |
| 13957 | 13986 | |
| 13958 | 13987 | /* |
| 13959 | 13988 | ** This is the maximum number of |
| 13960 | 13989 | ** |
| 13961 | 13990 | ** * Columns in a table |
| | @@ -14140,11 +14169,10 @@ |
| 14140 | 14169 | # define SQLITE_MAX_TRIGGER_DEPTH 1000 |
| 14141 | 14170 | #endif |
| 14142 | 14171 | |
| 14143 | 14172 | /************** End of sqliteLimit.h *****************************************/ |
| 14144 | 14173 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 14145 | | -#line 219 "tsrc/sqliteInt.h" |
| 14146 | 14174 | |
| 14147 | 14175 | /* Disable nuisance warnings on Borland compilers */ |
| 14148 | 14176 | #if defined(__BORLANDC__) |
| 14149 | 14177 | #pragma warn -rch /* unreachable code */ |
| 14150 | 14178 | #pragma warn -ccc /* Condition is always true or false */ |
| | @@ -14558,11 +14586,10 @@ |
| 14558 | 14586 | #define likely(X) (X) |
| 14559 | 14587 | #define unlikely(X) (X) |
| 14560 | 14588 | |
| 14561 | 14589 | /************** Include hash.h in the middle of sqliteInt.h ******************/ |
| 14562 | 14590 | /************** Begin file hash.h ********************************************/ |
| 14563 | | -#line 1 "tsrc/hash.h" |
| 14564 | 14591 | /* |
| 14565 | 14592 | ** 2001 September 22 |
| 14566 | 14593 | ** |
| 14567 | 14594 | ** The author disclaims copyright to this source code. In place of |
| 14568 | 14595 | ** a legal notice, here is a blessing: |
| | @@ -14658,14 +14685,12 @@ |
| 14658 | 14685 | |
| 14659 | 14686 | #endif /* SQLITE_HASH_H */ |
| 14660 | 14687 | |
| 14661 | 14688 | /************** End of hash.h ************************************************/ |
| 14662 | 14689 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 14663 | | -#line 635 "tsrc/sqliteInt.h" |
| 14664 | 14690 | /************** Include parse.h in the middle of sqliteInt.h *****************/ |
| 14665 | 14691 | /************** Begin file parse.h *******************************************/ |
| 14666 | | -#line 1 "tsrc/parse.h" |
| 14667 | 14692 | #define TK_SEMI 1 |
| 14668 | 14693 | #define TK_EXPLAIN 2 |
| 14669 | 14694 | #define TK_QUERY 3 |
| 14670 | 14695 | #define TK_PLAN 4 |
| 14671 | 14696 | #define TK_BEGIN 5 |
| | @@ -14850,11 +14875,10 @@ |
| 14850 | 14875 | #define TK_SPACE 184 |
| 14851 | 14876 | #define TK_ILLEGAL 185 |
| 14852 | 14877 | |
| 14853 | 14878 | /************** End of parse.h ***********************************************/ |
| 14854 | 14879 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 14855 | | -#line 636 "tsrc/sqliteInt.h" |
| 14856 | 14880 | #include <stdio.h> |
| 14857 | 14881 | #include <stdlib.h> |
| 14858 | 14882 | #include <string.h> |
| 14859 | 14883 | #include <assert.h> |
| 14860 | 14884 | #include <stddef.h> |
| | @@ -15616,11 +15640,10 @@ |
| 15616 | 15640 | ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque |
| 15617 | 15641 | ** pointer types (i.e. FuncDef) defined above. |
| 15618 | 15642 | */ |
| 15619 | 15643 | /************** Include os.h in the middle of sqliteInt.h ********************/ |
| 15620 | 15644 | /************** Begin file os.h **********************************************/ |
| 15621 | | -#line 1 "tsrc/os.h" |
| 15622 | 15645 | /* |
| 15623 | 15646 | ** 2001 September 16 |
| 15624 | 15647 | ** |
| 15625 | 15648 | ** The author disclaims copyright to this source code. In place of |
| 15626 | 15649 | ** a legal notice, here is a blessing: |
| | @@ -15645,11 +15668,10 @@ |
| 15645 | 15668 | ** Attempt to automatically detect the operating system and setup the |
| 15646 | 15669 | ** necessary pre-processor macros for it. |
| 15647 | 15670 | */ |
| 15648 | 15671 | /************** Include os_setup.h in the middle of os.h *********************/ |
| 15649 | 15672 | /************** Begin file os_setup.h ****************************************/ |
| 15650 | | -#line 1 "tsrc/os_setup.h" |
| 15651 | 15673 | /* |
| 15652 | 15674 | ** 2013 November 25 |
| 15653 | 15675 | ** |
| 15654 | 15676 | ** The author disclaims copyright to this source code. In place of |
| 15655 | 15677 | ** a legal notice, here is a blessing: |
| | @@ -15740,11 +15762,10 @@ |
| 15740 | 15762 | |
| 15741 | 15763 | #endif /* SQLITE_OS_SETUP_H */ |
| 15742 | 15764 | |
| 15743 | 15765 | /************** End of os_setup.h ********************************************/ |
| 15744 | 15766 | /************** Continuing where we left off in os.h *************************/ |
| 15745 | | -#line 28 "tsrc/os.h" |
| 15746 | 15767 | |
| 15747 | 15768 | /* If the SET_FULLSYNC macro is not defined above, then make it |
| 15748 | 15769 | ** a no-op |
| 15749 | 15770 | */ |
| 15750 | 15771 | #ifndef SET_FULLSYNC |
| | @@ -15942,14 +15963,12 @@ |
| 15942 | 15963 | |
| 15943 | 15964 | #endif /* _SQLITE_OS_H_ */ |
| 15944 | 15965 | |
| 15945 | 15966 | /************** End of os.h **************************************************/ |
| 15946 | 15967 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 15947 | | -#line 1400 "tsrc/sqliteInt.h" |
| 15948 | 15968 | /************** Include pager.h in the middle of sqliteInt.h *****************/ |
| 15949 | 15969 | /************** Begin file pager.h *******************************************/ |
| 15950 | | -#line 1 "tsrc/pager.h" |
| 15951 | 15970 | /* |
| 15952 | 15971 | ** 2001 September 15 |
| 15953 | 15972 | ** |
| 15954 | 15973 | ** The author disclaims copyright to this source code. In place of |
| 15955 | 15974 | ** a legal notice, here is a blessing: |
| | @@ -16196,14 +16215,12 @@ |
| 16196 | 16215 | |
| 16197 | 16216 | #endif /* SQLITE_PAGER_H */ |
| 16198 | 16217 | |
| 16199 | 16218 | /************** End of pager.h ***********************************************/ |
| 16200 | 16219 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 16201 | | -#line 1401 "tsrc/sqliteInt.h" |
| 16202 | 16220 | /************** Include btree.h in the middle of sqliteInt.h *****************/ |
| 16203 | 16221 | /************** Begin file btree.h *******************************************/ |
| 16204 | | -#line 1 "tsrc/btree.h" |
| 16205 | 16222 | /* |
| 16206 | 16223 | ** 2001 September 15 |
| 16207 | 16224 | ** |
| 16208 | 16225 | ** The author disclaims copyright to this source code. In place of |
| 16209 | 16226 | ** a legal notice, here is a blessing: |
| | @@ -16627,14 +16644,12 @@ |
| 16627 | 16644 | |
| 16628 | 16645 | #endif /* SQLITE_BTREE_H */ |
| 16629 | 16646 | |
| 16630 | 16647 | /************** End of btree.h ***********************************************/ |
| 16631 | 16648 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 16632 | | -#line 1402 "tsrc/sqliteInt.h" |
| 16633 | 16649 | /************** Include vdbe.h in the middle of sqliteInt.h ******************/ |
| 16634 | 16650 | /************** Begin file vdbe.h ********************************************/ |
| 16635 | | -#line 1 "tsrc/vdbe.h" |
| 16636 | 16651 | /* |
| 16637 | 16652 | ** 2001 September 15 |
| 16638 | 16653 | ** |
| 16639 | 16654 | ** The author disclaims copyright to this source code. In place of |
| 16640 | 16655 | ** a legal notice, here is a blessing: |
| | @@ -16814,11 +16829,10 @@ |
| 16814 | 16829 | ** The makefile scans the vdbe.c source file and creates the "opcodes.h" |
| 16815 | 16830 | ** header file that defines a number for each opcode used by the VDBE. |
| 16816 | 16831 | */ |
| 16817 | 16832 | /************** Include opcodes.h in the middle of vdbe.h ********************/ |
| 16818 | 16833 | /************** Begin file opcodes.h *****************************************/ |
| 16819 | | -#line 1 "tsrc/opcodes.h" |
| 16820 | 16834 | /* Automatically generated. Do not edit */ |
| 16821 | 16835 | /* See the tool/mkopcodeh.tcl script for details */ |
| 16822 | 16836 | #define OP_Savepoint 0 |
| 16823 | 16837 | #define OP_AutoCommit 1 |
| 16824 | 16838 | #define OP_Transaction 2 |
| | @@ -17056,17 +17070,16 @@ |
| 17056 | 17070 | */ |
| 17057 | 17071 | #define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */ |
| 17058 | 17072 | |
| 17059 | 17073 | /************** End of opcodes.h *********************************************/ |
| 17060 | 17074 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 17061 | | -#line 183 "tsrc/vdbe.h" |
| 17062 | 17075 | |
| 17063 | 17076 | /* |
| 17064 | 17077 | ** Additional non-public SQLITE_PREPARE_* flags |
| 17065 | 17078 | */ |
| 17066 | 17079 | #define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */ |
| 17067 | | -#define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */ |
| 17080 | +#define SQLITE_PREPARE_MASK 0x1f /* Mask of public flags */ |
| 17068 | 17081 | |
| 17069 | 17082 | /* |
| 17070 | 17083 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 17071 | 17084 | ** for a description of what each of these routines does. |
| 17072 | 17085 | */ |
| | @@ -17306,14 +17319,12 @@ |
| 17306 | 17319 | |
| 17307 | 17320 | #endif /* SQLITE_VDBE_H */ |
| 17308 | 17321 | |
| 17309 | 17322 | /************** End of vdbe.h ************************************************/ |
| 17310 | 17323 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 17311 | | -#line 1403 "tsrc/sqliteInt.h" |
| 17312 | 17324 | /************** Include pcache.h in the middle of sqliteInt.h ****************/ |
| 17313 | 17325 | /************** Begin file pcache.h ******************************************/ |
| 17314 | | -#line 1 "tsrc/pcache.h" |
| 17315 | 17326 | /* |
| 17316 | 17327 | ** 2008 August 05 |
| 17317 | 17328 | ** |
| 17318 | 17329 | ** The author disclaims copyright to this source code. In place of |
| 17319 | 17330 | ** a legal notice, here is a blessing: |
| | @@ -17503,14 +17514,12 @@ |
| 17503 | 17514 | |
| 17504 | 17515 | #endif /* _PCACHE_H_ */ |
| 17505 | 17516 | |
| 17506 | 17517 | /************** End of pcache.h **********************************************/ |
| 17507 | 17518 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 17508 | | -#line 1404 "tsrc/sqliteInt.h" |
| 17509 | 17519 | /************** Include mutex.h in the middle of sqliteInt.h *****************/ |
| 17510 | 17520 | /************** Begin file mutex.h *******************************************/ |
| 17511 | | -#line 1 "tsrc/mutex.h" |
| 17512 | 17521 | /* |
| 17513 | 17522 | ** 2007 August 28 |
| 17514 | 17523 | ** |
| 17515 | 17524 | ** The author disclaims copyright to this source code. In place of |
| 17516 | 17525 | ** a legal notice, here is a blessing: |
| | @@ -17581,11 +17590,10 @@ |
| 17581 | 17590 | SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); |
| 17582 | 17591 | #endif /* defined(SQLITE_MUTEX_OMIT) */ |
| 17583 | 17592 | |
| 17584 | 17593 | /************** End of mutex.h ***********************************************/ |
| 17585 | 17594 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 17586 | | -#line 1405 "tsrc/sqliteInt.h" |
| 17587 | 17595 | |
| 17588 | 17596 | /* The SQLITE_EXTRA_DURABLE compile-time option used to set the default |
| 17589 | 17597 | ** synchronous setting to EXTRA. It is no longer supported. |
| 17590 | 17598 | */ |
| 17591 | 17599 | #ifdef SQLITE_EXTRA_DURABLE |
| | @@ -21982,11 +21990,10 @@ |
| 21982 | 21990 | |
| 21983 | 21991 | #endif /* SQLITEINT_H */ |
| 21984 | 21992 | |
| 21985 | 21993 | /************** End of sqliteInt.h *******************************************/ |
| 21986 | 21994 | /************** Begin file os_common.h ***************************************/ |
| 21987 | | -#line 1 "tsrc/os_common.h" |
| 21988 | 21995 | /* |
| 21989 | 21996 | ** 2004 May 22 |
| 21990 | 21997 | ** |
| 21991 | 21998 | ** The author disclaims copyright to this source code. In place of |
| 21992 | 21999 | ** a legal notice, here is a blessing: |
| | @@ -22085,11 +22092,10 @@ |
| 22085 | 22092 | |
| 22086 | 22093 | #endif /* !defined(_OS_COMMON_H_) */ |
| 22087 | 22094 | |
| 22088 | 22095 | /************** End of os_common.h *******************************************/ |
| 22089 | 22096 | /************** Begin file ctime.c *******************************************/ |
| 22090 | | -#line 1 "tsrc/ctime.c" |
| 22091 | 22097 | /* DO NOT EDIT! |
| 22092 | 22098 | ** This file is automatically generated by the script in the canonical |
| 22093 | 22099 | ** SQLite source tree at tool/mkctimec.tcl. |
| 22094 | 22100 | ** |
| 22095 | 22101 | ** To modify this header, edit any of the various lists in that script |
| | @@ -22885,11 +22891,10 @@ |
| 22885 | 22891 | |
| 22886 | 22892 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 22887 | 22893 | |
| 22888 | 22894 | /************** End of ctime.c ***********************************************/ |
| 22889 | 22895 | /************** Begin file global.c ******************************************/ |
| 22890 | | -#line 1 "tsrc/global.c" |
| 22891 | 22896 | /* |
| 22892 | 22897 | ** 2008 June 13 |
| 22893 | 22898 | ** |
| 22894 | 22899 | ** The author disclaims copyright to this source code. In place of |
| 22895 | 22900 | ** a legal notice, here is a blessing: |
| | @@ -23290,11 +23295,10 @@ |
| 23290 | 23295 | "TEXT" |
| 23291 | 23296 | }; |
| 23292 | 23297 | |
| 23293 | 23298 | /************** End of global.c **********************************************/ |
| 23294 | 23299 | /************** Begin file status.c ******************************************/ |
| 23295 | | -#line 1 "tsrc/status.c" |
| 23296 | 23300 | /* |
| 23297 | 23301 | ** 2008 June 18 |
| 23298 | 23302 | ** |
| 23299 | 23303 | ** The author disclaims copyright to this source code. In place of |
| 23300 | 23304 | ** a legal notice, here is a blessing: |
| | @@ -23309,11 +23313,10 @@ |
| 23309 | 23313 | ** functionality. |
| 23310 | 23314 | */ |
| 23311 | 23315 | /* #include "sqliteInt.h" */ |
| 23312 | 23316 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 23313 | 23317 | /************** Begin file vdbeInt.h *****************************************/ |
| 23314 | | -#line 1 "tsrc/vdbeInt.h" |
| 23315 | 23318 | /* |
| 23316 | 23319 | ** 2003 September 6 |
| 23317 | 23320 | ** |
| 23318 | 23321 | ** The author disclaims copyright to this source code. In place of |
| 23319 | 23322 | ** a legal notice, here is a blessing: |
| | @@ -24046,11 +24049,10 @@ |
| 24046 | 24049 | |
| 24047 | 24050 | #endif /* !defined(SQLITE_VDBEINT_H) */ |
| 24048 | 24051 | |
| 24049 | 24052 | /************** End of vdbeInt.h *********************************************/ |
| 24050 | 24053 | /************** Continuing where we left off in status.c *********************/ |
| 24051 | | -#line 18 "tsrc/status.c" |
| 24052 | 24054 | |
| 24053 | 24055 | /* |
| 24054 | 24056 | ** Variables in which to record status information. |
| 24055 | 24057 | */ |
| 24056 | 24058 | #if SQLITE_PTRSIZE>4 |
| | @@ -24431,11 +24433,10 @@ |
| 24431 | 24433 | return rc; |
| 24432 | 24434 | } |
| 24433 | 24435 | |
| 24434 | 24436 | /************** End of status.c **********************************************/ |
| 24435 | 24437 | /************** Begin file date.c ********************************************/ |
| 24436 | | -#line 1 "tsrc/date.c" |
| 24437 | 24438 | /* |
| 24438 | 24439 | ** 2003 October 31 |
| 24439 | 24440 | ** |
| 24440 | 24441 | ** The author disclaims copyright to this source code. In place of |
| 24441 | 24442 | ** a legal notice, here is a blessing: |
| | @@ -26250,11 +26251,10 @@ |
| 26250 | 26251 | sqlite3InsertBuiltinFuncs(aDateTimeFuncs, ArraySize(aDateTimeFuncs)); |
| 26251 | 26252 | } |
| 26252 | 26253 | |
| 26253 | 26254 | /************** End of date.c ************************************************/ |
| 26254 | 26255 | /************** Begin file os.c **********************************************/ |
| 26255 | | -#line 1 "tsrc/os.c" |
| 26256 | 26256 | /* |
| 26257 | 26257 | ** 2005 November 29 |
| 26258 | 26258 | ** |
| 26259 | 26259 | ** The author disclaims copyright to this source code. In place of |
| 26260 | 26260 | ** a legal notice, here is a blessing: |
| | @@ -26701,11 +26701,10 @@ |
| 26701 | 26701 | return SQLITE_OK; |
| 26702 | 26702 | } |
| 26703 | 26703 | |
| 26704 | 26704 | /************** End of os.c **************************************************/ |
| 26705 | 26705 | /************** Begin file fault.c *******************************************/ |
| 26706 | | -#line 1 "tsrc/fault.c" |
| 26707 | 26706 | /* |
| 26708 | 26707 | ** 2008 Jan 22 |
| 26709 | 26708 | ** |
| 26710 | 26709 | ** The author disclaims copyright to this source code. In place of |
| 26711 | 26710 | ** a legal notice, here is a blessing: |
| | @@ -26792,11 +26791,10 @@ |
| 26792 | 26791 | |
| 26793 | 26792 | #endif /* #ifndef SQLITE_UNTESTABLE */ |
| 26794 | 26793 | |
| 26795 | 26794 | /************** End of fault.c ***********************************************/ |
| 26796 | 26795 | /************** Begin file mem0.c ********************************************/ |
| 26797 | | -#line 1 "tsrc/mem0.c" |
| 26798 | 26796 | /* |
| 26799 | 26797 | ** 2008 October 28 |
| 26800 | 26798 | ** |
| 26801 | 26799 | ** The author disclaims copyright to this source code. In place of |
| 26802 | 26800 | ** a legal notice, here is a blessing: |
| | @@ -26855,11 +26853,10 @@ |
| 26855 | 26853 | |
| 26856 | 26854 | #endif /* SQLITE_ZERO_MALLOC */ |
| 26857 | 26855 | |
| 26858 | 26856 | /************** End of mem0.c ************************************************/ |
| 26859 | 26857 | /************** Begin file mem1.c ********************************************/ |
| 26860 | | -#line 1 "tsrc/mem1.c" |
| 26861 | 26858 | /* |
| 26862 | 26859 | ** 2007 August 14 |
| 26863 | 26860 | ** |
| 26864 | 26861 | ** The author disclaims copyright to this source code. In place of |
| 26865 | 26862 | ** a legal notice, here is a blessing: |
| | @@ -27150,11 +27147,10 @@ |
| 27150 | 27147 | |
| 27151 | 27148 | #endif /* SQLITE_SYSTEM_MALLOC */ |
| 27152 | 27149 | |
| 27153 | 27150 | /************** End of mem1.c ************************************************/ |
| 27154 | 27151 | /************** Begin file mem2.c ********************************************/ |
| 27155 | | -#line 1 "tsrc/mem2.c" |
| 27156 | 27152 | /* |
| 27157 | 27153 | ** 2007 August 15 |
| 27158 | 27154 | ** |
| 27159 | 27155 | ** The author disclaims copyright to this source code. In place of |
| 27160 | 27156 | ** a legal notice, here is a blessing: |
| | @@ -27682,11 +27678,10 @@ |
| 27682 | 27678 | |
| 27683 | 27679 | #endif /* SQLITE_MEMDEBUG */ |
| 27684 | 27680 | |
| 27685 | 27681 | /************** End of mem2.c ************************************************/ |
| 27686 | 27682 | /************** Begin file mem3.c ********************************************/ |
| 27687 | | -#line 1 "tsrc/mem3.c" |
| 27688 | 27683 | /* |
| 27689 | 27684 | ** 2007 October 14 |
| 27690 | 27685 | ** |
| 27691 | 27686 | ** The author disclaims copyright to this source code. In place of |
| 27692 | 27687 | ** a legal notice, here is a blessing: |
| | @@ -28373,11 +28368,10 @@ |
| 28373 | 28368 | |
| 28374 | 28369 | #endif /* SQLITE_ENABLE_MEMSYS3 */ |
| 28375 | 28370 | |
| 28376 | 28371 | /************** End of mem3.c ************************************************/ |
| 28377 | 28372 | /************** Begin file mem5.c ********************************************/ |
| 28378 | | -#line 1 "tsrc/mem5.c" |
| 28379 | 28373 | /* |
| 28380 | 28374 | ** 2007 October 14 |
| 28381 | 28375 | ** |
| 28382 | 28376 | ** The author disclaims copyright to this source code. In place of |
| 28383 | 28377 | ** a legal notice, here is a blessing: |
| | @@ -28962,11 +28956,10 @@ |
| 28962 | 28956 | |
| 28963 | 28957 | #endif /* SQLITE_ENABLE_MEMSYS5 */ |
| 28964 | 28958 | |
| 28965 | 28959 | /************** End of mem5.c ************************************************/ |
| 28966 | 28960 | /************** Begin file mutex.c *******************************************/ |
| 28967 | | -#line 1 "tsrc/mutex.c" |
| 28968 | 28961 | /* |
| 28969 | 28962 | ** 2007 August 14 |
| 28970 | 28963 | ** |
| 28971 | 28964 | ** The author disclaims copyright to this source code. In place of |
| 28972 | 28965 | ** a legal notice, here is a blessing: |
| | @@ -29340,11 +29333,10 @@ |
| 29340 | 29333 | |
| 29341 | 29334 | #endif /* !defined(SQLITE_MUTEX_OMIT) */ |
| 29342 | 29335 | |
| 29343 | 29336 | /************** End of mutex.c ***********************************************/ |
| 29344 | 29337 | /************** Begin file mutex_noop.c **************************************/ |
| 29345 | | -#line 1 "tsrc/mutex_noop.c" |
| 29346 | 29338 | /* |
| 29347 | 29339 | ** 2008 October 07 |
| 29348 | 29340 | ** |
| 29349 | 29341 | ** The author disclaims copyright to this source code. In place of |
| 29350 | 29342 | ** a legal notice, here is a blessing: |
| | @@ -29559,11 +29551,10 @@ |
| 29559 | 29551 | #endif /* defined(SQLITE_MUTEX_NOOP) */ |
| 29560 | 29552 | #endif /* !defined(SQLITE_MUTEX_OMIT) */ |
| 29561 | 29553 | |
| 29562 | 29554 | /************** End of mutex_noop.c ******************************************/ |
| 29563 | 29555 | /************** Begin file mutex_unix.c **************************************/ |
| 29564 | | -#line 1 "tsrc/mutex_unix.c" |
| 29565 | 29556 | /* |
| 29566 | 29557 | ** 2007 August 28 |
| 29567 | 29558 | ** |
| 29568 | 29559 | ** The author disclaims copyright to this source code. In place of |
| 29569 | 29560 | ** a legal notice, here is a blessing: |
| | @@ -29957,11 +29948,10 @@ |
| 29957 | 29948 | |
| 29958 | 29949 | #endif /* SQLITE_MUTEX_PTHREADS */ |
| 29959 | 29950 | |
| 29960 | 29951 | /************** End of mutex_unix.c ******************************************/ |
| 29961 | 29952 | /************** Begin file mutex_w32.c ***************************************/ |
| 29962 | | -#line 1 "tsrc/mutex_w32.c" |
| 29963 | 29953 | /* |
| 29964 | 29954 | ** 2007 August 14 |
| 29965 | 29955 | ** |
| 29966 | 29956 | ** The author disclaims copyright to this source code. In place of |
| 29967 | 29957 | ** a legal notice, here is a blessing: |
| | @@ -29984,11 +29974,10 @@ |
| 29984 | 29974 | /* |
| 29985 | 29975 | ** Include the header file for the Windows VFS. |
| 29986 | 29976 | */ |
| 29987 | 29977 | /************** Include os_win.h in the middle of mutex_w32.c ****************/ |
| 29988 | 29978 | /************** Begin file os_win.h ******************************************/ |
| 29989 | | -#line 1 "tsrc/os_win.h" |
| 29990 | 29979 | /* |
| 29991 | 29980 | ** 2013 November 25 |
| 29992 | 29981 | ** |
| 29993 | 29982 | ** The author disclaims copyright to this source code. In place of |
| 29994 | 29983 | ** a legal notice, here is a blessing: |
| | @@ -30076,11 +30065,10 @@ |
| 30076 | 30065 | |
| 30077 | 30066 | #endif /* SQLITE_OS_WIN_H */ |
| 30078 | 30067 | |
| 30079 | 30068 | /************** End of os_win.h **********************************************/ |
| 30080 | 30069 | /************** Continuing where we left off in mutex_w32.c ******************/ |
| 30081 | | -#line 26 "tsrc/mutex_w32.c" |
| 30082 | 30070 | #endif |
| 30083 | 30071 | |
| 30084 | 30072 | /* |
| 30085 | 30073 | ** The code in this file is only used if we are compiling multithreaded |
| 30086 | 30074 | ** on a Win32 system. |
| | @@ -30454,11 +30442,10 @@ |
| 30454 | 30442 | |
| 30455 | 30443 | #endif /* SQLITE_MUTEX_W32 */ |
| 30456 | 30444 | |
| 30457 | 30445 | /************** End of mutex_w32.c *******************************************/ |
| 30458 | 30446 | /************** Begin file malloc.c ******************************************/ |
| 30459 | | -#line 1 "tsrc/malloc.c" |
| 30460 | 30447 | /* |
| 30461 | 30448 | ** 2001 September 15 |
| 30462 | 30449 | ** |
| 30463 | 30450 | ** The author disclaims copyright to this source code. In place of |
| 30464 | 30451 | ** a legal notice, here is a blessing: |
| | @@ -31378,11 +31365,10 @@ |
| 31378 | 31365 | return 0; |
| 31379 | 31366 | } |
| 31380 | 31367 | |
| 31381 | 31368 | /************** End of malloc.c **********************************************/ |
| 31382 | 31369 | /************** Begin file printf.c ******************************************/ |
| 31383 | | -#line 1 "tsrc/printf.c" |
| 31384 | 31370 | /* |
| 31385 | 31371 | ** The "printf" code that follows dates from the 1980's. It is in |
| 31386 | 31372 | ** the public domain. |
| 31387 | 31373 | ** |
| 31388 | 31374 | ************************************************************************** |
| | @@ -32319,10 +32305,11 @@ |
| 32319 | 32305 | && (ExprHasProperty(pExpr,EP_OuterON|EP_InnerON) || pExpr->w.iOfst<=0) |
| 32320 | 32306 | ){ |
| 32321 | 32307 | pExpr = pExpr->pLeft; |
| 32322 | 32308 | } |
| 32323 | 32309 | if( pExpr==0 ) return; |
| 32310 | + if( ExprHasProperty(pExpr, EP_FromDDL) ) return; |
| 32324 | 32311 | db->errByteOffset = pExpr->w.iOfst; |
| 32325 | 32312 | } |
| 32326 | 32313 | |
| 32327 | 32314 | /* |
| 32328 | 32315 | ** Enlarge the memory allocation on a StrAccum object so that it is |
| | @@ -32828,11 +32815,10 @@ |
| 32828 | 32815 | } |
| 32829 | 32816 | } |
| 32830 | 32817 | |
| 32831 | 32818 | /************** End of printf.c **********************************************/ |
| 32832 | 32819 | /************** Begin file treeview.c ****************************************/ |
| 32833 | | -#line 1 "tsrc/treeview.c" |
| 32834 | 32820 | /* |
| 32835 | 32821 | ** 2015-06-08 |
| 32836 | 32822 | ** |
| 32837 | 32823 | ** The author disclaims copyright to this source code. In place of |
| 32838 | 32824 | ** a legal notice, here is a blessing: |
| | @@ -33049,11 +33035,11 @@ |
| 33049 | 33035 | } |
| 33050 | 33036 | if( pItem->fg.isCte ){ |
| 33051 | 33037 | sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse); |
| 33052 | 33038 | } |
| 33053 | 33039 | if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){ |
| 33054 | | - sqlite3_str_appendf(&x, " ON"); |
| 33040 | + sqlite3_str_appendf(&x, " isOn"); |
| 33055 | 33041 | } |
| 33056 | 33042 | if( pItem->fg.isTabFunc ) sqlite3_str_appendf(&x, " isTabFunc"); |
| 33057 | 33043 | if( pItem->fg.isCorrelated ) sqlite3_str_appendf(&x, " isCorrelated"); |
| 33058 | 33044 | if( pItem->fg.isMaterialized ) sqlite3_str_appendf(&x, " isMaterialized"); |
| 33059 | 33045 | if( pItem->fg.viaCoroutine ) sqlite3_str_appendf(&x, " viaCoroutine"); |
| | @@ -34133,10 +34119,14 @@ |
| 34133 | 34119 | ** |
| 34134 | 34120 | ** This routines are given external linkage so that they will always be |
| 34135 | 34121 | ** accessible to the debugging, and to avoid warnings about unused |
| 34136 | 34122 | ** functions. But these routines only exist in debugging builds, so they |
| 34137 | 34123 | ** do not contaminate the interface. |
| 34124 | +** |
| 34125 | +** See Also: |
| 34126 | +** |
| 34127 | +** sqlite3ShowWhereTerm() in where.c |
| 34138 | 34128 | */ |
| 34139 | 34129 | SQLITE_PRIVATE void sqlite3ShowExpr(const Expr *p){ sqlite3TreeViewExpr(0,p,0); } |
| 34140 | 34130 | SQLITE_PRIVATE void sqlite3ShowExprList(const ExprList *p){ sqlite3TreeViewExprList(0,p,0,0);} |
| 34141 | 34131 | SQLITE_PRIVATE void sqlite3ShowIdList(const IdList *p){ sqlite3TreeViewIdList(0,p,0,0); } |
| 34142 | 34132 | SQLITE_PRIVATE void sqlite3ShowSrcList(const SrcList *p){ sqlite3TreeViewSrcList(0,p); } |
| | @@ -34160,11 +34150,10 @@ |
| 34160 | 34150 | |
| 34161 | 34151 | #endif /* SQLITE_DEBUG */ |
| 34162 | 34152 | |
| 34163 | 34153 | /************** End of treeview.c ********************************************/ |
| 34164 | 34154 | /************** Begin file random.c ******************************************/ |
| 34165 | | -#line 1 "tsrc/random.c" |
| 34166 | 34155 | /* |
| 34167 | 34156 | ** 2001 September 15 |
| 34168 | 34157 | ** |
| 34169 | 34158 | ** The author disclaims copyright to this source code. In place of |
| 34170 | 34159 | ** a legal notice, here is a blessing: |
| | @@ -34321,11 +34310,10 @@ |
| 34321 | 34310 | } |
| 34322 | 34311 | #endif /* SQLITE_UNTESTABLE */ |
| 34323 | 34312 | |
| 34324 | 34313 | /************** End of random.c **********************************************/ |
| 34325 | 34314 | /************** Begin file threads.c *****************************************/ |
| 34326 | | -#line 1 "tsrc/threads.c" |
| 34327 | 34315 | /* |
| 34328 | 34316 | ** 2012 July 21 |
| 34329 | 34317 | ** |
| 34330 | 34318 | ** The author disclaims copyright to this source code. In place of |
| 34331 | 34319 | ** a legal notice, here is a blessing: |
| | @@ -34599,11 +34587,10 @@ |
| 34599 | 34587 | /****************************** End Single-Threaded *************************/ |
| 34600 | 34588 | #endif /* SQLITE_MAX_WORKER_THREADS>0 */ |
| 34601 | 34589 | |
| 34602 | 34590 | /************** End of threads.c *********************************************/ |
| 34603 | 34591 | /************** Begin file utf.c *********************************************/ |
| 34604 | | -#line 1 "tsrc/utf.c" |
| 34605 | 34592 | /* |
| 34606 | 34593 | ** 2004 April 13 |
| 34607 | 34594 | ** |
| 34608 | 34595 | ** The author disclaims copyright to this source code. In place of |
| 34609 | 34596 | ** a legal notice, here is a blessing: |
| | @@ -35171,11 +35158,10 @@ |
| 35171 | 35158 | #endif /* SQLITE_TEST */ |
| 35172 | 35159 | #endif /* SQLITE_OMIT_UTF16 */ |
| 35173 | 35160 | |
| 35174 | 35161 | /************** End of utf.c *************************************************/ |
| 35175 | 35162 | /************** Begin file util.c ********************************************/ |
| 35176 | | -#line 1 "tsrc/util.c" |
| 35177 | 35163 | /* |
| 35178 | 35164 | ** 2001 September 15 |
| 35179 | 35165 | ** |
| 35180 | 35166 | ** The author disclaims copyright to this source code. In place of |
| 35181 | 35167 | ** a legal notice, here is a blessing: |
| | @@ -35713,12 +35699,12 @@ |
| 35713 | 35699 | int esign = 1; /* sign of exponent */ |
| 35714 | 35700 | int e = 0; /* exponent */ |
| 35715 | 35701 | int eValid = 1; /* True exponent is either not used or is well-formed */ |
| 35716 | 35702 | int nDigit = 0; /* Number of digits processed */ |
| 35717 | 35703 | int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ |
| 35704 | + u64 s2; /* round-tripped significand */ |
| 35718 | 35705 | double rr[2]; |
| 35719 | | - u64 s2; |
| 35720 | 35706 | |
| 35721 | 35707 | assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); |
| 35722 | 35708 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 35723 | 35709 | if( length==0 ) return 0; |
| 35724 | 35710 | |
| | @@ -35817,25 +35803,36 @@ |
| 35817 | 35803 | |
| 35818 | 35804 | /* adjust exponent by d, and update sign */ |
| 35819 | 35805 | e = (e*esign) + d; |
| 35820 | 35806 | |
| 35821 | 35807 | /* Try to adjust the exponent to make it smaller */ |
| 35822 | | - while( e>0 && s<(LARGEST_UINT64/10) ){ |
| 35808 | + while( e>0 && s<((LARGEST_UINT64-0x7ff)/10) ){ |
| 35823 | 35809 | s *= 10; |
| 35824 | 35810 | e--; |
| 35825 | 35811 | } |
| 35826 | 35812 | while( e<0 && (s%10)==0 ){ |
| 35827 | 35813 | s /= 10; |
| 35828 | 35814 | e++; |
| 35829 | 35815 | } |
| 35830 | 35816 | |
| 35831 | 35817 | rr[0] = (double)s; |
| 35832 | | - s2 = (u64)rr[0]; |
| 35833 | | -#if defined(_MSC_VER) && _MSC_VER<1700 |
| 35834 | | - if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); } |
| 35818 | + assert( sizeof(s2)==sizeof(rr[0]) ); |
| 35819 | +#ifdef SQLITE_DEBUG |
| 35820 | + rr[1] = 18446744073709549568.0; |
| 35821 | + memcpy(&s2, &rr[1], sizeof(s2)); |
| 35822 | + assert( s2==0x43efffffffffffffLL ); |
| 35835 | 35823 | #endif |
| 35836 | | - rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s); |
| 35824 | + /* Largest double that can be safely converted to u64 |
| 35825 | + ** vvvvvvvvvvvvvvvvvvvvvv */ |
| 35826 | + if( rr[0]<=18446744073709549568.0 ){ |
| 35827 | + s2 = (u64)rr[0]; |
| 35828 | + rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s); |
| 35829 | + }else{ |
| 35830 | + rr[1] = 0.0; |
| 35831 | + } |
| 35832 | + assert( rr[1]<=1.0e-10*rr[0] ); /* Equal only when rr[0]==0.0 */ |
| 35833 | + |
| 35837 | 35834 | if( e>0 ){ |
| 35838 | 35835 | while( e>=100 ){ |
| 35839 | 35836 | e -= 100; |
| 35840 | 35837 | dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); |
| 35841 | 35838 | } |
| | @@ -37023,11 +37020,10 @@ |
| 37023 | 37020 | return 0; |
| 37024 | 37021 | } |
| 37025 | 37022 | |
| 37026 | 37023 | /************** End of util.c ************************************************/ |
| 37027 | 37024 | /************** Begin file hash.c ********************************************/ |
| 37028 | | -#line 1 "tsrc/hash.c" |
| 37029 | 37025 | /* |
| 37030 | 37026 | ** 2001 September 22 |
| 37031 | 37027 | ** |
| 37032 | 37028 | ** The author disclaims copyright to this source code. In place of |
| 37033 | 37029 | ** a legal notice, here is a blessing: |
| | @@ -37297,11 +37293,10 @@ |
| 37297 | 37293 | return 0; |
| 37298 | 37294 | } |
| 37299 | 37295 | |
| 37300 | 37296 | /************** End of hash.c ************************************************/ |
| 37301 | 37297 | /************** Begin file opcodes.c *****************************************/ |
| 37302 | | -#line 1 "tsrc/opcodes.c" |
| 37303 | 37298 | /* Automatically generated. Do not edit */ |
| 37304 | 37299 | /* See the tool/mkopcodec.tcl script for details. */ |
| 37305 | 37300 | #if !defined(SQLITE_OMIT_EXPLAIN) \ |
| 37306 | 37301 | || defined(VDBE_PROFILE) \ |
| 37307 | 37302 | || defined(SQLITE_DEBUG) |
| | @@ -37507,11 +37502,10 @@ |
| 37507 | 37502 | } |
| 37508 | 37503 | #endif |
| 37509 | 37504 | |
| 37510 | 37505 | /************** End of opcodes.c *********************************************/ |
| 37511 | 37506 | /************** Begin file os_kv.c *******************************************/ |
| 37512 | | -#line 1 "tsrc/os_kv.c" |
| 37513 | 37507 | /* |
| 37514 | 37508 | ** 2022-09-06 |
| 37515 | 37509 | ** |
| 37516 | 37510 | ** The author disclaims copyright to this source code. In place of |
| 37517 | 37511 | ** a legal notice, here is a blessing: |
| | @@ -38490,11 +38484,10 @@ |
| 38490 | 38484 | } |
| 38491 | 38485 | #endif |
| 38492 | 38486 | |
| 38493 | 38487 | /************** End of os_kv.c ***********************************************/ |
| 38494 | 38488 | /************** Begin file os_unix.c *****************************************/ |
| 38495 | | -#line 1 "tsrc/os_unix.c" |
| 38496 | 38489 | /* |
| 38497 | 38490 | ** 2004 May 22 |
| 38498 | 38491 | ** |
| 38499 | 38492 | ** The author disclaims copyright to this source code. In place of |
| 38500 | 38493 | ** a legal notice, here is a blessing: |
| | @@ -42480,10 +42473,15 @@ |
| 42480 | 42473 | int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE); |
| 42481 | 42474 | return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK; |
| 42482 | 42475 | } |
| 42483 | 42476 | #endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ |
| 42484 | 42477 | |
| 42478 | + case SQLITE_FCNTL_NULL_IO: { |
| 42479 | + osClose(pFile->h); |
| 42480 | + pFile->h = -1; |
| 42481 | + return SQLITE_OK; |
| 42482 | + } |
| 42485 | 42483 | case SQLITE_FCNTL_LOCKSTATE: { |
| 42486 | 42484 | *(int*)pArg = pFile->eFileLock; |
| 42487 | 42485 | return SQLITE_OK; |
| 42488 | 42486 | } |
| 42489 | 42487 | case SQLITE_FCNTL_LAST_ERRNO: { |
| | @@ -46760,11 +46758,10 @@ |
| 46760 | 46758 | |
| 46761 | 46759 | #endif /* SQLITE_OS_UNIX */ |
| 46762 | 46760 | |
| 46763 | 46761 | /************** End of os_unix.c *********************************************/ |
| 46764 | 46762 | /************** Begin file os_win.c ******************************************/ |
| 46765 | | -#line 1 "tsrc/os_win.c" |
| 46766 | 46763 | /* |
| 46767 | 46764 | ** 2004 May 22 |
| 46768 | 46765 | ** |
| 46769 | 46766 | ** The author disclaims copyright to this source code. In place of |
| 46770 | 46767 | ** a legal notice, here is a blessing: |
| | @@ -50362,10 +50359,15 @@ |
| 50362 | 50359 | OSTRACE(("FCNTL oldFile=%p, newFile=%p, rc=SQLITE_OK\n", |
| 50363 | 50360 | hOldFile, pFile->h)); |
| 50364 | 50361 | return SQLITE_OK; |
| 50365 | 50362 | } |
| 50366 | 50363 | #endif |
| 50364 | + case SQLITE_FCNTL_NULL_IO: { |
| 50365 | + (void)osCloseHandle(pFile->h); |
| 50366 | + pFile->h = NULL; |
| 50367 | + return SQLITE_OK; |
| 50368 | + } |
| 50367 | 50369 | case SQLITE_FCNTL_TEMPFILENAME: { |
| 50368 | 50370 | char *zTFile = 0; |
| 50369 | 50371 | int rc = winGetTempname(pFile->pVfs, &zTFile); |
| 50370 | 50372 | if( rc==SQLITE_OK ){ |
| 50371 | 50373 | *(char**)pArg = zTFile; |
| | @@ -51811,11 +51813,11 @@ |
| 51811 | 51813 | */ |
| 51812 | 51814 | char *zTmpname = 0; /* For temporary filename, if necessary. */ |
| 51813 | 51815 | |
| 51814 | 51816 | int rc = SQLITE_OK; /* Function Return Code */ |
| 51815 | 51817 | #if !defined(NDEBUG) || SQLITE_OS_WINCE |
| 51816 | | - int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 51818 | + int eType = flags&0x0FFF00; /* Type of file to open */ |
| 51817 | 51819 | #endif |
| 51818 | 51820 | |
| 51819 | 51821 | int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); |
| 51820 | 51822 | int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE); |
| 51821 | 51823 | int isCreate = (flags & SQLITE_OPEN_CREATE); |
| | @@ -52975,11 +52977,10 @@ |
| 52975 | 52977 | |
| 52976 | 52978 | #endif /* SQLITE_OS_WIN */ |
| 52977 | 52979 | |
| 52978 | 52980 | /************** End of os_win.c **********************************************/ |
| 52979 | 52981 | /************** Begin file memdb.c *******************************************/ |
| 52980 | | -#line 1 "tsrc/memdb.c" |
| 52981 | 52982 | /* |
| 52982 | 52983 | ** 2016-09-07 |
| 52983 | 52984 | ** |
| 52984 | 52985 | ** The author disclaims copyright to this source code. In place of |
| 52985 | 52986 | ** a legal notice, here is a blessing: |
| | @@ -53915,11 +53916,10 @@ |
| 53915 | 53916 | } |
| 53916 | 53917 | #endif /* SQLITE_OMIT_DESERIALIZE */ |
| 53917 | 53918 | |
| 53918 | 53919 | /************** End of memdb.c ***********************************************/ |
| 53919 | 53920 | /************** Begin file bitvec.c ******************************************/ |
| 53920 | | -#line 1 "tsrc/bitvec.c" |
| 53921 | 53921 | /* |
| 53922 | 53922 | ** 2008 February 16 |
| 53923 | 53923 | ** |
| 53924 | 53924 | ** The author disclaims copyright to this source code. In place of |
| 53925 | 53925 | ** a legal notice, here is a blessing: |
| | @@ -54330,11 +54330,10 @@ |
| 54330 | 54330 | } |
| 54331 | 54331 | #endif /* SQLITE_UNTESTABLE */ |
| 54332 | 54332 | |
| 54333 | 54333 | /************** End of bitvec.c **********************************************/ |
| 54334 | 54334 | /************** Begin file pcache.c ******************************************/ |
| 54335 | | -#line 1 "tsrc/pcache.c" |
| 54336 | 54335 | /* |
| 54337 | 54336 | ** 2008 August 05 |
| 54338 | 54337 | ** |
| 54339 | 54338 | ** The author disclaims copyright to this source code. In place of |
| 54340 | 54339 | ** a legal notice, here is a blessing: |
| | @@ -55270,11 +55269,10 @@ |
| 55270 | 55269 | } |
| 55271 | 55270 | #endif |
| 55272 | 55271 | |
| 55273 | 55272 | /************** End of pcache.c **********************************************/ |
| 55274 | 55273 | /************** Begin file pcache1.c *****************************************/ |
| 55275 | | -#line 1 "tsrc/pcache1.c" |
| 55276 | 55274 | /* |
| 55277 | 55275 | ** 2008 November 05 |
| 55278 | 55276 | ** |
| 55279 | 55277 | ** The author disclaims copyright to this source code. In place of |
| 55280 | 55278 | ** a legal notice, here is a blessing: |
| | @@ -56556,11 +56554,10 @@ |
| 56556 | 56554 | } |
| 56557 | 56555 | #endif |
| 56558 | 56556 | |
| 56559 | 56557 | /************** End of pcache1.c *********************************************/ |
| 56560 | 56558 | /************** Begin file rowset.c ******************************************/ |
| 56561 | | -#line 1 "tsrc/rowset.c" |
| 56562 | 56559 | /* |
| 56563 | 56560 | ** 2008 December 3 |
| 56564 | 56561 | ** |
| 56565 | 56562 | ** The author disclaims copyright to this source code. In place of |
| 56566 | 56563 | ** a legal notice, here is a blessing: |
| | @@ -57062,11 +57059,10 @@ |
| 57062 | 57059 | return 0; |
| 57063 | 57060 | } |
| 57064 | 57061 | |
| 57065 | 57062 | /************** End of rowset.c **********************************************/ |
| 57066 | 57063 | /************** Begin file pager.c *******************************************/ |
| 57067 | | -#line 1 "tsrc/pager.c" |
| 57068 | 57064 | /* |
| 57069 | 57065 | ** 2001 September 15 |
| 57070 | 57066 | ** |
| 57071 | 57067 | ** The author disclaims copyright to this source code. In place of |
| 57072 | 57068 | ** a legal notice, here is a blessing: |
| | @@ -57087,11 +57083,10 @@ |
| 57087 | 57083 | */ |
| 57088 | 57084 | #ifndef SQLITE_OMIT_DISKIO |
| 57089 | 57085 | /* #include "sqliteInt.h" */ |
| 57090 | 57086 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 57091 | 57087 | /************** Begin file wal.h *********************************************/ |
| 57092 | | -#line 1 "tsrc/wal.h" |
| 57093 | 57088 | /* |
| 57094 | 57089 | ** 2010 February 1 |
| 57095 | 57090 | ** |
| 57096 | 57091 | ** The author disclaims copyright to this source code. In place of |
| 57097 | 57092 | ** a legal notice, here is a blessing: |
| | @@ -57251,11 +57246,10 @@ |
| 57251 | 57246 | #endif /* ifndef SQLITE_OMIT_WAL */ |
| 57252 | 57247 | #endif /* SQLITE_WAL_H */ |
| 57253 | 57248 | |
| 57254 | 57249 | /************** End of wal.h *************************************************/ |
| 57255 | 57250 | /************** Continuing where we left off in pager.c **********************/ |
| 57256 | | -#line 24 "tsrc/pager.c" |
| 57257 | 57251 | |
| 57258 | 57252 | |
| 57259 | 57253 | /******************* NOTES ON THE DESIGN OF THE PAGER ************************ |
| 57260 | 57254 | ** |
| 57261 | 57255 | ** This comment block describes invariants that hold when using a rollback |
| | @@ -65041,11 +65035,10 @@ |
| 65041 | 65035 | |
| 65042 | 65036 | #endif /* SQLITE_OMIT_DISKIO */ |
| 65043 | 65037 | |
| 65044 | 65038 | /************** End of pager.c ***********************************************/ |
| 65045 | 65039 | /************** Begin file wal.c *********************************************/ |
| 65046 | | -#line 1 "tsrc/wal.c" |
| 65047 | 65040 | /* |
| 65048 | 65041 | ** 2010 February 1 |
| 65049 | 65042 | ** |
| 65050 | 65043 | ** The author disclaims copyright to this source code. In place of |
| 65051 | 65044 | ** a legal notice, here is a blessing: |
| | @@ -69638,11 +69631,10 @@ |
| 69638 | 69631 | |
| 69639 | 69632 | #endif /* #ifndef SQLITE_OMIT_WAL */ |
| 69640 | 69633 | |
| 69641 | 69634 | /************** End of wal.c *************************************************/ |
| 69642 | 69635 | /************** Begin file btmutex.c *****************************************/ |
| 69643 | | -#line 1 "tsrc/btmutex.c" |
| 69644 | 69636 | /* |
| 69645 | 69637 | ** 2007 August 27 |
| 69646 | 69638 | ** |
| 69647 | 69639 | ** The author disclaims copyright to this source code. In place of |
| 69648 | 69640 | ** a legal notice, here is a blessing: |
| | @@ -69658,11 +69650,10 @@ |
| 69658 | 69650 | ** big and we want to break it down some. This packaged seemed like |
| 69659 | 69651 | ** a good breakout. |
| 69660 | 69652 | */ |
| 69661 | 69653 | /************** Include btreeInt.h in the middle of btmutex.c ****************/ |
| 69662 | 69654 | /************** Begin file btreeInt.h ****************************************/ |
| 69663 | | -#line 1 "tsrc/btreeInt.h" |
| 69664 | 69655 | /* |
| 69665 | 69656 | ** 2004 April 6 |
| 69666 | 69657 | ** |
| 69667 | 69658 | ** The author disclaims copyright to this source code. In place of |
| 69668 | 69659 | ** a legal notice, here is a blessing: |
| | @@ -70396,11 +70387,10 @@ |
| 70396 | 70387 | # define get2byteAligned(x) ((x)[0]<<8 | (x)[1]) |
| 70397 | 70388 | #endif |
| 70398 | 70389 | |
| 70399 | 70390 | /************** End of btreeInt.h ********************************************/ |
| 70400 | 70391 | /************** Continuing where we left off in btmutex.c ********************/ |
| 70401 | | -#line 19 "tsrc/btmutex.c" |
| 70402 | 70392 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 70403 | 70393 | #if SQLITE_THREADSAFE |
| 70404 | 70394 | |
| 70405 | 70395 | /* |
| 70406 | 70396 | ** Obtain the BtShared mutex associated with B-Tree handle p. Also, |
| | @@ -70691,11 +70681,10 @@ |
| 70691 | 70681 | |
| 70692 | 70682 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 70693 | 70683 | |
| 70694 | 70684 | /************** End of btmutex.c *********************************************/ |
| 70695 | 70685 | /************** Begin file btree.c *******************************************/ |
| 70696 | | -#line 1 "tsrc/btree.c" |
| 70697 | 70686 | /* |
| 70698 | 70687 | ** 2004 April 6 |
| 70699 | 70688 | ** |
| 70700 | 70689 | ** The author disclaims copyright to this source code. In place of |
| 70701 | 70690 | ** a legal notice, here is a blessing: |
| | @@ -82186,11 +82175,10 @@ |
| 82186 | 82175 | } |
| 82187 | 82176 | #endif |
| 82188 | 82177 | |
| 82189 | 82178 | /************** End of btree.c ***********************************************/ |
| 82190 | 82179 | /************** Begin file backup.c ******************************************/ |
| 82191 | | -#line 1 "tsrc/backup.c" |
| 82192 | 82180 | /* |
| 82193 | 82181 | ** 2009 January 28 |
| 82194 | 82182 | ** |
| 82195 | 82183 | ** The author disclaims copyright to this source code. In place of |
| 82196 | 82184 | ** a legal notice, here is a blessing: |
| | @@ -82957,11 +82945,10 @@ |
| 82957 | 82945 | } |
| 82958 | 82946 | #endif /* SQLITE_OMIT_VACUUM */ |
| 82959 | 82947 | |
| 82960 | 82948 | /************** End of backup.c **********************************************/ |
| 82961 | 82949 | /************** Begin file vdbemem.c *****************************************/ |
| 82962 | | -#line 1 "tsrc/vdbemem.c" |
| 82963 | 82950 | /* |
| 82964 | 82951 | ** 2004 May 26 |
| 82965 | 82952 | ** |
| 82966 | 82953 | ** The author disclaims copyright to this source code. In place of |
| 82967 | 82954 | ** a legal notice, here is a blessing: |
| | @@ -85014,11 +85001,10 @@ |
| 85014 | 85001 | return valueBytes(pVal, enc); |
| 85015 | 85002 | } |
| 85016 | 85003 | |
| 85017 | 85004 | /************** End of vdbemem.c *********************************************/ |
| 85018 | 85005 | /************** Begin file vdbeaux.c *****************************************/ |
| 85019 | | -#line 1 "tsrc/vdbeaux.c" |
| 85020 | 85006 | /* |
| 85021 | 85007 | ** 2003 September 6 |
| 85022 | 85008 | ** |
| 85023 | 85009 | ** The author disclaims copyright to this source code. In place of |
| 85024 | 85010 | ** a legal notice, here is a blessing: |
| | @@ -90566,11 +90552,10 @@ |
| 90566 | 90552 | } |
| 90567 | 90553 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 90568 | 90554 | |
| 90569 | 90555 | /************** End of vdbeaux.c *********************************************/ |
| 90570 | 90556 | /************** Begin file vdbeapi.c *****************************************/ |
| 90571 | | -#line 1 "tsrc/vdbeapi.c" |
| 90572 | 90557 | /* |
| 90573 | 90558 | ** 2004 May 26 |
| 90574 | 90559 | ** |
| 90575 | 90560 | ** The author disclaims copyright to this source code. In place of |
| 90576 | 90561 | ** a legal notice, here is a blessing: |
| | @@ -93153,11 +93138,10 @@ |
| 93153 | 93138 | } |
| 93154 | 93139 | #endif /* SQLITE_ENABLE_STMT_SCANSTATUS */ |
| 93155 | 93140 | |
| 93156 | 93141 | /************** End of vdbeapi.c *********************************************/ |
| 93157 | 93142 | /************** Begin file vdbetrace.c ***************************************/ |
| 93158 | | -#line 1 "tsrc/vdbetrace.c" |
| 93159 | 93143 | /* |
| 93160 | 93144 | ** 2009 November 25 |
| 93161 | 93145 | ** |
| 93162 | 93146 | ** The author disclaims copyright to this source code. In place of |
| 93163 | 93147 | ** a legal notice, here is a blessing: |
| | @@ -93349,11 +93333,10 @@ |
| 93349 | 93333 | |
| 93350 | 93334 | #endif /* #ifndef SQLITE_OMIT_TRACE */ |
| 93351 | 93335 | |
| 93352 | 93336 | /************** End of vdbetrace.c *******************************************/ |
| 93353 | 93337 | /************** Begin file vdbe.c ********************************************/ |
| 93354 | | -#line 1 "tsrc/vdbe.c" |
| 93355 | 93338 | /* |
| 93356 | 93339 | ** 2001 September 15 |
| 93357 | 93340 | ** |
| 93358 | 93341 | ** The author disclaims copyright to this source code. In place of |
| 93359 | 93342 | ** a legal notice, here is a blessing: |
| | @@ -93381,11 +93364,10 @@ |
| 93381 | 93364 | #if defined(VDBE_PROFILE) \ |
| 93382 | 93365 | || defined(SQLITE_PERFORMANCE_TRACE) \ |
| 93383 | 93366 | || defined(SQLITE_ENABLE_STMT_SCANSTATUS) |
| 93384 | 93367 | /************** Include hwtime.h in the middle of vdbe.c *********************/ |
| 93385 | 93368 | /************** Begin file hwtime.h ******************************************/ |
| 93386 | | -#line 1 "tsrc/hwtime.h" |
| 93387 | 93369 | /* |
| 93388 | 93370 | ** 2008 May 27 |
| 93389 | 93371 | ** |
| 93390 | 93372 | ** The author disclaims copyright to this source code. In place of |
| 93391 | 93373 | ** a legal notice, here is a blessing: |
| | @@ -93470,11 +93452,10 @@ |
| 93470 | 93452 | |
| 93471 | 93453 | #endif /* !defined(SQLITE_HWTIME_H) */ |
| 93472 | 93454 | |
| 93473 | 93455 | /************** End of hwtime.h **********************************************/ |
| 93474 | 93456 | /************** Continuing where we left off in vdbe.c ***********************/ |
| 93475 | | -#line 31 "tsrc/vdbe.c" |
| 93476 | 93457 | #endif |
| 93477 | 93458 | |
| 93478 | 93459 | /* |
| 93479 | 93460 | ** Invoke this macro on memory cells just prior to changing the |
| 93480 | 93461 | ** value of the cell. This macro verifies that shallow copies are |
| | @@ -102664,11 +102645,10 @@ |
| 102664 | 102645 | } |
| 102665 | 102646 | |
| 102666 | 102647 | |
| 102667 | 102648 | /************** End of vdbe.c ************************************************/ |
| 102668 | 102649 | /************** Begin file vdbeblob.c ****************************************/ |
| 102669 | | -#line 1 "tsrc/vdbeblob.c" |
| 102670 | 102650 | /* |
| 102671 | 102651 | ** 2007 May 1 |
| 102672 | 102652 | ** |
| 102673 | 102653 | ** The author disclaims copyright to this source code. In place of |
| 102674 | 102654 | ** a legal notice, here is a blessing: |
| | @@ -103188,11 +103168,10 @@ |
| 103188 | 103168 | |
| 103189 | 103169 | #endif /* #ifndef SQLITE_OMIT_INCRBLOB */ |
| 103190 | 103170 | |
| 103191 | 103171 | /************** End of vdbeblob.c ********************************************/ |
| 103192 | 103172 | /************** Begin file vdbesort.c ****************************************/ |
| 103193 | | -#line 1 "tsrc/vdbesort.c" |
| 103194 | 103173 | /* |
| 103195 | 103174 | ** 2011-07-09 |
| 103196 | 103175 | ** |
| 103197 | 103176 | ** The author disclaims copyright to this source code. In place of |
| 103198 | 103177 | ** a legal notice, here is a blessing: |
| | @@ -105959,11 +105938,10 @@ |
| 105959 | 105938 | return SQLITE_OK; |
| 105960 | 105939 | } |
| 105961 | 105940 | |
| 105962 | 105941 | /************** End of vdbesort.c ********************************************/ |
| 105963 | 105942 | /************** Begin file vdbevtab.c ****************************************/ |
| 105964 | | -#line 1 "tsrc/vdbevtab.c" |
| 105965 | 105943 | /* |
| 105966 | 105944 | ** 2020-03-23 |
| 105967 | 105945 | ** |
| 105968 | 105946 | ** The author disclaims copyright to this source code. In place of |
| 105969 | 105947 | ** a legal notice, here is a blessing: |
| | @@ -106409,11 +106387,10 @@ |
| 106409 | 106387 | SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3 *db){ return SQLITE_OK; } |
| 106410 | 106388 | #endif /* SQLITE_ENABLE_BYTECODE_VTAB */ |
| 106411 | 106389 | |
| 106412 | 106390 | /************** End of vdbevtab.c ********************************************/ |
| 106413 | 106391 | /************** Begin file memjournal.c **************************************/ |
| 106414 | | -#line 1 "tsrc/memjournal.c" |
| 106415 | 106392 | /* |
| 106416 | 106393 | ** 2008 October 7 |
| 106417 | 106394 | ** |
| 106418 | 106395 | ** The author disclaims copyright to this source code. In place of |
| 106419 | 106396 | ** a legal notice, here is a blessing: |
| | @@ -106853,11 +106830,10 @@ |
| 106853 | 106830 | return MAX(pVfs->szOsFile, (int)sizeof(MemJournal)); |
| 106854 | 106831 | } |
| 106855 | 106832 | |
| 106856 | 106833 | /************** End of memjournal.c ******************************************/ |
| 106857 | 106834 | /************** Begin file walker.c ******************************************/ |
| 106858 | | -#line 1 "tsrc/walker.c" |
| 106859 | 106835 | /* |
| 106860 | 106836 | ** 2008 August 16 |
| 106861 | 106837 | ** |
| 106862 | 106838 | ** The author disclaims copyright to this source code. In place of |
| 106863 | 106839 | ** a legal notice, here is a blessing: |
| | @@ -107118,11 +107094,10 @@ |
| 107118 | 107094 | return WRC_Continue; |
| 107119 | 107095 | } |
| 107120 | 107096 | |
| 107121 | 107097 | /************** End of walker.c **********************************************/ |
| 107122 | 107098 | /************** Begin file resolve.c *****************************************/ |
| 107123 | | -#line 1 "tsrc/resolve.c" |
| 107124 | 107099 | /* |
| 107125 | 107100 | ** 2008 August 18 |
| 107126 | 107101 | ** |
| 107127 | 107102 | ** The author disclaims copyright to this source code. In place of |
| 107128 | 107103 | ** a legal notice, here is a blessing: |
| | @@ -109440,11 +109415,10 @@ |
| 109440 | 109415 | return rc; |
| 109441 | 109416 | } |
| 109442 | 109417 | |
| 109443 | 109418 | /************** End of resolve.c *********************************************/ |
| 109444 | 109419 | /************** Begin file expr.c ********************************************/ |
| 109445 | | -#line 1 "tsrc/expr.c" |
| 109446 | 109420 | /* |
| 109447 | 109421 | ** 2001 September 15 |
| 109448 | 109422 | ** |
| 109449 | 109423 | ** The author disclaims copyright to this source code. In place of |
| 109450 | 109424 | ** a legal notice, here is a blessing: |
| | @@ -112089,11 +112063,11 @@ |
| 112089 | 112063 | ** |
| 112090 | 112064 | ** (4) If pSrc is the right operand of a LEFT JOIN, then... |
| 112091 | 112065 | ** (4a) pExpr must come from an ON clause.. |
| 112092 | 112066 | ** (4b) and specifically the ON clause associated with the LEFT JOIN. |
| 112093 | 112067 | ** |
| 112094 | | -** (5) If pSrc is not the right operand of a LEFT JOIN or the left |
| 112068 | +** (5) If pSrc is the right operand of a LEFT JOIN or the left |
| 112095 | 112069 | ** operand of a RIGHT JOIN, then pExpr must be from the WHERE |
| 112096 | 112070 | ** clause, not an ON clause. |
| 112097 | 112071 | ** |
| 112098 | 112072 | ** (6) Either: |
| 112099 | 112073 | ** |
| | @@ -115623,35 +115597,41 @@ |
| 115623 | 115597 | ** |
| 115624 | 115598 | ** Additionally, if pExpr is a simple SQL value and the value is the |
| 115625 | 115599 | ** same as that currently bound to variable pVar, non-zero is returned. |
| 115626 | 115600 | ** Otherwise, if the values are not the same or if pExpr is not a simple |
| 115627 | 115601 | ** SQL value, zero is returned. |
| 115602 | +** |
| 115603 | +** If the SQLITE_EnableQPSG flag is set on the database connection, then |
| 115604 | +** this routine always returns false. |
| 115628 | 115605 | */ |
| 115629 | | -static int exprCompareVariable( |
| 115606 | +static SQLITE_NOINLINE int exprCompareVariable( |
| 115630 | 115607 | const Parse *pParse, |
| 115631 | 115608 | const Expr *pVar, |
| 115632 | 115609 | const Expr *pExpr |
| 115633 | 115610 | ){ |
| 115634 | | - int res = 0; |
| 115611 | + int res = 2; |
| 115635 | 115612 | int iVar; |
| 115636 | 115613 | sqlite3_value *pL, *pR = 0; |
| 115637 | 115614 | |
| 115615 | + if( pExpr->op==TK_VARIABLE && pVar->iColumn==pExpr->iColumn ){ |
| 115616 | + return 0; |
| 115617 | + } |
| 115618 | + if( (pParse->db->flags & SQLITE_EnableQPSG)!=0 ) return 2; |
| 115638 | 115619 | sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR); |
| 115639 | 115620 | if( pR ){ |
| 115640 | 115621 | iVar = pVar->iColumn; |
| 115641 | 115622 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); |
| 115642 | 115623 | pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB); |
| 115643 | 115624 | if( pL ){ |
| 115644 | 115625 | if( sqlite3_value_type(pL)==SQLITE_TEXT ){ |
| 115645 | 115626 | sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */ |
| 115646 | 115627 | } |
| 115647 | | - res = 0==sqlite3MemCompare(pL, pR, 0); |
| 115628 | + res = sqlite3MemCompare(pL, pR, 0) ? 2 : 0; |
| 115648 | 115629 | } |
| 115649 | 115630 | sqlite3ValueFree(pR); |
| 115650 | 115631 | sqlite3ValueFree(pL); |
| 115651 | 115632 | } |
| 115652 | | - |
| 115653 | 115633 | return res; |
| 115654 | 115634 | } |
| 115655 | 115635 | |
| 115656 | 115636 | /* |
| 115657 | 115637 | ** Do a deep comparison of two expression trees. Return 0 if the two |
| | @@ -115673,16 +115653,14 @@ |
| 115673 | 115653 | ** can be sure the expressions are the same. In the places where |
| 115674 | 115654 | ** this routine is used, it does not hurt to get an extra 2 - that |
| 115675 | 115655 | ** just might result in some slightly slower code. But returning |
| 115676 | 115656 | ** an incorrect 0 or 1 could lead to a malfunction. |
| 115677 | 115657 | ** |
| 115678 | | -** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in |
| 115679 | | -** pParse->pReprepare can be matched against literals in pB. The |
| 115680 | | -** pParse->pVdbe->expmask bitmask is updated for each variable referenced. |
| 115681 | | -** If pParse is NULL (the normal case) then any TK_VARIABLE term in |
| 115682 | | -** Argument pParse should normally be NULL. If it is not NULL and pA or |
| 115683 | | -** pB causes a return value of 2. |
| 115658 | +** If pParse is not NULL and SQLITE_EnableQPSG is off then TK_VARIABLE |
| 115659 | +** terms in pA with bindings in pParse->pReprepare can be matched against |
| 115660 | +** literals in pB. The pParse->pVdbe->expmask bitmask is updated for |
| 115661 | +** each variable referenced. |
| 115684 | 115662 | */ |
| 115685 | 115663 | SQLITE_PRIVATE int sqlite3ExprCompare( |
| 115686 | 115664 | const Parse *pParse, |
| 115687 | 115665 | const Expr *pA, |
| 115688 | 115666 | const Expr *pB, |
| | @@ -115690,12 +115668,12 @@ |
| 115690 | 115668 | ){ |
| 115691 | 115669 | u32 combinedFlags; |
| 115692 | 115670 | if( pA==0 || pB==0 ){ |
| 115693 | 115671 | return pB==pA ? 0 : 2; |
| 115694 | 115672 | } |
| 115695 | | - if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){ |
| 115696 | | - return 0; |
| 115673 | + if( pParse && pA->op==TK_VARIABLE ){ |
| 115674 | + return exprCompareVariable(pParse, pA, pB); |
| 115697 | 115675 | } |
| 115698 | 115676 | combinedFlags = pA->flags | pB->flags; |
| 115699 | 115677 | if( combinedFlags & EP_IntValue ){ |
| 115700 | 115678 | if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){ |
| 115701 | 115679 | return 0; |
| | @@ -115885,23 +115863,75 @@ |
| 115885 | 115863 | return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1); |
| 115886 | 115864 | } |
| 115887 | 115865 | } |
| 115888 | 115866 | return 0; |
| 115889 | 115867 | } |
| 115868 | + |
| 115869 | +/* |
| 115870 | +** Return true if the boolean value of the expression is always either |
| 115871 | +** FALSE or NULL. |
| 115872 | +*/ |
| 115873 | +static int sqlite3ExprIsNotTrue(Expr *pExpr){ |
| 115874 | + int v; |
| 115875 | + if( pExpr->op==TK_NULL ) return 1; |
| 115876 | + if( pExpr->op==TK_TRUEFALSE && sqlite3ExprTruthValue(pExpr)==0 ) return 1; |
| 115877 | + v = 1; |
| 115878 | + if( sqlite3ExprIsInteger(pExpr, &v, 0) && v==0 ) return 1; |
| 115879 | + return 0; |
| 115880 | +} |
| 115881 | + |
| 115882 | +/* |
| 115883 | +** Return true if the expression is one of the following: |
| 115884 | +** |
| 115885 | +** CASE WHEN x THEN y END |
| 115886 | +** CASE WHEN x THEN y ELSE NULL END |
| 115887 | +** CASE WHEN x THEN y ELSE false END |
| 115888 | +** iif(x,y) |
| 115889 | +** iif(x,y,NULL) |
| 115890 | +** iif(x,y,false) |
| 115891 | +*/ |
| 115892 | +static int sqlite3ExprIsIIF(sqlite3 *db, const Expr *pExpr){ |
| 115893 | + ExprList *pList; |
| 115894 | + if( pExpr->op==TK_FUNCTION ){ |
| 115895 | + const char *z = pExpr->u.zToken; |
| 115896 | + FuncDef *pDef; |
| 115897 | + if( (z[0]!='i' && z[0]!='I') ) return 0; |
| 115898 | + if( pExpr->x.pList==0 ) return 0; |
| 115899 | + pDef = sqlite3FindFunction(db, z, pExpr->x.pList->nExpr, ENC(db), 0); |
| 115900 | +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 115901 | + if( pDef==0 ) return 0; |
| 115902 | +#else |
| 115903 | + if( NEVER(pDef==0) ) return 0; |
| 115904 | +#endif |
| 115905 | + if( (pDef->funcFlags & SQLITE_FUNC_INLINE)==0 ) return 0; |
| 115906 | + if( SQLITE_PTR_TO_INT(pDef->pUserData)!=INLINEFUNC_iif ) return 0; |
| 115907 | + }else if( pExpr->op==TK_CASE ){ |
| 115908 | + if( pExpr->pLeft!=0 ) return 0; |
| 115909 | + }else{ |
| 115910 | + return 0; |
| 115911 | + } |
| 115912 | + pList = pExpr->x.pList; |
| 115913 | + assert( pList!=0 ); |
| 115914 | + if( pList->nExpr==2 ) return 1; |
| 115915 | + if( pList->nExpr==3 && sqlite3ExprIsNotTrue(pList->a[2].pExpr) ) return 1; |
| 115916 | + return 0; |
| 115917 | +} |
| 115890 | 115918 | |
| 115891 | 115919 | /* |
| 115892 | 115920 | ** Return true if we can prove the pE2 will always be true if pE1 is |
| 115893 | 115921 | ** true. Return false if we cannot complete the proof or if pE2 might |
| 115894 | 115922 | ** be false. Examples: |
| 115895 | 115923 | ** |
| 115896 | | -** pE1: x==5 pE2: x==5 Result: true |
| 115897 | | -** pE1: x>0 pE2: x==5 Result: false |
| 115898 | | -** pE1: x=21 pE2: x=21 OR y=43 Result: true |
| 115899 | | -** pE1: x!=123 pE2: x IS NOT NULL Result: true |
| 115900 | | -** pE1: x!=?1 pE2: x IS NOT NULL Result: true |
| 115901 | | -** pE1: x IS NULL pE2: x IS NOT NULL Result: false |
| 115902 | | -** pE1: x IS ?2 pE2: x IS NOT NULL Result: false |
| 115924 | +** pE1: x==5 pE2: x==5 Result: true |
| 115925 | +** pE1: x>0 pE2: x==5 Result: false |
| 115926 | +** pE1: x=21 pE2: x=21 OR y=43 Result: true |
| 115927 | +** pE1: x!=123 pE2: x IS NOT NULL Result: true |
| 115928 | +** pE1: x!=?1 pE2: x IS NOT NULL Result: true |
| 115929 | +** pE1: x IS NULL pE2: x IS NOT NULL Result: false |
| 115930 | +** pE1: x IS ?2 pE2: x IS NOT NULL Result: false |
| 115931 | +** pE1: iif(x,y) pE2: x Result: true |
| 115932 | +** PE1: iif(x,y,0) pE2: x Result: true |
| 115903 | 115933 | ** |
| 115904 | 115934 | ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has |
| 115905 | 115935 | ** Expr.iTable<0 then assume a table number given by iTab. |
| 115906 | 115936 | ** |
| 115907 | 115937 | ** If pParse is not NULL, then the values of bound variables in pE1 are |
| | @@ -115931,10 +115961,13 @@ |
| 115931 | 115961 | if( pE2->op==TK_NOTNULL |
| 115932 | 115962 | && exprImpliesNotNull(pParse, pE1, pE2->pLeft, iTab, 0) |
| 115933 | 115963 | ){ |
| 115934 | 115964 | return 1; |
| 115935 | 115965 | } |
| 115966 | + if( sqlite3ExprIsIIF(pParse->db, pE1) ){ |
| 115967 | + return sqlite3ExprImpliesExpr(pParse,pE1->x.pList->a[0].pExpr,pE2,iTab); |
| 115968 | + } |
| 115936 | 115969 | return 0; |
| 115937 | 115970 | } |
| 115938 | 115971 | |
| 115939 | 115972 | /* This is a helper function to impliesNotNullRow(). In this routine, |
| 115940 | 115973 | ** set pWalker->eCode to one only if *both* of the input expressions |
| | @@ -116770,11 +116803,10 @@ |
| 116770 | 116803 | } |
| 116771 | 116804 | #endif /* SQLITE_DEBUG */ |
| 116772 | 116805 | |
| 116773 | 116806 | /************** End of expr.c ************************************************/ |
| 116774 | 116807 | /************** Begin file alter.c *******************************************/ |
| 116775 | | -#line 1 "tsrc/alter.c" |
| 116776 | 116808 | /* |
| 116777 | 116809 | ** 2005 February 15 |
| 116778 | 116810 | ** |
| 116779 | 116811 | ** The author disclaims copyright to this source code. In place of |
| 116780 | 116812 | ** a legal notice, here is a blessing: |
| | @@ -119090,11 +119122,10 @@ |
| 119090 | 119122 | } |
| 119091 | 119123 | #endif /* SQLITE_ALTER_TABLE */ |
| 119092 | 119124 | |
| 119093 | 119125 | /************** End of alter.c ***********************************************/ |
| 119094 | 119126 | /************** Begin file analyze.c *****************************************/ |
| 119095 | | -#line 1 "tsrc/analyze.c" |
| 119096 | 119127 | /* |
| 119097 | 119128 | ** 2005-07-08 |
| 119098 | 119129 | ** |
| 119099 | 119130 | ** The author disclaims copyright to this source code. In place of |
| 119100 | 119131 | ** a legal notice, here is a blessing: |
| | @@ -121115,11 +121146,10 @@ |
| 121115 | 121146 | |
| 121116 | 121147 | #endif /* SQLITE_OMIT_ANALYZE */ |
| 121117 | 121148 | |
| 121118 | 121149 | /************** End of analyze.c *********************************************/ |
| 121119 | 121150 | /************** Begin file attach.c ******************************************/ |
| 121120 | | -#line 1 "tsrc/attach.c" |
| 121121 | 121151 | /* |
| 121122 | 121152 | ** 2003 April 6 |
| 121123 | 121153 | ** |
| 121124 | 121154 | ** The author disclaims copyright to this source code. In place of |
| 121125 | 121155 | ** a legal notice, here is a blessing: |
| | @@ -121728,11 +121758,10 @@ |
| 121728 | 121758 | } |
| 121729 | 121759 | #endif |
| 121730 | 121760 | |
| 121731 | 121761 | /************** End of attach.c **********************************************/ |
| 121732 | 121762 | /************** Begin file auth.c ********************************************/ |
| 121733 | | -#line 1 "tsrc/auth.c" |
| 121734 | 121763 | /* |
| 121735 | 121764 | ** 2003 January 11 |
| 121736 | 121765 | ** |
| 121737 | 121766 | ** The author disclaims copyright to this source code. In place of |
| 121738 | 121767 | ** a legal notice, here is a blessing: |
| | @@ -121992,11 +122021,10 @@ |
| 121992 | 122021 | |
| 121993 | 122022 | #endif /* SQLITE_OMIT_AUTHORIZATION */ |
| 121994 | 122023 | |
| 121995 | 122024 | /************** End of auth.c ************************************************/ |
| 121996 | 122025 | /************** Begin file build.c *******************************************/ |
| 121997 | | -#line 1 "tsrc/build.c" |
| 121998 | 122026 | /* |
| 121999 | 122027 | ** 2001 September 15 |
| 122000 | 122028 | ** |
| 122001 | 122029 | ** The author disclaims copyright to this source code. In place of |
| 122002 | 122030 | ** a legal notice, here is a blessing: |
| | @@ -127763,11 +127791,10 @@ |
| 127763 | 127791 | } |
| 127764 | 127792 | #endif /* !defined(SQLITE_OMIT_CTE) */ |
| 127765 | 127793 | |
| 127766 | 127794 | /************** End of build.c ***********************************************/ |
| 127767 | 127795 | /************** Begin file callback.c ****************************************/ |
| 127768 | | -#line 1 "tsrc/callback.c" |
| 127769 | 127796 | /* |
| 127770 | 127797 | ** 2005 May 23 |
| 127771 | 127798 | ** |
| 127772 | 127799 | ** The author disclaims copyright to this source code. In place of |
| 127773 | 127800 | ** a legal notice, here is a blessing: |
| | @@ -128307,11 +128334,10 @@ |
| 128307 | 128334 | return p; |
| 128308 | 128335 | } |
| 128309 | 128336 | |
| 128310 | 128337 | /************** End of callback.c ********************************************/ |
| 128311 | 128338 | /************** Begin file delete.c ******************************************/ |
| 128312 | | -#line 1 "tsrc/delete.c" |
| 128313 | 128339 | /* |
| 128314 | 128340 | ** 2001 September 15 |
| 128315 | 128341 | ** |
| 128316 | 128342 | ** The author disclaims copyright to this source code. In place of |
| 128317 | 128343 | ** a legal notice, here is a blessing: |
| | @@ -129341,11 +129367,10 @@ |
| 129341 | 129367 | } |
| 129342 | 129368 | } |
| 129343 | 129369 | |
| 129344 | 129370 | /************** End of delete.c **********************************************/ |
| 129345 | 129371 | /************** Begin file func.c ********************************************/ |
| 129346 | | -#line 1 "tsrc/func.c" |
| 129347 | 129372 | /* |
| 129348 | 129373 | ** 2002 February 23 |
| 129349 | 129374 | ** |
| 129350 | 129375 | ** The author disclaims copyright to this source code. In place of |
| 129351 | 129376 | ** a legal notice, here is a blessing: |
| | @@ -132158,11 +132183,14 @@ |
| 132158 | 132183 | MFUNCTION(degrees, 1, radToDeg, math1Func ), |
| 132159 | 132184 | MFUNCTION(pi, 0, 0, piFunc ), |
| 132160 | 132185 | #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ |
| 132161 | 132186 | FUNCTION(sign, 1, 0, 0, signFunc ), |
| 132162 | 132187 | INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), |
| 132188 | + INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ), |
| 132163 | 132189 | INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), |
| 132190 | + INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ), |
| 132191 | + INLINE_FUNC(if, 3, INLINEFUNC_iif, 0 ), |
| 132164 | 132192 | }; |
| 132165 | 132193 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 132166 | 132194 | sqlite3AlterFunctions(); |
| 132167 | 132195 | #endif |
| 132168 | 132196 | sqlite3WindowFunctions(); |
| | @@ -132188,11 +132216,10 @@ |
| 132188 | 132216 | #endif |
| 132189 | 132217 | } |
| 132190 | 132218 | |
| 132191 | 132219 | /************** End of func.c ************************************************/ |
| 132192 | 132220 | /************** Begin file fkey.c ********************************************/ |
| 132193 | | -#line 1 "tsrc/fkey.c" |
| 132194 | 132221 | /* |
| 132195 | 132222 | ** |
| 132196 | 132223 | ** The author disclaims copyright to this source code. In place of |
| 132197 | 132224 | ** a legal notice, here is a blessing: |
| 132198 | 132225 | ** |
| | @@ -133676,11 +133703,10 @@ |
| 133676 | 133703 | } |
| 133677 | 133704 | #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */ |
| 133678 | 133705 | |
| 133679 | 133706 | /************** End of fkey.c ************************************************/ |
| 133680 | 133707 | /************** Begin file insert.c ******************************************/ |
| 133681 | | -#line 1 "tsrc/insert.c" |
| 133682 | 133708 | /* |
| 133683 | 133709 | ** 2001 September 15 |
| 133684 | 133710 | ** |
| 133685 | 133711 | ** The author disclaims copyright to this source code. In place of |
| 133686 | 133712 | ** a legal notice, here is a blessing: |
| | @@ -137072,11 +137098,10 @@ |
| 137072 | 137098 | } |
| 137073 | 137099 | #endif /* SQLITE_OMIT_XFER_OPT */ |
| 137074 | 137100 | |
| 137075 | 137101 | /************** End of insert.c **********************************************/ |
| 137076 | 137102 | /************** Begin file legacy.c ******************************************/ |
| 137077 | | -#line 1 "tsrc/legacy.c" |
| 137078 | 137103 | /* |
| 137079 | 137104 | ** 2001 September 15 |
| 137080 | 137105 | ** |
| 137081 | 137106 | ** The author disclaims copyright to this source code. In place of |
| 137082 | 137107 | ** a legal notice, here is a blessing: |
| | @@ -137217,11 +137242,10 @@ |
| 137217 | 137242 | return rc; |
| 137218 | 137243 | } |
| 137219 | 137244 | |
| 137220 | 137245 | /************** End of legacy.c **********************************************/ |
| 137221 | 137246 | /************** Begin file loadext.c *****************************************/ |
| 137222 | | -#line 1 "tsrc/loadext.c" |
| 137223 | 137247 | /* |
| 137224 | 137248 | ** 2006 June 7 |
| 137225 | 137249 | ** |
| 137226 | 137250 | ** The author disclaims copyright to this source code. In place of |
| 137227 | 137251 | ** a legal notice, here is a blessing: |
| | @@ -137238,11 +137262,10 @@ |
| 137238 | 137262 | #ifndef SQLITE_CORE |
| 137239 | 137263 | #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ |
| 137240 | 137264 | #endif |
| 137241 | 137265 | /************** Include sqlite3ext.h in the middle of loadext.c **************/ |
| 137242 | 137266 | /************** Begin file sqlite3ext.h **************************************/ |
| 137243 | | -#line 1 "tsrc/sqlite3ext.h" |
| 137244 | 137267 | /* |
| 137245 | 137268 | ** 2006 June 7 |
| 137246 | 137269 | ** |
| 137247 | 137270 | ** The author disclaims copyright to this source code. In place of |
| 137248 | 137271 | ** a legal notice, here is a blessing: |
| | @@ -137961,11 +137984,10 @@ |
| 137961 | 137984 | |
| 137962 | 137985 | #endif /* SQLITE3EXT_H */ |
| 137963 | 137986 | |
| 137964 | 137987 | /************** End of sqlite3ext.h ******************************************/ |
| 137965 | 137988 | /************** Continuing where we left off in loadext.c ********************/ |
| 137966 | | -#line 20 "tsrc/loadext.c" |
| 137967 | 137989 | /* #include "sqliteInt.h" */ |
| 137968 | 137990 | |
| 137969 | 137991 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 137970 | 137992 | /* |
| 137971 | 137993 | ** Some API routines are omitted when various features are |
| | @@ -138867,11 +138889,10 @@ |
| 138867 | 138889 | } |
| 138868 | 138890 | } |
| 138869 | 138891 | |
| 138870 | 138892 | /************** End of loadext.c *********************************************/ |
| 138871 | 138893 | /************** Begin file pragma.c ******************************************/ |
| 138872 | | -#line 1 "tsrc/pragma.c" |
| 138873 | 138894 | /* |
| 138874 | 138895 | ** 2003 April 6 |
| 138875 | 138896 | ** |
| 138876 | 138897 | ** The author disclaims copyright to this source code. In place of |
| 138877 | 138898 | ** a legal notice, here is a blessing: |
| | @@ -138900,11 +138921,10 @@ |
| 138900 | 138921 | ** lexicographical order to facility a binary search of the pragma name. |
| 138901 | 138922 | ** Do not edit pragma.h directly. Edit and rerun the script in at |
| 138902 | 138923 | ** ../tool/mkpragmatab.tcl. */ |
| 138903 | 138924 | /************** Include pragma.h in the middle of pragma.c *******************/ |
| 138904 | 138925 | /************** Begin file pragma.h ******************************************/ |
| 138905 | | -#line 1 "tsrc/pragma.h" |
| 138906 | 138926 | /* DO NOT EDIT! |
| 138907 | 138927 | ** This file is automatically generated by the script at |
| 138908 | 138928 | ** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit |
| 138909 | 138929 | ** that script and rerun it. |
| 138910 | 138930 | */ |
| | @@ -139564,11 +139584,10 @@ |
| 139564 | 139584 | }; |
| 139565 | 139585 | /* Number of pragmas: 68 on by default, 78 total. */ |
| 139566 | 139586 | |
| 139567 | 139587 | /************** End of pragma.h **********************************************/ |
| 139568 | 139588 | /************** Continuing where we left off in pragma.c *********************/ |
| 139569 | | -#line 32 "tsrc/pragma.c" |
| 139570 | 139589 | |
| 139571 | 139590 | /* |
| 139572 | 139591 | ** When the 0x10 bit of PRAGMA optimize is set, any ANALYZE commands |
| 139573 | 139592 | ** will be run with an analysis_limit set to the lessor of the value of |
| 139574 | 139593 | ** the following macro or to the actual analysis_limit if it is non-zero, |
| | @@ -140815,11 +140834,12 @@ |
| 140815 | 140834 | pTab = sqliteHashData(k); |
| 140816 | 140835 | if( pTab->nCol==0 ){ |
| 140817 | 140836 | char *zSql = sqlite3MPrintf(db, "SELECT*FROM\"%w\"", pTab->zName); |
| 140818 | 140837 | if( zSql ){ |
| 140819 | 140838 | sqlite3_stmt *pDummy = 0; |
| 140820 | | - (void)sqlite3_prepare(db, zSql, -1, &pDummy, 0); |
| 140839 | + (void)sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_DONT_LOG, |
| 140840 | + &pDummy, 0); |
| 140821 | 140841 | (void)sqlite3_finalize(pDummy); |
| 140822 | 140842 | sqlite3DbFree(db, zSql); |
| 140823 | 140843 | } |
| 140824 | 140844 | if( db->mallocFailed ){ |
| 140825 | 140845 | sqlite3ErrorMsg(db->pParse, "out of memory"); |
| | @@ -142608,11 +142628,10 @@ |
| 142608 | 142628 | |
| 142609 | 142629 | #endif /* SQLITE_OMIT_PRAGMA */ |
| 142610 | 142630 | |
| 142611 | 142631 | /************** End of pragma.c **********************************************/ |
| 142612 | 142632 | /************** Begin file prepare.c *****************************************/ |
| 142613 | | -#line 1 "tsrc/prepare.c" |
| 142614 | 142633 | /* |
| 142615 | 142634 | ** 2005 May 25 |
| 142616 | 142635 | ** |
| 142617 | 142636 | ** The author disclaims copyright to this source code. In place of |
| 142618 | 142637 | ** a legal notice, here is a blessing: |
| | @@ -143702,11 +143721,10 @@ |
| 143702 | 143721 | |
| 143703 | 143722 | #endif /* SQLITE_OMIT_UTF16 */ |
| 143704 | 143723 | |
| 143705 | 143724 | /************** End of prepare.c *********************************************/ |
| 143706 | 143725 | /************** Begin file select.c ******************************************/ |
| 143707 | | -#line 1 "tsrc/select.c" |
| 143708 | 143726 | /* |
| 143709 | 143727 | ** 2001 September 15 |
| 143710 | 143728 | ** |
| 143711 | 143729 | ** The author disclaims copyright to this source code. In place of |
| 143712 | 143730 | ** a legal notice, here is a blessing: |
| | @@ -147616,36 +147634,36 @@ |
| 147616 | 147634 | return pExpr; |
| 147617 | 147635 | } |
| 147618 | 147636 | if( pSubst->isOuterJoin ){ |
| 147619 | 147637 | ExprSetProperty(pNew, EP_CanBeNull); |
| 147620 | 147638 | } |
| 147639 | + if( pNew->op==TK_TRUEFALSE ){ |
| 147640 | + pNew->u.iValue = sqlite3ExprTruthValue(pNew); |
| 147641 | + pNew->op = TK_INTEGER; |
| 147642 | + ExprSetProperty(pNew, EP_IntValue); |
| 147643 | + } |
| 147644 | + |
| 147645 | + /* Ensure that the expression now has an implicit collation sequence, |
| 147646 | + ** just as it did when it was a column of a view or sub-query. */ |
| 147647 | + { |
| 147648 | + CollSeq *pNat = sqlite3ExprCollSeq(pSubst->pParse, pNew); |
| 147649 | + CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, |
| 147650 | + pSubst->pCList->a[iColumn].pExpr |
| 147651 | + ); |
| 147652 | + if( pNat!=pColl || (pNew->op!=TK_COLUMN && pNew->op!=TK_COLLATE) ){ |
| 147653 | + pNew = sqlite3ExprAddCollateString(pSubst->pParse, pNew, |
| 147654 | + (pColl ? pColl->zName : "BINARY") |
| 147655 | + ); |
| 147656 | + } |
| 147657 | + } |
| 147658 | + ExprClearProperty(pNew, EP_Collate); |
| 147621 | 147659 | if( ExprHasProperty(pExpr,EP_OuterON|EP_InnerON) ){ |
| 147622 | 147660 | sqlite3SetJoinExpr(pNew, pExpr->w.iJoin, |
| 147623 | 147661 | pExpr->flags & (EP_OuterON|EP_InnerON)); |
| 147624 | 147662 | } |
| 147625 | 147663 | sqlite3ExprDelete(db, pExpr); |
| 147626 | 147664 | pExpr = pNew; |
| 147627 | | - if( pExpr->op==TK_TRUEFALSE ){ |
| 147628 | | - pExpr->u.iValue = sqlite3ExprTruthValue(pExpr); |
| 147629 | | - pExpr->op = TK_INTEGER; |
| 147630 | | - ExprSetProperty(pExpr, EP_IntValue); |
| 147631 | | - } |
| 147632 | | - |
| 147633 | | - /* Ensure that the expression now has an implicit collation sequence, |
| 147634 | | - ** just as it did when it was a column of a view or sub-query. */ |
| 147635 | | - { |
| 147636 | | - CollSeq *pNat = sqlite3ExprCollSeq(pSubst->pParse, pExpr); |
| 147637 | | - CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, |
| 147638 | | - pSubst->pCList->a[iColumn].pExpr |
| 147639 | | - ); |
| 147640 | | - if( pNat!=pColl || (pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE) ){ |
| 147641 | | - pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, |
| 147642 | | - (pColl ? pColl->zName : "BINARY") |
| 147643 | | - ); |
| 147644 | | - } |
| 147645 | | - } |
| 147646 | | - ExprClearProperty(pExpr, EP_Collate); |
| 147647 | 147665 | } |
| 147648 | 147666 | } |
| 147649 | 147667 | }else{ |
| 147650 | 147668 | if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){ |
| 147651 | 147669 | pExpr->iTable = pSubst->iNewTable; |
| | @@ -148378,20 +148396,20 @@ |
| 148378 | 148396 | } |
| 148379 | 148397 | |
| 148380 | 148398 | /* Transfer the FROM clause terms from the subquery into the |
| 148381 | 148399 | ** outer query. |
| 148382 | 148400 | */ |
| 148401 | + iNewParent = pSubSrc->a[0].iCursor; |
| 148383 | 148402 | for(i=0; i<nSubSrc; i++){ |
| 148384 | 148403 | SrcItem *pItem = &pSrc->a[i+iFrom]; |
| 148385 | 148404 | assert( pItem->fg.isTabFunc==0 ); |
| 148386 | 148405 | assert( pItem->fg.isSubquery |
| 148387 | 148406 | || pItem->fg.fixedSchema |
| 148388 | 148407 | || pItem->u4.zDatabase==0 ); |
| 148389 | 148408 | if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing); |
| 148390 | 148409 | *pItem = pSubSrc->a[i]; |
| 148391 | 148410 | pItem->fg.jointype |= ltorj; |
| 148392 | | - iNewParent = pSubSrc->a[i].iCursor; |
| 148393 | 148411 | memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); |
| 148394 | 148412 | } |
| 148395 | 148413 | pSrc->a[iFrom].fg.jointype &= JT_LTORJ; |
| 148396 | 148414 | pSrc->a[iFrom].fg.jointype |= jointype | ltorj; |
| 148397 | 148415 | |
| | @@ -148427,10 +148445,11 @@ |
| 148427 | 148445 | pSub->pOrderBy = 0; |
| 148428 | 148446 | } |
| 148429 | 148447 | pWhere = pSub->pWhere; |
| 148430 | 148448 | pSub->pWhere = 0; |
| 148431 | 148449 | if( isOuterJoin>0 ){ |
| 148450 | + assert( pSubSrc->nSrc==1 ); |
| 148432 | 148451 | sqlite3SetJoinExpr(pWhere, iNewParent, EP_OuterON); |
| 148433 | 148452 | } |
| 148434 | 148453 | if( pWhere ){ |
| 148435 | 148454 | if( pParent->pWhere ){ |
| 148436 | 148455 | pParent->pWhere = sqlite3PExpr(pParse, TK_AND, pWhere, pParent->pWhere); |
| | @@ -151526,11 +151545,11 @@ |
| 151526 | 151545 | sqlite3TreeViewSelect(0, p, 0); |
| 151527 | 151546 | } |
| 151528 | 151547 | #endif |
| 151529 | 151548 | assert( pSubq->pSelect && (pSub->selFlags & SF_PushDown)!=0 ); |
| 151530 | 151549 | }else{ |
| 151531 | | - TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n")); |
| 151550 | + TREETRACE(0x4000,pParse,p,("WHERE-clause push-down not possible\n")); |
| 151532 | 151551 | } |
| 151533 | 151552 | |
| 151534 | 151553 | /* Convert unused result columns of the subquery into simple NULL |
| 151535 | 151554 | ** expressions, to avoid unneeded searching and computation. |
| 151536 | 151555 | ** tag-select-0440 |
| | @@ -152475,11 +152494,10 @@ |
| 152475 | 152494 | return rc; |
| 152476 | 152495 | } |
| 152477 | 152496 | |
| 152478 | 152497 | /************** End of select.c **********************************************/ |
| 152479 | 152498 | /************** Begin file table.c *******************************************/ |
| 152480 | | -#line 1 "tsrc/table.c" |
| 152481 | 152499 | /* |
| 152482 | 152500 | ** 2001 September 15 |
| 152483 | 152501 | ** |
| 152484 | 152502 | ** The author disclaims copyright to this source code. In place of |
| 152485 | 152503 | ** a legal notice, here is a blessing: |
| | @@ -152677,11 +152695,10 @@ |
| 152677 | 152695 | |
| 152678 | 152696 | #endif /* SQLITE_OMIT_GET_TABLE */ |
| 152679 | 152697 | |
| 152680 | 152698 | /************** End of table.c ***********************************************/ |
| 152681 | 152699 | /************** Begin file trigger.c *****************************************/ |
| 152682 | | -#line 1 "tsrc/trigger.c" |
| 152683 | 152700 | /* |
| 152684 | 152701 | ** |
| 152685 | 152702 | ** The author disclaims copyright to this source code. In place of |
| 152686 | 152703 | ** a legal notice, here is a blessing: |
| 152687 | 152704 | ** |
| | @@ -154244,11 +154261,10 @@ |
| 154244 | 154261 | |
| 154245 | 154262 | #endif /* !defined(SQLITE_OMIT_TRIGGER) */ |
| 154246 | 154263 | |
| 154247 | 154264 | /************** End of trigger.c *********************************************/ |
| 154248 | 154265 | /************** Begin file update.c ******************************************/ |
| 154249 | | -#line 1 "tsrc/update.c" |
| 154250 | 154266 | /* |
| 154251 | 154267 | ** 2001 September 15 |
| 154252 | 154268 | ** |
| 154253 | 154269 | ** The author disclaims copyright to this source code. In place of |
| 154254 | 154270 | ** a legal notice, here is a blessing: |
| | @@ -155616,11 +155632,10 @@ |
| 155616 | 155632 | } |
| 155617 | 155633 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 155618 | 155634 | |
| 155619 | 155635 | /************** End of update.c **********************************************/ |
| 155620 | 155636 | /************** Begin file upsert.c ******************************************/ |
| 155621 | | -#line 1 "tsrc/upsert.c" |
| 155622 | 155637 | /* |
| 155623 | 155638 | ** 2018-04-12 |
| 155624 | 155639 | ** |
| 155625 | 155640 | ** The author disclaims copyright to this source code. In place of |
| 155626 | 155641 | ** a legal notice, here is a blessing: |
| | @@ -155949,11 +155964,10 @@ |
| 155949 | 155964 | |
| 155950 | 155965 | #endif /* SQLITE_OMIT_UPSERT */ |
| 155951 | 155966 | |
| 155952 | 155967 | /************** End of upsert.c **********************************************/ |
| 155953 | 155968 | /************** Begin file vacuum.c ******************************************/ |
| 155954 | | -#line 1 "tsrc/vacuum.c" |
| 155955 | 155969 | /* |
| 155956 | 155970 | ** 2003 April 6 |
| 155957 | 155971 | ** |
| 155958 | 155972 | ** The author disclaims copyright to this source code. In place of |
| 155959 | 155973 | ** a legal notice, here is a blessing: |
| | @@ -156371,11 +156385,10 @@ |
| 156371 | 156385 | |
| 156372 | 156386 | #endif /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ |
| 156373 | 156387 | |
| 156374 | 156388 | /************** End of vacuum.c **********************************************/ |
| 156375 | 156389 | /************** Begin file vtab.c ********************************************/ |
| 156376 | | -#line 1 "tsrc/vtab.c" |
| 156377 | 156390 | /* |
| 156378 | 156391 | ** 2006 June 10 |
| 156379 | 156392 | ** |
| 156380 | 156393 | ** The author disclaims copyright to this source code. In place of |
| 156381 | 156394 | ** a legal notice, here is a blessing: |
| | @@ -157749,11 +157762,10 @@ |
| 157749 | 157762 | |
| 157750 | 157763 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 157751 | 157764 | |
| 157752 | 157765 | /************** End of vtab.c ************************************************/ |
| 157753 | 157766 | /************** Begin file wherecode.c ***************************************/ |
| 157754 | | -#line 1 "tsrc/wherecode.c" |
| 157755 | 157767 | /* |
| 157756 | 157768 | ** 2015-06-06 |
| 157757 | 157769 | ** |
| 157758 | 157770 | ** The author disclaims copyright to this source code. In place of |
| 157759 | 157771 | ** a legal notice, here is a blessing: |
| | @@ -157772,11 +157784,10 @@ |
| 157772 | 157784 | ** file retains the code that does query planning and analysis. |
| 157773 | 157785 | */ |
| 157774 | 157786 | /* #include "sqliteInt.h" */ |
| 157775 | 157787 | /************** Include whereInt.h in the middle of wherecode.c **************/ |
| 157776 | 157788 | /************** Begin file whereInt.h ****************************************/ |
| 157777 | | -#line 1 "tsrc/whereInt.h" |
| 157778 | 157789 | /* |
| 157779 | 157790 | ** 2013-11-12 |
| 157780 | 157791 | ** |
| 157781 | 157792 | ** The author disclaims copyright to this source code. In place of |
| 157782 | 157793 | ** a legal notice, here is a blessing: |
| | @@ -158429,11 +158440,10 @@ |
| 158429 | 158440 | |
| 158430 | 158441 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| 158431 | 158442 | |
| 158432 | 158443 | /************** End of whereInt.h ********************************************/ |
| 158433 | 158444 | /************** Continuing where we left off in wherecode.c ******************/ |
| 158434 | | -#line 22 "tsrc/wherecode.c" |
| 158435 | 158445 | |
| 158436 | 158446 | #ifndef SQLITE_OMIT_EXPLAIN |
| 158437 | 158447 | |
| 158438 | 158448 | /* |
| 158439 | 158449 | ** Return the name of the i-th column of the pIdx index. |
| | @@ -159026,10 +159036,11 @@ |
| 159026 | 159036 | if( pOrigLhs ){ |
| 159027 | 159037 | sqlite3ExprListDelete(db, pOrigLhs); |
| 159028 | 159038 | pNew->pLeft->x.pList = pLhs; |
| 159029 | 159039 | } |
| 159030 | 159040 | pSelect->pEList = pRhs; |
| 159041 | + pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */ |
| 159031 | 159042 | if( pLhs && pLhs->nExpr==1 ){ |
| 159032 | 159043 | /* Take care here not to generate a TK_VECTOR containing only a |
| 159033 | 159044 | ** single value. Since the parser never creates such a vector, some |
| 159034 | 159045 | ** of the subroutines do not handle this case. */ |
| 159035 | 159046 | Expr *p = pLhs->a[0].pExpr; |
| | @@ -161352,11 +161363,10 @@ |
| 161352 | 161363 | pParse->withinRJSubrtn--; |
| 161353 | 161364 | } |
| 161354 | 161365 | |
| 161355 | 161366 | /************** End of wherecode.c *******************************************/ |
| 161356 | 161367 | /************** Begin file whereexpr.c ***************************************/ |
| 161357 | | -#line 1 "tsrc/whereexpr.c" |
| 161358 | 161368 | /* |
| 161359 | 161369 | ** 2015-06-08 |
| 161360 | 161370 | ** |
| 161361 | 161371 | ** The author disclaims copyright to this source code. In place of |
| 161362 | 161372 | ** a legal notice, here is a blessing: |
| | @@ -163258,11 +163268,10 @@ |
| 163258 | 163268 | } |
| 163259 | 163269 | } |
| 163260 | 163270 | |
| 163261 | 163271 | /************** End of whereexpr.c *******************************************/ |
| 163262 | 163272 | /************** Begin file where.c *******************************************/ |
| 163263 | | -#line 1 "tsrc/where.c" |
| 163264 | 163273 | /* |
| 163265 | 163274 | ** 2001 September 15 |
| 163266 | 163275 | ** |
| 163267 | 163276 | ** The author disclaims copyright to this source code. In place of |
| 163268 | 163277 | ** a legal notice, here is a blessing: |
| | @@ -164100,11 +164109,11 @@ |
| 164100 | 164109 | || pTerm->pExpr->w.iJoin != pSrc->iCursor |
| 164101 | 164110 | ){ |
| 164102 | 164111 | return 0; |
| 164103 | 164112 | } |
| 164104 | 164113 | if( (pSrc->fg.jointype & (JT_LEFT|JT_RIGHT))!=0 |
| 164105 | | - && ExprHasProperty(pTerm->pExpr, EP_InnerON) |
| 164114 | + && NEVER(ExprHasProperty(pTerm->pExpr, EP_InnerON)) |
| 164106 | 164115 | ){ |
| 164107 | 164116 | return 0; |
| 164108 | 164117 | } |
| 164109 | 164118 | return 1; |
| 164110 | 164119 | } |
| | @@ -165593,11 +165602,11 @@ |
| 165593 | 165602 | return rc; |
| 165594 | 165603 | } |
| 165595 | 165604 | #endif /* SQLITE_ENABLE_STAT4 */ |
| 165596 | 165605 | |
| 165597 | 165606 | |
| 165598 | | -#ifdef WHERETRACE_ENABLED |
| 165607 | +#if defined(WHERETRACE_ENABLED) || defined(SQLITE_DEBUG) |
| 165599 | 165608 | /* |
| 165600 | 165609 | ** Print the content of a WhereTerm object |
| 165601 | 165610 | */ |
| 165602 | 165611 | SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){ |
| 165603 | 165612 | if( pTerm==0 ){ |
| | @@ -165636,10 +165645,13 @@ |
| 165636 | 165645 | sqlite3DebugPrintf(" iParent=%d", pTerm->iParent); |
| 165637 | 165646 | } |
| 165638 | 165647 | sqlite3DebugPrintf("\n"); |
| 165639 | 165648 | sqlite3TreeViewExpr(0, pTerm->pExpr, 0); |
| 165640 | 165649 | } |
| 165650 | +} |
| 165651 | +SQLITE_PRIVATE void sqlite3ShowWhereTerm(WhereTerm *pTerm){ |
| 165652 | + sqlite3WhereTermPrint(pTerm, 0); |
| 165641 | 165653 | } |
| 165642 | 165654 | #endif |
| 165643 | 165655 | |
| 165644 | 165656 | #ifdef WHERETRACE_ENABLED |
| 165645 | 165657 | /* |
| | @@ -166822,11 +166834,10 @@ |
| 166822 | 166834 | pParse = pWC->pWInfo->pParse; |
| 166823 | 166835 | while( pWhere->op==TK_AND ){ |
| 166824 | 166836 | if( !whereUsablePartialIndex(iTab,jointype,pWC,pWhere->pLeft) ) return 0; |
| 166825 | 166837 | pWhere = pWhere->pRight; |
| 166826 | 166838 | } |
| 166827 | | - if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0; |
| 166828 | 166839 | for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 166829 | 166840 | Expr *pExpr; |
| 166830 | 166841 | pExpr = pTerm->pExpr; |
| 166831 | 166842 | if( (!ExprHasProperty(pExpr, EP_OuterON) || pExpr->w.iJoin==iTab) |
| 166832 | 166843 | && ((jointype & JT_OUTER)==0 || ExprHasProperty(pExpr, EP_OuterON)) |
| | @@ -169483,11 +169494,11 @@ |
| 169483 | 169494 | break; |
| 169484 | 169495 | } |
| 169485 | 169496 | } |
| 169486 | 169497 | if( hasRightJoin |
| 169487 | 169498 | && ExprHasProperty(pTerm->pExpr, EP_InnerON) |
| 169488 | | - && pTerm->pExpr->w.iJoin==pItem->iCursor |
| 169499 | + && NEVER(pTerm->pExpr->w.iJoin==pItem->iCursor) |
| 169489 | 169500 | ){ |
| 169490 | 169501 | break; /* restriction (5) */ |
| 169491 | 169502 | } |
| 169492 | 169503 | } |
| 169493 | 169504 | if( pTerm<pEnd ) continue; |
| | @@ -170759,11 +170770,10 @@ |
| 170759 | 170770 | return; |
| 170760 | 170771 | } |
| 170761 | 170772 | |
| 170762 | 170773 | /************** End of where.c ***********************************************/ |
| 170763 | 170774 | /************** Begin file window.c ******************************************/ |
| 170764 | | -#line 1 "tsrc/window.c" |
| 170765 | 170775 | /* |
| 170766 | 170776 | ** 2018 May 08 |
| 170767 | 170777 | ** |
| 170768 | 170778 | ** The author disclaims copyright to this source code. In place of |
| 170769 | 170779 | ** a legal notice, here is a blessing: |
| | @@ -172432,10 +172442,11 @@ |
| 172432 | 172442 | for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ |
| 172433 | 172443 | FuncDef *pFunc = pWin->pWFunc; |
| 172434 | 172444 | int regArg; |
| 172435 | 172445 | int nArg = pWin->bExprArgs ? 0 : windowArgCount(pWin); |
| 172436 | 172446 | int i; |
| 172447 | + int addrIf = 0; |
| 172437 | 172448 | |
| 172438 | 172449 | assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED ); |
| 172439 | 172450 | |
| 172440 | 172451 | /* All OVER clauses in the same window function aggregate step must |
| 172441 | 172452 | ** be the same. */ |
| | @@ -172447,10 +172458,22 @@ |
| 172447 | 172458 | }else{ |
| 172448 | 172459 | sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i); |
| 172449 | 172460 | } |
| 172450 | 172461 | } |
| 172451 | 172462 | regArg = reg; |
| 172463 | + |
| 172464 | + if( pWin->pFilter ){ |
| 172465 | + int regTmp; |
| 172466 | + assert( ExprUseXList(pWin->pOwner) ); |
| 172467 | + assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr ); |
| 172468 | + assert( pWin->bExprArgs || nArg ||pWin->pOwner->x.pList==0 ); |
| 172469 | + regTmp = sqlite3GetTempReg(pParse); |
| 172470 | + sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp); |
| 172471 | + addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1); |
| 172472 | + VdbeCoverage(v); |
| 172473 | + sqlite3ReleaseTempReg(pParse, regTmp); |
| 172474 | + } |
| 172452 | 172475 | |
| 172453 | 172476 | if( pMWin->regStartRowid==0 |
| 172454 | 172477 | && (pFunc->funcFlags & SQLITE_FUNC_MINMAX) |
| 172455 | 172478 | && (pWin->eStart!=TK_UNBOUNDED) |
| 172456 | 172479 | ){ |
| | @@ -172467,29 +172490,17 @@ |
| 172467 | 172490 | sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp); |
| 172468 | 172491 | sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 172469 | 172492 | } |
| 172470 | 172493 | sqlite3VdbeJumpHere(v, addrIsNull); |
| 172471 | 172494 | }else if( pWin->regApp ){ |
| 172495 | + assert( pWin->pFilter==0 ); |
| 172472 | 172496 | assert( pFunc->zName==nth_valueName |
| 172473 | 172497 | || pFunc->zName==first_valueName |
| 172474 | 172498 | ); |
| 172475 | 172499 | assert( bInverse==0 || bInverse==1 ); |
| 172476 | 172500 | sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1); |
| 172477 | 172501 | }else if( pFunc->xSFunc!=noopStepFunc ){ |
| 172478 | | - int addrIf = 0; |
| 172479 | | - if( pWin->pFilter ){ |
| 172480 | | - int regTmp; |
| 172481 | | - assert( ExprUseXList(pWin->pOwner) ); |
| 172482 | | - assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr ); |
| 172483 | | - assert( pWin->bExprArgs || nArg ||pWin->pOwner->x.pList==0 ); |
| 172484 | | - regTmp = sqlite3GetTempReg(pParse); |
| 172485 | | - sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp); |
| 172486 | | - addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1); |
| 172487 | | - VdbeCoverage(v); |
| 172488 | | - sqlite3ReleaseTempReg(pParse, regTmp); |
| 172489 | | - } |
| 172490 | | - |
| 172491 | 172502 | if( pWin->bExprArgs ){ |
| 172492 | 172503 | int iOp = sqlite3VdbeCurrentAddr(v); |
| 172493 | 172504 | int iEnd; |
| 172494 | 172505 | |
| 172495 | 172506 | assert( ExprUseXList(pWin->pOwner) ); |
| | @@ -172516,12 +172527,13 @@ |
| 172516 | 172527 | sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF); |
| 172517 | 172528 | sqlite3VdbeChangeP5(v, (u8)nArg); |
| 172518 | 172529 | if( pWin->bExprArgs ){ |
| 172519 | 172530 | sqlite3ReleaseTempRange(pParse, regArg, nArg); |
| 172520 | 172531 | } |
| 172521 | | - if( addrIf ) sqlite3VdbeJumpHere(v, addrIf); |
| 172522 | 172532 | } |
| 172533 | + |
| 172534 | + if( addrIf ) sqlite3VdbeJumpHere(v, addrIf); |
| 172523 | 172535 | } |
| 172524 | 172536 | } |
| 172525 | 172537 | |
| 172526 | 172538 | /* |
| 172527 | 172539 | ** Values that may be passed as the second argument to windowCodeOp(). |
| | @@ -173869,11 +173881,10 @@ |
| 173869 | 173881 | |
| 173870 | 173882 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 173871 | 173883 | |
| 173872 | 173884 | /************** End of window.c **********************************************/ |
| 173873 | 173885 | /************** Begin file parse.c *******************************************/ |
| 173874 | | -#line 1 "tsrc/parse.c" |
| 173875 | 173886 | /* This file is automatically generated by Lemon from input grammar |
| 173876 | 173887 | ** source file "parse.y". |
| 173877 | 173888 | */ |
| 173878 | 173889 | /* |
| 173879 | 173890 | ** 2001-09-15 |
| | @@ -173893,11 +173904,10 @@ |
| 173893 | 173904 | ** That input file is processed by Lemon to generate a C-language |
| 173894 | 173905 | ** implementation of a parser for the given grammar. You might be reading |
| 173895 | 173906 | ** this comment as part of the translated C-code. Edits should be made |
| 173896 | 173907 | ** to the original parse.y sources. |
| 173897 | 173908 | */ |
| 173898 | | -#line 62 "parse.y" |
| 173899 | 173909 | |
| 173900 | 173910 | /* #include "sqliteInt.h" */ |
| 173901 | 173911 | |
| 173902 | 173912 | /* |
| 173903 | 173913 | ** Disable all error recovery processing in the parser push-down |
| | @@ -173945,10 +173955,17 @@ |
| 173945 | 173955 | ** Then the "b" IdList records the list "a,b,c". |
| 173946 | 173956 | */ |
| 173947 | 173957 | struct TrigEvent { int a; IdList * b; }; |
| 173948 | 173958 | |
| 173949 | 173959 | struct FrameBound { int eType; Expr *pExpr; }; |
| 173960 | + |
| 173961 | +/* |
| 173962 | +** Generate a syntax error |
| 173963 | +*/ |
| 173964 | +static void parserSyntaxError(Parse *pParse, Token *p){ |
| 173965 | + sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", p); |
| 173966 | +} |
| 173950 | 173967 | |
| 173951 | 173968 | /* |
| 173952 | 173969 | ** Disable lookaside memory allocation for objects that might be |
| 173953 | 173970 | ** shared across database connections. |
| 173954 | 173971 | */ |
| | @@ -173977,11 +173994,10 @@ |
| 173977 | 173994 | sqlite3ExprListDelete(pParse->db, pOrderBy); |
| 173978 | 173995 | sqlite3ExprDelete(pParse->db, pLimit); |
| 173979 | 173996 | } |
| 173980 | 173997 | #endif /* SQLITE_ENABLE_UPDATE_DELETE_LIMIT */ |
| 173981 | 173998 | |
| 173982 | | -#line 517 "parse.y" |
| 173983 | 173999 | |
| 173984 | 174000 | /* |
| 173985 | 174001 | ** For a compound SELECT statement, make sure p->pPrior->pNext==p for |
| 173986 | 174002 | ** all elements in the list. And make sure list length does not exceed |
| 173987 | 174003 | ** SQLITE_LIMIT_COMPOUND_SELECT. |
| | @@ -174032,11 +174048,10 @@ |
| 174032 | 174048 | ** testing. |
| 174033 | 174049 | */ |
| 174034 | 174050 | static void *parserStackRealloc(void *pOld, sqlite3_uint64 newSize){ |
| 174035 | 174051 | return sqlite3FaultSim(700) ? 0 : sqlite3_realloc(pOld, newSize); |
| 174036 | 174052 | } |
| 174037 | | -#line 1085 "parse.y" |
| 174038 | 174053 | |
| 174039 | 174054 | |
| 174040 | 174055 | /* Construct a new Expr object from a single token */ |
| 174041 | 174056 | static Expr *tokenExpr(Parse *pParse, int op, Token t){ |
| 174042 | 174057 | Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1); |
| | @@ -174069,11 +174084,10 @@ |
| 174069 | 174084 | } |
| 174070 | 174085 | } |
| 174071 | 174086 | return p; |
| 174072 | 174087 | } |
| 174073 | 174088 | |
| 174074 | | -#line 1329 "parse.y" |
| 174075 | 174089 | |
| 174076 | 174090 | /* A routine to convert a binary TK_IS or TK_ISNOT expression into a |
| 174077 | 174091 | ** unary TK_ISNULL or TK_NOTNULL expression. */ |
| 174078 | 174092 | static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){ |
| 174079 | 174093 | sqlite3 *db = pParse->db; |
| | @@ -174081,11 +174095,10 @@ |
| 174081 | 174095 | pA->op = (u8)op; |
| 174082 | 174096 | sqlite3ExprDelete(db, pA->pRight); |
| 174083 | 174097 | pA->pRight = 0; |
| 174084 | 174098 | } |
| 174085 | 174099 | } |
| 174086 | | -#line 1564 "parse.y" |
| 174087 | 174100 | |
| 174088 | 174101 | /* Add a single new term to an ExprList that is used to store a |
| 174089 | 174102 | ** list of identifiers. Report an error if the ID list contains |
| 174090 | 174103 | ** a COLLATE clause or an ASC or DESC keyword, except ignore the |
| 174091 | 174104 | ** error while parsing a legacy schema. |
| | @@ -174105,16 +174118,14 @@ |
| 174105 | 174118 | pIdToken->n, pIdToken->z); |
| 174106 | 174119 | } |
| 174107 | 174120 | sqlite3ExprListSetName(pParse, p, pIdToken, 1); |
| 174108 | 174121 | return p; |
| 174109 | 174122 | } |
| 174110 | | -#line 2048 "parse.y" |
| 174111 | 174123 | |
| 174112 | 174124 | #if TK_SPAN>255 |
| 174113 | 174125 | # error too many tokens in the grammar |
| 174114 | 174126 | #endif |
| 174115 | | -#line 267 "parse.sql" |
| 174116 | 174127 | /**************** End of %include directives **********************************/ |
| 174117 | 174128 | /* These constants specify the various numeric values for terminal symbols. |
| 174118 | 174129 | ***************** Begin token definitions *************************************/ |
| 174119 | 174130 | #ifndef TK_SEMI |
| 174120 | 174131 | #define TK_SEMI 1 |
| | @@ -176295,13 +176306,11 @@ |
| 176295 | 176306 | case 240: /* selectnowith */ |
| 176296 | 176307 | case 241: /* oneselect */ |
| 176297 | 176308 | case 253: /* values */ |
| 176298 | 176309 | case 255: /* mvalues */ |
| 176299 | 176310 | { |
| 176300 | | -#line 511 "parse.y" |
| 176301 | 176311 | sqlite3SelectDelete(pParse->db, (yypminor->yy555)); |
| 176302 | | -#line 2453 "parse.sql" |
| 176303 | 176312 | } |
| 176304 | 176313 | break; |
| 176305 | 176314 | case 217: /* term */ |
| 176306 | 176315 | case 218: /* expr */ |
| 176307 | 176316 | case 247: /* where_opt */ |
| | @@ -176312,13 +176321,11 @@ |
| 176312 | 176321 | case 285: /* vinto */ |
| 176313 | 176322 | case 292: /* when_clause */ |
| 176314 | 176323 | case 297: /* key_opt */ |
| 176315 | 176324 | case 314: /* filter_clause */ |
| 176316 | 176325 | { |
| 176317 | | -#line 1083 "parse.y" |
| 176318 | 176326 | sqlite3ExprDelete(pParse->db, (yypminor->yy454)); |
| 176319 | | -#line 2470 "parse.sql" |
| 176320 | 176327 | } |
| 176321 | 176328 | break; |
| 176322 | 176329 | case 222: /* eidlist_opt */ |
| 176323 | 176330 | case 232: /* sortlist */ |
| 176324 | 176331 | case 233: /* eidlist */ |
| | @@ -176331,82 +176338,64 @@ |
| 176331 | 176338 | case 270: /* setlist */ |
| 176332 | 176339 | case 279: /* paren_exprlist */ |
| 176333 | 176340 | case 281: /* case_exprlist */ |
| 176334 | 176341 | case 313: /* part_opt */ |
| 176335 | 176342 | { |
| 176336 | | -#line 1562 "parse.y" |
| 176337 | 176343 | sqlite3ExprListDelete(pParse->db, (yypminor->yy14)); |
| 176338 | | -#line 2489 "parse.sql" |
| 176339 | 176344 | } |
| 176340 | 176345 | break; |
| 176341 | 176346 | case 239: /* fullname */ |
| 176342 | 176347 | case 246: /* from */ |
| 176343 | 176348 | case 258: /* seltablist */ |
| 176344 | 176349 | case 259: /* stl_prefix */ |
| 176345 | 176350 | case 264: /* xfullname */ |
| 176346 | 176351 | { |
| 176347 | | -#line 789 "parse.y" |
| 176348 | 176352 | sqlite3SrcListDelete(pParse->db, (yypminor->yy203)); |
| 176349 | | -#line 2500 "parse.sql" |
| 176350 | 176353 | } |
| 176351 | 176354 | break; |
| 176352 | 176355 | case 242: /* wqlist */ |
| 176353 | 176356 | { |
| 176354 | | -#line 1849 "parse.y" |
| 176355 | 176357 | sqlite3WithDelete(pParse->db, (yypminor->yy59)); |
| 176356 | | -#line 2507 "parse.sql" |
| 176357 | 176358 | } |
| 176358 | 176359 | break; |
| 176359 | 176360 | case 252: /* window_clause */ |
| 176360 | 176361 | case 309: /* windowdefn_list */ |
| 176361 | 176362 | { |
| 176362 | | -#line 1977 "parse.y" |
| 176363 | 176363 | sqlite3WindowListDelete(pParse->db, (yypminor->yy211)); |
| 176364 | | -#line 2515 "parse.sql" |
| 176365 | 176364 | } |
| 176366 | 176365 | break; |
| 176367 | 176366 | case 265: /* idlist */ |
| 176368 | 176367 | case 272: /* idlist_opt */ |
| 176369 | 176368 | { |
| 176370 | | -#line 1068 "parse.y" |
| 176371 | 176369 | sqlite3IdListDelete(pParse->db, (yypminor->yy132)); |
| 176372 | | -#line 2523 "parse.sql" |
| 176373 | 176370 | } |
| 176374 | 176371 | break; |
| 176375 | 176372 | case 275: /* filter_over */ |
| 176376 | 176373 | case 310: /* windowdefn */ |
| 176377 | 176374 | case 311: /* window */ |
| 176378 | 176375 | case 312: /* frame_opt */ |
| 176379 | 176376 | case 315: /* over_clause */ |
| 176380 | 176377 | { |
| 176381 | | -#line 1916 "parse.y" |
| 176382 | 176378 | sqlite3WindowDelete(pParse->db, (yypminor->yy211)); |
| 176383 | | -#line 2534 "parse.sql" |
| 176384 | 176379 | } |
| 176385 | 176380 | break; |
| 176386 | 176381 | case 288: /* trigger_cmd_list */ |
| 176387 | 176382 | case 293: /* trigger_cmd */ |
| 176388 | 176383 | { |
| 176389 | | -#line 1677 "parse.y" |
| 176390 | 176384 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy427)); |
| 176391 | | -#line 2542 "parse.sql" |
| 176392 | 176385 | } |
| 176393 | 176386 | break; |
| 176394 | 176387 | case 290: /* trigger_event */ |
| 176395 | 176388 | { |
| 176396 | | -#line 1663 "parse.y" |
| 176397 | 176389 | sqlite3IdListDelete(pParse->db, (yypminor->yy286).b); |
| 176398 | | -#line 2549 "parse.sql" |
| 176399 | 176390 | } |
| 176400 | 176391 | break; |
| 176401 | 176392 | case 317: /* frame_bound */ |
| 176402 | 176393 | case 318: /* frame_bound_s */ |
| 176403 | 176394 | case 319: /* frame_bound_e */ |
| 176404 | 176395 | { |
| 176405 | | -#line 1921 "parse.y" |
| 176406 | 176396 | sqlite3ExprDelete(pParse->db, (yypminor->yy509).pExpr); |
| 176407 | | -#line 2558 "parse.sql" |
| 176408 | 176397 | } |
| 176409 | 176398 | break; |
| 176410 | 176399 | /********* End destructor definitions *****************************************/ |
| 176411 | 176400 | default: break; /* If no destructor action specified: do nothing */ |
| 176412 | 176401 | } |
| | @@ -176637,14 +176626,12 @@ |
| 176637 | 176626 | #endif |
| 176638 | 176627 | while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); |
| 176639 | 176628 | /* Here code is inserted which will execute if the parser |
| 176640 | 176629 | ** stack every overflows */ |
| 176641 | 176630 | /******** Begin %stack_overflow code ******************************************/ |
| 176642 | | -#line 51 "parse.y" |
| 176643 | 176631 | |
| 176644 | 176632 | sqlite3OomFault(pParse->db); |
| 176645 | | -#line 2796 "parse.sql" |
| 176646 | 176633 | /******** End %stack_overflow code ********************************************/ |
| 176647 | 176634 | sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */ |
| 176648 | 176635 | sqlite3ParserCTX_STORE |
| 176649 | 176636 | } |
| 176650 | 176637 | |
| | @@ -177571,481 +177558,330 @@ |
| 177571 | 177558 | ** break; |
| 177572 | 177559 | */ |
| 177573 | 177560 | /********** Begin reduce actions **********************************************/ |
| 177574 | 177561 | YYMINORTYPE yylhsminor; |
| 177575 | 177562 | case 0: /* explain ::= EXPLAIN */ |
| 177576 | | -#line 155 "parse.y" |
| 177577 | 177563 | { if( pParse->pReprepare==0 ) pParse->explain = 1; } |
| 177578 | | -#line 3729 "parse.sql" |
| 177579 | 177564 | break; |
| 177580 | 177565 | case 1: /* explain ::= EXPLAIN QUERY PLAN */ |
| 177581 | | -#line 156 "parse.y" |
| 177582 | 177566 | { if( pParse->pReprepare==0 ) pParse->explain = 2; } |
| 177583 | | -#line 3734 "parse.sql" |
| 177584 | 177567 | break; |
| 177585 | 177568 | case 2: /* cmdx ::= cmd */ |
| 177586 | | -#line 158 "parse.y" |
| 177587 | 177569 | { sqlite3FinishCoding(pParse); } |
| 177588 | | -#line 3739 "parse.sql" |
| 177589 | 177570 | break; |
| 177590 | 177571 | case 3: /* cmd ::= BEGIN transtype trans_opt */ |
| 177591 | | -#line 163 "parse.y" |
| 177592 | 177572 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy144);} |
| 177593 | | -#line 3744 "parse.sql" |
| 177594 | 177573 | break; |
| 177595 | 177574 | case 4: /* transtype ::= */ |
| 177596 | | -#line 168 "parse.y" |
| 177597 | 177575 | {yymsp[1].minor.yy144 = TK_DEFERRED;} |
| 177598 | | -#line 3749 "parse.sql" |
| 177599 | 177576 | break; |
| 177600 | 177577 | case 5: /* transtype ::= DEFERRED */ |
| 177601 | 177578 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 177602 | 177579 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 177603 | 177580 | case 324: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==324); |
| 177604 | | -#line 169 "parse.y" |
| 177605 | 177581 | {yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/} |
| 177606 | | -#line 3757 "parse.sql" |
| 177607 | 177582 | break; |
| 177608 | 177583 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 177609 | 177584 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| 177610 | | -#line 172 "parse.y" |
| 177611 | 177585 | {sqlite3EndTransaction(pParse,yymsp[-1].major);} |
| 177612 | | -#line 3763 "parse.sql" |
| 177613 | 177586 | break; |
| 177614 | 177587 | case 10: /* cmd ::= SAVEPOINT nm */ |
| 177615 | | -#line 177 "parse.y" |
| 177616 | 177588 | { |
| 177617 | 177589 | sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0); |
| 177618 | 177590 | } |
| 177619 | | -#line 3770 "parse.sql" |
| 177620 | 177591 | break; |
| 177621 | 177592 | case 11: /* cmd ::= RELEASE savepoint_opt nm */ |
| 177622 | | -#line 180 "parse.y" |
| 177623 | 177593 | { |
| 177624 | 177594 | sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0); |
| 177625 | 177595 | } |
| 177626 | | -#line 3777 "parse.sql" |
| 177627 | 177596 | break; |
| 177628 | 177597 | case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 177629 | | -#line 183 "parse.y" |
| 177630 | 177598 | { |
| 177631 | 177599 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 177632 | 177600 | } |
| 177633 | | -#line 3784 "parse.sql" |
| 177634 | 177601 | break; |
| 177635 | 177602 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 177636 | | -#line 190 "parse.y" |
| 177637 | 177603 | { |
| 177638 | 177604 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy144,0,0,yymsp[-2].minor.yy144); |
| 177639 | 177605 | } |
| 177640 | | -#line 3791 "parse.sql" |
| 177641 | 177606 | break; |
| 177642 | 177607 | case 14: /* createkw ::= CREATE */ |
| 177643 | | -#line 193 "parse.y" |
| 177644 | 177608 | {disableLookaside(pParse);} |
| 177645 | | -#line 3796 "parse.sql" |
| 177646 | 177609 | break; |
| 177647 | 177610 | case 15: /* ifnotexists ::= */ |
| 177648 | 177611 | case 18: /* temp ::= */ yytestcase(yyruleno==18); |
| 177649 | 177612 | case 47: /* autoinc ::= */ yytestcase(yyruleno==47); |
| 177650 | 177613 | case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62); |
| 177651 | 177614 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 177652 | 177615 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 177653 | 177616 | case 100: /* distinct ::= */ yytestcase(yyruleno==100); |
| 177654 | 177617 | case 246: /* collate ::= */ yytestcase(yyruleno==246); |
| 177655 | | -#line 196 "parse.y" |
| 177656 | 177618 | {yymsp[1].minor.yy144 = 0;} |
| 177657 | | -#line 3808 "parse.sql" |
| 177658 | 177619 | break; |
| 177659 | 177620 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 177660 | | -#line 197 "parse.y" |
| 177661 | 177621 | {yymsp[-2].minor.yy144 = 1;} |
| 177662 | | -#line 3813 "parse.sql" |
| 177663 | 177622 | break; |
| 177664 | 177623 | case 17: /* temp ::= TEMP */ |
| 177665 | | -#line 200 "parse.y" |
| 177666 | 177624 | {yymsp[0].minor.yy144 = pParse->db->init.busy==0;} |
| 177667 | | -#line 3818 "parse.sql" |
| 177668 | 177625 | break; |
| 177669 | 177626 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */ |
| 177670 | | -#line 203 "parse.y" |
| 177671 | 177627 | { |
| 177672 | 177628 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy391,0); |
| 177673 | 177629 | } |
| 177674 | | -#line 3825 "parse.sql" |
| 177675 | 177630 | break; |
| 177676 | 177631 | case 20: /* create_table_args ::= AS select */ |
| 177677 | | -#line 206 "parse.y" |
| 177678 | 177632 | { |
| 177679 | 177633 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy555); |
| 177680 | 177634 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555); |
| 177681 | 177635 | } |
| 177682 | | -#line 3833 "parse.sql" |
| 177683 | 177636 | break; |
| 177684 | 177637 | case 21: /* table_option_set ::= */ |
| 177685 | | -#line 212 "parse.y" |
| 177686 | 177638 | {yymsp[1].minor.yy391 = 0;} |
| 177687 | | -#line 3838 "parse.sql" |
| 177688 | 177639 | break; |
| 177689 | 177640 | case 22: /* table_option_set ::= table_option_set COMMA table_option */ |
| 177690 | | -#line 214 "parse.y" |
| 177691 | 177641 | {yylhsminor.yy391 = yymsp[-2].minor.yy391|yymsp[0].minor.yy391;} |
| 177692 | | -#line 3843 "parse.sql" |
| 177693 | 177642 | yymsp[-2].minor.yy391 = yylhsminor.yy391; |
| 177694 | 177643 | break; |
| 177695 | 177644 | case 23: /* table_option ::= WITHOUT nm */ |
| 177696 | | -#line 215 "parse.y" |
| 177697 | 177645 | { |
| 177698 | 177646 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 177699 | 177647 | yymsp[-1].minor.yy391 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 177700 | 177648 | }else{ |
| 177701 | 177649 | yymsp[-1].minor.yy391 = 0; |
| 177702 | 177650 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 177703 | 177651 | } |
| 177704 | 177652 | } |
| 177705 | | -#line 3856 "parse.sql" |
| 177706 | 177653 | break; |
| 177707 | 177654 | case 24: /* table_option ::= nm */ |
| 177708 | | -#line 223 "parse.y" |
| 177709 | 177655 | { |
| 177710 | 177656 | if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){ |
| 177711 | 177657 | yylhsminor.yy391 = TF_Strict; |
| 177712 | 177658 | }else{ |
| 177713 | 177659 | yylhsminor.yy391 = 0; |
| 177714 | 177660 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 177715 | 177661 | } |
| 177716 | 177662 | } |
| 177717 | | -#line 3868 "parse.sql" |
| 177718 | 177663 | yymsp[0].minor.yy391 = yylhsminor.yy391; |
| 177719 | 177664 | break; |
| 177720 | 177665 | case 25: /* columnname ::= nm typetoken */ |
| 177721 | | -#line 233 "parse.y" |
| 177722 | 177666 | {sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);} |
| 177723 | | -#line 3874 "parse.sql" |
| 177724 | 177667 | break; |
| 177725 | 177668 | case 26: /* typetoken ::= */ |
| 177726 | 177669 | case 65: /* conslist_opt ::= */ yytestcase(yyruleno==65); |
| 177727 | 177670 | case 106: /* as ::= */ yytestcase(yyruleno==106); |
| 177728 | | -#line 327 "parse.y" |
| 177729 | 177671 | {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;} |
| 177730 | | -#line 3881 "parse.sql" |
| 177731 | 177672 | break; |
| 177732 | 177673 | case 27: /* typetoken ::= typename LP signed RP */ |
| 177733 | | -#line 329 "parse.y" |
| 177734 | 177674 | { |
| 177735 | 177675 | yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); |
| 177736 | 177676 | } |
| 177737 | | -#line 3888 "parse.sql" |
| 177738 | 177677 | break; |
| 177739 | 177678 | case 28: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 177740 | | -#line 332 "parse.y" |
| 177741 | 177679 | { |
| 177742 | 177680 | yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 177743 | 177681 | } |
| 177744 | | -#line 3895 "parse.sql" |
| 177745 | 177682 | break; |
| 177746 | 177683 | case 29: /* typename ::= typename ID|STRING */ |
| 177747 | | -#line 337 "parse.y" |
| 177748 | 177684 | {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 177749 | | -#line 3900 "parse.sql" |
| 177750 | 177685 | break; |
| 177751 | 177686 | case 30: /* scanpt ::= */ |
| 177752 | | -#line 355 "parse.y" |
| 177753 | 177687 | { |
| 177754 | 177688 | assert( yyLookahead!=YYNOCODE ); |
| 177755 | 177689 | yymsp[1].minor.yy168 = yyLookaheadToken.z; |
| 177756 | 177690 | } |
| 177757 | | -#line 3908 "parse.sql" |
| 177758 | 177691 | break; |
| 177759 | 177692 | case 31: /* scantok ::= */ |
| 177760 | | -#line 359 "parse.y" |
| 177761 | 177693 | { |
| 177762 | 177694 | assert( yyLookahead!=YYNOCODE ); |
| 177763 | 177695 | yymsp[1].minor.yy0 = yyLookaheadToken; |
| 177764 | 177696 | } |
| 177765 | | -#line 3916 "parse.sql" |
| 177766 | 177697 | break; |
| 177767 | 177698 | case 32: /* ccons ::= CONSTRAINT nm */ |
| 177768 | 177699 | case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67); |
| 177769 | | -#line 369 "parse.y" |
| 177770 | 177700 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 177771 | | -#line 3922 "parse.sql" |
| 177772 | 177701 | break; |
| 177773 | 177702 | case 33: /* ccons ::= DEFAULT scantok term */ |
| 177774 | | -#line 371 "parse.y" |
| 177775 | 177703 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 177776 | | -#line 3927 "parse.sql" |
| 177777 | 177704 | break; |
| 177778 | 177705 | case 34: /* ccons ::= DEFAULT LP expr RP */ |
| 177779 | | -#line 373 "parse.y" |
| 177780 | 177706 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} |
| 177781 | | -#line 3932 "parse.sql" |
| 177782 | 177707 | break; |
| 177783 | 177708 | case 35: /* ccons ::= DEFAULT PLUS scantok term */ |
| 177784 | | -#line 375 "parse.y" |
| 177785 | 177709 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 177786 | | -#line 3937 "parse.sql" |
| 177787 | 177710 | break; |
| 177788 | 177711 | case 36: /* ccons ::= DEFAULT MINUS scantok term */ |
| 177789 | | -#line 376 "parse.y" |
| 177790 | 177712 | { |
| 177791 | 177713 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0); |
| 177792 | 177714 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); |
| 177793 | 177715 | } |
| 177794 | | -#line 3945 "parse.sql" |
| 177795 | 177716 | break; |
| 177796 | 177717 | case 37: /* ccons ::= DEFAULT scantok ID|INDEXED */ |
| 177797 | | -#line 380 "parse.y" |
| 177798 | 177718 | { |
| 177799 | 177719 | Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0); |
| 177800 | 177720 | if( p ){ |
| 177801 | 177721 | sqlite3ExprIdToTrueFalse(p); |
| 177802 | 177722 | testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) ); |
| 177803 | 177723 | } |
| 177804 | 177724 | sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n); |
| 177805 | 177725 | } |
| 177806 | | -#line 3957 "parse.sql" |
| 177807 | 177726 | break; |
| 177808 | 177727 | case 38: /* ccons ::= NOT NULL onconf */ |
| 177809 | | -#line 393 "parse.y" |
| 177810 | 177728 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy144);} |
| 177811 | | -#line 3962 "parse.sql" |
| 177812 | 177729 | break; |
| 177813 | 177730 | case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 177814 | | -#line 395 "parse.y" |
| 177815 | 177731 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy144,yymsp[0].minor.yy144,yymsp[-2].minor.yy144);} |
| 177816 | | -#line 3967 "parse.sql" |
| 177817 | 177732 | break; |
| 177818 | 177733 | case 40: /* ccons ::= UNIQUE onconf */ |
| 177819 | | -#line 396 "parse.y" |
| 177820 | 177734 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy144,0,0,0,0, |
| 177821 | 177735 | SQLITE_IDXTYPE_UNIQUE);} |
| 177822 | | -#line 3973 "parse.sql" |
| 177823 | 177736 | break; |
| 177824 | 177737 | case 41: /* ccons ::= CHECK LP expr RP */ |
| 177825 | | -#line 398 "parse.y" |
| 177826 | 177738 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} |
| 177827 | | -#line 3978 "parse.sql" |
| 177828 | 177739 | break; |
| 177829 | 177740 | case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 177830 | | -#line 400 "parse.y" |
| 177831 | 177741 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy144);} |
| 177832 | | -#line 3983 "parse.sql" |
| 177833 | 177742 | break; |
| 177834 | 177743 | case 43: /* ccons ::= defer_subclause */ |
| 177835 | | -#line 401 "parse.y" |
| 177836 | 177744 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy144);} |
| 177837 | | -#line 3988 "parse.sql" |
| 177838 | 177745 | break; |
| 177839 | 177746 | case 44: /* ccons ::= COLLATE ID|STRING */ |
| 177840 | | -#line 402 "parse.y" |
| 177841 | 177747 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 177842 | | -#line 3993 "parse.sql" |
| 177843 | 177748 | break; |
| 177844 | 177749 | case 45: /* generated ::= LP expr RP */ |
| 177845 | | -#line 405 "parse.y" |
| 177846 | 177750 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy454,0);} |
| 177847 | | -#line 3998 "parse.sql" |
| 177848 | 177751 | break; |
| 177849 | 177752 | case 46: /* generated ::= LP expr RP ID */ |
| 177850 | | -#line 406 "parse.y" |
| 177851 | 177753 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy454,&yymsp[0].minor.yy0);} |
| 177852 | | -#line 4003 "parse.sql" |
| 177853 | 177754 | break; |
| 177854 | 177755 | case 48: /* autoinc ::= AUTOINCR */ |
| 177855 | | -#line 411 "parse.y" |
| 177856 | 177756 | {yymsp[0].minor.yy144 = 1;} |
| 177857 | | -#line 4008 "parse.sql" |
| 177858 | 177757 | break; |
| 177859 | 177758 | case 49: /* refargs ::= */ |
| 177860 | | -#line 419 "parse.y" |
| 177861 | 177759 | { yymsp[1].minor.yy144 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 177862 | | -#line 4013 "parse.sql" |
| 177863 | 177760 | break; |
| 177864 | 177761 | case 50: /* refargs ::= refargs refarg */ |
| 177865 | | -#line 420 "parse.y" |
| 177866 | 177762 | { yymsp[-1].minor.yy144 = (yymsp[-1].minor.yy144 & ~yymsp[0].minor.yy383.mask) | yymsp[0].minor.yy383.value; } |
| 177867 | | -#line 4018 "parse.sql" |
| 177868 | 177763 | break; |
| 177869 | 177764 | case 51: /* refarg ::= MATCH nm */ |
| 177870 | | -#line 422 "parse.y" |
| 177871 | 177765 | { yymsp[-1].minor.yy383.value = 0; yymsp[-1].minor.yy383.mask = 0x000000; } |
| 177872 | | -#line 4023 "parse.sql" |
| 177873 | 177766 | break; |
| 177874 | 177767 | case 52: /* refarg ::= ON INSERT refact */ |
| 177875 | | -#line 423 "parse.y" |
| 177876 | 177768 | { yymsp[-2].minor.yy383.value = 0; yymsp[-2].minor.yy383.mask = 0x000000; } |
| 177877 | | -#line 4028 "parse.sql" |
| 177878 | 177769 | break; |
| 177879 | 177770 | case 53: /* refarg ::= ON DELETE refact */ |
| 177880 | | -#line 424 "parse.y" |
| 177881 | 177771 | { yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144; yymsp[-2].minor.yy383.mask = 0x0000ff; } |
| 177882 | | -#line 4033 "parse.sql" |
| 177883 | 177772 | break; |
| 177884 | 177773 | case 54: /* refarg ::= ON UPDATE refact */ |
| 177885 | | -#line 425 "parse.y" |
| 177886 | 177774 | { yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144<<8; yymsp[-2].minor.yy383.mask = 0x00ff00; } |
| 177887 | | -#line 4038 "parse.sql" |
| 177888 | 177775 | break; |
| 177889 | 177776 | case 55: /* refact ::= SET NULL */ |
| 177890 | | -#line 427 "parse.y" |
| 177891 | 177777 | { yymsp[-1].minor.yy144 = OE_SetNull; /* EV: R-33326-45252 */} |
| 177892 | | -#line 4043 "parse.sql" |
| 177893 | 177778 | break; |
| 177894 | 177779 | case 56: /* refact ::= SET DEFAULT */ |
| 177895 | | -#line 428 "parse.y" |
| 177896 | 177780 | { yymsp[-1].minor.yy144 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 177897 | | -#line 4048 "parse.sql" |
| 177898 | 177781 | break; |
| 177899 | 177782 | case 57: /* refact ::= CASCADE */ |
| 177900 | | -#line 429 "parse.y" |
| 177901 | 177783 | { yymsp[0].minor.yy144 = OE_Cascade; /* EV: R-33326-45252 */} |
| 177902 | | -#line 4053 "parse.sql" |
| 177903 | 177784 | break; |
| 177904 | 177785 | case 58: /* refact ::= RESTRICT */ |
| 177905 | | -#line 430 "parse.y" |
| 177906 | 177786 | { yymsp[0].minor.yy144 = OE_Restrict; /* EV: R-33326-45252 */} |
| 177907 | | -#line 4058 "parse.sql" |
| 177908 | 177787 | break; |
| 177909 | 177788 | case 59: /* refact ::= NO ACTION */ |
| 177910 | | -#line 431 "parse.y" |
| 177911 | 177789 | { yymsp[-1].minor.yy144 = OE_None; /* EV: R-33326-45252 */} |
| 177912 | | -#line 4063 "parse.sql" |
| 177913 | 177790 | break; |
| 177914 | 177791 | case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 177915 | | -#line 433 "parse.y" |
| 177916 | 177792 | {yymsp[-2].minor.yy144 = 0;} |
| 177917 | | -#line 4068 "parse.sql" |
| 177918 | 177793 | break; |
| 177919 | 177794 | case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 177920 | 177795 | case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76); |
| 177921 | 177796 | case 173: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==173); |
| 177922 | | -#line 434 "parse.y" |
| 177923 | 177797 | {yymsp[-1].minor.yy144 = yymsp[0].minor.yy144;} |
| 177924 | | -#line 4075 "parse.sql" |
| 177925 | 177798 | break; |
| 177926 | 177799 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 177927 | 177800 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 177928 | 177801 | case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219); |
| 177929 | 177802 | case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222); |
| 177930 | 177803 | case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247); |
| 177931 | | -#line 437 "parse.y" |
| 177932 | 177804 | {yymsp[-1].minor.yy144 = 1;} |
| 177933 | | -#line 4084 "parse.sql" |
| 177934 | 177805 | break; |
| 177935 | 177806 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 177936 | | -#line 438 "parse.y" |
| 177937 | 177807 | {yymsp[-1].minor.yy144 = 0;} |
| 177938 | | -#line 4089 "parse.sql" |
| 177939 | 177808 | break; |
| 177940 | 177809 | case 66: /* tconscomma ::= COMMA */ |
| 177941 | | -#line 444 "parse.y" |
| 177942 | 177810 | {pParse->constraintName.n = 0;} |
| 177943 | | -#line 4094 "parse.sql" |
| 177944 | 177811 | break; |
| 177945 | 177812 | case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 177946 | | -#line 448 "parse.y" |
| 177947 | 177813 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy144,yymsp[-2].minor.yy144,0);} |
| 177948 | | -#line 4099 "parse.sql" |
| 177949 | 177814 | break; |
| 177950 | 177815 | case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 177951 | | -#line 450 "parse.y" |
| 177952 | 177816 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy144,0,0,0,0, |
| 177953 | 177817 | SQLITE_IDXTYPE_UNIQUE);} |
| 177954 | | -#line 4105 "parse.sql" |
| 177955 | 177818 | break; |
| 177956 | 177819 | case 70: /* tcons ::= CHECK LP expr RP onconf */ |
| 177957 | | -#line 453 "parse.y" |
| 177958 | 177820 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} |
| 177959 | | -#line 4110 "parse.sql" |
| 177960 | 177821 | break; |
| 177961 | 177822 | case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 177962 | | -#line 455 "parse.y" |
| 177963 | 177823 | { |
| 177964 | 177824 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy144); |
| 177965 | 177825 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy144); |
| 177966 | 177826 | } |
| 177967 | | -#line 4118 "parse.sql" |
| 177968 | 177827 | break; |
| 177969 | 177828 | case 73: /* onconf ::= */ |
| 177970 | 177829 | case 75: /* orconf ::= */ yytestcase(yyruleno==75); |
| 177971 | | -#line 469 "parse.y" |
| 177972 | 177830 | {yymsp[1].minor.yy144 = OE_Default;} |
| 177973 | | -#line 4124 "parse.sql" |
| 177974 | 177831 | break; |
| 177975 | 177832 | case 74: /* onconf ::= ON CONFLICT resolvetype */ |
| 177976 | | -#line 470 "parse.y" |
| 177977 | 177833 | {yymsp[-2].minor.yy144 = yymsp[0].minor.yy144;} |
| 177978 | | -#line 4129 "parse.sql" |
| 177979 | 177834 | break; |
| 177980 | 177835 | case 77: /* resolvetype ::= IGNORE */ |
| 177981 | | -#line 474 "parse.y" |
| 177982 | 177836 | {yymsp[0].minor.yy144 = OE_Ignore;} |
| 177983 | | -#line 4134 "parse.sql" |
| 177984 | 177837 | break; |
| 177985 | 177838 | case 78: /* resolvetype ::= REPLACE */ |
| 177986 | 177839 | case 174: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==174); |
| 177987 | | -#line 475 "parse.y" |
| 177988 | 177840 | {yymsp[0].minor.yy144 = OE_Replace;} |
| 177989 | | -#line 4140 "parse.sql" |
| 177990 | 177841 | break; |
| 177991 | 177842 | case 79: /* cmd ::= DROP TABLE ifexists fullname */ |
| 177992 | | -#line 479 "parse.y" |
| 177993 | 177843 | { |
| 177994 | 177844 | sqlite3DropTable(pParse, yymsp[0].minor.yy203, 0, yymsp[-1].minor.yy144); |
| 177995 | 177845 | } |
| 177996 | | -#line 4147 "parse.sql" |
| 177997 | 177846 | break; |
| 177998 | 177847 | case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 177999 | | -#line 490 "parse.y" |
| 178000 | 177848 | { |
| 178001 | 177849 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[0].minor.yy555, yymsp[-7].minor.yy144, yymsp[-5].minor.yy144); |
| 178002 | 177850 | } |
| 178003 | | -#line 4154 "parse.sql" |
| 178004 | 177851 | break; |
| 178005 | 177852 | case 83: /* cmd ::= DROP VIEW ifexists fullname */ |
| 178006 | | -#line 493 "parse.y" |
| 178007 | 177853 | { |
| 178008 | 177854 | sqlite3DropTable(pParse, yymsp[0].minor.yy203, 1, yymsp[-1].minor.yy144); |
| 178009 | 177855 | } |
| 178010 | | -#line 4161 "parse.sql" |
| 178011 | 177856 | break; |
| 178012 | 177857 | case 84: /* cmd ::= select */ |
| 178013 | | -#line 500 "parse.y" |
| 178014 | 177858 | { |
| 178015 | 177859 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; |
| 178016 | 177860 | if( (pParse->db->mDbFlags & DBFLAG_EncodingFixed)!=0 |
| 178017 | 177861 | || sqlite3ReadSchema(pParse)==SQLITE_OK |
| 178018 | 177862 | ){ |
| 178019 | 177863 | sqlite3Select(pParse, yymsp[0].minor.yy555, &dest); |
| 178020 | 177864 | } |
| 178021 | 177865 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555); |
| 178022 | 177866 | } |
| 178023 | | -#line 4174 "parse.sql" |
| 178024 | 177867 | break; |
| 178025 | 177868 | case 85: /* select ::= WITH wqlist selectnowith */ |
| 178026 | | -#line 574 "parse.y" |
| 178027 | 177869 | {yymsp[-2].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);} |
| 178028 | | -#line 4179 "parse.sql" |
| 178029 | 177870 | break; |
| 178030 | 177871 | case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */ |
| 178031 | | -#line 576 "parse.y" |
| 178032 | 177872 | {yymsp[-3].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);} |
| 178033 | | -#line 4184 "parse.sql" |
| 178034 | 177873 | break; |
| 178035 | 177874 | case 87: /* select ::= selectnowith */ |
| 178036 | | -#line 579 "parse.y" |
| 178037 | 177875 | { |
| 178038 | 177876 | Select *p = yymsp[0].minor.yy555; |
| 178039 | 177877 | if( p ){ |
| 178040 | 177878 | parserDoubleLinkSelect(pParse, p); |
| 178041 | 177879 | } |
| 178042 | 177880 | } |
| 178043 | | -#line 4194 "parse.sql" |
| 178044 | 177881 | break; |
| 178045 | 177882 | case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */ |
| 178046 | | -#line 588 "parse.y" |
| 178047 | 177883 | { |
| 178048 | 177884 | Select *pRhs = yymsp[0].minor.yy555; |
| 178049 | 177885 | Select *pLhs = yymsp[-2].minor.yy555; |
| 178050 | 177886 | if( pRhs && pRhs->pPrior ){ |
| 178051 | 177887 | SrcList *pFrom; |
| | @@ -178064,175 +177900,131 @@ |
| 178064 | 177900 | }else{ |
| 178065 | 177901 | sqlite3SelectDelete(pParse->db, pLhs); |
| 178066 | 177902 | } |
| 178067 | 177903 | yymsp[-2].minor.yy555 = pRhs; |
| 178068 | 177904 | } |
| 178069 | | -#line 4220 "parse.sql" |
| 178070 | 177905 | break; |
| 178071 | 177906 | case 89: /* multiselect_op ::= UNION */ |
| 178072 | 177907 | case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91); |
| 178073 | | -#line 611 "parse.y" |
| 178074 | 177908 | {yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-OP*/} |
| 178075 | | -#line 4226 "parse.sql" |
| 178076 | 177909 | break; |
| 178077 | 177910 | case 90: /* multiselect_op ::= UNION ALL */ |
| 178078 | | -#line 612 "parse.y" |
| 178079 | 177911 | {yymsp[-1].minor.yy144 = TK_ALL;} |
| 178080 | | -#line 4231 "parse.sql" |
| 178081 | 177912 | break; |
| 178082 | 177913 | case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 178083 | | -#line 618 "parse.y" |
| 178084 | 177914 | { |
| 178085 | 177915 | yymsp[-8].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy203,yymsp[-4].minor.yy454,yymsp[-3].minor.yy14,yymsp[-2].minor.yy454,yymsp[-1].minor.yy14,yymsp[-7].minor.yy144,yymsp[0].minor.yy454); |
| 178086 | 177916 | } |
| 178087 | | -#line 4238 "parse.sql" |
| 178088 | 177917 | break; |
| 178089 | 177918 | case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 178090 | | -#line 624 "parse.y" |
| 178091 | 177919 | { |
| 178092 | 177920 | yymsp[-9].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy14,yymsp[-6].minor.yy203,yymsp[-5].minor.yy454,yymsp[-4].minor.yy14,yymsp[-3].minor.yy454,yymsp[-1].minor.yy14,yymsp[-8].minor.yy144,yymsp[0].minor.yy454); |
| 178093 | 177921 | if( yymsp[-9].minor.yy555 ){ |
| 178094 | 177922 | yymsp[-9].minor.yy555->pWinDefn = yymsp[-2].minor.yy211; |
| 178095 | 177923 | }else{ |
| 178096 | 177924 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy211); |
| 178097 | 177925 | } |
| 178098 | 177926 | } |
| 178099 | | -#line 4250 "parse.sql" |
| 178100 | 177927 | break; |
| 178101 | 177928 | case 94: /* values ::= VALUES LP nexprlist RP */ |
| 178102 | | -#line 640 "parse.y" |
| 178103 | 177929 | { |
| 178104 | 177930 | yymsp[-3].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0); |
| 178105 | 177931 | } |
| 178106 | | -#line 4257 "parse.sql" |
| 178107 | 177932 | break; |
| 178108 | 177933 | case 95: /* oneselect ::= mvalues */ |
| 178109 | | -#line 647 "parse.y" |
| 178110 | 177934 | { |
| 178111 | 177935 | sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy555); |
| 178112 | 177936 | } |
| 178113 | | -#line 4264 "parse.sql" |
| 178114 | 177937 | break; |
| 178115 | 177938 | case 96: /* mvalues ::= values COMMA LP nexprlist RP */ |
| 178116 | 177939 | case 97: /* mvalues ::= mvalues COMMA LP nexprlist RP */ yytestcase(yyruleno==97); |
| 178117 | | -#line 651 "parse.y" |
| 178118 | 177940 | { |
| 178119 | 177941 | yymsp[-4].minor.yy555 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy555, yymsp[-1].minor.yy14); |
| 178120 | 177942 | } |
| 178121 | | -#line 4272 "parse.sql" |
| 178122 | 177943 | break; |
| 178123 | 177944 | case 98: /* distinct ::= DISTINCT */ |
| 178124 | | -#line 662 "parse.y" |
| 178125 | 177945 | {yymsp[0].minor.yy144 = SF_Distinct;} |
| 178126 | | -#line 4277 "parse.sql" |
| 178127 | 177946 | break; |
| 178128 | 177947 | case 99: /* distinct ::= ALL */ |
| 178129 | | -#line 663 "parse.y" |
| 178130 | 177948 | {yymsp[0].minor.yy144 = SF_All;} |
| 178131 | | -#line 4282 "parse.sql" |
| 178132 | 177949 | break; |
| 178133 | 177950 | case 101: /* sclp ::= */ |
| 178134 | 177951 | case 134: /* orderby_opt ::= */ yytestcase(yyruleno==134); |
| 178135 | 177952 | case 144: /* groupby_opt ::= */ yytestcase(yyruleno==144); |
| 178136 | 177953 | case 234: /* exprlist ::= */ yytestcase(yyruleno==234); |
| 178137 | 177954 | case 237: /* paren_exprlist ::= */ yytestcase(yyruleno==237); |
| 178138 | 177955 | case 242: /* eidlist_opt ::= */ yytestcase(yyruleno==242); |
| 178139 | | -#line 676 "parse.y" |
| 178140 | 177956 | {yymsp[1].minor.yy14 = 0;} |
| 178141 | | -#line 4292 "parse.sql" |
| 178142 | 177957 | break; |
| 178143 | 177958 | case 102: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 178144 | | -#line 677 "parse.y" |
| 178145 | 177959 | { |
| 178146 | 177960 | yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[-2].minor.yy454); |
| 178147 | 177961 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[0].minor.yy0, 1); |
| 178148 | 177962 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy14,yymsp[-3].minor.yy168,yymsp[-1].minor.yy168); |
| 178149 | 177963 | } |
| 178150 | | -#line 4301 "parse.sql" |
| 178151 | 177964 | break; |
| 178152 | 177965 | case 103: /* selcollist ::= sclp scanpt STAR */ |
| 178153 | | -#line 682 "parse.y" |
| 178154 | 177966 | { |
| 178155 | 177967 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); |
| 178156 | 177968 | sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail)); |
| 178157 | 177969 | yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, p); |
| 178158 | 177970 | } |
| 178159 | | -#line 4310 "parse.sql" |
| 178160 | 177971 | break; |
| 178161 | 177972 | case 104: /* selcollist ::= sclp scanpt nm DOT STAR */ |
| 178162 | | -#line 687 "parse.y" |
| 178163 | 177973 | { |
| 178164 | 177974 | Expr *pRight, *pLeft, *pDot; |
| 178165 | 177975 | pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); |
| 178166 | 177976 | sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail)); |
| 178167 | 177977 | pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0); |
| 178168 | 177978 | pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 178169 | 177979 | yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, pDot); |
| 178170 | 177980 | } |
| 178171 | | -#line 4322 "parse.sql" |
| 178172 | 177981 | break; |
| 178173 | 177982 | case 105: /* as ::= AS nm */ |
| 178174 | 177983 | case 117: /* dbnm ::= DOT nm */ yytestcase(yyruleno==117); |
| 178175 | 177984 | case 258: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==258); |
| 178176 | 177985 | case 259: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==259); |
| 178177 | | -#line 700 "parse.y" |
| 178178 | 177986 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 178179 | | -#line 4330 "parse.sql" |
| 178180 | 177987 | break; |
| 178181 | 177988 | case 107: /* from ::= */ |
| 178182 | 177989 | case 110: /* stl_prefix ::= */ yytestcase(yyruleno==110); |
| 178183 | | -#line 714 "parse.y" |
| 178184 | 177990 | {yymsp[1].minor.yy203 = 0;} |
| 178185 | | -#line 4336 "parse.sql" |
| 178186 | 177991 | break; |
| 178187 | 177992 | case 108: /* from ::= FROM seltablist */ |
| 178188 | | -#line 715 "parse.y" |
| 178189 | 177993 | { |
| 178190 | 177994 | yymsp[-1].minor.yy203 = yymsp[0].minor.yy203; |
| 178191 | 177995 | sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy203); |
| 178192 | 177996 | } |
| 178193 | | -#line 4344 "parse.sql" |
| 178194 | 177997 | break; |
| 178195 | 177998 | case 109: /* stl_prefix ::= seltablist joinop */ |
| 178196 | | -#line 723 "parse.y" |
| 178197 | 177999 | { |
| 178198 | 178000 | if( ALWAYS(yymsp[-1].minor.yy203 && yymsp[-1].minor.yy203->nSrc>0) ) yymsp[-1].minor.yy203->a[yymsp[-1].minor.yy203->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy144; |
| 178199 | 178001 | } |
| 178200 | | -#line 4351 "parse.sql" |
| 178201 | 178002 | break; |
| 178202 | 178003 | case 111: /* seltablist ::= stl_prefix nm dbnm as on_using */ |
| 178203 | | -#line 727 "parse.y" |
| 178204 | 178004 | { |
| 178205 | 178005 | yymsp[-4].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy203,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269); |
| 178206 | 178006 | } |
| 178207 | | -#line 4358 "parse.sql" |
| 178208 | 178007 | break; |
| 178209 | 178008 | case 112: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ |
| 178210 | | -#line 730 "parse.y" |
| 178211 | 178009 | { |
| 178212 | 178010 | yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy269); |
| 178213 | 178011 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-1].minor.yy0); |
| 178214 | 178012 | } |
| 178215 | | -#line 4366 "parse.sql" |
| 178216 | 178013 | break; |
| 178217 | 178014 | case 113: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ |
| 178218 | | -#line 734 "parse.y" |
| 178219 | 178015 | { |
| 178220 | 178016 | yymsp[-7].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy203,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269); |
| 178221 | 178017 | sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy203, yymsp[-3].minor.yy14); |
| 178222 | 178018 | } |
| 178223 | | -#line 4374 "parse.sql" |
| 178224 | 178019 | break; |
| 178225 | 178020 | case 114: /* seltablist ::= stl_prefix LP select RP as on_using */ |
| 178226 | | -#line 739 "parse.y" |
| 178227 | 178021 | { |
| 178228 | 178022 | yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy555,&yymsp[0].minor.yy269); |
| 178229 | 178023 | } |
| 178230 | | -#line 4381 "parse.sql" |
| 178231 | 178024 | break; |
| 178232 | 178025 | case 115: /* seltablist ::= stl_prefix LP seltablist RP as on_using */ |
| 178233 | | -#line 742 "parse.y" |
| 178234 | 178026 | { |
| 178235 | 178027 | if( yymsp[-5].minor.yy203==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy269.pOn==0 && yymsp[0].minor.yy269.pUsing==0 ){ |
| 178236 | 178028 | yymsp[-5].minor.yy203 = yymsp[-3].minor.yy203; |
| 178237 | 178029 | }else if( ALWAYS(yymsp[-3].minor.yy203!=0) && yymsp[-3].minor.yy203->nSrc==1 ){ |
| 178238 | 178030 | yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269); |
| | @@ -178269,210 +178061,144 @@ |
| 178269 | 178061 | sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy203); |
| 178270 | 178062 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy203,0,0,0,0,SF_NestedFrom,0); |
| 178271 | 178063 | yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy269); |
| 178272 | 178064 | } |
| 178273 | 178065 | } |
| 178274 | | -#line 4425 "parse.sql" |
| 178275 | 178066 | break; |
| 178276 | 178067 | case 116: /* dbnm ::= */ |
| 178277 | 178068 | case 131: /* indexed_opt ::= */ yytestcase(yyruleno==131); |
| 178278 | | -#line 785 "parse.y" |
| 178279 | 178069 | {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} |
| 178280 | | -#line 4431 "parse.sql" |
| 178281 | 178070 | break; |
| 178282 | 178071 | case 118: /* fullname ::= nm */ |
| 178283 | | -#line 790 "parse.y" |
| 178284 | 178072 | { |
| 178285 | 178073 | yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 178286 | 178074 | if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0); |
| 178287 | 178075 | } |
| 178288 | | -#line 4439 "parse.sql" |
| 178289 | 178076 | yymsp[0].minor.yy203 = yylhsminor.yy203; |
| 178290 | 178077 | break; |
| 178291 | 178078 | case 119: /* fullname ::= nm DOT nm */ |
| 178292 | | -#line 794 "parse.y" |
| 178293 | 178079 | { |
| 178294 | 178080 | yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 178295 | 178081 | if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0); |
| 178296 | 178082 | } |
| 178297 | | -#line 4448 "parse.sql" |
| 178298 | 178083 | yymsp[-2].minor.yy203 = yylhsminor.yy203; |
| 178299 | 178084 | break; |
| 178300 | 178085 | case 120: /* xfullname ::= nm */ |
| 178301 | | -#line 802 "parse.y" |
| 178302 | 178086 | {yymsp[0].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 178303 | | -#line 4454 "parse.sql" |
| 178304 | 178087 | break; |
| 178305 | 178088 | case 121: /* xfullname ::= nm DOT nm */ |
| 178306 | | -#line 804 "parse.y" |
| 178307 | 178089 | {yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 178308 | | -#line 4459 "parse.sql" |
| 178309 | 178090 | break; |
| 178310 | 178091 | case 122: /* xfullname ::= nm DOT nm AS nm */ |
| 178311 | | -#line 805 "parse.y" |
| 178312 | 178092 | { |
| 178313 | 178093 | yymsp[-4].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 178314 | 178094 | if( yymsp[-4].minor.yy203 ) yymsp[-4].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 178315 | 178095 | } |
| 178316 | | -#line 4467 "parse.sql" |
| 178317 | 178096 | break; |
| 178318 | 178097 | case 123: /* xfullname ::= nm AS nm */ |
| 178319 | | -#line 809 "parse.y" |
| 178320 | 178098 | { |
| 178321 | 178099 | yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 178322 | 178100 | if( yymsp[-2].minor.yy203 ) yymsp[-2].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 178323 | 178101 | } |
| 178324 | | -#line 4475 "parse.sql" |
| 178325 | 178102 | break; |
| 178326 | 178103 | case 124: /* joinop ::= COMMA|JOIN */ |
| 178327 | | -#line 815 "parse.y" |
| 178328 | 178104 | { yymsp[0].minor.yy144 = JT_INNER; } |
| 178329 | | -#line 4480 "parse.sql" |
| 178330 | 178105 | break; |
| 178331 | 178106 | case 125: /* joinop ::= JOIN_KW JOIN */ |
| 178332 | | -#line 817 "parse.y" |
| 178333 | 178107 | {yymsp[-1].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 178334 | | -#line 4485 "parse.sql" |
| 178335 | 178108 | break; |
| 178336 | 178109 | case 126: /* joinop ::= JOIN_KW nm JOIN */ |
| 178337 | | -#line 819 "parse.y" |
| 178338 | 178110 | {yymsp[-2].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 178339 | | -#line 4490 "parse.sql" |
| 178340 | 178111 | break; |
| 178341 | 178112 | case 127: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 178342 | | -#line 821 "parse.y" |
| 178343 | 178113 | {yymsp[-3].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 178344 | | -#line 4495 "parse.sql" |
| 178345 | 178114 | break; |
| 178346 | 178115 | case 128: /* on_using ::= ON expr */ |
| 178347 | | -#line 842 "parse.y" |
| 178348 | 178116 | {yymsp[-1].minor.yy269.pOn = yymsp[0].minor.yy454; yymsp[-1].minor.yy269.pUsing = 0;} |
| 178349 | | -#line 4500 "parse.sql" |
| 178350 | 178117 | break; |
| 178351 | 178118 | case 129: /* on_using ::= USING LP idlist RP */ |
| 178352 | | -#line 843 "parse.y" |
| 178353 | 178119 | {yymsp[-3].minor.yy269.pOn = 0; yymsp[-3].minor.yy269.pUsing = yymsp[-1].minor.yy132;} |
| 178354 | | -#line 4505 "parse.sql" |
| 178355 | 178120 | break; |
| 178356 | 178121 | case 130: /* on_using ::= */ |
| 178357 | | -#line 844 "parse.y" |
| 178358 | 178122 | {yymsp[1].minor.yy269.pOn = 0; yymsp[1].minor.yy269.pUsing = 0;} |
| 178359 | | -#line 4510 "parse.sql" |
| 178360 | 178123 | break; |
| 178361 | 178124 | case 132: /* indexed_by ::= INDEXED BY nm */ |
| 178362 | | -#line 860 "parse.y" |
| 178363 | 178125 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| 178364 | | -#line 4515 "parse.sql" |
| 178365 | 178126 | break; |
| 178366 | 178127 | case 133: /* indexed_by ::= NOT INDEXED */ |
| 178367 | | -#line 861 "parse.y" |
| 178368 | 178128 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 178369 | | -#line 4520 "parse.sql" |
| 178370 | 178129 | break; |
| 178371 | 178130 | case 135: /* orderby_opt ::= ORDER BY sortlist */ |
| 178372 | 178131 | case 145: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==145); |
| 178373 | | -#line 874 "parse.y" |
| 178374 | 178132 | {yymsp[-2].minor.yy14 = yymsp[0].minor.yy14;} |
| 178375 | | -#line 4526 "parse.sql" |
| 178376 | 178133 | break; |
| 178377 | 178134 | case 136: /* sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 178378 | | -#line 875 "parse.y" |
| 178379 | 178135 | { |
| 178380 | 178136 | yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14,yymsp[-2].minor.yy454); |
| 178381 | 178137 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144); |
| 178382 | 178138 | } |
| 178383 | | -#line 4534 "parse.sql" |
| 178384 | 178139 | break; |
| 178385 | 178140 | case 137: /* sortlist ::= expr sortorder nulls */ |
| 178386 | | -#line 879 "parse.y" |
| 178387 | 178141 | { |
| 178388 | 178142 | yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy454); /*A-overwrites-Y*/ |
| 178389 | 178143 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144); |
| 178390 | 178144 | } |
| 178391 | | -#line 4542 "parse.sql" |
| 178392 | 178145 | break; |
| 178393 | 178146 | case 138: /* sortorder ::= ASC */ |
| 178394 | | -#line 886 "parse.y" |
| 178395 | 178147 | {yymsp[0].minor.yy144 = SQLITE_SO_ASC;} |
| 178396 | | -#line 4547 "parse.sql" |
| 178397 | 178148 | break; |
| 178398 | 178149 | case 139: /* sortorder ::= DESC */ |
| 178399 | | -#line 887 "parse.y" |
| 178400 | 178150 | {yymsp[0].minor.yy144 = SQLITE_SO_DESC;} |
| 178401 | | -#line 4552 "parse.sql" |
| 178402 | 178151 | break; |
| 178403 | 178152 | case 140: /* sortorder ::= */ |
| 178404 | 178153 | case 143: /* nulls ::= */ yytestcase(yyruleno==143); |
| 178405 | | -#line 888 "parse.y" |
| 178406 | 178154 | {yymsp[1].minor.yy144 = SQLITE_SO_UNDEFINED;} |
| 178407 | | -#line 4558 "parse.sql" |
| 178408 | 178155 | break; |
| 178409 | 178156 | case 141: /* nulls ::= NULLS FIRST */ |
| 178410 | | -#line 891 "parse.y" |
| 178411 | 178157 | {yymsp[-1].minor.yy144 = SQLITE_SO_ASC;} |
| 178412 | | -#line 4563 "parse.sql" |
| 178413 | 178158 | break; |
| 178414 | 178159 | case 142: /* nulls ::= NULLS LAST */ |
| 178415 | | -#line 892 "parse.y" |
| 178416 | 178160 | {yymsp[-1].minor.yy144 = SQLITE_SO_DESC;} |
| 178417 | | -#line 4568 "parse.sql" |
| 178418 | 178161 | break; |
| 178419 | 178162 | case 146: /* having_opt ::= */ |
| 178420 | 178163 | case 148: /* limit_opt ::= */ yytestcase(yyruleno==148); |
| 178421 | 178164 | case 153: /* where_opt ::= */ yytestcase(yyruleno==153); |
| 178422 | 178165 | case 155: /* where_opt_ret ::= */ yytestcase(yyruleno==155); |
| 178423 | 178166 | case 232: /* case_else ::= */ yytestcase(yyruleno==232); |
| 178424 | 178167 | case 233: /* case_operand ::= */ yytestcase(yyruleno==233); |
| 178425 | 178168 | case 252: /* vinto ::= */ yytestcase(yyruleno==252); |
| 178426 | | -#line 902 "parse.y" |
| 178427 | 178169 | {yymsp[1].minor.yy454 = 0;} |
| 178428 | | -#line 4579 "parse.sql" |
| 178429 | 178170 | break; |
| 178430 | 178171 | case 147: /* having_opt ::= HAVING expr */ |
| 178431 | 178172 | case 154: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==154); |
| 178432 | 178173 | case 156: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==156); |
| 178433 | 178174 | case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231); |
| 178434 | 178175 | case 251: /* vinto ::= INTO expr */ yytestcase(yyruleno==251); |
| 178435 | | -#line 903 "parse.y" |
| 178436 | 178176 | {yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;} |
| 178437 | | -#line 4588 "parse.sql" |
| 178438 | 178177 | break; |
| 178439 | 178178 | case 149: /* limit_opt ::= LIMIT expr */ |
| 178440 | | -#line 917 "parse.y" |
| 178441 | 178179 | {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,0);} |
| 178442 | | -#line 4593 "parse.sql" |
| 178443 | 178180 | break; |
| 178444 | 178181 | case 150: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 178445 | | -#line 919 "parse.y" |
| 178446 | 178182 | {yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);} |
| 178447 | | -#line 4598 "parse.sql" |
| 178448 | 178183 | break; |
| 178449 | 178184 | case 151: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 178450 | | -#line 921 "parse.y" |
| 178451 | 178185 | {yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,yymsp[-2].minor.yy454);} |
| 178452 | | -#line 4603 "parse.sql" |
| 178453 | 178186 | break; |
| 178454 | 178187 | case 152: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 178455 | | -#line 939 "parse.y" |
| 178456 | 178188 | { |
| 178457 | 178189 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy203, &yymsp[-1].minor.yy0); |
| 178458 | 178190 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy203,yymsp[0].minor.yy454,0,0); |
| 178459 | 178191 | } |
| 178460 | | -#line 4611 "parse.sql" |
| 178461 | 178192 | break; |
| 178462 | 178193 | case 157: /* where_opt_ret ::= RETURNING selcollist */ |
| 178463 | | -#line 955 "parse.y" |
| 178464 | 178194 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-1].minor.yy454 = 0;} |
| 178465 | | -#line 4616 "parse.sql" |
| 178466 | 178195 | break; |
| 178467 | 178196 | case 158: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 178468 | | -#line 957 "parse.y" |
| 178469 | 178197 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-3].minor.yy454 = yymsp[-2].minor.yy454;} |
| 178470 | | -#line 4621 "parse.sql" |
| 178471 | 178198 | break; |
| 178472 | 178199 | case 159: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 178473 | | -#line 989 "parse.y" |
| 178474 | 178200 | { |
| 178475 | 178201 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-4].minor.yy0); |
| 178476 | 178202 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy14,"set list"); |
| 178477 | 178203 | if( yymsp[-1].minor.yy203 ){ |
| 178478 | 178204 | SrcList *pFromClause = yymsp[-1].minor.yy203; |
| | @@ -178486,134 +178212,92 @@ |
| 178486 | 178212 | } |
| 178487 | 178213 | yymsp[-5].minor.yy203 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy203, pFromClause); |
| 178488 | 178214 | } |
| 178489 | 178215 | sqlite3Update(pParse,yymsp[-5].minor.yy203,yymsp[-2].minor.yy14,yymsp[0].minor.yy454,yymsp[-6].minor.yy144,0,0,0); |
| 178490 | 178216 | } |
| 178491 | | -#line 4642 "parse.sql" |
| 178492 | 178217 | break; |
| 178493 | 178218 | case 160: /* setlist ::= setlist COMMA nm EQ expr */ |
| 178494 | | -#line 1013 "parse.y" |
| 178495 | 178219 | { |
| 178496 | 178220 | yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy454); |
| 178497 | 178221 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, 1); |
| 178498 | 178222 | } |
| 178499 | | -#line 4650 "parse.sql" |
| 178500 | 178223 | break; |
| 178501 | 178224 | case 161: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 178502 | | -#line 1017 "parse.y" |
| 178503 | 178225 | { |
| 178504 | 178226 | yymsp[-6].minor.yy14 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy14, yymsp[-3].minor.yy132, yymsp[0].minor.yy454); |
| 178505 | 178227 | } |
| 178506 | | -#line 4657 "parse.sql" |
| 178507 | 178228 | break; |
| 178508 | 178229 | case 162: /* setlist ::= nm EQ expr */ |
| 178509 | | -#line 1020 "parse.y" |
| 178510 | 178230 | { |
| 178511 | 178231 | yylhsminor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy454); |
| 178512 | 178232 | sqlite3ExprListSetName(pParse, yylhsminor.yy14, &yymsp[-2].minor.yy0, 1); |
| 178513 | 178233 | } |
| 178514 | | -#line 4665 "parse.sql" |
| 178515 | 178234 | yymsp[-2].minor.yy14 = yylhsminor.yy14; |
| 178516 | 178235 | break; |
| 178517 | 178236 | case 163: /* setlist ::= LP idlist RP EQ expr */ |
| 178518 | | -#line 1024 "parse.y" |
| 178519 | 178237 | { |
| 178520 | 178238 | yymsp[-4].minor.yy14 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy132, yymsp[0].minor.yy454); |
| 178521 | 178239 | } |
| 178522 | | -#line 4673 "parse.sql" |
| 178523 | 178240 | break; |
| 178524 | 178241 | case 164: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 178525 | | -#line 1031 "parse.y" |
| 178526 | 178242 | { |
| 178527 | 178243 | sqlite3Insert(pParse, yymsp[-3].minor.yy203, yymsp[-1].minor.yy555, yymsp[-2].minor.yy132, yymsp[-5].minor.yy144, yymsp[0].minor.yy122); |
| 178528 | 178244 | } |
| 178529 | | -#line 4680 "parse.sql" |
| 178530 | 178245 | break; |
| 178531 | 178246 | case 165: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 178532 | | -#line 1035 "parse.y" |
| 178533 | 178247 | { |
| 178534 | 178248 | sqlite3Insert(pParse, yymsp[-4].minor.yy203, 0, yymsp[-3].minor.yy132, yymsp[-6].minor.yy144, 0); |
| 178535 | 178249 | } |
| 178536 | | -#line 4687 "parse.sql" |
| 178537 | 178250 | break; |
| 178538 | 178251 | case 166: /* upsert ::= */ |
| 178539 | | -#line 1046 "parse.y" |
| 178540 | 178252 | { yymsp[1].minor.yy122 = 0; } |
| 178541 | | -#line 4692 "parse.sql" |
| 178542 | 178253 | break; |
| 178543 | 178254 | case 167: /* upsert ::= RETURNING selcollist */ |
| 178544 | | -#line 1047 "parse.y" |
| 178545 | 178255 | { yymsp[-1].minor.yy122 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy14); } |
| 178546 | | -#line 4697 "parse.sql" |
| 178547 | 178256 | break; |
| 178548 | 178257 | case 168: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 178549 | | -#line 1050 "parse.y" |
| 178550 | 178258 | { yymsp[-11].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy14,yymsp[-6].minor.yy454,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,yymsp[0].minor.yy122);} |
| 178551 | | -#line 4702 "parse.sql" |
| 178552 | 178259 | break; |
| 178553 | 178260 | case 169: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 178554 | | -#line 1052 "parse.y" |
| 178555 | 178261 | { yymsp[-8].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy14,yymsp[-3].minor.yy454,0,0,yymsp[0].minor.yy122); } |
| 178556 | | -#line 4707 "parse.sql" |
| 178557 | 178262 | break; |
| 178558 | 178263 | case 170: /* upsert ::= ON CONFLICT DO NOTHING returning */ |
| 178559 | | -#line 1054 "parse.y" |
| 178560 | 178264 | { yymsp[-4].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } |
| 178561 | | -#line 4712 "parse.sql" |
| 178562 | 178265 | break; |
| 178563 | 178266 | case 171: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 178564 | | -#line 1056 "parse.y" |
| 178565 | 178267 | { yymsp[-7].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,0);} |
| 178566 | | -#line 4717 "parse.sql" |
| 178567 | 178268 | break; |
| 178568 | 178269 | case 172: /* returning ::= RETURNING selcollist */ |
| 178569 | | -#line 1058 "parse.y" |
| 178570 | 178270 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy14);} |
| 178571 | | -#line 4722 "parse.sql" |
| 178572 | 178271 | break; |
| 178573 | 178272 | case 175: /* idlist_opt ::= */ |
| 178574 | | -#line 1070 "parse.y" |
| 178575 | 178273 | {yymsp[1].minor.yy132 = 0;} |
| 178576 | | -#line 4727 "parse.sql" |
| 178577 | 178274 | break; |
| 178578 | 178275 | case 176: /* idlist_opt ::= LP idlist RP */ |
| 178579 | | -#line 1071 "parse.y" |
| 178580 | 178276 | {yymsp[-2].minor.yy132 = yymsp[-1].minor.yy132;} |
| 178581 | | -#line 4732 "parse.sql" |
| 178582 | 178277 | break; |
| 178583 | 178278 | case 177: /* idlist ::= idlist COMMA nm */ |
| 178584 | | -#line 1073 "parse.y" |
| 178585 | 178279 | {yymsp[-2].minor.yy132 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy132,&yymsp[0].minor.yy0);} |
| 178586 | | -#line 4737 "parse.sql" |
| 178587 | 178280 | break; |
| 178588 | 178281 | case 178: /* idlist ::= nm */ |
| 178589 | | -#line 1075 "parse.y" |
| 178590 | 178282 | {yymsp[0].minor.yy132 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 178591 | | -#line 4742 "parse.sql" |
| 178592 | 178283 | break; |
| 178593 | 178284 | case 179: /* expr ::= LP expr RP */ |
| 178594 | | -#line 1124 "parse.y" |
| 178595 | 178285 | {yymsp[-2].minor.yy454 = yymsp[-1].minor.yy454;} |
| 178596 | | -#line 4747 "parse.sql" |
| 178597 | 178286 | break; |
| 178598 | 178287 | case 180: /* expr ::= ID|INDEXED|JOIN_KW */ |
| 178599 | | -#line 1125 "parse.y" |
| 178600 | 178288 | {yymsp[0].minor.yy454=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 178601 | | -#line 4752 "parse.sql" |
| 178602 | 178289 | break; |
| 178603 | 178290 | case 181: /* expr ::= nm DOT nm */ |
| 178604 | | -#line 1126 "parse.y" |
| 178605 | 178291 | { |
| 178606 | 178292 | Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0); |
| 178607 | 178293 | Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); |
| 178608 | 178294 | yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); |
| 178609 | 178295 | } |
| 178610 | | -#line 4761 "parse.sql" |
| 178611 | 178296 | yymsp[-2].minor.yy454 = yylhsminor.yy454; |
| 178612 | 178297 | break; |
| 178613 | 178298 | case 182: /* expr ::= nm DOT nm DOT nm */ |
| 178614 | | -#line 1131 "parse.y" |
| 178615 | 178299 | { |
| 178616 | 178300 | Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0); |
| 178617 | 178301 | Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0); |
| 178618 | 178302 | Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); |
| 178619 | 178303 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3); |
| | @@ -178620,30 +178304,24 @@ |
| 178620 | 178304 | if( IN_RENAME_OBJECT ){ |
| 178621 | 178305 | sqlite3RenameTokenRemap(pParse, 0, temp1); |
| 178622 | 178306 | } |
| 178623 | 178307 | yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); |
| 178624 | 178308 | } |
| 178625 | | -#line 4776 "parse.sql" |
| 178626 | 178309 | yymsp[-4].minor.yy454 = yylhsminor.yy454; |
| 178627 | 178310 | break; |
| 178628 | 178311 | case 183: /* term ::= NULL|FLOAT|BLOB */ |
| 178629 | 178312 | case 184: /* term ::= STRING */ yytestcase(yyruleno==184); |
| 178630 | | -#line 1141 "parse.y" |
| 178631 | 178313 | {yymsp[0].minor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 178632 | | -#line 4783 "parse.sql" |
| 178633 | 178314 | break; |
| 178634 | 178315 | case 185: /* term ::= INTEGER */ |
| 178635 | | -#line 1143 "parse.y" |
| 178636 | 178316 | { |
| 178637 | 178317 | yylhsminor.yy454 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 178638 | 178318 | if( yylhsminor.yy454 ) yylhsminor.yy454->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail); |
| 178639 | 178319 | } |
| 178640 | | -#line 4791 "parse.sql" |
| 178641 | 178320 | yymsp[0].minor.yy454 = yylhsminor.yy454; |
| 178642 | 178321 | break; |
| 178643 | 178322 | case 186: /* expr ::= VARIABLE */ |
| 178644 | | -#line 1147 "parse.y" |
| 178645 | 178323 | { |
| 178646 | 178324 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 178647 | 178325 | u32 n = yymsp[0].minor.yy0.n; |
| 178648 | 178326 | yymsp[0].minor.yy454 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 178649 | 178327 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy454, n); |
| | @@ -178652,98 +178330,78 @@ |
| 178652 | 178330 | ** that look like this: #1 #2 ... These terms refer to registers |
| 178653 | 178331 | ** in the virtual machine. #N is the N-th register. */ |
| 178654 | 178332 | Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ |
| 178655 | 178333 | assert( t.n>=2 ); |
| 178656 | 178334 | if( pParse->nested==0 ){ |
| 178657 | | - sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); |
| 178335 | + parserSyntaxError(pParse, &t); |
| 178658 | 178336 | yymsp[0].minor.yy454 = 0; |
| 178659 | 178337 | }else{ |
| 178660 | 178338 | yymsp[0].minor.yy454 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); |
| 178661 | 178339 | if( yymsp[0].minor.yy454 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy454->iTable); |
| 178662 | 178340 | } |
| 178663 | 178341 | } |
| 178664 | 178342 | } |
| 178665 | | -#line 4816 "parse.sql" |
| 178666 | 178343 | break; |
| 178667 | 178344 | case 187: /* expr ::= expr COLLATE ID|STRING */ |
| 178668 | | -#line 1167 "parse.y" |
| 178669 | 178345 | { |
| 178670 | 178346 | yymsp[-2].minor.yy454 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0, 1); |
| 178671 | 178347 | } |
| 178672 | | -#line 4823 "parse.sql" |
| 178673 | 178348 | break; |
| 178674 | 178349 | case 188: /* expr ::= CAST LP expr AS typetoken RP */ |
| 178675 | | -#line 1171 "parse.y" |
| 178676 | 178350 | { |
| 178677 | 178351 | yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); |
| 178678 | 178352 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy454, yymsp[-3].minor.yy454, 0); |
| 178679 | 178353 | } |
| 178680 | | -#line 4831 "parse.sql" |
| 178681 | 178354 | break; |
| 178682 | 178355 | case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 178683 | | -#line 1178 "parse.y" |
| 178684 | 178356 | { |
| 178685 | 178357 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy144); |
| 178686 | 178358 | } |
| 178687 | | -#line 4838 "parse.sql" |
| 178688 | 178359 | yymsp[-4].minor.yy454 = yylhsminor.yy454; |
| 178689 | 178360 | break; |
| 178690 | 178361 | case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 178691 | | -#line 1181 "parse.y" |
| 178692 | 178362 | { |
| 178693 | 178363 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy14, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy144); |
| 178694 | 178364 | sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-1].minor.yy14); |
| 178695 | 178365 | } |
| 178696 | | -#line 4847 "parse.sql" |
| 178697 | 178366 | yymsp[-7].minor.yy454 = yylhsminor.yy454; |
| 178698 | 178367 | break; |
| 178699 | 178368 | case 191: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 178700 | | -#line 1185 "parse.y" |
| 178701 | 178369 | { |
| 178702 | 178370 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 178703 | 178371 | } |
| 178704 | | -#line 4855 "parse.sql" |
| 178705 | 178372 | yymsp[-3].minor.yy454 = yylhsminor.yy454; |
| 178706 | 178373 | break; |
| 178707 | 178374 | case 192: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 178708 | | -#line 1249 "parse.y" |
| 178709 | 178375 | { |
| 178710 | 178376 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy14, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy144); |
| 178711 | 178377 | sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211); |
| 178712 | 178378 | } |
| 178713 | | -#line 4864 "parse.sql" |
| 178714 | 178379 | yymsp[-5].minor.yy454 = yylhsminor.yy454; |
| 178715 | 178380 | break; |
| 178716 | 178381 | case 193: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 178717 | | -#line 1253 "parse.y" |
| 178718 | 178382 | { |
| 178719 | 178383 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy14, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy144); |
| 178720 | 178384 | sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211); |
| 178721 | 178385 | sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-2].minor.yy14); |
| 178722 | 178386 | } |
| 178723 | | -#line 4874 "parse.sql" |
| 178724 | 178387 | yymsp[-8].minor.yy454 = yylhsminor.yy454; |
| 178725 | 178388 | break; |
| 178726 | 178389 | case 194: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 178727 | | -#line 1258 "parse.y" |
| 178728 | 178390 | { |
| 178729 | 178391 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 178730 | 178392 | sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211); |
| 178731 | 178393 | } |
| 178732 | | -#line 4883 "parse.sql" |
| 178733 | 178394 | yymsp[-4].minor.yy454 = yylhsminor.yy454; |
| 178734 | 178395 | break; |
| 178735 | 178396 | case 195: /* term ::= CTIME_KW */ |
| 178736 | | -#line 1272 "parse.y" |
| 178737 | 178397 | { |
| 178738 | 178398 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 178739 | 178399 | } |
| 178740 | | -#line 4891 "parse.sql" |
| 178741 | 178400 | yymsp[0].minor.yy454 = yylhsminor.yy454; |
| 178742 | 178401 | break; |
| 178743 | 178402 | case 196: /* expr ::= LP nexprlist COMMA expr RP */ |
| 178744 | | -#line 1276 "parse.y" |
| 178745 | 178403 | { |
| 178746 | 178404 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454); |
| 178747 | 178405 | yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 178748 | 178406 | if( yymsp[-4].minor.yy454 ){ |
| 178749 | 178407 | yymsp[-4].minor.yy454->x.pList = pList; |
| | @@ -178752,35 +178410,27 @@ |
| 178752 | 178410 | } |
| 178753 | 178411 | }else{ |
| 178754 | 178412 | sqlite3ExprListDelete(pParse->db, pList); |
| 178755 | 178413 | } |
| 178756 | 178414 | } |
| 178757 | | -#line 4908 "parse.sql" |
| 178758 | 178415 | break; |
| 178759 | 178416 | case 197: /* expr ::= expr AND expr */ |
| 178760 | | -#line 1289 "parse.y" |
| 178761 | 178417 | {yymsp[-2].minor.yy454=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);} |
| 178762 | | -#line 4913 "parse.sql" |
| 178763 | 178418 | break; |
| 178764 | 178419 | case 198: /* expr ::= expr OR expr */ |
| 178765 | 178420 | case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199); |
| 178766 | 178421 | case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200); |
| 178767 | 178422 | case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201); |
| 178768 | 178423 | case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202); |
| 178769 | 178424 | case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203); |
| 178770 | 178425 | case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204); |
| 178771 | | -#line 1290 "parse.y" |
| 178772 | 178426 | {yymsp[-2].minor.yy454=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);} |
| 178773 | | -#line 4924 "parse.sql" |
| 178774 | 178427 | break; |
| 178775 | 178428 | case 205: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 178776 | | -#line 1303 "parse.y" |
| 178777 | 178429 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 178778 | | -#line 4929 "parse.sql" |
| 178779 | 178430 | break; |
| 178780 | 178431 | case 206: /* expr ::= expr likeop expr */ |
| 178781 | | -#line 1304 "parse.y" |
| 178782 | 178432 | { |
| 178783 | 178433 | ExprList *pList; |
| 178784 | 178434 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 178785 | 178435 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 178786 | 178436 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy454); |
| | @@ -178787,14 +178437,12 @@ |
| 178787 | 178437 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy454); |
| 178788 | 178438 | yymsp[-2].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 178789 | 178439 | if( bNot ) yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy454, 0); |
| 178790 | 178440 | if( yymsp[-2].minor.yy454 ) yymsp[-2].minor.yy454->flags |= EP_InfixFunc; |
| 178791 | 178441 | } |
| 178792 | | -#line 4943 "parse.sql" |
| 178793 | 178442 | break; |
| 178794 | 178443 | case 207: /* expr ::= expr likeop expr ESCAPE expr */ |
| 178795 | | -#line 1314 "parse.y" |
| 178796 | 178444 | { |
| 178797 | 178445 | ExprList *pList; |
| 178798 | 178446 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 178799 | 178447 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 178800 | 178448 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454); |
| | @@ -178802,62 +178450,46 @@ |
| 178802 | 178450 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454); |
| 178803 | 178451 | yymsp[-4].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 178804 | 178452 | if( bNot ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0); |
| 178805 | 178453 | if( yymsp[-4].minor.yy454 ) yymsp[-4].minor.yy454->flags |= EP_InfixFunc; |
| 178806 | 178454 | } |
| 178807 | | -#line 4958 "parse.sql" |
| 178808 | 178455 | break; |
| 178809 | 178456 | case 208: /* expr ::= expr ISNULL|NOTNULL */ |
| 178810 | | -#line 1326 "parse.y" |
| 178811 | 178457 | {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy454,0);} |
| 178812 | | -#line 4963 "parse.sql" |
| 178813 | 178458 | break; |
| 178814 | 178459 | case 209: /* expr ::= expr NOT NULL */ |
| 178815 | | -#line 1327 "parse.y" |
| 178816 | 178460 | {yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy454,0);} |
| 178817 | | -#line 4968 "parse.sql" |
| 178818 | 178461 | break; |
| 178819 | 178462 | case 210: /* expr ::= expr IS expr */ |
| 178820 | | -#line 1348 "parse.y" |
| 178821 | 178463 | { |
| 178822 | 178464 | yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy454,yymsp[0].minor.yy454); |
| 178823 | 178465 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-2].minor.yy454, TK_ISNULL); |
| 178824 | 178466 | } |
| 178825 | | -#line 4976 "parse.sql" |
| 178826 | 178467 | break; |
| 178827 | 178468 | case 211: /* expr ::= expr IS NOT expr */ |
| 178828 | | -#line 1352 "parse.y" |
| 178829 | 178469 | { |
| 178830 | 178470 | yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy454,yymsp[0].minor.yy454); |
| 178831 | 178471 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-3].minor.yy454, TK_NOTNULL); |
| 178832 | 178472 | } |
| 178833 | | -#line 4984 "parse.sql" |
| 178834 | 178473 | break; |
| 178835 | 178474 | case 212: /* expr ::= expr IS NOT DISTINCT FROM expr */ |
| 178836 | | -#line 1356 "parse.y" |
| 178837 | 178475 | { |
| 178838 | 178476 | yymsp[-5].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy454,yymsp[0].minor.yy454); |
| 178839 | 178477 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-5].minor.yy454, TK_ISNULL); |
| 178840 | 178478 | } |
| 178841 | | -#line 4992 "parse.sql" |
| 178842 | 178479 | break; |
| 178843 | 178480 | case 213: /* expr ::= expr IS DISTINCT FROM expr */ |
| 178844 | | -#line 1360 "parse.y" |
| 178845 | 178481 | { |
| 178846 | 178482 | yymsp[-4].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy454,yymsp[0].minor.yy454); |
| 178847 | 178483 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-4].minor.yy454, TK_NOTNULL); |
| 178848 | 178484 | } |
| 178849 | | -#line 5000 "parse.sql" |
| 178850 | 178485 | break; |
| 178851 | 178486 | case 214: /* expr ::= NOT expr */ |
| 178852 | 178487 | case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215); |
| 178853 | | -#line 1366 "parse.y" |
| 178854 | 178488 | {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/} |
| 178855 | | -#line 5006 "parse.sql" |
| 178856 | 178489 | break; |
| 178857 | 178490 | case 216: /* expr ::= PLUS|MINUS expr */ |
| 178858 | | -#line 1369 "parse.y" |
| 178859 | 178491 | { |
| 178860 | 178492 | Expr *p = yymsp[0].minor.yy454; |
| 178861 | 178493 | u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS); |
| 178862 | 178494 | assert( TK_UPLUS>TK_PLUS ); |
| 178863 | 178495 | assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) ); |
| | @@ -178867,30 +178499,24 @@ |
| 178867 | 178499 | }else{ |
| 178868 | 178500 | yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, op, p, 0); |
| 178869 | 178501 | /*A-overwrites-B*/ |
| 178870 | 178502 | } |
| 178871 | 178503 | } |
| 178872 | | -#line 5023 "parse.sql" |
| 178873 | 178504 | break; |
| 178874 | 178505 | case 217: /* expr ::= expr PTR expr */ |
| 178875 | | -#line 1383 "parse.y" |
| 178876 | 178506 | { |
| 178877 | 178507 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy454); |
| 178878 | 178508 | pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy454); |
| 178879 | 178509 | yylhsminor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 178880 | 178510 | } |
| 178881 | | -#line 5032 "parse.sql" |
| 178882 | 178511 | yymsp[-2].minor.yy454 = yylhsminor.yy454; |
| 178883 | 178512 | break; |
| 178884 | 178513 | case 218: /* between_op ::= BETWEEN */ |
| 178885 | 178514 | case 221: /* in_op ::= IN */ yytestcase(yyruleno==221); |
| 178886 | | -#line 1390 "parse.y" |
| 178887 | 178515 | {yymsp[0].minor.yy144 = 0;} |
| 178888 | | -#line 5039 "parse.sql" |
| 178889 | 178516 | break; |
| 178890 | 178517 | case 220: /* expr ::= expr between_op expr AND expr */ |
| 178891 | | -#line 1392 "parse.y" |
| 178892 | 178518 | { |
| 178893 | 178519 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454); |
| 178894 | 178520 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454); |
| 178895 | 178521 | yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0); |
| 178896 | 178522 | if( yymsp[-4].minor.yy454 ){ |
| | @@ -178898,14 +178524,12 @@ |
| 178898 | 178524 | }else{ |
| 178899 | 178525 | sqlite3ExprListDelete(pParse->db, pList); |
| 178900 | 178526 | } |
| 178901 | 178527 | if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0); |
| 178902 | 178528 | } |
| 178903 | | -#line 5054 "parse.sql" |
| 178904 | 178529 | break; |
| 178905 | 178530 | case 223: /* expr ::= expr in_op LP exprlist RP */ |
| 178906 | | -#line 1407 "parse.y" |
| 178907 | 178531 | { |
| 178908 | 178532 | if( yymsp[-1].minor.yy14==0 ){ |
| 178909 | 178533 | /* Expressions of the form |
| 178910 | 178534 | ** |
| 178911 | 178535 | ** expr1 IN () |
| | @@ -178946,52 +178570,42 @@ |
| 178946 | 178570 | } |
| 178947 | 178571 | } |
| 178948 | 178572 | if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0); |
| 178949 | 178573 | } |
| 178950 | 178574 | } |
| 178951 | | -#line 5102 "parse.sql" |
| 178952 | 178575 | break; |
| 178953 | 178576 | case 224: /* expr ::= LP select RP */ |
| 178954 | | -#line 1451 "parse.y" |
| 178955 | 178577 | { |
| 178956 | 178578 | yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 178957 | 178579 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy454, yymsp[-1].minor.yy555); |
| 178958 | 178580 | } |
| 178959 | | -#line 5110 "parse.sql" |
| 178960 | 178581 | break; |
| 178961 | 178582 | case 225: /* expr ::= expr in_op LP select RP */ |
| 178962 | | -#line 1455 "parse.y" |
| 178963 | 178583 | { |
| 178964 | 178584 | yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0); |
| 178965 | 178585 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, yymsp[-1].minor.yy555); |
| 178966 | 178586 | if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0); |
| 178967 | 178587 | } |
| 178968 | | -#line 5119 "parse.sql" |
| 178969 | 178588 | break; |
| 178970 | 178589 | case 226: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 178971 | | -#line 1460 "parse.y" |
| 178972 | 178590 | { |
| 178973 | 178591 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 178974 | 178592 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 178975 | 178593 | if( yymsp[0].minor.yy14 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy14); |
| 178976 | 178594 | yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0); |
| 178977 | 178595 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelect); |
| 178978 | 178596 | if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0); |
| 178979 | 178597 | } |
| 178980 | | -#line 5131 "parse.sql" |
| 178981 | 178598 | break; |
| 178982 | 178599 | case 227: /* expr ::= EXISTS LP select RP */ |
| 178983 | | -#line 1468 "parse.y" |
| 178984 | 178600 | { |
| 178985 | 178601 | Expr *p; |
| 178986 | 178602 | p = yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 178987 | 178603 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy555); |
| 178988 | 178604 | } |
| 178989 | | -#line 5140 "parse.sql" |
| 178990 | 178605 | break; |
| 178991 | 178606 | case 228: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 178992 | | -#line 1476 "parse.y" |
| 178993 | 178607 | { |
| 178994 | 178608 | yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, 0); |
| 178995 | 178609 | if( yymsp[-4].minor.yy454 ){ |
| 178996 | 178610 | yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy454 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454) : yymsp[-2].minor.yy14; |
| 178997 | 178611 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454); |
| | @@ -178998,627 +178612,446 @@ |
| 178998 | 178612 | }else{ |
| 178999 | 178613 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14); |
| 179000 | 178614 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454); |
| 179001 | 178615 | } |
| 179002 | 178616 | } |
| 179003 | | -#line 5154 "parse.sql" |
| 179004 | 178617 | break; |
| 179005 | 178618 | case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 179006 | | -#line 1488 "parse.y" |
| 179007 | 178619 | { |
| 179008 | 178620 | yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy454); |
| 179009 | 178621 | yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[0].minor.yy454); |
| 179010 | 178622 | } |
| 179011 | | -#line 5162 "parse.sql" |
| 179012 | 178623 | break; |
| 179013 | 178624 | case 230: /* case_exprlist ::= WHEN expr THEN expr */ |
| 179014 | | -#line 1492 "parse.y" |
| 179015 | 178625 | { |
| 179016 | 178626 | yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454); |
| 179017 | 178627 | yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, yymsp[0].minor.yy454); |
| 179018 | 178628 | } |
| 179019 | | -#line 5170 "parse.sql" |
| 179020 | 178629 | break; |
| 179021 | 178630 | case 235: /* nexprlist ::= nexprlist COMMA expr */ |
| 179022 | | -#line 1513 "parse.y" |
| 179023 | 178631 | {yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy454);} |
| 179024 | | -#line 5175 "parse.sql" |
| 179025 | 178632 | break; |
| 179026 | 178633 | case 236: /* nexprlist ::= expr */ |
| 179027 | | -#line 1515 "parse.y" |
| 179028 | 178634 | {yymsp[0].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454); /*A-overwrites-Y*/} |
| 179029 | | -#line 5180 "parse.sql" |
| 179030 | 178635 | break; |
| 179031 | 178636 | case 238: /* paren_exprlist ::= LP exprlist RP */ |
| 179032 | 178637 | case 243: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==243); |
| 179033 | | -#line 1523 "parse.y" |
| 179034 | 178638 | {yymsp[-2].minor.yy14 = yymsp[-1].minor.yy14;} |
| 179035 | | -#line 5186 "parse.sql" |
| 179036 | 178639 | break; |
| 179037 | 178640 | case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 179038 | | -#line 1530 "parse.y" |
| 179039 | 178641 | { |
| 179040 | 178642 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 179041 | 178643 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy144, |
| 179042 | 178644 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy454, SQLITE_SO_ASC, yymsp[-8].minor.yy144, SQLITE_IDXTYPE_APPDEF); |
| 179043 | 178645 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 179044 | 178646 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 179045 | 178647 | } |
| 179046 | 178648 | } |
| 179047 | | -#line 5198 "parse.sql" |
| 179048 | 178649 | break; |
| 179049 | 178650 | case 240: /* uniqueflag ::= UNIQUE */ |
| 179050 | 178651 | case 282: /* raisetype ::= ABORT */ yytestcase(yyruleno==282); |
| 179051 | | -#line 1540 "parse.y" |
| 179052 | 178652 | {yymsp[0].minor.yy144 = OE_Abort;} |
| 179053 | | -#line 5204 "parse.sql" |
| 179054 | 178653 | break; |
| 179055 | 178654 | case 241: /* uniqueflag ::= */ |
| 179056 | | -#line 1541 "parse.y" |
| 179057 | 178655 | {yymsp[1].minor.yy144 = OE_None;} |
| 179058 | | -#line 5209 "parse.sql" |
| 179059 | 178656 | break; |
| 179060 | 178657 | case 244: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 179061 | | -#line 1591 "parse.y" |
| 179062 | 178658 | { |
| 179063 | 178659 | yymsp[-4].minor.yy14 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144); |
| 179064 | 178660 | } |
| 179065 | | -#line 5216 "parse.sql" |
| 179066 | 178661 | break; |
| 179067 | 178662 | case 245: /* eidlist ::= nm collate sortorder */ |
| 179068 | | -#line 1594 "parse.y" |
| 179069 | 178663 | { |
| 179070 | 178664 | yymsp[-2].minor.yy14 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144); /*A-overwrites-Y*/ |
| 179071 | 178665 | } |
| 179072 | | -#line 5223 "parse.sql" |
| 179073 | 178666 | break; |
| 179074 | 178667 | case 248: /* cmd ::= DROP INDEX ifexists fullname */ |
| 179075 | | -#line 1605 "parse.y" |
| 179076 | 178668 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy203, yymsp[-1].minor.yy144);} |
| 179077 | | -#line 5228 "parse.sql" |
| 179078 | 178669 | break; |
| 179079 | 178670 | case 249: /* cmd ::= VACUUM vinto */ |
| 179080 | | -#line 1612 "parse.y" |
| 179081 | 178671 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy454);} |
| 179082 | | -#line 5233 "parse.sql" |
| 179083 | 178672 | break; |
| 179084 | 178673 | case 250: /* cmd ::= VACUUM nm vinto */ |
| 179085 | | -#line 1613 "parse.y" |
| 179086 | 178674 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy454);} |
| 179087 | | -#line 5238 "parse.sql" |
| 179088 | 178675 | break; |
| 179089 | 178676 | case 253: /* cmd ::= PRAGMA nm dbnm */ |
| 179090 | | -#line 1621 "parse.y" |
| 179091 | 178677 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 179092 | | -#line 5243 "parse.sql" |
| 179093 | 178678 | break; |
| 179094 | 178679 | case 254: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 179095 | | -#line 1622 "parse.y" |
| 179096 | 178680 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 179097 | | -#line 5248 "parse.sql" |
| 179098 | 178681 | break; |
| 179099 | 178682 | case 255: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 179100 | | -#line 1623 "parse.y" |
| 179101 | 178683 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 179102 | | -#line 5253 "parse.sql" |
| 179103 | 178684 | break; |
| 179104 | 178685 | case 256: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 179105 | | -#line 1625 "parse.y" |
| 179106 | 178686 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 179107 | | -#line 5258 "parse.sql" |
| 179108 | 178687 | break; |
| 179109 | 178688 | case 257: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 179110 | | -#line 1627 "parse.y" |
| 179111 | 178689 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 179112 | | -#line 5263 "parse.sql" |
| 179113 | 178690 | break; |
| 179114 | 178691 | case 260: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 179115 | | -#line 1643 "parse.y" |
| 179116 | 178692 | { |
| 179117 | 178693 | Token all; |
| 179118 | 178694 | all.z = yymsp[-3].minor.yy0.z; |
| 179119 | 178695 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 179120 | 178696 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy427, &all); |
| 179121 | 178697 | } |
| 179122 | | -#line 5273 "parse.sql" |
| 179123 | 178698 | break; |
| 179124 | 178699 | case 261: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 179125 | | -#line 1652 "parse.y" |
| 179126 | 178700 | { |
| 179127 | 178701 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy144, yymsp[-4].minor.yy286.a, yymsp[-4].minor.yy286.b, yymsp[-2].minor.yy203, yymsp[0].minor.yy454, yymsp[-10].minor.yy144, yymsp[-8].minor.yy144); |
| 179128 | 178702 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 179129 | 178703 | } |
| 179130 | | -#line 5281 "parse.sql" |
| 179131 | 178704 | break; |
| 179132 | 178705 | case 262: /* trigger_time ::= BEFORE|AFTER */ |
| 179133 | | -#line 1658 "parse.y" |
| 179134 | 178706 | { yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/ } |
| 179135 | | -#line 5286 "parse.sql" |
| 179136 | 178707 | break; |
| 179137 | 178708 | case 263: /* trigger_time ::= INSTEAD OF */ |
| 179138 | | -#line 1659 "parse.y" |
| 179139 | 178709 | { yymsp[-1].minor.yy144 = TK_INSTEAD;} |
| 179140 | | -#line 5291 "parse.sql" |
| 179141 | 178710 | break; |
| 179142 | 178711 | case 264: /* trigger_time ::= */ |
| 179143 | | -#line 1660 "parse.y" |
| 179144 | 178712 | { yymsp[1].minor.yy144 = TK_BEFORE; } |
| 179145 | | -#line 5296 "parse.sql" |
| 179146 | 178713 | break; |
| 179147 | 178714 | case 265: /* trigger_event ::= DELETE|INSERT */ |
| 179148 | 178715 | case 266: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==266); |
| 179149 | | -#line 1664 "parse.y" |
| 179150 | 178716 | {yymsp[0].minor.yy286.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy286.b = 0;} |
| 179151 | | -#line 5302 "parse.sql" |
| 179152 | 178717 | break; |
| 179153 | 178718 | case 267: /* trigger_event ::= UPDATE OF idlist */ |
| 179154 | | -#line 1666 "parse.y" |
| 179155 | 178719 | {yymsp[-2].minor.yy286.a = TK_UPDATE; yymsp[-2].minor.yy286.b = yymsp[0].minor.yy132;} |
| 179156 | | -#line 5307 "parse.sql" |
| 179157 | 178720 | break; |
| 179158 | 178721 | case 268: /* when_clause ::= */ |
| 179159 | 178722 | case 287: /* key_opt ::= */ yytestcase(yyruleno==287); |
| 179160 | | -#line 1673 "parse.y" |
| 179161 | 178723 | { yymsp[1].minor.yy454 = 0; } |
| 179162 | | -#line 5313 "parse.sql" |
| 179163 | 178724 | break; |
| 179164 | 178725 | case 269: /* when_clause ::= WHEN expr */ |
| 179165 | 178726 | case 288: /* key_opt ::= KEY expr */ yytestcase(yyruleno==288); |
| 179166 | | -#line 1674 "parse.y" |
| 179167 | 178727 | { yymsp[-1].minor.yy454 = yymsp[0].minor.yy454; } |
| 179168 | | -#line 5319 "parse.sql" |
| 179169 | 178728 | break; |
| 179170 | 178729 | case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 179171 | | -#line 1678 "parse.y" |
| 179172 | 178730 | { |
| 179173 | 178731 | assert( yymsp[-2].minor.yy427!=0 ); |
| 179174 | 178732 | yymsp[-2].minor.yy427->pLast->pNext = yymsp[-1].minor.yy427; |
| 179175 | 178733 | yymsp[-2].minor.yy427->pLast = yymsp[-1].minor.yy427; |
| 179176 | 178734 | } |
| 179177 | | -#line 5328 "parse.sql" |
| 179178 | 178735 | break; |
| 179179 | 178736 | case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 179180 | | -#line 1683 "parse.y" |
| 179181 | 178737 | { |
| 179182 | 178738 | assert( yymsp[-1].minor.yy427!=0 ); |
| 179183 | 178739 | yymsp[-1].minor.yy427->pLast = yymsp[-1].minor.yy427; |
| 179184 | 178740 | } |
| 179185 | | -#line 5336 "parse.sql" |
| 179186 | 178741 | break; |
| 179187 | 178742 | case 272: /* trnm ::= nm DOT nm */ |
| 179188 | | -#line 1694 "parse.y" |
| 179189 | 178743 | { |
| 179190 | 178744 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 179191 | 178745 | sqlite3ErrorMsg(pParse, |
| 179192 | 178746 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 179193 | 178747 | "statements within triggers"); |
| 179194 | 178748 | } |
| 179195 | | -#line 5346 "parse.sql" |
| 179196 | 178749 | break; |
| 179197 | 178750 | case 273: /* tridxby ::= INDEXED BY nm */ |
| 179198 | | -#line 1706 "parse.y" |
| 179199 | 178751 | { |
| 179200 | 178752 | sqlite3ErrorMsg(pParse, |
| 179201 | 178753 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 179202 | 178754 | "within triggers"); |
| 179203 | 178755 | } |
| 179204 | | -#line 5355 "parse.sql" |
| 179205 | 178756 | break; |
| 179206 | 178757 | case 274: /* tridxby ::= NOT INDEXED */ |
| 179207 | | -#line 1711 "parse.y" |
| 179208 | 178758 | { |
| 179209 | 178759 | sqlite3ErrorMsg(pParse, |
| 179210 | 178760 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 179211 | 178761 | "within triggers"); |
| 179212 | 178762 | } |
| 179213 | | -#line 5364 "parse.sql" |
| 179214 | 178763 | break; |
| 179215 | 178764 | case 275: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 179216 | | -#line 1724 "parse.y" |
| 179217 | 178765 | {yylhsminor.yy427 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy203, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454, yymsp[-7].minor.yy144, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy168);} |
| 179218 | | -#line 5369 "parse.sql" |
| 179219 | 178766 | yymsp[-8].minor.yy427 = yylhsminor.yy427; |
| 179220 | 178767 | break; |
| 179221 | 178768 | case 276: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 179222 | | -#line 1728 "parse.y" |
| 179223 | 178769 | { |
| 179224 | 178770 | yylhsminor.yy427 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy132,yymsp[-2].minor.yy555,yymsp[-6].minor.yy144,yymsp[-1].minor.yy122,yymsp[-7].minor.yy168,yymsp[0].minor.yy168);/*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/ |
| 179225 | 178771 | } |
| 179226 | | -#line 5377 "parse.sql" |
| 179227 | 178772 | yymsp[-7].minor.yy427 = yylhsminor.yy427; |
| 179228 | 178773 | break; |
| 179229 | 178774 | case 277: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 179230 | | -#line 1733 "parse.y" |
| 179231 | 178775 | {yylhsminor.yy427 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy454, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy168);} |
| 179232 | | -#line 5383 "parse.sql" |
| 179233 | 178776 | yymsp[-5].minor.yy427 = yylhsminor.yy427; |
| 179234 | 178777 | break; |
| 179235 | 178778 | case 278: /* trigger_cmd ::= scanpt select scanpt */ |
| 179236 | | -#line 1737 "parse.y" |
| 179237 | 178779 | {yylhsminor.yy427 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy555, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/} |
| 179238 | | -#line 5389 "parse.sql" |
| 179239 | 178780 | yymsp[-2].minor.yy427 = yylhsminor.yy427; |
| 179240 | 178781 | break; |
| 179241 | 178782 | case 279: /* expr ::= RAISE LP IGNORE RP */ |
| 179242 | | -#line 1740 "parse.y" |
| 179243 | 178783 | { |
| 179244 | 178784 | yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 179245 | 178785 | if( yymsp[-3].minor.yy454 ){ |
| 179246 | 178786 | yymsp[-3].minor.yy454->affExpr = OE_Ignore; |
| 179247 | 178787 | } |
| 179248 | 178788 | } |
| 179249 | | -#line 5400 "parse.sql" |
| 179250 | 178789 | break; |
| 179251 | 178790 | case 280: /* expr ::= RAISE LP raisetype COMMA expr RP */ |
| 179252 | | -#line 1746 "parse.y" |
| 179253 | 178791 | { |
| 179254 | 178792 | yymsp[-5].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy454, 0); |
| 179255 | 178793 | if( yymsp[-5].minor.yy454 ) { |
| 179256 | 178794 | yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy144; |
| 179257 | 178795 | } |
| 179258 | 178796 | } |
| 179259 | | -#line 5410 "parse.sql" |
| 179260 | 178797 | break; |
| 179261 | 178798 | case 281: /* raisetype ::= ROLLBACK */ |
| 179262 | | -#line 1755 "parse.y" |
| 179263 | 178799 | {yymsp[0].minor.yy144 = OE_Rollback;} |
| 179264 | | -#line 5415 "parse.sql" |
| 179265 | 178800 | break; |
| 179266 | 178801 | case 283: /* raisetype ::= FAIL */ |
| 179267 | | -#line 1757 "parse.y" |
| 179268 | 178802 | {yymsp[0].minor.yy144 = OE_Fail;} |
| 179269 | | -#line 5420 "parse.sql" |
| 179270 | 178803 | break; |
| 179271 | 178804 | case 284: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 179272 | | -#line 1762 "parse.y" |
| 179273 | 178805 | { |
| 179274 | 178806 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy203,yymsp[-1].minor.yy144); |
| 179275 | 178807 | } |
| 179276 | | -#line 5427 "parse.sql" |
| 179277 | 178808 | break; |
| 179278 | 178809 | case 285: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 179279 | | -#line 1769 "parse.y" |
| 179280 | 178810 | { |
| 179281 | 178811 | sqlite3Attach(pParse, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, yymsp[0].minor.yy454); |
| 179282 | 178812 | } |
| 179283 | | -#line 5434 "parse.sql" |
| 179284 | 178813 | break; |
| 179285 | 178814 | case 286: /* cmd ::= DETACH database_kw_opt expr */ |
| 179286 | | -#line 1772 "parse.y" |
| 179287 | 178815 | { |
| 179288 | 178816 | sqlite3Detach(pParse, yymsp[0].minor.yy454); |
| 179289 | 178817 | } |
| 179290 | | -#line 5441 "parse.sql" |
| 179291 | 178818 | break; |
| 179292 | 178819 | case 289: /* cmd ::= REINDEX */ |
| 179293 | | -#line 1787 "parse.y" |
| 179294 | 178820 | {sqlite3Reindex(pParse, 0, 0);} |
| 179295 | | -#line 5446 "parse.sql" |
| 179296 | 178821 | break; |
| 179297 | 178822 | case 290: /* cmd ::= REINDEX nm dbnm */ |
| 179298 | | -#line 1788 "parse.y" |
| 179299 | 178823 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 179300 | | -#line 5451 "parse.sql" |
| 179301 | 178824 | break; |
| 179302 | 178825 | case 291: /* cmd ::= ANALYZE */ |
| 179303 | | -#line 1793 "parse.y" |
| 179304 | 178826 | {sqlite3Analyze(pParse, 0, 0);} |
| 179305 | | -#line 5456 "parse.sql" |
| 179306 | 178827 | break; |
| 179307 | 178828 | case 292: /* cmd ::= ANALYZE nm dbnm */ |
| 179308 | | -#line 1794 "parse.y" |
| 179309 | 178829 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 179310 | | -#line 5461 "parse.sql" |
| 179311 | 178830 | break; |
| 179312 | 178831 | case 293: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 179313 | | -#line 1800 "parse.y" |
| 179314 | 178832 | { |
| 179315 | 178833 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy203,&yymsp[0].minor.yy0); |
| 179316 | 178834 | } |
| 179317 | | -#line 5468 "parse.sql" |
| 179318 | 178835 | break; |
| 179319 | 178836 | case 294: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 179320 | | -#line 1804 "parse.y" |
| 179321 | 178837 | { |
| 179322 | 178838 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 179323 | 178839 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 179324 | 178840 | } |
| 179325 | | -#line 5476 "parse.sql" |
| 179326 | 178841 | break; |
| 179327 | 178842 | case 295: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 179328 | | -#line 1808 "parse.y" |
| 179329 | 178843 | { |
| 179330 | 178844 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy203, &yymsp[0].minor.yy0); |
| 179331 | 178845 | } |
| 179332 | | -#line 5483 "parse.sql" |
| 179333 | 178846 | break; |
| 179334 | 178847 | case 296: /* add_column_fullname ::= fullname */ |
| 179335 | | -#line 1812 "parse.y" |
| 179336 | 178848 | { |
| 179337 | 178849 | disableLookaside(pParse); |
| 179338 | 178850 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy203); |
| 179339 | 178851 | } |
| 179340 | | -#line 5491 "parse.sql" |
| 179341 | 178852 | break; |
| 179342 | 178853 | case 297: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 179343 | | -#line 1816 "parse.y" |
| 179344 | 178854 | { |
| 179345 | 178855 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy203, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 179346 | 178856 | } |
| 179347 | | -#line 5498 "parse.sql" |
| 179348 | 178857 | break; |
| 179349 | 178858 | case 298: /* cmd ::= create_vtab */ |
| 179350 | | -#line 1828 "parse.y" |
| 179351 | 178859 | {sqlite3VtabFinishParse(pParse,0);} |
| 179352 | | -#line 5503 "parse.sql" |
| 179353 | 178860 | break; |
| 179354 | 178861 | case 299: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 179355 | | -#line 1829 "parse.y" |
| 179356 | 178862 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 179357 | | -#line 5508 "parse.sql" |
| 179358 | 178863 | break; |
| 179359 | 178864 | case 300: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 179360 | | -#line 1831 "parse.y" |
| 179361 | 178865 | { |
| 179362 | 178866 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy144); |
| 179363 | 178867 | } |
| 179364 | | -#line 5515 "parse.sql" |
| 179365 | 178868 | break; |
| 179366 | 178869 | case 301: /* vtabarg ::= */ |
| 179367 | | -#line 1836 "parse.y" |
| 179368 | 178870 | {sqlite3VtabArgInit(pParse);} |
| 179369 | | -#line 5520 "parse.sql" |
| 179370 | 178871 | break; |
| 179371 | 178872 | case 302: /* vtabargtoken ::= ANY */ |
| 179372 | 178873 | case 303: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==303); |
| 179373 | 178874 | case 304: /* lp ::= LP */ yytestcase(yyruleno==304); |
| 179374 | | -#line 1838 "parse.y" |
| 179375 | 178875 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 179376 | | -#line 5527 "parse.sql" |
| 179377 | 178876 | break; |
| 179378 | 178877 | case 305: /* with ::= WITH wqlist */ |
| 179379 | 178878 | case 306: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==306); |
| 179380 | | -#line 1855 "parse.y" |
| 179381 | 178879 | { sqlite3WithPush(pParse, yymsp[0].minor.yy59, 1); } |
| 179382 | | -#line 5533 "parse.sql" |
| 179383 | 178880 | break; |
| 179384 | 178881 | case 307: /* wqas ::= AS */ |
| 179385 | | -#line 1859 "parse.y" |
| 179386 | 178882 | {yymsp[0].minor.yy462 = M10d_Any;} |
| 179387 | | -#line 5538 "parse.sql" |
| 179388 | 178883 | break; |
| 179389 | 178884 | case 308: /* wqas ::= AS MATERIALIZED */ |
| 179390 | | -#line 1860 "parse.y" |
| 179391 | 178885 | {yymsp[-1].minor.yy462 = M10d_Yes;} |
| 179392 | | -#line 5543 "parse.sql" |
| 179393 | 178886 | break; |
| 179394 | 178887 | case 309: /* wqas ::= AS NOT MATERIALIZED */ |
| 179395 | | -#line 1861 "parse.y" |
| 179396 | 178888 | {yymsp[-2].minor.yy462 = M10d_No;} |
| 179397 | | -#line 5548 "parse.sql" |
| 179398 | 178889 | break; |
| 179399 | 178890 | case 310: /* wqitem ::= withnm eidlist_opt wqas LP select RP */ |
| 179400 | | -#line 1862 "parse.y" |
| 179401 | 178891 | { |
| 179402 | 178892 | yymsp[-5].minor.yy67 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy555, yymsp[-3].minor.yy462); /*A-overwrites-X*/ |
| 179403 | 178893 | } |
| 179404 | | -#line 5555 "parse.sql" |
| 179405 | 178894 | break; |
| 179406 | 178895 | case 311: /* withnm ::= nm */ |
| 179407 | | -#line 1865 "parse.y" |
| 179408 | 178896 | {pParse->bHasWith = 1;} |
| 179409 | | -#line 5560 "parse.sql" |
| 179410 | 178897 | break; |
| 179411 | 178898 | case 312: /* wqlist ::= wqitem */ |
| 179412 | | -#line 1866 "parse.y" |
| 179413 | 178899 | { |
| 179414 | 178900 | yymsp[0].minor.yy59 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy67); /*A-overwrites-X*/ |
| 179415 | 178901 | } |
| 179416 | | -#line 5567 "parse.sql" |
| 179417 | 178902 | break; |
| 179418 | 178903 | case 313: /* wqlist ::= wqlist COMMA wqitem */ |
| 179419 | | -#line 1869 "parse.y" |
| 179420 | 178904 | { |
| 179421 | 178905 | yymsp[-2].minor.yy59 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy59, yymsp[0].minor.yy67); |
| 179422 | 178906 | } |
| 179423 | | -#line 5574 "parse.sql" |
| 179424 | 178907 | break; |
| 179425 | 178908 | case 314: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 179426 | | -#line 1884 "parse.y" |
| 179427 | 178909 | { |
| 179428 | 178910 | assert( yymsp[0].minor.yy211!=0 ); |
| 179429 | 178911 | sqlite3WindowChain(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy211); |
| 179430 | 178912 | yymsp[0].minor.yy211->pNextWin = yymsp[-2].minor.yy211; |
| 179431 | 178913 | yylhsminor.yy211 = yymsp[0].minor.yy211; |
| 179432 | 178914 | } |
| 179433 | | -#line 5584 "parse.sql" |
| 179434 | 178915 | yymsp[-2].minor.yy211 = yylhsminor.yy211; |
| 179435 | 178916 | break; |
| 179436 | 178917 | case 315: /* windowdefn ::= nm AS LP window RP */ |
| 179437 | | -#line 1893 "parse.y" |
| 179438 | 178918 | { |
| 179439 | 178919 | if( ALWAYS(yymsp[-1].minor.yy211) ){ |
| 179440 | 178920 | yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 179441 | 178921 | } |
| 179442 | 178922 | yylhsminor.yy211 = yymsp[-1].minor.yy211; |
| 179443 | 178923 | } |
| 179444 | | -#line 5595 "parse.sql" |
| 179445 | 178924 | yymsp[-4].minor.yy211 = yylhsminor.yy211; |
| 179446 | 178925 | break; |
| 179447 | 178926 | case 316: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 179448 | | -#line 1927 "parse.y" |
| 179449 | 178927 | { |
| 179450 | 178928 | yymsp[-4].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, 0); |
| 179451 | 178929 | } |
| 179452 | | -#line 5603 "parse.sql" |
| 179453 | 178930 | break; |
| 179454 | 178931 | case 317: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 179455 | | -#line 1930 "parse.y" |
| 179456 | 178932 | { |
| 179457 | 178933 | yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, &yymsp[-5].minor.yy0); |
| 179458 | 178934 | } |
| 179459 | | -#line 5610 "parse.sql" |
| 179460 | 178935 | yymsp[-5].minor.yy211 = yylhsminor.yy211; |
| 179461 | 178936 | break; |
| 179462 | 178937 | case 318: /* window ::= ORDER BY sortlist frame_opt */ |
| 179463 | | -#line 1933 "parse.y" |
| 179464 | 178938 | { |
| 179465 | 178939 | yymsp[-3].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, 0); |
| 179466 | 178940 | } |
| 179467 | | -#line 5618 "parse.sql" |
| 179468 | 178941 | break; |
| 179469 | 178942 | case 319: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 179470 | | -#line 1936 "parse.y" |
| 179471 | 178943 | { |
| 179472 | 178944 | yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0); |
| 179473 | 178945 | } |
| 179474 | | -#line 5625 "parse.sql" |
| 179475 | 178946 | yymsp[-4].minor.yy211 = yylhsminor.yy211; |
| 179476 | 178947 | break; |
| 179477 | 178948 | case 320: /* window ::= nm frame_opt */ |
| 179478 | | -#line 1940 "parse.y" |
| 179479 | 178949 | { |
| 179480 | 178950 | yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, 0, &yymsp[-1].minor.yy0); |
| 179481 | 178951 | } |
| 179482 | | -#line 5633 "parse.sql" |
| 179483 | 178952 | yymsp[-1].minor.yy211 = yylhsminor.yy211; |
| 179484 | 178953 | break; |
| 179485 | 178954 | case 321: /* frame_opt ::= */ |
| 179486 | | -#line 1944 "parse.y" |
| 179487 | 178955 | { |
| 179488 | 178956 | yymsp[1].minor.yy211 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 179489 | 178957 | } |
| 179490 | | -#line 5641 "parse.sql" |
| 179491 | 178958 | break; |
| 179492 | 178959 | case 322: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 179493 | | -#line 1947 "parse.y" |
| 179494 | 178960 | { |
| 179495 | 178961 | yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy144, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy462); |
| 179496 | 178962 | } |
| 179497 | | -#line 5648 "parse.sql" |
| 179498 | 178963 | yymsp[-2].minor.yy211 = yylhsminor.yy211; |
| 179499 | 178964 | break; |
| 179500 | 178965 | case 323: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 179501 | | -#line 1951 "parse.y" |
| 179502 | 178966 | { |
| 179503 | 178967 | yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy144, yymsp[-3].minor.yy509.eType, yymsp[-3].minor.yy509.pExpr, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, yymsp[0].minor.yy462); |
| 179504 | 178968 | } |
| 179505 | | -#line 5656 "parse.sql" |
| 179506 | 178969 | yymsp[-5].minor.yy211 = yylhsminor.yy211; |
| 179507 | 178970 | break; |
| 179508 | 178971 | case 325: /* frame_bound_s ::= frame_bound */ |
| 179509 | 178972 | case 327: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==327); |
| 179510 | | -#line 1957 "parse.y" |
| 179511 | 178973 | {yylhsminor.yy509 = yymsp[0].minor.yy509;} |
| 179512 | | -#line 5663 "parse.sql" |
| 179513 | 178974 | yymsp[0].minor.yy509 = yylhsminor.yy509; |
| 179514 | 178975 | break; |
| 179515 | 178976 | case 326: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 179516 | 178977 | case 328: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==328); |
| 179517 | 178978 | case 330: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==330); |
| 179518 | | -#line 1958 "parse.y" |
| 179519 | 178979 | {yylhsminor.yy509.eType = yymsp[-1].major; yylhsminor.yy509.pExpr = 0;} |
| 179520 | | -#line 5671 "parse.sql" |
| 179521 | 178980 | yymsp[-1].minor.yy509 = yylhsminor.yy509; |
| 179522 | 178981 | break; |
| 179523 | 178982 | case 329: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 179524 | | -#line 1963 "parse.y" |
| 179525 | 178983 | {yylhsminor.yy509.eType = yymsp[0].major; yylhsminor.yy509.pExpr = yymsp[-1].minor.yy454;} |
| 179526 | | -#line 5677 "parse.sql" |
| 179527 | 178984 | yymsp[-1].minor.yy509 = yylhsminor.yy509; |
| 179528 | 178985 | break; |
| 179529 | 178986 | case 331: /* frame_exclude_opt ::= */ |
| 179530 | | -#line 1967 "parse.y" |
| 179531 | 178987 | {yymsp[1].minor.yy462 = 0;} |
| 179532 | | -#line 5683 "parse.sql" |
| 179533 | 178988 | break; |
| 179534 | 178989 | case 332: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 179535 | | -#line 1968 "parse.y" |
| 179536 | 178990 | {yymsp[-1].minor.yy462 = yymsp[0].minor.yy462;} |
| 179537 | | -#line 5688 "parse.sql" |
| 179538 | 178991 | break; |
| 179539 | 178992 | case 333: /* frame_exclude ::= NO OTHERS */ |
| 179540 | 178993 | case 334: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==334); |
| 179541 | | -#line 1971 "parse.y" |
| 179542 | 178994 | {yymsp[-1].minor.yy462 = yymsp[-1].major; /*A-overwrites-X*/} |
| 179543 | | -#line 5694 "parse.sql" |
| 179544 | 178995 | break; |
| 179545 | 178996 | case 335: /* frame_exclude ::= GROUP|TIES */ |
| 179546 | | -#line 1973 "parse.y" |
| 179547 | 178997 | {yymsp[0].minor.yy462 = yymsp[0].major; /*A-overwrites-X*/} |
| 179548 | | -#line 5699 "parse.sql" |
| 179549 | 178998 | break; |
| 179550 | 178999 | case 336: /* window_clause ::= WINDOW windowdefn_list */ |
| 179551 | | -#line 1978 "parse.y" |
| 179552 | 179000 | { yymsp[-1].minor.yy211 = yymsp[0].minor.yy211; } |
| 179553 | | -#line 5704 "parse.sql" |
| 179554 | 179001 | break; |
| 179555 | 179002 | case 337: /* filter_over ::= filter_clause over_clause */ |
| 179556 | | -#line 1980 "parse.y" |
| 179557 | 179003 | { |
| 179558 | 179004 | if( yymsp[0].minor.yy211 ){ |
| 179559 | 179005 | yymsp[0].minor.yy211->pFilter = yymsp[-1].minor.yy454; |
| 179560 | 179006 | }else{ |
| 179561 | 179007 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454); |
| 179562 | 179008 | } |
| 179563 | 179009 | yylhsminor.yy211 = yymsp[0].minor.yy211; |
| 179564 | 179010 | } |
| 179565 | | -#line 5716 "parse.sql" |
| 179566 | 179011 | yymsp[-1].minor.yy211 = yylhsminor.yy211; |
| 179567 | 179012 | break; |
| 179568 | 179013 | case 338: /* filter_over ::= over_clause */ |
| 179569 | | -#line 1988 "parse.y" |
| 179570 | 179014 | { |
| 179571 | 179015 | yylhsminor.yy211 = yymsp[0].minor.yy211; |
| 179572 | 179016 | } |
| 179573 | | -#line 5724 "parse.sql" |
| 179574 | 179017 | yymsp[0].minor.yy211 = yylhsminor.yy211; |
| 179575 | 179018 | break; |
| 179576 | 179019 | case 339: /* filter_over ::= filter_clause */ |
| 179577 | | -#line 1991 "parse.y" |
| 179578 | 179020 | { |
| 179579 | 179021 | yylhsminor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 179580 | 179022 | if( yylhsminor.yy211 ){ |
| 179581 | 179023 | yylhsminor.yy211->eFrmType = TK_FILTER; |
| 179582 | 179024 | yylhsminor.yy211->pFilter = yymsp[0].minor.yy454; |
| 179583 | 179025 | }else{ |
| 179584 | 179026 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy454); |
| 179585 | 179027 | } |
| 179586 | 179028 | } |
| 179587 | | -#line 5738 "parse.sql" |
| 179588 | 179029 | yymsp[0].minor.yy211 = yylhsminor.yy211; |
| 179589 | 179030 | break; |
| 179590 | 179031 | case 340: /* over_clause ::= OVER LP window RP */ |
| 179591 | | -#line 2001 "parse.y" |
| 179592 | 179032 | { |
| 179593 | 179033 | yymsp[-3].minor.yy211 = yymsp[-1].minor.yy211; |
| 179594 | 179034 | assert( yymsp[-3].minor.yy211!=0 ); |
| 179595 | 179035 | } |
| 179596 | | -#line 5747 "parse.sql" |
| 179597 | 179036 | break; |
| 179598 | 179037 | case 341: /* over_clause ::= OVER nm */ |
| 179599 | | -#line 2005 "parse.y" |
| 179600 | 179038 | { |
| 179601 | 179039 | yymsp[-1].minor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 179602 | 179040 | if( yymsp[-1].minor.yy211 ){ |
| 179603 | 179041 | yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 179604 | 179042 | } |
| 179605 | 179043 | } |
| 179606 | | -#line 5757 "parse.sql" |
| 179607 | 179044 | break; |
| 179608 | 179045 | case 342: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 179609 | | -#line 2012 "parse.y" |
| 179610 | 179046 | { yymsp[-4].minor.yy454 = yymsp[-1].minor.yy454; } |
| 179611 | | -#line 5762 "parse.sql" |
| 179612 | 179047 | break; |
| 179613 | 179048 | case 343: /* term ::= QNUMBER */ |
| 179614 | | -#line 2038 "parse.y" |
| 179615 | 179049 | { |
| 179616 | 179050 | yylhsminor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); |
| 179617 | 179051 | sqlite3DequoteNumber(pParse, yylhsminor.yy454); |
| 179618 | 179052 | } |
| 179619 | | -#line 5770 "parse.sql" |
| 179620 | 179053 | yymsp[0].minor.yy454 = yylhsminor.yy454; |
| 179621 | 179054 | break; |
| 179622 | 179055 | default: |
| 179623 | 179056 | /* (344) input ::= cmdlist */ yytestcase(yyruleno==344); |
| 179624 | 179057 | /* (345) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==345); |
| | @@ -179742,19 +179175,17 @@ |
| 179742 | 179175 | ){ |
| 179743 | 179176 | sqlite3ParserARG_FETCH |
| 179744 | 179177 | sqlite3ParserCTX_FETCH |
| 179745 | 179178 | #define TOKEN yyminor |
| 179746 | 179179 | /************ Begin %syntax_error code ****************************************/ |
| 179747 | | -#line 43 "parse.y" |
| 179748 | 179180 | |
| 179749 | 179181 | UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ |
| 179750 | 179182 | if( TOKEN.z[0] ){ |
| 179751 | | - sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); |
| 179183 | + parserSyntaxError(pParse, &TOKEN); |
| 179752 | 179184 | }else{ |
| 179753 | 179185 | sqlite3ErrorMsg(pParse, "incomplete input"); |
| 179754 | 179186 | } |
| 179755 | | -#line 5906 "parse.sql" |
| 179756 | 179187 | /************ End %syntax_error code ******************************************/ |
| 179757 | 179188 | sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ |
| 179758 | 179189 | sqlite3ParserCTX_STORE |
| 179759 | 179190 | } |
| 179760 | 179191 | |
| | @@ -180022,11 +179453,10 @@ |
| 180022 | 179453 | #endif |
| 180023 | 179454 | } |
| 180024 | 179455 | |
| 180025 | 179456 | /************** End of parse.c ***********************************************/ |
| 180026 | 179457 | /************** Begin file tokenize.c ****************************************/ |
| 180027 | | -#line 1 "tsrc/tokenize.c" |
| 180028 | 179458 | /* |
| 180029 | 179459 | ** 2001 September 15 |
| 180030 | 179460 | ** |
| 180031 | 179461 | ** The author disclaims copyright to this source code. In place of |
| 180032 | 179462 | ** a legal notice, here is a blessing: |
| | @@ -180172,11 +179602,10 @@ |
| 180172 | 179602 | ** named keywordhash.h and then included into this source file by |
| 180173 | 179603 | ** the #include below. |
| 180174 | 179604 | */ |
| 180175 | 179605 | /************** Include keywordhash.h in the middle of tokenize.c ************/ |
| 180176 | 179606 | /************** Begin file keywordhash.h *************************************/ |
| 180177 | | -#line 1 "tsrc/keywordhash.h" |
| 180178 | 179607 | /***** This file contains automatically generated code ****** |
| 180179 | 179608 | ** |
| 180180 | 179609 | ** The code in this file has been automatically generated by |
| 180181 | 179610 | ** |
| 180182 | 179611 | ** sqlite/tool/mkkeywordhash.c |
| | @@ -180658,11 +180087,10 @@ |
| 180658 | 180087 | return TK_ID!=sqlite3KeywordCode((const u8*)zName, nName); |
| 180659 | 180088 | } |
| 180660 | 180089 | |
| 180661 | 180090 | /************** End of keywordhash.h *****************************************/ |
| 180662 | 180091 | /************** Continuing where we left off in tokenize.c *******************/ |
| 180663 | | -#line 149 "tsrc/tokenize.c" |
| 180664 | 180092 | |
| 180665 | 180093 | |
| 180666 | 180094 | /* |
| 180667 | 180095 | ** If X is a character that can be used in an identifier then |
| 180668 | 180096 | ** IdChar(X) will be true. Otherwise it is false. |
| | @@ -181241,11 +180669,13 @@ |
| 181241 | 180669 | } |
| 181242 | 180670 | if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){ |
| 181243 | 180671 | if( pParse->zErrMsg==0 ){ |
| 181244 | 180672 | pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc)); |
| 181245 | 180673 | } |
| 181246 | | - sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail); |
| 180674 | + if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){ |
| 180675 | + sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail); |
| 180676 | + } |
| 181247 | 180677 | nErr++; |
| 181248 | 180678 | } |
| 181249 | 180679 | pParse->zTail = zSql; |
| 181250 | 180680 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 181251 | 180681 | sqlite3_free(pParse->apVtabLock); |
| | @@ -181402,11 +180832,10 @@ |
| 181402 | 180832 | } |
| 181403 | 180833 | #endif /* SQLITE_ENABLE_NORMALIZE */ |
| 181404 | 180834 | |
| 181405 | 180835 | /************** End of tokenize.c ********************************************/ |
| 181406 | 180836 | /************** Begin file complete.c ****************************************/ |
| 181407 | | -#line 1 "tsrc/complete.c" |
| 181408 | 180837 | /* |
| 181409 | 180838 | ** 2001 September 15 |
| 181410 | 180839 | ** |
| 181411 | 180840 | ** The author disclaims copyright to this source code. In place of |
| 181412 | 180841 | ** a legal notice, here is a blessing: |
| | @@ -181696,11 +181125,10 @@ |
| 181696 | 181125 | #endif /* SQLITE_OMIT_UTF16 */ |
| 181697 | 181126 | #endif /* SQLITE_OMIT_COMPLETE */ |
| 181698 | 181127 | |
| 181699 | 181128 | /************** End of complete.c ********************************************/ |
| 181700 | 181129 | /************** Begin file main.c ********************************************/ |
| 181701 | | -#line 1 "tsrc/main.c" |
| 181702 | 181130 | /* |
| 181703 | 181131 | ** 2001 September 15 |
| 181704 | 181132 | ** |
| 181705 | 181133 | ** The author disclaims copyright to this source code. In place of |
| 181706 | 181134 | ** a legal notice, here is a blessing: |
| | @@ -181718,11 +181146,10 @@ |
| 181718 | 181146 | /* #include "sqliteInt.h" */ |
| 181719 | 181147 | |
| 181720 | 181148 | #ifdef SQLITE_ENABLE_FTS3 |
| 181721 | 181149 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 181722 | 181150 | /************** Begin file fts3.h ********************************************/ |
| 181723 | | -#line 1 "tsrc/fts3.h" |
| 181724 | 181151 | /* |
| 181725 | 181152 | ** 2006 Oct 10 |
| 181726 | 181153 | ** |
| 181727 | 181154 | ** The author disclaims copyright to this source code. In place of |
| 181728 | 181155 | ** a legal notice, here is a blessing: |
| | @@ -181748,16 +181175,14 @@ |
| 181748 | 181175 | } /* extern "C" */ |
| 181749 | 181176 | #endif /* __cplusplus */ |
| 181750 | 181177 | |
| 181751 | 181178 | /************** End of fts3.h ************************************************/ |
| 181752 | 181179 | /************** Continuing where we left off in main.c ***********************/ |
| 181753 | | -#line 21 "tsrc/main.c" |
| 181754 | 181180 | #endif |
| 181755 | 181181 | #ifdef SQLITE_ENABLE_RTREE |
| 181756 | 181182 | /************** Include rtree.h in the middle of main.c **********************/ |
| 181757 | 181183 | /************** Begin file rtree.h *******************************************/ |
| 181758 | | -#line 1 "tsrc/rtree.h" |
| 181759 | 181184 | /* |
| 181760 | 181185 | ** 2008 May 26 |
| 181761 | 181186 | ** |
| 181762 | 181187 | ** The author disclaims copyright to this source code. In place of |
| 181763 | 181188 | ** a legal notice, here is a blessing: |
| | @@ -181787,16 +181212,14 @@ |
| 181787 | 181212 | } /* extern "C" */ |
| 181788 | 181213 | #endif /* __cplusplus */ |
| 181789 | 181214 | |
| 181790 | 181215 | /************** End of rtree.h ***********************************************/ |
| 181791 | 181216 | /************** Continuing where we left off in main.c ***********************/ |
| 181792 | | -#line 24 "tsrc/main.c" |
| 181793 | 181217 | #endif |
| 181794 | 181218 | #if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS) |
| 181795 | 181219 | /************** Include sqliteicu.h in the middle of main.c ******************/ |
| 181796 | 181220 | /************** Begin file sqliteicu.h ***************************************/ |
| 181797 | | -#line 1 "tsrc/sqliteicu.h" |
| 181798 | 181221 | /* |
| 181799 | 181222 | ** 2008 May 26 |
| 181800 | 181223 | ** |
| 181801 | 181224 | ** The author disclaims copyright to this source code. In place of |
| 181802 | 181225 | ** a legal notice, here is a blessing: |
| | @@ -181822,11 +181245,10 @@ |
| 181822 | 181245 | } /* extern "C" */ |
| 181823 | 181246 | #endif /* __cplusplus */ |
| 181824 | 181247 | |
| 181825 | 181248 | /************** End of sqliteicu.h *******************************************/ |
| 181826 | 181249 | /************** Continuing where we left off in main.c ***********************/ |
| 181827 | | -#line 27 "tsrc/main.c" |
| 181828 | 181250 | #endif |
| 181829 | 181251 | |
| 181830 | 181252 | /* |
| 181831 | 181253 | ** This is an extension initializer that is a no-op and always |
| 181832 | 181254 | ** succeeds, except that it fails if the fault-simulation is set |
| | @@ -184724,12 +184146,12 @@ |
| 184724 | 184146 | } |
| 184725 | 184147 | oldLimit = db->aLimit[limitId]; |
| 184726 | 184148 | if( newLimit>=0 ){ /* IMP: R-52476-28732 */ |
| 184727 | 184149 | if( newLimit>aHardLimit[limitId] ){ |
| 184728 | 184150 | newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ |
| 184729 | | - }else if( newLimit<1 && limitId==SQLITE_LIMIT_LENGTH ){ |
| 184730 | | - newLimit = 1; |
| 184151 | + }else if( newLimit<SQLITE_MIN_LENGTH && limitId==SQLITE_LIMIT_LENGTH ){ |
| 184152 | + newLimit = SQLITE_MIN_LENGTH; |
| 184731 | 184153 | } |
| 184732 | 184154 | db->aLimit[limitId] = newLimit; |
| 184733 | 184155 | } |
| 184734 | 184156 | return oldLimit; /* IMP: R-53341-35419 */ |
| 184735 | 184157 | } |
| | @@ -186087,10 +185509,11 @@ |
| 186087 | 185509 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 186088 | 185510 | sqlite3ShowWindow(0); |
| 186089 | 185511 | sqlite3ShowWinFunc(0); |
| 186090 | 185512 | #endif |
| 186091 | 185513 | sqlite3ShowSelect(0); |
| 185514 | + sqlite3ShowWhereTerm(0); |
| 186092 | 185515 | } |
| 186093 | 185516 | #endif |
| 186094 | 185517 | break; |
| 186095 | 185518 | } |
| 186096 | 185519 | |
| | @@ -186873,11 +186296,10 @@ |
| 186873 | 186296 | } |
| 186874 | 186297 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 186875 | 186298 | |
| 186876 | 186299 | /************** End of main.c ************************************************/ |
| 186877 | 186300 | /************** Begin file notify.c ******************************************/ |
| 186878 | | -#line 1 "tsrc/notify.c" |
| 186879 | 186301 | /* |
| 186880 | 186302 | ** 2009 March 3 |
| 186881 | 186303 | ** |
| 186882 | 186304 | ** The author disclaims copyright to this source code. In place of |
| 186883 | 186305 | ** a legal notice, here is a blessing: |
| | @@ -187212,11 +186634,10 @@ |
| 187212 | 186634 | } |
| 187213 | 186635 | #endif |
| 187214 | 186636 | |
| 187215 | 186637 | /************** End of notify.c **********************************************/ |
| 187216 | 186638 | /************** Begin file fts3.c ********************************************/ |
| 187217 | | -#line 1 "tsrc/fts3.c" |
| 187218 | 186639 | /* |
| 187219 | 186640 | ** 2006 Oct 10 |
| 187220 | 186641 | ** |
| 187221 | 186642 | ** The author disclaims copyright to this source code. In place of |
| 187222 | 186643 | ** a legal notice, here is a blessing: |
| | @@ -187505,11 +186926,10 @@ |
| 187505 | 186926 | ** older data. |
| 187506 | 186927 | */ |
| 187507 | 186928 | |
| 187508 | 186929 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 187509 | 186930 | /************** Begin file fts3Int.h *****************************************/ |
| 187510 | | -#line 1 "tsrc/fts3Int.h" |
| 187511 | 186931 | /* |
| 187512 | 186932 | ** 2009 Nov 12 |
| 187513 | 186933 | ** |
| 187514 | 186934 | ** The author disclaims copyright to this source code. In place of |
| 187515 | 186935 | ** a legal notice, here is a blessing: |
| | @@ -187552,11 +186972,10 @@ |
| 187552 | 186972 | #endif |
| 187553 | 186973 | |
| 187554 | 186974 | /* #include "sqlite3.h" */ |
| 187555 | 186975 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 187556 | 186976 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 187557 | | -#line 1 "tsrc/fts3_tokenizer.h" |
| 187558 | 186977 | /* |
| 187559 | 186978 | ** 2006 July 10 |
| 187560 | 186979 | ** |
| 187561 | 186980 | ** The author disclaims copyright to this source code. |
| 187562 | 186981 | ** |
| | @@ -187717,14 +187136,12 @@ |
| 187717 | 187136 | |
| 187718 | 187137 | #endif /* _FTS3_TOKENIZER_H_ */ |
| 187719 | 187138 | |
| 187720 | 187139 | /************** End of fts3_tokenizer.h **************************************/ |
| 187721 | 187140 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 187722 | | -#line 46 "tsrc/fts3Int.h" |
| 187723 | 187141 | /************** Include fts3_hash.h in the middle of fts3Int.h ***************/ |
| 187724 | 187142 | /************** Begin file fts3_hash.h ***************************************/ |
| 187725 | | -#line 1 "tsrc/fts3_hash.h" |
| 187726 | 187143 | /* |
| 187727 | 187144 | ** 2001 September 22 |
| 187728 | 187145 | ** |
| 187729 | 187146 | ** The author disclaims copyright to this source code. In place of |
| 187730 | 187147 | ** a legal notice, here is a blessing: |
| | @@ -187836,11 +187253,10 @@ |
| 187836 | 187253 | |
| 187837 | 187254 | #endif /* _FTS3_HASH_H_ */ |
| 187838 | 187255 | |
| 187839 | 187256 | /************** End of fts3_hash.h *******************************************/ |
| 187840 | 187257 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 187841 | | -#line 47 "tsrc/fts3Int.h" |
| 187842 | 187258 | |
| 187843 | 187259 | /* |
| 187844 | 187260 | ** This constant determines the maximum depth of an FTS expression tree |
| 187845 | 187261 | ** that the library will create and use. FTS uses recursion to perform |
| 187846 | 187262 | ** various operations on the query tree, so the disadvantage of a large |
| | @@ -188453,11 +187869,10 @@ |
| 188453 | 187869 | #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ |
| 188454 | 187870 | #endif /* _FTSINT_H */ |
| 188455 | 187871 | |
| 188456 | 187872 | /************** End of fts3Int.h *********************************************/ |
| 188457 | 187873 | /************** Continuing where we left off in fts3.c ***********************/ |
| 188458 | | -#line 292 "tsrc/fts3.c" |
| 188459 | 187874 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 188460 | 187875 | |
| 188461 | 187876 | #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) |
| 188462 | 187877 | # define SQLITE_CORE 1 |
| 188463 | 187878 | #endif |
| | @@ -190509,14 +189924,19 @@ |
| 190509 | 189924 | |
| 190510 | 189925 | assert_fts3_nc( p!=0 && *p1!=0 && *p2!=0 ); |
| 190511 | 189926 | if( *p1==POS_COLUMN ){ |
| 190512 | 189927 | p1++; |
| 190513 | 189928 | p1 += fts3GetVarint32(p1, &iCol1); |
| 189929 | + /* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN |
| 189930 | + ** entry, so this is actually end-of-doclist. */ |
| 189931 | + if( iCol1==0 ) return 0; |
| 190514 | 189932 | } |
| 190515 | 189933 | if( *p2==POS_COLUMN ){ |
| 190516 | 189934 | p2++; |
| 190517 | 189935 | p2 += fts3GetVarint32(p2, &iCol2); |
| 189936 | + /* As above, iCol2==0 indicates corruption. */ |
| 189937 | + if( iCol2==0 ) return 0; |
| 190518 | 189938 | } |
| 190519 | 189939 | |
| 190520 | 189940 | while( 1 ){ |
| 190521 | 189941 | if( iCol1==iCol2 ){ |
| 190522 | 189942 | char *pSave = p; |
| | @@ -193683,11 +193103,11 @@ |
| 193683 | 193103 | for(p=pExpr; p->pLeft; p=p->pLeft){ |
| 193684 | 193104 | assert( p->pRight->pPhrase->doclist.nList>0 ); |
| 193685 | 193105 | nTmp += p->pRight->pPhrase->doclist.nList; |
| 193686 | 193106 | } |
| 193687 | 193107 | nTmp += p->pPhrase->doclist.nList; |
| 193688 | | - aTmp = sqlite3_malloc64(nTmp*2); |
| 193108 | + aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX); |
| 193689 | 193109 | if( !aTmp ){ |
| 193690 | 193110 | *pRc = SQLITE_NOMEM; |
| 193691 | 193111 | res = 0; |
| 193692 | 193112 | }else{ |
| 193693 | 193113 | char *aPoslist = p->pPhrase->doclist.pList; |
| | @@ -194355,11 +193775,10 @@ |
| 194355 | 193775 | |
| 194356 | 193776 | #endif |
| 194357 | 193777 | |
| 194358 | 193778 | /************** End of fts3.c ************************************************/ |
| 194359 | 193779 | /************** Begin file fts3_aux.c ****************************************/ |
| 194360 | | -#line 1 "tsrc/fts3_aux.c" |
| 194361 | 193780 | /* |
| 194362 | 193781 | ** 2011 Jan 27 |
| 194363 | 193782 | ** |
| 194364 | 193783 | ** The author disclaims copyright to this source code. In place of |
| 194365 | 193784 | ** a legal notice, here is a blessing: |
| | @@ -194916,11 +194335,10 @@ |
| 194916 | 194335 | |
| 194917 | 194336 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 194918 | 194337 | |
| 194919 | 194338 | /************** End of fts3_aux.c ********************************************/ |
| 194920 | 194339 | /************** Begin file fts3_expr.c ***************************************/ |
| 194921 | | -#line 1 "tsrc/fts3_expr.c" |
| 194922 | 194340 | /* |
| 194923 | 194341 | ** 2008 Nov 28 |
| 194924 | 194342 | ** |
| 194925 | 194343 | ** The author disclaims copyright to this source code. In place of |
| 194926 | 194344 | ** a legal notice, here is a blessing: |
| | @@ -195238,14 +194656,15 @@ |
| 195238 | 194656 | rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos); |
| 195239 | 194657 | if( rc==SQLITE_OK ){ |
| 195240 | 194658 | Fts3PhraseToken *pToken; |
| 195241 | 194659 | |
| 195242 | 194660 | p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken)); |
| 195243 | | - if( !p ) goto no_mem; |
| 195244 | | - |
| 195245 | 194661 | zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte); |
| 195246 | | - if( !zTemp ) goto no_mem; |
| 194662 | + if( !zTemp || !p ){ |
| 194663 | + rc = SQLITE_NOMEM; |
| 194664 | + goto getnextstring_out; |
| 194665 | + } |
| 195247 | 194666 | |
| 195248 | 194667 | assert( nToken==ii ); |
| 195249 | 194668 | pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii]; |
| 195250 | 194669 | memset(pToken, 0, sizeof(Fts3PhraseToken)); |
| 195251 | 194670 | |
| | @@ -195256,53 +194675,51 @@ |
| 195256 | 194675 | pToken->isPrefix = (iEnd<nInput && zInput[iEnd]=='*'); |
| 195257 | 194676 | pToken->bFirst = (iBegin>0 && zInput[iBegin-1]=='^'); |
| 195258 | 194677 | nToken = ii+1; |
| 195259 | 194678 | } |
| 195260 | 194679 | } |
| 195261 | | - |
| 195262 | | - pModule->xClose(pCursor); |
| 195263 | | - pCursor = 0; |
| 195264 | 194680 | } |
| 195265 | 194681 | |
| 195266 | 194682 | if( rc==SQLITE_DONE ){ |
| 195267 | 194683 | int jj; |
| 195268 | 194684 | char *zBuf = 0; |
| 195269 | 194685 | |
| 195270 | 194686 | p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp); |
| 195271 | | - if( !p ) goto no_mem; |
| 194687 | + if( !p ){ |
| 194688 | + rc = SQLITE_NOMEM; |
| 194689 | + goto getnextstring_out; |
| 194690 | + } |
| 195272 | 194691 | memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p); |
| 195273 | 194692 | p->eType = FTSQUERY_PHRASE; |
| 195274 | 194693 | p->pPhrase = (Fts3Phrase *)&p[1]; |
| 195275 | 194694 | p->pPhrase->iColumn = pParse->iDefaultCol; |
| 195276 | 194695 | p->pPhrase->nToken = nToken; |
| 195277 | 194696 | |
| 195278 | 194697 | zBuf = (char *)&p->pPhrase->aToken[nToken]; |
| 194698 | + assert( nTemp==0 || zTemp ); |
| 195279 | 194699 | if( zTemp ){ |
| 195280 | 194700 | memcpy(zBuf, zTemp, nTemp); |
| 195281 | | - sqlite3_free(zTemp); |
| 195282 | | - }else{ |
| 195283 | | - assert( nTemp==0 ); |
| 195284 | 194701 | } |
| 195285 | 194702 | |
| 195286 | 194703 | for(jj=0; jj<p->pPhrase->nToken; jj++){ |
| 195287 | 194704 | p->pPhrase->aToken[jj].z = zBuf; |
| 195288 | 194705 | zBuf += p->pPhrase->aToken[jj].n; |
| 195289 | 194706 | } |
| 195290 | 194707 | rc = SQLITE_OK; |
| 195291 | 194708 | } |
| 195292 | 194709 | |
| 195293 | | - *ppExpr = p; |
| 195294 | | - return rc; |
| 195295 | | -no_mem: |
| 195296 | | - |
| 194710 | + getnextstring_out: |
| 195297 | 194711 | if( pCursor ){ |
| 195298 | 194712 | pModule->xClose(pCursor); |
| 195299 | 194713 | } |
| 195300 | 194714 | sqlite3_free(zTemp); |
| 195301 | | - sqlite3_free(p); |
| 195302 | | - *ppExpr = 0; |
| 195303 | | - return SQLITE_NOMEM; |
| 194715 | + if( rc!=SQLITE_OK ){ |
| 194716 | + sqlite3_free(p); |
| 194717 | + p = 0; |
| 194718 | + } |
| 194719 | + *ppExpr = p; |
| 194720 | + return rc; |
| 195304 | 194721 | } |
| 195305 | 194722 | |
| 195306 | 194723 | /* |
| 195307 | 194724 | ** The output variable *ppExpr is populated with an allocated Fts3Expr |
| 195308 | 194725 | ** structure, or set to 0 if the end of the input buffer is reached. |
| | @@ -196213,11 +195630,10 @@ |
| 196213 | 195630 | #endif |
| 196214 | 195631 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 196215 | 195632 | |
| 196216 | 195633 | /************** End of fts3_expr.c *******************************************/ |
| 196217 | 195634 | /************** Begin file fts3_hash.c ***************************************/ |
| 196218 | | -#line 1 "tsrc/fts3_hash.c" |
| 196219 | 195635 | /* |
| 196220 | 195636 | ** 2001 September 22 |
| 196221 | 195637 | ** |
| 196222 | 195638 | ** The author disclaims copyright to this source code. In place of |
| 196223 | 195639 | ** a legal notice, here is a blessing: |
| | @@ -196600,11 +196016,10 @@ |
| 196600 | 196016 | |
| 196601 | 196017 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 196602 | 196018 | |
| 196603 | 196019 | /************** End of fts3_hash.c *******************************************/ |
| 196604 | 196020 | /************** Begin file fts3_porter.c *************************************/ |
| 196605 | | -#line 1 "tsrc/fts3_porter.c" |
| 196606 | 196021 | /* |
| 196607 | 196022 | ** 2006 September 30 |
| 196608 | 196023 | ** |
| 196609 | 196024 | ** The author disclaims copyright to this source code. In place of |
| 196610 | 196025 | ** a legal notice, here is a blessing: |
| | @@ -197266,11 +196681,10 @@ |
| 197266 | 196681 | |
| 197267 | 196682 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 197268 | 196683 | |
| 197269 | 196684 | /************** End of fts3_porter.c *****************************************/ |
| 197270 | 196685 | /************** Begin file fts3_tokenizer.c **********************************/ |
| 197271 | | -#line 1 "tsrc/fts3_tokenizer.c" |
| 197272 | 196686 | /* |
| 197273 | 196687 | ** 2007 June 22 |
| 197274 | 196688 | ** |
| 197275 | 196689 | ** The author disclaims copyright to this source code. In place of |
| 197276 | 196690 | ** a legal notice, here is a blessing: |
| | @@ -197786,11 +197200,10 @@ |
| 197786 | 197200 | |
| 197787 | 197201 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 197788 | 197202 | |
| 197789 | 197203 | /************** End of fts3_tokenizer.c **************************************/ |
| 197790 | 197204 | /************** Begin file fts3_tokenizer1.c *********************************/ |
| 197791 | | -#line 1 "tsrc/fts3_tokenizer1.c" |
| 197792 | 197205 | /* |
| 197793 | 197206 | ** 2006 Oct 10 |
| 197794 | 197207 | ** |
| 197795 | 197208 | ** The author disclaims copyright to this source code. In place of |
| 197796 | 197209 | ** a legal notice, here is a blessing: |
| | @@ -198024,11 +197437,10 @@ |
| 198024 | 197437 | |
| 198025 | 197438 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 198026 | 197439 | |
| 198027 | 197440 | /************** End of fts3_tokenizer1.c *************************************/ |
| 198028 | 197441 | /************** Begin file fts3_tokenize_vtab.c ******************************/ |
| 198029 | | -#line 1 "tsrc/fts3_tokenize_vtab.c" |
| 198030 | 197442 | /* |
| 198031 | 197443 | ** 2013 Apr 22 |
| 198032 | 197444 | ** |
| 198033 | 197445 | ** The author disclaims copyright to this source code. In place of |
| 198034 | 197446 | ** a legal notice, here is a blessing: |
| | @@ -198487,11 +197899,10 @@ |
| 198487 | 197899 | |
| 198488 | 197900 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 198489 | 197901 | |
| 198490 | 197902 | /************** End of fts3_tokenize_vtab.c **********************************/ |
| 198491 | 197903 | /************** Begin file fts3_write.c **************************************/ |
| 198492 | | -#line 1 "tsrc/fts3_write.c" |
| 198493 | 197904 | /* |
| 198494 | 197905 | ** 2009 Oct 23 |
| 198495 | 197906 | ** |
| 198496 | 197907 | ** The author disclaims copyright to this source code. In place of |
| 198497 | 197908 | ** a legal notice, here is a blessing: |
| | @@ -204325,11 +203736,10 @@ |
| 204325 | 203736 | |
| 204326 | 203737 | #endif |
| 204327 | 203738 | |
| 204328 | 203739 | /************** End of fts3_write.c ******************************************/ |
| 204329 | 203740 | /************** Begin file fts3_snippet.c ************************************/ |
| 204330 | | -#line 1 "tsrc/fts3_snippet.c" |
| 204331 | 203741 | /* |
| 204332 | 203742 | ** 2009 Oct 23 |
| 204333 | 203743 | ** |
| 204334 | 203744 | ** The author disclaims copyright to this source code. In place of |
| 204335 | 203745 | ** a legal notice, here is a blessing: |
| | @@ -206085,11 +205495,10 @@ |
| 206085 | 205495 | |
| 206086 | 205496 | #endif |
| 206087 | 205497 | |
| 206088 | 205498 | /************** End of fts3_snippet.c ****************************************/ |
| 206089 | 205499 | /************** Begin file fts3_unicode.c ************************************/ |
| 206090 | | -#line 1 "tsrc/fts3_unicode.c" |
| 206091 | 205500 | /* |
| 206092 | 205501 | ** 2012 May 24 |
| 206093 | 205502 | ** |
| 206094 | 205503 | ** The author disclaims copyright to this source code. In place of |
| 206095 | 205504 | ** a legal notice, here is a blessing: |
| | @@ -206486,11 +205895,10 @@ |
| 206486 | 205895 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 206487 | 205896 | #endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */ |
| 206488 | 205897 | |
| 206489 | 205898 | /************** End of fts3_unicode.c ****************************************/ |
| 206490 | 205899 | /************** Begin file fts3_unicode2.c ***********************************/ |
| 206491 | | -#line 1 "tsrc/fts3_unicode2.c" |
| 206492 | 205900 | /* |
| 206493 | 205901 | ** 2012-05-25 |
| 206494 | 205902 | ** |
| 206495 | 205903 | ** The author disclaims copyright to this source code. In place of |
| 206496 | 205904 | ** a legal notice, here is a blessing: |
| | @@ -206873,11 +206281,10 @@ |
| 206873 | 206281 | #endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */ |
| 206874 | 206282 | #endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */ |
| 206875 | 206283 | |
| 206876 | 206284 | /************** End of fts3_unicode2.c ***************************************/ |
| 206877 | 206285 | /************** Begin file json.c ********************************************/ |
| 206878 | | -#line 1 "tsrc/json.c" |
| 206879 | 206286 | /* |
| 206880 | 206287 | ** 2015-08-12 |
| 206881 | 206288 | ** |
| 206882 | 206289 | ** The author disclaims copyright to this source code. In place of |
| 206883 | 206290 | ** a legal notice, here is a blessing: |
| | @@ -212343,11 +211750,10 @@ |
| 212343 | 211750 | } |
| 212344 | 211751 | #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON) */ |
| 212345 | 211752 | |
| 212346 | 211753 | /************** End of json.c ************************************************/ |
| 212347 | 211754 | /************** Begin file rtree.c *******************************************/ |
| 212348 | | -#line 1 "tsrc/rtree.c" |
| 212349 | 211755 | /* |
| 212350 | 211756 | ** 2001 September 15 |
| 212351 | 211757 | ** |
| 212352 | 211758 | ** The author disclaims copyright to this source code. In place of |
| 212353 | 211759 | ** a legal notice, here is a blessing: |
| | @@ -216632,11 +216038,10 @@ |
| 216632 | 216038 | |
| 216633 | 216039 | /* Conditionally include the geopoly code */ |
| 216634 | 216040 | #ifdef SQLITE_ENABLE_GEOPOLY |
| 216635 | 216041 | /************** Include geopoly.c in the middle of rtree.c *******************/ |
| 216636 | 216042 | /************** Begin file geopoly.c *****************************************/ |
| 216637 | | -#line 1 "tsrc/geopoly.c" |
| 216638 | 216043 | /* |
| 216639 | 216044 | ** 2018-05-25 |
| 216640 | 216045 | ** |
| 216641 | 216046 | ** The author disclaims copyright to this source code. In place of |
| 216642 | 216047 | ** a legal notice, here is a blessing: |
| | @@ -218475,11 +217880,10 @@ |
| 218475 | 217880 | return rc; |
| 218476 | 217881 | } |
| 218477 | 217882 | |
| 218478 | 217883 | /************** End of geopoly.c *********************************************/ |
| 218479 | 217884 | /************** Continuing where we left off in rtree.c **********************/ |
| 218480 | | -#line 4288 "tsrc/rtree.c" |
| 218481 | 217885 | #endif |
| 218482 | 217886 | |
| 218483 | 217887 | /* |
| 218484 | 217888 | ** Register the r-tree module with database handle db. This creates the |
| 218485 | 217889 | ** virtual table module "rtree" and the debugging/analysis scalar |
| | @@ -218658,11 +218062,10 @@ |
| 218658 | 218062 | |
| 218659 | 218063 | #endif |
| 218660 | 218064 | |
| 218661 | 218065 | /************** End of rtree.c ***********************************************/ |
| 218662 | 218066 | /************** Begin file icu.c *********************************************/ |
| 218663 | | -#line 1 "tsrc/icu.c" |
| 218664 | 218067 | /* |
| 218665 | 218068 | ** 2007 May 6 |
| 218666 | 218069 | ** |
| 218667 | 218070 | ** The author disclaims copyright to this source code. In place of |
| 218668 | 218071 | ** a legal notice, here is a blessing: |
| | @@ -219250,11 +218653,10 @@ |
| 219250 | 218653 | |
| 219251 | 218654 | #endif |
| 219252 | 218655 | |
| 219253 | 218656 | /************** End of icu.c *************************************************/ |
| 219254 | 218657 | /************** Begin file fts3_icu.c ****************************************/ |
| 219255 | | -#line 1 "tsrc/fts3_icu.c" |
| 219256 | 218658 | /* |
| 219257 | 218659 | ** 2007 June 22 |
| 219258 | 218660 | ** |
| 219259 | 218661 | ** The author disclaims copyright to this source code. In place of |
| 219260 | 218662 | ** a legal notice, here is a blessing: |
| | @@ -219516,11 +218918,10 @@ |
| 219516 | 218918 | #endif /* defined(SQLITE_ENABLE_ICU) */ |
| 219517 | 218919 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 219518 | 218920 | |
| 219519 | 218921 | /************** End of fts3_icu.c ********************************************/ |
| 219520 | 218922 | /************** Begin file sqlite3rbu.c **************************************/ |
| 219521 | | -#line 1 "tsrc/sqlite3rbu.c" |
| 219522 | 218923 | /* |
| 219523 | 218924 | ** 2014 August 30 |
| 219524 | 218925 | ** |
| 219525 | 218926 | ** The author disclaims copyright to this source code. In place of |
| 219526 | 218927 | ** a legal notice, here is a blessing: |
| | @@ -219608,11 +219009,10 @@ |
| 219608 | 219009 | /* #include "sqlite3.h" */ |
| 219609 | 219010 | |
| 219610 | 219011 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) |
| 219611 | 219012 | /************** Include sqlite3rbu.h in the middle of sqlite3rbu.c ***********/ |
| 219612 | 219013 | /************** Begin file sqlite3rbu.h **************************************/ |
| 219613 | | -#line 1 "tsrc/sqlite3rbu.h" |
| 219614 | 219014 | /* |
| 219615 | 219015 | ** 2014 August 30 |
| 219616 | 219016 | ** |
| 219617 | 219017 | ** The author disclaims copyright to this source code. In place of |
| 219618 | 219018 | ** a legal notice, here is a blessing: |
| | @@ -220245,11 +219645,10 @@ |
| 220245 | 219645 | |
| 220246 | 219646 | #endif /* _SQLITE3RBU_H */ |
| 220247 | 219647 | |
| 220248 | 219648 | /************** End of sqlite3rbu.h ******************************************/ |
| 220249 | 219649 | /************** Continuing where we left off in sqlite3rbu.c *****************/ |
| 220250 | | -#line 91 "tsrc/sqlite3rbu.c" |
| 220251 | 219650 | |
| 220252 | 219651 | #if defined(_WIN32_WCE) |
| 220253 | 219652 | /* #include "windows.h" */ |
| 220254 | 219653 | #endif |
| 220255 | 219654 | |
| | @@ -225606,11 +225005,10 @@ |
| 225606 | 225005 | |
| 225607 | 225006 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */ |
| 225608 | 225007 | |
| 225609 | 225008 | /************** End of sqlite3rbu.c ******************************************/ |
| 225610 | 225009 | /************** Begin file dbstat.c ******************************************/ |
| 225611 | | -#line 1 "tsrc/dbstat.c" |
| 225612 | 225010 | /* |
| 225613 | 225011 | ** 2010 July 12 |
| 225614 | 225012 | ** |
| 225615 | 225013 | ** The author disclaims copyright to this source code. In place of |
| 225616 | 225014 | ** a legal notice, here is a blessing: |
| | @@ -226516,11 +225914,10 @@ |
| 226516 | 225914 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } |
| 226517 | 225915 | #endif /* SQLITE_ENABLE_DBSTAT_VTAB */ |
| 226518 | 225916 | |
| 226519 | 225917 | /************** End of dbstat.c **********************************************/ |
| 226520 | 225918 | /************** Begin file dbpage.c ******************************************/ |
| 226521 | | -#line 1 "tsrc/dbpage.c" |
| 226522 | 225919 | /* |
| 226523 | 225920 | ** 2017-10-11 |
| 226524 | 225921 | ** |
| 226525 | 225922 | ** The author disclaims copyright to this source code. In place of |
| 226526 | 225923 | ** a legal notice, here is a blessing: |
| | @@ -226912,10 +226309,12 @@ |
| 226912 | 226309 | if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){ |
| 226913 | 226310 | unsigned char *aPage = sqlite3PagerGetData(pDbPage); |
| 226914 | 226311 | memcpy(aPage, pData, szPage); |
| 226915 | 226312 | pTab->pgnoTrunc = 0; |
| 226916 | 226313 | } |
| 226314 | + }else{ |
| 226315 | + pTab->pgnoTrunc = 0; |
| 226917 | 226316 | } |
| 226918 | 226317 | sqlite3PagerUnref(pDbPage); |
| 226919 | 226318 | return rc; |
| 226920 | 226319 | |
| 226921 | 226320 | update_fail: |
| | @@ -226999,11 +226398,10 @@ |
| 226999 | 226398 | SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; } |
| 227000 | 226399 | #endif /* SQLITE_ENABLE_DBSTAT_VTAB */ |
| 227001 | 226400 | |
| 227002 | 226401 | /************** End of dbpage.c **********************************************/ |
| 227003 | 226402 | /************** Begin file sqlite3session.c **********************************/ |
| 227004 | | -#line 1 "tsrc/sqlite3session.c" |
| 227005 | 226403 | |
| 227006 | 226404 | #if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK) |
| 227007 | 226405 | /* #include "sqlite3session.h" */ |
| 227008 | 226406 | /* #include <assert.h> */ |
| 227009 | 226407 | /* #include <string.h> */ |
| | @@ -233539,11 +232937,10 @@ |
| 233539 | 232937 | |
| 233540 | 232938 | #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 233541 | 232939 | |
| 233542 | 232940 | /************** End of sqlite3session.c **************************************/ |
| 233543 | 232941 | /************** Begin file fts5.c ********************************************/ |
| 233544 | | -#line 1 "tsrc/fts5.c" |
| 233545 | 232942 | |
| 233546 | 232943 | /* |
| 233547 | 232944 | ** This, the "fts5.c" source file, is a composite file that is itself |
| 233548 | 232945 | ** assembled from the following files: |
| 233549 | 232946 | ** |
| | @@ -233577,11 +232974,10 @@ |
| 233577 | 232974 | /* #include <stdint.h> */ |
| 233578 | 232975 | #endif |
| 233579 | 232976 | #ifdef HAVE_INTTYPES_H |
| 233580 | 232977 | /* #include <inttypes.h> */ |
| 233581 | 232978 | #endif |
| 233582 | | -#line 1 "fts5.h" |
| 233583 | 232979 | /* |
| 233584 | 232980 | ** 2014 May 31 |
| 233585 | 232981 | ** |
| 233586 | 232982 | ** The author disclaims copyright to this source code. In place of |
| 233587 | 232983 | ** a legal notice, here is a blessing: |
| | @@ -233878,17 +233274,32 @@ |
| 233878 | 233274 | ** This is used to access token iToken of phrase hit iIdx within the |
| 233879 | 233275 | ** current row. If iIdx is less than zero or greater than or equal to the |
| 233880 | 233276 | ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, |
| 233881 | 233277 | ** output variable (*ppToken) is set to point to a buffer containing the |
| 233882 | 233278 | ** matching document token, and (*pnToken) to the size of that buffer in |
| 233883 | | -** bytes. This API is not available if the specified token matches a |
| 233884 | | -** prefix query term. In that case both output variables are always set |
| 233885 | | -** to 0. |
| 233279 | +** bytes. |
| 233886 | 233280 | ** |
| 233887 | 233281 | ** The output text is not a copy of the document text that was tokenized. |
| 233888 | 233282 | ** It is the output of the tokenizer module. For tokendata=1 tables, this |
| 233889 | 233283 | ** includes any embedded 0x00 and trailing data. |
| 233284 | +** |
| 233285 | +** This API may be slow in some cases if the token identified by parameters |
| 233286 | +** iIdx and iToken matched a prefix token in the query. In most cases, the |
| 233287 | +** first call to this API for each prefix token in the query is forced |
| 233288 | +** to scan the portion of the full-text index that matches the prefix |
| 233289 | +** token to collect the extra data required by this API. If the prefix |
| 233290 | +** token matches a large number of token instances in the document set, |
| 233291 | +** this may be a performance problem. |
| 233292 | +** |
| 233293 | +** If the user knows in advance that a query may use this API for a |
| 233294 | +** prefix token, FTS5 may be configured to collect all required data as part |
| 233295 | +** of the initial querying of the full-text index, avoiding the second scan |
| 233296 | +** entirely. This also causes prefix queries that do not use this API to |
| 233297 | +** run more slowly and use more memory. FTS5 may be configured in this way |
| 233298 | +** either on a per-table basis using the [FTS5 insttoken | 'insttoken'] |
| 233299 | +** option, or on a per-query basis using the |
| 233300 | +** [fts5_insttoken | fts5_insttoken()] user function. |
| 233890 | 233301 | ** |
| 233891 | 233302 | ** This API can be quite slow if used with an FTS5 table created with the |
| 233892 | 233303 | ** "detail=none" or "detail=column" option. |
| 233893 | 233304 | ** |
| 233894 | 233305 | ** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale) |
| | @@ -234318,11 +233729,10 @@ |
| 234318 | 233729 | } /* end of the 'extern "C"' block */ |
| 234319 | 233730 | #endif |
| 234320 | 233731 | |
| 234321 | 233732 | #endif /* _FTS5_H */ |
| 234322 | 233733 | |
| 234323 | | -#line 1 "fts5Int.h" |
| 234324 | 233734 | /* |
| 234325 | 233735 | ** 2014 May 31 |
| 234326 | 233736 | ** |
| 234327 | 233737 | ** The author disclaims copyright to this source code. In place of |
| 234328 | 233738 | ** a legal notice, here is a blessing: |
| | @@ -234568,11 +233978,12 @@ |
| 234568 | 233978 | int nUsermerge; /* 'usermerge' setting */ |
| 234569 | 233979 | int nHashSize; /* Bytes of memory for in-memory hash */ |
| 234570 | 233980 | char *zRank; /* Name of rank function */ |
| 234571 | 233981 | char *zRankArgs; /* Arguments to rank function */ |
| 234572 | 233982 | int bSecureDelete; /* 'secure-delete' */ |
| 234573 | | - int nDeleteMerge; /* 'deletemerge' */ |
| 233983 | + int nDeleteMerge; /* 'deletemerge' */ |
| 233984 | + int bPrefixInsttoken; /* 'prefix-insttoken' */ |
| 234574 | 233985 | |
| 234575 | 233986 | /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */ |
| 234576 | 233987 | char **pzErrmsg; |
| 234577 | 233988 | |
| 234578 | 233989 | #ifdef SQLITE_DEBUG |
| | @@ -234825,11 +234236,18 @@ |
| 234825 | 234236 | static int sqlite3Fts5StructureTest(Fts5Index*, void*); |
| 234826 | 234237 | |
| 234827 | 234238 | /* |
| 234828 | 234239 | ** Used by xInstToken(): |
| 234829 | 234240 | */ |
| 234830 | | -static int sqlite3Fts5IterToken(Fts5IndexIter*, i64, int, int, const char**, int*); |
| 234241 | +static int sqlite3Fts5IterToken( |
| 234242 | + Fts5IndexIter *pIndexIter, |
| 234243 | + const char *pToken, int nToken, |
| 234244 | + i64 iRowid, |
| 234245 | + int iCol, |
| 234246 | + int iOff, |
| 234247 | + const char **ppOut, int *pnOut |
| 234248 | +); |
| 234831 | 234249 | |
| 234832 | 234250 | /* |
| 234833 | 234251 | ** Insert or remove data to or from the index. Each time a document is |
| 234834 | 234252 | ** added to or removed from the index, this function is called one or more |
| 234835 | 234253 | ** times. |
| | @@ -235258,11 +234676,10 @@ |
| 235258 | 234676 | ** End of interface to code in fts5_unicode2.c. |
| 235259 | 234677 | **************************************************************************/ |
| 235260 | 234678 | |
| 235261 | 234679 | #endif |
| 235262 | 234680 | |
| 235263 | | -#line 1 "fts5parse.h" |
| 235264 | 234681 | #define FTS5_OR 1 |
| 235265 | 234682 | #define FTS5_AND 2 |
| 235266 | 234683 | #define FTS5_NOT 3 |
| 235267 | 234684 | #define FTS5_TERM 4 |
| 235268 | 234685 | #define FTS5_COLON 5 |
| | @@ -235275,11 +234692,10 @@ |
| 235275 | 234692 | #define FTS5_CARET 12 |
| 235276 | 234693 | #define FTS5_COMMA 13 |
| 235277 | 234694 | #define FTS5_PLUS 14 |
| 235278 | 234695 | #define FTS5_STAR 15 |
| 235279 | 234696 | |
| 235280 | | -#line 1 "fts5parse.c" |
| 235281 | 234697 | /* This file is automatically generated by Lemon from input grammar |
| 235282 | 234698 | ** source file "fts5parse.y". |
| 235283 | 234699 | */ |
| 235284 | 234700 | /* |
| 235285 | 234701 | ** 2000-05-29 |
| | @@ -235304,11 +234720,10 @@ |
| 235304 | 234720 | ** |
| 235305 | 234721 | ** The following is the concatenation of all %include directives from the |
| 235306 | 234722 | ** input grammar file: |
| 235307 | 234723 | */ |
| 235308 | 234724 | /************ Begin %include sections from the grammar ************************/ |
| 235309 | | -#line 47 "fts5parse.y" |
| 235310 | 234725 | |
| 235311 | 234726 | /* #include "fts5Int.h" */ |
| 235312 | 234727 | /* #include "fts5parse.h" */ |
| 235313 | 234728 | |
| 235314 | 234729 | /* |
| | @@ -235332,11 +234747,10 @@ |
| 235332 | 234747 | ** Alternative datatype for the argument to the malloc() routine passed |
| 235333 | 234748 | ** into sqlite3ParserAlloc(). The default is size_t. |
| 235334 | 234749 | */ |
| 235335 | 234750 | #define fts5YYMALLOCARGTYPE u64 |
| 235336 | 234751 | |
| 235337 | | -#line 58 "fts5parse.sql" |
| 235338 | 234752 | /**************** End of %include directives **********************************/ |
| 235339 | 234753 | /* These constants specify the various numeric values for terminal symbols. |
| 235340 | 234754 | ***************** Begin token definitions *************************************/ |
| 235341 | 234755 | #ifndef FTS5_OR |
| 235342 | 234756 | #define FTS5_OR 1 |
| | @@ -235879,45 +235293,35 @@ |
| 235879 | 235293 | ** inside the C code. |
| 235880 | 235294 | */ |
| 235881 | 235295 | /********* Begin destructor definitions ***************************************/ |
| 235882 | 235296 | case 16: /* input */ |
| 235883 | 235297 | { |
| 235884 | | -#line 83 "fts5parse.y" |
| 235885 | 235298 | (void)pParse; |
| 235886 | | -#line 606 "fts5parse.sql" |
| 235887 | 235299 | } |
| 235888 | 235300 | break; |
| 235889 | 235301 | case 17: /* expr */ |
| 235890 | 235302 | case 18: /* cnearset */ |
| 235891 | 235303 | case 19: /* exprlist */ |
| 235892 | 235304 | { |
| 235893 | | -#line 89 "fts5parse.y" |
| 235894 | 235305 | sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); |
| 235895 | | -#line 615 "fts5parse.sql" |
| 235896 | 235306 | } |
| 235897 | 235307 | break; |
| 235898 | 235308 | case 20: /* colset */ |
| 235899 | 235309 | case 21: /* colsetlist */ |
| 235900 | 235310 | { |
| 235901 | | -#line 93 "fts5parse.y" |
| 235902 | 235311 | sqlite3_free((fts5yypminor->fts5yy11)); |
| 235903 | | -#line 623 "fts5parse.sql" |
| 235904 | 235312 | } |
| 235905 | 235313 | break; |
| 235906 | 235314 | case 22: /* nearset */ |
| 235907 | 235315 | case 23: /* nearphrases */ |
| 235908 | 235316 | { |
| 235909 | | -#line 148 "fts5parse.y" |
| 235910 | 235317 | sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); |
| 235911 | | -#line 631 "fts5parse.sql" |
| 235912 | 235318 | } |
| 235913 | 235319 | break; |
| 235914 | 235320 | case 24: /* phrase */ |
| 235915 | 235321 | { |
| 235916 | | -#line 183 "fts5parse.y" |
| 235917 | 235322 | sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); |
| 235918 | | -#line 638 "fts5parse.sql" |
| 235919 | 235323 | } |
| 235920 | 235324 | break; |
| 235921 | 235325 | /********* End destructor definitions *****************************************/ |
| 235922 | 235326 | default: break; /* If no destructor action specified: do nothing */ |
| 235923 | 235327 | } |
| | @@ -236148,14 +235552,12 @@ |
| 236148 | 235552 | #endif |
| 236149 | 235553 | while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser); |
| 236150 | 235554 | /* Here code is inserted which will execute if the parser |
| 236151 | 235555 | ** stack every overflows */ |
| 236152 | 235556 | /******** Begin %stack_overflow code ******************************************/ |
| 236153 | | -#line 36 "fts5parse.y" |
| 236154 | 235557 | |
| 236155 | 235558 | sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow"); |
| 236156 | | -#line 876 "fts5parse.sql" |
| 236157 | 235559 | /******** End %stack_overflow code ********************************************/ |
| 236158 | 235560 | sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument var */ |
| 236159 | 235561 | sqlite3Fts5ParserCTX_STORE |
| 236160 | 235562 | } |
| 236161 | 235563 | |
| | @@ -236320,202 +235722,148 @@ |
| 236320 | 235722 | ** break; |
| 236321 | 235723 | */ |
| 236322 | 235724 | /********** Begin reduce actions **********************************************/ |
| 236323 | 235725 | fts5YYMINORTYPE fts5yylhsminor; |
| 236324 | 235726 | case 0: /* input ::= expr */ |
| 236325 | | -#line 82 "fts5parse.y" |
| 236326 | 235727 | { sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); } |
| 236327 | | -#line 1047 "fts5parse.sql" |
| 236328 | 235728 | break; |
| 236329 | 235729 | case 1: /* colset ::= MINUS LCP colsetlist RCP */ |
| 236330 | | -#line 97 "fts5parse.y" |
| 236331 | 235730 | { |
| 236332 | 235731 | fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 236333 | 235732 | } |
| 236334 | | -#line 1054 "fts5parse.sql" |
| 236335 | 235733 | break; |
| 236336 | 235734 | case 2: /* colset ::= LCP colsetlist RCP */ |
| 236337 | | -#line 100 "fts5parse.y" |
| 236338 | 235735 | { fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; } |
| 236339 | | -#line 1059 "fts5parse.sql" |
| 236340 | 235736 | break; |
| 236341 | 235737 | case 3: /* colset ::= STRING */ |
| 236342 | | -#line 101 "fts5parse.y" |
| 236343 | 235738 | { |
| 236344 | 235739 | fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 236345 | 235740 | } |
| 236346 | | -#line 1066 "fts5parse.sql" |
| 236347 | 235741 | fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 236348 | 235742 | break; |
| 236349 | 235743 | case 4: /* colset ::= MINUS STRING */ |
| 236350 | | -#line 104 "fts5parse.y" |
| 236351 | 235744 | { |
| 236352 | 235745 | fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 236353 | 235746 | fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 236354 | 235747 | } |
| 236355 | | -#line 1075 "fts5parse.sql" |
| 236356 | 235748 | break; |
| 236357 | 235749 | case 5: /* colsetlist ::= colsetlist STRING */ |
| 236358 | | -#line 109 "fts5parse.y" |
| 236359 | 235750 | { |
| 236360 | 235751 | fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); } |
| 236361 | | -#line 1081 "fts5parse.sql" |
| 236362 | 235752 | fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 236363 | 235753 | break; |
| 236364 | 235754 | case 6: /* colsetlist ::= STRING */ |
| 236365 | | -#line 111 "fts5parse.y" |
| 236366 | 235755 | { |
| 236367 | 235756 | fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 236368 | 235757 | } |
| 236369 | | -#line 1089 "fts5parse.sql" |
| 236370 | 235758 | fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 236371 | 235759 | break; |
| 236372 | 235760 | case 7: /* expr ::= expr AND expr */ |
| 236373 | | -#line 115 "fts5parse.y" |
| 236374 | 235761 | { |
| 236375 | 235762 | fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 236376 | 235763 | } |
| 236377 | | -#line 1097 "fts5parse.sql" |
| 236378 | 235764 | fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236379 | 235765 | break; |
| 236380 | 235766 | case 8: /* expr ::= expr OR expr */ |
| 236381 | | -#line 118 "fts5parse.y" |
| 236382 | 235767 | { |
| 236383 | 235768 | fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 236384 | 235769 | } |
| 236385 | | -#line 1105 "fts5parse.sql" |
| 236386 | 235770 | fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236387 | 235771 | break; |
| 236388 | 235772 | case 9: /* expr ::= expr NOT expr */ |
| 236389 | | -#line 121 "fts5parse.y" |
| 236390 | 235773 | { |
| 236391 | 235774 | fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 236392 | 235775 | } |
| 236393 | | -#line 1113 "fts5parse.sql" |
| 236394 | 235776 | fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236395 | 235777 | break; |
| 236396 | 235778 | case 10: /* expr ::= colset COLON LP expr RP */ |
| 236397 | | -#line 125 "fts5parse.y" |
| 236398 | 235779 | { |
| 236399 | 235780 | sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11); |
| 236400 | 235781 | fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24; |
| 236401 | 235782 | } |
| 236402 | | -#line 1122 "fts5parse.sql" |
| 236403 | 235783 | fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236404 | 235784 | break; |
| 236405 | 235785 | case 11: /* expr ::= LP expr RP */ |
| 236406 | | -#line 129 "fts5parse.y" |
| 236407 | 235786 | {fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;} |
| 236408 | | -#line 1128 "fts5parse.sql" |
| 236409 | 235787 | break; |
| 236410 | 235788 | case 12: /* expr ::= exprlist */ |
| 236411 | 235789 | case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13); |
| 236412 | | -#line 130 "fts5parse.y" |
| 236413 | 235790 | {fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;} |
| 236414 | | -#line 1134 "fts5parse.sql" |
| 236415 | 235791 | fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236416 | 235792 | break; |
| 236417 | 235793 | case 14: /* exprlist ::= exprlist cnearset */ |
| 236418 | | -#line 133 "fts5parse.y" |
| 236419 | 235794 | { |
| 236420 | 235795 | fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24); |
| 236421 | 235796 | } |
| 236422 | | -#line 1142 "fts5parse.sql" |
| 236423 | 235797 | fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236424 | 235798 | break; |
| 236425 | 235799 | case 15: /* cnearset ::= nearset */ |
| 236426 | | -#line 137 "fts5parse.y" |
| 236427 | 235800 | { |
| 236428 | 235801 | fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 236429 | 235802 | } |
| 236430 | | -#line 1150 "fts5parse.sql" |
| 236431 | 235803 | fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236432 | 235804 | break; |
| 236433 | 235805 | case 16: /* cnearset ::= colset COLON nearset */ |
| 236434 | | -#line 140 "fts5parse.y" |
| 236435 | 235806 | { |
| 236436 | 235807 | fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 236437 | 235808 | sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11); |
| 236438 | 235809 | } |
| 236439 | | -#line 1159 "fts5parse.sql" |
| 236440 | 235810 | fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 236441 | 235811 | break; |
| 236442 | 235812 | case 17: /* nearset ::= phrase */ |
| 236443 | | -#line 151 "fts5parse.y" |
| 236444 | 235813 | { fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } |
| 236445 | | -#line 1165 "fts5parse.sql" |
| 236446 | 235814 | fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 236447 | 235815 | break; |
| 236448 | 235816 | case 18: /* nearset ::= CARET phrase */ |
| 236449 | | -#line 152 "fts5parse.y" |
| 236450 | 235817 | { |
| 236451 | 235818 | sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy53); |
| 236452 | 235819 | fts5yymsp[-1].minor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); |
| 236453 | 235820 | } |
| 236454 | | -#line 1174 "fts5parse.sql" |
| 236455 | 235821 | break; |
| 236456 | 235822 | case 19: /* nearset ::= STRING LP nearphrases neardist_opt RP */ |
| 236457 | | -#line 156 "fts5parse.y" |
| 236458 | 235823 | { |
| 236459 | 235824 | sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0); |
| 236460 | 235825 | sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0); |
| 236461 | 235826 | fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46; |
| 236462 | 235827 | } |
| 236463 | | -#line 1183 "fts5parse.sql" |
| 236464 | 235828 | fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 236465 | 235829 | break; |
| 236466 | 235830 | case 20: /* nearphrases ::= phrase */ |
| 236467 | | -#line 162 "fts5parse.y" |
| 236468 | 235831 | { |
| 236469 | 235832 | fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); |
| 236470 | 235833 | } |
| 236471 | | -#line 1191 "fts5parse.sql" |
| 236472 | 235834 | fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 236473 | 235835 | break; |
| 236474 | 235836 | case 21: /* nearphrases ::= nearphrases phrase */ |
| 236475 | | -#line 165 "fts5parse.y" |
| 236476 | 235837 | { |
| 236477 | 235838 | fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53); |
| 236478 | 235839 | } |
| 236479 | | -#line 1199 "fts5parse.sql" |
| 236480 | 235840 | fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 236481 | 235841 | break; |
| 236482 | 235842 | case 22: /* neardist_opt ::= */ |
| 236483 | | -#line 172 "fts5parse.y" |
| 236484 | 235843 | { fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; } |
| 236485 | | -#line 1205 "fts5parse.sql" |
| 236486 | 235844 | break; |
| 236487 | 235845 | case 23: /* neardist_opt ::= COMMA STRING */ |
| 236488 | | -#line 173 "fts5parse.y" |
| 236489 | 235846 | { fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; } |
| 236490 | | -#line 1210 "fts5parse.sql" |
| 236491 | 235847 | break; |
| 236492 | 235848 | case 24: /* phrase ::= phrase PLUS STRING star_opt */ |
| 236493 | | -#line 185 "fts5parse.y" |
| 236494 | 235849 | { |
| 236495 | 235850 | fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); |
| 236496 | 235851 | } |
| 236497 | | -#line 1217 "fts5parse.sql" |
| 236498 | 235852 | fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53; |
| 236499 | 235853 | break; |
| 236500 | 235854 | case 25: /* phrase ::= STRING star_opt */ |
| 236501 | | -#line 188 "fts5parse.y" |
| 236502 | 235855 | { |
| 236503 | 235856 | fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); |
| 236504 | 235857 | } |
| 236505 | | -#line 1225 "fts5parse.sql" |
| 236506 | 235858 | fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53; |
| 236507 | 235859 | break; |
| 236508 | 235860 | case 26: /* star_opt ::= STAR */ |
| 236509 | | -#line 196 "fts5parse.y" |
| 236510 | 235861 | { fts5yymsp[0].minor.fts5yy4 = 1; } |
| 236511 | | -#line 1231 "fts5parse.sql" |
| 236512 | 235862 | break; |
| 236513 | 235863 | case 27: /* star_opt ::= */ |
| 236514 | | -#line 197 "fts5parse.y" |
| 236515 | 235864 | { fts5yymsp[1].minor.fts5yy4 = 0; } |
| 236516 | | -#line 1236 "fts5parse.sql" |
| 236517 | 235865 | break; |
| 236518 | 235866 | default: |
| 236519 | 235867 | break; |
| 236520 | 235868 | /********** End reduce actions ************************************************/ |
| 236521 | 235869 | }; |
| | @@ -236573,17 +235921,15 @@ |
| 236573 | 235921 | ){ |
| 236574 | 235922 | sqlite3Fts5ParserARG_FETCH |
| 236575 | 235923 | sqlite3Fts5ParserCTX_FETCH |
| 236576 | 235924 | #define FTS5TOKEN fts5yyminor |
| 236577 | 235925 | /************ Begin %syntax_error code ****************************************/ |
| 236578 | | -#line 30 "fts5parse.y" |
| 236579 | 235926 | |
| 236580 | 235927 | UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */ |
| 236581 | 235928 | sqlite3Fts5ParseError( |
| 236582 | 235929 | pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p |
| 236583 | 235930 | ); |
| 236584 | | -#line 1304 "fts5parse.sql" |
| 236585 | 235931 | /************ End %syntax_error code ******************************************/ |
| 236586 | 235932 | sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ |
| 236587 | 235933 | sqlite3Fts5ParserCTX_STORE |
| 236588 | 235934 | } |
| 236589 | 235935 | |
| | @@ -236849,11 +236195,10 @@ |
| 236849 | 236195 | (void)iToken; |
| 236850 | 236196 | return 0; |
| 236851 | 236197 | #endif |
| 236852 | 236198 | } |
| 236853 | 236199 | |
| 236854 | | -#line 1 "fts5_aux.c" |
| 236855 | 236200 | /* |
| 236856 | 236201 | ** 2014 May 31 |
| 236857 | 236202 | ** |
| 236858 | 236203 | ** The author disclaims copyright to this source code. In place of |
| 236859 | 236204 | ** a legal notice, here is a blessing: |
| | @@ -237672,11 +237017,10 @@ |
| 237672 | 237017 | } |
| 237673 | 237018 | |
| 237674 | 237019 | return rc; |
| 237675 | 237020 | } |
| 237676 | 237021 | |
| 237677 | | -#line 1 "fts5_buffer.c" |
| 237678 | 237022 | /* |
| 237679 | 237023 | ** 2014 May 31 |
| 237680 | 237024 | ** |
| 237681 | 237025 | ** The author disclaims copyright to this source code. In place of |
| 237682 | 237026 | ** a legal notice, here is a blessing: |
| | @@ -238085,11 +237429,10 @@ |
| 238085 | 237429 | } |
| 238086 | 237430 | sqlite3_free(p); |
| 238087 | 237431 | } |
| 238088 | 237432 | } |
| 238089 | 237433 | |
| 238090 | | -#line 1 "fts5_config.c" |
| 238091 | 237434 | /* |
| 238092 | 237435 | ** 2014 Jun 09 |
| 238093 | 237436 | ** |
| 238094 | 237437 | ** The author disclaims copyright to this source code. In place of |
| 238095 | 237438 | ** a legal notice, here is a blessing: |
| | @@ -239114,10 +238457,23 @@ |
| 239114 | 238457 | if( bVal<0 ){ |
| 239115 | 238458 | *pbBadkey = 1; |
| 239116 | 238459 | }else{ |
| 239117 | 238460 | pConfig->bSecureDelete = (bVal ? 1 : 0); |
| 239118 | 238461 | } |
| 238462 | + } |
| 238463 | + |
| 238464 | + else if( 0==sqlite3_stricmp(zKey, "insttoken") ){ |
| 238465 | + int bVal = -1; |
| 238466 | + if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){ |
| 238467 | + bVal = sqlite3_value_int(pVal); |
| 238468 | + } |
| 238469 | + if( bVal<0 ){ |
| 238470 | + *pbBadkey = 1; |
| 238471 | + }else{ |
| 238472 | + pConfig->bPrefixInsttoken = (bVal ? 1 : 0); |
| 238473 | + } |
| 238474 | + |
| 239119 | 238475 | }else{ |
| 239120 | 238476 | *pbBadkey = 1; |
| 239121 | 238477 | } |
| 239122 | 238478 | return rc; |
| 239123 | 238479 | } |
| | @@ -239201,11 +238557,10 @@ |
| 239201 | 238557 | va_end(ap); |
| 239202 | 238558 | } |
| 239203 | 238559 | |
| 239204 | 238560 | |
| 239205 | 238561 | |
| 239206 | | -#line 1 "fts5_expr.c" |
| 239207 | 238562 | /* |
| 239208 | 238563 | ** 2014 May 31 |
| 239209 | 238564 | ** |
| 239210 | 238565 | ** The author disclaims copyright to this source code. In place of |
| 239211 | 238566 | ** a legal notice, here is a blessing: |
| | @@ -242250,11 +241605,11 @@ |
| 242250 | 241605 | && memcmp(pT->pTerm, pToken, pT->nQueryTerm)==0 |
| 242251 | 241606 | ){ |
| 242252 | 241607 | int rc = sqlite3Fts5PoslistWriterAppend( |
| 242253 | 241608 | &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff |
| 242254 | 241609 | ); |
| 242255 | | - if( rc==SQLITE_OK && pExpr->pConfig->bTokendata && !pT->bPrefix ){ |
| 241610 | + if( rc==SQLITE_OK && (pExpr->pConfig->bTokendata || pT->bPrefix) ){ |
| 242256 | 241611 | int iCol = p->iOff>>32; |
| 242257 | 241612 | int iTokOff = p->iOff & 0x7FFFFFFF; |
| 242258 | 241613 | rc = sqlite3Fts5IndexIterWriteTokendata( |
| 242259 | 241614 | pT->pIter, pToken, nToken, iRowid, iCol, iTokOff |
| 242260 | 241615 | ); |
| | @@ -242443,19 +241798,18 @@ |
| 242443 | 241798 | pPhrase = pExpr->apExprPhrase[iPhrase]; |
| 242444 | 241799 | if( iToken<0 || iToken>=pPhrase->nTerm ){ |
| 242445 | 241800 | return SQLITE_RANGE; |
| 242446 | 241801 | } |
| 242447 | 241802 | pTerm = &pPhrase->aTerm[iToken]; |
| 242448 | | - if( pTerm->bPrefix==0 ){ |
| 242449 | | - if( pExpr->pConfig->bTokendata ){ |
| 242450 | | - rc = sqlite3Fts5IterToken( |
| 242451 | | - pTerm->pIter, iRowid, iCol, iOff+iToken, ppOut, pnOut |
| 242452 | | - ); |
| 242453 | | - }else{ |
| 242454 | | - *ppOut = pTerm->pTerm; |
| 242455 | | - *pnOut = pTerm->nFullTerm; |
| 242456 | | - } |
| 241803 | + if( pExpr->pConfig->bTokendata || pTerm->bPrefix ){ |
| 241804 | + rc = sqlite3Fts5IterToken( |
| 241805 | + pTerm->pIter, pTerm->pTerm, pTerm->nQueryTerm, |
| 241806 | + iRowid, iCol, iOff+iToken, ppOut, pnOut |
| 241807 | + ); |
| 241808 | + }else{ |
| 241809 | + *ppOut = pTerm->pTerm; |
| 241810 | + *pnOut = pTerm->nFullTerm; |
| 242457 | 241811 | } |
| 242458 | 241812 | return rc; |
| 242459 | 241813 | } |
| 242460 | 241814 | |
| 242461 | 241815 | /* |
| | @@ -242470,11 +241824,10 @@ |
| 242470 | 241824 | sqlite3Fts5IndexIterClearTokendata(pT->pIter); |
| 242471 | 241825 | } |
| 242472 | 241826 | } |
| 242473 | 241827 | } |
| 242474 | 241828 | |
| 242475 | | -#line 1 "fts5_hash.c" |
| 242476 | 241829 | /* |
| 242477 | 241830 | ** 2014 August 11 |
| 242478 | 241831 | ** |
| 242479 | 241832 | ** The author disclaims copyright to this source code. In place of |
| 242480 | 241833 | ** a legal notice, here is a blessing: |
| | @@ -243062,11 +242415,10 @@ |
| 243062 | 242415 | *ppDoclist = 0; |
| 243063 | 242416 | *pnDoclist = 0; |
| 243064 | 242417 | } |
| 243065 | 242418 | } |
| 243066 | 242419 | |
| 243067 | | -#line 1 "fts5_index.c" |
| 243068 | 242420 | /* |
| 243069 | 242421 | ** 2014 May 31 |
| 243070 | 242422 | ** |
| 243071 | 242423 | ** The author disclaims copyright to this source code. In place of |
| 243072 | 242424 | ** a legal notice, here is a blessing: |
| | @@ -249268,10 +248620,387 @@ |
| 249268 | 248620 | fts5BufferFree(&tmp); |
| 249269 | 248621 | memset(&out.p[out.n], 0, FTS5_DATA_ZERO_PADDING); |
| 249270 | 248622 | *p1 = out; |
| 249271 | 248623 | } |
| 249272 | 248624 | |
| 248625 | + |
| 248626 | +/* |
| 248627 | +** Iterate through a range of entries in the FTS index, invoking the xVisit |
| 248628 | +** callback for each of them. |
| 248629 | +** |
| 248630 | +** Parameter pToken points to an nToken buffer containing an FTS index term |
| 248631 | +** (i.e. a document term with the preceding 1 byte index identifier - |
| 248632 | +** FTS5_MAIN_PREFIX or similar). If bPrefix is true, then the call visits |
| 248633 | +** all entries for terms that have pToken/nToken as a prefix. If bPrefix |
| 248634 | +** is false, then only entries with pToken/nToken as the entire key are |
| 248635 | +** visited. |
| 248636 | +** |
| 248637 | +** If the current table is a tokendata=1 table, then if bPrefix is true then |
| 248638 | +** each index term is treated separately. However, if bPrefix is false, then |
| 248639 | +** all index terms corresponding to pToken/nToken are collapsed into a single |
| 248640 | +** term before the callback is invoked. |
| 248641 | +** |
| 248642 | +** The callback invoked for each entry visited is specified by paramter xVisit. |
| 248643 | +** Each time it is invoked, it is passed a pointer to the Fts5Index object, |
| 248644 | +** a copy of the 7th paramter to this function (pCtx) and a pointer to the |
| 248645 | +** iterator that indicates the current entry. If the current entry is the |
| 248646 | +** first with a new term (i.e. different from that of the previous entry, |
| 248647 | +** including the very first term), then the final two parameters are passed |
| 248648 | +** a pointer to the term and its size in bytes, respectively. If the current |
| 248649 | +** entry is not the first associated with its term, these two parameters |
| 248650 | +** are passed 0. |
| 248651 | +** |
| 248652 | +** If parameter pColset is not NULL, then it is used to filter entries before |
| 248653 | +** the callback is invoked. |
| 248654 | +*/ |
| 248655 | +static int fts5VisitEntries( |
| 248656 | + Fts5Index *p, /* Fts5 index object */ |
| 248657 | + Fts5Colset *pColset, /* Columns filter to apply, or NULL */ |
| 248658 | + u8 *pToken, /* Buffer containing token */ |
| 248659 | + int nToken, /* Size of buffer pToken in bytes */ |
| 248660 | + int bPrefix, /* True for a prefix scan */ |
| 248661 | + void (*xVisit)(Fts5Index*, void *pCtx, Fts5Iter *pIter, const u8*, int), |
| 248662 | + void *pCtx /* Passed as second argument to xVisit() */ |
| 248663 | +){ |
| 248664 | + const int flags = (bPrefix ? FTS5INDEX_QUERY_SCAN : 0) |
| 248665 | + | FTS5INDEX_QUERY_SKIPEMPTY |
| 248666 | + | FTS5INDEX_QUERY_NOOUTPUT; |
| 248667 | + Fts5Iter *p1 = 0; /* Iterator used to gather data from index */ |
| 248668 | + int bNewTerm = 1; |
| 248669 | + Fts5Structure *pStruct = fts5StructureRead(p); |
| 248670 | + |
| 248671 | + fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1); |
| 248672 | + fts5IterSetOutputCb(&p->rc, p1); |
| 248673 | + for( /* no-op */ ; |
| 248674 | + fts5MultiIterEof(p, p1)==0; |
| 248675 | + fts5MultiIterNext2(p, p1, &bNewTerm) |
| 248676 | + ){ |
| 248677 | + Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ]; |
| 248678 | + int nNew = 0; |
| 248679 | + const u8 *pNew = 0; |
| 248680 | + |
| 248681 | + p1->xSetOutputs(p1, pSeg); |
| 248682 | + if( p->rc ) break; |
| 248683 | + |
| 248684 | + if( bNewTerm ){ |
| 248685 | + nNew = pSeg->term.n; |
| 248686 | + pNew = pSeg->term.p; |
| 248687 | + if( nNew<nToken || memcmp(pToken, pNew, nToken) ) break; |
| 248688 | + } |
| 248689 | + |
| 248690 | + xVisit(p, pCtx, p1, pNew, nNew); |
| 248691 | + } |
| 248692 | + fts5MultiIterFree(p1); |
| 248693 | + |
| 248694 | + fts5StructureRelease(pStruct); |
| 248695 | + return p->rc; |
| 248696 | +} |
| 248697 | + |
| 248698 | + |
| 248699 | +/* |
| 248700 | +** Usually, a tokendata=1 iterator (struct Fts5TokenDataIter) accumulates an |
| 248701 | +** array of these for each row it visits (so all iRowid fields are the same). |
| 248702 | +** Or, for an iterator used by an "ORDER BY rank" query, it accumulates an |
| 248703 | +** array of these for the entire query (in which case iRowid fields may take |
| 248704 | +** a variety of values). |
| 248705 | +** |
| 248706 | +** Each instance in the array indicates the iterator (and therefore term) |
| 248707 | +** associated with position iPos of rowid iRowid. This is used by the |
| 248708 | +** xInstToken() API. |
| 248709 | +** |
| 248710 | +** iRowid: |
| 248711 | +** Rowid for the current entry. |
| 248712 | +** |
| 248713 | +** iPos: |
| 248714 | +** Position of current entry within row. In the usual ((iCol<<32)+iOff) |
| 248715 | +** format (e.g. see macros FTS5_POS2COLUMN() and FTS5_POS2OFFSET()). |
| 248716 | +** |
| 248717 | +** iIter: |
| 248718 | +** If the Fts5TokenDataIter iterator that the entry is part of is |
| 248719 | +** actually an iterator (i.e. with nIter>0, not just a container for |
| 248720 | +** Fts5TokenDataMap structures), then this variable is an index into |
| 248721 | +** the apIter[] array. The corresponding term is that which the iterator |
| 248722 | +** at apIter[iIter] currently points to. |
| 248723 | +** |
| 248724 | +** Or, if the Fts5TokenDataIter iterator is just a container object |
| 248725 | +** (nIter==0), then iIter is an index into the term.p[] buffer where |
| 248726 | +** the term is stored. |
| 248727 | +** |
| 248728 | +** nByte: |
| 248729 | +** In the case where iIter is an index into term.p[], this variable |
| 248730 | +** is the size of the term in bytes. If iIter is an index into apIter[], |
| 248731 | +** this variable is unused. |
| 248732 | +*/ |
| 248733 | +struct Fts5TokenDataMap { |
| 248734 | + i64 iRowid; /* Row this token is located in */ |
| 248735 | + i64 iPos; /* Position of token */ |
| 248736 | + int iIter; /* Iterator token was read from */ |
| 248737 | + int nByte; /* Length of token in bytes (or 0) */ |
| 248738 | +}; |
| 248739 | + |
| 248740 | +/* |
| 248741 | +** An object used to supplement Fts5Iter for tokendata=1 iterators. |
| 248742 | +** |
| 248743 | +** This object serves two purposes. The first is as a container for an array |
| 248744 | +** of Fts5TokenDataMap structures, which are used to find the token required |
| 248745 | +** when the xInstToken() API is used. This is done by the nMapAlloc, nMap and |
| 248746 | +** aMap[] variables. |
| 248747 | +*/ |
| 248748 | +struct Fts5TokenDataIter { |
| 248749 | + int nMapAlloc; /* Allocated size of aMap[] in entries */ |
| 248750 | + int nMap; /* Number of valid entries in aMap[] */ |
| 248751 | + Fts5TokenDataMap *aMap; /* Array of (rowid+pos -> token) mappings */ |
| 248752 | + |
| 248753 | + /* The following are used for prefix-queries only. */ |
| 248754 | + Fts5Buffer terms; |
| 248755 | + |
| 248756 | + /* The following are used for other full-token tokendata queries only. */ |
| 248757 | + int nIter; |
| 248758 | + int nIterAlloc; |
| 248759 | + Fts5PoslistReader *aPoslistReader; |
| 248760 | + int *aPoslistToIter; |
| 248761 | + Fts5Iter *apIter[1]; |
| 248762 | +}; |
| 248763 | + |
| 248764 | +/* |
| 248765 | +** The two input arrays - a1[] and a2[] - are in sorted order. This function |
| 248766 | +** merges the two arrays together and writes the result to output array |
| 248767 | +** aOut[]. aOut[] is guaranteed to be large enough to hold the result. |
| 248768 | +** |
| 248769 | +** Duplicate entries are copied into the output. So the size of the output |
| 248770 | +** array is always (n1+n2) entries. |
| 248771 | +*/ |
| 248772 | +static void fts5TokendataMerge( |
| 248773 | + Fts5TokenDataMap *a1, int n1, /* Input array 1 */ |
| 248774 | + Fts5TokenDataMap *a2, int n2, /* Input array 2 */ |
| 248775 | + Fts5TokenDataMap *aOut /* Output array */ |
| 248776 | +){ |
| 248777 | + int i1 = 0; |
| 248778 | + int i2 = 0; |
| 248779 | + |
| 248780 | + assert( n1>=0 && n2>=0 ); |
| 248781 | + while( i1<n1 || i2<n2 ){ |
| 248782 | + Fts5TokenDataMap *pOut = &aOut[i1+i2]; |
| 248783 | + if( i2>=n2 || (i1<n1 && ( |
| 248784 | + a1[i1].iRowid<a2[i2].iRowid |
| 248785 | + || (a1[i1].iRowid==a2[i2].iRowid && a1[i1].iPos<=a2[i2].iPos) |
| 248786 | + ))){ |
| 248787 | + memcpy(pOut, &a1[i1], sizeof(Fts5TokenDataMap)); |
| 248788 | + i1++; |
| 248789 | + }else{ |
| 248790 | + memcpy(pOut, &a2[i2], sizeof(Fts5TokenDataMap)); |
| 248791 | + i2++; |
| 248792 | + } |
| 248793 | + } |
| 248794 | +} |
| 248795 | + |
| 248796 | + |
| 248797 | +/* |
| 248798 | +** Append a mapping to the token-map belonging to object pT. |
| 248799 | +*/ |
| 248800 | +static void fts5TokendataIterAppendMap( |
| 248801 | + Fts5Index *p, |
| 248802 | + Fts5TokenDataIter *pT, |
| 248803 | + int iIter, |
| 248804 | + int nByte, |
| 248805 | + i64 iRowid, |
| 248806 | + i64 iPos |
| 248807 | +){ |
| 248808 | + if( p->rc==SQLITE_OK ){ |
| 248809 | + if( pT->nMap==pT->nMapAlloc ){ |
| 248810 | + int nNew = pT->nMapAlloc ? pT->nMapAlloc*2 : 64; |
| 248811 | + int nAlloc = nNew * sizeof(Fts5TokenDataMap); |
| 248812 | + Fts5TokenDataMap *aNew; |
| 248813 | + |
| 248814 | + aNew = (Fts5TokenDataMap*)sqlite3_realloc(pT->aMap, nAlloc); |
| 248815 | + if( aNew==0 ){ |
| 248816 | + p->rc = SQLITE_NOMEM; |
| 248817 | + return; |
| 248818 | + } |
| 248819 | + |
| 248820 | + pT->aMap = aNew; |
| 248821 | + pT->nMapAlloc = nNew; |
| 248822 | + } |
| 248823 | + |
| 248824 | + pT->aMap[pT->nMap].iRowid = iRowid; |
| 248825 | + pT->aMap[pT->nMap].iPos = iPos; |
| 248826 | + pT->aMap[pT->nMap].iIter = iIter; |
| 248827 | + pT->aMap[pT->nMap].nByte = nByte; |
| 248828 | + pT->nMap++; |
| 248829 | + } |
| 248830 | +} |
| 248831 | + |
| 248832 | +/* |
| 248833 | +** Sort the contents of the pT->aMap[] array. |
| 248834 | +** |
| 248835 | +** The sorting algorithm requries a malloc(). If this fails, an error code |
| 248836 | +** is left in Fts5Index.rc before returning. |
| 248837 | +*/ |
| 248838 | +static void fts5TokendataIterSortMap(Fts5Index *p, Fts5TokenDataIter *pT){ |
| 248839 | + Fts5TokenDataMap *aTmp = 0; |
| 248840 | + int nByte = pT->nMap * sizeof(Fts5TokenDataMap); |
| 248841 | + |
| 248842 | + aTmp = (Fts5TokenDataMap*)sqlite3Fts5MallocZero(&p->rc, nByte); |
| 248843 | + if( aTmp ){ |
| 248844 | + Fts5TokenDataMap *a1 = pT->aMap; |
| 248845 | + Fts5TokenDataMap *a2 = aTmp; |
| 248846 | + i64 nHalf; |
| 248847 | + |
| 248848 | + for(nHalf=1; nHalf<pT->nMap; nHalf=nHalf*2){ |
| 248849 | + int i1; |
| 248850 | + for(i1=0; i1<pT->nMap; i1+=(nHalf*2)){ |
| 248851 | + int n1 = MIN(nHalf, pT->nMap-i1); |
| 248852 | + int n2 = MIN(nHalf, pT->nMap-i1-n1); |
| 248853 | + fts5TokendataMerge(&a1[i1], n1, &a1[i1+n1], n2, &a2[i1]); |
| 248854 | + } |
| 248855 | + SWAPVAL(Fts5TokenDataMap*, a1, a2); |
| 248856 | + } |
| 248857 | + |
| 248858 | + if( a1!=pT->aMap ){ |
| 248859 | + memcpy(pT->aMap, a1, pT->nMap*sizeof(Fts5TokenDataMap)); |
| 248860 | + } |
| 248861 | + sqlite3_free(aTmp); |
| 248862 | + |
| 248863 | +#ifdef SQLITE_DEBUG |
| 248864 | + { |
| 248865 | + int ii; |
| 248866 | + for(ii=1; ii<pT->nMap; ii++){ |
| 248867 | + Fts5TokenDataMap *p1 = &pT->aMap[ii-1]; |
| 248868 | + Fts5TokenDataMap *p2 = &pT->aMap[ii]; |
| 248869 | + assert( p1->iRowid<p2->iRowid |
| 248870 | + || (p1->iRowid==p2->iRowid && p1->iPos<=p2->iPos) |
| 248871 | + ); |
| 248872 | + } |
| 248873 | + } |
| 248874 | +#endif |
| 248875 | + } |
| 248876 | +} |
| 248877 | + |
| 248878 | +/* |
| 248879 | +** Delete an Fts5TokenDataIter structure and its contents. |
| 248880 | +*/ |
| 248881 | +static void fts5TokendataIterDelete(Fts5TokenDataIter *pSet){ |
| 248882 | + if( pSet ){ |
| 248883 | + int ii; |
| 248884 | + for(ii=0; ii<pSet->nIter; ii++){ |
| 248885 | + fts5MultiIterFree(pSet->apIter[ii]); |
| 248886 | + } |
| 248887 | + fts5BufferFree(&pSet->terms); |
| 248888 | + sqlite3_free(pSet->aPoslistReader); |
| 248889 | + sqlite3_free(pSet->aMap); |
| 248890 | + sqlite3_free(pSet); |
| 248891 | + } |
| 248892 | +} |
| 248893 | + |
| 248894 | + |
| 248895 | +/* |
| 248896 | +** fts5VisitEntries() context object used by fts5SetupPrefixIterTokendata() |
| 248897 | +** to pass data to prefixIterSetupTokendataCb(). |
| 248898 | +*/ |
| 248899 | +typedef struct TokendataSetupCtx TokendataSetupCtx; |
| 248900 | +struct TokendataSetupCtx { |
| 248901 | + Fts5TokenDataIter *pT; /* Object being populated with mappings */ |
| 248902 | + int iTermOff; /* Offset of current term in terms.p[] */ |
| 248903 | + int nTermByte; /* Size of current term in bytes */ |
| 248904 | +}; |
| 248905 | + |
| 248906 | +/* |
| 248907 | +** fts5VisitEntries() callback used by fts5SetupPrefixIterTokendata(). This |
| 248908 | +** callback adds an entry to the Fts5TokenDataIter.aMap[] array for each |
| 248909 | +** position in the current position-list. It doesn't matter that some of |
| 248910 | +** these may be out of order - they will be sorted later. |
| 248911 | +*/ |
| 248912 | +static void prefixIterSetupTokendataCb( |
| 248913 | + Fts5Index *p, |
| 248914 | + void *pCtx, |
| 248915 | + Fts5Iter *p1, |
| 248916 | + const u8 *pNew, |
| 248917 | + int nNew |
| 248918 | +){ |
| 248919 | + TokendataSetupCtx *pSetup = (TokendataSetupCtx*)pCtx; |
| 248920 | + int iPosOff = 0; |
| 248921 | + i64 iPos = 0; |
| 248922 | + |
| 248923 | + if( pNew ){ |
| 248924 | + pSetup->nTermByte = nNew-1; |
| 248925 | + pSetup->iTermOff = pSetup->pT->terms.n; |
| 248926 | + fts5BufferAppendBlob(&p->rc, &pSetup->pT->terms, nNew-1, pNew+1); |
| 248927 | + } |
| 248928 | + |
| 248929 | + while( 0==sqlite3Fts5PoslistNext64( |
| 248930 | + p1->base.pData, p1->base.nData, &iPosOff, &iPos |
| 248931 | + ) ){ |
| 248932 | + fts5TokendataIterAppendMap(p, |
| 248933 | + pSetup->pT, pSetup->iTermOff, pSetup->nTermByte, p1->base.iRowid, iPos |
| 248934 | + ); |
| 248935 | + } |
| 248936 | +} |
| 248937 | + |
| 248938 | + |
| 248939 | +/* |
| 248940 | +** Context object passed by fts5SetupPrefixIter() to fts5VisitEntries(). |
| 248941 | +*/ |
| 248942 | +typedef struct PrefixSetupCtx PrefixSetupCtx; |
| 248943 | +struct PrefixSetupCtx { |
| 248944 | + void (*xMerge)(Fts5Index*, Fts5Buffer*, int, Fts5Buffer*); |
| 248945 | + void (*xAppend)(Fts5Index*, u64, Fts5Iter*, Fts5Buffer*); |
| 248946 | + i64 iLastRowid; |
| 248947 | + int nMerge; |
| 248948 | + Fts5Buffer *aBuf; |
| 248949 | + int nBuf; |
| 248950 | + Fts5Buffer doclist; |
| 248951 | + TokendataSetupCtx *pTokendata; |
| 248952 | +}; |
| 248953 | + |
| 248954 | +/* |
| 248955 | +** fts5VisitEntries() callback used by fts5SetupPrefixIter() |
| 248956 | +*/ |
| 248957 | +static void prefixIterSetupCb( |
| 248958 | + Fts5Index *p, |
| 248959 | + void *pCtx, |
| 248960 | + Fts5Iter *p1, |
| 248961 | + const u8 *pNew, |
| 248962 | + int nNew |
| 248963 | +){ |
| 248964 | + PrefixSetupCtx *pSetup = (PrefixSetupCtx*)pCtx; |
| 248965 | + const int nMerge = pSetup->nMerge; |
| 248966 | + |
| 248967 | + if( p1->base.nData>0 ){ |
| 248968 | + if( p1->base.iRowid<=pSetup->iLastRowid && pSetup->doclist.n>0 ){ |
| 248969 | + int i; |
| 248970 | + for(i=0; p->rc==SQLITE_OK && pSetup->doclist.n; i++){ |
| 248971 | + int i1 = i*nMerge; |
| 248972 | + int iStore; |
| 248973 | + assert( i1+nMerge<=pSetup->nBuf ); |
| 248974 | + for(iStore=i1; iStore<i1+nMerge; iStore++){ |
| 248975 | + if( pSetup->aBuf[iStore].n==0 ){ |
| 248976 | + fts5BufferSwap(&pSetup->doclist, &pSetup->aBuf[iStore]); |
| 248977 | + fts5BufferZero(&pSetup->doclist); |
| 248978 | + break; |
| 248979 | + } |
| 248980 | + } |
| 248981 | + if( iStore==i1+nMerge ){ |
| 248982 | + pSetup->xMerge(p, &pSetup->doclist, nMerge, &pSetup->aBuf[i1]); |
| 248983 | + for(iStore=i1; iStore<i1+nMerge; iStore++){ |
| 248984 | + fts5BufferZero(&pSetup->aBuf[iStore]); |
| 248985 | + } |
| 248986 | + } |
| 248987 | + } |
| 248988 | + pSetup->iLastRowid = 0; |
| 248989 | + } |
| 248990 | + |
| 248991 | + pSetup->xAppend( |
| 248992 | + p, (u64)p1->base.iRowid-(u64)pSetup->iLastRowid, p1, &pSetup->doclist |
| 248993 | + ); |
| 248994 | + pSetup->iLastRowid = p1->base.iRowid; |
| 248995 | + } |
| 248996 | + |
| 248997 | + if( pSetup->pTokendata ){ |
| 248998 | + prefixIterSetupTokendataCb(p, (void*)pSetup->pTokendata, p1, pNew, nNew); |
| 248999 | + } |
| 249000 | +} |
| 249001 | + |
| 249273 | 249002 | static void fts5SetupPrefixIter( |
| 249274 | 249003 | Fts5Index *p, /* Index to read from */ |
| 249275 | 249004 | int bDesc, /* True for "ORDER BY rowid DESC" */ |
| 249276 | 249005 | int iIdx, /* Index to scan for data */ |
| 249277 | 249006 | u8 *pToken, /* Buffer containing prefix to match */ |
| | @@ -249278,137 +249007,89 @@ |
| 249278 | 249007 | int nToken, /* Size of buffer pToken in bytes */ |
| 249279 | 249008 | Fts5Colset *pColset, /* Restrict matches to these columns */ |
| 249280 | 249009 | Fts5Iter **ppIter /* OUT: New iterator */ |
| 249281 | 249010 | ){ |
| 249282 | 249011 | Fts5Structure *pStruct; |
| 249283 | | - Fts5Buffer *aBuf; |
| 249284 | | - int nBuf = 32; |
| 249285 | | - int nMerge = 1; |
| 249012 | + PrefixSetupCtx s; |
| 249013 | + TokendataSetupCtx s2; |
| 249286 | 249014 | |
| 249287 | | - void (*xMerge)(Fts5Index*, Fts5Buffer*, int, Fts5Buffer*); |
| 249288 | | - void (*xAppend)(Fts5Index*, u64, Fts5Iter*, Fts5Buffer*); |
| 249015 | + memset(&s, 0, sizeof(s)); |
| 249016 | + memset(&s2, 0, sizeof(s2)); |
| 249017 | + |
| 249018 | + s.nMerge = 1; |
| 249019 | + s.iLastRowid = 0; |
| 249020 | + s.nBuf = 32; |
| 249021 | + if( iIdx==0 |
| 249022 | + && p->pConfig->eDetail==FTS5_DETAIL_FULL |
| 249023 | + && p->pConfig->bPrefixInsttoken |
| 249024 | + ){ |
| 249025 | + s.pTokendata = &s2; |
| 249026 | + s2.pT = (Fts5TokenDataIter*)fts5IdxMalloc(p, sizeof(*s2.pT)); |
| 249027 | + } |
| 249028 | + |
| 249289 | 249029 | if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ |
| 249290 | | - xMerge = fts5MergeRowidLists; |
| 249291 | | - xAppend = fts5AppendRowid; |
| 249030 | + s.xMerge = fts5MergeRowidLists; |
| 249031 | + s.xAppend = fts5AppendRowid; |
| 249292 | 249032 | }else{ |
| 249293 | | - nMerge = FTS5_MERGE_NLIST-1; |
| 249294 | | - nBuf = nMerge*8; /* Sufficient to merge (16^8)==(2^32) lists */ |
| 249295 | | - xMerge = fts5MergePrefixLists; |
| 249296 | | - xAppend = fts5AppendPoslist; |
| 249033 | + s.nMerge = FTS5_MERGE_NLIST-1; |
| 249034 | + s.nBuf = s.nMerge*8; /* Sufficient to merge (16^8)==(2^32) lists */ |
| 249035 | + s.xMerge = fts5MergePrefixLists; |
| 249036 | + s.xAppend = fts5AppendPoslist; |
| 249297 | 249037 | } |
| 249298 | 249038 | |
| 249299 | | - aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf); |
| 249039 | + s.aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*s.nBuf); |
| 249300 | 249040 | pStruct = fts5StructureRead(p); |
| 249301 | | - assert( p->rc!=SQLITE_OK || (aBuf && pStruct) ); |
| 249041 | + assert( p->rc!=SQLITE_OK || (s.aBuf && pStruct) ); |
| 249302 | 249042 | |
| 249303 | 249043 | if( p->rc==SQLITE_OK ){ |
| 249304 | | - const int flags = FTS5INDEX_QUERY_SCAN |
| 249305 | | - | FTS5INDEX_QUERY_SKIPEMPTY |
| 249306 | | - | FTS5INDEX_QUERY_NOOUTPUT; |
| 249044 | + void *pCtx = (void*)&s; |
| 249307 | 249045 | int i; |
| 249308 | | - i64 iLastRowid = 0; |
| 249309 | | - Fts5Iter *p1 = 0; /* Iterator used to gather data from index */ |
| 249310 | 249046 | Fts5Data *pData; |
| 249311 | | - Fts5Buffer doclist; |
| 249312 | | - int bNewTerm = 1; |
| 249313 | | - |
| 249314 | | - memset(&doclist, 0, sizeof(doclist)); |
| 249315 | 249047 | |
| 249316 | 249048 | /* If iIdx is non-zero, then it is the number of a prefix-index for |
| 249317 | 249049 | ** prefixes 1 character longer than the prefix being queried for. That |
| 249318 | 249050 | ** index contains all the doclists required, except for the one |
| 249319 | 249051 | ** corresponding to the prefix itself. That one is extracted from the |
| 249320 | 249052 | ** main term index here. */ |
| 249321 | 249053 | if( iIdx!=0 ){ |
| 249322 | | - int dummy = 0; |
| 249323 | | - const int f2 = FTS5INDEX_QUERY_SKIPEMPTY|FTS5INDEX_QUERY_NOOUTPUT; |
| 249324 | 249054 | pToken[0] = FTS5_MAIN_PREFIX; |
| 249325 | | - fts5MultiIterNew(p, pStruct, f2, pColset, pToken, nToken, -1, 0, &p1); |
| 249326 | | - fts5IterSetOutputCb(&p->rc, p1); |
| 249327 | | - for(; |
| 249328 | | - fts5MultiIterEof(p, p1)==0; |
| 249329 | | - fts5MultiIterNext2(p, p1, &dummy) |
| 249330 | | - ){ |
| 249331 | | - Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ]; |
| 249332 | | - p1->xSetOutputs(p1, pSeg); |
| 249333 | | - if( p1->base.nData ){ |
| 249334 | | - xAppend(p, (u64)p1->base.iRowid-(u64)iLastRowid, p1, &doclist); |
| 249335 | | - iLastRowid = p1->base.iRowid; |
| 249336 | | - } |
| 249337 | | - } |
| 249338 | | - fts5MultiIterFree(p1); |
| 249055 | + fts5VisitEntries(p, pColset, pToken, nToken, 0, prefixIterSetupCb, pCtx); |
| 249339 | 249056 | } |
| 249340 | 249057 | |
| 249341 | 249058 | pToken[0] = FTS5_MAIN_PREFIX + iIdx; |
| 249342 | | - fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1); |
| 249343 | | - fts5IterSetOutputCb(&p->rc, p1); |
| 249344 | | - |
| 249345 | | - for( /* no-op */ ; |
| 249346 | | - fts5MultiIterEof(p, p1)==0; |
| 249347 | | - fts5MultiIterNext2(p, p1, &bNewTerm) |
| 249348 | | - ){ |
| 249349 | | - Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ]; |
| 249350 | | - int nTerm = pSeg->term.n; |
| 249351 | | - const u8 *pTerm = pSeg->term.p; |
| 249352 | | - p1->xSetOutputs(p1, pSeg); |
| 249353 | | - |
| 249354 | | - assert_nc( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 ); |
| 249355 | | - if( bNewTerm ){ |
| 249356 | | - if( nTerm<nToken || memcmp(pToken, pTerm, nToken) ) break; |
| 249357 | | - } |
| 249358 | | - |
| 249359 | | - if( p1->base.nData==0 ) continue; |
| 249360 | | - if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){ |
| 249361 | | - for(i=0; p->rc==SQLITE_OK && doclist.n; i++){ |
| 249362 | | - int i1 = i*nMerge; |
| 249363 | | - int iStore; |
| 249364 | | - assert( i1+nMerge<=nBuf ); |
| 249365 | | - for(iStore=i1; iStore<i1+nMerge; iStore++){ |
| 249366 | | - if( aBuf[iStore].n==0 ){ |
| 249367 | | - fts5BufferSwap(&doclist, &aBuf[iStore]); |
| 249368 | | - fts5BufferZero(&doclist); |
| 249369 | | - break; |
| 249370 | | - } |
| 249371 | | - } |
| 249372 | | - if( iStore==i1+nMerge ){ |
| 249373 | | - xMerge(p, &doclist, nMerge, &aBuf[i1]); |
| 249374 | | - for(iStore=i1; iStore<i1+nMerge; iStore++){ |
| 249375 | | - fts5BufferZero(&aBuf[iStore]); |
| 249376 | | - } |
| 249377 | | - } |
| 249378 | | - } |
| 249379 | | - iLastRowid = 0; |
| 249380 | | - } |
| 249381 | | - |
| 249382 | | - xAppend(p, (u64)p1->base.iRowid-(u64)iLastRowid, p1, &doclist); |
| 249383 | | - iLastRowid = p1->base.iRowid; |
| 249384 | | - } |
| 249385 | | - |
| 249386 | | - assert( (nBuf%nMerge)==0 ); |
| 249387 | | - for(i=0; i<nBuf; i+=nMerge){ |
| 249059 | + fts5VisitEntries(p, pColset, pToken, nToken, 1, prefixIterSetupCb, pCtx); |
| 249060 | + |
| 249061 | + assert( (s.nBuf%s.nMerge)==0 ); |
| 249062 | + for(i=0; i<s.nBuf; i+=s.nMerge){ |
| 249388 | 249063 | int iFree; |
| 249389 | 249064 | if( p->rc==SQLITE_OK ){ |
| 249390 | | - xMerge(p, &doclist, nMerge, &aBuf[i]); |
| 249065 | + s.xMerge(p, &s.doclist, s.nMerge, &s.aBuf[i]); |
| 249391 | 249066 | } |
| 249392 | | - for(iFree=i; iFree<i+nMerge; iFree++){ |
| 249393 | | - fts5BufferFree(&aBuf[iFree]); |
| 249067 | + for(iFree=i; iFree<i+s.nMerge; iFree++){ |
| 249068 | + fts5BufferFree(&s.aBuf[iFree]); |
| 249394 | 249069 | } |
| 249395 | 249070 | } |
| 249396 | | - fts5MultiIterFree(p1); |
| 249397 | 249071 | |
| 249398 | | - pData = fts5IdxMalloc(p, sizeof(*pData)+doclist.n+FTS5_DATA_ZERO_PADDING); |
| 249072 | + pData = fts5IdxMalloc(p, sizeof(*pData)+s.doclist.n+FTS5_DATA_ZERO_PADDING); |
| 249399 | 249073 | if( pData ){ |
| 249400 | 249074 | pData->p = (u8*)&pData[1]; |
| 249401 | | - pData->nn = pData->szLeaf = doclist.n; |
| 249402 | | - if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n); |
| 249075 | + pData->nn = pData->szLeaf = s.doclist.n; |
| 249076 | + if( s.doclist.n ) memcpy(pData->p, s.doclist.p, s.doclist.n); |
| 249403 | 249077 | fts5MultiIterNew2(p, pData, bDesc, ppIter); |
| 249404 | 249078 | } |
| 249405 | | - fts5BufferFree(&doclist); |
| 249079 | + |
| 249080 | + if( p->rc==SQLITE_OK && s.pTokendata ){ |
| 249081 | + fts5TokendataIterSortMap(p, s2.pT); |
| 249082 | + (*ppIter)->pTokenDataIter = s2.pT; |
| 249083 | + s2.pT = 0; |
| 249084 | + } |
| 249406 | 249085 | } |
| 249407 | 249086 | |
| 249087 | + fts5TokendataIterDelete(s2.pT); |
| 249088 | + fts5BufferFree(&s.doclist); |
| 249408 | 249089 | fts5StructureRelease(pStruct); |
| 249409 | | - sqlite3_free(aBuf); |
| 249090 | + sqlite3_free(s.aBuf); |
| 249410 | 249091 | } |
| 249411 | 249092 | |
| 249412 | 249093 | |
| 249413 | 249094 | /* |
| 249414 | 249095 | ** Indicate that all subsequent calls to sqlite3Fts5IndexWrite() pertain |
| | @@ -249658,42 +249339,10 @@ |
| 249658 | 249339 | static void fts5SegIterSetEOF(Fts5SegIter *pSeg){ |
| 249659 | 249340 | fts5DataRelease(pSeg->pLeaf); |
| 249660 | 249341 | pSeg->pLeaf = 0; |
| 249661 | 249342 | } |
| 249662 | 249343 | |
| 249663 | | -/* |
| 249664 | | -** Usually, a tokendata=1 iterator (struct Fts5TokenDataIter) accumulates an |
| 249665 | | -** array of these for each row it visits. Or, for an iterator used by an |
| 249666 | | -** "ORDER BY rank" query, it accumulates an array of these for the entire |
| 249667 | | -** query. |
| 249668 | | -** |
| 249669 | | -** Each instance in the array indicates the iterator (and therefore term) |
| 249670 | | -** associated with position iPos of rowid iRowid. This is used by the |
| 249671 | | -** xInstToken() API. |
| 249672 | | -*/ |
| 249673 | | -struct Fts5TokenDataMap { |
| 249674 | | - i64 iRowid; /* Row this token is located in */ |
| 249675 | | - i64 iPos; /* Position of token */ |
| 249676 | | - int iIter; /* Iterator token was read from */ |
| 249677 | | -}; |
| 249678 | | - |
| 249679 | | -/* |
| 249680 | | -** An object used to supplement Fts5Iter for tokendata=1 iterators. |
| 249681 | | -*/ |
| 249682 | | -struct Fts5TokenDataIter { |
| 249683 | | - int nIter; |
| 249684 | | - int nIterAlloc; |
| 249685 | | - |
| 249686 | | - int nMap; |
| 249687 | | - int nMapAlloc; |
| 249688 | | - Fts5TokenDataMap *aMap; |
| 249689 | | - |
| 249690 | | - Fts5PoslistReader *aPoslistReader; |
| 249691 | | - int *aPoslistToIter; |
| 249692 | | - Fts5Iter *apIter[1]; |
| 249693 | | -}; |
| 249694 | | - |
| 249695 | 249344 | /* |
| 249696 | 249345 | ** This function appends iterator pAppend to Fts5TokenDataIter pIn and |
| 249697 | 249346 | ** returns the result. |
| 249698 | 249347 | */ |
| 249699 | 249348 | static Fts5TokenDataIter *fts5AppendTokendataIter( |
| | @@ -249726,58 +249375,10 @@ |
| 249726 | 249375 | assert( pRet==0 || pRet->nIter<=pRet->nIterAlloc ); |
| 249727 | 249376 | |
| 249728 | 249377 | return pRet; |
| 249729 | 249378 | } |
| 249730 | 249379 | |
| 249731 | | -/* |
| 249732 | | -** Delete an Fts5TokenDataIter structure and its contents. |
| 249733 | | -*/ |
| 249734 | | -static void fts5TokendataIterDelete(Fts5TokenDataIter *pSet){ |
| 249735 | | - if( pSet ){ |
| 249736 | | - int ii; |
| 249737 | | - for(ii=0; ii<pSet->nIter; ii++){ |
| 249738 | | - fts5MultiIterFree(pSet->apIter[ii]); |
| 249739 | | - } |
| 249740 | | - sqlite3_free(pSet->aPoslistReader); |
| 249741 | | - sqlite3_free(pSet->aMap); |
| 249742 | | - sqlite3_free(pSet); |
| 249743 | | - } |
| 249744 | | -} |
| 249745 | | - |
| 249746 | | -/* |
| 249747 | | -** Append a mapping to the token-map belonging to object pT. |
| 249748 | | -*/ |
| 249749 | | -static void fts5TokendataIterAppendMap( |
| 249750 | | - Fts5Index *p, |
| 249751 | | - Fts5TokenDataIter *pT, |
| 249752 | | - int iIter, |
| 249753 | | - i64 iRowid, |
| 249754 | | - i64 iPos |
| 249755 | | -){ |
| 249756 | | - if( p->rc==SQLITE_OK ){ |
| 249757 | | - if( pT->nMap==pT->nMapAlloc ){ |
| 249758 | | - int nNew = pT->nMapAlloc ? pT->nMapAlloc*2 : 64; |
| 249759 | | - int nByte = nNew * sizeof(Fts5TokenDataMap); |
| 249760 | | - Fts5TokenDataMap *aNew; |
| 249761 | | - |
| 249762 | | - aNew = (Fts5TokenDataMap*)sqlite3_realloc(pT->aMap, nByte); |
| 249763 | | - if( aNew==0 ){ |
| 249764 | | - p->rc = SQLITE_NOMEM; |
| 249765 | | - return; |
| 249766 | | - } |
| 249767 | | - |
| 249768 | | - pT->aMap = aNew; |
| 249769 | | - pT->nMapAlloc = nNew; |
| 249770 | | - } |
| 249771 | | - |
| 249772 | | - pT->aMap[pT->nMap].iRowid = iRowid; |
| 249773 | | - pT->aMap[pT->nMap].iPos = iPos; |
| 249774 | | - pT->aMap[pT->nMap].iIter = iIter; |
| 249775 | | - pT->nMap++; |
| 249776 | | - } |
| 249777 | | -} |
| 249778 | | - |
| 249779 | 249380 | /* |
| 249780 | 249381 | ** The iterator passed as the only argument must be a tokendata=1 iterator |
| 249781 | 249382 | ** (pIter->pTokenDataIter!=0). This function sets the iterator output |
| 249782 | 249383 | ** variables (pIter->base.*) according to the contents of the current |
| 249783 | 249384 | ** row. |
| | @@ -249814,11 +249415,11 @@ |
| 249814 | 249415 | int eDetail = pIter->pIndex->pConfig->eDetail; |
| 249815 | 249416 | pIter->base.bEof = 0; |
| 249816 | 249417 | pIter->base.iRowid = iRowid; |
| 249817 | 249418 | |
| 249818 | 249419 | if( nHit==1 && eDetail==FTS5_DETAIL_FULL ){ |
| 249819 | | - fts5TokendataIterAppendMap(pIter->pIndex, pT, iMin, iRowid, -1); |
| 249420 | + fts5TokendataIterAppendMap(pIter->pIndex, pT, iMin, 0, iRowid, -1); |
| 249820 | 249421 | }else |
| 249821 | 249422 | if( nHit>1 && eDetail!=FTS5_DETAIL_NONE ){ |
| 249822 | 249423 | int nReader = 0; |
| 249823 | 249424 | int nByte = 0; |
| 249824 | 249425 | i64 iPrev = 0; |
| | @@ -250067,10 +249668,11 @@ |
| 250067 | 249668 | |
| 250068 | 249669 | if( p->rc==SQLITE_OK ){ |
| 250069 | 249670 | pRet = fts5MultiIterAlloc(p, 0); |
| 250070 | 249671 | } |
| 250071 | 249672 | if( pRet ){ |
| 249673 | + pRet->nSeg = 0; |
| 250072 | 249674 | pRet->pTokenDataIter = pSet; |
| 250073 | 249675 | if( pSet ){ |
| 250074 | 249676 | fts5IterSetOutputsTokendata(pRet); |
| 250075 | 249677 | }else{ |
| 250076 | 249678 | pRet->base.bEof = 1; |
| | @@ -250081,11 +249683,10 @@ |
| 250081 | 249683 | |
| 250082 | 249684 | fts5StructureRelease(pStruct); |
| 250083 | 249685 | fts5BufferFree(&bSeek); |
| 250084 | 249686 | return pRet; |
| 250085 | 249687 | } |
| 250086 | | - |
| 250087 | 249688 | |
| 250088 | 249689 | /* |
| 250089 | 249690 | ** Open a new iterator to iterate though all rowid that match the |
| 250090 | 249691 | ** specified token or token prefix. |
| 250091 | 249692 | */ |
| | @@ -250107,10 +249708,15 @@ |
| 250107 | 249708 | int iIdx = 0; /* Index to search */ |
| 250108 | 249709 | int iPrefixIdx = 0; /* +1 prefix index */ |
| 250109 | 249710 | int bTokendata = pConfig->bTokendata; |
| 250110 | 249711 | if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken); |
| 250111 | 249712 | |
| 249713 | + /* The NOTOKENDATA flag is set when each token in a tokendata=1 table |
| 249714 | + ** should be treated individually, instead of merging all those with |
| 249715 | + ** a common prefix into a single entry. This is used, for example, by |
| 249716 | + ** queries performed as part of an integrity-check, or by the fts5vocab |
| 249717 | + ** module. */ |
| 250112 | 249718 | if( flags & (FTS5INDEX_QUERY_NOTOKENDATA|FTS5INDEX_QUERY_SCAN) ){ |
| 250113 | 249719 | bTokendata = 0; |
| 250114 | 249720 | } |
| 250115 | 249721 | |
| 250116 | 249722 | /* Figure out which index to search and set iIdx accordingly. If this |
| | @@ -250137,11 +249743,11 @@ |
| 250137 | 249743 | if( nIdxChar==nChar+1 ) iPrefixIdx = iIdx; |
| 250138 | 249744 | } |
| 250139 | 249745 | } |
| 250140 | 249746 | |
| 250141 | 249747 | if( bTokendata && iIdx==0 ){ |
| 250142 | | - buf.p[0] = '0'; |
| 249748 | + buf.p[0] = FTS5_MAIN_PREFIX; |
| 250143 | 249749 | pRet = fts5SetupTokendataIter(p, buf.p, nToken+1, pColset); |
| 250144 | 249750 | }else if( iIdx<=pConfig->nPrefix ){ |
| 250145 | 249751 | /* Straight index lookup */ |
| 250146 | 249752 | Fts5Structure *pStruct = fts5StructureRead(p); |
| 250147 | 249753 | buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx); |
| | @@ -250150,11 +249756,11 @@ |
| 250150 | 249756 | pColset, buf.p, nToken+1, -1, 0, &pRet |
| 250151 | 249757 | ); |
| 250152 | 249758 | fts5StructureRelease(pStruct); |
| 250153 | 249759 | } |
| 250154 | 249760 | }else{ |
| 250155 | | - /* Scan multiple terms in the main index */ |
| 249761 | + /* Scan multiple terms in the main index for a prefix query. */ |
| 250156 | 249762 | int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0; |
| 250157 | 249763 | fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet); |
| 250158 | 249764 | if( pRet==0 ){ |
| 250159 | 249765 | assert( p->rc!=SQLITE_OK ); |
| 250160 | 249766 | }else{ |
| | @@ -250186,11 +249792,12 @@ |
| 250186 | 249792 | ** Move to the next matching rowid. |
| 250187 | 249793 | */ |
| 250188 | 249794 | static int sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){ |
| 250189 | 249795 | Fts5Iter *pIter = (Fts5Iter*)pIndexIter; |
| 250190 | 249796 | assert( pIter->pIndex->rc==SQLITE_OK ); |
| 250191 | | - if( pIter->pTokenDataIter ){ |
| 249797 | + if( pIter->nSeg==0 ){ |
| 249798 | + assert( pIter->pTokenDataIter ); |
| 250192 | 249799 | fts5TokendataIterNext(pIter, 0, 0); |
| 250193 | 249800 | }else{ |
| 250194 | 249801 | fts5MultiIterNext(pIter->pIndex, pIter, 0, 0); |
| 250195 | 249802 | } |
| 250196 | 249803 | return fts5IndexReturn(pIter->pIndex); |
| | @@ -250223,11 +249830,12 @@ |
| 250223 | 249830 | ** definition of "at or after" depends on whether this iterator iterates |
| 250224 | 249831 | ** in ascending or descending rowid order. |
| 250225 | 249832 | */ |
| 250226 | 249833 | static int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){ |
| 250227 | 249834 | Fts5Iter *pIter = (Fts5Iter*)pIndexIter; |
| 250228 | | - if( pIter->pTokenDataIter ){ |
| 249835 | + if( pIter->nSeg==0 ){ |
| 249836 | + assert( pIter->pTokenDataIter ); |
| 250229 | 249837 | fts5TokendataIterNext(pIter, 1, iMatch); |
| 250230 | 249838 | }else{ |
| 250231 | 249839 | fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch); |
| 250232 | 249840 | } |
| 250233 | 249841 | return fts5IndexReturn(pIter->pIndex); |
| | @@ -250241,32 +249849,87 @@ |
| 250241 | 249849 | const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n); |
| 250242 | 249850 | assert_nc( z || n<=1 ); |
| 250243 | 249851 | *pn = n-1; |
| 250244 | 249852 | return (z ? &z[1] : 0); |
| 250245 | 249853 | } |
| 249854 | + |
| 249855 | +/* |
| 249856 | +** pIter is a prefix query. This function populates pIter->pTokenDataIter |
| 249857 | +** with an Fts5TokenDataIter object containing mappings for all rows |
| 249858 | +** matched by the query. |
| 249859 | +*/ |
| 249860 | +static int fts5SetupPrefixIterTokendata( |
| 249861 | + Fts5Iter *pIter, |
| 249862 | + const char *pToken, /* Token prefix to search for */ |
| 249863 | + int nToken /* Size of pToken in bytes */ |
| 249864 | +){ |
| 249865 | + Fts5Index *p = pIter->pIndex; |
| 249866 | + Fts5Buffer token = {0, 0, 0}; |
| 249867 | + TokendataSetupCtx ctx; |
| 249868 | + |
| 249869 | + memset(&ctx, 0, sizeof(ctx)); |
| 249870 | + |
| 249871 | + fts5BufferGrow(&p->rc, &token, nToken+1); |
| 249872 | + ctx.pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*ctx.pT)); |
| 249873 | + |
| 249874 | + if( p->rc==SQLITE_OK ){ |
| 249875 | + |
| 249876 | + /* Fill in the token prefix to search for */ |
| 249877 | + token.p[0] = FTS5_MAIN_PREFIX; |
| 249878 | + memcpy(&token.p[1], pToken, nToken); |
| 249879 | + token.n = nToken+1; |
| 249880 | + |
| 249881 | + fts5VisitEntries( |
| 249882 | + p, 0, token.p, token.n, 1, prefixIterSetupTokendataCb, (void*)&ctx |
| 249883 | + ); |
| 249884 | + |
| 249885 | + fts5TokendataIterSortMap(p, ctx.pT); |
| 249886 | + } |
| 249887 | + |
| 249888 | + if( p->rc==SQLITE_OK ){ |
| 249889 | + pIter->pTokenDataIter = ctx.pT; |
| 249890 | + }else{ |
| 249891 | + fts5TokendataIterDelete(ctx.pT); |
| 249892 | + } |
| 249893 | + fts5BufferFree(&token); |
| 249894 | + |
| 249895 | + return fts5IndexReturn(p); |
| 249896 | +} |
| 250246 | 249897 | |
| 250247 | 249898 | /* |
| 250248 | 249899 | ** This is used by xInstToken() to access the token at offset iOff, column |
| 250249 | 249900 | ** iCol of row iRowid. The token is returned via output variables *ppOut |
| 250250 | 249901 | ** and *pnOut. The iterator passed as the first argument must be a tokendata=1 |
| 250251 | 249902 | ** iterator (pIter->pTokenDataIter!=0). |
| 249903 | +** |
| 249904 | +** pToken/nToken: |
| 250252 | 249905 | */ |
| 250253 | 249906 | static int sqlite3Fts5IterToken( |
| 250254 | 249907 | Fts5IndexIter *pIndexIter, |
| 249908 | + const char *pToken, int nToken, |
| 250255 | 249909 | i64 iRowid, |
| 250256 | 249910 | int iCol, |
| 250257 | 249911 | int iOff, |
| 250258 | 249912 | const char **ppOut, int *pnOut |
| 250259 | 249913 | ){ |
| 250260 | 249914 | Fts5Iter *pIter = (Fts5Iter*)pIndexIter; |
| 250261 | 249915 | Fts5TokenDataIter *pT = pIter->pTokenDataIter; |
| 250262 | | - Fts5TokenDataMap *aMap = pT->aMap; |
| 250263 | 249916 | i64 iPos = (((i64)iCol)<<32) + iOff; |
| 250264 | | - |
| 249917 | + Fts5TokenDataMap *aMap = 0; |
| 250265 | 249918 | int i1 = 0; |
| 250266 | | - int i2 = pT->nMap; |
| 249919 | + int i2 = 0; |
| 250267 | 249920 | int iTest = 0; |
| 249921 | + |
| 249922 | + assert( pT || (pToken && pIter->nSeg>0) ); |
| 249923 | + if( pT==0 ){ |
| 249924 | + int rc = fts5SetupPrefixIterTokendata(pIter, pToken, nToken); |
| 249925 | + if( rc!=SQLITE_OK ) return rc; |
| 249926 | + pT = pIter->pTokenDataIter; |
| 249927 | + } |
| 249928 | + |
| 249929 | + i2 = pT->nMap; |
| 249930 | + aMap = pT->aMap; |
| 250268 | 249931 | |
| 250269 | 249932 | while( i2>i1 ){ |
| 250270 | 249933 | iTest = (i1 + i2) / 2; |
| 250271 | 249934 | |
| 250272 | 249935 | if( aMap[iTest].iRowid<iRowid ){ |
| | @@ -250286,13 +249949,19 @@ |
| 250286 | 249949 | } |
| 250287 | 249950 | } |
| 250288 | 249951 | } |
| 250289 | 249952 | |
| 250290 | 249953 | if( i2>i1 ){ |
| 250291 | | - Fts5Iter *pMap = pT->apIter[aMap[iTest].iIter]; |
| 250292 | | - *ppOut = (const char*)pMap->aSeg[0].term.p+1; |
| 250293 | | - *pnOut = pMap->aSeg[0].term.n-1; |
| 249954 | + if( pIter->nSeg==0 ){ |
| 249955 | + Fts5Iter *pMap = pT->apIter[aMap[iTest].iIter]; |
| 249956 | + *ppOut = (const char*)pMap->aSeg[0].term.p+1; |
| 249957 | + *pnOut = pMap->aSeg[0].term.n-1; |
| 249958 | + }else{ |
| 249959 | + Fts5TokenDataMap *p = &aMap[iTest]; |
| 249960 | + *ppOut = (const char*)&pT->terms.p[p->iIter]; |
| 249961 | + *pnOut = aMap[iTest].nByte; |
| 249962 | + } |
| 250294 | 249963 | } |
| 250295 | 249964 | |
| 250296 | 249965 | return SQLITE_OK; |
| 250297 | 249966 | } |
| 250298 | 249967 | |
| | @@ -250300,11 +249969,13 @@ |
| 250300 | 249969 | ** Clear any existing entries from the token-map associated with the |
| 250301 | 249970 | ** iterator passed as the only argument. |
| 250302 | 249971 | */ |
| 250303 | 249972 | static void sqlite3Fts5IndexIterClearTokendata(Fts5IndexIter *pIndexIter){ |
| 250304 | 249973 | Fts5Iter *pIter = (Fts5Iter*)pIndexIter; |
| 250305 | | - if( pIter && pIter->pTokenDataIter ){ |
| 249974 | + if( pIter && pIter->pTokenDataIter |
| 249975 | + && (pIter->nSeg==0 || pIter->pIndex->pConfig->eDetail!=FTS5_DETAIL_FULL) |
| 249976 | + ){ |
| 250306 | 249977 | pIter->pTokenDataIter->nMap = 0; |
| 250307 | 249978 | } |
| 250308 | 249979 | } |
| 250309 | 249980 | |
| 250310 | 249981 | /* |
| | @@ -250320,21 +249991,33 @@ |
| 250320 | 249991 | i64 iRowid, int iCol, int iOff |
| 250321 | 249992 | ){ |
| 250322 | 249993 | Fts5Iter *pIter = (Fts5Iter*)pIndexIter; |
| 250323 | 249994 | Fts5TokenDataIter *pT = pIter->pTokenDataIter; |
| 250324 | 249995 | Fts5Index *p = pIter->pIndex; |
| 250325 | | - int ii; |
| 249996 | + i64 iPos = (((i64)iCol)<<32) + iOff; |
| 250326 | 249997 | |
| 250327 | 249998 | assert( p->pConfig->eDetail!=FTS5_DETAIL_FULL ); |
| 250328 | | - assert( pIter->pTokenDataIter ); |
| 250329 | | - |
| 250330 | | - for(ii=0; ii<pT->nIter; ii++){ |
| 250331 | | - Fts5Buffer *pTerm = &pT->apIter[ii]->aSeg[0].term; |
| 250332 | | - if( nToken==pTerm->n-1 && memcmp(pToken, pTerm->p+1, nToken)==0 ) break; |
| 250333 | | - } |
| 250334 | | - if( ii<pT->nIter ){ |
| 250335 | | - fts5TokendataIterAppendMap(p, pT, ii, iRowid, (((i64)iCol)<<32) + iOff); |
| 249999 | + assert( pIter->pTokenDataIter || pIter->nSeg>0 ); |
| 250000 | + if( pIter->nSeg>0 ){ |
| 250001 | + /* This is a prefix term iterator. */ |
| 250002 | + if( pT==0 ){ |
| 250003 | + pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*pT)); |
| 250004 | + pIter->pTokenDataIter = pT; |
| 250005 | + } |
| 250006 | + if( pT ){ |
| 250007 | + fts5TokendataIterAppendMap(p, pT, pT->terms.n, nToken, iRowid, iPos); |
| 250008 | + fts5BufferAppendBlob(&p->rc, &pT->terms, nToken, (const u8*)pToken); |
| 250009 | + } |
| 250010 | + }else{ |
| 250011 | + int ii; |
| 250012 | + for(ii=0; ii<pT->nIter; ii++){ |
| 250013 | + Fts5Buffer *pTerm = &pT->apIter[ii]->aSeg[0].term; |
| 250014 | + if( nToken==pTerm->n-1 && memcmp(pToken, pTerm->p+1, nToken)==0 ) break; |
| 250015 | + } |
| 250016 | + if( ii<pT->nIter ){ |
| 250017 | + fts5TokendataIterAppendMap(p, pT, ii, 0, iRowid, iPos); |
| 250018 | + } |
| 250336 | 250019 | } |
| 250337 | 250020 | return fts5IndexReturn(p); |
| 250338 | 250021 | } |
| 250339 | 250022 | |
| 250340 | 250023 | /* |
| | @@ -252140,11 +251823,10 @@ |
| 252140 | 251823 | fts5StructureInvalidate(p); |
| 252141 | 251824 | } |
| 252142 | 251825 | return fts5IndexReturn(p); |
| 252143 | 251826 | } |
| 252144 | 251827 | |
| 252145 | | -#line 1 "fts5_main.c" |
| 252146 | 251828 | /* |
| 252147 | 251829 | ** 2014 Jun 09 |
| 252148 | 251830 | ** |
| 252149 | 251831 | ** The author disclaims copyright to this source code. In place of |
| 252150 | 251832 | ** a legal notice, here is a blessing: |
| | @@ -252236,10 +251918,11 @@ |
| 252236 | 251918 | ** containing a copy of the header from an Fts5Config pointer. |
| 252237 | 251919 | */ |
| 252238 | 251920 | #define FTS5_LOCALE_HDR_SIZE ((int)sizeof( ((Fts5Global*)0)->aLocaleHdr )) |
| 252239 | 251921 | #define FTS5_LOCALE_HDR(pConfig) ((const u8*)(pConfig->pGlobal->aLocaleHdr)) |
| 252240 | 251922 | |
| 251923 | +#define FTS5_INSTTOKEN_SUBTYPE 73 |
| 252241 | 251924 | |
| 252242 | 251925 | /* |
| 252243 | 251926 | ** Each auxiliary function registered with the FTS5 module is represented |
| 252244 | 251927 | ** by an object of the following type. All such objects are stored as part |
| 252245 | 251928 | ** of the Fts5Global.pAux list. |
| | @@ -252775,10 +252458,11 @@ |
| 252775 | 252458 | ){ |
| 252776 | 252459 | /* A MATCH operator or equivalent */ |
| 252777 | 252460 | if( p->usable==0 || iCol<0 ){ |
| 252778 | 252461 | /* As there exists an unusable MATCH constraint this is an |
| 252779 | 252462 | ** unusable plan. Return SQLITE_CONSTRAINT. */ |
| 252463 | + idxStr[iIdxStr] = 0; |
| 252780 | 252464 | return SQLITE_CONSTRAINT; |
| 252781 | 252465 | }else{ |
| 252782 | 252466 | if( iCol==nCol+1 ){ |
| 252783 | 252467 | if( bSeenRank ) continue; |
| 252784 | 252468 | idxStr[iIdxStr++] = 'r'; |
| | @@ -253560,10 +253244,11 @@ |
| 253560 | 253244 | sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */ |
| 253561 | 253245 | sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */ |
| 253562 | 253246 | sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */ |
| 253563 | 253247 | int iCol; /* Column on LHS of MATCH operator */ |
| 253564 | 253248 | char **pzErrmsg = pConfig->pzErrmsg; |
| 253249 | + int bPrefixInsttoken = pConfig->bPrefixInsttoken; |
| 253565 | 253250 | int i; |
| 253566 | 253251 | int iIdxStr = 0; |
| 253567 | 253252 | Fts5Expr *pExpr = 0; |
| 253568 | 253253 | |
| 253569 | 253254 | assert( pConfig->bLock==0 ); |
| | @@ -253595,10 +253280,13 @@ |
| 253595 | 253280 | int bInternal = 0; |
| 253596 | 253281 | |
| 253597 | 253282 | rc = fts5ExtractExprText(pConfig, apVal[i], &zText, &bFreeAndReset); |
| 253598 | 253283 | if( rc!=SQLITE_OK ) goto filter_out; |
| 253599 | 253284 | if( zText==0 ) zText = ""; |
| 253285 | + if( sqlite3_value_subtype(apVal[i])==FTS5_INSTTOKEN_SUBTYPE ){ |
| 253286 | + pConfig->bPrefixInsttoken = 1; |
| 253287 | + } |
| 253600 | 253288 | |
| 253601 | 253289 | iCol = 0; |
| 253602 | 253290 | do{ |
| 253603 | 253291 | iCol = iCol*10 + (idxStr[iIdxStr]-'0'); |
| 253604 | 253292 | iIdxStr++; |
| | @@ -253735,10 +253423,11 @@ |
| 253735 | 253423 | } |
| 253736 | 253424 | |
| 253737 | 253425 | filter_out: |
| 253738 | 253426 | sqlite3Fts5ExprFree(pExpr); |
| 253739 | 253427 | pConfig->pzErrmsg = pzErrmsg; |
| 253428 | + pConfig->bPrefixInsttoken = bPrefixInsttoken; |
| 253740 | 253429 | return rc; |
| 253741 | 253430 | } |
| 253742 | 253431 | |
| 253743 | 253432 | /* |
| 253744 | 253433 | ** This is the xEof method of the virtual table. SQLite calls this |
| | @@ -255730,11 +255419,11 @@ |
| 255730 | 255419 | int nArg, /* Number of args */ |
| 255731 | 255420 | sqlite3_value **apUnused /* Function arguments */ |
| 255732 | 255421 | ){ |
| 255733 | 255422 | assert( nArg==0 ); |
| 255734 | 255423 | UNUSED_PARAM2(nArg, apUnused); |
| 255735 | | - sqlite3_result_text(pCtx, "fts5: 2024-11-06 12:58:31 5495b12569c318d5020b4b5a625a392ef8e777b81c0200624fbbc2a6b5eddef9", -1, SQLITE_TRANSIENT); |
| 255424 | + sqlite3_result_text(pCtx, "fts5: 2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653", -1, SQLITE_TRANSIENT); |
| 255736 | 255425 | } |
| 255737 | 255426 | |
| 255738 | 255427 | /* |
| 255739 | 255428 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 255740 | 255429 | ** |
| | @@ -255793,10 +255482,24 @@ |
| 255793 | 255482 | assert( &pCsr[nText]==&pBlob[nBlob] ); |
| 255794 | 255483 | |
| 255795 | 255484 | sqlite3_result_blob(pCtx, pBlob, nBlob, sqlite3_free); |
| 255796 | 255485 | } |
| 255797 | 255486 | } |
| 255487 | + |
| 255488 | +/* |
| 255489 | +** Implementation of fts5_insttoken() function. |
| 255490 | +*/ |
| 255491 | +static void fts5InsttokenFunc( |
| 255492 | + sqlite3_context *pCtx, /* Function call context */ |
| 255493 | + int nArg, /* Number of args */ |
| 255494 | + sqlite3_value **apArg /* Function arguments */ |
| 255495 | +){ |
| 255496 | + assert( nArg==1 ); |
| 255497 | + (void)nArg; |
| 255498 | + sqlite3_result_value(pCtx, apArg[0]); |
| 255499 | + sqlite3_result_subtype(pCtx, FTS5_INSTTOKEN_SUBTYPE); |
| 255500 | +} |
| 255798 | 255501 | |
| 255799 | 255502 | /* |
| 255800 | 255503 | ** Return true if zName is the extension on one of the shadow tables used |
| 255801 | 255504 | ** by this module. |
| 255802 | 255505 | */ |
| | @@ -255923,13 +255626,20 @@ |
| 255923 | 255626 | ); |
| 255924 | 255627 | } |
| 255925 | 255628 | if( rc==SQLITE_OK ){ |
| 255926 | 255629 | rc = sqlite3_create_function( |
| 255927 | 255630 | db, "fts5_locale", 2, |
| 255928 | | - SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE, |
| 255631 | + SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE|SQLITE_SUBTYPE, |
| 255929 | 255632 | p, fts5LocaleFunc, 0, 0 |
| 255930 | 255633 | ); |
| 255634 | + } |
| 255635 | + if( rc==SQLITE_OK ){ |
| 255636 | + rc = sqlite3_create_function( |
| 255637 | + db, "fts5_insttoken", 1, |
| 255638 | + SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE, |
| 255639 | + p, fts5InsttokenFunc, 0, 0 |
| 255640 | + ); |
| 255931 | 255641 | } |
| 255932 | 255642 | } |
| 255933 | 255643 | |
| 255934 | 255644 | /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file |
| 255935 | 255645 | ** fts5_test_mi.c is compiled and linked into the executable. And call |
| | @@ -255983,11 +255693,10 @@ |
| 255983 | 255693 | SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3 *db){ |
| 255984 | 255694 | return fts5Init(db); |
| 255985 | 255695 | } |
| 255986 | 255696 | #endif |
| 255987 | 255697 | |
| 255988 | | -#line 1 "fts5_storage.c" |
| 255989 | 255698 | /* |
| 255990 | 255699 | ** 2014 May 31 |
| 255991 | 255700 | ** |
| 255992 | 255701 | ** The author disclaims copyright to this source code. In place of |
| 255993 | 255702 | ** a legal notice, here is a blessing: |
| | @@ -257497,11 +257206,10 @@ |
| 257497 | 257206 | } |
| 257498 | 257207 | } |
| 257499 | 257208 | return rc; |
| 257500 | 257209 | } |
| 257501 | 257210 | |
| 257502 | | -#line 1 "fts5_tokenize.c" |
| 257503 | 257211 | /* |
| 257504 | 257212 | ** 2014 May 31 |
| 257505 | 257213 | ** |
| 257506 | 257214 | ** The author disclaims copyright to this source code. In place of |
| 257507 | 257215 | ** a legal notice, here is a blessing: |
| | @@ -258853,22 +258561,22 @@ |
| 258853 | 258561 | int rc = SQLITE_OK; |
| 258854 | 258562 | char aBuf[32]; |
| 258855 | 258563 | char *zOut = aBuf; |
| 258856 | 258564 | int ii; |
| 258857 | 258565 | const unsigned char *zIn = (const unsigned char*)pText; |
| 258858 | | - const unsigned char *zEof = &zIn[nText]; |
| 258859 | | - u32 iCode; |
| 258566 | + const unsigned char *zEof = (zIn ? &zIn[nText] : 0); |
| 258567 | + u32 iCode = 0; |
| 258860 | 258568 | int aStart[3]; /* Input offset of each character in aBuf[] */ |
| 258861 | 258569 | |
| 258862 | 258570 | UNUSED_PARAM(unusedFlags); |
| 258863 | 258571 | |
| 258864 | 258572 | /* Populate aBuf[] with the characters for the first trigram. */ |
| 258865 | 258573 | for(ii=0; ii<3; ii++){ |
| 258866 | 258574 | do { |
| 258867 | 258575 | aStart[ii] = zIn - (const unsigned char*)pText; |
| 258576 | + if( zIn>=zEof ) return SQLITE_OK; |
| 258868 | 258577 | READ_UTF8(zIn, zEof, iCode); |
| 258869 | | - if( iCode==0 ) return SQLITE_OK; |
| 258870 | 258578 | if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam); |
| 258871 | 258579 | }while( iCode==0 ); |
| 258872 | 258580 | WRITE_UTF8(zOut, iCode); |
| 258873 | 258581 | } |
| 258874 | 258582 | |
| | @@ -258885,12 +258593,15 @@ |
| 258885 | 258593 | const char *z1; |
| 258886 | 258594 | |
| 258887 | 258595 | /* Read characters from the input up until the first non-diacritic */ |
| 258888 | 258596 | do { |
| 258889 | 258597 | iNext = zIn - (const unsigned char*)pText; |
| 258598 | + if( zIn>=zEof ){ |
| 258599 | + iCode = 0; |
| 258600 | + break; |
| 258601 | + } |
| 258890 | 258602 | READ_UTF8(zIn, zEof, iCode); |
| 258891 | | - if( iCode==0 ) break; |
| 258892 | 258603 | if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam); |
| 258893 | 258604 | }while( iCode==0 ); |
| 258894 | 258605 | |
| 258895 | 258606 | /* Pass the current trigram back to fts5 */ |
| 258896 | 258607 | rc = xToken(pCtx, 0, aBuf, zOut-aBuf, aStart[0], iNext); |
| | @@ -258986,11 +258697,10 @@ |
| 258986 | 258697 | ); |
| 258987 | 258698 | } |
| 258988 | 258699 | return rc; |
| 258989 | 258700 | } |
| 258990 | 258701 | |
| 258991 | | -#line 1 "fts5_unicode2.c" |
| 258992 | 258702 | /* |
| 258993 | 258703 | ** 2012-05-25 |
| 258994 | 258704 | ** |
| 258995 | 258705 | ** The author disclaims copyright to this source code. In place of |
| 258996 | 258706 | ** a legal notice, here is a blessing: |
| | @@ -259769,11 +259479,10 @@ |
| 259769 | 259479 | } |
| 259770 | 259480 | aAscii[0] = 0; /* 0x00 is never a token character */ |
| 259771 | 259481 | } |
| 259772 | 259482 | |
| 259773 | 259483 | |
| 259774 | | -#line 1 "fts5_varint.c" |
| 259775 | 259484 | /* |
| 259776 | 259485 | ** 2015 May 30 |
| 259777 | 259486 | ** |
| 259778 | 259487 | ** The author disclaims copyright to this source code. In place of |
| 259779 | 259488 | ** a legal notice, here is a blessing: |
| | @@ -260115,11 +259824,10 @@ |
| 260115 | 259824 | if( iVal<(1 << 21) ) return 3; |
| 260116 | 259825 | if( iVal<(1 << 28) ) return 4; |
| 260117 | 259826 | return 5; |
| 260118 | 259827 | } |
| 260119 | 259828 | |
| 260120 | | -#line 1 "fts5_vocab.c" |
| 260121 | 259829 | /* |
| 260122 | 259830 | ** 2015 May 08 |
| 260123 | 259831 | ** |
| 260124 | 259832 | ** The author disclaims copyright to this source code. In place of |
| 260125 | 259833 | ** a legal notice, here is a blessing: |
| | @@ -260931,11 +260639,10 @@ |
| 260931 | 260639 | /* Here ends the fts5.c composite file. */ |
| 260932 | 260640 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */ |
| 260933 | 260641 | |
| 260934 | 260642 | /************** End of fts5.c ************************************************/ |
| 260935 | 260643 | /************** Begin file stmt.c ********************************************/ |
| 260936 | | -#line 1 "tsrc/stmt.c" |
| 260937 | 260644 | /* |
| 260938 | 260645 | ** 2017-05-31 |
| 260939 | 260646 | ** |
| 260940 | 260647 | ** The author disclaims copyright to this source code. In place of |
| 260941 | 260648 | ** a legal notice, here is a blessing: |
| 260942 | 260649 | |