| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.46.0. By combining all the individual C code files into this |
| 3 | +** version 3.47.0. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -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 | | -** a49296de0061931badaf3db6b965131a78b1. |
| 21 | +** baa83b460c677c210c7fa3f20314d7e05f30. |
| 22 | 22 | */ |
| 23 | 23 | #define SQLITE_CORE 1 |
| 24 | 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | 25 | #ifndef SQLITE_PRIVATE |
| 26 | 26 | # define SQLITE_PRIVATE static |
| | @@ -254,14 +254,17 @@ |
| 254 | 254 | #endif |
| 255 | 255 | |
| 256 | 256 | /* |
| 257 | 257 | ** Macro to disable warnings about missing "break" at the end of a "case". |
| 258 | 258 | */ |
| 259 | | -#if GCC_VERSION>=7000000 |
| 260 | | -# define deliberate_fall_through __attribute__((fallthrough)); |
| 261 | | -#else |
| 262 | | -# define deliberate_fall_through |
| 259 | +#if defined(__has_attribute) |
| 260 | +# if __has_attribute(fallthrough) |
| 261 | +# define deliberate_fall_through __attribute__((fallthrough)); |
| 262 | +# endif |
| 263 | +#endif |
| 264 | +#if !defined(deliberate_fall_through) |
| 265 | +# define deliberate_fall_through |
| 263 | 266 | #endif |
| 264 | 267 | |
| 265 | 268 | /* |
| 266 | 269 | ** For MinGW, check to see if we can include the header file containing its |
| 267 | 270 | ** version information, among other things. Normally, this internal MinGW |
| | @@ -457,13 +460,13 @@ |
| 457 | 460 | ** |
| 458 | 461 | ** See also: [sqlite3_libversion()], |
| 459 | 462 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | 463 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | 464 | */ |
| 462 | | -#define SQLITE_VERSION "3.46.0" |
| 463 | | -#define SQLITE_VERSION_NUMBER 3046000 |
| 464 | | -#define SQLITE_SOURCE_ID "2024-03-26 11:14:52 a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3" |
| 465 | +#define SQLITE_VERSION "3.47.0" |
| 466 | +#define SQLITE_VERSION_NUMBER 3047000 |
| 467 | +#define SQLITE_SOURCE_ID "2024-07-03 20:19:33 baa83b460c677c210c7fa3f20314d7e05f305aed8a69026bc5fa106a3de4ea38" |
| 465 | 468 | |
| 466 | 469 | /* |
| 467 | 470 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | 471 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | 472 | ** |
| | @@ -1083,12 +1086,12 @@ |
| 1083 | 1086 | ** xUnlock() downgrades the database file lock to either SHARED or NONE. |
| 1084 | 1087 | ** If the lock is already at or below the requested lock state, then the call |
| 1085 | 1088 | ** to xUnlock() is a no-op. |
| 1086 | 1089 | ** The xCheckReservedLock() method checks whether any database connection, |
| 1087 | 1090 | ** either in this process or in some other process, is holding a RESERVED, |
| 1088 | | -** PENDING, or EXCLUSIVE lock on the file. It returns true |
| 1089 | | -** if such a lock exists and false otherwise. |
| 1091 | +** PENDING, or EXCLUSIVE lock on the file. It returns, via its output |
| 1092 | +** pointer parameter, true if such a lock exists and false otherwise. |
| 1090 | 1093 | ** |
| 1091 | 1094 | ** The xFileControl() method is a generic interface that allows custom |
| 1092 | 1095 | ** VFS implementations to directly control an open file using the |
| 1093 | 1096 | ** [sqlite3_file_control()] interface. The second "op" argument is an |
| 1094 | 1097 | ** integer opcode. The third argument is a generic pointer intended to |
| | @@ -3881,12 +3884,12 @@ |
| 3881 | 3884 | ** the default shared cache setting provided by |
| 3882 | 3885 | ** [sqlite3_enable_shared_cache()].)^ |
| 3883 | 3886 | ** |
| 3884 | 3887 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> |
| 3885 | 3888 | ** <dd>The database connection comes up in "extended result code mode". |
| 3886 | | -** In other words, the database behaves has if |
| 3887 | | -** [sqlite3_extended_result_codes(db,1)] where called on the database |
| 3889 | +** In other words, the database behaves as if |
| 3890 | +** [sqlite3_extended_result_codes(db,1)] were called on the database |
| 3888 | 3891 | ** connection as soon as the connection is created. In addition to setting |
| 3889 | 3892 | ** the extended result code mode, this flag also causes [sqlite3_open_v2()] |
| 3890 | 3893 | ** to return an extended result code.</dd> |
| 3891 | 3894 | ** |
| 3892 | 3895 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| | @@ -7197,10 +7200,16 @@ |
| 7197 | 7200 | ** is not invoked when conflicting rows are deleted because of an |
| 7198 | 7201 | ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook |
| 7199 | 7202 | ** invoked when rows are deleted using the [truncate optimization]. |
| 7200 | 7203 | ** The exceptions defined in this paragraph might change in a future |
| 7201 | 7204 | ** release of SQLite. |
| 7205 | +** |
| 7206 | +** Whether the update hook is invoked before or after the |
| 7207 | +** corresponding change is currently unspecified and may differ |
| 7208 | +** depending on the type of change. Do not rely on the order of the |
| 7209 | +** hook call with regards to the final result of the operation which |
| 7210 | +** triggers the hook. |
| 7202 | 7211 | ** |
| 7203 | 7212 | ** The update hook implementation must not do anything that will modify |
| 7204 | 7213 | ** the database connection that invoked the update hook. Any actions |
| 7205 | 7214 | ** to modify the database connection must be deferred until after the |
| 7206 | 7215 | ** completion of the [sqlite3_step()] call that triggered the update hook. |
| | @@ -8668,11 +8677,11 @@ |
| 8668 | 8677 | ** by enclosing in double-quotes) so as not to confuse the parser. |
| 8669 | 8678 | ** |
| 8670 | 8679 | ** The sqlite3_keyword_count() interface returns the number of distinct |
| 8671 | 8680 | ** keywords understood by SQLite. |
| 8672 | 8681 | ** |
| 8673 | | -** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and |
| 8682 | +** The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and |
| 8674 | 8683 | ** makes *Z point to that keyword expressed as UTF8 and writes the number |
| 8675 | 8684 | ** of bytes in the keyword into *L. The string that *Z points to is not |
| 8676 | 8685 | ** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns |
| 8677 | 8686 | ** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z |
| 8678 | 8687 | ** or L are NULL or invalid pointers then calls to |
| | @@ -10247,27 +10256,48 @@ |
| 10247 | 10256 | ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner |
| 10248 | 10257 | ** is doing a GROUP BY. |
| 10249 | 10258 | ** <li value="2"><p> |
| 10250 | 10259 | ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means |
| 10251 | 10260 | ** that the query planner does not need the rows returned in any particular |
| 10252 | | -** order, as long as rows with the same values in all "aOrderBy" columns |
| 10253 | | -** are adjacent.)^ ^(Furthermore, only a single row for each particular |
| 10254 | | -** combination of values in the columns identified by the "aOrderBy" field |
| 10255 | | -** needs to be returned.)^ ^It is always ok for two or more rows with the same |
| 10256 | | -** values in all "aOrderBy" columns to be returned, as long as all such rows |
| 10257 | | -** are adjacent. ^The virtual table may, if it chooses, omit extra rows |
| 10258 | | -** that have the same value for all columns identified by "aOrderBy". |
| 10259 | | -** ^However omitting the extra rows is optional. |
| 10261 | +** order, as long as rows with the same values in all columns identified |
| 10262 | +** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows |
| 10263 | +** contain the same values for all columns identified by "colUsed", all but |
| 10264 | +** one such row may optionally be omitted from the result.)^ |
| 10265 | +** The virtual table is not required to omit rows that are duplicates |
| 10266 | +** over the "colUsed" columns, but if the virtual table can do that without |
| 10267 | +** too much extra effort, it could potentially help the query to run faster. |
| 10260 | 10268 | ** This mode is used for a DISTINCT query. |
| 10261 | 10269 | ** <li value="3"><p> |
| 10262 | | -** ^(If the sqlite3_vtab_distinct() interface returns 3, that means |
| 10263 | | -** that the query planner needs only distinct rows but it does need the |
| 10264 | | -** rows to be sorted.)^ ^The virtual table implementation is free to omit |
| 10265 | | -** rows that are identical in all aOrderBy columns, if it wants to, but |
| 10266 | | -** it is not required to omit any rows. This mode is used for queries |
| 10270 | +** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the |
| 10271 | +** virtual table must return rows in the order defined by "aOrderBy" as |
| 10272 | +** if the sqlite3_vtab_distinct() interface had returned 0. However if |
| 10273 | +** two or more rows in the result have the same values for all columns |
| 10274 | +** identified by "colUsed", then all but one such row may optionally be |
| 10275 | +** omitted.)^ Like when the return value is 2, the virtual table |
| 10276 | +** is not required to omit rows that are duplicates over the "colUsed" |
| 10277 | +** columns, but if the virtual table can do that without |
| 10278 | +** too much extra effort, it could potentially help the query to run faster. |
| 10279 | +** This mode is used for queries |
| 10267 | 10280 | ** that have both DISTINCT and ORDER BY clauses. |
| 10268 | 10281 | ** </ol> |
| 10282 | +** |
| 10283 | +** <p>The following table summarizes the conditions under which the |
| 10284 | +** virtual table is allowed to set the "orderByConsumed" flag based on |
| 10285 | +** the value returned by sqlite3_vtab_distinct(). This table is a |
| 10286 | +** restatement of the previous four paragraphs: |
| 10287 | +** |
| 10288 | +** <table border=1 cellspacing=0 cellpadding=10 width="90%"> |
| 10289 | +** <tr> |
| 10290 | +** <td valign="top">sqlite3_vtab_distinct() return value |
| 10291 | +** <td valign="top">Rows are returned in aOrderBy order |
| 10292 | +** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent |
| 10293 | +** <td valign="top">Duplicates over all colUsed columns may be omitted |
| 10294 | +** <tr><td>0<td>yes<td>yes<td>no |
| 10295 | +** <tr><td>1<td>no<td>yes<td>no |
| 10296 | +** <tr><td>2<td>no<td>yes<td>yes |
| 10297 | +** <tr><td>3<td>yes<td>yes<td>yes |
| 10298 | +** </table> |
| 10269 | 10299 | ** |
| 10270 | 10300 | ** ^For the purposes of comparing virtual table output values to see if the |
| 10271 | 10301 | ** values are same value for sorting purposes, two NULL values are considered |
| 10272 | 10302 | ** to be the same. In other words, the comparison operator is "IS" |
| 10273 | 10303 | ** (or "IS NOT DISTINCT FROM") and not "==". |
| | @@ -11116,12 +11146,10 @@ |
| 11116 | 11146 | #endif |
| 11117 | 11147 | |
| 11118 | 11148 | #if defined(__wasi__) |
| 11119 | 11149 | # undef SQLITE_WASI |
| 11120 | 11150 | # define SQLITE_WASI 1 |
| 11121 | | -# undef SQLITE_OMIT_WAL |
| 11122 | | -# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ |
| 11123 | 11151 | # ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 11124 | 11152 | # define SQLITE_OMIT_LOAD_EXTENSION |
| 11125 | 11153 | # endif |
| 11126 | 11154 | # ifndef SQLITE_THREADSAFE |
| 11127 | 11155 | # define SQLITE_THREADSAFE 0 |
| | @@ -12308,10 +12336,34 @@ |
| 12308 | 12336 | ** |
| 12309 | 12337 | ** In all cases, if an error occurs the state of the final contents of the |
| 12310 | 12338 | ** changegroup is undefined. If no error occurs, SQLITE_OK is returned. |
| 12311 | 12339 | */ |
| 12312 | 12340 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 12341 | + |
| 12342 | +/* |
| 12343 | +** CAPI3REF: Add A Single Change To A Changegroup |
| 12344 | +** METHOD: sqlite3_changegroup |
| 12345 | +** |
| 12346 | +** This function adds the single change currently indicated by the iterator |
| 12347 | +** passed as the second argument to the changegroup object. The rules for |
| 12348 | +** adding the change are just as described for [sqlite3changegroup_add()]. |
| 12349 | +** |
| 12350 | +** If the change is successfully added to the changegroup, SQLITE_OK is |
| 12351 | +** returned. Otherwise, an SQLite error code is returned. |
| 12352 | +** |
| 12353 | +** The iterator must point to a valid entry when this function is called. |
| 12354 | +** If it does not, SQLITE_ERROR is returned and no change is added to the |
| 12355 | +** changegroup. Additionally, the iterator must not have been opened with |
| 12356 | +** the SQLITE_CHANGESETAPPLY_INVERT flag. In this case SQLITE_ERROR is also |
| 12357 | +** returned. |
| 12358 | +*/ |
| 12359 | +SQLITE_API int sqlite3changegroup_add_change( |
| 12360 | + sqlite3_changegroup*, |
| 12361 | + sqlite3_changeset_iter* |
| 12362 | +); |
| 12363 | + |
| 12364 | + |
| 12313 | 12365 | |
| 12314 | 12366 | /* |
| 12315 | 12367 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| 12316 | 12368 | ** METHOD: sqlite3_changegroup |
| 12317 | 12369 | ** |
| | @@ -13113,12 +13165,12 @@ |
| 13113 | 13165 | |
| 13114 | 13166 | /* |
| 13115 | 13167 | ** EXTENSION API FUNCTIONS |
| 13116 | 13168 | ** |
| 13117 | 13169 | ** xUserData(pFts): |
| 13118 | | -** Return a copy of the context pointer the extension function was |
| 13119 | | -** registered with. |
| 13170 | +** Return a copy of the pUserData pointer passed to the xCreateFunction() |
| 13171 | +** API when the extension function was registered. |
| 13120 | 13172 | ** |
| 13121 | 13173 | ** xColumnTotalSize(pFts, iCol, pnToken): |
| 13122 | 13174 | ** If parameter iCol is less than zero, set output variable *pnToken |
| 13123 | 13175 | ** to the total number of tokens in the FTS5 table. Or, if iCol is |
| 13124 | 13176 | ** non-negative but less than the number of columns in the table, return |
| | @@ -13295,10 +13347,14 @@ |
| 13295 | 13347 | ** This API can be quite slow if used with an FTS5 table created with the |
| 13296 | 13348 | ** "detail=none" or "detail=column" option. If the FTS5 table is created |
| 13297 | 13349 | ** with either "detail=none" or "detail=column" and "content=" option |
| 13298 | 13350 | ** (i.e. if it is a contentless table), then this API always iterates |
| 13299 | 13351 | ** through an empty set (all calls to xPhraseFirst() set iCol to -1). |
| 13352 | +** |
| 13353 | +** In all cases, matches are visited in (column ASC, offset ASC) order. |
| 13354 | +** i.e. all those in column 0, sorted by offset, followed by those in |
| 13355 | +** column 1, etc. |
| 13300 | 13356 | ** |
| 13301 | 13357 | ** xPhraseNext() |
| 13302 | 13358 | ** See xPhraseFirst above. |
| 13303 | 13359 | ** |
| 13304 | 13360 | ** xPhraseFirstColumn() |
| | @@ -14479,139 +14535,139 @@ |
| 14479 | 14535 | #define TK_EACH 41 |
| 14480 | 14536 | #define TK_FAIL 42 |
| 14481 | 14537 | #define TK_OR 43 |
| 14482 | 14538 | #define TK_AND 44 |
| 14483 | 14539 | #define TK_IS 45 |
| 14484 | | -#define TK_MATCH 46 |
| 14485 | | -#define TK_LIKE_KW 47 |
| 14486 | | -#define TK_BETWEEN 48 |
| 14487 | | -#define TK_IN 49 |
| 14488 | | -#define TK_ISNULL 50 |
| 14489 | | -#define TK_NOTNULL 51 |
| 14490 | | -#define TK_NE 52 |
| 14491 | | -#define TK_EQ 53 |
| 14492 | | -#define TK_GT 54 |
| 14493 | | -#define TK_LE 55 |
| 14494 | | -#define TK_LT 56 |
| 14495 | | -#define TK_GE 57 |
| 14496 | | -#define TK_ESCAPE 58 |
| 14497 | | -#define TK_ID 59 |
| 14498 | | -#define TK_COLUMNKW 60 |
| 14499 | | -#define TK_DO 61 |
| 14500 | | -#define TK_FOR 62 |
| 14501 | | -#define TK_IGNORE 63 |
| 14502 | | -#define TK_INITIALLY 64 |
| 14503 | | -#define TK_INSTEAD 65 |
| 14504 | | -#define TK_NO 66 |
| 14505 | | -#define TK_KEY 67 |
| 14506 | | -#define TK_OF 68 |
| 14507 | | -#define TK_OFFSET 69 |
| 14508 | | -#define TK_PRAGMA 70 |
| 14509 | | -#define TK_RAISE 71 |
| 14510 | | -#define TK_RECURSIVE 72 |
| 14511 | | -#define TK_REPLACE 73 |
| 14512 | | -#define TK_RESTRICT 74 |
| 14513 | | -#define TK_ROW 75 |
| 14514 | | -#define TK_ROWS 76 |
| 14515 | | -#define TK_TRIGGER 77 |
| 14516 | | -#define TK_VACUUM 78 |
| 14517 | | -#define TK_VIEW 79 |
| 14518 | | -#define TK_VIRTUAL 80 |
| 14519 | | -#define TK_WITH 81 |
| 14520 | | -#define TK_NULLS 82 |
| 14521 | | -#define TK_FIRST 83 |
| 14522 | | -#define TK_LAST 84 |
| 14523 | | -#define TK_CURRENT 85 |
| 14524 | | -#define TK_FOLLOWING 86 |
| 14525 | | -#define TK_PARTITION 87 |
| 14526 | | -#define TK_PRECEDING 88 |
| 14527 | | -#define TK_RANGE 89 |
| 14528 | | -#define TK_UNBOUNDED 90 |
| 14529 | | -#define TK_EXCLUDE 91 |
| 14530 | | -#define TK_GROUPS 92 |
| 14531 | | -#define TK_OTHERS 93 |
| 14532 | | -#define TK_TIES 94 |
| 14533 | | -#define TK_GENERATED 95 |
| 14534 | | -#define TK_ALWAYS 96 |
| 14535 | | -#define TK_MATERIALIZED 97 |
| 14536 | | -#define TK_REINDEX 98 |
| 14537 | | -#define TK_RENAME 99 |
| 14538 | | -#define TK_CTIME_KW 100 |
| 14539 | | -#define TK_ANY 101 |
| 14540 | | -#define TK_BITAND 102 |
| 14541 | | -#define TK_BITOR 103 |
| 14542 | | -#define TK_LSHIFT 104 |
| 14543 | | -#define TK_RSHIFT 105 |
| 14544 | | -#define TK_PLUS 106 |
| 14545 | | -#define TK_MINUS 107 |
| 14546 | | -#define TK_STAR 108 |
| 14547 | | -#define TK_SLASH 109 |
| 14548 | | -#define TK_REM 110 |
| 14549 | | -#define TK_CONCAT 111 |
| 14550 | | -#define TK_PTR 112 |
| 14551 | | -#define TK_COLLATE 113 |
| 14552 | | -#define TK_BITNOT 114 |
| 14553 | | -#define TK_ON 115 |
| 14554 | | -#define TK_INDEXED 116 |
| 14555 | | -#define TK_STRING 117 |
| 14556 | | -#define TK_JOIN_KW 118 |
| 14557 | | -#define TK_CONSTRAINT 119 |
| 14558 | | -#define TK_DEFAULT 120 |
| 14559 | | -#define TK_NULL 121 |
| 14560 | | -#define TK_PRIMARY 122 |
| 14561 | | -#define TK_UNIQUE 123 |
| 14562 | | -#define TK_CHECK 124 |
| 14563 | | -#define TK_REFERENCES 125 |
| 14564 | | -#define TK_AUTOINCR 126 |
| 14565 | | -#define TK_INSERT 127 |
| 14566 | | -#define TK_DELETE 128 |
| 14567 | | -#define TK_UPDATE 129 |
| 14568 | | -#define TK_SET 130 |
| 14569 | | -#define TK_DEFERRABLE 131 |
| 14570 | | -#define TK_FOREIGN 132 |
| 14571 | | -#define TK_DROP 133 |
| 14572 | | -#define TK_UNION 134 |
| 14573 | | -#define TK_ALL 135 |
| 14574 | | -#define TK_EXCEPT 136 |
| 14575 | | -#define TK_INTERSECT 137 |
| 14576 | | -#define TK_SELECT 138 |
| 14577 | | -#define TK_VALUES 139 |
| 14578 | | -#define TK_DISTINCT 140 |
| 14579 | | -#define TK_DOT 141 |
| 14580 | | -#define TK_FROM 142 |
| 14581 | | -#define TK_JOIN 143 |
| 14582 | | -#define TK_USING 144 |
| 14583 | | -#define TK_ORDER 145 |
| 14584 | | -#define TK_GROUP 146 |
| 14585 | | -#define TK_HAVING 147 |
| 14586 | | -#define TK_LIMIT 148 |
| 14587 | | -#define TK_WHERE 149 |
| 14588 | | -#define TK_RETURNING 150 |
| 14589 | | -#define TK_INTO 151 |
| 14590 | | -#define TK_NOTHING 152 |
| 14591 | | -#define TK_FLOAT 153 |
| 14592 | | -#define TK_BLOB 154 |
| 14593 | | -#define TK_INTEGER 155 |
| 14594 | | -#define TK_VARIABLE 156 |
| 14595 | | -#define TK_CASE 157 |
| 14596 | | -#define TK_WHEN 158 |
| 14597 | | -#define TK_THEN 159 |
| 14598 | | -#define TK_ELSE 160 |
| 14599 | | -#define TK_INDEX 161 |
| 14600 | | -#define TK_ALTER 162 |
| 14601 | | -#define TK_ADD 163 |
| 14602 | | -#define TK_WINDOW 164 |
| 14603 | | -#define TK_OVER 165 |
| 14604 | | -#define TK_FILTER 166 |
| 14605 | | -#define TK_COLUMN 167 |
| 14606 | | -#define TK_AGG_FUNCTION 168 |
| 14607 | | -#define TK_AGG_COLUMN 169 |
| 14608 | | -#define TK_TRUEFALSE 170 |
| 14609 | | -#define TK_ISNOT 171 |
| 14540 | +#define TK_ISNOT 46 |
| 14541 | +#define TK_MATCH 47 |
| 14542 | +#define TK_LIKE_KW 48 |
| 14543 | +#define TK_BETWEEN 49 |
| 14544 | +#define TK_IN 50 |
| 14545 | +#define TK_ISNULL 51 |
| 14546 | +#define TK_NOTNULL 52 |
| 14547 | +#define TK_NE 53 |
| 14548 | +#define TK_EQ 54 |
| 14549 | +#define TK_GT 55 |
| 14550 | +#define TK_LE 56 |
| 14551 | +#define TK_LT 57 |
| 14552 | +#define TK_GE 58 |
| 14553 | +#define TK_ESCAPE 59 |
| 14554 | +#define TK_ID 60 |
| 14555 | +#define TK_COLUMNKW 61 |
| 14556 | +#define TK_DO 62 |
| 14557 | +#define TK_FOR 63 |
| 14558 | +#define TK_IGNORE 64 |
| 14559 | +#define TK_INITIALLY 65 |
| 14560 | +#define TK_INSTEAD 66 |
| 14561 | +#define TK_NO 67 |
| 14562 | +#define TK_KEY 68 |
| 14563 | +#define TK_OF 69 |
| 14564 | +#define TK_OFFSET 70 |
| 14565 | +#define TK_PRAGMA 71 |
| 14566 | +#define TK_RAISE 72 |
| 14567 | +#define TK_RECURSIVE 73 |
| 14568 | +#define TK_REPLACE 74 |
| 14569 | +#define TK_RESTRICT 75 |
| 14570 | +#define TK_ROW 76 |
| 14571 | +#define TK_ROWS 77 |
| 14572 | +#define TK_TRIGGER 78 |
| 14573 | +#define TK_VACUUM 79 |
| 14574 | +#define TK_VIEW 80 |
| 14575 | +#define TK_VIRTUAL 81 |
| 14576 | +#define TK_WITH 82 |
| 14577 | +#define TK_NULLS 83 |
| 14578 | +#define TK_FIRST 84 |
| 14579 | +#define TK_LAST 85 |
| 14580 | +#define TK_CURRENT 86 |
| 14581 | +#define TK_FOLLOWING 87 |
| 14582 | +#define TK_PARTITION 88 |
| 14583 | +#define TK_PRECEDING 89 |
| 14584 | +#define TK_RANGE 90 |
| 14585 | +#define TK_UNBOUNDED 91 |
| 14586 | +#define TK_EXCLUDE 92 |
| 14587 | +#define TK_GROUPS 93 |
| 14588 | +#define TK_OTHERS 94 |
| 14589 | +#define TK_TIES 95 |
| 14590 | +#define TK_GENERATED 96 |
| 14591 | +#define TK_ALWAYS 97 |
| 14592 | +#define TK_MATERIALIZED 98 |
| 14593 | +#define TK_REINDEX 99 |
| 14594 | +#define TK_RENAME 100 |
| 14595 | +#define TK_CTIME_KW 101 |
| 14596 | +#define TK_ANY 102 |
| 14597 | +#define TK_BITAND 103 |
| 14598 | +#define TK_BITOR 104 |
| 14599 | +#define TK_LSHIFT 105 |
| 14600 | +#define TK_RSHIFT 106 |
| 14601 | +#define TK_PLUS 107 |
| 14602 | +#define TK_MINUS 108 |
| 14603 | +#define TK_STAR 109 |
| 14604 | +#define TK_SLASH 110 |
| 14605 | +#define TK_REM 111 |
| 14606 | +#define TK_CONCAT 112 |
| 14607 | +#define TK_PTR 113 |
| 14608 | +#define TK_COLLATE 114 |
| 14609 | +#define TK_BITNOT 115 |
| 14610 | +#define TK_ON 116 |
| 14611 | +#define TK_INDEXED 117 |
| 14612 | +#define TK_STRING 118 |
| 14613 | +#define TK_JOIN_KW 119 |
| 14614 | +#define TK_CONSTRAINT 120 |
| 14615 | +#define TK_DEFAULT 121 |
| 14616 | +#define TK_NULL 122 |
| 14617 | +#define TK_PRIMARY 123 |
| 14618 | +#define TK_UNIQUE 124 |
| 14619 | +#define TK_CHECK 125 |
| 14620 | +#define TK_REFERENCES 126 |
| 14621 | +#define TK_AUTOINCR 127 |
| 14622 | +#define TK_INSERT 128 |
| 14623 | +#define TK_DELETE 129 |
| 14624 | +#define TK_UPDATE 130 |
| 14625 | +#define TK_SET 131 |
| 14626 | +#define TK_DEFERRABLE 132 |
| 14627 | +#define TK_FOREIGN 133 |
| 14628 | +#define TK_DROP 134 |
| 14629 | +#define TK_UNION 135 |
| 14630 | +#define TK_ALL 136 |
| 14631 | +#define TK_EXCEPT 137 |
| 14632 | +#define TK_INTERSECT 138 |
| 14633 | +#define TK_SELECT 139 |
| 14634 | +#define TK_VALUES 140 |
| 14635 | +#define TK_DISTINCT 141 |
| 14636 | +#define TK_DOT 142 |
| 14637 | +#define TK_FROM 143 |
| 14638 | +#define TK_JOIN 144 |
| 14639 | +#define TK_USING 145 |
| 14640 | +#define TK_ORDER 146 |
| 14641 | +#define TK_GROUP 147 |
| 14642 | +#define TK_HAVING 148 |
| 14643 | +#define TK_LIMIT 149 |
| 14644 | +#define TK_WHERE 150 |
| 14645 | +#define TK_RETURNING 151 |
| 14646 | +#define TK_INTO 152 |
| 14647 | +#define TK_NOTHING 153 |
| 14648 | +#define TK_FLOAT 154 |
| 14649 | +#define TK_BLOB 155 |
| 14650 | +#define TK_INTEGER 156 |
| 14651 | +#define TK_VARIABLE 157 |
| 14652 | +#define TK_CASE 158 |
| 14653 | +#define TK_WHEN 159 |
| 14654 | +#define TK_THEN 160 |
| 14655 | +#define TK_ELSE 161 |
| 14656 | +#define TK_INDEX 162 |
| 14657 | +#define TK_ALTER 163 |
| 14658 | +#define TK_ADD 164 |
| 14659 | +#define TK_WINDOW 165 |
| 14660 | +#define TK_OVER 166 |
| 14661 | +#define TK_FILTER 167 |
| 14662 | +#define TK_COLUMN 168 |
| 14663 | +#define TK_AGG_FUNCTION 169 |
| 14664 | +#define TK_AGG_COLUMN 170 |
| 14665 | +#define TK_TRUEFALSE 171 |
| 14610 | 14666 | #define TK_FUNCTION 172 |
| 14611 | | -#define TK_UMINUS 173 |
| 14612 | | -#define TK_UPLUS 174 |
| 14667 | +#define TK_UPLUS 173 |
| 14668 | +#define TK_UMINUS 174 |
| 14613 | 14669 | #define TK_TRUTH 175 |
| 14614 | 14670 | #define TK_REGISTER 176 |
| 14615 | 14671 | #define TK_VECTOR 177 |
| 14616 | 14672 | #define TK_SELECT_COLUMN 178 |
| 14617 | 14673 | #define TK_IF_NULL_ROW 179 |
| | @@ -15148,11 +15204,11 @@ |
| 15148 | 15204 | ** 0x00000008 WhereLoop inserts |
| 15149 | 15205 | ** |
| 15150 | 15206 | ** 0x00000010 Display sqlite3_index_info xBestIndex calls |
| 15151 | 15207 | ** 0x00000020 Range an equality scan metrics |
| 15152 | 15208 | ** 0x00000040 IN operator decisions |
| 15153 | | -** 0x00000080 WhereLoop cost adjustements |
| 15209 | +** 0x00000080 WhereLoop cost adjustments |
| 15154 | 15210 | ** 0x00000100 |
| 15155 | 15211 | ** 0x00000200 Covering index decisions |
| 15156 | 15212 | ** 0x00000400 OR optimization |
| 15157 | 15213 | ** 0x00000800 Index scanner |
| 15158 | 15214 | ** 0x00001000 More details associated with code generation |
| | @@ -16610,20 +16666,20 @@ |
| 16610 | 16666 | #define OP_IdxGE 45 /* jump, synopsis: key=r[P3@P4] */ |
| 16611 | 16667 | #define OP_RowSetRead 46 /* jump, synopsis: r[P3]=rowset(P1) */ |
| 16612 | 16668 | #define OP_RowSetTest 47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 16613 | 16669 | #define OP_Program 48 /* jump0 */ |
| 16614 | 16670 | #define OP_FkIfZero 49 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ |
| 16615 | | -#define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 16616 | | -#define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 16617 | | -#define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 16618 | | -#define OP_Eq 53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 16619 | | -#define OP_Gt 54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 16620 | | -#define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 16621 | | -#define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 16622 | | -#define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 16623 | | -#define OP_ElseEq 58 /* jump, same as TK_ESCAPE */ |
| 16624 | | -#define OP_IfPos 59 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 16671 | +#define OP_IfPos 50 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 16672 | +#define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 16673 | +#define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 16674 | +#define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 16675 | +#define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 16676 | +#define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 16677 | +#define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 16678 | +#define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 16679 | +#define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 16680 | +#define OP_ElseEq 59 /* jump, same as TK_ESCAPE */ |
| 16625 | 16681 | #define OP_IfNotZero 60 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 16626 | 16682 | #define OP_DecrJumpZero 61 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 16627 | 16683 | #define OP_IncrVacuum 62 /* jump */ |
| 16628 | 16684 | #define OP_VNext 63 /* jump */ |
| 16629 | 16685 | #define OP_Filter 64 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */ |
| | @@ -16662,27 +16718,27 @@ |
| 16662 | 16718 | #define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 16663 | 16719 | #define OP_Count 98 /* synopsis: r[P2]=count() */ |
| 16664 | 16720 | #define OP_ReadCookie 99 |
| 16665 | 16721 | #define OP_SetCookie 100 |
| 16666 | 16722 | #define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */ |
| 16667 | | -#define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 16668 | | -#define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 16669 | | -#define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 16670 | | -#define OP_ShiftRight 105 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 16671 | | -#define OP_Add 106 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 16672 | | -#define OP_Subtract 107 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 16673 | | -#define OP_Multiply 108 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 16674 | | -#define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 16675 | | -#define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 16676 | | -#define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 16677 | | -#define OP_OpenRead 112 /* synopsis: root=P2 iDb=P3 */ |
| 16723 | +#define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */ |
| 16724 | +#define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 16725 | +#define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 16726 | +#define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 16727 | +#define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 16728 | +#define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 16729 | +#define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 16730 | +#define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 16731 | +#define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 16732 | +#define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 16733 | +#define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 16678 | 16734 | #define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */ |
| 16679 | | -#define OP_BitNot 114 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 16680 | | -#define OP_OpenDup 115 |
| 16735 | +#define OP_OpenDup 114 |
| 16736 | +#define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 16681 | 16737 | #define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */ |
| 16682 | | -#define OP_String8 117 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 16683 | | -#define OP_OpenEphemeral 118 /* synopsis: nColumn=P2 */ |
| 16738 | +#define OP_OpenEphemeral 117 /* synopsis: nColumn=P2 */ |
| 16739 | +#define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 16684 | 16740 | #define OP_SorterOpen 119 |
| 16685 | 16741 | #define OP_SequenceTest 120 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 16686 | 16742 | #define OP_OpenPseudo 121 /* synopsis: P3 columns in r[P2] */ |
| 16687 | 16743 | #define OP_Close 122 |
| 16688 | 16744 | #define OP_ColumnsUsed 123 |
| | @@ -16713,12 +16769,12 @@ |
| 16713 | 16769 | #define OP_SqlExec 148 |
| 16714 | 16770 | #define OP_ParseSchema 149 |
| 16715 | 16771 | #define OP_LoadAnalysis 150 |
| 16716 | 16772 | #define OP_DropTable 151 |
| 16717 | 16773 | #define OP_DropIndex 152 |
| 16718 | | -#define OP_Real 153 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 16719 | | -#define OP_DropTrigger 154 |
| 16774 | +#define OP_DropTrigger 153 |
| 16775 | +#define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 16720 | 16776 | #define OP_IntegrityCk 155 |
| 16721 | 16777 | #define OP_RowSetAdd 156 /* synopsis: rowset(P1)=r[P2] */ |
| 16722 | 16778 | #define OP_Param 157 |
| 16723 | 16779 | #define OP_FkCounter 158 /* synopsis: fkctr[P1]+=P2 */ |
| 16724 | 16780 | #define OP_MemMax 159 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| | @@ -16770,24 +16826,24 @@ |
| 16770 | 16826 | /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\ |
| 16771 | 16827 | /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\ |
| 16772 | 16828 | /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\ |
| 16773 | 16829 | /* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x41, 0x41,\ |
| 16774 | 16830 | /* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\ |
| 16775 | | -/* 48 */ 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 16776 | | -/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01, 0x41,\ |
| 16831 | +/* 48 */ 0x81, 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 16832 | +/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x41,\ |
| 16777 | 16833 | /* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\ |
| 16778 | 16834 | /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\ |
| 16779 | 16835 | /* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\ |
| 16780 | 16836 | /* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40, 0x00,\ |
| 16781 | | -/* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26, 0x26,\ |
| 16837 | +/* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x40, 0x26,\ |
| 16782 | 16838 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 16783 | | -/* 112 */ 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40, 0x00,\ |
| 16839 | +/* 112 */ 0x26, 0x00, 0x40, 0x12, 0x40, 0x40, 0x10, 0x00,\ |
| 16784 | 16840 | /* 120 */ 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10, 0x10,\ |
| 16785 | 16841 | /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\ |
| 16786 | 16842 | /* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\ |
| 16787 | 16843 | /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 16788 | | -/* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 16844 | +/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 16789 | 16845 | /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16790 | 16846 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ |
| 16791 | 16847 | /* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12, 0x00,\ |
| 16792 | 16848 | /* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,} |
| 16793 | 16849 | |
| | @@ -17826,11 +17882,11 @@ |
| 17826 | 17882 | #define SQLITE_OmitNoopJoin 0x00000100 /* Omit unused tables in joins */ |
| 17827 | 17883 | #define SQLITE_CountOfView 0x00000200 /* The count-of-view optimization */ |
| 17828 | 17884 | #define SQLITE_CursorHints 0x00000400 /* Add OP_CursorHint opcodes */ |
| 17829 | 17885 | #define SQLITE_Stat4 0x00000800 /* Use STAT4 data */ |
| 17830 | 17886 | /* TH3 expects this value ^^^^^^^^^^ to be 0x0000800. Don't change it */ |
| 17831 | | -#define SQLITE_PushDown 0x00001000 /* The push-down optimization */ |
| 17887 | +#define SQLITE_PushDown 0x00001000 /* WHERE-clause push-down opt */ |
| 17832 | 17888 | #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */ |
| 17833 | 17889 | #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ |
| 17834 | 17890 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ |
| 17835 | 17891 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ |
| 17836 | 17892 | #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ |
| | @@ -19232,10 +19288,11 @@ |
| 19232 | 19288 | unsigned notCte :1; /* This item may not match a CTE */ |
| 19233 | 19289 | unsigned isUsing :1; /* u3.pUsing is valid */ |
| 19234 | 19290 | unsigned isOn :1; /* u3.pOn was once valid and non-NULL */ |
| 19235 | 19291 | unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */ |
| 19236 | 19292 | unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ |
| 19293 | + unsigned rowidUsed :1; /* The ROWID of this table is referenced */ |
| 19237 | 19294 | } fg; |
| 19238 | 19295 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 19239 | 19296 | union { |
| 19240 | 19297 | Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */ |
| 19241 | 19298 | IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */ |
| | @@ -19307,11 +19364,11 @@ |
| 19307 | 19364 | #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ |
| 19308 | 19365 | #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ |
| 19309 | 19366 | #define WHERE_AGG_DISTINCT 0x0400 /* Query is "SELECT agg(DISTINCT ...)" */ |
| 19310 | 19367 | #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ |
| 19311 | 19368 | #define WHERE_RIGHT_JOIN 0x1000 /* Processing a RIGHT JOIN */ |
| 19312 | | - /* 0x2000 not currently used */ |
| 19369 | +#define WHERE_KEEP_ALL_JOINS 0x2000 /* Do not do the omit-noop-join opt */ |
| 19313 | 19370 | #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ |
| 19314 | 19371 | /* 0x8000 not currently used */ |
| 19315 | 19372 | |
| 19316 | 19373 | /* Allowed return values from sqlite3WhereIsDistinct() |
| 19317 | 19374 | */ |
| | @@ -19379,11 +19436,11 @@ |
| 19379 | 19436 | #define NC_UEList 0x000080 /* True if uNC.pEList is used */ |
| 19380 | 19437 | #define NC_UAggInfo 0x000100 /* True if uNC.pAggInfo is used */ |
| 19381 | 19438 | #define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */ |
| 19382 | 19439 | #define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */ |
| 19383 | 19440 | #define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */ |
| 19384 | | -#define NC_Complex 0x002000 /* True if a function or subquery seen */ |
| 19441 | +/* 0x002000 // available for reuse */ |
| 19385 | 19442 | #define NC_AllowWin 0x004000 /* Window functions are allowed here */ |
| 19386 | 19443 | #define NC_HasWin 0x008000 /* One or more window functions seen */ |
| 19387 | 19444 | #define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */ |
| 19388 | 19445 | #define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */ |
| 19389 | 19446 | #define NC_FromDDL 0x040000 /* SQL text comes from sqlite_schema */ |
| | @@ -19500,15 +19557,16 @@ |
| 19500 | 19557 | #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */ |
| 19501 | 19558 | #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ |
| 19502 | 19559 | #define SF_View 0x0200000 /* SELECT statement is a view */ |
| 19503 | 19560 | #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ |
| 19504 | 19561 | #define SF_UFSrcCheck 0x0800000 /* Check pSrc as required by UPDATE...FROM */ |
| 19505 | | -#define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ |
| 19562 | +#define SF_PushDown 0x1000000 /* Modified by WHERE-clause push-down opt */ |
| 19506 | 19563 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ |
| 19507 | 19564 | #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ |
| 19508 | 19565 | #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */ |
| 19509 | 19566 | #define SF_UpdateFrom 0x10000000 /* Query originates with UPDATE FROM */ |
| 19567 | +#define SF_Correlated 0x20000000 /* True if references the outer context */ |
| 19510 | 19568 | |
| 19511 | 19569 | /* True if S exists and has SF_NestedFrom */ |
| 19512 | 19570 | #define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0) |
| 19513 | 19571 | |
| 19514 | 19572 | /* |
| | @@ -19537,11 +19595,15 @@ |
| 19537 | 19595 | ** of the query. This destination implies "LIMIT 1". |
| 19538 | 19596 | ** |
| 19539 | 19597 | ** SRT_Set The result must be a single column. Store each |
| 19540 | 19598 | ** row of result as the key in table pDest->iSDParm. |
| 19541 | 19599 | ** Apply the affinity pDest->affSdst before storing |
| 19542 | | -** results. Used to implement "IN (SELECT ...)". |
| 19600 | +** results. if pDest->iSDParm2 is positive, then it is |
| 19601 | +** a regsiter holding a Bloom filter for the IN operator |
| 19602 | +** that should be populated in addition to the |
| 19603 | +** pDest->iSDParm table. This SRT is used to |
| 19604 | +** implement "IN (SELECT ...)". |
| 19543 | 19605 | ** |
| 19544 | 19606 | ** SRT_EphemTab Create an temporary table pDest->iSDParm and store |
| 19545 | 19607 | ** the result there. The cursor is left open after |
| 19546 | 19608 | ** returning. This is like SRT_Table except that |
| 19547 | 19609 | ** this destination uses OP_OpenEphemeral to create |
| | @@ -20040,11 +20102,11 @@ |
| 20040 | 20102 | int iRetReg; /* Register array for holding a row of RETURNING */ |
| 20041 | 20103 | char zName[40]; /* Name of trigger: "sqlite_returning_%p" */ |
| 20042 | 20104 | }; |
| 20043 | 20105 | |
| 20044 | 20106 | /* |
| 20045 | | -** An objected used to accumulate the text of a string where we |
| 20107 | +** An object used to accumulate the text of a string where we |
| 20046 | 20108 | ** do not necessarily know how big the string will be in the end. |
| 20047 | 20109 | */ |
| 20048 | 20110 | struct sqlite3_str { |
| 20049 | 20111 | sqlite3 *db; /* Optional database for lookaside. Can be NULL */ |
| 20050 | 20112 | char *zText; /* The string collected so far */ |
| | @@ -20054,11 +20116,11 @@ |
| 20054 | 20116 | u8 accError; /* SQLITE_NOMEM or SQLITE_TOOBIG */ |
| 20055 | 20117 | u8 printfFlags; /* SQLITE_PRINTF flags below */ |
| 20056 | 20118 | }; |
| 20057 | 20119 | #define SQLITE_PRINTF_INTERNAL 0x01 /* Internal-use-only converters allowed */ |
| 20058 | 20120 | #define SQLITE_PRINTF_SQLFUNC 0x02 /* SQL function arguments to VXPrintf */ |
| 20059 | | -#define SQLITE_PRINTF_MALLOCED 0x04 /* True if xText is allocated space */ |
| 20121 | +#define SQLITE_PRINTF_MALLOCED 0x04 /* True if zText is allocated space */ |
| 20060 | 20122 | |
| 20061 | 20123 | #define isMalloced(X) (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0) |
| 20062 | 20124 | |
| 20063 | 20125 | /* |
| 20064 | 20126 | ** The following object is the header for an "RCStr" or "reference-counted |
| | @@ -20775,11 +20837,11 @@ |
| 20775 | 20837 | SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); |
| 20776 | 20838 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 20777 | 20839 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 20778 | 20840 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 20779 | 20841 | SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*); |
| 20780 | | -SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20842 | +SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20781 | 20843 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| 20782 | 20844 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 20783 | 20845 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 20784 | 20846 | SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*); |
| 20785 | 20847 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int); |
| | @@ -20943,10 +21005,11 @@ |
| 20943 | 21005 | SQLITE_PRIVATE int sqlite3WhereUsesDeferredSeek(WhereInfo*); |
| 20944 | 21006 | SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int); |
| 20945 | 21007 | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); |
| 20946 | 21008 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
| 20947 | 21009 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 21010 | +SQLITE_PRIVATE void sqlite3ExprToRegister(Expr *pExpr, int iReg); |
| 20948 | 21011 | SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int); |
| 20949 | 21012 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 20950 | 21013 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int); |
| 20951 | 21014 | #endif |
| 20952 | 21015 | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int); |
| | @@ -21001,16 +21064,15 @@ |
| 21001 | 21064 | SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr*); |
| 21002 | 21065 | SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr*); |
| 21003 | 21066 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Parse*,Expr*); |
| 21004 | 21067 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 21005 | 21068 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); |
| 21006 | | -SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); |
| 21007 | | -SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int); |
| 21069 | +SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int,int); |
| 21008 | 21070 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 21009 | 21071 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 21010 | 21072 | #endif |
| 21011 | | -SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 21073 | +SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*, Parse*); |
| 21012 | 21074 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 21013 | 21075 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 21014 | 21076 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 21015 | 21077 | SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab); |
| 21016 | 21078 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( |
| | @@ -21187,11 +21249,13 @@ |
| 21187 | 21249 | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); |
| 21188 | 21250 | SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); |
| 21189 | 21251 | SQLITE_PRIVATE void sqlite3Error(sqlite3*,int); |
| 21190 | 21252 | SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*); |
| 21191 | 21253 | SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int); |
| 21254 | +#if !defined(SQLITE_OMIT_BLOB_LITERAL) |
| 21192 | 21255 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 21256 | +#endif |
| 21193 | 21257 | SQLITE_PRIVATE u8 sqlite3HexToInt(int h); |
| 21194 | 21258 | SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
| 21195 | 21259 | |
| 21196 | 21260 | #if defined(SQLITE_NEED_ERR_NAME) |
| 21197 | 21261 | SQLITE_PRIVATE const char *sqlite3ErrName(int); |
| | @@ -24830,12 +24894,12 @@ |
| 24830 | 24894 | } aXformType[] = { |
| 24831 | 24895 | /* 0 */ { 6, "second", 4.6427e+14, 1.0 }, |
| 24832 | 24896 | /* 1 */ { 6, "minute", 7.7379e+12, 60.0 }, |
| 24833 | 24897 | /* 2 */ { 4, "hour", 1.2897e+11, 3600.0 }, |
| 24834 | 24898 | /* 3 */ { 3, "day", 5373485.0, 86400.0 }, |
| 24835 | | - /* 4 */ { 5, "month", 176546.0, 30.0*86400.0 }, |
| 24836 | | - /* 5 */ { 4, "year", 14713.0, 365.0*86400.0 }, |
| 24899 | + /* 4 */ { 5, "month", 176546.0, 2592000.0 }, |
| 24900 | + /* 5 */ { 4, "year", 14713.0, 31536000.0 }, |
| 24837 | 24901 | }; |
| 24838 | 24902 | |
| 24839 | 24903 | /* |
| 24840 | 24904 | ** If the DateTime p is raw number, try to figure out if it is |
| 24841 | 24905 | ** a julian day number of a unix timestamp. Set the p value |
| | @@ -31939,11 +32003,11 @@ |
| 31939 | 32003 | sqlite3_str_appendall(pAccum, pItem->zName); |
| 31940 | 32004 | }else if( pItem->zAlias ){ |
| 31941 | 32005 | sqlite3_str_appendall(pAccum, pItem->zAlias); |
| 31942 | 32006 | }else{ |
| 31943 | 32007 | Select *pSel = pItem->pSelect; |
| 31944 | | - assert( pSel!=0 ); |
| 32008 | + assert( pSel!=0 ); /* Because of tag-20240424-1 */ |
| 31945 | 32009 | if( pSel->selFlags & SF_NestedFrom ){ |
| 31946 | 32010 | sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); |
| 31947 | 32011 | }else if( pSel->selFlags & SF_MultiValue ){ |
| 31948 | 32012 | assert( !pItem->fg.isTabFunc && !pItem->fg.isIndexedBy ); |
| 31949 | 32013 | sqlite3_str_appendf(pAccum, "%u-ROW VALUES CLAUSE", |
| | @@ -32722,12 +32786,14 @@ |
| 32722 | 32786 | char zLine[1000]; |
| 32723 | 32787 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 32724 | 32788 | x.printfFlags |= SQLITE_PRINTF_INTERNAL; |
| 32725 | 32789 | sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); |
| 32726 | 32790 | if( pItem->pTab ){ |
| 32727 | | - sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", |
| 32728 | | - pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); |
| 32791 | + sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s", |
| 32792 | + pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, |
| 32793 | + pItem->colUsed, |
| 32794 | + pItem->fg.rowidUsed ? "+rowid" : ""); |
| 32729 | 32795 | } |
| 32730 | 32796 | if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){ |
| 32731 | 32797 | sqlite3_str_appendf(&x, " FULL-OUTER-JOIN"); |
| 32732 | 32798 | }else if( pItem->fg.jointype & JT_LEFT ){ |
| 32733 | 32799 | sqlite3_str_appendf(&x, " LEFT-JOIN"); |
| | @@ -32763,16 +32829,18 @@ |
| 32763 | 32829 | if( pItem->fg.isUsing ) n++; |
| 32764 | 32830 | if( pItem->fg.isUsing ){ |
| 32765 | 32831 | sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); |
| 32766 | 32832 | } |
| 32767 | 32833 | if( pItem->pSelect ){ |
| 32834 | + sqlite3TreeViewPush(&pView, i+1<pSrc->nSrc); |
| 32768 | 32835 | if( pItem->pTab ){ |
| 32769 | 32836 | Table *pTab = pItem->pTab; |
| 32770 | 32837 | sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1); |
| 32771 | 32838 | } |
| 32772 | 32839 | assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); |
| 32773 | 32840 | sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0); |
| 32841 | + sqlite3TreeViewPop(&pView); |
| 32774 | 32842 | } |
| 32775 | 32843 | if( pItem->fg.isTabFunc ){ |
| 32776 | 32844 | sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); |
| 32777 | 32845 | } |
| 32778 | 32846 | sqlite3TreeViewPop(&pView); |
| | @@ -32872,11 +32940,11 @@ |
| 32872 | 32940 | } |
| 32873 | 32941 | if( p->pLimit ){ |
| 32874 | 32942 | sqlite3TreeViewItem(pView, "LIMIT", (n--)>0); |
| 32875 | 32943 | sqlite3TreeViewExpr(pView, p->pLimit->pLeft, p->pLimit->pRight!=0); |
| 32876 | 32944 | if( p->pLimit->pRight ){ |
| 32877 | | - sqlite3TreeViewItem(pView, "OFFSET", (n--)>0); |
| 32945 | + sqlite3TreeViewItem(pView, "OFFSET", 0); |
| 32878 | 32946 | sqlite3TreeViewExpr(pView, p->pLimit->pRight, 0); |
| 32879 | 32947 | sqlite3TreeViewPop(&pView); |
| 32880 | 32948 | } |
| 32881 | 32949 | sqlite3TreeViewPop(&pView); |
| 32882 | 32950 | } |
| | @@ -33344,11 +33412,12 @@ |
| 33344 | 33412 | case OE_Abort: zType = "abort"; break; |
| 33345 | 33413 | case OE_Fail: zType = "fail"; break; |
| 33346 | 33414 | case OE_Ignore: zType = "ignore"; break; |
| 33347 | 33415 | } |
| 33348 | 33416 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 33349 | | - sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken); |
| 33417 | + sqlite3TreeViewLine(pView, "RAISE %s", zType); |
| 33418 | + sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 33350 | 33419 | break; |
| 33351 | 33420 | } |
| 33352 | 33421 | #endif |
| 33353 | 33422 | case TK_MATCH: { |
| 33354 | 33423 | sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s", |
| | @@ -33424,13 +33493,14 @@ |
| 33424 | 33493 | }else{ |
| 33425 | 33494 | int i; |
| 33426 | 33495 | sqlite3TreeViewLine(pView, "%s", zLabel); |
| 33427 | 33496 | for(i=0; i<pList->nExpr; i++){ |
| 33428 | 33497 | int j = pList->a[i].u.x.iOrderByCol; |
| 33498 | + u8 sortFlags = pList->a[i].fg.sortFlags; |
| 33429 | 33499 | char *zName = pList->a[i].zEName; |
| 33430 | 33500 | int moreToFollow = i<pList->nExpr - 1; |
| 33431 | | - if( j || zName ){ |
| 33501 | + if( j || zName || sortFlags ){ |
| 33432 | 33502 | sqlite3TreeViewPush(&pView, moreToFollow); |
| 33433 | 33503 | moreToFollow = 0; |
| 33434 | 33504 | sqlite3TreeViewLine(pView, 0); |
| 33435 | 33505 | if( zName ){ |
| 33436 | 33506 | switch( pList->a[i].fg.eEName ){ |
| | @@ -33447,17 +33517,22 @@ |
| 33447 | 33517 | fprintf(stdout, "SPAN(\"%s\") ", zName); |
| 33448 | 33518 | break; |
| 33449 | 33519 | } |
| 33450 | 33520 | } |
| 33451 | 33521 | if( j ){ |
| 33452 | | - fprintf(stdout, "iOrderByCol=%d", j); |
| 33522 | + fprintf(stdout, "iOrderByCol=%d ", j); |
| 33523 | + } |
| 33524 | + if( sortFlags & KEYINFO_ORDER_DESC ){ |
| 33525 | + fprintf(stdout, "DESC "); |
| 33526 | + }else if( sortFlags & KEYINFO_ORDER_BIGNULL ){ |
| 33527 | + fprintf(stdout, "NULLS-LAST"); |
| 33453 | 33528 | } |
| 33454 | 33529 | fprintf(stdout, "\n"); |
| 33455 | 33530 | fflush(stdout); |
| 33456 | 33531 | } |
| 33457 | 33532 | sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow); |
| 33458 | | - if( j || zName ){ |
| 33533 | + if( j || zName || sortFlags ){ |
| 33459 | 33534 | sqlite3TreeViewPop(&pView); |
| 33460 | 33535 | } |
| 33461 | 33536 | } |
| 33462 | 33537 | } |
| 33463 | 33538 | } |
| | @@ -35864,14 +35939,17 @@ |
| 35864 | 35939 | |
| 35865 | 35940 | /* |
| 35866 | 35941 | ** Decode a floating-point value into an approximate decimal |
| 35867 | 35942 | ** representation. |
| 35868 | 35943 | ** |
| 35869 | | -** Round the decimal representation to n significant digits if |
| 35870 | | -** n is positive. Or round to -n signficant digits after the |
| 35871 | | -** decimal point if n is negative. No rounding is performed if |
| 35872 | | -** n is zero. |
| 35944 | +** If iRound<=0 then round to -iRound significant digits to the |
| 35945 | +** the left of the decimal point, or to a maximum of mxRound total |
| 35946 | +** significant digits. |
| 35947 | +** |
| 35948 | +** If iRound>0 round to min(iRound,mxRound) significant digits total. |
| 35949 | +** |
| 35950 | +** mxRound must be positive. |
| 35873 | 35951 | ** |
| 35874 | 35952 | ** The significant digits of the decimal representation are |
| 35875 | 35953 | ** stored in p->z[] which is a often (but not always) a pointer |
| 35876 | 35954 | ** into the middle of p->zBuf[]. There are p->n significant digits. |
| 35877 | 35955 | ** The p->z[] array is *not* zero-terminated. |
| | @@ -35880,10 +35958,12 @@ |
| 35880 | 35958 | int i; |
| 35881 | 35959 | u64 v; |
| 35882 | 35960 | int e, exp = 0; |
| 35883 | 35961 | p->isSpecial = 0; |
| 35884 | 35962 | p->z = p->zBuf; |
| 35963 | + |
| 35964 | + assert( mxRound>0 ); |
| 35885 | 35965 | |
| 35886 | 35966 | /* Convert negative numbers to positive. Deal with Infinity, 0.0, and |
| 35887 | 35967 | ** NaN. */ |
| 35888 | 35968 | if( r<0.0 ){ |
| 35889 | 35969 | p->sign = '-'; |
| | @@ -37167,20 +37247,20 @@ |
| 37167 | 37247 | /* 45 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 37168 | 37248 | /* 46 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 37169 | 37249 | /* 47 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 37170 | 37250 | /* 48 */ "Program" OpHelp(""), |
| 37171 | 37251 | /* 49 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 37172 | | - /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 37173 | | - /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 37174 | | - /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 37175 | | - /* 53 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 37176 | | - /* 54 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 37177 | | - /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 37178 | | - /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 37179 | | - /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 37180 | | - /* 58 */ "ElseEq" OpHelp(""), |
| 37181 | | - /* 59 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 37252 | + /* 50 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 37253 | + /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 37254 | + /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 37255 | + /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 37256 | + /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 37257 | + /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 37258 | + /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 37259 | + /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 37260 | + /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 37261 | + /* 59 */ "ElseEq" OpHelp(""), |
| 37182 | 37262 | /* 60 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 37183 | 37263 | /* 61 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 37184 | 37264 | /* 62 */ "IncrVacuum" OpHelp(""), |
| 37185 | 37265 | /* 63 */ "VNext" OpHelp(""), |
| 37186 | 37266 | /* 64 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"), |
| | @@ -37219,27 +37299,27 @@ |
| 37219 | 37299 | /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 37220 | 37300 | /* 98 */ "Count" OpHelp("r[P2]=count()"), |
| 37221 | 37301 | /* 99 */ "ReadCookie" OpHelp(""), |
| 37222 | 37302 | /* 100 */ "SetCookie" OpHelp(""), |
| 37223 | 37303 | /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 37224 | | - /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 37225 | | - /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 37226 | | - /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 37227 | | - /* 105 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 37228 | | - /* 106 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 37229 | | - /* 107 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 37230 | | - /* 108 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 37231 | | - /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 37232 | | - /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 37233 | | - /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 37234 | | - /* 112 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 37304 | + /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 37305 | + /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 37306 | + /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 37307 | + /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 37308 | + /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 37309 | + /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 37310 | + /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 37311 | + /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 37312 | + /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 37313 | + /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 37314 | + /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 37235 | 37315 | /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 37236 | | - /* 114 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 37237 | | - /* 115 */ "OpenDup" OpHelp(""), |
| 37316 | + /* 114 */ "OpenDup" OpHelp(""), |
| 37317 | + /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 37238 | 37318 | /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 37239 | | - /* 117 */ "String8" OpHelp("r[P2]='P4'"), |
| 37240 | | - /* 118 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 37319 | + /* 117 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 37320 | + /* 118 */ "String8" OpHelp("r[P2]='P4'"), |
| 37241 | 37321 | /* 119 */ "SorterOpen" OpHelp(""), |
| 37242 | 37322 | /* 120 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 37243 | 37323 | /* 121 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 37244 | 37324 | /* 122 */ "Close" OpHelp(""), |
| 37245 | 37325 | /* 123 */ "ColumnsUsed" OpHelp(""), |
| | @@ -37270,12 +37350,12 @@ |
| 37270 | 37350 | /* 148 */ "SqlExec" OpHelp(""), |
| 37271 | 37351 | /* 149 */ "ParseSchema" OpHelp(""), |
| 37272 | 37352 | /* 150 */ "LoadAnalysis" OpHelp(""), |
| 37273 | 37353 | /* 151 */ "DropTable" OpHelp(""), |
| 37274 | 37354 | /* 152 */ "DropIndex" OpHelp(""), |
| 37275 | | - /* 153 */ "Real" OpHelp("r[P2]=P4"), |
| 37276 | | - /* 154 */ "DropTrigger" OpHelp(""), |
| 37355 | + /* 153 */ "DropTrigger" OpHelp(""), |
| 37356 | + /* 154 */ "Real" OpHelp("r[P2]=P4"), |
| 37277 | 37357 | /* 155 */ "IntegrityCk" OpHelp(""), |
| 37278 | 37358 | /* 156 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 37279 | 37359 | /* 157 */ "Param" OpHelp(""), |
| 37280 | 37360 | /* 158 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 37281 | 37361 | /* 159 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| | @@ -40577,30 +40657,26 @@ |
| 40577 | 40657 | */ |
| 40578 | 40658 | #define DOTLOCK_SUFFIX ".lock" |
| 40579 | 40659 | |
| 40580 | 40660 | /* |
| 40581 | 40661 | ** This routine checks if there is a RESERVED lock held on the specified |
| 40582 | | -** file by this or any other process. If such a lock is held, set *pResOut |
| 40583 | | -** to a non-zero value otherwise *pResOut is set to zero. The return value |
| 40584 | | -** is set to SQLITE_OK unless an I/O error occurs during lock checking. |
| 40585 | | -** |
| 40586 | | -** In dotfile locking, either a lock exists or it does not. So in this |
| 40587 | | -** variation of CheckReservedLock(), *pResOut is set to true if any lock |
| 40588 | | -** is held on the file and false if the file is unlocked. |
| 40662 | +** file by this or any other process. If the caller holds a SHARED |
| 40663 | +** or greater lock when it is called, then it is assumed that no other |
| 40664 | +** client may hold RESERVED. Or, if the caller holds no lock, then it |
| 40665 | +** is assumed another client holds RESERVED if the lock-file exists. |
| 40589 | 40666 | */ |
| 40590 | 40667 | static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) { |
| 40591 | | - int rc = SQLITE_OK; |
| 40592 | | - int reserved = 0; |
| 40593 | 40668 | unixFile *pFile = (unixFile*)id; |
| 40594 | | - |
| 40595 | 40669 | SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); |
| 40596 | 40670 | |
| 40597 | | - assert( pFile ); |
| 40598 | | - reserved = osAccess((const char*)pFile->lockingContext, 0)==0; |
| 40599 | | - OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved)); |
| 40600 | | - *pResOut = reserved; |
| 40601 | | - return rc; |
| 40671 | + if( pFile->eFileLock>=SHARED_LOCK ){ |
| 40672 | + *pResOut = 0; |
| 40673 | + }else{ |
| 40674 | + *pResOut = osAccess((const char*)pFile->lockingContext, 0)==0; |
| 40675 | + } |
| 40676 | + OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, 0, *pResOut)); |
| 40677 | + return SQLITE_OK; |
| 40602 | 40678 | } |
| 40603 | 40679 | |
| 40604 | 40680 | /* |
| 40605 | 40681 | ** Lock the file with the lock specified by parameter eFileLock - one |
| 40606 | 40682 | ** of the following: |
| | @@ -42285,11 +42361,11 @@ |
| 42285 | 42361 | } |
| 42286 | 42362 | } |
| 42287 | 42363 | |
| 42288 | 42364 | /* Forward declaration */ |
| 42289 | 42365 | static int unixGetTempname(int nBuf, char *zBuf); |
| 42290 | | -#ifndef SQLITE_OMIT_WAL |
| 42366 | +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) |
| 42291 | 42367 | static int unixFcntlExternalReader(unixFile*, int*); |
| 42292 | 42368 | #endif |
| 42293 | 42369 | |
| 42294 | 42370 | /* |
| 42295 | 42371 | ** Information and control of an open file handle. |
| | @@ -42412,11 +42488,11 @@ |
| 42412 | 42488 | return proxyFileControl(id,op,pArg); |
| 42413 | 42489 | } |
| 42414 | 42490 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ |
| 42415 | 42491 | |
| 42416 | 42492 | case SQLITE_FCNTL_EXTERNAL_READER: { |
| 42417 | | -#ifndef SQLITE_OMIT_WAL |
| 42493 | +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) |
| 42418 | 42494 | return unixFcntlExternalReader((unixFile*)id, (int*)pArg); |
| 42419 | 42495 | #else |
| 42420 | 42496 | *(int*)pArg = 0; |
| 42421 | 42497 | return SQLITE_OK; |
| 42422 | 42498 | #endif |
| | @@ -42585,11 +42661,11 @@ |
| 42585 | 42661 | #endif |
| 42586 | 42662 | } |
| 42587 | 42663 | |
| 42588 | 42664 | #endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */ |
| 42589 | 42665 | |
| 42590 | | -#ifndef SQLITE_OMIT_WAL |
| 42666 | +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) |
| 42591 | 42667 | |
| 42592 | 42668 | /* |
| 42593 | 42669 | ** Object used to represent an shared memory buffer. |
| 42594 | 42670 | ** |
| 42595 | 42671 | ** When multiple threads all reference the same wal-index, each thread |
| | @@ -64135,11 +64211,11 @@ |
| 64135 | 64211 | /* |
| 64136 | 64212 | ** Return the file handle for the journal file (if it exists). |
| 64137 | 64213 | ** This will be either the rollback journal or the WAL file. |
| 64138 | 64214 | */ |
| 64139 | 64215 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ |
| 64140 | | -#if SQLITE_OMIT_WAL |
| 64216 | +#ifdef SQLITE_OMIT_WAL |
| 64141 | 64217 | return pPager->jfd; |
| 64142 | 64218 | #else |
| 64143 | 64219 | return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd; |
| 64144 | 64220 | #endif |
| 64145 | 64221 | } |
| | @@ -75626,10 +75702,16 @@ |
| 75626 | 75702 | } |
| 75627 | 75703 | } |
| 75628 | 75704 | memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); |
| 75629 | 75705 | pCur->curFlags |= BTCF_ValidOvfl; |
| 75630 | 75706 | }else{ |
| 75707 | + /* Sanity check the validity of the overflow page cache */ |
| 75708 | + assert( pCur->aOverflow[0]==nextPage |
| 75709 | + || pCur->aOverflow[0]==0 |
| 75710 | + || CORRUPT_DB ); |
| 75711 | + assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 ); |
| 75712 | + |
| 75631 | 75713 | /* If the overflow page-list cache has been allocated and the |
| 75632 | 75714 | ** entry for the first required overflow page is valid, skip |
| 75633 | 75715 | ** directly to it. |
| 75634 | 75716 | */ |
| 75635 | 75717 | if( pCur->aOverflow[offset/ovflSize] ){ |
| | @@ -76106,10 +76188,27 @@ |
| 76106 | 76188 | *pRes = 1; |
| 76107 | 76189 | rc = SQLITE_OK; |
| 76108 | 76190 | } |
| 76109 | 76191 | return rc; |
| 76110 | 76192 | } |
| 76193 | + |
| 76194 | +#ifdef SQLITE_DEBUG |
| 76195 | +/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that |
| 76196 | +** this flags are true for a consistent database. |
| 76197 | +** |
| 76198 | +** This routine is is called from within assert() statements only. |
| 76199 | +** It is an internal verification routine and does not appear in production |
| 76200 | +** builds. |
| 76201 | +*/ |
| 76202 | +static int cursorIsAtLastEntry(BtCursor *pCur){ |
| 76203 | + int ii; |
| 76204 | + for(ii=0; ii<pCur->iPage; ii++){ |
| 76205 | + if( pCur->aiIdx[ii]!=pCur->apPage[ii]->nCell ) return 0; |
| 76206 | + } |
| 76207 | + return pCur->ix==pCur->pPage->nCell-1 && pCur->pPage->leaf!=0; |
| 76208 | +} |
| 76209 | +#endif |
| 76111 | 76210 | |
| 76112 | 76211 | /* Move the cursor to the last entry in the table. Return SQLITE_OK |
| 76113 | 76212 | ** on success. Set *pRes to 0 if the cursor actually points to something |
| 76114 | 76213 | ** or set *pRes to 1 if the table is empty. |
| 76115 | 76214 | */ |
| | @@ -76135,22 +76234,11 @@ |
| 76135 | 76234 | assert( cursorOwnsBtShared(pCur) ); |
| 76136 | 76235 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 76137 | 76236 | |
| 76138 | 76237 | /* If the cursor already points to the last entry, this is a no-op. */ |
| 76139 | 76238 | if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){ |
| 76140 | | -#ifdef SQLITE_DEBUG |
| 76141 | | - /* This block serves to assert() that the cursor really does point |
| 76142 | | - ** to the last entry in the b-tree. */ |
| 76143 | | - int ii; |
| 76144 | | - for(ii=0; ii<pCur->iPage; ii++){ |
| 76145 | | - assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); |
| 76146 | | - } |
| 76147 | | - assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB ); |
| 76148 | | - testcase( pCur->ix!=pCur->pPage->nCell-1 ); |
| 76149 | | - /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */ |
| 76150 | | - assert( pCur->pPage->leaf ); |
| 76151 | | -#endif |
| 76239 | + assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB ); |
| 76152 | 76240 | *pRes = 0; |
| 76153 | 76241 | return SQLITE_OK; |
| 76154 | 76242 | } |
| 76155 | 76243 | return btreeLast(pCur, pRes); |
| 76156 | 76244 | } |
| | @@ -76199,10 +76287,11 @@ |
| 76199 | 76287 | *pRes = 0; |
| 76200 | 76288 | return SQLITE_OK; |
| 76201 | 76289 | } |
| 76202 | 76290 | if( pCur->info.nKey<intKey ){ |
| 76203 | 76291 | if( (pCur->curFlags & BTCF_AtLast)!=0 ){ |
| 76292 | + assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB ); |
| 76204 | 76293 | *pRes = -1; |
| 76205 | 76294 | return SQLITE_OK; |
| 76206 | 76295 | } |
| 76207 | 76296 | /* If the requested key is one more than the previous key, then |
| 76208 | 76297 | ** try to get there using sqlite3BtreeNext() rather than a full |
| | @@ -78037,11 +78126,12 @@ |
| 78037 | 78126 | assert( i<iEnd ); |
| 78038 | 78127 | j = get2byte(&aData[hdr+5]); |
| 78039 | 78128 | if( j>(u32)usableSize ){ j = 0; } |
| 78040 | 78129 | memcpy(&pTmp[j], &aData[j], usableSize - j); |
| 78041 | 78130 | |
| 78042 | | - for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} |
| 78131 | + assert( pCArray->ixNx[NB*2-1]>i ); |
| 78132 | + for(k=0; pCArray->ixNx[k]<=i; k++){} |
| 78043 | 78133 | pSrcEnd = pCArray->apEnd[k]; |
| 78044 | 78134 | |
| 78045 | 78135 | pData = pEnd; |
| 78046 | 78136 | while( 1/*exit by break*/ ){ |
| 78047 | 78137 | u8 *pCell = pCArray->apCell[i]; |
| | @@ -78120,11 +78210,12 @@ |
| 78120 | 78210 | int iEnd = iFirst + nCell; /* End of loop. One past last cell to ins */ |
| 78121 | 78211 | int k; /* Current slot in pCArray->apEnd[] */ |
| 78122 | 78212 | u8 *pEnd; /* Maximum extent of cell data */ |
| 78123 | 78213 | assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */ |
| 78124 | 78214 | if( iEnd<=iFirst ) return 0; |
| 78125 | | - for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i ; k++){} |
| 78215 | + assert( pCArray->ixNx[NB*2-1]>i ); |
| 78216 | + for(k=0; pCArray->ixNx[k]<=i ; k++){} |
| 78126 | 78217 | pEnd = pCArray->apEnd[k]; |
| 78127 | 78218 | while( 1 /*Exit by break*/ ){ |
| 78128 | 78219 | int sz, rc; |
| 78129 | 78220 | u8 *pSlot; |
| 78130 | 78221 | assert( pCArray->szCell[i]!=0 ); |
| | @@ -78405,10 +78496,11 @@ |
| 78405 | 78496 | b.pRef = pPage; |
| 78406 | 78497 | b.apCell = &pCell; |
| 78407 | 78498 | b.szCell = &szCell; |
| 78408 | 78499 | b.apEnd[0] = pPage->aDataEnd; |
| 78409 | 78500 | b.ixNx[0] = 2; |
| 78501 | + b.ixNx[NB*2-1] = 0x7fffffff; |
| 78410 | 78502 | rc = rebuildPage(&b, 0, 1, pNew); |
| 78411 | 78503 | if( NEVER(rc) ){ |
| 78412 | 78504 | releasePage(pNew); |
| 78413 | 78505 | return rc; |
| 78414 | 78506 | } |
| | @@ -78640,11 +78732,13 @@ |
| 78640 | 78732 | u8 abDone[NB+2]; /* True after i'th new page is populated */ |
| 78641 | 78733 | Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */ |
| 78642 | 78734 | CellArray b; /* Parsed information on cells being balanced */ |
| 78643 | 78735 | |
| 78644 | 78736 | memset(abDone, 0, sizeof(abDone)); |
| 78645 | | - memset(&b, 0, sizeof(b)); |
| 78737 | + assert( sizeof(b) - sizeof(b.ixNx) == offsetof(CellArray,ixNx) ); |
| 78738 | + memset(&b, 0, sizeof(b)-sizeof(b.ixNx[0])); |
| 78739 | + b.ixNx[NB*2-1] = 0x7fffffff; |
| 78646 | 78740 | pBt = pParent->pBt; |
| 78647 | 78741 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 78648 | 78742 | assert( sqlite3PagerIswriteable(pParent->pDbPage) ); |
| 78649 | 78743 | |
| 78650 | 78744 | /* At this point pParent may have at most one overflow cell. And if |
| | @@ -79231,11 +79325,12 @@ |
| 79231 | 79325 | } |
| 79232 | 79326 | } |
| 79233 | 79327 | iOvflSpace += sz; |
| 79234 | 79328 | assert( sz<=pBt->maxLocal+23 ); |
| 79235 | 79329 | assert( iOvflSpace <= (int)pBt->pageSize ); |
| 79236 | | - for(k=0; ALWAYS(k<NB*2) && b.ixNx[k]<=j; k++){} |
| 79330 | + assert( b.ixNx[NB*2-1]>j ); |
| 79331 | + for(k=0; b.ixNx[k]<=j; k++){} |
| 79237 | 79332 | pSrcEnd = b.apEnd[k]; |
| 79238 | 79333 | if( SQLITE_OVERFLOW(pSrcEnd, pCell, pCell+sz) ){ |
| 79239 | 79334 | rc = SQLITE_CORRUPT_BKPT; |
| 79240 | 79335 | goto balance_cleanup; |
| 79241 | 79336 | } |
| | @@ -80004,11 +80099,11 @@ |
| 80004 | 80099 | dropCell(pPage, idx, info.nSize, &rc); |
| 80005 | 80100 | if( rc ) goto end_insert; |
| 80006 | 80101 | }else if( loc<0 && pPage->nCell>0 ){ |
| 80007 | 80102 | assert( pPage->leaf ); |
| 80008 | 80103 | idx = ++pCur->ix; |
| 80009 | | - pCur->curFlags &= ~BTCF_ValidNKey; |
| 80104 | + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 80010 | 80105 | }else{ |
| 80011 | 80106 | assert( pPage->leaf ); |
| 80012 | 80107 | } |
| 80013 | 80108 | rc = insertCellFast(pPage, idx, newCell, szNew); |
| 80014 | 80109 | assert( pPage->nOverflow==0 || rc==SQLITE_OK ); |
| | @@ -80034,11 +80129,11 @@ |
| 80034 | 80129 | ** larger than the largest existing key, it is possible to insert the |
| 80035 | 80130 | ** row without seeking the cursor. This can be a big performance boost. |
| 80036 | 80131 | */ |
| 80037 | 80132 | if( pPage->nOverflow ){ |
| 80038 | 80133 | assert( rc==SQLITE_OK ); |
| 80039 | | - pCur->curFlags &= ~(BTCF_ValidNKey); |
| 80134 | + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 80040 | 80135 | rc = balance(pCur); |
| 80041 | 80136 | |
| 80042 | 80137 | /* Must make sure nOverflow is reset to zero even if the balance() |
| 80043 | 80138 | ** fails. Internal data structure corruption will result otherwise. |
| 80044 | 80139 | ** Also, set the cursor state to invalid. This stops saveCursorPosition() |
| | @@ -84658,21 +84753,21 @@ |
| 84658 | 84753 | int nRec, /* Size of buffer pRec in bytes */ |
| 84659 | 84754 | int iCol, /* Column to extract */ |
| 84660 | 84755 | sqlite3_value **ppVal /* OUT: Extracted value */ |
| 84661 | 84756 | ){ |
| 84662 | 84757 | u32 t = 0; /* a column type code */ |
| 84663 | | - int nHdr; /* Size of the header in the record */ |
| 84664 | | - int iHdr; /* Next unread header byte */ |
| 84665 | | - int iField; /* Next unread data byte */ |
| 84666 | | - int szField = 0; /* Size of the current data field */ |
| 84758 | + u32 nHdr; /* Size of the header in the record */ |
| 84759 | + u32 iHdr; /* Next unread header byte */ |
| 84760 | + i64 iField; /* Next unread data byte */ |
| 84761 | + u32 szField = 0; /* Size of the current data field */ |
| 84667 | 84762 | int i; /* Column index */ |
| 84668 | 84763 | u8 *a = (u8*)pRec; /* Typecast byte array */ |
| 84669 | 84764 | Mem *pMem = *ppVal; /* Write result into this Mem object */ |
| 84670 | 84765 | |
| 84671 | 84766 | assert( iCol>0 ); |
| 84672 | 84767 | iHdr = getVarint32(a, nHdr); |
| 84673 | | - if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT; |
| 84768 | + if( nHdr>(u32)nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT; |
| 84674 | 84769 | iField = nHdr; |
| 84675 | 84770 | for(i=0; i<=iCol; i++){ |
| 84676 | 84771 | iHdr += getVarint32(&a[iHdr], t); |
| 84677 | 84772 | testcase( iHdr==nHdr ); |
| 84678 | 84773 | testcase( iHdr==nHdr+1 ); |
| | @@ -88119,11 +88214,11 @@ |
| 88119 | 88214 | } |
| 88120 | 88215 | } |
| 88121 | 88216 | |
| 88122 | 88217 | /* Check for immediate foreign key violations. */ |
| 88123 | 88218 | if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){ |
| 88124 | | - sqlite3VdbeCheckFk(p, 0); |
| 88219 | + (void)sqlite3VdbeCheckFk(p, 0); |
| 88125 | 88220 | } |
| 88126 | 88221 | |
| 88127 | 88222 | /* If the auto-commit flag is set and this is the only active writer |
| 88128 | 88223 | ** VM, then we do either a commit or rollback of the current transaction. |
| 88129 | 88224 | ** |
| | @@ -90100,11 +90195,12 @@ |
| 90100 | 90195 | */ |
| 90101 | 90196 | SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ |
| 90102 | 90197 | assert( iVar>0 ); |
| 90103 | 90198 | if( v ){ |
| 90104 | 90199 | Mem *pMem = &v->aVar[iVar-1]; |
| 90105 | | - assert( (v->db->flags & SQLITE_EnableQPSG)==0 ); |
| 90200 | + assert( (v->db->flags & SQLITE_EnableQPSG)==0 |
| 90201 | + || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 ); |
| 90106 | 90202 | if( 0==(pMem->flags & MEM_Null) ){ |
| 90107 | 90203 | sqlite3_value *pRet = sqlite3ValueNew(v->db); |
| 90108 | 90204 | if( pRet ){ |
| 90109 | 90205 | sqlite3VdbeMemCopy((Mem *)pRet, pMem); |
| 90110 | 90206 | sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8); |
| | @@ -90120,11 +90216,12 @@ |
| 90120 | 90216 | ** to sqlite3_reoptimize() that re-preparing the statement may result |
| 90121 | 90217 | ** in a better query plan. |
| 90122 | 90218 | */ |
| 90123 | 90219 | SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ |
| 90124 | 90220 | assert( iVar>0 ); |
| 90125 | | - assert( (v->db->flags & SQLITE_EnableQPSG)==0 ); |
| 90221 | + assert( (v->db->flags & SQLITE_EnableQPSG)==0 |
| 90222 | + || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 ); |
| 90126 | 90223 | if( iVar>=32 ){ |
| 90127 | 90224 | v->expmask |= 0x80000000; |
| 90128 | 90225 | }else{ |
| 90129 | 90226 | v->expmask |= ((u32)1 << (iVar-1)); |
| 90130 | 90227 | } |
| | @@ -94190,11 +94287,13 @@ |
| 94190 | 94287 | |
| 94191 | 94288 | /* Opcode: EndCoroutine P1 * * * * |
| 94192 | 94289 | ** |
| 94193 | 94290 | ** The instruction at the address in register P1 is a Yield. |
| 94194 | 94291 | ** Jump to the P2 parameter of that Yield. |
| 94195 | | -** After the jump, register P1 becomes undefined. |
| 94292 | +** After the jump, the value register P1 is left with a value |
| 94293 | +** such that subsequent OP_Yields go back to the this same |
| 94294 | +** OP_EndCoroutine instruction. |
| 94196 | 94295 | ** |
| 94197 | 94296 | ** See also: InitCoroutine |
| 94198 | 94297 | */ |
| 94199 | 94298 | case OP_EndCoroutine: { /* in1 */ |
| 94200 | 94299 | VdbeOp *pCaller; |
| | @@ -94202,12 +94301,12 @@ |
| 94202 | 94301 | assert( pIn1->flags==MEM_Int ); |
| 94203 | 94302 | assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp ); |
| 94204 | 94303 | pCaller = &aOp[pIn1->u.i]; |
| 94205 | 94304 | assert( pCaller->opcode==OP_Yield ); |
| 94206 | 94305 | assert( pCaller->p2>=0 && pCaller->p2<p->nOp ); |
| 94306 | + pIn1->u.i = (int)(pOp - p->aOp) - 1; |
| 94207 | 94307 | pOp = &aOp[pCaller->p2 - 1]; |
| 94208 | | - pIn1->flags = MEM_Undefined; |
| 94209 | 94308 | break; |
| 94210 | 94309 | } |
| 94211 | 94310 | |
| 94212 | 94311 | /* Opcode: Yield P1 P2 * * * |
| 94213 | 94312 | ** |
| | @@ -94250,11 +94349,11 @@ |
| 94250 | 94349 | if( (pIn3->flags & MEM_Null)==0 ) break; |
| 94251 | 94350 | /* Fall through into OP_Halt */ |
| 94252 | 94351 | /* no break */ deliberate_fall_through |
| 94253 | 94352 | } |
| 94254 | 94353 | |
| 94255 | | -/* Opcode: Halt P1 P2 * P4 P5 |
| 94354 | +/* Opcode: Halt P1 P2 P3 P4 P5 |
| 94256 | 94355 | ** |
| 94257 | 94356 | ** Exit immediately. All open cursors, etc are closed |
| 94258 | 94357 | ** automatically. |
| 94259 | 94358 | ** |
| 94260 | 94359 | ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(), |
| | @@ -94263,22 +94362,26 @@ |
| 94263 | 94362 | ** whether or not to rollback the current transaction. Do not rollback |
| 94264 | 94363 | ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort, |
| 94265 | 94364 | ** then back out all changes that have occurred during this execution of the |
| 94266 | 94365 | ** VDBE, but do not rollback the transaction. |
| 94267 | 94366 | ** |
| 94268 | | -** If P4 is not null then it is an error message string. |
| 94367 | +** If P3 is not zero and P4 is NULL, then P3 is a register that holds the |
| 94368 | +** text of an error message. |
| 94269 | 94369 | ** |
| 94270 | | -** P5 is a value between 0 and 4, inclusive, that modifies the P4 string. |
| 94370 | +** If P3 is zero and P4 is not null then the error message string is held |
| 94371 | +** in P4. |
| 94271 | 94372 | ** |
| 94272 | | -** 0: (no change) |
| 94373 | +** P5 is a value between 1 and 4, inclusive, then the P4 error message |
| 94374 | +** string is modified as follows: |
| 94375 | +** |
| 94273 | 94376 | ** 1: NOT NULL constraint failed: P4 |
| 94274 | 94377 | ** 2: UNIQUE constraint failed: P4 |
| 94275 | 94378 | ** 3: CHECK constraint failed: P4 |
| 94276 | 94379 | ** 4: FOREIGN KEY constraint failed: P4 |
| 94277 | 94380 | ** |
| 94278 | | -** If P5 is not zero and P4 is NULL, then everything after the ":" is |
| 94279 | | -** omitted. |
| 94381 | +** If P3 is zero and P5 is not zero and P4 is NULL, then everything after |
| 94382 | +** the ":" is omitted. |
| 94280 | 94383 | ** |
| 94281 | 94384 | ** There is an implied "Halt 0 0 0" instruction inserted at the very end of |
| 94282 | 94385 | ** every program. So a jump past the last instruction of the program |
| 94283 | 94386 | ** is the same as executing Halt. |
| 94284 | 94387 | */ |
| | @@ -94287,10 +94390,13 @@ |
| 94287 | 94390 | int pcx; |
| 94288 | 94391 | |
| 94289 | 94392 | #ifdef SQLITE_DEBUG |
| 94290 | 94393 | if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); } |
| 94291 | 94394 | #endif |
| 94395 | + assert( pOp->p4type==P4_NOTUSED |
| 94396 | + || pOp->p4type==P4_STATIC |
| 94397 | + || pOp->p4type==P4_DYNAMIC ); |
| 94292 | 94398 | |
| 94293 | 94399 | /* A deliberately coded "OP_Halt SQLITE_INTERNAL * * * *" opcode indicates |
| 94294 | 94400 | ** something is wrong with the code generator. Raise an assertion in order |
| 94295 | 94401 | ** to bring this to the attention of fuzzers and other testing tools. */ |
| 94296 | 94402 | assert( pOp->p1!=SQLITE_INTERNAL ); |
| | @@ -94317,11 +94423,16 @@ |
| 94317 | 94423 | } |
| 94318 | 94424 | p->rc = pOp->p1; |
| 94319 | 94425 | p->errorAction = (u8)pOp->p2; |
| 94320 | 94426 | assert( pOp->p5<=4 ); |
| 94321 | 94427 | if( p->rc ){ |
| 94322 | | - if( pOp->p5 ){ |
| 94428 | + if( pOp->p3>0 && pOp->p4type==P4_NOTUSED ){ |
| 94429 | + const char *zErr; |
| 94430 | + assert( pOp->p3<=(p->nMem + 1 - p->nCursor) ); |
| 94431 | + zErr = sqlite3ValueText(&aMem[pOp->p3], SQLITE_UTF8); |
| 94432 | + sqlite3VdbeError(p, "%s", zErr); |
| 94433 | + }else if( pOp->p5 ){ |
| 94323 | 94434 | static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", |
| 94324 | 94435 | "FOREIGN KEY" }; |
| 94325 | 94436 | testcase( pOp->p5==1 ); |
| 94326 | 94437 | testcase( pOp->p5==2 ); |
| 94327 | 94438 | testcase( pOp->p5==3 ); |
| | @@ -97360,27 +97471,27 @@ |
| 97360 | 97471 | wrFlag = BTREE_WRCSR | (pOp->p5 & OPFLAG_FORDELETE); |
| 97361 | 97472 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 97362 | 97473 | if( pDb->pSchema->file_format < p->minWriteFileFormat ){ |
| 97363 | 97474 | p->minWriteFileFormat = pDb->pSchema->file_format; |
| 97364 | 97475 | } |
| 97476 | + if( pOp->p5 & OPFLAG_P2ISREG ){ |
| 97477 | + assert( p2>0 ); |
| 97478 | + assert( p2<=(u32)(p->nMem+1 - p->nCursor) ); |
| 97479 | + pIn2 = &aMem[p2]; |
| 97480 | + assert( memIsValid(pIn2) ); |
| 97481 | + assert( (pIn2->flags & MEM_Int)!=0 ); |
| 97482 | + sqlite3VdbeMemIntegerify(pIn2); |
| 97483 | + p2 = (int)pIn2->u.i; |
| 97484 | + /* The p2 value always comes from a prior OP_CreateBtree opcode and |
| 97485 | + ** that opcode will always set the p2 value to 2 or more or else fail. |
| 97486 | + ** If there were a failure, the prepared statement would have halted |
| 97487 | + ** before reaching this instruction. */ |
| 97488 | + assert( p2>=2 ); |
| 97489 | + } |
| 97365 | 97490 | }else{ |
| 97366 | 97491 | wrFlag = 0; |
| 97367 | | - } |
| 97368 | | - if( pOp->p5 & OPFLAG_P2ISREG ){ |
| 97369 | | - assert( p2>0 ); |
| 97370 | | - assert( p2<=(u32)(p->nMem+1 - p->nCursor) ); |
| 97371 | | - assert( pOp->opcode==OP_OpenWrite ); |
| 97372 | | - pIn2 = &aMem[p2]; |
| 97373 | | - assert( memIsValid(pIn2) ); |
| 97374 | | - assert( (pIn2->flags & MEM_Int)!=0 ); |
| 97375 | | - sqlite3VdbeMemIntegerify(pIn2); |
| 97376 | | - p2 = (int)pIn2->u.i; |
| 97377 | | - /* The p2 value always comes from a prior OP_CreateBtree opcode and |
| 97378 | | - ** that opcode will always set the p2 value to 2 or more or else fail. |
| 97379 | | - ** If there were a failure, the prepared statement would have halted |
| 97380 | | - ** before reaching this instruction. */ |
| 97381 | | - assert( p2>=2 ); |
| 97492 | + assert( (pOp->p5 & OPFLAG_P2ISREG)==0 ); |
| 97382 | 97493 | } |
| 97383 | 97494 | if( pOp->p4type==P4_KEYINFO ){ |
| 97384 | 97495 | pKeyInfo = pOp->p4.pKeyInfo; |
| 97385 | 97496 | assert( pKeyInfo->enc==ENC(db) ); |
| 97386 | 97497 | assert( pKeyInfo->db==db ); |
| | @@ -97620,11 +97731,12 @@ |
| 97620 | 97731 | ** row output from the sorter so that the row can be decomposed into |
| 97621 | 97732 | ** individual columns using the OP_Column opcode. The OP_Column opcode |
| 97622 | 97733 | ** is the only cursor opcode that works with a pseudo-table. |
| 97623 | 97734 | ** |
| 97624 | 97735 | ** P3 is the number of fields in the records that will be stored by |
| 97625 | | -** the pseudo-table. |
| 97736 | +** the pseudo-table. If P2 is 0 or negative then the pseudo-cursor |
| 97737 | +** will return NULL for every column. |
| 97626 | 97738 | */ |
| 97627 | 97739 | case OP_OpenPseudo: { |
| 97628 | 97740 | VdbeCursor *pCx; |
| 97629 | 97741 | |
| 97630 | 97742 | assert( pOp->p1>=0 ); |
| | @@ -98331,10 +98443,11 @@ |
| 98331 | 98443 | if( r.nField>0 ){ |
| 98332 | 98444 | /* Key values in an array of registers */ |
| 98333 | 98445 | r.pKeyInfo = pC->pKeyInfo; |
| 98334 | 98446 | r.default_rc = 0; |
| 98335 | 98447 | #ifdef SQLITE_DEBUG |
| 98448 | + (void)sqlite3FaultSim(50); /* For use by --counter in TH3 */ |
| 98336 | 98449 | for(ii=0; ii<r.nField; ii++){ |
| 98337 | 98450 | assert( memIsValid(&r.aMem[ii]) ); |
| 98338 | 98451 | assert( (r.aMem[ii].flags & MEM_Zero)==0 || r.aMem[ii].n==0 ); |
| 98339 | 98452 | if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]); |
| 98340 | 98453 | } |
| | @@ -102038,18 +102151,33 @@ |
| 102038 | 102151 | } |
| 102039 | 102152 | #endif |
| 102040 | 102153 | |
| 102041 | 102154 | /* Opcode: Noop * * * * * |
| 102042 | 102155 | ** |
| 102043 | | -** Do nothing. This instruction is often useful as a jump |
| 102044 | | -** destination. |
| 102156 | +** Do nothing. Continue downward to the next opcode. |
| 102045 | 102157 | */ |
| 102046 | | -/* |
| 102047 | | -** The magic Explain opcode are only inserted when explain==2 (which |
| 102048 | | -** is to say when the EXPLAIN QUERY PLAN syntax is used.) |
| 102049 | | -** This opcode records information from the optimizer. It is the |
| 102050 | | -** the same as a no-op. This opcodesnever appears in a real VM program. |
| 102158 | +/* Opcode: Explain P1 P2 P3 P4 * |
| 102159 | +** |
| 102160 | +** This is the same as OP_Noop during normal query execution. The |
| 102161 | +** purpose of this opcode is to hold information about the query |
| 102162 | +** plan for the purpose of EXPLAIN QUERY PLAN output. |
| 102163 | +** |
| 102164 | +** The P4 value is human-readable text that describes the query plan |
| 102165 | +** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". |
| 102166 | +** |
| 102167 | +** The P1 value is the ID of the current element and P2 is the parent |
| 102168 | +** element for the case of nested query plan elements. If P2 is zero |
| 102169 | +** then this element is a top-level element. |
| 102170 | +** |
| 102171 | +** For loop elements, P3 is the estimated code of each invocation of this |
| 102172 | +** element. |
| 102173 | +** |
| 102174 | +** As with all opcodes, the meanings of the parameters for OP_Explain |
| 102175 | +** are subject to change from one release to the next. Applications |
| 102176 | +** should not attempt to interpret or use any of the information |
| 102177 | +** contined in the OP_Explain opcode. The information provided by this |
| 102178 | +** opcode is intended for testing and debugging use only. |
| 102051 | 102179 | */ |
| 102052 | 102180 | default: { /* This is really OP_Noop, OP_Explain */ |
| 102053 | 102181 | assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain ); |
| 102054 | 102182 | |
| 102055 | 102183 | break; |
| | @@ -105778,14 +105906,14 @@ |
| 105778 | 105906 | break; |
| 105779 | 105907 | } |
| 105780 | 105908 | |
| 105781 | 105909 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 105782 | 105910 | case 9: /* nexec */ |
| 105783 | | - sqlite3_result_int(ctx, pOp->nExec); |
| 105911 | + sqlite3_result_int64(ctx, pOp->nExec); |
| 105784 | 105912 | break; |
| 105785 | 105913 | case 10: /* ncycle */ |
| 105786 | | - sqlite3_result_int(ctx, pOp->nCycle); |
| 105914 | + sqlite3_result_int64(ctx, pOp->nCycle); |
| 105787 | 105915 | break; |
| 105788 | 105916 | #else |
| 105789 | 105917 | case 9: /* nexec */ |
| 105790 | 105918 | case 10: /* ncycle */ |
| 105791 | 105919 | sqlite3_result_int(ctx, 0); |
| | @@ -106874,11 +107002,11 @@ |
| 106874 | 107002 | ** Return TRUE (non-zero) if zTab is a valid name for the schema table pTab. |
| 106875 | 107003 | */ |
| 106876 | 107004 | static SQLITE_NOINLINE int isValidSchemaTableName( |
| 106877 | 107005 | const char *zTab, /* Name as it appears in the SQL */ |
| 106878 | 107006 | Table *pTab, /* The schema table we are trying to match */ |
| 106879 | | - Schema *pSchema /* non-NULL if a database qualifier is present */ |
| 107007 | + const char *zDb /* non-NULL if a database qualifier is present */ |
| 106880 | 107008 | ){ |
| 106881 | 107009 | const char *zLegacy; |
| 106882 | 107010 | assert( pTab!=0 ); |
| 106883 | 107011 | assert( pTab->tnum==1 ); |
| 106884 | 107012 | if( sqlite3StrNICmp(zTab, "sqlite_", 7)!=0 ) return 0; |
| | @@ -106885,11 +107013,11 @@ |
| 106885 | 107013 | zLegacy = pTab->zName; |
| 106886 | 107014 | if( strcmp(zLegacy+7, &LEGACY_TEMP_SCHEMA_TABLE[7])==0 ){ |
| 106887 | 107015 | if( sqlite3StrICmp(zTab+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 ){ |
| 106888 | 107016 | return 1; |
| 106889 | 107017 | } |
| 106890 | | - if( pSchema==0 ) return 0; |
| 107018 | + if( zDb==0 ) return 0; |
| 106891 | 107019 | if( sqlite3StrICmp(zTab+7, &LEGACY_SCHEMA_TABLE[7])==0 ) return 1; |
| 106892 | 107020 | if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1; |
| 106893 | 107021 | }else{ |
| 106894 | 107022 | if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1; |
| 106895 | 107023 | } |
| | @@ -107068,11 +107196,11 @@ |
| 107068 | 107196 | if( sqlite3StrICmp(zTab, pItem->zAlias)!=0 ){ |
| 107069 | 107197 | continue; |
| 107070 | 107198 | } |
| 107071 | 107199 | }else if( sqlite3StrICmp(zTab, pTab->zName)!=0 ){ |
| 107072 | 107200 | if( pTab->tnum!=1 ) continue; |
| 107073 | | - if( !isValidSchemaTableName(zTab, pTab, pSchema) ) continue; |
| 107201 | + if( !isValidSchemaTableName(zTab, pTab, zDb) ) continue; |
| 107074 | 107202 | } |
| 107075 | 107203 | assert( ExprUseYTab(pExpr) ); |
| 107076 | 107204 | if( IN_RENAME_OBJECT && pItem->zAlias ){ |
| 107077 | 107205 | sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab); |
| 107078 | 107206 | } |
| | @@ -107174,11 +107302,12 @@ |
| 107174 | 107302 | int op = pParse->eTriggerOp; |
| 107175 | 107303 | assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); |
| 107176 | 107304 | if( pParse->bReturning ){ |
| 107177 | 107305 | if( (pNC->ncFlags & NC_UBaseReg)!=0 |
| 107178 | 107306 | && ALWAYS(zTab==0 |
| 107179 | | - || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0) |
| 107307 | + || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0 |
| 107308 | + || isValidSchemaTableName(zTab, pParse->pTriggerTab, 0)) |
| 107180 | 107309 | ){ |
| 107181 | 107310 | pExpr->iTable = op!=TK_DELETE; |
| 107182 | 107311 | pTab = pParse->pTriggerTab; |
| 107183 | 107312 | } |
| 107184 | 107313 | }else if( op!=TK_DELETE && zTab && sqlite3StrICmp("new",zTab) == 0 ){ |
| | @@ -107278,10 +107407,15 @@ |
| 107278 | 107407 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 |
| 107279 | 107408 | && sqlite3IsRowid(zCol) |
| 107280 | 107409 | && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) |
| 107281 | 107410 | ){ |
| 107282 | 107411 | cnt = cntTab; |
| 107412 | +#if SQLITE_ALLOW_ROWID_IN_VIEW+0==2 |
| 107413 | + if( pMatch->pTab!=0 && IsView(pMatch->pTab) ){ |
| 107414 | + eNewExprOp = TK_NULL; |
| 107415 | + } |
| 107416 | +#endif |
| 107283 | 107417 | if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; |
| 107284 | 107418 | pExpr->affExpr = SQLITE_AFF_INTEGER; |
| 107285 | 107419 | } |
| 107286 | 107420 | |
| 107287 | 107421 | /* |
| | @@ -107468,12 +107602,16 @@ |
| 107468 | 107602 | ** (See ticket [b92e5e8ec2cdbaa1]). |
| 107469 | 107603 | ** |
| 107470 | 107604 | ** If a generated column is referenced, set bits for every column |
| 107471 | 107605 | ** of the table. |
| 107472 | 107606 | */ |
| 107473 | | - if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){ |
| 107474 | | - pMatch->colUsed |= sqlite3ExprColUsed(pExpr); |
| 107607 | + if( pMatch ){ |
| 107608 | + if( pExpr->iColumn>=0 ){ |
| 107609 | + pMatch->colUsed |= sqlite3ExprColUsed(pExpr); |
| 107610 | + }else{ |
| 107611 | + pMatch->fg.rowidUsed = 1; |
| 107612 | + } |
| 107475 | 107613 | } |
| 107476 | 107614 | |
| 107477 | 107615 | pExpr->op = eNewExprOp; |
| 107478 | 107616 | lookupname_end: |
| 107479 | 107617 | if( cnt==1 ){ |
| | @@ -107921,15 +108059,13 @@ |
| 107921 | 108059 | #else |
| 107922 | 108060 | pNC->ncFlags &= ~NC_AllowAgg; |
| 107923 | 108061 | #endif |
| 107924 | 108062 | } |
| 107925 | 108063 | } |
| 107926 | | -#ifndef SQLITE_OMIT_WINDOWFUNC |
| 107927 | | - else if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 108064 | + else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){ |
| 107928 | 108065 | is_agg = 1; |
| 107929 | 108066 | } |
| 107930 | | -#endif |
| 107931 | 108067 | sqlite3WalkExprList(pWalker, pList); |
| 107932 | 108068 | if( is_agg ){ |
| 107933 | 108069 | if( pExpr->pLeft ){ |
| 107934 | 108070 | assert( pExpr->pLeft->op==TK_ORDER ); |
| 107935 | 108071 | assert( ExprUseXList(pExpr->pLeft) ); |
| | @@ -107995,18 +108131,20 @@ |
| 107995 | 108131 | int nRef = pNC->nRef; |
| 107996 | 108132 | testcase( pNC->ncFlags & NC_IsCheck ); |
| 107997 | 108133 | testcase( pNC->ncFlags & NC_PartIdx ); |
| 107998 | 108134 | testcase( pNC->ncFlags & NC_IdxExpr ); |
| 107999 | 108135 | testcase( pNC->ncFlags & NC_GenCol ); |
| 108136 | + assert( pExpr->x.pSelect ); |
| 108000 | 108137 | if( pNC->ncFlags & NC_SelfRef ){ |
| 108001 | 108138 | notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr); |
| 108002 | 108139 | }else{ |
| 108003 | 108140 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 108004 | 108141 | } |
| 108005 | 108142 | assert( pNC->nRef>=nRef ); |
| 108006 | 108143 | if( nRef!=pNC->nRef ){ |
| 108007 | 108144 | ExprSetProperty(pExpr, EP_VarSelect); |
| 108145 | + pExpr->x.pSelect->selFlags |= SF_Correlated; |
| 108008 | 108146 | } |
| 108009 | 108147 | pNC->ncFlags |= NC_Subquery; |
| 108010 | 108148 | } |
| 108011 | 108149 | break; |
| 108012 | 108150 | } |
| | @@ -108141,11 +108279,11 @@ |
| 108141 | 108279 | NameContext nc; /* Name context for resolving pE */ |
| 108142 | 108280 | sqlite3 *db; /* Database connection */ |
| 108143 | 108281 | int rc; /* Return code from subprocedures */ |
| 108144 | 108282 | u8 savedSuppErr; /* Saved value of db->suppressErr */ |
| 108145 | 108283 | |
| 108146 | | - assert( sqlite3ExprIsInteger(pE, &i)==0 ); |
| 108284 | + assert( sqlite3ExprIsInteger(pE, &i, 0)==0 ); |
| 108147 | 108285 | pEList = pSelect->pEList; |
| 108148 | 108286 | |
| 108149 | 108287 | /* Resolve all names in the ORDER BY term expression |
| 108150 | 108288 | */ |
| 108151 | 108289 | memset(&nc, 0, sizeof(nc)); |
| | @@ -108240,11 +108378,11 @@ |
| 108240 | 108378 | int iCol = -1; |
| 108241 | 108379 | Expr *pE, *pDup; |
| 108242 | 108380 | if( pItem->fg.done ) continue; |
| 108243 | 108381 | pE = sqlite3ExprSkipCollateAndLikely(pItem->pExpr); |
| 108244 | 108382 | if( NEVER(pE==0) ) continue; |
| 108245 | | - if( sqlite3ExprIsInteger(pE, &iCol) ){ |
| 108383 | + if( sqlite3ExprIsInteger(pE, &iCol, 0) ){ |
| 108246 | 108384 | if( iCol<=0 || iCol>pEList->nExpr ){ |
| 108247 | 108385 | resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr, pE); |
| 108248 | 108386 | return 1; |
| 108249 | 108387 | } |
| 108250 | 108388 | }else{ |
| | @@ -108425,11 +108563,11 @@ |
| 108425 | 108563 | ** copy of the iCol-th result-set expression. */ |
| 108426 | 108564 | pItem->u.x.iOrderByCol = (u16)iCol; |
| 108427 | 108565 | continue; |
| 108428 | 108566 | } |
| 108429 | 108567 | } |
| 108430 | | - if( sqlite3ExprIsInteger(pE2, &iCol) ){ |
| 108568 | + if( sqlite3ExprIsInteger(pE2, &iCol, 0) ){ |
| 108431 | 108569 | /* The ORDER BY term is an integer constant. Again, set the column |
| 108432 | 108570 | ** number so that sqlite3ResolveOrderGroupBy() will convert the |
| 108433 | 108571 | ** order-by term to a copy of the result-set expression */ |
| 108434 | 108572 | if( iCol<1 || iCol>0xffff ){ |
| 108435 | 108573 | resolveOutOfRangeError(pParse, zType, i+1, nResult, pE2); |
| | @@ -108528,10 +108666,11 @@ |
| 108528 | 108666 | /* Recursively resolve names in all subqueries in the FROM clause |
| 108529 | 108667 | */ |
| 108530 | 108668 | if( pOuterNC ) pOuterNC->nNestedSelect++; |
| 108531 | 108669 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 108532 | 108670 | SrcItem *pItem = &p->pSrc->a[i]; |
| 108671 | + assert( pItem->zName!=0 || pItem->pSelect!=0 );/* Test of tag-20240424-1*/ |
| 108533 | 108672 | if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ |
| 108534 | 108673 | int nRef = pOuterNC ? pOuterNC->nRef : 0; |
| 108535 | 108674 | const char *zSavedContext = pParse->zAuthContext; |
| 108536 | 108675 | |
| 108537 | 108676 | if( pItem->zName ) pParse->zAuthContext = pItem->zName; |
| | @@ -109004,11 +109143,13 @@ |
| 109004 | 109143 | || (pExpr->op==TK_REGISTER && pExpr->op2==TK_IF_NULL_ROW) ); |
| 109005 | 109144 | pExpr = pExpr->pLeft; |
| 109006 | 109145 | op = pExpr->op; |
| 109007 | 109146 | continue; |
| 109008 | 109147 | } |
| 109009 | | - if( op!=TK_REGISTER || (op = pExpr->op2)==TK_REGISTER ) break; |
| 109148 | + if( op!=TK_REGISTER ) break; |
| 109149 | + op = pExpr->op2; |
| 109150 | + if( NEVER( op==TK_REGISTER ) ) break; |
| 109010 | 109151 | } |
| 109011 | 109152 | return pExpr->affExpr; |
| 109012 | 109153 | } |
| 109013 | 109154 | |
| 109014 | 109155 | /* |
| | @@ -110287,10 +110428,11 @@ |
| 110287 | 110428 | ** Recursively delete an expression tree. |
| 110288 | 110429 | */ |
| 110289 | 110430 | static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ |
| 110290 | 110431 | assert( p!=0 ); |
| 110291 | 110432 | assert( db!=0 ); |
| 110433 | +exprDeleteRestart: |
| 110292 | 110434 | assert( !ExprUseUValue(p) || p->u.iValue>=0 ); |
| 110293 | 110435 | assert( !ExprUseYWin(p) || !ExprUseYSub(p) ); |
| 110294 | 110436 | assert( !ExprUseYWin(p) || p->y.pWin!=0 || db->mallocFailed ); |
| 110295 | 110437 | assert( p->op!=TK_FUNCTION || !ExprUseYSub(p) ); |
| 110296 | 110438 | #ifdef SQLITE_DEBUG |
| | @@ -110302,11 +110444,10 @@ |
| 110302 | 110444 | } |
| 110303 | 110445 | #endif |
| 110304 | 110446 | if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){ |
| 110305 | 110447 | /* The Expr.x union is never used at the same time as Expr.pRight */ |
| 110306 | 110448 | assert( (ExprUseXList(p) && p->x.pList==0) || p->pRight==0 ); |
| 110307 | | - if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft); |
| 110308 | 110449 | if( p->pRight ){ |
| 110309 | 110450 | assert( !ExprHasProperty(p, EP_WinFunc) ); |
| 110310 | 110451 | sqlite3ExprDeleteNN(db, p->pRight); |
| 110311 | 110452 | }else if( ExprUseXSelect(p) ){ |
| 110312 | 110453 | assert( !ExprHasProperty(p, EP_WinFunc) ); |
| | @@ -110316,10 +110457,23 @@ |
| 110316 | 110457 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 110317 | 110458 | if( ExprHasProperty(p, EP_WinFunc) ){ |
| 110318 | 110459 | sqlite3WindowDelete(db, p->y.pWin); |
| 110319 | 110460 | } |
| 110320 | 110461 | #endif |
| 110462 | + } |
| 110463 | + if( p->pLeft && p->op!=TK_SELECT_COLUMN ){ |
| 110464 | + Expr *pLeft = p->pLeft; |
| 110465 | + if( !ExprHasProperty(p, EP_Static) |
| 110466 | + && !ExprHasProperty(pLeft, EP_Static) |
| 110467 | + ){ |
| 110468 | + /* Avoid unnecessary recursion on unary operators */ |
| 110469 | + sqlite3DbNNFreeNN(db, p); |
| 110470 | + p = pLeft; |
| 110471 | + goto exprDeleteRestart; |
| 110472 | + }else{ |
| 110473 | + sqlite3ExprDeleteNN(db, pLeft); |
| 110474 | + } |
| 110321 | 110475 | } |
| 110322 | 110476 | } |
| 110323 | 110477 | if( !ExprHasProperty(p, EP_Static) ){ |
| 110324 | 110478 | sqlite3DbNNFreeNN(db, p); |
| 110325 | 110479 | } |
| | @@ -110349,15 +110503,15 @@ |
| 110349 | 110503 | ** This is similar to sqlite3ExprDelete() except that the delete is |
| 110350 | 110504 | ** deferred until the pParse is deleted. |
| 110351 | 110505 | ** |
| 110352 | 110506 | ** The pExpr might be deleted immediately on an OOM error. |
| 110353 | 110507 | ** |
| 110354 | | -** The deferred delete is (currently) implemented by adding the |
| 110355 | | -** pExpr to the pParse->pConstExpr list with a register number of 0. |
| 110508 | +** Return 0 if the delete was successfully deferred. Return non-zero |
| 110509 | +** if the delete happened immediately because of an OOM. |
| 110356 | 110510 | */ |
| 110357 | | -SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ |
| 110358 | | - sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); |
| 110511 | +SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ |
| 110512 | + return 0==sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); |
| 110359 | 110513 | } |
| 110360 | 110514 | |
| 110361 | 110515 | /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the |
| 110362 | 110516 | ** expression. |
| 110363 | 110517 | */ |
| | @@ -111312,11 +111466,11 @@ |
| 111312 | 111466 | || ExprHasProperty(pExpr, EP_WinFunc) |
| 111313 | 111467 | ){ |
| 111314 | 111468 | pWalker->eCode = 0; |
| 111315 | 111469 | return WRC_Abort; |
| 111316 | 111470 | } |
| 111317 | | - return WRC_Continue; |
| 111471 | + return WRC_Prune; |
| 111318 | 111472 | } |
| 111319 | 111473 | |
| 111320 | 111474 | |
| 111321 | 111475 | /* |
| 111322 | 111476 | ** These routines are Walker callbacks used to check expressions to |
| | @@ -111419,20 +111573,19 @@ |
| 111419 | 111573 | testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail() disallows */ |
| 111420 | 111574 | testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail() disallows */ |
| 111421 | 111575 | return WRC_Continue; |
| 111422 | 111576 | } |
| 111423 | 111577 | } |
| 111424 | | -static int exprIsConst(Parse *pParse, Expr *p, int initFlag, int iCur){ |
| 111578 | +static int exprIsConst(Parse *pParse, Expr *p, int initFlag){ |
| 111425 | 111579 | Walker w; |
| 111426 | 111580 | w.eCode = initFlag; |
| 111427 | 111581 | w.pParse = pParse; |
| 111428 | 111582 | w.xExprCallback = exprNodeIsConstant; |
| 111429 | 111583 | w.xSelectCallback = sqlite3SelectWalkFail; |
| 111430 | 111584 | #ifdef SQLITE_DEBUG |
| 111431 | 111585 | w.xSelectCallback2 = sqlite3SelectWalkAssert2; |
| 111432 | 111586 | #endif |
| 111433 | | - w.u.iCur = iCur; |
| 111434 | 111587 | sqlite3WalkExpr(&w, p); |
| 111435 | 111588 | return w.eCode; |
| 111436 | 111589 | } |
| 111437 | 111590 | |
| 111438 | 111591 | /* |
| | @@ -111448,11 +111601,11 @@ |
| 111448 | 111601 | ** function calls will be considered to be non-constant. If pParse is |
| 111449 | 111602 | ** not NULL, then a function call might be constant, depending on the |
| 111450 | 111603 | ** function and on its parameters. |
| 111451 | 111604 | */ |
| 111452 | 111605 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Parse *pParse, Expr *p){ |
| 111453 | | - return exprIsConst(pParse, p, 1, 0); |
| 111606 | + return exprIsConst(pParse, p, 1); |
| 111454 | 111607 | } |
| 111455 | 111608 | |
| 111456 | 111609 | /* |
| 111457 | 111610 | ** Walk an expression tree. Return non-zero if |
| 111458 | 111611 | ** |
| | @@ -111465,21 +111618,54 @@ |
| 111465 | 111618 | ** When this routine returns true, it indicates that the expression |
| 111466 | 111619 | ** can be added to the pParse->pConstExpr list and evaluated once when |
| 111467 | 111620 | ** the prepared statement starts up. See sqlite3ExprCodeRunJustOnce(). |
| 111468 | 111621 | */ |
| 111469 | 111622 | static int sqlite3ExprIsConstantNotJoin(Parse *pParse, Expr *p){ |
| 111470 | | - return exprIsConst(pParse, p, 2, 0); |
| 111623 | + return exprIsConst(pParse, p, 2); |
| 111624 | +} |
| 111625 | + |
| 111626 | +/* |
| 111627 | +** This routine examines sub-SELECT statements as an expression is being |
| 111628 | +** walked as part of sqlite3ExprIsTableConstant(). Sub-SELECTs are considered |
| 111629 | +** constant as long as they are uncorrelated - meaning that they do not |
| 111630 | +** contain any terms from outer contexts. |
| 111631 | +*/ |
| 111632 | +static int exprSelectWalkTableConstant(Walker *pWalker, Select *pSelect){ |
| 111633 | + assert( pSelect!=0 ); |
| 111634 | + assert( pWalker->eCode==3 || pWalker->eCode==0 ); |
| 111635 | + if( (pSelect->selFlags & SF_Correlated)!=0 ){ |
| 111636 | + pWalker->eCode = 0; |
| 111637 | + return WRC_Abort; |
| 111638 | + } |
| 111639 | + return WRC_Prune; |
| 111471 | 111640 | } |
| 111472 | 111641 | |
| 111473 | 111642 | /* |
| 111474 | 111643 | ** Walk an expression tree. Return non-zero if the expression is constant |
| 111475 | 111644 | ** for any single row of the table with cursor iCur. In other words, the |
| 111476 | 111645 | ** expression must not refer to any non-deterministic function nor any |
| 111477 | 111646 | ** table other than iCur. |
| 111647 | +** |
| 111648 | +** Consider uncorrelated subqueries to be constants if the bAllowSubq |
| 111649 | +** parameter is true. |
| 111478 | 111650 | */ |
| 111479 | | -SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){ |
| 111480 | | - return exprIsConst(0, p, 3, iCur); |
| 111651 | +static int sqlite3ExprIsTableConstant(Expr *p, int iCur, int bAllowSubq){ |
| 111652 | + Walker w; |
| 111653 | + w.eCode = 3; |
| 111654 | + w.pParse = 0; |
| 111655 | + w.xExprCallback = exprNodeIsConstant; |
| 111656 | + if( bAllowSubq ){ |
| 111657 | + w.xSelectCallback = exprSelectWalkTableConstant; |
| 111658 | + }else{ |
| 111659 | + w.xSelectCallback = sqlite3SelectWalkFail; |
| 111660 | +#ifdef SQLITE_DEBUG |
| 111661 | + w.xSelectCallback2 = sqlite3SelectWalkAssert2; |
| 111662 | +#endif |
| 111663 | + } |
| 111664 | + w.u.iCur = iCur; |
| 111665 | + sqlite3WalkExpr(&w, p); |
| 111666 | + return w.eCode; |
| 111481 | 111667 | } |
| 111482 | 111668 | |
| 111483 | 111669 | /* |
| 111484 | 111670 | ** Check pExpr to see if it is an constraint on the single data source |
| 111485 | 111671 | ** pSrc = &pSrcList->a[iSrc]. In other words, check to see if pExpr |
| | @@ -111493,11 +111679,14 @@ |
| 111493 | 111679 | ** |
| 111494 | 111680 | ** To be an single-source constraint, the following must be true: |
| 111495 | 111681 | ** |
| 111496 | 111682 | ** (1) pExpr cannot refer to any table other than pSrc->iCursor. |
| 111497 | 111683 | ** |
| 111498 | | -** (2) pExpr cannot use subqueries or non-deterministic functions. |
| 111684 | +** (2a) pExpr cannot use subqueries unless the bAllowSubq parameter is |
| 111685 | +** true and the subquery is non-correlated |
| 111686 | +** |
| 111687 | +** (2b) pExpr cannot use non-deterministic functions. |
| 111499 | 111688 | ** |
| 111500 | 111689 | ** (3) pSrc cannot be part of the left operand for a RIGHT JOIN. |
| 111501 | 111690 | ** (Is there some way to relax this constraint?) |
| 111502 | 111691 | ** |
| 111503 | 111692 | ** (4) If pSrc is the right operand of a LEFT JOIN, then... |
| | @@ -111522,11 +111711,12 @@ |
| 111522 | 111711 | ** on push-down. |
| 111523 | 111712 | */ |
| 111524 | 111713 | SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint( |
| 111525 | 111714 | Expr *pExpr, /* The constraint */ |
| 111526 | 111715 | const SrcList *pSrcList, /* Complete FROM clause */ |
| 111527 | | - int iSrc /* Which element of pSrcList to use */ |
| 111716 | + int iSrc, /* Which element of pSrcList to use */ |
| 111717 | + int bAllowSubq /* Allow non-correlated subqueries */ |
| 111528 | 111718 | ){ |
| 111529 | 111719 | const SrcItem *pSrc = &pSrcList->a[iSrc]; |
| 111530 | 111720 | if( pSrc->fg.jointype & JT_LTORJ ){ |
| 111531 | 111721 | return 0; /* rule (3) */ |
| 111532 | 111722 | } |
| | @@ -111547,11 +111737,12 @@ |
| 111547 | 111737 | } |
| 111548 | 111738 | break; |
| 111549 | 111739 | } |
| 111550 | 111740 | } |
| 111551 | 111741 | } |
| 111552 | | - return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor); /* rules (1), (2) */ |
| 111742 | + /* Rules (1), (2a), and (2b) handled by the following: */ |
| 111743 | + return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor, bAllowSubq); |
| 111553 | 111744 | } |
| 111554 | 111745 | |
| 111555 | 111746 | |
| 111556 | 111747 | /* |
| 111557 | 111748 | ** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). |
| | @@ -111632,11 +111823,11 @@ |
| 111632 | 111823 | ** is considered a variable but a single-quoted string (ex: 'abc') is |
| 111633 | 111824 | ** a constant. |
| 111634 | 111825 | */ |
| 111635 | 111826 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){ |
| 111636 | 111827 | assert( isInit==0 || isInit==1 ); |
| 111637 | | - return exprIsConst(0, p, 4+isInit, 0); |
| 111828 | + return exprIsConst(0, p, 4+isInit); |
| 111638 | 111829 | } |
| 111639 | 111830 | |
| 111640 | 111831 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 111641 | 111832 | /* |
| 111642 | 111833 | ** Walk an expression tree. Return 1 if the expression contains a |
| | @@ -111658,12 +111849,16 @@ |
| 111658 | 111849 | /* |
| 111659 | 111850 | ** If the expression p codes a constant integer that is small enough |
| 111660 | 111851 | ** to fit in a 32-bit integer, return 1 and put the value of the integer |
| 111661 | 111852 | ** in *pValue. If the expression is not an integer or if it is too big |
| 111662 | 111853 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. |
| 111854 | +** |
| 111855 | +** If the pParse pointer is provided, then allow the expression p to be |
| 111856 | +** a parameter (TK_VARIABLE) that is bound to an integer. |
| 111857 | +** But if pParse is NULL, then p must be a pure integer literal. |
| 111663 | 111858 | */ |
| 111664 | | -SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr *p, int *pValue){ |
| 111859 | +SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr *p, int *pValue, Parse *pParse){ |
| 111665 | 111860 | int rc = 0; |
| 111666 | 111861 | if( NEVER(p==0) ) return 0; /* Used to only happen following on OOM */ |
| 111667 | 111862 | |
| 111668 | 111863 | /* If an expression is an integer literal that fits in a signed 32-bit |
| 111669 | 111864 | ** integer, then the EP_IntValue flag will have already been set */ |
| | @@ -111674,21 +111869,41 @@ |
| 111674 | 111869 | *pValue = p->u.iValue; |
| 111675 | 111870 | return 1; |
| 111676 | 111871 | } |
| 111677 | 111872 | switch( p->op ){ |
| 111678 | 111873 | case TK_UPLUS: { |
| 111679 | | - rc = sqlite3ExprIsInteger(p->pLeft, pValue); |
| 111874 | + rc = sqlite3ExprIsInteger(p->pLeft, pValue, 0); |
| 111680 | 111875 | break; |
| 111681 | 111876 | } |
| 111682 | 111877 | case TK_UMINUS: { |
| 111683 | 111878 | int v = 0; |
| 111684 | | - if( sqlite3ExprIsInteger(p->pLeft, &v) ){ |
| 111879 | + if( sqlite3ExprIsInteger(p->pLeft, &v, 0) ){ |
| 111685 | 111880 | assert( ((unsigned int)v)!=0x80000000 ); |
| 111686 | 111881 | *pValue = -v; |
| 111687 | 111882 | rc = 1; |
| 111688 | 111883 | } |
| 111689 | 111884 | break; |
| 111885 | + } |
| 111886 | + case TK_VARIABLE: { |
| 111887 | + sqlite3_value *pVal; |
| 111888 | + if( pParse==0 ) break; |
| 111889 | + if( NEVER(pParse->pVdbe==0) ) break; |
| 111890 | + if( (pParse->db->flags & SQLITE_EnableQPSG)!=0 ) break; |
| 111891 | + sqlite3VdbeSetVarmask(pParse->pVdbe, p->iColumn); |
| 111892 | + pVal = sqlite3VdbeGetBoundValue(pParse->pReprepare, p->iColumn, |
| 111893 | + SQLITE_AFF_BLOB); |
| 111894 | + if( pVal ){ |
| 111895 | + if( sqlite3_value_type(pVal)==SQLITE_INTEGER ){ |
| 111896 | + sqlite3_int64 vv = sqlite3_value_int64(pVal); |
| 111897 | + if( vv == (vv & 0x7fffffff) ){ /* non-negative numbers only */ |
| 111898 | + *pValue = (int)vv; |
| 111899 | + rc = 1; |
| 111900 | + } |
| 111901 | + } |
| 111902 | + sqlite3ValueFree(pVal); |
| 111903 | + } |
| 111904 | + break; |
| 111690 | 111905 | } |
| 111691 | 111906 | default: break; |
| 111692 | 111907 | } |
| 111693 | 111908 | return rc; |
| 111694 | 111909 | } |
| | @@ -112379,19 +112594,34 @@ |
| 112379 | 112594 | if( ALWAYS(pEList->nExpr==nVal) ){ |
| 112380 | 112595 | Select *pCopy; |
| 112381 | 112596 | SelectDest dest; |
| 112382 | 112597 | int i; |
| 112383 | 112598 | int rc; |
| 112599 | + int addrBloom = 0; |
| 112384 | 112600 | sqlite3SelectDestInit(&dest, SRT_Set, iTab); |
| 112385 | 112601 | dest.zAffSdst = exprINAffinity(pParse, pExpr); |
| 112386 | 112602 | pSelect->iLimit = 0; |
| 112603 | + if( addrOnce && OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){ |
| 112604 | + int regBloom = ++pParse->nMem; |
| 112605 | + addrBloom = sqlite3VdbeAddOp2(v, OP_Blob, 10000, regBloom); |
| 112606 | + VdbeComment((v, "Bloom filter")); |
| 112607 | + dest.iSDParm2 = regBloom; |
| 112608 | + } |
| 112387 | 112609 | testcase( pSelect->selFlags & SF_Distinct ); |
| 112388 | 112610 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ |
| 112389 | 112611 | pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); |
| 112390 | 112612 | rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); |
| 112391 | 112613 | sqlite3SelectDelete(pParse->db, pCopy); |
| 112392 | 112614 | sqlite3DbFree(pParse->db, dest.zAffSdst); |
| 112615 | + if( addrBloom ){ |
| 112616 | + sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; |
| 112617 | + if( dest.iSDParm2==0 ){ |
| 112618 | + sqlite3VdbeChangeToNoop(v, addrBloom); |
| 112619 | + }else{ |
| 112620 | + sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; |
| 112621 | + } |
| 112622 | + } |
| 112393 | 112623 | if( rc ){ |
| 112394 | 112624 | sqlite3KeyInfoUnref(pKeyInfo); |
| 112395 | 112625 | return; |
| 112396 | 112626 | } |
| 112397 | 112627 | assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ |
| | @@ -112830,10 +113060,19 @@ |
| 112830 | 113060 | addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto); /* Return True */ |
| 112831 | 113061 | }else{ |
| 112832 | 113062 | sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector); |
| 112833 | 113063 | if( destIfFalse==destIfNull ){ |
| 112834 | 113064 | /* Combine Step 3 and Step 5 into a single opcode */ |
| 113065 | + if( ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 113066 | + const VdbeOp *pOp = sqlite3VdbeGetOp(v, pExpr->y.sub.iAddr); |
| 113067 | + assert( pOp->opcode==OP_Once || pParse->nErr ); |
| 113068 | + if( pOp->opcode==OP_Once && pOp->p3>0 ){ |
| 113069 | + assert( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ); |
| 113070 | + sqlite3VdbeAddOp4Int(v, OP_Filter, pOp->p3, destIfFalse, |
| 113071 | + rLhs, nVector); VdbeCoverage(v); |
| 113072 | + } |
| 113073 | + } |
| 112835 | 113074 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iTab, destIfFalse, |
| 112836 | 113075 | rLhs, nVector); VdbeCoverage(v); |
| 112837 | 113076 | goto sqlite3ExprCodeIN_finished; |
| 112838 | 113077 | } |
| 112839 | 113078 | /* Ordinary Step 3, for the case where FALSE and NULL are distinct */ |
| | @@ -113112,17 +113351,21 @@ |
| 113112 | 113351 | /* |
| 113113 | 113352 | ** Convert a scalar expression node to a TK_REGISTER referencing |
| 113114 | 113353 | ** register iReg. The caller must ensure that iReg already contains |
| 113115 | 113354 | ** the correct value for the expression. |
| 113116 | 113355 | */ |
| 113117 | | -static void exprToRegister(Expr *pExpr, int iReg){ |
| 113356 | +SQLITE_PRIVATE void sqlite3ExprToRegister(Expr *pExpr, int iReg){ |
| 113118 | 113357 | Expr *p = sqlite3ExprSkipCollateAndLikely(pExpr); |
| 113119 | 113358 | if( NEVER(p==0) ) return; |
| 113120 | | - p->op2 = p->op; |
| 113121 | | - p->op = TK_REGISTER; |
| 113122 | | - p->iTable = iReg; |
| 113123 | | - ExprClearProperty(p, EP_Skip); |
| 113359 | + if( p->op==TK_REGISTER ){ |
| 113360 | + assert( p->iTable==iReg ); |
| 113361 | + }else{ |
| 113362 | + p->op2 = p->op; |
| 113363 | + p->op = TK_REGISTER; |
| 113364 | + p->iTable = iReg; |
| 113365 | + ExprClearProperty(p, EP_Skip); |
| 113366 | + } |
| 113124 | 113367 | } |
| 113125 | 113368 | |
| 113126 | 113369 | /* |
| 113127 | 113370 | ** Evaluate an expression (either a vector or a scalar expression) and store |
| 113128 | 113371 | ** the result in contiguous temporary registers. Return the index of |
| | @@ -113950,12 +114193,13 @@ |
| 113950 | 114193 | } |
| 113951 | 114194 | case TK_COLLATE: { |
| 113952 | 114195 | if( !ExprHasProperty(pExpr, EP_Collate) ){ |
| 113953 | 114196 | /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called |
| 113954 | 114197 | ** "SOFT-COLLATE" that is added to constraints that are pushed down |
| 113955 | | - ** from outer queries into sub-queries by the push-down optimization. |
| 113956 | | - ** Clear subtypes as subtypes may not cross a subquery boundary. |
| 114198 | + ** from outer queries into sub-queries by the WHERE-clause push-down |
| 114199 | + ** optimization. Clear subtypes as subtypes may not cross a subquery |
| 114200 | + ** boundary. |
| 113957 | 114201 | */ |
| 113958 | 114202 | assert( pExpr->pLeft ); |
| 113959 | 114203 | sqlite3ExprCode(pParse, pExpr->pLeft, target); |
| 113960 | 114204 | sqlite3VdbeAddOp1(v, OP_ClrSubtype, target); |
| 113961 | 114205 | return target; |
| | @@ -114120,11 +114364,11 @@ |
| 114120 | 114364 | if( db->mallocFailed ){ |
| 114121 | 114365 | sqlite3ExprDelete(db, pDel); |
| 114122 | 114366 | break; |
| 114123 | 114367 | } |
| 114124 | 114368 | testcase( pX->op==TK_COLUMN ); |
| 114125 | | - exprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); |
| 114369 | + sqlite3ExprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); |
| 114126 | 114370 | testcase( regFree1==0 ); |
| 114127 | 114371 | memset(&opCompare, 0, sizeof(opCompare)); |
| 114128 | 114372 | opCompare.op = TK_EQ; |
| 114129 | 114373 | opCompare.pLeft = pDel; |
| 114130 | 114374 | pTest = &opCompare; |
| | @@ -114174,19 +114418,18 @@ |
| 114174 | 114418 | if( pExpr->affExpr==OE_Abort ){ |
| 114175 | 114419 | sqlite3MayAbort(pParse); |
| 114176 | 114420 | } |
| 114177 | 114421 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 114178 | 114422 | if( pExpr->affExpr==OE_Ignore ){ |
| 114179 | | - sqlite3VdbeAddOp4( |
| 114180 | | - v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0); |
| 114423 | + sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, OE_Ignore); |
| 114181 | 114424 | VdbeCoverage(v); |
| 114182 | 114425 | }else{ |
| 114183 | | - sqlite3HaltConstraint(pParse, |
| 114426 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); |
| 114427 | + sqlite3VdbeAddOp3(v, OP_Halt, |
| 114184 | 114428 | pParse->pTriggerTab ? SQLITE_CONSTRAINT_TRIGGER : SQLITE_ERROR, |
| 114185 | | - pExpr->affExpr, pExpr->u.zToken, 0, 0); |
| 114429 | + pExpr->affExpr, r1); |
| 114186 | 114430 | } |
| 114187 | | - |
| 114188 | 114431 | break; |
| 114189 | 114432 | } |
| 114190 | 114433 | #endif |
| 114191 | 114434 | } |
| 114192 | 114435 | sqlite3ReleaseTempReg(pParse, regFree1); |
| | @@ -114471,11 +114714,11 @@ |
| 114471 | 114714 | compLeft.pLeft = pDel; |
| 114472 | 114715 | compLeft.pRight = pExpr->x.pList->a[0].pExpr; |
| 114473 | 114716 | compRight.op = TK_LE; |
| 114474 | 114717 | compRight.pLeft = pDel; |
| 114475 | 114718 | compRight.pRight = pExpr->x.pList->a[1].pExpr; |
| 114476 | | - exprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); |
| 114719 | + sqlite3ExprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1)); |
| 114477 | 114720 | if( xJump ){ |
| 114478 | 114721 | xJump(pParse, &exprAnd, dest, jumpIfNull); |
| 114479 | 114722 | }else{ |
| 114480 | 114723 | /* Mark the expression is being from the ON or USING clause of a join |
| 114481 | 114724 | ** so that the sqlite3ExprCodeTarget() routine will not attempt to move |
| | @@ -115549,24 +115792,22 @@ |
| 115549 | 115792 | if( pExpr->op!=TK_AGG_FUNCTION ){ |
| 115550 | 115793 | if( iAgg<pAggInfo->nColumn |
| 115551 | 115794 | && pAggInfo->aCol[iAgg].pCExpr==pExpr |
| 115552 | 115795 | ){ |
| 115553 | 115796 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 115554 | | - if( pExpr ){ |
| 115797 | + if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){ |
| 115555 | 115798 | pAggInfo->aCol[iAgg].pCExpr = pExpr; |
| 115556 | | - sqlite3ExprDeferredDelete(pParse, pExpr); |
| 115557 | 115799 | } |
| 115558 | 115800 | } |
| 115559 | 115801 | }else{ |
| 115560 | 115802 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 115561 | 115803 | if( ALWAYS(iAgg<pAggInfo->nFunc) |
| 115562 | 115804 | && pAggInfo->aFunc[iAgg].pFExpr==pExpr |
| 115563 | 115805 | ){ |
| 115564 | 115806 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 115565 | | - if( pExpr ){ |
| 115807 | + if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){ |
| 115566 | 115808 | pAggInfo->aFunc[iAgg].pFExpr = pExpr; |
| 115567 | | - sqlite3ExprDeferredDelete(pParse, pExpr); |
| 115568 | 115809 | } |
| 115569 | 115810 | } |
| 115570 | 115811 | } |
| 115571 | 115812 | } |
| 115572 | 115813 | return WRC_Continue; |
| | @@ -124153,13 +124394,10 @@ |
| 124153 | 124394 | if( p->tabFlags & TF_HasGenerated ){ |
| 124154 | 124395 | sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0, |
| 124155 | 124396 | sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", |
| 124156 | 124397 | db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); |
| 124157 | 124398 | } |
| 124158 | | - sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0, |
| 124159 | | - sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", |
| 124160 | | - db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); |
| 124161 | 124399 | } |
| 124162 | 124400 | |
| 124163 | 124401 | /* Add the table to the in-memory representation of the database. |
| 124164 | 124402 | */ |
| 124165 | 124403 | if( db->init.busy ){ |
| | @@ -124293,12 +124531,13 @@ |
| 124293 | 124531 | #endif /* SQLITE_OMIT_VIEW */ |
| 124294 | 124532 | |
| 124295 | 124533 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 124296 | 124534 | /* |
| 124297 | 124535 | ** The Table structure pTable is really a VIEW. Fill in the names of |
| 124298 | | -** the columns of the view in the pTable structure. Return the number |
| 124299 | | -** of errors. If an error is seen leave an error message in pParse->zErrMsg. |
| 124536 | +** the columns of the view in the pTable structure. Return non-zero if |
| 124537 | +** there are errors. If an error is seen an error message is left |
| 124538 | +** in pParse->zErrMsg. |
| 124300 | 124539 | */ |
| 124301 | 124540 | static SQLITE_NOINLINE int viewGetColumnNames(Parse *pParse, Table *pTable){ |
| 124302 | 124541 | Table *pSelTab; /* A fake table from which we get the result set */ |
| 124303 | 124542 | Select *pSel; /* Copy of the SELECT that implements the view */ |
| 124304 | 124543 | int nErr = 0; /* Number of errors encountered */ |
| | @@ -124417,11 +124656,11 @@ |
| 124417 | 124656 | pTable->pSchema->schemaFlags |= DB_UnresetViews; |
| 124418 | 124657 | if( db->mallocFailed ){ |
| 124419 | 124658 | sqlite3DeleteColumnNames(db, pTable); |
| 124420 | 124659 | } |
| 124421 | 124660 | #endif /* SQLITE_OMIT_VIEW */ |
| 124422 | | - return nErr; |
| 124661 | + return nErr + pParse->nErr; |
| 124423 | 124662 | } |
| 124424 | 124663 | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ |
| 124425 | 124664 | assert( pTable!=0 ); |
| 124426 | 124665 | if( !IsVirtual(pTable) && pTable->nCol>0 ) return 0; |
| 124427 | 124666 | return viewGetColumnNames(pParse, pTable); |
| | @@ -130715,10 +130954,12 @@ |
| 130715 | 130954 | StrAccum *pAccum = &pGCC->str; |
| 130716 | 130955 | if( pAccum->accError==SQLITE_TOOBIG ){ |
| 130717 | 130956 | sqlite3_result_error_toobig(context); |
| 130718 | 130957 | }else if( pAccum->accError==SQLITE_NOMEM ){ |
| 130719 | 130958 | sqlite3_result_error_nomem(context); |
| 130959 | + }else if( pGCC->nAccum>0 && pAccum->nChar==0 ){ |
| 130960 | + sqlite3_result_text(context, "", 1, SQLITE_STATIC); |
| 130720 | 130961 | }else{ |
| 130721 | 130962 | const char *zText = sqlite3_str_value(pAccum); |
| 130722 | 130963 | sqlite3_result_text(context, zText, pAccum->nChar, SQLITE_TRANSIENT); |
| 130723 | 130964 | } |
| 130724 | 130965 | } |
| | @@ -131054,10 +131295,11 @@ |
| 131054 | 131295 | UNUSED_PARAMETER(argc); |
| 131055 | 131296 | assert( argc==3 ); |
| 131056 | 131297 | x = sqlite3_value_double(argv[0]); |
| 131057 | 131298 | y = sqlite3_value_int(argv[1]); |
| 131058 | 131299 | z = sqlite3_value_int(argv[2]); |
| 131300 | + if( z<=0 ) z = 1; |
| 131059 | 131301 | sqlite3FpDecode(&s, x, y, z); |
| 131060 | 131302 | if( s.isSpecial==2 ){ |
| 131061 | 131303 | sqlite3_snprintf(sizeof(zBuf), zBuf, "NaN"); |
| 131062 | 131304 | }else{ |
| 131063 | 131305 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%c%.*s/%d", s.sign, s.n, s.z, s.iDP); |
| | @@ -132595,11 +132837,12 @@ |
| 132595 | 132837 | if( action==OE_Restrict ){ |
| 132596 | 132838 | int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 132597 | 132839 | SrcList *pSrc; |
| 132598 | 132840 | Expr *pRaise; |
| 132599 | 132841 | |
| 132600 | | - pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); |
| 132842 | + pRaise = sqlite3Expr(db, TK_STRING, "FOREIGN KEY constraint failed"), |
| 132843 | + pRaise = sqlite3PExpr(pParse, TK_RAISE, pRaise, 0); |
| 132601 | 132844 | if( pRaise ){ |
| 132602 | 132845 | pRaise->affExpr = OE_Abort; |
| 132603 | 132846 | } |
| 132604 | 132847 | pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 132605 | 132848 | if( pSrc ){ |
| | @@ -135934,11 +136177,14 @@ |
| 135934 | 136177 | ** further downstream. */ |
| 135935 | 136178 | return 0; /* Corrupt schema - two indexes on the same btree */ |
| 135936 | 136179 | } |
| 135937 | 136180 | } |
| 135938 | 136181 | #ifndef SQLITE_OMIT_CHECK |
| 135939 | | - if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){ |
| 136182 | + if( pDest->pCheck |
| 136183 | + && (db->mDbFlags & DBFLAG_Vacuum)==0 |
| 136184 | + && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) |
| 136185 | + ){ |
| 135940 | 136186 | return 0; /* Tables have different CHECK constraints. Ticket #2252 */ |
| 135941 | 136187 | } |
| 135942 | 136188 | #endif |
| 135943 | 136189 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 135944 | 136190 | /* Disallow the transfer optimization if the destination table contains |
| | @@ -140282,11 +140528,11 @@ |
| 140282 | 140528 | pParse->nMem = 6; |
| 140283 | 140529 | |
| 140284 | 140530 | /* Set the maximum error count */ |
| 140285 | 140531 | mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; |
| 140286 | 140532 | if( zRight ){ |
| 140287 | | - if( sqlite3GetInt32(zRight, &mxErr) ){ |
| 140533 | + if( sqlite3GetInt32(pValue->z, &mxErr) ){ |
| 140288 | 140534 | if( mxErr<=0 ){ |
| 140289 | 140535 | mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; |
| 140290 | 140536 | } |
| 140291 | 140537 | }else{ |
| 140292 | 140538 | pObjTab = sqlite3LocateTable(pParse, 0, zRight, |
| | @@ -141490,10 +141736,11 @@ |
| 141490 | 141736 | /* Clear all content from pragma virtual table cursor. */ |
| 141491 | 141737 | static void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){ |
| 141492 | 141738 | int i; |
| 141493 | 141739 | sqlite3_finalize(pCsr->pPragma); |
| 141494 | 141740 | pCsr->pPragma = 0; |
| 141741 | + pCsr->iRowid = 0; |
| 141495 | 141742 | for(i=0; i<ArraySize(pCsr->azArg); i++){ |
| 141496 | 141743 | sqlite3_free(pCsr->azArg[i]); |
| 141497 | 141744 | pCsr->azArg[i] = 0; |
| 141498 | 141745 | } |
| 141499 | 141746 | } |
| | @@ -142290,11 +142537,17 @@ |
| 142290 | 142537 | SQLITE_PRIVATE void *sqlite3ParserAddCleanup( |
| 142291 | 142538 | Parse *pParse, /* Destroy when this Parser finishes */ |
| 142292 | 142539 | void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */ |
| 142293 | 142540 | void *pPtr /* Pointer to object to be cleaned up */ |
| 142294 | 142541 | ){ |
| 142295 | | - ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); |
| 142542 | + ParseCleanup *pCleanup; |
| 142543 | + if( sqlite3FaultSim(300) ){ |
| 142544 | + pCleanup = 0; |
| 142545 | + sqlite3OomFault(pParse->db); |
| 142546 | + }else{ |
| 142547 | + pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); |
| 142548 | + } |
| 142296 | 142549 | if( pCleanup ){ |
| 142297 | 142550 | pCleanup->pNext = pParse->pCleanup; |
| 142298 | 142551 | pParse->pCleanup = pCleanup; |
| 142299 | 142552 | pCleanup->pPtr = pPtr; |
| 142300 | 142553 | pCleanup->xCleanup = xCleanup; |
| | @@ -144116,16 +144369,22 @@ |
| 144116 | 144369 | ** ORDER BY in this case since the order of entries in the set |
| 144117 | 144370 | ** does not matter. But there might be a LIMIT clause, in which |
| 144118 | 144371 | ** case the order does matter */ |
| 144119 | 144372 | pushOntoSorter( |
| 144120 | 144373 | pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg); |
| 144374 | + pDest->iSDParm2 = 0; /* Signal that any Bloom filter is unpopulated */ |
| 144121 | 144375 | }else{ |
| 144122 | 144376 | int r1 = sqlite3GetTempReg(pParse); |
| 144123 | 144377 | assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol ); |
| 144124 | 144378 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, |
| 144125 | 144379 | r1, pDest->zAffSdst, nResultCol); |
| 144126 | 144380 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol); |
| 144381 | + if( pDest->iSDParm2 ){ |
| 144382 | + sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pDest->iSDParm2, 0, |
| 144383 | + regResult, nResultCol); |
| 144384 | + ExplainQueryPlan((pParse, 0, "CREATE BLOOM FILTER")); |
| 144385 | + } |
| 144127 | 144386 | sqlite3ReleaseTempReg(pParse, r1); |
| 144128 | 144387 | } |
| 144129 | 144388 | break; |
| 144130 | 144389 | } |
| 144131 | 144390 | |
| | @@ -145063,12 +145322,11 @@ |
| 145063 | 145322 | Expr *p; |
| 145064 | 145323 | struct ExprList_item *a; |
| 145065 | 145324 | NameContext sNC; |
| 145066 | 145325 | |
| 145067 | 145326 | assert( pSelect!=0 ); |
| 145068 | | - testcase( (pSelect->selFlags & SF_Resolved)==0 ); |
| 145069 | | - assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT ); |
| 145327 | + assert( (pSelect->selFlags & SF_Resolved)!=0 ); |
| 145070 | 145328 | assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 ); |
| 145071 | 145329 | assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB ); |
| 145072 | 145330 | if( db->mallocFailed || IN_RENAME_OBJECT ) return; |
| 145073 | 145331 | while( pSelect->pPrior ) pSelect = pSelect->pPrior; |
| 145074 | 145332 | a = pSelect->pEList->a; |
| | @@ -145075,21 +145333,26 @@ |
| 145075 | 145333 | memset(&sNC, 0, sizeof(sNC)); |
| 145076 | 145334 | sNC.pSrcList = pSelect->pSrc; |
| 145077 | 145335 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 145078 | 145336 | const char *zType; |
| 145079 | 145337 | i64 n; |
| 145338 | + int m = 0; |
| 145339 | + Select *pS2 = pSelect; |
| 145080 | 145340 | pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); |
| 145081 | 145341 | p = a[i].pExpr; |
| 145082 | 145342 | /* pCol->szEst = ... // Column size est for SELECT tables never used */ |
| 145083 | 145343 | pCol->affinity = sqlite3ExprAffinity(p); |
| 145344 | + while( pCol->affinity<=SQLITE_AFF_NONE && pS2->pNext!=0 ){ |
| 145345 | + m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); |
| 145346 | + pS2 = pS2->pNext; |
| 145347 | + pCol->affinity = sqlite3ExprAffinity(pS2->pEList->a[i].pExpr); |
| 145348 | + } |
| 145084 | 145349 | if( pCol->affinity<=SQLITE_AFF_NONE ){ |
| 145085 | 145350 | pCol->affinity = aff; |
| 145086 | 145351 | } |
| 145087 | | - if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){ |
| 145088 | | - int m = 0; |
| 145089 | | - Select *pS2; |
| 145090 | | - for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){ |
| 145352 | + if( pCol->affinity>=SQLITE_AFF_TEXT && (pS2->pNext || pS2!=pSelect) ){ |
| 145353 | + for(pS2=pS2->pNext; pS2; pS2=pS2->pNext){ |
| 145091 | 145354 | m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); |
| 145092 | 145355 | } |
| 145093 | 145356 | if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ |
| 145094 | 145357 | pCol->affinity = SQLITE_AFF_BLOB; |
| 145095 | 145358 | }else |
| | @@ -145115,16 +145378,16 @@ |
| 145115 | 145378 | } |
| 145116 | 145379 | } |
| 145117 | 145380 | } |
| 145118 | 145381 | } |
| 145119 | 145382 | if( zType ){ |
| 145120 | | - i64 m = sqlite3Strlen30(zType); |
| 145383 | + const i64 k = sqlite3Strlen30(zType); |
| 145121 | 145384 | n = sqlite3Strlen30(pCol->zCnName); |
| 145122 | | - pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2); |
| 145385 | + pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+k+2); |
| 145123 | 145386 | pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL); |
| 145124 | 145387 | if( pCol->zCnName ){ |
| 145125 | | - memcpy(&pCol->zCnName[n+1], zType, m+1); |
| 145388 | + memcpy(&pCol->zCnName[n+1], zType, k+1); |
| 145126 | 145389 | pCol->colFlags |= COLFLAG_HASTYPE; |
| 145127 | 145390 | } |
| 145128 | 145391 | } |
| 145129 | 145392 | pColl = sqlite3ExprCollSeq(pParse, p); |
| 145130 | 145393 | if( pColl ){ |
| | @@ -145227,11 +145490,11 @@ |
| 145227 | 145490 | assert( pLimit->op==TK_LIMIT ); |
| 145228 | 145491 | assert( pLimit->pLeft!=0 ); |
| 145229 | 145492 | p->iLimit = iLimit = ++pParse->nMem; |
| 145230 | 145493 | v = sqlite3GetVdbe(pParse); |
| 145231 | 145494 | assert( v!=0 ); |
| 145232 | | - if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){ |
| 145495 | + if( sqlite3ExprIsInteger(pLimit->pLeft, &n, pParse) ){ |
| 145233 | 145496 | sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit); |
| 145234 | 145497 | VdbeComment((v, "LIMIT counter")); |
| 145235 | 145498 | if( n==0 ){ |
| 145236 | 145499 | sqlite3VdbeGoto(v, iBreak); |
| 145237 | 145500 | }else if( n>=0 && p->nSelectRow>sqlite3LogEst((u64)n) ){ |
| | @@ -145707,11 +145970,11 @@ |
| 145707 | 145970 | testcase( rc!=SQLITE_OK ); |
| 145708 | 145971 | pDelete = p->pPrior; |
| 145709 | 145972 | p->pPrior = pPrior; |
| 145710 | 145973 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); |
| 145711 | 145974 | if( p->pLimit |
| 145712 | | - && sqlite3ExprIsInteger(p->pLimit->pLeft, &nLimit) |
| 145975 | + && sqlite3ExprIsInteger(p->pLimit->pLeft, &nLimit, pParse) |
| 145713 | 145976 | && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) |
| 145714 | 145977 | ){ |
| 145715 | 145978 | p->nSelectRow = sqlite3LogEst((u64)nLimit); |
| 145716 | 145979 | } |
| 145717 | 145980 | if( addr ){ |
| | @@ -146051,10 +146314,15 @@ |
| 146051 | 146314 | r1 = sqlite3GetTempReg(pParse); |
| 146052 | 146315 | sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, |
| 146053 | 146316 | r1, pDest->zAffSdst, pIn->nSdst); |
| 146054 | 146317 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1, |
| 146055 | 146318 | pIn->iSdst, pIn->nSdst); |
| 146319 | + if( pDest->iSDParm2>0 ){ |
| 146320 | + sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pDest->iSDParm2, 0, |
| 146321 | + pIn->iSdst, pIn->nSdst); |
| 146322 | + ExplainQueryPlan((pParse, 0, "CREATE BLOOM FILTER")); |
| 146323 | + } |
| 146056 | 146324 | sqlite3ReleaseTempReg(pParse, r1); |
| 146057 | 146325 | break; |
| 146058 | 146326 | } |
| 146059 | 146327 | |
| 146060 | 146328 | /* If this is a scalar select that is part of an expression, then |
| | @@ -147798,10 +148066,22 @@ |
| 147798 | 148066 | ** SELECT * FROM (SELECT a AS x, c-d AS y FROM t1 WHERE a=5 AND c-d=10) |
| 147799 | 148067 | ** WHERE x=5 AND y=10; |
| 147800 | 148068 | ** |
| 147801 | 148069 | ** The hope is that the terms added to the inner query will make it more |
| 147802 | 148070 | ** efficient. |
| 148071 | +** |
| 148072 | +** NAME AMBIGUITY |
| 148073 | +** |
| 148074 | +** This optimization is called the "WHERE-clause push-down optimization". |
| 148075 | +** |
| 148076 | +** Do not confuse this optimization with another unrelated optimization |
| 148077 | +** with a similar name: The "MySQL push-down optimization" causes WHERE |
| 148078 | +** clause terms that can be evaluated using only the index and without |
| 148079 | +** reference to the table are run first, so that if they are false, |
| 148080 | +** unnecessary table seeks are avoided. |
| 148081 | +** |
| 148082 | +** RULES |
| 147803 | 148083 | ** |
| 147804 | 148084 | ** Do not attempt this optimization if: |
| 147805 | 148085 | ** |
| 147806 | 148086 | ** (1) (** This restriction was removed on 2017-09-29. We used to |
| 147807 | 148087 | ** disallow this optimization for aggregate subqueries, but now |
| | @@ -147864,14 +148144,14 @@ |
| 147864 | 148144 | ** (9b) The subquery is to the right of the ON/USING clause |
| 147865 | 148145 | ** |
| 147866 | 148146 | ** (9c) There is a RIGHT JOIN (or FULL JOIN) in between the ON/USING |
| 147867 | 148147 | ** clause and the subquery. |
| 147868 | 148148 | ** |
| 147869 | | -** Without this restriction, the push-down optimization might move |
| 147870 | | -** the ON/USING filter expression from the left side of a RIGHT JOIN |
| 147871 | | -** over to the right side, which leads to incorrect answers. See |
| 147872 | | -** also restriction (6) in sqlite3ExprIsSingleTableConstraint(). |
| 148149 | +** Without this restriction, the WHERE-clause push-down optimization |
| 148150 | +** might move the ON/USING filter expression from the left side of a |
| 148151 | +** RIGHT JOIN over to the right side, which leads to incorrect answers. |
| 148152 | +** See also restriction (6) in sqlite3ExprIsSingleTableConstraint(). |
| 147873 | 148153 | ** |
| 147874 | 148154 | ** (10) The inner query is not the right-hand table of a RIGHT JOIN. |
| 147875 | 148155 | ** |
| 147876 | 148156 | ** (11) The subquery is not a VALUES clause |
| 147877 | 148157 | ** |
| | @@ -147999,11 +148279,11 @@ |
| 147999 | 148279 | return 0; /* Restriction (12) */ |
| 148000 | 148280 | } |
| 148001 | 148281 | } |
| 148002 | 148282 | #endif |
| 148003 | 148283 | |
| 148004 | | - if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc) ){ |
| 148284 | + if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc, 1) ){ |
| 148005 | 148285 | nChng++; |
| 148006 | 148286 | pSubq->selFlags |= SF_PushDown; |
| 148007 | 148287 | while( pSubq ){ |
| 148008 | 148288 | SubstContext x; |
| 148009 | 148289 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| | @@ -149134,12 +149414,11 @@ |
| 149134 | 149414 | SrcItem *pFrom; |
| 149135 | 149415 | |
| 149136 | 149416 | if( p->selFlags & SF_HasTypeInfo ) return; |
| 149137 | 149417 | p->selFlags |= SF_HasTypeInfo; |
| 149138 | 149418 | pParse = pWalker->pParse; |
| 149139 | | - testcase( (p->selFlags & SF_Resolved)==0 ); |
| 149140 | | - assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT ); |
| 149419 | + assert( (p->selFlags & SF_Resolved) ); |
| 149141 | 149420 | pTabList = p->pSrc; |
| 149142 | 149421 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 149143 | 149422 | Table *pTab = pFrom->pTab; |
| 149144 | 149423 | assert( pTab!=0 ); |
| 149145 | 149424 | if( (pTab->tabFlags & TF_Ephemeral)!=0 ){ |
| | @@ -150259,17 +150538,20 @@ |
| 150259 | 150538 | ** (5) The ORDER BY isn't going to accomplish anything because |
| 150260 | 150539 | ** one of: |
| 150261 | 150540 | ** (a) The outer query has a different ORDER BY clause |
| 150262 | 150541 | ** (b) The subquery is part of a join |
| 150263 | 150542 | ** See forum post 062d576715d277c8 |
| 150543 | + ** (6) The subquery is not a recursive CTE. ORDER BY has a different |
| 150544 | + ** meaning for recursive CTEs and this optimization does not |
| 150545 | + ** apply. |
| 150264 | 150546 | ** |
| 150265 | 150547 | ** Also retain the ORDER BY if the OmitOrderBy optimization is disabled. |
| 150266 | 150548 | */ |
| 150267 | 150549 | if( pSub->pOrderBy!=0 |
| 150268 | 150550 | && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */ |
| 150269 | 150551 | && pSub->pLimit==0 /* Condition (1) */ |
| 150270 | | - && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */ |
| 150552 | + && (pSub->selFlags & (SF_OrderByReqd|SF_Recursive))==0 /* (2) and (6) */ |
| 150271 | 150553 | && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */ |
| 150272 | 150554 | && OptimizationEnabled(db, SQLITE_OmitOrderBy) |
| 150273 | 150555 | ){ |
| 150274 | 150556 | TREETRACE(0x800,pParse,p, |
| 150275 | 150557 | ("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1)); |
| | @@ -150428,11 +150710,11 @@ |
| 150428 | 150710 | sqlite3TreeViewSelect(0, p, 0); |
| 150429 | 150711 | } |
| 150430 | 150712 | #endif |
| 150431 | 150713 | assert( pItem->pSelect && (pItem->pSelect->selFlags & SF_PushDown)!=0 ); |
| 150432 | 150714 | }else{ |
| 150433 | | - TREETRACE(0x4000,pParse,p,("Push-down not possible\n")); |
| 150715 | + TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n")); |
| 150434 | 150716 | } |
| 150435 | 150717 | |
| 150436 | 150718 | /* Convert unused result columns of the subquery into simple NULL |
| 150437 | 150719 | ** expressions, to avoid unneeded searching and computation. |
| 150438 | 150720 | */ |
| | @@ -150571,16 +150853,22 @@ |
| 150571 | 150853 | ** written the query must use a temp-table for at least one of the ORDER |
| 150572 | 150854 | ** BY and DISTINCT, and an index or separate temp-table for the other. |
| 150573 | 150855 | */ |
| 150574 | 150856 | if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct |
| 150575 | 150857 | && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 |
| 150858 | + && OptimizationEnabled(db, SQLITE_GroupByOrder) |
| 150576 | 150859 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 150577 | 150860 | && p->pWin==0 |
| 150578 | 150861 | #endif |
| 150579 | 150862 | ){ |
| 150580 | 150863 | p->selFlags &= ~SF_Distinct; |
| 150581 | 150864 | pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); |
| 150865 | + if( pGroupBy ){ |
| 150866 | + for(i=0; i<pGroupBy->nExpr; i++){ |
| 150867 | + pGroupBy->a[i].u.x.iOrderByCol = i+1; |
| 150868 | + } |
| 150869 | + } |
| 150582 | 150870 | p->selFlags |= SF_Aggregate; |
| 150583 | 150871 | /* Notice that even thought SF_Distinct has been cleared from p->selFlags, |
| 150584 | 150872 | ** the sDistinct.isTnct is still set. Hence, isTnct represents the |
| 150585 | 150873 | ** original setting of the SF_Distinct flag, not the current setting */ |
| 150586 | 150874 | assert( sDistinct.isTnct ); |
| | @@ -151039,16 +151327,29 @@ |
| 151039 | 151327 | if( groupBySort ){ |
| 151040 | 151328 | sqlite3VdbeAddOp3(v, OP_SorterData, pAggInfo->sortingIdx, |
| 151041 | 151329 | sortOut, sortPTab); |
| 151042 | 151330 | } |
| 151043 | 151331 | for(j=0; j<pGroupBy->nExpr; j++){ |
| 151332 | + int iOrderByCol = pGroupBy->a[j].u.x.iOrderByCol; |
| 151333 | + |
| 151044 | 151334 | if( groupBySort ){ |
| 151045 | 151335 | sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j); |
| 151046 | 151336 | }else{ |
| 151047 | 151337 | pAggInfo->directMode = 1; |
| 151048 | 151338 | sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j); |
| 151049 | 151339 | } |
| 151340 | + |
| 151341 | + if( iOrderByCol ){ |
| 151342 | + Expr *pX = p->pEList->a[iOrderByCol-1].pExpr; |
| 151343 | + Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX); |
| 151344 | + if( ALWAYS(pBase!=0) |
| 151345 | + && pBase->op!=TK_AGG_COLUMN |
| 151346 | + && pBase->op!=TK_REGISTER |
| 151347 | + ){ |
| 151348 | + sqlite3ExprToRegister(pX, iAMem+j); |
| 151349 | + } |
| 151350 | + } |
| 151050 | 151351 | } |
| 151051 | 151352 | sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr, |
| 151052 | 151353 | (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO); |
| 151053 | 151354 | addr1 = sqlite3VdbeCurrentAddr(v); |
| 151054 | 151355 | sqlite3VdbeAddOp3(v, OP_Jump, addr1+1, 0, addr1+1); VdbeCoverage(v); |
| | @@ -151060,13 +151361,13 @@ |
| 151060 | 151361 | ** This code copies current group by terms in b0,b1,b2,... |
| 151061 | 151362 | ** over to a0,a1,a2. It then calls the output subroutine |
| 151062 | 151363 | ** and resets the aggregate accumulator registers in preparation |
| 151063 | 151364 | ** for the next GROUP BY batch. |
| 151064 | 151365 | */ |
| 151065 | | - sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr); |
| 151066 | 151366 | sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); |
| 151067 | 151367 | VdbeComment((v, "output one row")); |
| 151368 | + sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr); |
| 151068 | 151369 | sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v); |
| 151069 | 151370 | VdbeComment((v, "check abort flag")); |
| 151070 | 151371 | sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset); |
| 151071 | 151372 | VdbeComment((v, "reset accumulator")); |
| 151072 | 151373 | |
| | @@ -152495,10 +152796,76 @@ |
| 152495 | 152796 | } |
| 152496 | 152797 | } |
| 152497 | 152798 | } |
| 152498 | 152799 | return pNew; |
| 152499 | 152800 | } |
| 152801 | + |
| 152802 | +/* If the Expr node is a subquery or an EXISTS operator or an IN operator that |
| 152803 | +** uses a subquery, and if the subquery is SF_Correlated, then mark the |
| 152804 | +** expression as EP_VarSelect. |
| 152805 | +*/ |
| 152806 | +static int sqlite3ReturningSubqueryVarSelect(Walker *NotUsed, Expr *pExpr){ |
| 152807 | + UNUSED_PARAMETER(NotUsed); |
| 152808 | + if( ExprUseXSelect(pExpr) |
| 152809 | + && (pExpr->x.pSelect->selFlags & SF_Correlated)!=0 |
| 152810 | + ){ |
| 152811 | + testcase( ExprHasProperty(pExpr, EP_VarSelect) ); |
| 152812 | + ExprSetProperty(pExpr, EP_VarSelect); |
| 152813 | + } |
| 152814 | + return WRC_Continue; |
| 152815 | +} |
| 152816 | + |
| 152817 | + |
| 152818 | +/* |
| 152819 | +** If the SELECT references the table pWalker->u.pTab, then do two things: |
| 152820 | +** |
| 152821 | +** (1) Mark the SELECT as as SF_Correlated. |
| 152822 | +** (2) Set pWalker->eCode to non-zero so that the caller will know |
| 152823 | +** that (1) has happened. |
| 152824 | +*/ |
| 152825 | +static int sqlite3ReturningSubqueryCorrelated(Walker *pWalker, Select *pSelect){ |
| 152826 | + int i; |
| 152827 | + SrcList *pSrc; |
| 152828 | + assert( pSelect!=0 ); |
| 152829 | + pSrc = pSelect->pSrc; |
| 152830 | + assert( pSrc!=0 ); |
| 152831 | + for(i=0; i<pSrc->nSrc; i++){ |
| 152832 | + if( pSrc->a[i].pTab==pWalker->u.pTab ){ |
| 152833 | + testcase( pSelect->selFlags & SF_Correlated ); |
| 152834 | + pSelect->selFlags |= SF_Correlated; |
| 152835 | + pWalker->eCode = 1; |
| 152836 | + break; |
| 152837 | + } |
| 152838 | + } |
| 152839 | + return WRC_Continue; |
| 152840 | +} |
| 152841 | + |
| 152842 | +/* |
| 152843 | +** Scan the expression list that is the argument to RETURNING looking |
| 152844 | +** for subqueries that depend on the table which is being modified in the |
| 152845 | +** statement that is hosting the RETURNING clause (pTab). Mark all such |
| 152846 | +** subqueries as SF_Correlated. If the subqueries are part of an |
| 152847 | +** expression, mark the expression as EP_VarSelect. |
| 152848 | +** |
| 152849 | +** https://sqlite.org/forum/forumpost/2c83569ce8945d39 |
| 152850 | +*/ |
| 152851 | +static void sqlite3ProcessReturningSubqueries( |
| 152852 | + ExprList *pEList, |
| 152853 | + Table *pTab |
| 152854 | +){ |
| 152855 | + Walker w; |
| 152856 | + memset(&w, 0, sizeof(w)); |
| 152857 | + w.xExprCallback = sqlite3ExprWalkNoop; |
| 152858 | + w.xSelectCallback = sqlite3ReturningSubqueryCorrelated; |
| 152859 | + w.u.pTab = pTab; |
| 152860 | + sqlite3WalkExprList(&w, pEList); |
| 152861 | + if( w.eCode ){ |
| 152862 | + w.xExprCallback = sqlite3ReturningSubqueryVarSelect; |
| 152863 | + w.xSelectCallback = sqlite3SelectWalkNoop; |
| 152864 | + sqlite3WalkExprList(&w, pEList); |
| 152865 | + } |
| 152866 | +} |
| 152500 | 152867 | |
| 152501 | 152868 | /* |
| 152502 | 152869 | ** Generate code for the RETURNING trigger. Unlike other triggers |
| 152503 | 152870 | ** that invoke a subprogram in the bytecode, the code for RETURNING |
| 152504 | 152871 | ** is generated in-line. |
| | @@ -152532,10 +152899,11 @@ |
| 152532 | 152899 | memset(&sFrom, 0, sizeof(sFrom)); |
| 152533 | 152900 | sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); |
| 152534 | 152901 | sSelect.pSrc = &sFrom; |
| 152535 | 152902 | sFrom.nSrc = 1; |
| 152536 | 152903 | sFrom.a[0].pTab = pTab; |
| 152904 | + sFrom.a[0].zName = pTab->zName; /* tag-20240424-1 */ |
| 152537 | 152905 | sFrom.a[0].iCursor = -1; |
| 152538 | 152906 | sqlite3SelectPrep(pParse, &sSelect, 0); |
| 152539 | 152907 | if( pParse->nErr==0 ){ |
| 152540 | 152908 | assert( db->mallocFailed==0 ); |
| 152541 | 152909 | sqlite3GenerateColumnNames(pParse, &sSelect); |
| | @@ -152558,10 +152926,11 @@ |
| 152558 | 152926 | && ALWAYS(!db->mallocFailed) |
| 152559 | 152927 | ){ |
| 152560 | 152928 | int i; |
| 152561 | 152929 | int nCol = pNew->nExpr; |
| 152562 | 152930 | int reg = pParse->nMem+1; |
| 152931 | + sqlite3ProcessReturningSubqueries(pNew, pTab); |
| 152563 | 152932 | pParse->nMem += nCol+2; |
| 152564 | 152933 | pReturning->iRetReg = reg; |
| 152565 | 152934 | for(i=0; i<nCol; i++){ |
| 152566 | 152935 | Expr *pCol = pNew->a[i].pExpr; |
| 152567 | 152936 | assert( pCol!=0 ); /* Due to !db->mallocFailed ~9 lines above */ |
| | @@ -153959,10 +154328,13 @@ |
| 153959 | 154328 | }else{ |
| 153960 | 154329 | sqlite3VdbeAddOp2(v, OP_Null, 0, k); |
| 153961 | 154330 | } |
| 153962 | 154331 | } |
| 153963 | 154332 | if( chngRowid==0 && pPk==0 ){ |
| 154333 | +#ifdef SQLITE_ALLOW_ROWID_IN_VIEW |
| 154334 | + if( isView ) sqlite3VdbeAddOp2(v, OP_Null, 0, regOldRowid); |
| 154335 | +#endif |
| 153964 | 154336 | sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid); |
| 153965 | 154337 | } |
| 153966 | 154338 | } |
| 153967 | 154339 | |
| 153968 | 154340 | /* Populate the array of registers beginning at regNew with the new |
| | @@ -155985,11 +156357,14 @@ |
| 155985 | 156357 | */ |
| 155986 | 156358 | z = (const unsigned char*)zCreateTable; |
| 155987 | 156359 | for(i=0; aKeyword[i]; i++){ |
| 155988 | 156360 | int tokenType = 0; |
| 155989 | 156361 | do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE ); |
| 155990 | | - if( tokenType!=aKeyword[i] ) return SQLITE_MISUSE_BKPT; |
| 156362 | + if( tokenType!=aKeyword[i] ){ |
| 156363 | + sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error"); |
| 156364 | + return SQLITE_ERROR; |
| 156365 | + } |
| 155991 | 156366 | } |
| 155992 | 156367 | |
| 155993 | 156368 | sqlite3_mutex_enter(db->mutex); |
| 155994 | 156369 | pCtx = db->pVtabCtx; |
| 155995 | 156370 | if( !pCtx || pCtx->bDeclared ){ |
| | @@ -156709,10 +157084,12 @@ |
| 156709 | 157084 | u16 nLTerm; /* Number of entries in aLTerm[] */ |
| 156710 | 157085 | u16 nSkip; /* Number of NULL aLTerm[] entries */ |
| 156711 | 157086 | /**** whereLoopXfer() copies fields above ***********************/ |
| 156712 | 157087 | # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot) |
| 156713 | 157088 | u16 nLSlot; /* Number of slots allocated for aLTerm[] */ |
| 157089 | + LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not |
| 157090 | + ** initialized unless pWInfo->nOutStarDelta>0 */ |
| 156714 | 157091 | WhereTerm **aLTerm; /* WhereTerms used */ |
| 156715 | 157092 | WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */ |
| 156716 | 157093 | WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */ |
| 156717 | 157094 | }; |
| 156718 | 157095 | |
| | @@ -157031,10 +157408,11 @@ |
| 157031 | 157408 | u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ |
| 157032 | 157409 | unsigned bDeferredSeek :1; /* Uses OP_DeferredSeek */ |
| 157033 | 157410 | unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */ |
| 157034 | 157411 | unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */ |
| 157035 | 157412 | unsigned sorted :1; /* True if really sorted (not just grouped) */ |
| 157413 | + LogEst nOutStarDelta; /* Artifical nOut reduction for star-query */ |
| 157036 | 157414 | LogEst nRowOut; /* Estimated number of output rows */ |
| 157037 | 157415 | int iTop; /* The very beginning of the WHERE loop */ |
| 157038 | 157416 | int iEndWhere; /* End of the WHERE clause itself */ |
| 157039 | 157417 | WhereLoop *pLoops; /* List of all WhereLoop objects */ |
| 157040 | 157418 | WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */ |
| | @@ -157388,11 +157766,12 @@ |
| 157388 | 157766 | } |
| 157389 | 157767 | #endif |
| 157390 | 157768 | zMsg = sqlite3StrAccumFinish(&str); |
| 157391 | 157769 | sqlite3ExplainBreakpoint("",zMsg); |
| 157392 | 157770 | ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v), |
| 157393 | | - pParse->addrExplain, 0, zMsg,P4_DYNAMIC); |
| 157771 | + pParse->addrExplain, pLoop->rRun, |
| 157772 | + zMsg, P4_DYNAMIC); |
| 157394 | 157773 | } |
| 157395 | 157774 | return ret; |
| 157396 | 157775 | } |
| 157397 | 157776 | |
| 157398 | 157777 | /* |
| | @@ -157630,10 +158009,43 @@ |
| 157630 | 158009 | zAff[i] = SQLITE_AFF_BLOB; |
| 157631 | 158010 | } |
| 157632 | 158011 | } |
| 157633 | 158012 | } |
| 157634 | 158013 | |
| 158014 | +/* |
| 158015 | +** The pOrderBy->a[].u.x.iOrderByCol values might be incorrect because |
| 158016 | +** columns might have been rearranged in the result set. This routine |
| 158017 | +** fixes them up. |
| 158018 | +** |
| 158019 | +** pEList is the new result set. The pEList->a[].u.x.iOrderByCol values |
| 158020 | +** contain the *old* locations of each expression. This is a temporary |
| 158021 | +** use of u.x.iOrderByCol, not its intended use. The caller must reset |
| 158022 | +** u.x.iOrderByCol back to zero for all entries in pEList before the |
| 158023 | +** caller returns. |
| 158024 | +** |
| 158025 | +** This routine changes pOrderBy->a[].u.x.iOrderByCol values from |
| 158026 | +** pEList->a[N].u.x.iOrderByCol into N+1. (The "+1" is because of the 1-based |
| 158027 | +** indexing used by iOrderByCol.) Or if no match, iOrderByCol is set to zero. |
| 158028 | +*/ |
| 158029 | +static void adjustOrderByCol(ExprList *pOrderBy, ExprList *pEList){ |
| 158030 | + int i, j; |
| 158031 | + if( pOrderBy==0 ) return; |
| 158032 | + for(i=0; i<pOrderBy->nExpr; i++){ |
| 158033 | + int t = pOrderBy->a[i].u.x.iOrderByCol; |
| 158034 | + if( t==0 ) continue; |
| 158035 | + for(j=0; j<pEList->nExpr; j++){ |
| 158036 | + if( pEList->a[j].u.x.iOrderByCol==t ){ |
| 158037 | + pOrderBy->a[i].u.x.iOrderByCol = j+1; |
| 158038 | + break; |
| 158039 | + } |
| 158040 | + } |
| 158041 | + if( j>=pEList->nExpr ){ |
| 158042 | + pOrderBy->a[i].u.x.iOrderByCol = 0; |
| 158043 | + } |
| 158044 | + } |
| 158045 | +} |
| 158046 | + |
| 157635 | 158047 | |
| 157636 | 158048 | /* |
| 157637 | 158049 | ** pX is an expression of the form: (vector) IN (SELECT ...) |
| 157638 | 158050 | ** In other words, it is a vector IN operator with a SELECT clause on the |
| 157639 | 158051 | ** LHS. But not all terms in the vector are indexable and the terms might |
| | @@ -157693,10 +158105,11 @@ |
| 157693 | 158105 | assert( (pLoop->aLTerm[i]->eOperator & (WO_OR|WO_AND))==0 ); |
| 157694 | 158106 | iField = pLoop->aLTerm[i]->u.x.iField - 1; |
| 157695 | 158107 | if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */ |
| 157696 | 158108 | pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr); |
| 157697 | 158109 | pOrigRhs->a[iField].pExpr = 0; |
| 158110 | + if( pRhs ) pRhs->a[pRhs->nExpr-1].u.x.iOrderByCol = iField+1; |
| 157698 | 158111 | if( pOrigLhs ){ |
| 157699 | 158112 | assert( pOrigLhs->a[iField].pExpr!=0 ); |
| 157700 | 158113 | pLhs = sqlite3ExprListAppend(pParse,pLhs,pOrigLhs->a[iField].pExpr); |
| 157701 | 158114 | pOrigLhs->a[iField].pExpr = 0; |
| 157702 | 158115 | } |
| | @@ -157715,22 +158128,20 @@ |
| 157715 | 158128 | Expr *p = pLhs->a[0].pExpr; |
| 157716 | 158129 | pLhs->a[0].pExpr = 0; |
| 157717 | 158130 | sqlite3ExprDelete(db, pNew->pLeft); |
| 157718 | 158131 | pNew->pLeft = p; |
| 157719 | 158132 | } |
| 157720 | | - if( pSelect->pOrderBy ){ |
| 157721 | | - /* If the SELECT statement has an ORDER BY clause, zero the |
| 157722 | | - ** iOrderByCol variables. These are set to non-zero when an |
| 157723 | | - ** ORDER BY term exactly matches one of the terms of the |
| 157724 | | - ** result-set. Since the result-set of the SELECT statement may |
| 157725 | | - ** have been modified or reordered, these variables are no longer |
| 157726 | | - ** set correctly. Since setting them is just an optimization, |
| 157727 | | - ** it's easiest just to zero them here. */ |
| 157728 | | - ExprList *pOrderBy = pSelect->pOrderBy; |
| 157729 | | - for(i=0; i<pOrderBy->nExpr; i++){ |
| 157730 | | - pOrderBy->a[i].u.x.iOrderByCol = 0; |
| 157731 | | - } |
| 158133 | + |
| 158134 | + /* If either the ORDER BY clause or the GROUP BY clause contains |
| 158135 | + ** references to result-set columns, those references might now be |
| 158136 | + ** obsolete. So fix them up. |
| 158137 | + */ |
| 158138 | + assert( pRhs!=0 || db->mallocFailed ); |
| 158139 | + if( pRhs ){ |
| 158140 | + adjustOrderByCol(pSelect->pOrderBy, pRhs); |
| 158141 | + adjustOrderByCol(pSelect->pGroupBy, pRhs); |
| 158142 | + for(i=0; i<pRhs->nExpr; i++) pRhs->a[i].u.x.iOrderByCol = 0; |
| 157732 | 158143 | } |
| 157733 | 158144 | |
| 157734 | 158145 | #if 0 |
| 157735 | 158146 | printf("For indexing, change the IN expr:\n"); |
| 157736 | 158147 | sqlite3TreeViewExpr(0, pX, 0); |
| | @@ -157740,10 +158151,151 @@ |
| 157740 | 158151 | } |
| 157741 | 158152 | } |
| 157742 | 158153 | return pNew; |
| 157743 | 158154 | } |
| 157744 | 158155 | |
| 158156 | + |
| 158157 | +#ifndef SQLITE_OMIT_SUBQUERY |
| 158158 | +/* |
| 158159 | +** Generate code for a single X IN (....) term of the WHERE clause. |
| 158160 | +** |
| 158161 | +** This is a special-case of codeEqualityTerm() that works for IN operators |
| 158162 | +** only. It is broken out into a subroutine because this case is |
| 158163 | +** uncommon and by splitting it off into a subroutine, the common case |
| 158164 | +** runs faster. |
| 158165 | +** |
| 158166 | +** The current value for the constraint is left in register iTarget. |
| 158167 | +** This routine sets up a loop that will iterate over all values of X. |
| 158168 | +*/ |
| 158169 | +static SQLITE_NOINLINE void codeINTerm( |
| 158170 | + Parse *pParse, /* The parsing context */ |
| 158171 | + WhereTerm *pTerm, /* The term of the WHERE clause to be coded */ |
| 158172 | + WhereLevel *pLevel, /* The level of the FROM clause we are working on */ |
| 158173 | + int iEq, /* Index of the equality term within this level */ |
| 158174 | + int bRev, /* True for reverse-order IN operations */ |
| 158175 | + int iTarget /* Attempt to leave results in this register */ |
| 158176 | +){ |
| 158177 | + Expr *pX = pTerm->pExpr; |
| 158178 | + int eType = IN_INDEX_NOOP; |
| 158179 | + int iTab; |
| 158180 | + struct InLoop *pIn; |
| 158181 | + WhereLoop *pLoop = pLevel->pWLoop; |
| 158182 | + Vdbe *v = pParse->pVdbe; |
| 158183 | + int i; |
| 158184 | + int nEq = 0; |
| 158185 | + int *aiMap = 0; |
| 158186 | + |
| 158187 | + if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 |
| 158188 | + && pLoop->u.btree.pIndex!=0 |
| 158189 | + && pLoop->u.btree.pIndex->aSortOrder[iEq] |
| 158190 | + ){ |
| 158191 | + testcase( iEq==0 ); |
| 158192 | + testcase( bRev ); |
| 158193 | + bRev = !bRev; |
| 158194 | + } |
| 158195 | + assert( pX->op==TK_IN ); |
| 158196 | + |
| 158197 | + for(i=0; i<iEq; i++){ |
| 158198 | + if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){ |
| 158199 | + disableTerm(pLevel, pTerm); |
| 158200 | + return; |
| 158201 | + } |
| 158202 | + } |
| 158203 | + for(i=iEq;i<pLoop->nLTerm; i++){ |
| 158204 | + assert( pLoop->aLTerm[i]!=0 ); |
| 158205 | + if( pLoop->aLTerm[i]->pExpr==pX ) nEq++; |
| 158206 | + } |
| 158207 | + |
| 158208 | + iTab = 0; |
| 158209 | + if( !ExprUseXSelect(pX) || pX->x.pSelect->pEList->nExpr==1 ){ |
| 158210 | + eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab); |
| 158211 | + }else{ |
| 158212 | + Expr *pExpr = pTerm->pExpr; |
| 158213 | + if( pExpr->iTable==0 || !ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 158214 | + sqlite3 *db = pParse->db; |
| 158215 | + pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX); |
| 158216 | + if( !db->mallocFailed ){ |
| 158217 | + aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq); |
| 158218 | + eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap,&iTab); |
| 158219 | + pExpr->iTable = iTab; |
| 158220 | + } |
| 158221 | + sqlite3ExprDelete(db, pX); |
| 158222 | + }else{ |
| 158223 | + int n = sqlite3ExprVectorSize(pX->pLeft); |
| 158224 | + aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*MAX(nEq,n)); |
| 158225 | + eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab); |
| 158226 | + } |
| 158227 | + pX = pExpr; |
| 158228 | + } |
| 158229 | + |
| 158230 | + if( eType==IN_INDEX_INDEX_DESC ){ |
| 158231 | + testcase( bRev ); |
| 158232 | + bRev = !bRev; |
| 158233 | + } |
| 158234 | + sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); |
| 158235 | + VdbeCoverageIf(v, bRev); |
| 158236 | + VdbeCoverageIf(v, !bRev); |
| 158237 | + |
| 158238 | + assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); |
| 158239 | + pLoop->wsFlags |= WHERE_IN_ABLE; |
| 158240 | + if( pLevel->u.in.nIn==0 ){ |
| 158241 | + pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); |
| 158242 | + } |
| 158243 | + if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){ |
| 158244 | + pLoop->wsFlags |= WHERE_IN_EARLYOUT; |
| 158245 | + } |
| 158246 | + |
| 158247 | + i = pLevel->u.in.nIn; |
| 158248 | + pLevel->u.in.nIn += nEq; |
| 158249 | + pLevel->u.in.aInLoop = |
| 158250 | + sqlite3WhereRealloc(pTerm->pWC->pWInfo, |
| 158251 | + pLevel->u.in.aInLoop, |
| 158252 | + sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn); |
| 158253 | + pIn = pLevel->u.in.aInLoop; |
| 158254 | + if( pIn ){ |
| 158255 | + int iMap = 0; /* Index in aiMap[] */ |
| 158256 | + pIn += i; |
| 158257 | + for(i=iEq;i<pLoop->nLTerm; i++){ |
| 158258 | + if( pLoop->aLTerm[i]->pExpr==pX ){ |
| 158259 | + int iOut = iTarget + i - iEq; |
| 158260 | + if( eType==IN_INDEX_ROWID ){ |
| 158261 | + pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut); |
| 158262 | + }else{ |
| 158263 | + int iCol = aiMap ? aiMap[iMap++] : 0; |
| 158264 | + pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut); |
| 158265 | + } |
| 158266 | + sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v); |
| 158267 | + if( i==iEq ){ |
| 158268 | + pIn->iCur = iTab; |
| 158269 | + pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next; |
| 158270 | + if( iEq>0 ){ |
| 158271 | + pIn->iBase = iTarget - i; |
| 158272 | + pIn->nPrefix = i; |
| 158273 | + }else{ |
| 158274 | + pIn->nPrefix = 0; |
| 158275 | + } |
| 158276 | + }else{ |
| 158277 | + pIn->eEndLoopOp = OP_Noop; |
| 158278 | + } |
| 158279 | + pIn++; |
| 158280 | + } |
| 158281 | + } |
| 158282 | + testcase( iEq>0 |
| 158283 | + && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 |
| 158284 | + && (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ); |
| 158285 | + if( iEq>0 |
| 158286 | + && (pLoop->wsFlags & (WHERE_IN_SEEKSCAN|WHERE_VIRTUALTABLE))==0 |
| 158287 | + ){ |
| 158288 | + sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq); |
| 158289 | + } |
| 158290 | + }else{ |
| 158291 | + pLevel->u.in.nIn = 0; |
| 158292 | + } |
| 158293 | + sqlite3DbFree(pParse->db, aiMap); |
| 158294 | +} |
| 158295 | +#endif |
| 158296 | + |
| 157745 | 158297 | |
| 157746 | 158298 | /* |
| 157747 | 158299 | ** Generate code for a single equality term of the WHERE clause. An equality |
| 157748 | 158300 | ** term can be either X=expr or X IN (...). pTerm is the term to be |
| 157749 | 158301 | ** coded. |
| | @@ -157765,138 +158317,24 @@ |
| 157765 | 158317 | int iEq, /* Index of the equality term within this level */ |
| 157766 | 158318 | int bRev, /* True for reverse-order IN operations */ |
| 157767 | 158319 | int iTarget /* Attempt to leave results in this register */ |
| 157768 | 158320 | ){ |
| 157769 | 158321 | Expr *pX = pTerm->pExpr; |
| 157770 | | - Vdbe *v = pParse->pVdbe; |
| 157771 | 158322 | int iReg; /* Register holding results */ |
| 157772 | 158323 | |
| 157773 | 158324 | assert( pLevel->pWLoop->aLTerm[iEq]==pTerm ); |
| 157774 | 158325 | assert( iTarget>0 ); |
| 157775 | 158326 | if( pX->op==TK_EQ || pX->op==TK_IS ){ |
| 157776 | 158327 | iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget); |
| 157777 | 158328 | }else if( pX->op==TK_ISNULL ){ |
| 157778 | 158329 | iReg = iTarget; |
| 157779 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, iReg); |
| 158330 | + sqlite3VdbeAddOp2(pParse->pVdbe, OP_Null, 0, iReg); |
| 157780 | 158331 | #ifndef SQLITE_OMIT_SUBQUERY |
| 157781 | 158332 | }else{ |
| 157782 | | - int eType = IN_INDEX_NOOP; |
| 157783 | | - int iTab; |
| 157784 | | - struct InLoop *pIn; |
| 157785 | | - WhereLoop *pLoop = pLevel->pWLoop; |
| 157786 | | - int i; |
| 157787 | | - int nEq = 0; |
| 157788 | | - int *aiMap = 0; |
| 157789 | | - |
| 157790 | | - if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 |
| 157791 | | - && pLoop->u.btree.pIndex!=0 |
| 157792 | | - && pLoop->u.btree.pIndex->aSortOrder[iEq] |
| 157793 | | - ){ |
| 157794 | | - testcase( iEq==0 ); |
| 157795 | | - testcase( bRev ); |
| 157796 | | - bRev = !bRev; |
| 157797 | | - } |
| 157798 | 158333 | assert( pX->op==TK_IN ); |
| 157799 | 158334 | iReg = iTarget; |
| 157800 | | - |
| 157801 | | - for(i=0; i<iEq; i++){ |
| 157802 | | - if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){ |
| 157803 | | - disableTerm(pLevel, pTerm); |
| 157804 | | - return iTarget; |
| 157805 | | - } |
| 157806 | | - } |
| 157807 | | - for(i=iEq;i<pLoop->nLTerm; i++){ |
| 157808 | | - assert( pLoop->aLTerm[i]!=0 ); |
| 157809 | | - if( pLoop->aLTerm[i]->pExpr==pX ) nEq++; |
| 157810 | | - } |
| 157811 | | - |
| 157812 | | - iTab = 0; |
| 157813 | | - if( !ExprUseXSelect(pX) || pX->x.pSelect->pEList->nExpr==1 ){ |
| 157814 | | - eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab); |
| 157815 | | - }else{ |
| 157816 | | - Expr *pExpr = pTerm->pExpr; |
| 157817 | | - if( pExpr->iTable==0 || !ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 157818 | | - sqlite3 *db = pParse->db; |
| 157819 | | - pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX); |
| 157820 | | - if( !db->mallocFailed ){ |
| 157821 | | - aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq); |
| 157822 | | - eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap,&iTab); |
| 157823 | | - pExpr->iTable = iTab; |
| 157824 | | - } |
| 157825 | | - sqlite3ExprDelete(db, pX); |
| 157826 | | - }else{ |
| 157827 | | - int n = sqlite3ExprVectorSize(pX->pLeft); |
| 157828 | | - aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*MAX(nEq,n)); |
| 157829 | | - eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab); |
| 157830 | | - } |
| 157831 | | - pX = pExpr; |
| 157832 | | - } |
| 157833 | | - |
| 157834 | | - if( eType==IN_INDEX_INDEX_DESC ){ |
| 157835 | | - testcase( bRev ); |
| 157836 | | - bRev = !bRev; |
| 157837 | | - } |
| 157838 | | - sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); |
| 157839 | | - VdbeCoverageIf(v, bRev); |
| 157840 | | - VdbeCoverageIf(v, !bRev); |
| 157841 | | - |
| 157842 | | - assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); |
| 157843 | | - pLoop->wsFlags |= WHERE_IN_ABLE; |
| 157844 | | - if( pLevel->u.in.nIn==0 ){ |
| 157845 | | - pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); |
| 157846 | | - } |
| 157847 | | - if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){ |
| 157848 | | - pLoop->wsFlags |= WHERE_IN_EARLYOUT; |
| 157849 | | - } |
| 157850 | | - |
| 157851 | | - i = pLevel->u.in.nIn; |
| 157852 | | - pLevel->u.in.nIn += nEq; |
| 157853 | | - pLevel->u.in.aInLoop = |
| 157854 | | - sqlite3WhereRealloc(pTerm->pWC->pWInfo, |
| 157855 | | - pLevel->u.in.aInLoop, |
| 157856 | | - sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn); |
| 157857 | | - pIn = pLevel->u.in.aInLoop; |
| 157858 | | - if( pIn ){ |
| 157859 | | - int iMap = 0; /* Index in aiMap[] */ |
| 157860 | | - pIn += i; |
| 157861 | | - for(i=iEq;i<pLoop->nLTerm; i++){ |
| 157862 | | - if( pLoop->aLTerm[i]->pExpr==pX ){ |
| 157863 | | - int iOut = iReg + i - iEq; |
| 157864 | | - if( eType==IN_INDEX_ROWID ){ |
| 157865 | | - pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut); |
| 157866 | | - }else{ |
| 157867 | | - int iCol = aiMap ? aiMap[iMap++] : 0; |
| 157868 | | - pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut); |
| 157869 | | - } |
| 157870 | | - sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v); |
| 157871 | | - if( i==iEq ){ |
| 157872 | | - pIn->iCur = iTab; |
| 157873 | | - pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next; |
| 157874 | | - if( iEq>0 ){ |
| 157875 | | - pIn->iBase = iReg - i; |
| 157876 | | - pIn->nPrefix = i; |
| 157877 | | - }else{ |
| 157878 | | - pIn->nPrefix = 0; |
| 157879 | | - } |
| 157880 | | - }else{ |
| 157881 | | - pIn->eEndLoopOp = OP_Noop; |
| 157882 | | - } |
| 157883 | | - pIn++; |
| 157884 | | - } |
| 157885 | | - } |
| 157886 | | - testcase( iEq>0 |
| 157887 | | - && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 |
| 157888 | | - && (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ); |
| 157889 | | - if( iEq>0 |
| 157890 | | - && (pLoop->wsFlags & (WHERE_IN_SEEKSCAN|WHERE_VIRTUALTABLE))==0 |
| 157891 | | - ){ |
| 157892 | | - sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq); |
| 157893 | | - } |
| 157894 | | - }else{ |
| 157895 | | - pLevel->u.in.nIn = 0; |
| 157896 | | - } |
| 157897 | | - sqlite3DbFree(pParse->db, aiMap); |
| 158335 | + codeINTerm(pParse, pTerm, pLevel, iEq, bRev, iTarget); |
| 157898 | 158336 | #endif |
| 157899 | 158337 | } |
| 157900 | 158338 | |
| 157901 | 158339 | /* As an optimization, try to disable the WHERE clause term that is |
| 157902 | 158340 | ** driving the index as it will always be true. The correct answer is |
| | @@ -158506,10 +158944,31 @@ |
| 158506 | 158944 | } |
| 158507 | 158945 | pLevel->regFilter = 0; |
| 158508 | 158946 | pLevel->addrBrk = 0; |
| 158509 | 158947 | } |
| 158510 | 158948 | } |
| 158949 | + |
| 158950 | +/* |
| 158951 | +** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...) |
| 158952 | +** operator. Return true if level pLoop is guaranteed to visit only one |
| 158953 | +** row for each key generated for the index. |
| 158954 | +*/ |
| 158955 | +static int whereLoopIsOneRow(WhereLoop *pLoop){ |
| 158956 | + if( pLoop->u.btree.pIndex->onError |
| 158957 | + && pLoop->nSkip==0 |
| 158958 | + && pLoop->u.btree.nEq==pLoop->u.btree.pIndex->nKeyCol |
| 158959 | + ){ |
| 158960 | + int ii; |
| 158961 | + for(ii=0; ii<pLoop->u.btree.nEq; ii++){ |
| 158962 | + if( pLoop->aLTerm[ii]->eOperator & (WO_IS|WO_ISNULL) ){ |
| 158963 | + return 0; |
| 158964 | + } |
| 158965 | + } |
| 158966 | + return 1; |
| 158967 | + } |
| 158968 | + return 0; |
| 158969 | +} |
| 158511 | 158970 | |
| 158512 | 158971 | /* |
| 158513 | 158972 | ** Generate code for the start of the iLevel-th loop in the WHERE clause |
| 158514 | 158973 | ** implementation described by pWInfo. |
| 158515 | 158974 | */ |
| | @@ -158585,11 +159044,11 @@ |
| 158585 | 159044 | || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0 |
| 158586 | 159045 | ); |
| 158587 | 159046 | if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){ |
| 158588 | 159047 | pLevel->iLeftJoin = ++pParse->nMem; |
| 158589 | 159048 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin); |
| 158590 | | - VdbeComment((v, "init LEFT JOIN no-match flag")); |
| 159049 | + VdbeComment((v, "init LEFT JOIN match flag")); |
| 158591 | 159050 | } |
| 158592 | 159051 | |
| 158593 | 159052 | /* Compute a safe address to jump to if we discover that the table for |
| 158594 | 159053 | ** this loop is empty and can never contribute content. */ |
| 158595 | 159054 | for(j=iLevel; j>0; j--){ |
| | @@ -159254,11 +159713,13 @@ |
| 159254 | 159713 | ** a LEFT JOIN: */ |
| 159255 | 159714 | assert( (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN))==0 ); |
| 159256 | 159715 | } |
| 159257 | 159716 | |
| 159258 | 159717 | /* Record the instruction used to terminate the loop. */ |
| 159259 | | - if( pLoop->wsFlags & WHERE_ONEROW ){ |
| 159718 | + if( (pLoop->wsFlags & WHERE_ONEROW) |
| 159719 | + || (pLevel->u.in.nIn && regBignull==0 && whereLoopIsOneRow(pLoop)) |
| 159720 | + ){ |
| 159260 | 159721 | pLevel->op = OP_Noop; |
| 159261 | 159722 | }else if( bRev ){ |
| 159262 | 159723 | pLevel->op = OP_Prev; |
| 159263 | 159724 | }else{ |
| 159264 | 159725 | pLevel->op = OP_Next; |
| | @@ -159644,10 +160105,16 @@ |
| 159644 | 160105 | ** iLoop==2: Code remaining expressions that do not contain correlated |
| 159645 | 160106 | ** sub-queries. |
| 159646 | 160107 | ** iLoop==3: Code all remaining expressions. |
| 159647 | 160108 | ** |
| 159648 | 160109 | ** An effort is made to skip unnecessary iterations of the loop. |
| 160110 | + ** |
| 160111 | + ** This optimization of causing simple query restrictions to occur before |
| 160112 | + ** more complex one is call the "push-down" optimization in MySQL. Here |
| 160113 | + ** in SQLite, the name is "MySQL push-down", since there is also another |
| 160114 | + ** totally unrelated optimization called "WHERE-clause push-down". |
| 160115 | + ** Sometimes the qualifier is omitted, resulting in an ambiguity, so beware. |
| 159649 | 160116 | */ |
| 159650 | 160117 | iLoop = (pIdx ? 1 : 2); |
| 159651 | 160118 | do{ |
| 159652 | 160119 | int iNext = 0; /* Next value for iLoop */ |
| 159653 | 160120 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| | @@ -159894,11 +160361,20 @@ |
| 159894 | 160361 | ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pTab->zName)); |
| 159895 | 160362 | sqlite3VdbeNoJumpsOutsideSubrtn(v, pRJ->addrSubrtn, pRJ->endSubrtn, |
| 159896 | 160363 | pRJ->regReturn); |
| 159897 | 160364 | for(k=0; k<iLevel; k++){ |
| 159898 | 160365 | int iIdxCur; |
| 160366 | + SrcItem *pRight; |
| 160367 | + assert( pWInfo->a[k].pWLoop->iTab == pWInfo->a[k].iFrom ); |
| 160368 | + pRight = &pWInfo->pTabList->a[pWInfo->a[k].iFrom]; |
| 159899 | 160369 | mAll |= pWInfo->a[k].pWLoop->maskSelf; |
| 160370 | + if( pRight->fg.viaCoroutine ){ |
| 160371 | + sqlite3VdbeAddOp3( |
| 160372 | + v, OP_Null, 0, pRight->regResult, |
| 160373 | + pRight->regResult + pRight->pSelect->pEList->nExpr-1 |
| 160374 | + ); |
| 160375 | + } |
| 159900 | 160376 | sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); |
| 159901 | 160377 | iIdxCur = pWInfo->a[k].iIdxCur; |
| 159902 | 160378 | if( iIdxCur ){ |
| 159903 | 160379 | sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); |
| 159904 | 160380 | } |
| | @@ -160063,11 +160539,16 @@ |
| 160063 | 160539 | static int allowedOp(int op){ |
| 160064 | 160540 | assert( TK_GT>TK_EQ && TK_GT<TK_GE ); |
| 160065 | 160541 | assert( TK_LT>TK_EQ && TK_LT<TK_GE ); |
| 160066 | 160542 | assert( TK_LE>TK_EQ && TK_LE<TK_GE ); |
| 160067 | 160543 | assert( TK_GE==TK_EQ+4 ); |
| 160068 | | - return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS; |
| 160544 | + assert( TK_IN<TK_EQ ); |
| 160545 | + assert( TK_IS<TK_EQ ); |
| 160546 | + assert( TK_ISNULL<TK_EQ ); |
| 160547 | + if( op>TK_GE ) return 0; |
| 160548 | + if( op>=TK_EQ ) return 1; |
| 160549 | + return op==TK_IN || op==TK_ISNULL || op==TK_IS; |
| 160069 | 160550 | } |
| 160070 | 160551 | |
| 160071 | 160552 | /* |
| 160072 | 160553 | ** Commute a comparison operator. Expressions of the form "X op Y" |
| 160073 | 160554 | ** are converted into "Y op X". |
| | @@ -160096,19 +160577,20 @@ |
| 160096 | 160577 | ** Translate from TK_xx operator to WO_xx bitmask. |
| 160097 | 160578 | */ |
| 160098 | 160579 | static u16 operatorMask(int op){ |
| 160099 | 160580 | u16 c; |
| 160100 | 160581 | assert( allowedOp(op) ); |
| 160101 | | - if( op==TK_IN ){ |
| 160582 | + if( op>=TK_EQ ){ |
| 160583 | + assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); |
| 160584 | + c = (u16)(WO_EQ<<(op-TK_EQ)); |
| 160585 | + }else if( op==TK_IN ){ |
| 160102 | 160586 | c = WO_IN; |
| 160103 | 160587 | }else if( op==TK_ISNULL ){ |
| 160104 | 160588 | c = WO_ISNULL; |
| 160105 | | - }else if( op==TK_IS ){ |
| 160589 | + }else{ |
| 160590 | + assert( op==TK_IS ); |
| 160106 | 160591 | c = WO_IS; |
| 160107 | | - }else{ |
| 160108 | | - assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); |
| 160109 | | - c = (u16)(WO_EQ<<(op-TK_EQ)); |
| 160110 | 160592 | } |
| 160111 | 160593 | assert( op!=TK_ISNULL || c==WO_ISNULL ); |
| 160112 | 160594 | assert( op!=TK_IN || c==WO_IN ); |
| 160113 | 160595 | assert( op!=TK_EQ || c==WO_EQ ); |
| 160114 | 160596 | assert( op!=TK_LT || c==WO_LT ); |
| | @@ -160391,10 +160873,17 @@ |
| 160391 | 160873 | *ppLeft = pCol; |
| 160392 | 160874 | return 1; |
| 160393 | 160875 | } |
| 160394 | 160876 | } |
| 160395 | 160877 | } |
| 160878 | + }else if( pExpr->op>=TK_EQ ){ |
| 160879 | + /* Comparison operators are a common case. Save a few comparisons for |
| 160880 | + ** that common case by terminating early. */ |
| 160881 | + assert( TK_NE < TK_EQ ); |
| 160882 | + assert( TK_ISNOT < TK_EQ ); |
| 160883 | + assert( TK_NOTNULL < TK_EQ ); |
| 160884 | + return 0; |
| 160396 | 160885 | }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){ |
| 160397 | 160886 | int res = 0; |
| 160398 | 160887 | Expr *pLeft = pExpr->pLeft; |
| 160399 | 160888 | Expr *pRight = pExpr->pRight; |
| 160400 | 160889 | assert( pLeft->op!=TK_COLUMN || (ExprUseYTab(pLeft) && pLeft->y.pTab!=0) ); |
| | @@ -161532,11 +162021,11 @@ |
| 161532 | 162021 | Parse *pParse = pWC->pWInfo->pParse; |
| 161533 | 162022 | sqlite3 *db = pParse->db; |
| 161534 | 162023 | Expr *pNew; |
| 161535 | 162024 | int iVal = 0; |
| 161536 | 162025 | |
| 161537 | | - if( sqlite3ExprIsInteger(pExpr, &iVal) && iVal>=0 ){ |
| 162026 | + if( sqlite3ExprIsInteger(pExpr, &iVal, pParse) && iVal>=0 ){ |
| 161538 | 162027 | Expr *pVal = sqlite3Expr(db, TK_INTEGER, 0); |
| 161539 | 162028 | if( pVal==0 ) return; |
| 161540 | 162029 | ExprSetProperty(pVal, EP_IntValue); |
| 161541 | 162030 | pVal->u.iValue = iVal; |
| 161542 | 162031 | pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal); |
| | @@ -161600,10 +162089,11 @@ |
| 161600 | 162089 | ** will only be added if each of the child terms passes the |
| 161601 | 162090 | ** (leftCursor==iCsr) test below. */ |
| 161602 | 162091 | continue; |
| 161603 | 162092 | } |
| 161604 | 162093 | if( pWC->a[ii].leftCursor!=iCsr ) return; |
| 162094 | + if( pWC->a[ii].prereqRight!=0 ) return; |
| 161605 | 162095 | } |
| 161606 | 162096 | |
| 161607 | 162097 | /* Check condition (5). Return early if it is not met. */ |
| 161608 | 162098 | if( pOrderBy ){ |
| 161609 | 162099 | for(ii=0; ii<pOrderBy->nExpr; ii++){ |
| | @@ -161614,16 +162104,18 @@ |
| 161614 | 162104 | } |
| 161615 | 162105 | } |
| 161616 | 162106 | |
| 161617 | 162107 | /* All conditions are met. Add the terms to the where-clause object. */ |
| 161618 | 162108 | assert( p->pLimit->op==TK_LIMIT ); |
| 161619 | | - whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft, |
| 161620 | | - iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT); |
| 161621 | | - if( p->iOffset>0 ){ |
| 162109 | + if( p->iOffset!=0 && (p->selFlags & SF_Compound)==0 ){ |
| 161622 | 162110 | whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight, |
| 161623 | 162111 | iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET); |
| 161624 | 162112 | } |
| 162113 | + if( p->iOffset==0 || (p->selFlags & SF_Compound)==0 ){ |
| 162114 | + whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft, |
| 162115 | + iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT); |
| 162116 | + } |
| 161625 | 162117 | } |
| 161626 | 162118 | } |
| 161627 | 162119 | |
| 161628 | 162120 | /* |
| 161629 | 162121 | ** Initialize a preallocated WhereClause structure. |
| | @@ -162136,10 +162628,46 @@ |
| 162136 | 162628 | if( ALWAYS(p!=0) && p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){ |
| 162137 | 162629 | return p; |
| 162138 | 162630 | } |
| 162139 | 162631 | return 0; |
| 162140 | 162632 | } |
| 162633 | + |
| 162634 | +/* |
| 162635 | +** Term pTerm is guaranteed to be a WO_IN term. It may be a component term |
| 162636 | +** of a vector IN expression of the form "(x, y, ...) IN (SELECT ...)". |
| 162637 | +** This function checks to see if the term is compatible with an index |
| 162638 | +** column with affinity idxaff (one of the SQLITE_AFF_XYZ values). If so, |
| 162639 | +** it returns a pointer to the name of the collation sequence (e.g. "BINARY" |
| 162640 | +** or "NOCASE") used by the comparison in pTerm. If it is not compatible |
| 162641 | +** with affinity idxaff, NULL is returned. |
| 162642 | +*/ |
| 162643 | +static SQLITE_NOINLINE const char *indexInAffinityOk( |
| 162644 | + Parse *pParse, |
| 162645 | + WhereTerm *pTerm, |
| 162646 | + u8 idxaff |
| 162647 | +){ |
| 162648 | + Expr *pX = pTerm->pExpr; |
| 162649 | + Expr inexpr; |
| 162650 | + |
| 162651 | + assert( pTerm->eOperator & WO_IN ); |
| 162652 | + |
| 162653 | + if( sqlite3ExprIsVector(pX->pLeft) ){ |
| 162654 | + int iField = pTerm->u.x.iField - 1; |
| 162655 | + inexpr.flags = 0; |
| 162656 | + inexpr.op = TK_EQ; |
| 162657 | + inexpr.pLeft = pX->pLeft->x.pList->a[iField].pExpr; |
| 162658 | + assert( ExprUseXSelect(pX) ); |
| 162659 | + inexpr.pRight = pX->x.pSelect->pEList->a[iField].pExpr; |
| 162660 | + pX = &inexpr; |
| 162661 | + } |
| 162662 | + |
| 162663 | + if( sqlite3IndexAffinityOk(pX, idxaff) ){ |
| 162664 | + CollSeq *pRet = sqlite3ExprCompareCollSeq(pParse, pX); |
| 162665 | + return pRet ? pRet->zName : sqlite3StrBINARY; |
| 162666 | + } |
| 162667 | + return 0; |
| 162668 | +} |
| 162141 | 162669 | |
| 162142 | 162670 | /* |
| 162143 | 162671 | ** Advance to the next WhereTerm that matches according to the criteria |
| 162144 | 162672 | ** established when the pScan object was initialized by whereScanInit(). |
| 162145 | 162673 | ** Return NULL if there are no more matching WhereTerms. |
| | @@ -162187,20 +162715,28 @@ |
| 162187 | 162715 | } |
| 162188 | 162716 | } |
| 162189 | 162717 | if( (pTerm->eOperator & pScan->opMask)!=0 ){ |
| 162190 | 162718 | /* Verify the affinity and collating sequence match */ |
| 162191 | 162719 | if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){ |
| 162192 | | - CollSeq *pColl; |
| 162720 | + const char *zCollName; |
| 162193 | 162721 | Parse *pParse = pWC->pWInfo->pParse; |
| 162194 | 162722 | pX = pTerm->pExpr; |
| 162195 | | - if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){ |
| 162196 | | - continue; |
| 162723 | + |
| 162724 | + if( (pTerm->eOperator & WO_IN) ){ |
| 162725 | + zCollName = indexInAffinityOk(pParse, pTerm, pScan->idxaff); |
| 162726 | + if( !zCollName ) continue; |
| 162727 | + }else{ |
| 162728 | + CollSeq *pColl; |
| 162729 | + if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){ |
| 162730 | + continue; |
| 162731 | + } |
| 162732 | + assert(pX->pLeft); |
| 162733 | + pColl = sqlite3ExprCompareCollSeq(pParse, pX); |
| 162734 | + zCollName = pColl ? pColl->zName : sqlite3StrBINARY; |
| 162197 | 162735 | } |
| 162198 | | - assert(pX->pLeft); |
| 162199 | | - pColl = sqlite3ExprCompareCollSeq(pParse, pX); |
| 162200 | | - if( pColl==0 ) pColl = pParse->db->pDfltColl; |
| 162201 | | - if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){ |
| 162736 | + |
| 162737 | + if( sqlite3StrICmp(zCollName, pScan->zCollName) ){ |
| 162202 | 162738 | continue; |
| 162203 | 162739 | } |
| 162204 | 162740 | } |
| 162205 | 162741 | if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0 |
| 162206 | 162742 | && (pX = pTerm->pExpr->pRight, ALWAYS(pX!=0)) |
| | @@ -162631,10 +163167,44 @@ |
| 162631 | 163167 | return 0; |
| 162632 | 163168 | } |
| 162633 | 163169 | return 1; |
| 162634 | 163170 | } |
| 162635 | 163171 | |
| 163172 | +#ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 163173 | +/* |
| 163174 | +** Return true if column iCol of table pTab seem like it might be a |
| 163175 | +** good column to use as part of a query-time index. |
| 163176 | +** |
| 163177 | +** Current algorithm (subject to improvement!): |
| 163178 | +** |
| 163179 | +** 1. If iCol is already the left-most column of some other index, |
| 163180 | +** then return false. |
| 163181 | +** |
| 163182 | +** 2. If iCol is part of an existing index that has an aiRowLogEst of |
| 163183 | +** more than 20, then return false. |
| 163184 | +** |
| 163185 | +** 3. If no disqualifying conditions above are found, return true. |
| 163186 | +*/ |
| 163187 | +static SQLITE_NOINLINE int columnIsGoodIndexCandidate( |
| 163188 | + const Table *pTab, |
| 163189 | + int iCol |
| 163190 | +){ |
| 163191 | + const Index *pIdx; |
| 163192 | + for(pIdx = pTab->pIndex; pIdx!=0; pIdx=pIdx->pNext){ |
| 163193 | + int j; |
| 163194 | + for(j=0; j<pIdx->nKeyCol; j++){ |
| 163195 | + if( pIdx->aiColumn[j]==iCol ){ |
| 163196 | + if( j==0 ) return 0; |
| 163197 | + if( pIdx->hasStat1 && pIdx->aiRowLogEst[j+1]>20 ) return 0; |
| 163198 | + break; |
| 163199 | + } |
| 163200 | + } |
| 163201 | + } |
| 163202 | + return 1; |
| 163203 | +} |
| 163204 | +#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */ |
| 163205 | + |
| 162636 | 163206 | |
| 162637 | 163207 | |
| 162638 | 163208 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 162639 | 163209 | /* |
| 162640 | 163210 | ** Return TRUE if the WHERE clause term pTerm is of a form where it |
| | @@ -162645,10 +163215,12 @@ |
| 162645 | 163215 | const WhereTerm *pTerm, /* WHERE clause term to check */ |
| 162646 | 163216 | const SrcItem *pSrc, /* Table we are trying to access */ |
| 162647 | 163217 | const Bitmask notReady /* Tables in outer loops of the join */ |
| 162648 | 163218 | ){ |
| 162649 | 163219 | char aff; |
| 163220 | + int leftCol; |
| 163221 | + |
| 162650 | 163222 | if( pTerm->leftCursor!=pSrc->iCursor ) return 0; |
| 162651 | 163223 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; |
| 162652 | 163224 | assert( (pSrc->fg.jointype & JT_RIGHT)==0 ); |
| 162653 | 163225 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 |
| 162654 | 163226 | && !constraintCompatibleWithOuterJoin(pTerm,pSrc) |
| | @@ -162655,15 +163227,16 @@ |
| 162655 | 163227 | ){ |
| 162656 | 163228 | return 0; /* See https://sqlite.org/forum/forumpost/51e6959f61 */ |
| 162657 | 163229 | } |
| 162658 | 163230 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 162659 | 163231 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 162660 | | - if( pTerm->u.x.leftColumn<0 ) return 0; |
| 162661 | | - aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; |
| 163232 | + leftCol = pTerm->u.x.leftColumn; |
| 163233 | + if( leftCol<0 ) return 0; |
| 163234 | + aff = pSrc->pTab->aCol[leftCol].affinity; |
| 162662 | 163235 | if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; |
| 162663 | 163236 | testcase( pTerm->pExpr->op==TK_IS ); |
| 162664 | | - return 1; |
| 163237 | + return columnIsGoodIndexCandidate(pSrc->pTab, leftCol); |
| 162665 | 163238 | } |
| 162666 | 163239 | #endif |
| 162667 | 163240 | |
| 162668 | 163241 | |
| 162669 | 163242 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| | @@ -162777,11 +163350,11 @@ |
| 162777 | 163350 | Expr *pExpr = pTerm->pExpr; |
| 162778 | 163351 | /* Make the automatic index a partial index if there are terms in the |
| 162779 | 163352 | ** WHERE clause (or the ON clause of a LEFT join) that constrain which |
| 162780 | 163353 | ** rows of the target table (pSrc) that can be used. */ |
| 162781 | 163354 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 162782 | | - && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom) |
| 163355 | + && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom, 0) |
| 162783 | 163356 | ){ |
| 162784 | 163357 | pPartial = sqlite3ExprAnd(pParse, pPartial, |
| 162785 | 163358 | sqlite3ExprDup(pParse->db, pExpr, 0)); |
| 162786 | 163359 | } |
| 162787 | 163360 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| | @@ -163046,11 +163619,11 @@ |
| 163046 | 163619 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); |
| 163047 | 163620 | pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm]; |
| 163048 | 163621 | for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){ |
| 163049 | 163622 | Expr *pExpr = pTerm->pExpr; |
| 163050 | 163623 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 163051 | | - && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc) |
| 163624 | + && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc, 0) |
| 163052 | 163625 | ){ |
| 163053 | 163626 | sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); |
| 163054 | 163627 | } |
| 163055 | 163628 | } |
| 163056 | 163629 | if( pLoop->wsFlags & WHERE_IPK ){ |
| | @@ -163100,10 +163673,24 @@ |
| 163100 | 163673 | pParse->pIdxPartExpr = saved_pIdxPartExpr; |
| 163101 | 163674 | } |
| 163102 | 163675 | |
| 163103 | 163676 | |
| 163104 | 163677 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 163678 | +/* |
| 163679 | +** Return term iTerm of the WhereClause passed as the first argument. Terms |
| 163680 | +** are numbered from 0 upwards, starting with the terms in pWC->a[], then |
| 163681 | +** those in pWC->pOuter->a[] (if any), and so on. |
| 163682 | +*/ |
| 163683 | +static WhereTerm *termFromWhereClause(WhereClause *pWC, int iTerm){ |
| 163684 | + WhereClause *p; |
| 163685 | + for(p=pWC; p; p=p->pOuter){ |
| 163686 | + if( iTerm<p->nTerm ) return &p->a[iTerm]; |
| 163687 | + iTerm -= p->nTerm; |
| 163688 | + } |
| 163689 | + return 0; |
| 163690 | +} |
| 163691 | + |
| 163105 | 163692 | /* |
| 163106 | 163693 | ** Allocate and populate an sqlite3_index_info structure. It is the |
| 163107 | 163694 | ** responsibility of the caller to eventually release the structure |
| 163108 | 163695 | ** by passing the pointer returned by this function to freeIndexInfo(). |
| 163109 | 163696 | */ |
| | @@ -163126,10 +163713,11 @@ |
| 163126 | 163713 | sqlite3_index_info *pIdxInfo; |
| 163127 | 163714 | u16 mNoOmit = 0; |
| 163128 | 163715 | const Table *pTab; |
| 163129 | 163716 | int eDistinct = 0; |
| 163130 | 163717 | ExprList *pOrderBy = pWInfo->pOrderBy; |
| 163718 | + WhereClause *p; |
| 163131 | 163719 | |
| 163132 | 163720 | assert( pSrc!=0 ); |
| 163133 | 163721 | pTab = pSrc->pTab; |
| 163134 | 163722 | assert( pTab!=0 ); |
| 163135 | 163723 | assert( IsVirtual(pTab) ); |
| | @@ -163136,32 +163724,34 @@ |
| 163136 | 163724 | |
| 163137 | 163725 | /* Find all WHERE clause constraints referring to this virtual table. |
| 163138 | 163726 | ** Mark each term with the TERM_OK flag. Set nTerm to the number of |
| 163139 | 163727 | ** terms found. |
| 163140 | 163728 | */ |
| 163141 | | - for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 163142 | | - pTerm->wtFlags &= ~TERM_OK; |
| 163143 | | - if( pTerm->leftCursor != pSrc->iCursor ) continue; |
| 163144 | | - if( pTerm->prereqRight & mUnusable ) continue; |
| 163145 | | - assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) ); |
| 163146 | | - testcase( pTerm->eOperator & WO_IN ); |
| 163147 | | - testcase( pTerm->eOperator & WO_ISNULL ); |
| 163148 | | - testcase( pTerm->eOperator & WO_IS ); |
| 163149 | | - testcase( pTerm->eOperator & WO_ALL ); |
| 163150 | | - if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; |
| 163151 | | - if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 163152 | | - |
| 163153 | | - assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 163154 | | - assert( pTerm->u.x.leftColumn>=XN_ROWID ); |
| 163155 | | - assert( pTerm->u.x.leftColumn<pTab->nCol ); |
| 163156 | | - if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 |
| 163157 | | - && !constraintCompatibleWithOuterJoin(pTerm,pSrc) |
| 163158 | | - ){ |
| 163159 | | - continue; |
| 163160 | | - } |
| 163161 | | - nTerm++; |
| 163162 | | - pTerm->wtFlags |= TERM_OK; |
| 163729 | + for(p=pWC, nTerm=0; p; p=p->pOuter){ |
| 163730 | + for(i=0, pTerm=p->a; i<p->nTerm; i++, pTerm++){ |
| 163731 | + pTerm->wtFlags &= ~TERM_OK; |
| 163732 | + if( pTerm->leftCursor != pSrc->iCursor ) continue; |
| 163733 | + if( pTerm->prereqRight & mUnusable ) continue; |
| 163734 | + assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) ); |
| 163735 | + testcase( pTerm->eOperator & WO_IN ); |
| 163736 | + testcase( pTerm->eOperator & WO_ISNULL ); |
| 163737 | + testcase( pTerm->eOperator & WO_IS ); |
| 163738 | + testcase( pTerm->eOperator & WO_ALL ); |
| 163739 | + if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; |
| 163740 | + if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 163741 | + |
| 163742 | + assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 163743 | + assert( pTerm->u.x.leftColumn>=XN_ROWID ); |
| 163744 | + assert( pTerm->u.x.leftColumn<pTab->nCol ); |
| 163745 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 |
| 163746 | + && !constraintCompatibleWithOuterJoin(pTerm,pSrc) |
| 163747 | + ){ |
| 163748 | + continue; |
| 163749 | + } |
| 163750 | + nTerm++; |
| 163751 | + pTerm->wtFlags |= TERM_OK; |
| 163752 | + } |
| 163163 | 163753 | } |
| 163164 | 163754 | |
| 163165 | 163755 | /* If the ORDER BY clause contains only columns in the current |
| 163166 | 163756 | ** virtual table then allocate space for the aOrderBy part of |
| 163167 | 163757 | ** the sqlite3_index_info structure. |
| | @@ -163207,11 +163797,11 @@ |
| 163207 | 163797 | /* No matches cause a break out of the loop */ |
| 163208 | 163798 | break; |
| 163209 | 163799 | } |
| 163210 | 163800 | if( i==n ){ |
| 163211 | 163801 | nOrderBy = n; |
| 163212 | | - if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) ){ |
| 163802 | + if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) && !pSrc->fg.rowidUsed ){ |
| 163213 | 163803 | eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0); |
| 163214 | 163804 | }else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){ |
| 163215 | 163805 | eDistinct = 1; |
| 163216 | 163806 | } |
| 163217 | 163807 | } |
| | @@ -163236,53 +163826,56 @@ |
| 163236 | 163826 | pIdxInfo->aConstraintUsage = pUsage; |
| 163237 | 163827 | pHidden->pWC = pWC; |
| 163238 | 163828 | pHidden->pParse = pParse; |
| 163239 | 163829 | pHidden->eDistinct = eDistinct; |
| 163240 | 163830 | pHidden->mIn = 0; |
| 163241 | | - for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 163242 | | - u16 op; |
| 163243 | | - if( (pTerm->wtFlags & TERM_OK)==0 ) continue; |
| 163244 | | - pIdxCons[j].iColumn = pTerm->u.x.leftColumn; |
| 163245 | | - pIdxCons[j].iTermOffset = i; |
| 163246 | | - op = pTerm->eOperator & WO_ALL; |
| 163247 | | - if( op==WO_IN ){ |
| 163248 | | - if( (pTerm->wtFlags & TERM_SLICE)==0 ){ |
| 163249 | | - pHidden->mIn |= SMASKBIT32(j); |
| 163250 | | - } |
| 163251 | | - op = WO_EQ; |
| 163252 | | - } |
| 163253 | | - if( op==WO_AUX ){ |
| 163254 | | - pIdxCons[j].op = pTerm->eMatchOp; |
| 163255 | | - }else if( op & (WO_ISNULL|WO_IS) ){ |
| 163256 | | - if( op==WO_ISNULL ){ |
| 163257 | | - pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL; |
| 163258 | | - }else{ |
| 163259 | | - pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS; |
| 163260 | | - } |
| 163261 | | - }else{ |
| 163262 | | - pIdxCons[j].op = (u8)op; |
| 163263 | | - /* The direct assignment in the previous line is possible only because |
| 163264 | | - ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The |
| 163265 | | - ** following asserts verify this fact. */ |
| 163266 | | - assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ ); |
| 163267 | | - assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT ); |
| 163268 | | - assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE ); |
| 163269 | | - assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT ); |
| 163270 | | - assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE ); |
| 163271 | | - assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) ); |
| 163272 | | - |
| 163273 | | - if( op & (WO_LT|WO_LE|WO_GT|WO_GE) |
| 163274 | | - && sqlite3ExprIsVector(pTerm->pExpr->pRight) |
| 163275 | | - ){ |
| 163276 | | - testcase( j!=i ); |
| 163277 | | - if( j<16 ) mNoOmit |= (1 << j); |
| 163278 | | - if( op==WO_LT ) pIdxCons[j].op = WO_LE; |
| 163279 | | - if( op==WO_GT ) pIdxCons[j].op = WO_GE; |
| 163280 | | - } |
| 163281 | | - } |
| 163282 | | - |
| 163283 | | - j++; |
| 163831 | + for(p=pWC, i=j=0; p; p=p->pOuter){ |
| 163832 | + int nLast = i+p->nTerm;; |
| 163833 | + for(pTerm=p->a; i<nLast; i++, pTerm++){ |
| 163834 | + u16 op; |
| 163835 | + if( (pTerm->wtFlags & TERM_OK)==0 ) continue; |
| 163836 | + pIdxCons[j].iColumn = pTerm->u.x.leftColumn; |
| 163837 | + pIdxCons[j].iTermOffset = i; |
| 163838 | + op = pTerm->eOperator & WO_ALL; |
| 163839 | + if( op==WO_IN ){ |
| 163840 | + if( (pTerm->wtFlags & TERM_SLICE)==0 ){ |
| 163841 | + pHidden->mIn |= SMASKBIT32(j); |
| 163842 | + } |
| 163843 | + op = WO_EQ; |
| 163844 | + } |
| 163845 | + if( op==WO_AUX ){ |
| 163846 | + pIdxCons[j].op = pTerm->eMatchOp; |
| 163847 | + }else if( op & (WO_ISNULL|WO_IS) ){ |
| 163848 | + if( op==WO_ISNULL ){ |
| 163849 | + pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL; |
| 163850 | + }else{ |
| 163851 | + pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS; |
| 163852 | + } |
| 163853 | + }else{ |
| 163854 | + pIdxCons[j].op = (u8)op; |
| 163855 | + /* The direct assignment in the previous line is possible only because |
| 163856 | + ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The |
| 163857 | + ** following asserts verify this fact. */ |
| 163858 | + assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ ); |
| 163859 | + assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT ); |
| 163860 | + assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE ); |
| 163861 | + assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT ); |
| 163862 | + assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE ); |
| 163863 | + assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) ); |
| 163864 | + |
| 163865 | + if( op & (WO_LT|WO_LE|WO_GT|WO_GE) |
| 163866 | + && sqlite3ExprIsVector(pTerm->pExpr->pRight) |
| 163867 | + ){ |
| 163868 | + testcase( j!=i ); |
| 163869 | + if( j<16 ) mNoOmit |= (1 << j); |
| 163870 | + if( op==WO_LT ) pIdxCons[j].op = WO_LE; |
| 163871 | + if( op==WO_GT ) pIdxCons[j].op = WO_GE; |
| 163872 | + } |
| 163873 | + } |
| 163874 | + |
| 163875 | + j++; |
| 163876 | + } |
| 163284 | 163877 | } |
| 163285 | 163878 | assert( j==nTerm ); |
| 163286 | 163879 | pIdxInfo->nConstraint = j; |
| 163287 | 163880 | for(i=j=0; i<nOrderBy; i++){ |
| 163288 | 163881 | Expr *pExpr = pOrderBy->a[i].pExpr; |
| | @@ -163297,10 +163890,21 @@ |
| 163297 | 163890 | pIdxInfo->nOrderBy = j; |
| 163298 | 163891 | |
| 163299 | 163892 | *pmNoOmit = mNoOmit; |
| 163300 | 163893 | return pIdxInfo; |
| 163301 | 163894 | } |
| 163895 | + |
| 163896 | +/* |
| 163897 | +** Free and zero the sqlite3_index_info.idxStr value if needed. |
| 163898 | +*/ |
| 163899 | +static void freeIdxStr(sqlite3_index_info *pIdxInfo){ |
| 163900 | + if( pIdxInfo->needToFreeIdxStr ){ |
| 163901 | + sqlite3_free(pIdxInfo->idxStr); |
| 163902 | + pIdxInfo->idxStr = 0; |
| 163903 | + pIdxInfo->needToFreeIdxStr = 0; |
| 163904 | + } |
| 163905 | +} |
| 163302 | 163906 | |
| 163303 | 163907 | /* |
| 163304 | 163908 | ** Free an sqlite3_index_info structure allocated by allocateIndexInfo() |
| 163305 | 163909 | ** and possibly modified by xBestIndex methods. |
| 163306 | 163910 | */ |
| | @@ -163313,10 +163917,11 @@ |
| 163313 | 163917 | assert( pHidden->pParse->db==db ); |
| 163314 | 163918 | for(i=0; i<pIdxInfo->nConstraint; i++){ |
| 163315 | 163919 | sqlite3ValueFree(pHidden->aRhs[i]); /* IMP: R-14553-25174 */ |
| 163316 | 163920 | pHidden->aRhs[i] = 0; |
| 163317 | 163921 | } |
| 163922 | + freeIdxStr(pIdxInfo); |
| 163318 | 163923 | sqlite3DbFree(db, pIdxInfo); |
| 163319 | 163924 | } |
| 163320 | 163925 | |
| 163321 | 163926 | /* |
| 163322 | 163927 | ** The table object reference passed as the second argument to this function |
| | @@ -164664,11 +165269,11 @@ |
| 164664 | 165269 | && (pTerm->wtFlags & TERM_HIGHTRUTH)==0 /* tag-20200224-1 */ |
| 164665 | 165270 | ){ |
| 164666 | 165271 | Expr *pRight = pTerm->pExpr->pRight; |
| 164667 | 165272 | int k = 0; |
| 164668 | 165273 | testcase( pTerm->pExpr->op==TK_IS ); |
| 164669 | | - if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){ |
| 165274 | + if( sqlite3ExprIsInteger(pRight, &k, 0) && k>=(-1) && k<=1 ){ |
| 164670 | 165275 | k = 10; |
| 164671 | 165276 | }else{ |
| 164672 | 165277 | k = 20; |
| 164673 | 165278 | } |
| 164674 | 165279 | if( iReduce<k ){ |
| | @@ -164961,11 +165566,11 @@ |
| 164961 | 165566 | assert( saved_nEq==pNew->u.btree.nEq ); |
| 164962 | 165567 | if( iCol==XN_ROWID |
| 164963 | 165568 | || (iCol>=0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1) |
| 164964 | 165569 | ){ |
| 164965 | 165570 | if( iCol==XN_ROWID || pProbe->uniqNotNull |
| 164966 | | - || (pProbe->nKeyCol==1 && pProbe->onError && eOp==WO_EQ) |
| 165571 | + || (pProbe->nKeyCol==1 && pProbe->onError && (eOp & WO_EQ)) |
| 164967 | 165572 | ){ |
| 164968 | 165573 | pNew->wsFlags |= WHERE_ONEROW; |
| 164969 | 165574 | }else{ |
| 164970 | 165575 | pNew->wsFlags |= WHERE_UNQ_WANTED; |
| 164971 | 165576 | } |
| | @@ -165087,14 +165692,17 @@ |
| 165087 | 165692 | } |
| 165088 | 165693 | } |
| 165089 | 165694 | } |
| 165090 | 165695 | } |
| 165091 | 165696 | |
| 165092 | | - /* Set rCostIdx to the cost of visiting selected rows in index. Add |
| 165093 | | - ** it to pNew->rRun, which is currently set to the cost of the index |
| 165094 | | - ** seek only. Then, if this is a non-covering index, add the cost of |
| 165095 | | - ** visiting the rows in the main table. */ |
| 165697 | + /* Set rCostIdx to the estimated cost of visiting selected rows in the |
| 165698 | + ** index. The estimate is the sum of two values: |
| 165699 | + ** 1. The cost of doing one search-by-key to find the first matching |
| 165700 | + ** entry |
| 165701 | + ** 2. Stepping forward in the index pNew->nOut times to find all |
| 165702 | + ** additional matching entries. |
| 165703 | + */ |
| 165096 | 165704 | assert( pSrc->pTab->szTabRow>0 ); |
| 165097 | 165705 | if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){ |
| 165098 | 165706 | /* The pProbe->szIdxRow is low for an IPK table since the interior |
| 165099 | 165707 | ** pages are small. Thus szIdxRow gives a good estimate of seek cost. |
| 165100 | 165708 | ** But the leaf pages are full-size, so pProbe->szIdxRow would badly |
| | @@ -165101,11 +165709,19 @@ |
| 165101 | 165709 | ** under-estimate the scanning cost. */ |
| 165102 | 165710 | rCostIdx = pNew->nOut + 16; |
| 165103 | 165711 | }else{ |
| 165104 | 165712 | rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow; |
| 165105 | 165713 | } |
| 165106 | | - pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx); |
| 165714 | + rCostIdx = sqlite3LogEstAdd(rLogSize, rCostIdx); |
| 165715 | + |
| 165716 | + /* Estimate the cost of running the loop. If all data is coming |
| 165717 | + ** from the index, then this is just the cost of doing the index |
| 165718 | + ** lookup and scan. But if some data is coming out of the main table, |
| 165719 | + ** we also have to add in the cost of doing pNew->nOut searches to |
| 165720 | + ** locate the row in the main table that corresponds to the index entry. |
| 165721 | + */ |
| 165722 | + pNew->rRun = rCostIdx; |
| 165107 | 165723 | if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK|WHERE_EXPRIDX))==0 ){ |
| 165108 | 165724 | pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16); |
| 165109 | 165725 | } |
| 165110 | 165726 | ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult); |
| 165111 | 165727 | |
| | @@ -165836,10 +166452,25 @@ |
| 165836 | 166452 | static int isLimitTerm(WhereTerm *pTerm){ |
| 165837 | 166453 | assert( pTerm->eOperator==WO_AUX || pTerm->eMatchOp==0 ); |
| 165838 | 166454 | return pTerm->eMatchOp>=SQLITE_INDEX_CONSTRAINT_LIMIT |
| 165839 | 166455 | && pTerm->eMatchOp<=SQLITE_INDEX_CONSTRAINT_OFFSET; |
| 165840 | 166456 | } |
| 166457 | + |
| 166458 | +/* |
| 166459 | +** Return true if the first nCons constraints in the pUsage array are |
| 166460 | +** marked as in-use (have argvIndex>0). False otherwise. |
| 166461 | +*/ |
| 166462 | +static int allConstraintsUsed( |
| 166463 | + struct sqlite3_index_constraint_usage *aUsage, |
| 166464 | + int nCons |
| 166465 | +){ |
| 166466 | + int ii; |
| 166467 | + for(ii=0; ii<nCons; ii++){ |
| 166468 | + if( aUsage[ii].argvIndex<=0 ) return 0; |
| 166469 | + } |
| 166470 | + return 1; |
| 166471 | +} |
| 165841 | 166472 | |
| 165842 | 166473 | /* |
| 165843 | 166474 | ** Argument pIdxInfo is already populated with all constraints that may |
| 165844 | 166475 | ** be used by the virtual table identified by pBuilder->pNew->iTab. This |
| 165845 | 166476 | ** function marks a subset of those constraints usable, invokes the |
| | @@ -165887,11 +166518,11 @@ |
| 165887 | 166518 | |
| 165888 | 166519 | /* Set the usable flag on the subset of constraints identified by |
| 165889 | 166520 | ** arguments mUsable and mExclude. */ |
| 165890 | 166521 | pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; |
| 165891 | 166522 | for(i=0; i<nConstraint; i++, pIdxCons++){ |
| 165892 | | - WhereTerm *pTerm = &pWC->a[pIdxCons->iTermOffset]; |
| 166523 | + WhereTerm *pTerm = termFromWhereClause(pWC, pIdxCons->iTermOffset); |
| 165893 | 166524 | pIdxCons->usable = 0; |
| 165894 | 166525 | if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight |
| 165895 | 166526 | && (pTerm->eOperator & mExclude)==0 |
| 165896 | 166527 | && (pbRetryLimit || !isLimitTerm(pTerm)) |
| 165897 | 166528 | ){ |
| | @@ -165918,10 +166549,11 @@ |
| 165918 | 166549 | /* If the xBestIndex method returns SQLITE_CONSTRAINT, that means |
| 165919 | 166550 | ** that the particular combination of parameters provided is unusable. |
| 165920 | 166551 | ** Make no entries in the loop table. |
| 165921 | 166552 | */ |
| 165922 | 166553 | WHERETRACE(0xffffffff, (" ^^^^--- non-viable plan rejected!\n")); |
| 166554 | + freeIdxStr(pIdxInfo); |
| 165923 | 166555 | return SQLITE_OK; |
| 165924 | 166556 | } |
| 165925 | 166557 | return rc; |
| 165926 | 166558 | } |
| 165927 | 166559 | |
| | @@ -165935,22 +166567,21 @@ |
| 165935 | 166567 | if( (iTerm = pUsage[i].argvIndex - 1)>=0 ){ |
| 165936 | 166568 | WhereTerm *pTerm; |
| 165937 | 166569 | int j = pIdxCons->iTermOffset; |
| 165938 | 166570 | if( iTerm>=nConstraint |
| 165939 | 166571 | || j<0 |
| 165940 | | - || j>=pWC->nTerm |
| 166572 | + || (pTerm = termFromWhereClause(pWC, j))==0 |
| 165941 | 166573 | || pNew->aLTerm[iTerm]!=0 |
| 165942 | 166574 | || pIdxCons->usable==0 |
| 165943 | 166575 | ){ |
| 165944 | 166576 | sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); |
| 165945 | | - testcase( pIdxInfo->needToFreeIdxStr ); |
| 166577 | + freeIdxStr(pIdxInfo); |
| 165946 | 166578 | return SQLITE_ERROR; |
| 165947 | 166579 | } |
| 165948 | 166580 | testcase( iTerm==nConstraint-1 ); |
| 165949 | 166581 | testcase( j==0 ); |
| 165950 | 166582 | testcase( j==pWC->nTerm-1 ); |
| 165951 | | - pTerm = &pWC->a[j]; |
| 165952 | 166583 | pNew->prereq |= pTerm->prereqRight; |
| 165953 | 166584 | assert( iTerm<pNew->nLSlot ); |
| 165954 | 166585 | pNew->aLTerm[iTerm] = pTerm; |
| 165955 | 166586 | if( iTerm>mxTerm ) mxTerm = iTerm; |
| 165956 | 166587 | testcase( iTerm==15 ); |
| | @@ -165977,22 +166608,25 @@ |
| 165977 | 166608 | pIdxInfo->orderByConsumed = 0; |
| 165978 | 166609 | pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE; |
| 165979 | 166610 | *pbIn = 1; assert( (mExclude & WO_IN)==0 ); |
| 165980 | 166611 | } |
| 165981 | 166612 | |
| 166613 | + /* Unless pbRetryLimit is non-NULL, there should be no LIMIT/OFFSET |
| 166614 | + ** terms. And if there are any, they should follow all other terms. */ |
| 165982 | 166615 | assert( pbRetryLimit || !isLimitTerm(pTerm) ); |
| 165983 | | - if( isLimitTerm(pTerm) && *pbIn ){ |
| 166616 | + assert( !isLimitTerm(pTerm) || i>=nConstraint-2 ); |
| 166617 | + assert( !isLimitTerm(pTerm) || i==nConstraint-1 || isLimitTerm(pTerm+1) ); |
| 166618 | + |
| 166619 | + if( isLimitTerm(pTerm) && (*pbIn || !allConstraintsUsed(pUsage, i)) ){ |
| 165984 | 166620 | /* If there is an IN(...) term handled as an == (separate call to |
| 165985 | 166621 | ** xFilter for each value on the RHS of the IN) and a LIMIT or |
| 165986 | | - ** OFFSET term handled as well, the plan is unusable. Set output |
| 165987 | | - ** variable *pbRetryLimit to true to tell the caller to retry with |
| 165988 | | - ** LIMIT and OFFSET disabled. */ |
| 165989 | | - if( pIdxInfo->needToFreeIdxStr ){ |
| 165990 | | - sqlite3_free(pIdxInfo->idxStr); |
| 165991 | | - pIdxInfo->idxStr = 0; |
| 165992 | | - pIdxInfo->needToFreeIdxStr = 0; |
| 165993 | | - } |
| 166622 | + ** OFFSET term handled as well, the plan is unusable. Similarly, |
| 166623 | + ** if there is a LIMIT/OFFSET and there are other unused terms, |
| 166624 | + ** the plan cannot be used. In these cases set variable *pbRetryLimit |
| 166625 | + ** to true to tell the caller to retry with LIMIT and OFFSET |
| 166626 | + ** disabled. */ |
| 166627 | + freeIdxStr(pIdxInfo); |
| 165994 | 166628 | *pbRetryLimit = 1; |
| 165995 | 166629 | return SQLITE_OK; |
| 165996 | 166630 | } |
| 165997 | 166631 | } |
| 165998 | 166632 | } |
| | @@ -166001,11 +166635,11 @@ |
| 166001 | 166635 | for(i=0; i<=mxTerm; i++){ |
| 166002 | 166636 | if( pNew->aLTerm[i]==0 ){ |
| 166003 | 166637 | /* The non-zero argvIdx values must be contiguous. Raise an |
| 166004 | 166638 | ** error if they are not */ |
| 166005 | 166639 | sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); |
| 166006 | | - testcase( pIdxInfo->needToFreeIdxStr ); |
| 166640 | + freeIdxStr(pIdxInfo); |
| 166007 | 166641 | return SQLITE_ERROR; |
| 166008 | 166642 | } |
| 166009 | 166643 | } |
| 166010 | 166644 | assert( pNew->nLTerm<=pNew->nLSlot ); |
| 166011 | 166645 | pNew->u.vtab.idxNum = pIdxInfo->idxNum; |
| | @@ -166056,11 +166690,11 @@ |
| 166056 | 166690 | HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 166057 | 166691 | const char *zRet = 0; |
| 166058 | 166692 | if( iCons>=0 && iCons<pIdxInfo->nConstraint ){ |
| 166059 | 166693 | CollSeq *pC = 0; |
| 166060 | 166694 | int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset; |
| 166061 | | - Expr *pX = pHidden->pWC->a[iTerm].pExpr; |
| 166695 | + Expr *pX = termFromWhereClause(pHidden->pWC, iTerm)->pExpr; |
| 166062 | 166696 | if( pX->pLeft ){ |
| 166063 | 166697 | pC = sqlite3ExprCompareCollSeq(pHidden->pParse, pX); |
| 166064 | 166698 | } |
| 166065 | 166699 | zRet = (pC ? pC->zName : sqlite3StrBINARY); |
| 166066 | 166700 | } |
| | @@ -166102,11 +166736,13 @@ |
| 166102 | 166736 | int rc = SQLITE_OK; |
| 166103 | 166737 | if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ |
| 166104 | 166738 | rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */ |
| 166105 | 166739 | }else{ |
| 166106 | 166740 | if( pH->aRhs[iCons]==0 ){ |
| 166107 | | - WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; |
| 166741 | + WhereTerm *pTerm = termFromWhereClause( |
| 166742 | + pH->pWC, pIdxInfo->aConstraint[iCons].iTermOffset |
| 166743 | + ); |
| 166108 | 166744 | rc = sqlite3ValueFromExpr( |
| 166109 | 166745 | pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db), |
| 166110 | 166746 | SQLITE_AFF_BLOB, &pH->aRhs[iCons] |
| 166111 | 166747 | ); |
| 166112 | 166748 | testcase( rc!=SQLITE_OK ); |
| | @@ -166258,13 +166894,12 @@ |
| 166258 | 166894 | while( rc==SQLITE_OK ){ |
| 166259 | 166895 | int i; |
| 166260 | 166896 | Bitmask mNext = ALLBITS; |
| 166261 | 166897 | assert( mNext>0 ); |
| 166262 | 166898 | for(i=0; i<nConstraint; i++){ |
| 166263 | | - Bitmask mThis = ( |
| 166264 | | - pWC->a[p->aConstraint[i].iTermOffset].prereqRight & ~mPrereq |
| 166265 | | - ); |
| 166899 | + int iTerm = p->aConstraint[i].iTermOffset; |
| 166900 | + Bitmask mThis = termFromWhereClause(pWC, iTerm)->prereqRight & ~mPrereq; |
| 166266 | 166901 | if( mThis>mPrev && mThis<mNext ) mNext = mThis; |
| 166267 | 166902 | } |
| 166268 | 166903 | mPrev = mNext; |
| 166269 | 166904 | if( mNext==ALLBITS ) break; |
| 166270 | 166905 | if( mNext==mBest || mNext==mBestNoIn ) continue; |
| | @@ -166296,11 +166931,10 @@ |
| 166296 | 166931 | rc = whereLoopAddVirtualOne( |
| 166297 | 166932 | pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn, 0); |
| 166298 | 166933 | } |
| 166299 | 166934 | } |
| 166300 | 166935 | |
| 166301 | | - if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); |
| 166302 | 166936 | freeIndexInfo(pParse->db, p); |
| 166303 | 166937 | WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc)); |
| 166304 | 166938 | return rc; |
| 166305 | 166939 | } |
| 166306 | 166940 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| | @@ -166673,11 +167307,11 @@ |
| 166673 | 167307 | nColumn = pIndex->nColumn; |
| 166674 | 167308 | assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) ); |
| 166675 | 167309 | assert( pIndex->aiColumn[nColumn-1]==XN_ROWID |
| 166676 | 167310 | || !HasRowid(pIndex->pTable)); |
| 166677 | 167311 | /* All relevant terms of the index must also be non-NULL in order |
| 166678 | | - ** for isOrderDistinct to be true. So the isOrderDistint value |
| 167312 | + ** for isOrderDistinct to be true. So the isOrderDistinct value |
| 166679 | 167313 | ** computed here might be a false positive. Corrections will be |
| 166680 | 167314 | ** made at tag-20210426-1 below */ |
| 166681 | 167315 | isOrderDistinct = IsUniqueIndex(pIndex) |
| 166682 | 167316 | && (pLoop->wsFlags & WHERE_SKIPSCAN)==0; |
| 166683 | 167317 | } |
| | @@ -166964,10 +167598,87 @@ |
| 166964 | 167598 | if( nRow>10 ){ nRow -= 10; assert( 10==sqlite3LogEst(2) ); } |
| 166965 | 167599 | } |
| 166966 | 167600 | rSortCost += estLog(nRow); |
| 166967 | 167601 | return rSortCost; |
| 166968 | 167602 | } |
| 167603 | + |
| 167604 | +/* |
| 167605 | +** Compute the maximum number of paths in the solver algorithm, for |
| 167606 | +** queries that have three or more terms in the FROM clause. Queries with |
| 167607 | +** two or fewer FROM clause terms are handled by the caller. |
| 167608 | +** |
| 167609 | +** Query planning is NP-hard. We must limit the number of paths at |
| 167610 | +** each step of the solver search algorithm to avoid exponential behavior. |
| 167611 | +** |
| 167612 | +** The value returned is a tuning parameter. Currently the value is: |
| 167613 | +** |
| 167614 | +** 18 for star queries |
| 167615 | +** 12 otherwise |
| 167616 | +** |
| 167617 | +** For the purposes of SQLite, a star-query is defined as a query |
| 167618 | +** with a large central table that is joined against four or more |
| 167619 | +** smaller tables. The central table is called the "fact" table. |
| 167620 | +** The smaller tables that get joined are "dimension tables". |
| 167621 | +** |
| 167622 | +** SIDE EFFECT: (and really the whole point of this subroutine) |
| 167623 | +** |
| 167624 | +** If pWInfo describes a star-query, then the cost on WhereLoops for the |
| 167625 | +** fact table is reduced. This heuristic helps keep fact tables in |
| 167626 | +** outer loops. Without this heuristic, paths with fact tables in outer |
| 167627 | +** loops tend to get pruned by the mxChoice limit on the number of paths, |
| 167628 | +** resulting in poor query plans. The total amount of heuristic cost |
| 167629 | +** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment |
| 167630 | +** for each WhereLoop is stored in its rStarDelta field. |
| 167631 | +*/ |
| 167632 | +static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ |
| 167633 | + int nLoop = pWInfo->nLevel; /* Number of terms in the join */ |
| 167634 | + if( nRowEst==0 && nLoop>=5 ){ |
| 167635 | + /* Check to see if we are dealing with a star schema and if so, reduce |
| 167636 | + ** the cost of fact tables relative to dimension tables, as a heuristic |
| 167637 | + ** to help keep the fact tables in outer loops. |
| 167638 | + */ |
| 167639 | + int iLoop; /* Counter over join terms */ |
| 167640 | + Bitmask m; /* Bitmask for current loop */ |
| 167641 | + assert( pWInfo->nOutStarDelta==0 ); |
| 167642 | + for(iLoop=0, m=1; iLoop<nLoop; iLoop++, m<<=1){ |
| 167643 | + WhereLoop *pWLoop; /* For looping over WhereLoops */ |
| 167644 | + int nDep = 0; /* Number of dimension tables */ |
| 167645 | + LogEst rDelta; /* Heuristic cost adjustment */ |
| 167646 | + Bitmask mSeen = 0; /* Mask of dimension tables */ |
| 167647 | + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ |
| 167648 | + if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){ |
| 167649 | + nDep++; |
| 167650 | + mSeen |= pWLoop->maskSelf; |
| 167651 | + } |
| 167652 | + } |
| 167653 | + if( nDep<=3 ) continue; |
| 167654 | + rDelta = 15*(nDep-3); |
| 167655 | +#ifdef WHERETRACE_ENABLED /* 0x4 */ |
| 167656 | + if( sqlite3WhereTrace&0x4 ){ |
| 167657 | + SrcItem *pItem = pWInfo->pTabList->a + iLoop; |
| 167658 | + sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n", |
| 167659 | + pItem->zAlias ? pItem->zAlias : pItem->pTab->zName, |
| 167660 | + nDep, rDelta); |
| 167661 | + } |
| 167662 | +#endif |
| 167663 | + if( pWInfo->nOutStarDelta==0 ){ |
| 167664 | + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ |
| 167665 | + pWLoop->rStarDelta = 0; |
| 167666 | + } |
| 167667 | + } |
| 167668 | + pWInfo->nOutStarDelta += rDelta; |
| 167669 | + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ |
| 167670 | + if( pWLoop->maskSelf==m ){ |
| 167671 | + pWLoop->rRun -= rDelta; |
| 167672 | + pWLoop->nOut -= rDelta; |
| 167673 | + pWLoop->rStarDelta = rDelta; |
| 167674 | + } |
| 167675 | + } |
| 167676 | + } |
| 167677 | + } |
| 167678 | + return pWInfo->nOutStarDelta>0 ? 18 : 12; |
| 167679 | +} |
| 166969 | 167680 | |
| 166970 | 167681 | /* |
| 166971 | 167682 | ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine |
| 166972 | 167683 | ** attempts to find the lowest cost path that visits each WhereLoop |
| 166973 | 167684 | ** once. This path is then loaded into the pWInfo->a[].pWLoop fields. |
| | @@ -167000,17 +167711,29 @@ |
| 167000 | 167711 | char *pSpace; /* Temporary memory used by this routine */ |
| 167001 | 167712 | int nSpace; /* Bytes of space allocated at pSpace */ |
| 167002 | 167713 | |
| 167003 | 167714 | pParse = pWInfo->pParse; |
| 167004 | 167715 | nLoop = pWInfo->nLevel; |
| 167005 | | - /* TUNING: For simple queries, only the best path is tracked. |
| 167006 | | - ** For 2-way joins, the 5 best paths are followed. |
| 167007 | | - ** For joins of 3 or more tables, track the 10 best paths */ |
| 167008 | | - mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10); |
| 167009 | | - assert( nLoop<=pWInfo->pTabList->nSrc ); |
| 167010 | 167716 | WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", |
| 167011 | 167717 | nRowEst, pParse->nQueryLoop)); |
| 167718 | + /* TUNING: mxChoice is the maximum number of possible paths to preserve |
| 167719 | + ** at each step. Based on the number of loops in the FROM clause: |
| 167720 | + ** |
| 167721 | + ** nLoop mxChoice |
| 167722 | + ** ----- -------- |
| 167723 | + ** 1 1 // the most common case |
| 167724 | + ** 2 5 |
| 167725 | + ** 3+ 12 or 18 // see computeMxChoice() |
| 167726 | + */ |
| 167727 | + if( nLoop<=1 ){ |
| 167728 | + mxChoice = 1; |
| 167729 | + }else if( nLoop==2 ){ |
| 167730 | + mxChoice = 5; |
| 167731 | + }else{ |
| 167732 | + mxChoice = computeMxChoice(pWInfo, nRowEst); |
| 167733 | + } |
| 167734 | + assert( nLoop<=pWInfo->pTabList->nSrc ); |
| 167012 | 167735 | |
| 167013 | 167736 | /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this |
| 167014 | 167737 | ** case the purpose of this call is to estimate the number of rows returned |
| 167015 | 167738 | ** by the overall query. Once this estimate has been obtained, the caller |
| 167016 | 167739 | ** will invoke this function a second time, passing the estimate as the |
| | @@ -167089,11 +167812,14 @@ |
| 167089 | 167812 | continue; |
| 167090 | 167813 | } |
| 167091 | 167814 | |
| 167092 | 167815 | /* At this point, pWLoop is a candidate to be the next loop. |
| 167093 | 167816 | ** Compute its cost */ |
| 167094 | | - rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow); |
| 167817 | + rUnsorted = pWLoop->rRun + pFrom->nRow; |
| 167818 | + if( pWLoop->rSetup ){ |
| 167819 | + rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup, rUnsorted); |
| 167820 | + } |
| 167095 | 167821 | rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted); |
| 167096 | 167822 | nOut = pFrom->nRow + pWLoop->nOut; |
| 167097 | 167823 | maskNew = pFrom->maskLoop | pWLoop->maskSelf; |
| 167098 | 167824 | isOrdered = pFrom->isOrdered; |
| 167099 | 167825 | if( isOrdered<0 ){ |
| | @@ -167134,10 +167860,11 @@ |
| 167134 | 167860 | ** |
| 167135 | 167861 | ** The term "((pTo->isOrdered^isOrdered)&0x80)==0" is equivalent |
| 167136 | 167862 | ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range |
| 167137 | 167863 | ** of legal values for isOrdered, -1..64. |
| 167138 | 167864 | */ |
| 167865 | + testcase( nTo==0 ); |
| 167139 | 167866 | for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){ |
| 167140 | 167867 | if( pTo->maskLoop==maskNew |
| 167141 | 167868 | && ((pTo->isOrdered^isOrdered)&0x80)==0 |
| 167142 | 167869 | ){ |
| 167143 | 167870 | testcase( jj==nTo-1 ); |
| | @@ -167250,20 +167977,32 @@ |
| 167250 | 167977 | } |
| 167251 | 167978 | } |
| 167252 | 167979 | |
| 167253 | 167980 | #ifdef WHERETRACE_ENABLED /* >=2 */ |
| 167254 | 167981 | if( sqlite3WhereTrace & 0x02 ){ |
| 167982 | + LogEst rMin, rFloor = 0; |
| 167983 | + int nDone = 0; |
| 167255 | 167984 | sqlite3DebugPrintf("---- after round %d ----\n", iLoop); |
| 167256 | | - for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){ |
| 167257 | | - sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c", |
| 167258 | | - wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow, |
| 167259 | | - pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?'); |
| 167260 | | - if( pTo->isOrdered>0 ){ |
| 167261 | | - sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop); |
| 167262 | | - }else{ |
| 167263 | | - sqlite3DebugPrintf("\n"); |
| 167264 | | - } |
| 167985 | + while( nDone<nTo ){ |
| 167986 | + rMin = 0x7fff; |
| 167987 | + for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){ |
| 167988 | + if( pTo->rCost>rFloor && pTo->rCost<rMin ) rMin = pTo->rCost; |
| 167989 | + } |
| 167990 | + for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){ |
| 167991 | + if( pTo->rCost==rMin ){ |
| 167992 | + sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c", |
| 167993 | + wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow, |
| 167994 | + pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?'); |
| 167995 | + if( pTo->isOrdered>0 ){ |
| 167996 | + sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop); |
| 167997 | + }else{ |
| 167998 | + sqlite3DebugPrintf("\n"); |
| 167999 | + } |
| 168000 | + nDone++; |
| 168001 | + } |
| 168002 | + } |
| 168003 | + rFloor = rMin; |
| 167265 | 168004 | } |
| 167266 | 168005 | } |
| 167267 | 168006 | #endif |
| 167268 | 168007 | |
| 167269 | 168008 | /* Swap the roles of aFrom and aTo for the next generation */ |
| | @@ -167354,17 +168093,93 @@ |
| 167354 | 168093 | pWInfo->revMask = revMask; |
| 167355 | 168094 | } |
| 167356 | 168095 | } |
| 167357 | 168096 | } |
| 167358 | 168097 | |
| 167359 | | - |
| 167360 | | - pWInfo->nRowOut = pFrom->nRow; |
| 168098 | + pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta; |
| 167361 | 168099 | |
| 167362 | 168100 | /* Free temporary memory and return success */ |
| 167363 | 168101 | sqlite3StackFreeNN(pParse->db, pSpace); |
| 167364 | 168102 | return SQLITE_OK; |
| 167365 | 168103 | } |
| 168104 | + |
| 168105 | +/* |
| 168106 | +** This routine implements a heuristic designed to improve query planning. |
| 168107 | +** This routine is called in between the first and second call to |
| 168108 | +** wherePathSolver(). Hence the name "Interstage" "Heuristic". |
| 168109 | +** |
| 168110 | +** The first call to wherePathSolver() (hereafter just "solver()") computes |
| 168111 | +** the best path without regard to the order of the outputs. The second call |
| 168112 | +** to the solver() builds upon the first call to try to find an alternative |
| 168113 | +** path that satisfies the ORDER BY clause. |
| 168114 | +** |
| 168115 | +** This routine looks at the results of the first solver() run, and for |
| 168116 | +** every FROM clause term in the resulting query plan that uses an equality |
| 168117 | +** constraint against an index, disable other WhereLoops for that same |
| 168118 | +** FROM clause term that would try to do a full-table scan. This prevents |
| 168119 | +** an index search from being converted into a full-table scan in order to |
| 168120 | +** satisfy an ORDER BY clause, since even though we might get slightly better |
| 168121 | +** performance using the full-scan without sorting if the output size |
| 168122 | +** estimates are very precise, we might also get severe performance |
| 168123 | +** degradation using the full-scan if the output size estimate is too large. |
| 168124 | +** It is better to err on the side of caution. |
| 168125 | +** |
| 168126 | +** Except, if the first solver() call generated a full-table scan in an outer |
| 168127 | +** loop then stop this analysis at the first full-scan, since the second |
| 168128 | +** solver() run might try to swap that full-scan for another in order to |
| 168129 | +** get the output into the correct order. In other words, we allow a |
| 168130 | +** rewrite like this: |
| 168131 | +** |
| 168132 | +** First Solver() Second Solver() |
| 168133 | +** |-- SCAN t1 |-- SCAN t2 |
| 168134 | +** |-- SEARCH t2 `-- SEARCH t1 |
| 168135 | +** `-- SORT USING B-TREE |
| 168136 | +** |
| 168137 | +** The purpose of this routine is to disallow rewrites such as: |
| 168138 | +** |
| 168139 | +** First Solver() Second Solver() |
| 168140 | +** |-- SEARCH t1 |-- SCAN t2 <--- bad! |
| 168141 | +** |-- SEARCH t2 `-- SEARCH t1 |
| 168142 | +** `-- SORT USING B-TREE |
| 168143 | +** |
| 168144 | +** See test cases in test/whereN.test for the real-world query that |
| 168145 | +** originally provoked this heuristic. |
| 168146 | +*/ |
| 168147 | +static SQLITE_NOINLINE void whereInterstageHeuristic(WhereInfo *pWInfo){ |
| 168148 | + int i; |
| 168149 | +#ifdef WHERETRACE_ENABLED |
| 168150 | + int once = 0; |
| 168151 | +#endif |
| 168152 | + for(i=0; i<pWInfo->nLevel; i++){ |
| 168153 | + WhereLoop *p = pWInfo->a[i].pWLoop; |
| 168154 | + if( p==0 ) break; |
| 168155 | + if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 ) continue; |
| 168156 | + if( (p->wsFlags & (WHERE_COLUMN_EQ|WHERE_COLUMN_NULL|WHERE_COLUMN_IN))!=0 ){ |
| 168157 | + u8 iTab = p->iTab; |
| 168158 | + WhereLoop *pLoop; |
| 168159 | + for(pLoop=pWInfo->pLoops; pLoop; pLoop=pLoop->pNextLoop){ |
| 168160 | + if( pLoop->iTab!=iTab ) continue; |
| 168161 | + if( (pLoop->wsFlags & (WHERE_CONSTRAINT|WHERE_AUTO_INDEX))!=0 ){ |
| 168162 | + /* Auto-index and index-constrained loops allowed to remain */ |
| 168163 | + continue; |
| 168164 | + } |
| 168165 | +#ifdef WHERETRACE_ENABLED |
| 168166 | + if( sqlite3WhereTrace & 0x80 ){ |
| 168167 | + if( once==0 ){ |
| 168168 | + sqlite3DebugPrintf("Loops disabled by interstage heuristic:\n"); |
| 168169 | + once = 1; |
| 168170 | + } |
| 168171 | + sqlite3WhereLoopPrint(pLoop, &pWInfo->sWC); |
| 168172 | + } |
| 168173 | +#endif /* WHERETRACE_ENABLED */ |
| 168174 | + pLoop->prereq = ALLBITS; /* Prevent 2nd solver() from using this one */ |
| 168175 | + } |
| 168176 | + }else{ |
| 168177 | + break; |
| 168178 | + } |
| 168179 | + } |
| 168180 | +} |
| 167366 | 168181 | |
| 167367 | 168182 | /* |
| 167368 | 168183 | ** Most queries use only a single table (they are not joins) and have |
| 167369 | 168184 | ** simple == constraints against indexed fields. This routine attempts |
| 167370 | 168185 | ** to plan those simple cases using much less ceremony than the |
| | @@ -167530,10 +168345,14 @@ |
| 167530 | 168345 | ** might move from the right side to the left side of the RIGHT JOIN. |
| 167531 | 168346 | ** Note: Due to (2), this condition can only arise if the table is |
| 167532 | 168347 | ** the right-most table of a subquery that was flattened into the |
| 167533 | 168348 | ** main query and that subquery was the right-hand operand of an |
| 167534 | 168349 | ** inner join that held an ON or USING clause. |
| 168350 | +** 6) The ORDER BY clause has 63 or fewer terms |
| 168351 | +** 7) The omit-noop-join optimization is enabled. |
| 168352 | +** |
| 168353 | +** Items (1), (6), and (7) are checked by the caller. |
| 167535 | 168354 | ** |
| 167536 | 168355 | ** For example, given: |
| 167537 | 168356 | ** |
| 167538 | 168357 | ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1); |
| 167539 | 168358 | ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2); |
| | @@ -167668,12 +168487,65 @@ |
| 167668 | 168487 | pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName, |
| 167669 | 168488 | (double)sqlite3LogEstToInt(pTab->nRowLogEst))); |
| 167670 | 168489 | } |
| 167671 | 168490 | } |
| 167672 | 168491 | nSearch += pLoop->nOut; |
| 168492 | + if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta; |
| 167673 | 168493 | } |
| 167674 | 168494 | } |
| 168495 | + |
| 168496 | +/* |
| 168497 | +** Expression Node callback for sqlite3ExprCanReturnSubtype(). |
| 168498 | +** |
| 168499 | +** Only a function call is able to return a subtype. So if the node |
| 168500 | +** is not a function call, return WRC_Prune immediately. |
| 168501 | +** |
| 168502 | +** A function call is able to return a subtype if it has the |
| 168503 | +** SQLITE_RESULT_SUBTYPE property. |
| 168504 | +** |
| 168505 | +** Assume that every function is able to pass-through a subtype from |
| 168506 | +** one of its argument (using sqlite3_result_value()). Most functions |
| 168507 | +** are not this way, but we don't have a mechanism to distinguish those |
| 168508 | +** that are from those that are not, so assume they all work this way. |
| 168509 | +** That means that if one of its arguments is another function and that |
| 168510 | +** other function is able to return a subtype, then this function is |
| 168511 | +** able to return a subtype. |
| 168512 | +*/ |
| 168513 | +static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ |
| 168514 | + int n; |
| 168515 | + FuncDef *pDef; |
| 168516 | + sqlite3 *db; |
| 168517 | + if( pExpr->op!=TK_FUNCTION ){ |
| 168518 | + return WRC_Prune; |
| 168519 | + } |
| 168520 | + assert( ExprUseXList(pExpr) ); |
| 168521 | + db = pWalker->pParse->db; |
| 168522 | + n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; |
| 168523 | + pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); |
| 168524 | + if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ |
| 168525 | + pWalker->eCode = 1; |
| 168526 | + return WRC_Prune; |
| 168527 | + } |
| 168528 | + return WRC_Continue; |
| 168529 | +} |
| 168530 | + |
| 168531 | +/* |
| 168532 | +** Return TRUE if expression pExpr is able to return a subtype. |
| 168533 | +** |
| 168534 | +** A TRUE return does not guarantee that a subtype will be returned. |
| 168535 | +** It only indicates that a subtype return is possible. False positives |
| 168536 | +** are acceptable as they only disable an optimization. False negatives, |
| 168537 | +** on the other hand, can lead to incorrect answers. |
| 168538 | +*/ |
| 168539 | +static int sqlite3ExprCanReturnSubtype(Parse *pParse, Expr *pExpr){ |
| 168540 | + Walker w; |
| 168541 | + memset(&w, 0, sizeof(w)); |
| 168542 | + w.pParse = pParse; |
| 168543 | + w.xExprCallback = exprNodeCanReturnSubtype; |
| 168544 | + sqlite3WalkExpr(&w, pExpr); |
| 168545 | + return w.eCode; |
| 168546 | +} |
| 167675 | 168547 | |
| 167676 | 168548 | /* |
| 167677 | 168549 | ** The index pIdx is used by a query and contains one or more expressions. |
| 167678 | 168550 | ** In other words pIdx is an index on an expression. iIdxCur is the cursor |
| 167679 | 168551 | ** number for the index and iDataCur is the cursor number for the corresponding |
| | @@ -167696,37 +168568,23 @@ |
| 167696 | 168568 | assert( pIdx->bHasExpr ); |
| 167697 | 168569 | pTab = pIdx->pTable; |
| 167698 | 168570 | for(i=0; i<pIdx->nColumn; i++){ |
| 167699 | 168571 | Expr *pExpr; |
| 167700 | 168572 | int j = pIdx->aiColumn[i]; |
| 167701 | | - int bMaybeNullRow; |
| 167702 | 168573 | if( j==XN_EXPR ){ |
| 167703 | 168574 | pExpr = pIdx->aColExpr->a[i].pExpr; |
| 167704 | | - testcase( pTabItem->fg.jointype & JT_LEFT ); |
| 167705 | | - testcase( pTabItem->fg.jointype & JT_RIGHT ); |
| 167706 | | - testcase( pTabItem->fg.jointype & JT_LTORJ ); |
| 167707 | | - bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0; |
| 167708 | 168575 | }else if( j>=0 && (pTab->aCol[j].colFlags & COLFLAG_VIRTUAL)!=0 ){ |
| 167709 | 168576 | pExpr = sqlite3ColumnExpr(pTab, &pTab->aCol[j]); |
| 167710 | | - bMaybeNullRow = 0; |
| 167711 | 168577 | }else{ |
| 167712 | 168578 | continue; |
| 167713 | 168579 | } |
| 167714 | 168580 | if( sqlite3ExprIsConstant(0,pExpr) ) continue; |
| 167715 | | - if( pExpr->op==TK_FUNCTION ){ |
| 168581 | + if( pExpr->op==TK_FUNCTION && sqlite3ExprCanReturnSubtype(pParse,pExpr) ){ |
| 167716 | 168582 | /* Functions that might set a subtype should not be replaced by the |
| 167717 | 168583 | ** value taken from an expression index since the index omits the |
| 167718 | 168584 | ** subtype. https://sqlite.org/forum/forumpost/68d284c86b082c3e */ |
| 167719 | | - int n; |
| 167720 | | - FuncDef *pDef; |
| 167721 | | - sqlite3 *db = pParse->db; |
| 167722 | | - assert( ExprUseXList(pExpr) ); |
| 167723 | | - n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; |
| 167724 | | - pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); |
| 167725 | | - if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ |
| 167726 | | - continue; |
| 167727 | | - } |
| 168585 | + continue; |
| 167728 | 168586 | } |
| 167729 | 168587 | p = sqlite3DbMallocRaw(pParse->db, sizeof(IndexedExpr)); |
| 167730 | 168588 | if( p==0 ) break; |
| 167731 | 168589 | p->pIENext = pParse->pIdxEpr; |
| 167732 | 168590 | #ifdef WHERETRACE_ENABLED |
| | @@ -167737,11 +168595,11 @@ |
| 167737 | 168595 | #endif |
| 167738 | 168596 | p->pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 167739 | 168597 | p->iDataCur = pTabItem->iCursor; |
| 167740 | 168598 | p->iIdxCur = iIdxCur; |
| 167741 | 168599 | p->iIdxCol = i; |
| 167742 | | - p->bMaybeNullRow = bMaybeNullRow; |
| 168600 | + p->bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0; |
| 167743 | 168601 | if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){ |
| 167744 | 168602 | p->aff = pIdx->zColAff[i]; |
| 167745 | 168603 | } |
| 167746 | 168604 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 167747 | 168605 | p->zIdxName = pIdx->zName; |
| | @@ -167905,10 +168763,11 @@ |
| 167905 | 168763 | /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ |
| 167906 | 168764 | testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); |
| 167907 | 168765 | if( pOrderBy && pOrderBy->nExpr>=BMS ){ |
| 167908 | 168766 | pOrderBy = 0; |
| 167909 | 168767 | wctrlFlags &= ~WHERE_WANT_DISTINCT; |
| 168768 | + wctrlFlags |= WHERE_KEEP_ALL_JOINS; /* Disable omit-noop-join opt */ |
| 167910 | 168769 | } |
| 167911 | 168770 | |
| 167912 | 168771 | /* The number of tables in the FROM clause is limited by the number of |
| 167913 | 168772 | ** bits in a Bitmask |
| 167914 | 168773 | */ |
| | @@ -168144,11 +169003,12 @@ |
| 168144 | 169003 | WHERETRACE_ALL_LOOPS(pWInfo, sWLB.pWC); |
| 168145 | 169004 | |
| 168146 | 169005 | wherePathSolver(pWInfo, 0); |
| 168147 | 169006 | if( db->mallocFailed ) goto whereBeginError; |
| 168148 | 169007 | if( pWInfo->pOrderBy ){ |
| 168149 | | - wherePathSolver(pWInfo, pWInfo->nRowOut+1); |
| 169008 | + whereInterstageHeuristic(pWInfo); |
| 169009 | + wherePathSolver(pWInfo, pWInfo->nRowOut<0 ? 1 : pWInfo->nRowOut+1); |
| 168150 | 169010 | if( db->mallocFailed ) goto whereBeginError; |
| 168151 | 169011 | } |
| 168152 | 169012 | |
| 168153 | 169013 | /* TUNING: Assume that a DISTINCT clause on a subquery reduces |
| 168154 | 169014 | ** the output size by a factor of 8 (LogEst -30). |
| | @@ -168204,14 +169064,14 @@ |
| 168204 | 169064 | ** some C-compiler optimizers from in-lining the |
| 168205 | 169065 | ** sqlite3WhereCodeOneLoopStart() procedure, and it is important to |
| 168206 | 169066 | ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons. |
| 168207 | 169067 | */ |
| 168208 | 169068 | notReady = ~(Bitmask)0; |
| 168209 | | - if( pWInfo->nLevel>=2 |
| 168210 | | - && pResultSet!=0 /* these two combine to guarantee */ |
| 168211 | | - && 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */ |
| 168212 | | - && OptimizationEnabled(db, SQLITE_OmitNoopJoin) |
| 169069 | + if( pWInfo->nLevel>=2 /* Must be a join, or this opt8n is pointless */ |
| 169070 | + && pResultSet!=0 /* Condition (1) */ |
| 169071 | + && 0==(wctrlFlags & (WHERE_AGG_DISTINCT|WHERE_KEEP_ALL_JOINS)) /* (1),(6) */ |
| 169072 | + && OptimizationEnabled(db, SQLITE_OmitNoopJoin) /* (7) */ |
| 168213 | 169073 | ){ |
| 168214 | 169074 | notReady = whereOmitNoopJoin(pWInfo, notReady); |
| 168215 | 169075 | nTabList = pWInfo->nLevel; |
| 168216 | 169076 | assert( nTabList>0 ); |
| 168217 | 169077 | } |
| | @@ -168693,11 +169553,19 @@ |
| 168693 | 169553 | if( pLevel->iLeftJoin ){ |
| 168694 | 169554 | int ws = pLoop->wsFlags; |
| 168695 | 169555 | addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v); |
| 168696 | 169556 | assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 ); |
| 168697 | 169557 | if( (ws & WHERE_IDX_ONLY)==0 ){ |
| 168698 | | - assert( pLevel->iTabCur==pTabList->a[pLevel->iFrom].iCursor ); |
| 169558 | + SrcItem *pSrc = &pTabList->a[pLevel->iFrom]; |
| 169559 | + assert( pLevel->iTabCur==pSrc->iCursor ); |
| 169560 | + if( pSrc->fg.viaCoroutine ){ |
| 169561 | + int m, n; |
| 169562 | + n = pSrc->regResult; |
| 169563 | + assert( pSrc->pTab!=0 ); |
| 169564 | + m = pSrc->pTab->nCol; |
| 169565 | + sqlite3VdbeAddOp3(v, OP_Null, 0, n, n+m-1); |
| 169566 | + } |
| 168699 | 169567 | sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); |
| 168700 | 169568 | } |
| 168701 | 169569 | if( (ws & WHERE_INDEXED) |
| 168702 | 169570 | || ((ws & WHERE_MULTI_OR) && pLevel->u.pCoveringIdx) |
| 168703 | 169571 | ){ |
| | @@ -169793,11 +170661,11 @@ |
| 169793 | 170661 | } |
| 169794 | 170662 | if( bIntToNull ){ |
| 169795 | 170663 | int iDummy; |
| 169796 | 170664 | Expr *pSub; |
| 169797 | 170665 | pSub = sqlite3ExprSkipCollateAndLikely(pDup); |
| 169798 | | - if( sqlite3ExprIsInteger(pSub, &iDummy) ){ |
| 170666 | + if( sqlite3ExprIsInteger(pSub, &iDummy, 0) ){ |
| 169799 | 170667 | pSub->op = TK_NULL; |
| 169800 | 170668 | pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); |
| 169801 | 170669 | pSub->u.zToken = 0; |
| 169802 | 170670 | } |
| 169803 | 170671 | } |
| | @@ -172270,139 +173138,139 @@ |
| 172270 | 173138 | #define TK_EACH 41 |
| 172271 | 173139 | #define TK_FAIL 42 |
| 172272 | 173140 | #define TK_OR 43 |
| 172273 | 173141 | #define TK_AND 44 |
| 172274 | 173142 | #define TK_IS 45 |
| 172275 | | -#define TK_MATCH 46 |
| 172276 | | -#define TK_LIKE_KW 47 |
| 172277 | | -#define TK_BETWEEN 48 |
| 172278 | | -#define TK_IN 49 |
| 172279 | | -#define TK_ISNULL 50 |
| 172280 | | -#define TK_NOTNULL 51 |
| 172281 | | -#define TK_NE 52 |
| 172282 | | -#define TK_EQ 53 |
| 172283 | | -#define TK_GT 54 |
| 172284 | | -#define TK_LE 55 |
| 172285 | | -#define TK_LT 56 |
| 172286 | | -#define TK_GE 57 |
| 172287 | | -#define TK_ESCAPE 58 |
| 172288 | | -#define TK_ID 59 |
| 172289 | | -#define TK_COLUMNKW 60 |
| 172290 | | -#define TK_DO 61 |
| 172291 | | -#define TK_FOR 62 |
| 172292 | | -#define TK_IGNORE 63 |
| 172293 | | -#define TK_INITIALLY 64 |
| 172294 | | -#define TK_INSTEAD 65 |
| 172295 | | -#define TK_NO 66 |
| 172296 | | -#define TK_KEY 67 |
| 172297 | | -#define TK_OF 68 |
| 172298 | | -#define TK_OFFSET 69 |
| 172299 | | -#define TK_PRAGMA 70 |
| 172300 | | -#define TK_RAISE 71 |
| 172301 | | -#define TK_RECURSIVE 72 |
| 172302 | | -#define TK_REPLACE 73 |
| 172303 | | -#define TK_RESTRICT 74 |
| 172304 | | -#define TK_ROW 75 |
| 172305 | | -#define TK_ROWS 76 |
| 172306 | | -#define TK_TRIGGER 77 |
| 172307 | | -#define TK_VACUUM 78 |
| 172308 | | -#define TK_VIEW 79 |
| 172309 | | -#define TK_VIRTUAL 80 |
| 172310 | | -#define TK_WITH 81 |
| 172311 | | -#define TK_NULLS 82 |
| 172312 | | -#define TK_FIRST 83 |
| 172313 | | -#define TK_LAST 84 |
| 172314 | | -#define TK_CURRENT 85 |
| 172315 | | -#define TK_FOLLOWING 86 |
| 172316 | | -#define TK_PARTITION 87 |
| 172317 | | -#define TK_PRECEDING 88 |
| 172318 | | -#define TK_RANGE 89 |
| 172319 | | -#define TK_UNBOUNDED 90 |
| 172320 | | -#define TK_EXCLUDE 91 |
| 172321 | | -#define TK_GROUPS 92 |
| 172322 | | -#define TK_OTHERS 93 |
| 172323 | | -#define TK_TIES 94 |
| 172324 | | -#define TK_GENERATED 95 |
| 172325 | | -#define TK_ALWAYS 96 |
| 172326 | | -#define TK_MATERIALIZED 97 |
| 172327 | | -#define TK_REINDEX 98 |
| 172328 | | -#define TK_RENAME 99 |
| 172329 | | -#define TK_CTIME_KW 100 |
| 172330 | | -#define TK_ANY 101 |
| 172331 | | -#define TK_BITAND 102 |
| 172332 | | -#define TK_BITOR 103 |
| 172333 | | -#define TK_LSHIFT 104 |
| 172334 | | -#define TK_RSHIFT 105 |
| 172335 | | -#define TK_PLUS 106 |
| 172336 | | -#define TK_MINUS 107 |
| 172337 | | -#define TK_STAR 108 |
| 172338 | | -#define TK_SLASH 109 |
| 172339 | | -#define TK_REM 110 |
| 172340 | | -#define TK_CONCAT 111 |
| 172341 | | -#define TK_PTR 112 |
| 172342 | | -#define TK_COLLATE 113 |
| 172343 | | -#define TK_BITNOT 114 |
| 172344 | | -#define TK_ON 115 |
| 172345 | | -#define TK_INDEXED 116 |
| 172346 | | -#define TK_STRING 117 |
| 172347 | | -#define TK_JOIN_KW 118 |
| 172348 | | -#define TK_CONSTRAINT 119 |
| 172349 | | -#define TK_DEFAULT 120 |
| 172350 | | -#define TK_NULL 121 |
| 172351 | | -#define TK_PRIMARY 122 |
| 172352 | | -#define TK_UNIQUE 123 |
| 172353 | | -#define TK_CHECK 124 |
| 172354 | | -#define TK_REFERENCES 125 |
| 172355 | | -#define TK_AUTOINCR 126 |
| 172356 | | -#define TK_INSERT 127 |
| 172357 | | -#define TK_DELETE 128 |
| 172358 | | -#define TK_UPDATE 129 |
| 172359 | | -#define TK_SET 130 |
| 172360 | | -#define TK_DEFERRABLE 131 |
| 172361 | | -#define TK_FOREIGN 132 |
| 172362 | | -#define TK_DROP 133 |
| 172363 | | -#define TK_UNION 134 |
| 172364 | | -#define TK_ALL 135 |
| 172365 | | -#define TK_EXCEPT 136 |
| 172366 | | -#define TK_INTERSECT 137 |
| 172367 | | -#define TK_SELECT 138 |
| 172368 | | -#define TK_VALUES 139 |
| 172369 | | -#define TK_DISTINCT 140 |
| 172370 | | -#define TK_DOT 141 |
| 172371 | | -#define TK_FROM 142 |
| 172372 | | -#define TK_JOIN 143 |
| 172373 | | -#define TK_USING 144 |
| 172374 | | -#define TK_ORDER 145 |
| 172375 | | -#define TK_GROUP 146 |
| 172376 | | -#define TK_HAVING 147 |
| 172377 | | -#define TK_LIMIT 148 |
| 172378 | | -#define TK_WHERE 149 |
| 172379 | | -#define TK_RETURNING 150 |
| 172380 | | -#define TK_INTO 151 |
| 172381 | | -#define TK_NOTHING 152 |
| 172382 | | -#define TK_FLOAT 153 |
| 172383 | | -#define TK_BLOB 154 |
| 172384 | | -#define TK_INTEGER 155 |
| 172385 | | -#define TK_VARIABLE 156 |
| 172386 | | -#define TK_CASE 157 |
| 172387 | | -#define TK_WHEN 158 |
| 172388 | | -#define TK_THEN 159 |
| 172389 | | -#define TK_ELSE 160 |
| 172390 | | -#define TK_INDEX 161 |
| 172391 | | -#define TK_ALTER 162 |
| 172392 | | -#define TK_ADD 163 |
| 172393 | | -#define TK_WINDOW 164 |
| 172394 | | -#define TK_OVER 165 |
| 172395 | | -#define TK_FILTER 166 |
| 172396 | | -#define TK_COLUMN 167 |
| 172397 | | -#define TK_AGG_FUNCTION 168 |
| 172398 | | -#define TK_AGG_COLUMN 169 |
| 172399 | | -#define TK_TRUEFALSE 170 |
| 172400 | | -#define TK_ISNOT 171 |
| 173143 | +#define TK_ISNOT 46 |
| 173144 | +#define TK_MATCH 47 |
| 173145 | +#define TK_LIKE_KW 48 |
| 173146 | +#define TK_BETWEEN 49 |
| 173147 | +#define TK_IN 50 |
| 173148 | +#define TK_ISNULL 51 |
| 173149 | +#define TK_NOTNULL 52 |
| 173150 | +#define TK_NE 53 |
| 173151 | +#define TK_EQ 54 |
| 173152 | +#define TK_GT 55 |
| 173153 | +#define TK_LE 56 |
| 173154 | +#define TK_LT 57 |
| 173155 | +#define TK_GE 58 |
| 173156 | +#define TK_ESCAPE 59 |
| 173157 | +#define TK_ID 60 |
| 173158 | +#define TK_COLUMNKW 61 |
| 173159 | +#define TK_DO 62 |
| 173160 | +#define TK_FOR 63 |
| 173161 | +#define TK_IGNORE 64 |
| 173162 | +#define TK_INITIALLY 65 |
| 173163 | +#define TK_INSTEAD 66 |
| 173164 | +#define TK_NO 67 |
| 173165 | +#define TK_KEY 68 |
| 173166 | +#define TK_OF 69 |
| 173167 | +#define TK_OFFSET 70 |
| 173168 | +#define TK_PRAGMA 71 |
| 173169 | +#define TK_RAISE 72 |
| 173170 | +#define TK_RECURSIVE 73 |
| 173171 | +#define TK_REPLACE 74 |
| 173172 | +#define TK_RESTRICT 75 |
| 173173 | +#define TK_ROW 76 |
| 173174 | +#define TK_ROWS 77 |
| 173175 | +#define TK_TRIGGER 78 |
| 173176 | +#define TK_VACUUM 79 |
| 173177 | +#define TK_VIEW 80 |
| 173178 | +#define TK_VIRTUAL 81 |
| 173179 | +#define TK_WITH 82 |
| 173180 | +#define TK_NULLS 83 |
| 173181 | +#define TK_FIRST 84 |
| 173182 | +#define TK_LAST 85 |
| 173183 | +#define TK_CURRENT 86 |
| 173184 | +#define TK_FOLLOWING 87 |
| 173185 | +#define TK_PARTITION 88 |
| 173186 | +#define TK_PRECEDING 89 |
| 173187 | +#define TK_RANGE 90 |
| 173188 | +#define TK_UNBOUNDED 91 |
| 173189 | +#define TK_EXCLUDE 92 |
| 173190 | +#define TK_GROUPS 93 |
| 173191 | +#define TK_OTHERS 94 |
| 173192 | +#define TK_TIES 95 |
| 173193 | +#define TK_GENERATED 96 |
| 173194 | +#define TK_ALWAYS 97 |
| 173195 | +#define TK_MATERIALIZED 98 |
| 173196 | +#define TK_REINDEX 99 |
| 173197 | +#define TK_RENAME 100 |
| 173198 | +#define TK_CTIME_KW 101 |
| 173199 | +#define TK_ANY 102 |
| 173200 | +#define TK_BITAND 103 |
| 173201 | +#define TK_BITOR 104 |
| 173202 | +#define TK_LSHIFT 105 |
| 173203 | +#define TK_RSHIFT 106 |
| 173204 | +#define TK_PLUS 107 |
| 173205 | +#define TK_MINUS 108 |
| 173206 | +#define TK_STAR 109 |
| 173207 | +#define TK_SLASH 110 |
| 173208 | +#define TK_REM 111 |
| 173209 | +#define TK_CONCAT 112 |
| 173210 | +#define TK_PTR 113 |
| 173211 | +#define TK_COLLATE 114 |
| 173212 | +#define TK_BITNOT 115 |
| 173213 | +#define TK_ON 116 |
| 173214 | +#define TK_INDEXED 117 |
| 173215 | +#define TK_STRING 118 |
| 173216 | +#define TK_JOIN_KW 119 |
| 173217 | +#define TK_CONSTRAINT 120 |
| 173218 | +#define TK_DEFAULT 121 |
| 173219 | +#define TK_NULL 122 |
| 173220 | +#define TK_PRIMARY 123 |
| 173221 | +#define TK_UNIQUE 124 |
| 173222 | +#define TK_CHECK 125 |
| 173223 | +#define TK_REFERENCES 126 |
| 173224 | +#define TK_AUTOINCR 127 |
| 173225 | +#define TK_INSERT 128 |
| 173226 | +#define TK_DELETE 129 |
| 173227 | +#define TK_UPDATE 130 |
| 173228 | +#define TK_SET 131 |
| 173229 | +#define TK_DEFERRABLE 132 |
| 173230 | +#define TK_FOREIGN 133 |
| 173231 | +#define TK_DROP 134 |
| 173232 | +#define TK_UNION 135 |
| 173233 | +#define TK_ALL 136 |
| 173234 | +#define TK_EXCEPT 137 |
| 173235 | +#define TK_INTERSECT 138 |
| 173236 | +#define TK_SELECT 139 |
| 173237 | +#define TK_VALUES 140 |
| 173238 | +#define TK_DISTINCT 141 |
| 173239 | +#define TK_DOT 142 |
| 173240 | +#define TK_FROM 143 |
| 173241 | +#define TK_JOIN 144 |
| 173242 | +#define TK_USING 145 |
| 173243 | +#define TK_ORDER 146 |
| 173244 | +#define TK_GROUP 147 |
| 173245 | +#define TK_HAVING 148 |
| 173246 | +#define TK_LIMIT 149 |
| 173247 | +#define TK_WHERE 150 |
| 173248 | +#define TK_RETURNING 151 |
| 173249 | +#define TK_INTO 152 |
| 173250 | +#define TK_NOTHING 153 |
| 173251 | +#define TK_FLOAT 154 |
| 173252 | +#define TK_BLOB 155 |
| 173253 | +#define TK_INTEGER 156 |
| 173254 | +#define TK_VARIABLE 157 |
| 173255 | +#define TK_CASE 158 |
| 173256 | +#define TK_WHEN 159 |
| 173257 | +#define TK_THEN 160 |
| 173258 | +#define TK_ELSE 161 |
| 173259 | +#define TK_INDEX 162 |
| 173260 | +#define TK_ALTER 163 |
| 173261 | +#define TK_ADD 164 |
| 173262 | +#define TK_WINDOW 165 |
| 173263 | +#define TK_OVER 166 |
| 173264 | +#define TK_FILTER 167 |
| 173265 | +#define TK_COLUMN 168 |
| 173266 | +#define TK_AGG_FUNCTION 169 |
| 173267 | +#define TK_AGG_COLUMN 170 |
| 173268 | +#define TK_TRUEFALSE 171 |
| 172401 | 173269 | #define TK_FUNCTION 172 |
| 172402 | | -#define TK_UMINUS 173 |
| 172403 | | -#define TK_UPLUS 174 |
| 173270 | +#define TK_UPLUS 173 |
| 173271 | +#define TK_UMINUS 174 |
| 172404 | 173272 | #define TK_TRUTH 175 |
| 172405 | 173273 | #define TK_REGISTER 176 |
| 172406 | 173274 | #define TK_VECTOR 177 |
| 172407 | 173275 | #define TK_SELECT_COLUMN 178 |
| 172408 | 173276 | #define TK_IF_NULL_ROW 179 |
| | @@ -172476,11 +173344,11 @@ |
| 172476 | 173344 | #endif |
| 172477 | 173345 | /************* Begin control #defines *****************************************/ |
| 172478 | 173346 | #define YYCODETYPE unsigned short int |
| 172479 | 173347 | #define YYNOCODE 322 |
| 172480 | 173348 | #define YYACTIONTYPE unsigned short int |
| 172481 | | -#define YYWILDCARD 101 |
| 173349 | +#define YYWILDCARD 102 |
| 172482 | 173350 | #define sqlite3ParserTOKENTYPE Token |
| 172483 | 173351 | typedef union { |
| 172484 | 173352 | int yyinit; |
| 172485 | 173353 | sqlite3ParserTOKENTYPE yy0; |
| 172486 | 173354 | ExprList* yy14; |
| | @@ -172613,450 +173481,456 @@ |
| 172613 | 173481 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 172614 | 173482 | ** shifting non-terminals after a reduce. |
| 172615 | 173483 | ** yy_default[] Default action for each state. |
| 172616 | 173484 | ** |
| 172617 | 173485 | *********** Begin parsing tables **********************************************/ |
| 172618 | | -#define YY_ACTTAB_COUNT (2142) |
| 173486 | +#define YY_ACTTAB_COUNT (2207) |
| 172619 | 173487 | static const YYACTIONTYPE yy_action[] = { |
| 172620 | | - /* 0 */ 576, 128, 125, 232, 1622, 549, 576, 1290, 1281, 576, |
| 172621 | | - /* 10 */ 328, 576, 1300, 212, 576, 128, 125, 232, 578, 412, |
| 172622 | | - /* 20 */ 578, 391, 1542, 51, 51, 523, 405, 1293, 529, 51, |
| 172623 | | - /* 30 */ 51, 983, 51, 51, 81, 81, 1107, 61, 61, 984, |
| 172624 | | - /* 40 */ 1107, 1292, 380, 135, 136, 90, 1228, 1228, 1063, 1066, |
| 172625 | | - /* 50 */ 1053, 1053, 133, 133, 134, 134, 134, 134, 1577, 412, |
| 172626 | | - /* 60 */ 287, 287, 7, 287, 287, 422, 1050, 1050, 1064, 1067, |
| 172627 | | - /* 70 */ 289, 556, 492, 573, 524, 561, 573, 497, 561, 482, |
| 172628 | | - /* 80 */ 530, 262, 229, 135, 136, 90, 1228, 1228, 1063, 1066, |
| 172629 | | - /* 90 */ 1053, 1053, 133, 133, 134, 134, 134, 134, 128, 125, |
| 172630 | | - /* 100 */ 232, 1506, 132, 132, 132, 132, 131, 131, 130, 130, |
| 172631 | | - /* 110 */ 130, 129, 126, 450, 1204, 1255, 1, 1, 582, 2, |
| 172632 | | - /* 120 */ 1259, 1571, 420, 1582, 379, 320, 1174, 153, 1174, 1584, |
| 172633 | | - /* 130 */ 412, 378, 1582, 543, 1341, 330, 111, 570, 570, 570, |
| 172634 | | - /* 140 */ 293, 1054, 132, 132, 132, 132, 131, 131, 130, 130, |
| 172635 | | - /* 150 */ 130, 129, 126, 450, 135, 136, 90, 1228, 1228, 1063, |
| 172636 | | - /* 160 */ 1066, 1053, 1053, 133, 133, 134, 134, 134, 134, 287, |
| 172637 | | - /* 170 */ 287, 1204, 1205, 1204, 255, 287, 287, 510, 507, 506, |
| 172638 | | - /* 180 */ 137, 455, 573, 212, 561, 447, 446, 505, 573, 1616, |
| 172639 | | - /* 190 */ 561, 134, 134, 134, 134, 127, 400, 243, 132, 132, |
| 172640 | | - /* 200 */ 132, 132, 131, 131, 130, 130, 130, 129, 126, 450, |
| 172641 | | - /* 210 */ 282, 471, 345, 132, 132, 132, 132, 131, 131, 130, |
| 172642 | | - /* 220 */ 130, 130, 129, 126, 450, 574, 155, 936, 936, 454, |
| 172643 | | - /* 230 */ 227, 521, 1236, 412, 1236, 134, 134, 134, 134, 132, |
| 172644 | | - /* 240 */ 132, 132, 132, 131, 131, 130, 130, 130, 129, 126, |
| 172645 | | - /* 250 */ 450, 130, 130, 130, 129, 126, 450, 135, 136, 90, |
| 172646 | | - /* 260 */ 1228, 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, |
| 172647 | | - /* 270 */ 134, 134, 128, 125, 232, 450, 576, 412, 397, 1249, |
| 172648 | | - /* 280 */ 180, 92, 93, 132, 132, 132, 132, 131, 131, 130, |
| 172649 | | - /* 290 */ 130, 130, 129, 126, 450, 381, 387, 1204, 383, 81, |
| 172650 | | - /* 300 */ 81, 135, 136, 90, 1228, 1228, 1063, 1066, 1053, 1053, |
| 172651 | | - /* 310 */ 133, 133, 134, 134, 134, 134, 132, 132, 132, 132, |
| 172652 | | - /* 320 */ 131, 131, 130, 130, 130, 129, 126, 450, 131, 131, |
| 172653 | | - /* 330 */ 130, 130, 130, 129, 126, 450, 556, 1204, 302, 319, |
| 172654 | | - /* 340 */ 567, 121, 568, 480, 4, 555, 1149, 1657, 1628, 1657, |
| 172655 | | - /* 350 */ 45, 128, 125, 232, 1204, 1205, 1204, 1250, 571, 1169, |
| 172656 | | - /* 360 */ 132, 132, 132, 132, 131, 131, 130, 130, 130, 129, |
| 172657 | | - /* 370 */ 126, 450, 1169, 287, 287, 1169, 1019, 576, 422, 1019, |
| 172658 | | - /* 380 */ 412, 451, 1602, 582, 2, 1259, 573, 44, 561, 95, |
| 172659 | | - /* 390 */ 320, 110, 153, 565, 1204, 1205, 1204, 522, 522, 1341, |
| 172660 | | - /* 400 */ 81, 81, 7, 44, 135, 136, 90, 1228, 1228, 1063, |
| 172661 | | - /* 410 */ 1066, 1053, 1053, 133, 133, 134, 134, 134, 134, 295, |
| 172662 | | - /* 420 */ 1149, 1658, 1040, 1658, 1204, 1147, 319, 567, 119, 119, |
| 172663 | | - /* 430 */ 343, 466, 331, 343, 287, 287, 120, 556, 451, 577, |
| 172664 | | - /* 440 */ 451, 1169, 1169, 1028, 319, 567, 438, 573, 210, 561, |
| 172665 | | - /* 450 */ 1339, 1451, 546, 531, 1169, 1169, 1598, 1169, 1169, 416, |
| 172666 | | - /* 460 */ 319, 567, 243, 132, 132, 132, 132, 131, 131, 130, |
| 172667 | | - /* 470 */ 130, 130, 129, 126, 450, 1028, 1028, 1030, 1031, 35, |
| 172668 | | - /* 480 */ 44, 1204, 1205, 1204, 472, 287, 287, 1328, 412, 1307, |
| 172669 | | - /* 490 */ 372, 1595, 359, 225, 454, 1204, 195, 1328, 573, 1147, |
| 172670 | | - /* 500 */ 561, 1333, 1333, 274, 576, 1188, 576, 340, 46, 196, |
| 172671 | | - /* 510 */ 537, 217, 135, 136, 90, 1228, 1228, 1063, 1066, 1053, |
| 172672 | | - /* 520 */ 1053, 133, 133, 134, 134, 134, 134, 19, 19, 19, |
| 172673 | | - /* 530 */ 19, 412, 581, 1204, 1259, 511, 1204, 319, 567, 320, |
| 172674 | | - /* 540 */ 944, 153, 425, 491, 430, 943, 1204, 488, 1341, 1450, |
| 172675 | | - /* 550 */ 532, 1277, 1204, 1205, 1204, 135, 136, 90, 1228, 1228, |
| 172676 | | - /* 560 */ 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, 134, |
| 172677 | | - /* 570 */ 575, 132, 132, 132, 132, 131, 131, 130, 130, 130, |
| 172678 | | - /* 580 */ 129, 126, 450, 287, 287, 528, 287, 287, 372, 1595, |
| 172679 | | - /* 590 */ 1204, 1205, 1204, 1204, 1205, 1204, 573, 486, 561, 573, |
| 172680 | | - /* 600 */ 889, 561, 412, 1204, 1205, 1204, 886, 40, 22, 22, |
| 172681 | | - /* 610 */ 220, 243, 525, 1449, 132, 132, 132, 132, 131, 131, |
| 172682 | | - /* 620 */ 130, 130, 130, 129, 126, 450, 135, 136, 90, 1228, |
| 172683 | | - /* 630 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172684 | | - /* 640 */ 134, 412, 180, 454, 1204, 879, 255, 287, 287, 510, |
| 172685 | | - /* 650 */ 507, 506, 372, 1595, 1568, 1331, 1331, 576, 889, 505, |
| 172686 | | - /* 660 */ 573, 44, 561, 559, 1207, 135, 136, 90, 1228, 1228, |
| 172687 | | - /* 670 */ 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, 134, |
| 172688 | | - /* 680 */ 81, 81, 422, 576, 377, 132, 132, 132, 132, 131, |
| 172689 | | - /* 690 */ 131, 130, 130, 130, 129, 126, 450, 297, 287, 287, |
| 172690 | | - /* 700 */ 460, 1204, 1205, 1204, 1204, 534, 19, 19, 448, 448, |
| 172691 | | - /* 710 */ 448, 573, 412, 561, 230, 436, 1187, 535, 319, 567, |
| 172692 | | - /* 720 */ 363, 432, 1207, 1435, 132, 132, 132, 132, 131, 131, |
| 172693 | | - /* 730 */ 130, 130, 130, 129, 126, 450, 135, 136, 90, 1228, |
| 172694 | | - /* 740 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172695 | | - /* 750 */ 134, 412, 211, 949, 1169, 1041, 1110, 1110, 494, 547, |
| 172696 | | - /* 760 */ 547, 1204, 1205, 1204, 7, 539, 1570, 1169, 376, 576, |
| 172697 | | - /* 770 */ 1169, 5, 1204, 486, 3, 135, 136, 90, 1228, 1228, |
| 172698 | | - /* 780 */ 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, 134, |
| 172699 | | - /* 790 */ 576, 513, 19, 19, 427, 132, 132, 132, 132, 131, |
| 172700 | | - /* 800 */ 131, 130, 130, 130, 129, 126, 450, 305, 1204, 433, |
| 172701 | | - /* 810 */ 225, 1204, 385, 19, 19, 273, 290, 371, 516, 366, |
| 172702 | | - /* 820 */ 515, 260, 412, 538, 1568, 549, 1024, 362, 437, 1204, |
| 172703 | | - /* 830 */ 1205, 1204, 902, 1552, 132, 132, 132, 132, 131, 131, |
| 172704 | | - /* 840 */ 130, 130, 130, 129, 126, 450, 135, 136, 90, 1228, |
| 172705 | | - /* 850 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172706 | | - /* 860 */ 134, 412, 1435, 514, 1281, 1204, 1205, 1204, 1204, 1205, |
| 172707 | | - /* 870 */ 1204, 903, 48, 342, 1568, 1568, 1279, 1627, 1568, 911, |
| 172708 | | - /* 880 */ 576, 129, 126, 450, 110, 135, 136, 90, 1228, 1228, |
| 172709 | | - /* 890 */ 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, 134, |
| 172710 | | - /* 900 */ 265, 576, 459, 19, 19, 132, 132, 132, 132, 131, |
| 172711 | | - /* 910 */ 131, 130, 130, 130, 129, 126, 450, 1345, 204, 576, |
| 172712 | | - /* 920 */ 459, 458, 50, 47, 19, 19, 49, 434, 1105, 573, |
| 172713 | | - /* 930 */ 497, 561, 412, 428, 108, 1224, 1569, 1554, 376, 205, |
| 172714 | | - /* 940 */ 550, 550, 81, 81, 132, 132, 132, 132, 131, 131, |
| 172715 | | - /* 950 */ 130, 130, 130, 129, 126, 450, 135, 136, 90, 1228, |
| 172716 | | - /* 960 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172717 | | - /* 970 */ 134, 480, 576, 1204, 576, 1541, 412, 1435, 969, 315, |
| 172718 | | - /* 980 */ 1659, 398, 284, 497, 969, 893, 1569, 1569, 376, 376, |
| 172719 | | - /* 990 */ 1569, 461, 376, 1224, 459, 80, 80, 81, 81, 497, |
| 172720 | | - /* 1000 */ 374, 114, 90, 1228, 1228, 1063, 1066, 1053, 1053, 133, |
| 172721 | | - /* 1010 */ 133, 134, 134, 134, 134, 132, 132, 132, 132, 131, |
| 172722 | | - /* 1020 */ 131, 130, 130, 130, 129, 126, 450, 1204, 1505, 576, |
| 172723 | | - /* 1030 */ 1204, 1205, 1204, 1366, 316, 486, 281, 281, 497, 431, |
| 172724 | | - /* 1040 */ 557, 288, 288, 402, 1340, 471, 345, 298, 429, 573, |
| 172725 | | - /* 1050 */ 576, 561, 81, 81, 573, 374, 561, 971, 386, 132, |
| 172726 | | - /* 1060 */ 132, 132, 132, 131, 131, 130, 130, 130, 129, 126, |
| 172727 | | - /* 1070 */ 450, 231, 117, 81, 81, 287, 287, 231, 287, 287, |
| 172728 | | - /* 1080 */ 576, 1511, 576, 1336, 1204, 1205, 1204, 139, 573, 556, |
| 172729 | | - /* 1090 */ 561, 573, 412, 561, 441, 456, 969, 213, 558, 1511, |
| 172730 | | - /* 1100 */ 1513, 1550, 969, 143, 143, 145, 145, 1368, 314, 478, |
| 172731 | | - /* 1110 */ 444, 970, 412, 850, 851, 852, 135, 136, 90, 1228, |
| 172732 | | - /* 1120 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172733 | | - /* 1130 */ 134, 357, 412, 397, 1148, 304, 135, 136, 90, 1228, |
| 172734 | | - /* 1140 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172735 | | - /* 1150 */ 134, 1575, 323, 6, 862, 7, 135, 124, 90, 1228, |
| 172736 | | - /* 1160 */ 1228, 1063, 1066, 1053, 1053, 133, 133, 134, 134, 134, |
| 172737 | | - /* 1170 */ 134, 409, 408, 1511, 212, 132, 132, 132, 132, 131, |
| 172738 | | - /* 1180 */ 131, 130, 130, 130, 129, 126, 450, 411, 118, 1204, |
| 172739 | | - /* 1190 */ 116, 10, 352, 265, 355, 132, 132, 132, 132, 131, |
| 172740 | | - /* 1200 */ 131, 130, 130, 130, 129, 126, 450, 576, 324, 306, |
| 172741 | | - /* 1210 */ 576, 306, 1250, 469, 158, 132, 132, 132, 132, 131, |
| 172742 | | - /* 1220 */ 131, 130, 130, 130, 129, 126, 450, 207, 1224, 1126, |
| 172743 | | - /* 1230 */ 65, 65, 470, 66, 66, 412, 447, 446, 882, 531, |
| 172744 | | - /* 1240 */ 335, 258, 257, 256, 1127, 1233, 1204, 1205, 1204, 327, |
| 172745 | | - /* 1250 */ 1235, 874, 159, 576, 16, 480, 1085, 1040, 1234, 1128, |
| 172746 | | - /* 1260 */ 136, 90, 1228, 1228, 1063, 1066, 1053, 1053, 133, 133, |
| 172747 | | - /* 1270 */ 134, 134, 134, 134, 1029, 576, 81, 81, 1028, 1040, |
| 172748 | | - /* 1280 */ 922, 576, 463, 1236, 576, 1236, 1224, 502, 107, 1435, |
| 172749 | | - /* 1290 */ 923, 6, 576, 410, 1498, 882, 1029, 480, 21, 21, |
| 172750 | | - /* 1300 */ 1028, 332, 1380, 334, 53, 53, 497, 81, 81, 874, |
| 172751 | | - /* 1310 */ 1028, 1028, 1030, 445, 259, 19, 19, 533, 132, 132, |
| 172752 | | - /* 1320 */ 132, 132, 131, 131, 130, 130, 130, 129, 126, 450, |
| 172753 | | - /* 1330 */ 551, 301, 1028, 1028, 1030, 107, 532, 545, 121, 568, |
| 172754 | | - /* 1340 */ 1188, 4, 1126, 1576, 449, 576, 462, 7, 1282, 418, |
| 172755 | | - /* 1350 */ 462, 350, 1435, 576, 518, 571, 544, 1127, 121, 568, |
| 172756 | | - /* 1360 */ 442, 4, 1188, 464, 533, 1180, 1223, 9, 67, 67, |
| 172757 | | - /* 1370 */ 487, 576, 1128, 303, 410, 571, 54, 54, 451, 576, |
| 172758 | | - /* 1380 */ 123, 944, 576, 417, 576, 333, 943, 1379, 576, 236, |
| 172759 | | - /* 1390 */ 565, 576, 1574, 564, 68, 68, 7, 576, 451, 362, |
| 172760 | | - /* 1400 */ 419, 182, 69, 69, 541, 70, 70, 71, 71, 540, |
| 172761 | | - /* 1410 */ 565, 72, 72, 484, 55, 55, 473, 1180, 296, 1040, |
| 172762 | | - /* 1420 */ 56, 56, 296, 493, 541, 119, 119, 410, 1573, 542, |
| 172763 | | - /* 1430 */ 569, 418, 7, 120, 1244, 451, 577, 451, 465, 1040, |
| 172764 | | - /* 1440 */ 1028, 576, 1557, 552, 476, 119, 119, 527, 259, 121, |
| 172765 | | - /* 1450 */ 568, 240, 4, 120, 576, 451, 577, 451, 576, 477, |
| 172766 | | - /* 1460 */ 1028, 576, 156, 576, 57, 57, 571, 576, 286, 229, |
| 172767 | | - /* 1470 */ 410, 336, 1028, 1028, 1030, 1031, 35, 59, 59, 219, |
| 172768 | | - /* 1480 */ 983, 60, 60, 220, 73, 73, 74, 74, 984, 451, |
| 172769 | | - /* 1490 */ 75, 75, 1028, 1028, 1030, 1031, 35, 96, 216, 291, |
| 172770 | | - /* 1500 */ 552, 565, 1188, 318, 395, 395, 394, 276, 392, 576, |
| 172771 | | - /* 1510 */ 485, 859, 474, 1311, 410, 541, 576, 417, 1530, 1144, |
| 172772 | | - /* 1520 */ 540, 399, 1188, 292, 237, 1153, 326, 38, 23, 576, |
| 172773 | | - /* 1530 */ 1040, 576, 20, 20, 325, 299, 119, 119, 164, 76, |
| 172774 | | - /* 1540 */ 76, 1529, 121, 568, 120, 4, 451, 577, 451, 203, |
| 172775 | | - /* 1550 */ 576, 1028, 141, 141, 142, 142, 576, 322, 39, 571, |
| 172776 | | - /* 1560 */ 341, 1021, 110, 264, 239, 901, 900, 423, 242, 908, |
| 172777 | | - /* 1570 */ 909, 370, 173, 77, 77, 43, 479, 1310, 264, 62, |
| 172778 | | - /* 1580 */ 62, 369, 451, 1028, 1028, 1030, 1031, 35, 1601, 1192, |
| 172779 | | - /* 1590 */ 453, 1092, 238, 291, 565, 163, 1309, 110, 395, 395, |
| 172780 | | - /* 1600 */ 394, 276, 392, 986, 987, 859, 481, 346, 264, 110, |
| 172781 | | - /* 1610 */ 1032, 489, 576, 1188, 503, 1088, 261, 261, 237, 576, |
| 172782 | | - /* 1620 */ 326, 121, 568, 1040, 4, 347, 1376, 413, 325, 119, |
| 172783 | | - /* 1630 */ 119, 948, 319, 567, 351, 78, 78, 120, 571, 451, |
| 172784 | | - /* 1640 */ 577, 451, 79, 79, 1028, 354, 356, 576, 360, 1092, |
| 172785 | | - /* 1650 */ 110, 576, 974, 942, 264, 123, 457, 358, 239, 576, |
| 172786 | | - /* 1660 */ 519, 451, 939, 1104, 123, 1104, 173, 576, 1032, 43, |
| 172787 | | - /* 1670 */ 63, 63, 1324, 565, 168, 168, 1028, 1028, 1030, 1031, |
| 172788 | | - /* 1680 */ 35, 576, 169, 169, 1308, 872, 238, 157, 1589, 576, |
| 172789 | | - /* 1690 */ 86, 86, 365, 89, 568, 375, 4, 1103, 941, 1103, |
| 172790 | | - /* 1700 */ 123, 576, 1040, 1389, 64, 64, 1188, 1434, 119, 119, |
| 172791 | | - /* 1710 */ 571, 576, 82, 82, 563, 576, 120, 165, 451, 577, |
| 172792 | | - /* 1720 */ 451, 413, 1362, 1028, 144, 144, 319, 567, 576, 1374, |
| 172793 | | - /* 1730 */ 562, 498, 279, 451, 83, 83, 1439, 576, 166, 166, |
| 172794 | | - /* 1740 */ 576, 1289, 554, 576, 1280, 565, 576, 12, 576, 1268, |
| 172795 | | - /* 1750 */ 457, 146, 146, 1267, 576, 1028, 1028, 1030, 1031, 35, |
| 172796 | | - /* 1760 */ 140, 140, 1269, 167, 167, 1609, 160, 160, 1359, 150, |
| 172797 | | - /* 1770 */ 150, 149, 149, 311, 1040, 576, 312, 147, 147, 313, |
| 172798 | | - /* 1780 */ 119, 119, 222, 235, 576, 1188, 396, 576, 120, 576, |
| 172799 | | - /* 1790 */ 451, 577, 451, 1192, 453, 1028, 508, 291, 148, 148, |
| 172800 | | - /* 1800 */ 1421, 1612, 395, 395, 394, 276, 392, 85, 85, 859, |
| 172801 | | - /* 1810 */ 87, 87, 84, 84, 553, 576, 294, 576, 1426, 338, |
| 172802 | | - /* 1820 */ 339, 1425, 237, 300, 326, 1416, 1409, 1028, 1028, 1030, |
| 172803 | | - /* 1830 */ 1031, 35, 325, 344, 403, 483, 226, 1307, 52, 52, |
| 172804 | | - /* 1840 */ 58, 58, 368, 1371, 1502, 566, 1501, 121, 568, 221, |
| 172805 | | - /* 1850 */ 4, 208, 268, 209, 390, 1244, 1549, 1188, 1372, 1370, |
| 172806 | | - /* 1860 */ 1369, 1547, 239, 184, 571, 233, 421, 1241, 95, 218, |
| 172807 | | - /* 1870 */ 173, 1507, 193, 43, 91, 94, 178, 186, 467, 188, |
| 172808 | | - /* 1880 */ 468, 1422, 13, 189, 190, 191, 501, 451, 245, 108, |
| 172809 | | - /* 1890 */ 238, 401, 1428, 1427, 1430, 475, 404, 1496, 197, 565, |
| 172810 | | - /* 1900 */ 14, 490, 249, 101, 1518, 496, 349, 280, 251, 201, |
| 172811 | | - /* 1910 */ 353, 499, 252, 406, 1270, 253, 517, 1327, 1326, 435, |
| 172812 | | - /* 1920 */ 1325, 1318, 103, 893, 1296, 413, 227, 407, 1040, 1626, |
| 172813 | | - /* 1930 */ 319, 567, 1625, 1297, 119, 119, 439, 367, 1317, 1295, |
| 172814 | | - /* 1940 */ 1624, 526, 120, 440, 451, 577, 451, 1594, 309, 1028, |
| 172815 | | - /* 1950 */ 310, 373, 266, 267, 457, 1580, 1579, 443, 138, 1394, |
| 172816 | | - /* 1960 */ 552, 1393, 11, 1483, 384, 115, 317, 1350, 109, 536, |
| 172817 | | - /* 1970 */ 42, 579, 382, 214, 1349, 388, 1198, 389, 275, 277, |
| 172818 | | - /* 1980 */ 278, 1028, 1028, 1030, 1031, 35, 580, 1265, 414, 1260, |
| 172819 | | - /* 1990 */ 170, 415, 183, 1534, 1535, 1533, 171, 154, 307, 1532, |
| 172820 | | - /* 2000 */ 846, 223, 224, 88, 452, 215, 172, 321, 234, 1102, |
| 172821 | | - /* 2010 */ 152, 1188, 1100, 329, 185, 174, 1223, 925, 187, 241, |
| 172822 | | - /* 2020 */ 337, 244, 1116, 192, 175, 176, 424, 426, 97, 194, |
| 172823 | | - /* 2030 */ 98, 99, 100, 177, 1119, 1115, 246, 247, 161, 24, |
| 172824 | | - /* 2040 */ 248, 348, 1238, 264, 1108, 250, 495, 199, 198, 15, |
| 172825 | | - /* 2050 */ 861, 500, 369, 254, 504, 509, 512, 200, 102, 25, |
| 172826 | | - /* 2060 */ 179, 361, 26, 364, 104, 891, 308, 162, 105, 904, |
| 172827 | | - /* 2070 */ 520, 106, 1185, 1069, 1155, 17, 228, 27, 1154, 283, |
| 172828 | | - /* 2080 */ 285, 263, 978, 202, 972, 123, 28, 1175, 29, 30, |
| 172829 | | - /* 2090 */ 1179, 1171, 31, 1173, 1160, 41, 32, 206, 548, 33, |
| 172830 | | - /* 2100 */ 110, 1178, 1083, 8, 112, 1070, 113, 1068, 1072, 34, |
| 172831 | | - /* 2110 */ 1073, 560, 1125, 269, 1124, 270, 36, 18, 1194, 1033, |
| 172832 | | - /* 2120 */ 873, 151, 122, 37, 393, 271, 272, 572, 181, 1193, |
| 172833 | | - /* 2130 */ 1256, 1256, 1256, 935, 1256, 1256, 1256, 1256, 1256, 1256, |
| 172834 | | - /* 2140 */ 1256, 1617, |
| 173488 | + /* 0 */ 130, 127, 234, 282, 282, 1328, 576, 1307, 460, 289, |
| 173489 | + /* 10 */ 289, 576, 1622, 381, 576, 1328, 573, 576, 562, 413, |
| 173490 | + /* 20 */ 1300, 1542, 573, 481, 562, 524, 460, 459, 558, 82, |
| 173491 | + /* 30 */ 82, 983, 294, 375, 51, 51, 498, 61, 61, 984, |
| 173492 | + /* 40 */ 82, 82, 1577, 137, 138, 91, 7, 1228, 1228, 1063, |
| 173493 | + /* 50 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 413, |
| 173494 | + /* 60 */ 288, 288, 182, 288, 288, 481, 536, 288, 288, 130, |
| 173495 | + /* 70 */ 127, 234, 432, 573, 525, 562, 573, 557, 562, 1290, |
| 173496 | + /* 80 */ 573, 421, 562, 137, 138, 91, 559, 1228, 1228, 1063, |
| 173497 | + /* 90 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 296, |
| 173498 | + /* 100 */ 460, 398, 1249, 134, 134, 134, 134, 133, 133, 132, |
| 173499 | + /* 110 */ 132, 132, 131, 128, 451, 44, 1050, 1050, 1064, 1067, |
| 173500 | + /* 120 */ 1255, 1, 1, 582, 2, 1259, 581, 1174, 1259, 1174, |
| 173501 | + /* 130 */ 321, 413, 155, 321, 1584, 155, 379, 112, 498, 1341, |
| 173502 | + /* 140 */ 456, 299, 1341, 134, 134, 134, 134, 133, 133, 132, |
| 173503 | + /* 150 */ 132, 132, 131, 128, 451, 137, 138, 91, 1105, 1228, |
| 173504 | + /* 160 */ 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, |
| 173505 | + /* 170 */ 136, 1204, 320, 567, 288, 288, 283, 288, 288, 523, |
| 173506 | + /* 180 */ 523, 1250, 139, 1541, 7, 214, 503, 573, 1169, 562, |
| 173507 | + /* 190 */ 573, 1054, 562, 136, 136, 136, 136, 129, 401, 547, |
| 173508 | + /* 200 */ 487, 1169, 245, 1568, 1169, 245, 133, 133, 132, 132, |
| 173509 | + /* 210 */ 132, 131, 128, 451, 261, 134, 134, 134, 134, 133, |
| 173510 | + /* 220 */ 133, 132, 132, 132, 131, 128, 451, 451, 1204, 1205, |
| 173511 | + /* 230 */ 1204, 130, 127, 234, 455, 413, 182, 455, 130, 127, |
| 173512 | + /* 240 */ 234, 134, 134, 134, 134, 133, 133, 132, 132, 132, |
| 173513 | + /* 250 */ 131, 128, 451, 136, 136, 136, 136, 538, 576, 137, |
| 173514 | + /* 260 */ 138, 91, 261, 1228, 1228, 1063, 1066, 1053, 1053, 135, |
| 173515 | + /* 270 */ 135, 136, 136, 136, 136, 44, 472, 346, 1204, 472, |
| 173516 | + /* 280 */ 346, 51, 51, 418, 93, 157, 134, 134, 134, 134, |
| 173517 | + /* 290 */ 133, 133, 132, 132, 132, 131, 128, 451, 166, 363, |
| 173518 | + /* 300 */ 298, 134, 134, 134, 134, 133, 133, 132, 132, 132, |
| 173519 | + /* 310 */ 131, 128, 451, 1293, 461, 1570, 423, 377, 275, 134, |
| 173520 | + /* 320 */ 134, 134, 134, 133, 133, 132, 132, 132, 131, 128, |
| 173521 | + /* 330 */ 451, 418, 320, 567, 1292, 1204, 1205, 1204, 257, 413, |
| 173522 | + /* 340 */ 483, 511, 508, 507, 94, 132, 132, 132, 131, 128, |
| 173523 | + /* 350 */ 451, 506, 1204, 548, 548, 388, 576, 384, 7, 413, |
| 173524 | + /* 360 */ 550, 229, 522, 137, 138, 91, 530, 1228, 1228, 1063, |
| 173525 | + /* 370 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 51, |
| 173526 | + /* 380 */ 51, 1582, 380, 137, 138, 91, 331, 1228, 1228, 1063, |
| 173527 | + /* 390 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 320, |
| 173528 | + /* 400 */ 567, 288, 288, 320, 567, 1602, 582, 2, 1259, 1204, |
| 173529 | + /* 410 */ 1205, 1204, 1628, 321, 573, 155, 562, 576, 1511, 264, |
| 173530 | + /* 420 */ 231, 520, 1341, 134, 134, 134, 134, 133, 133, 132, |
| 173531 | + /* 430 */ 132, 132, 131, 128, 451, 519, 1511, 1513, 1333, 1333, |
| 173532 | + /* 440 */ 82, 82, 498, 134, 134, 134, 134, 133, 133, 132, |
| 173533 | + /* 450 */ 132, 132, 131, 128, 451, 1435, 257, 288, 288, 511, |
| 173534 | + /* 460 */ 508, 507, 944, 1568, 413, 1019, 1204, 943, 360, 506, |
| 173535 | + /* 470 */ 573, 1598, 562, 44, 575, 551, 551, 557, 1107, 1582, |
| 173536 | + /* 480 */ 544, 576, 1107, 40, 417, 245, 531, 1505, 137, 138, |
| 173537 | + /* 490 */ 91, 219, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, |
| 173538 | + /* 500 */ 136, 136, 136, 136, 81, 81, 1281, 1204, 413, 553, |
| 173539 | + /* 510 */ 1511, 48, 512, 448, 447, 493, 578, 455, 578, 344, |
| 173540 | + /* 520 */ 45, 1204, 1233, 1204, 1205, 1204, 428, 1235, 158, 882, |
| 173541 | + /* 530 */ 320, 567, 137, 138, 91, 1234, 1228, 1228, 1063, 1066, |
| 173542 | + /* 540 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 134, 134, |
| 173543 | + /* 550 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451, |
| 173544 | + /* 560 */ 1236, 576, 1236, 329, 1204, 1205, 1204, 387, 492, 403, |
| 173545 | + /* 570 */ 1040, 382, 489, 123, 568, 1569, 4, 377, 1204, 1205, |
| 173546 | + /* 580 */ 1204, 570, 570, 570, 82, 82, 882, 1029, 1331, 1331, |
| 173547 | + /* 590 */ 571, 1028, 134, 134, 134, 134, 133, 133, 132, 132, |
| 173548 | + /* 600 */ 132, 131, 128, 451, 288, 288, 1281, 1204, 576, 423, |
| 173549 | + /* 610 */ 576, 1568, 413, 423, 452, 378, 886, 573, 1279, 562, |
| 173550 | + /* 620 */ 46, 557, 532, 1028, 1028, 1030, 565, 130, 127, 234, |
| 173551 | + /* 630 */ 556, 82, 82, 82, 82, 479, 137, 138, 91, 462, |
| 173552 | + /* 640 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, |
| 173553 | + /* 650 */ 136, 136, 1188, 487, 1506, 1040, 413, 6, 1204, 50, |
| 173554 | + /* 660 */ 879, 121, 121, 948, 1204, 1205, 1204, 358, 557, 122, |
| 173555 | + /* 670 */ 316, 452, 577, 452, 535, 1204, 1028, 439, 303, 212, |
| 173556 | + /* 680 */ 137, 138, 91, 213, 1228, 1228, 1063, 1066, 1053, 1053, |
| 173557 | + /* 690 */ 135, 135, 136, 136, 136, 136, 134, 134, 134, 134, |
| 173558 | + /* 700 */ 133, 133, 132, 132, 132, 131, 128, 451, 1028, 1028, |
| 173559 | + /* 710 */ 1030, 1031, 35, 288, 288, 1204, 1205, 1204, 1040, 1339, |
| 173560 | + /* 720 */ 533, 123, 568, 1569, 4, 377, 573, 1019, 562, 353, |
| 173561 | + /* 730 */ 1277, 356, 1204, 1205, 1204, 1029, 488, 1188, 571, 1028, |
| 173562 | + /* 740 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131, |
| 173563 | + /* 750 */ 128, 451, 576, 343, 288, 288, 449, 449, 449, 971, |
| 173564 | + /* 760 */ 413, 1627, 452, 911, 1187, 288, 288, 573, 464, 562, |
| 173565 | + /* 770 */ 238, 1028, 1028, 1030, 565, 82, 82, 498, 573, 411, |
| 173566 | + /* 780 */ 562, 344, 467, 332, 137, 138, 91, 197, 1228, 1228, |
| 173567 | + /* 790 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, |
| 173568 | + /* 800 */ 1188, 528, 1169, 1040, 413, 1110, 1110, 495, 1041, 121, |
| 173569 | + /* 810 */ 121, 1204, 317, 540, 862, 1169, 1244, 122, 1169, 452, |
| 173570 | + /* 820 */ 577, 452, 1340, 198, 1028, 1204, 481, 526, 137, 138, |
| 173571 | + /* 830 */ 91, 560, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, |
| 173572 | + /* 840 */ 136, 136, 136, 136, 134, 134, 134, 134, 133, 133, |
| 173573 | + /* 850 */ 132, 132, 132, 131, 128, 451, 1028, 1028, 1030, 1031, |
| 173574 | + /* 860 */ 35, 1204, 288, 288, 1204, 477, 288, 288, 1204, 1205, |
| 173575 | + /* 870 */ 1204, 539, 481, 437, 470, 573, 1451, 562, 364, 573, |
| 173576 | + /* 880 */ 1153, 562, 1204, 1205, 1204, 1188, 5, 576, 134, 134, |
| 173577 | + /* 890 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451, |
| 173578 | + /* 900 */ 221, 214, 302, 96, 1149, 1657, 232, 1657, 413, 392, |
| 173579 | + /* 910 */ 19, 19, 1024, 949, 406, 373, 1595, 1085, 1204, 1205, |
| 173580 | + /* 920 */ 1204, 1204, 1205, 1204, 1204, 426, 1149, 1658, 413, 1658, |
| 173581 | + /* 930 */ 1659, 399, 137, 138, 91, 3, 1228, 1228, 1063, 1066, |
| 173582 | + /* 940 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 304, 1311, |
| 173583 | + /* 950 */ 514, 1204, 137, 138, 91, 1498, 1228, 1228, 1063, 1066, |
| 173584 | + /* 960 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 434, 131, |
| 173585 | + /* 970 */ 128, 451, 375, 1204, 274, 291, 372, 517, 367, 516, |
| 173586 | + /* 980 */ 262, 1204, 1205, 1204, 1147, 227, 363, 448, 447, 1435, |
| 173587 | + /* 990 */ 1568, 1310, 134, 134, 134, 134, 133, 133, 132, 132, |
| 173588 | + /* 1000 */ 132, 131, 128, 451, 1568, 576, 1147, 487, 1204, 1205, |
| 173589 | + /* 1010 */ 1204, 442, 134, 134, 134, 134, 133, 133, 132, 132, |
| 173590 | + /* 1020 */ 132, 131, 128, 451, 386, 576, 485, 576, 19, 19, |
| 173591 | + /* 1030 */ 1204, 1205, 1204, 1345, 1236, 970, 1236, 574, 47, 936, |
| 173592 | + /* 1040 */ 936, 473, 413, 431, 1552, 573, 1125, 562, 19, 19, |
| 173593 | + /* 1050 */ 19, 19, 49, 336, 850, 851, 852, 111, 1368, 315, |
| 173594 | + /* 1060 */ 429, 576, 413, 433, 341, 306, 137, 138, 91, 115, |
| 173595 | + /* 1070 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, |
| 173596 | + /* 1080 */ 136, 136, 576, 1309, 82, 82, 137, 138, 91, 529, |
| 173597 | + /* 1090 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, |
| 173598 | + /* 1100 */ 136, 136, 1569, 222, 377, 19, 19, 305, 1126, 1169, |
| 173599 | + /* 1110 */ 398, 1148, 22, 22, 498, 333, 1569, 335, 377, 576, |
| 173600 | + /* 1120 */ 438, 445, 1169, 1127, 486, 1169, 134, 134, 134, 134, |
| 173601 | + /* 1130 */ 133, 133, 132, 132, 132, 131, 128, 451, 1128, 576, |
| 173602 | + /* 1140 */ 902, 576, 145, 145, 6, 576, 134, 134, 134, 134, |
| 173603 | + /* 1150 */ 133, 133, 132, 132, 132, 131, 128, 451, 214, 1336, |
| 173604 | + /* 1160 */ 922, 576, 19, 19, 19, 19, 1282, 419, 19, 19, |
| 173605 | + /* 1170 */ 923, 412, 515, 141, 576, 1169, 413, 206, 465, 207, |
| 173606 | + /* 1180 */ 903, 215, 1575, 552, 147, 147, 7, 227, 1169, 411, |
| 173607 | + /* 1190 */ 1250, 1169, 120, 307, 117, 307, 413, 66, 66, 334, |
| 173608 | + /* 1200 */ 137, 138, 91, 119, 1228, 1228, 1063, 1066, 1053, 1053, |
| 173609 | + /* 1210 */ 135, 135, 136, 136, 136, 136, 413, 285, 209, 969, |
| 173610 | + /* 1220 */ 137, 138, 91, 471, 1228, 1228, 1063, 1066, 1053, 1053, |
| 173611 | + /* 1230 */ 135, 135, 136, 136, 136, 136, 435, 10, 1450, 267, |
| 173612 | + /* 1240 */ 137, 126, 91, 1435, 1228, 1228, 1063, 1066, 1053, 1053, |
| 173613 | + /* 1250 */ 135, 135, 136, 136, 136, 136, 1435, 1435, 410, 409, |
| 173614 | + /* 1260 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131, |
| 173615 | + /* 1270 */ 128, 451, 576, 969, 576, 1224, 498, 373, 1595, 1554, |
| 173616 | + /* 1280 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131, |
| 173617 | + /* 1290 */ 128, 451, 532, 457, 576, 82, 82, 82, 82, 111, |
| 173618 | + /* 1300 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131, |
| 173619 | + /* 1310 */ 128, 451, 109, 233, 430, 1576, 546, 67, 67, 7, |
| 173620 | + /* 1320 */ 413, 351, 550, 1550, 260, 259, 258, 494, 443, 569, |
| 173621 | + /* 1330 */ 419, 983, 446, 1224, 450, 545, 1207, 576, 969, 984, |
| 173622 | + /* 1340 */ 413, 475, 1449, 1574, 1180, 138, 91, 7, 1228, 1228, |
| 173623 | + /* 1350 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, |
| 173624 | + /* 1360 */ 21, 21, 267, 576, 300, 1126, 91, 233, 1228, 1228, |
| 173625 | + /* 1370 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, |
| 173626 | + /* 1380 */ 1127, 373, 1595, 161, 1573, 16, 53, 53, 7, 108, |
| 173627 | + /* 1390 */ 533, 38, 969, 125, 1207, 1128, 1180, 576, 1224, 123, |
| 173628 | + /* 1400 */ 568, 893, 4, 324, 134, 134, 134, 134, 133, 133, |
| 173629 | + /* 1410 */ 132, 132, 132, 131, 128, 451, 571, 564, 534, 576, |
| 173630 | + /* 1420 */ 68, 68, 576, 39, 134, 134, 134, 134, 133, 133, |
| 173631 | + /* 1430 */ 132, 132, 132, 131, 128, 451, 576, 160, 1571, 1223, |
| 173632 | + /* 1440 */ 452, 576, 54, 54, 576, 69, 69, 576, 1366, 576, |
| 173633 | + /* 1450 */ 420, 184, 565, 463, 297, 576, 1224, 463, 297, 70, |
| 173634 | + /* 1460 */ 70, 576, 44, 474, 71, 71, 576, 72, 72, 576, |
| 173635 | + /* 1470 */ 73, 73, 55, 55, 411, 874, 242, 576, 56, 56, |
| 173636 | + /* 1480 */ 576, 1040, 576, 478, 57, 57, 576, 121, 121, 59, |
| 173637 | + /* 1490 */ 59, 23, 60, 60, 411, 122, 319, 452, 577, 452, |
| 173638 | + /* 1500 */ 74, 74, 1028, 75, 75, 76, 76, 411, 290, 20, |
| 173639 | + /* 1510 */ 20, 108, 287, 231, 553, 123, 568, 325, 4, 320, |
| 173640 | + /* 1520 */ 567, 97, 218, 944, 1144, 328, 400, 576, 943, 576, |
| 173641 | + /* 1530 */ 1380, 424, 571, 874, 1028, 1028, 1030, 1031, 35, 293, |
| 173642 | + /* 1540 */ 534, 576, 1104, 576, 1104, 9, 576, 342, 576, 111, |
| 173643 | + /* 1550 */ 77, 77, 143, 143, 576, 205, 452, 222, 1379, 889, |
| 173644 | + /* 1560 */ 576, 901, 900, 1188, 144, 144, 78, 78, 565, 62, |
| 173645 | + /* 1570 */ 62, 79, 79, 323, 1021, 576, 266, 63, 63, 908, |
| 173646 | + /* 1580 */ 909, 1589, 542, 80, 80, 576, 371, 541, 123, 568, |
| 173647 | + /* 1590 */ 480, 4, 266, 482, 244, 266, 370, 1040, 64, 64, |
| 173648 | + /* 1600 */ 576, 466, 576, 121, 121, 571, 1557, 576, 170, 170, |
| 173649 | + /* 1610 */ 576, 122, 576, 452, 577, 452, 576, 889, 1028, 576, |
| 173650 | + /* 1620 */ 165, 576, 111, 171, 171, 87, 87, 337, 1616, 452, |
| 173651 | + /* 1630 */ 65, 65, 1530, 83, 83, 146, 146, 986, 987, 84, |
| 173652 | + /* 1640 */ 84, 565, 168, 168, 148, 148, 1092, 347, 1032, 111, |
| 173653 | + /* 1650 */ 1028, 1028, 1030, 1031, 35, 542, 1103, 576, 1103, 576, |
| 173654 | + /* 1660 */ 543, 123, 568, 504, 4, 263, 576, 361, 1529, 111, |
| 173655 | + /* 1670 */ 1040, 1088, 576, 263, 576, 490, 121, 121, 571, 1188, |
| 173656 | + /* 1680 */ 142, 142, 169, 169, 122, 576, 452, 577, 452, 162, |
| 173657 | + /* 1690 */ 162, 1028, 576, 563, 576, 152, 152, 151, 151, 348, |
| 173658 | + /* 1700 */ 1376, 974, 452, 266, 1092, 942, 1032, 125, 149, 149, |
| 173659 | + /* 1710 */ 939, 576, 125, 576, 565, 150, 150, 86, 86, 872, |
| 173660 | + /* 1720 */ 352, 159, 576, 1028, 1028, 1030, 1031, 35, 542, 941, |
| 173661 | + /* 1730 */ 576, 125, 355, 541, 88, 88, 85, 85, 357, 359, |
| 173662 | + /* 1740 */ 1324, 1308, 366, 1040, 376, 52, 52, 499, 1389, 121, |
| 173663 | + /* 1750 */ 121, 1434, 1188, 58, 58, 1362, 1374, 122, 1439, 452, |
| 173664 | + /* 1760 */ 577, 452, 1289, 167, 1028, 1280, 280, 1268, 1267, 1269, |
| 173665 | + /* 1770 */ 1609, 1359, 312, 313, 12, 314, 397, 1421, 224, 1416, |
| 173666 | + /* 1780 */ 295, 237, 1409, 339, 340, 1426, 301, 345, 484, 228, |
| 173667 | + /* 1790 */ 1371, 1307, 1372, 1370, 1425, 404, 1028, 1028, 1030, 1031, |
| 173668 | + /* 1800 */ 35, 1601, 1192, 454, 509, 369, 292, 1502, 210, 1501, |
| 173669 | + /* 1810 */ 1369, 396, 396, 395, 277, 393, 211, 566, 859, 1612, |
| 173670 | + /* 1820 */ 1244, 123, 568, 391, 4, 1188, 223, 270, 1549, 1547, |
| 173671 | + /* 1830 */ 1241, 239, 186, 327, 422, 96, 195, 220, 571, 235, |
| 173672 | + /* 1840 */ 180, 326, 188, 468, 190, 1507, 191, 192, 92, 193, |
| 173673 | + /* 1850 */ 469, 95, 1422, 13, 502, 247, 1430, 109, 199, 402, |
| 173674 | + /* 1860 */ 476, 405, 452, 1496, 1428, 1427, 14, 491, 251, 102, |
| 173675 | + /* 1870 */ 497, 1518, 241, 281, 565, 253, 203, 354, 500, 254, |
| 173676 | + /* 1880 */ 175, 1270, 407, 43, 350, 518, 1327, 436, 255, 1326, |
| 173677 | + /* 1890 */ 1325, 1318, 104, 893, 1626, 229, 408, 440, 1625, 441, |
| 173678 | + /* 1900 */ 240, 310, 1296, 1040, 311, 1317, 527, 1594, 1297, 121, |
| 173679 | + /* 1910 */ 121, 368, 1295, 1624, 268, 269, 1580, 122, 1579, 452, |
| 173680 | + /* 1920 */ 577, 452, 374, 444, 1028, 1394, 1393, 140, 553, 90, |
| 173681 | + /* 1930 */ 568, 11, 4, 1483, 383, 414, 385, 110, 116, 216, |
| 173682 | + /* 1940 */ 320, 567, 1350, 555, 42, 318, 571, 537, 1349, 389, |
| 173683 | + /* 1950 */ 390, 579, 1198, 276, 279, 278, 1028, 1028, 1030, 1031, |
| 173684 | + /* 1960 */ 35, 580, 415, 1265, 458, 1260, 416, 185, 1534, 172, |
| 173685 | + /* 1970 */ 452, 1535, 173, 156, 308, 846, 1533, 1532, 453, 217, |
| 173686 | + /* 1980 */ 225, 89, 565, 174, 322, 1188, 226, 236, 1102, 154, |
| 173687 | + /* 1990 */ 1100, 330, 176, 187, 1223, 189, 925, 338, 243, 1116, |
| 173688 | + /* 2000 */ 246, 194, 177, 178, 425, 427, 98, 99, 196, 100, |
| 173689 | + /* 2010 */ 101, 1040, 179, 1119, 248, 1115, 249, 121, 121, 24, |
| 173690 | + /* 2020 */ 163, 250, 349, 1108, 266, 122, 1238, 452, 577, 452, |
| 173691 | + /* 2030 */ 1192, 454, 1028, 200, 292, 496, 252, 201, 861, 396, |
| 173692 | + /* 2040 */ 396, 395, 277, 393, 15, 501, 859, 370, 292, 256, |
| 173693 | + /* 2050 */ 202, 554, 505, 396, 396, 395, 277, 393, 103, 239, |
| 173694 | + /* 2060 */ 859, 327, 25, 26, 1028, 1028, 1030, 1031, 35, 326, |
| 173695 | + /* 2070 */ 362, 510, 891, 239, 365, 327, 513, 904, 105, 309, |
| 173696 | + /* 2080 */ 164, 181, 27, 326, 106, 521, 107, 1185, 1069, 1155, |
| 173697 | + /* 2090 */ 17, 1154, 284, 1188, 286, 978, 265, 204, 125, 1171, |
| 173698 | + /* 2100 */ 241, 230, 972, 1175, 28, 1160, 29, 1179, 175, 1173, |
| 173699 | + /* 2110 */ 30, 43, 31, 1178, 241, 32, 41, 549, 8, 33, |
| 173700 | + /* 2120 */ 208, 111, 175, 1083, 1070, 43, 113, 1068, 240, 114, |
| 173701 | + /* 2130 */ 1072, 34, 1073, 561, 1124, 118, 271, 36, 18, 1194, |
| 173702 | + /* 2140 */ 1033, 873, 240, 935, 124, 37, 272, 273, 1617, 572, |
| 173703 | + /* 2150 */ 183, 153, 394, 1193, 1256, 1256, 1256, 1256, 1256, 1256, |
| 173704 | + /* 2160 */ 1256, 1256, 1256, 414, 1256, 1256, 1256, 1256, 320, 567, |
| 173705 | + /* 2170 */ 1256, 1256, 1256, 1256, 1256, 1256, 1256, 414, 1256, 1256, |
| 173706 | + /* 2180 */ 1256, 1256, 320, 567, 1256, 1256, 1256, 1256, 1256, 1256, |
| 173707 | + /* 2190 */ 1256, 1256, 458, 1256, 1256, 1256, 1256, 1256, 1256, 1256, |
| 173708 | + /* 2200 */ 1256, 1256, 1256, 1256, 1256, 1256, 458, |
| 172835 | 173709 | }; |
| 172836 | 173710 | static const YYCODETYPE yy_lookahead[] = { |
| 172837 | | - /* 0 */ 194, 276, 277, 278, 216, 194, 194, 217, 194, 194, |
| 172838 | | - /* 10 */ 194, 194, 224, 194, 194, 276, 277, 278, 204, 19, |
| 172839 | | - /* 20 */ 206, 202, 297, 217, 218, 205, 207, 217, 205, 217, |
| 172840 | | - /* 30 */ 218, 31, 217, 218, 217, 218, 29, 217, 218, 39, |
| 172841 | | - /* 40 */ 33, 217, 220, 43, 44, 45, 46, 47, 48, 49, |
| 172842 | | - /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 312, 19, |
| 172843 | | - /* 60 */ 240, 241, 316, 240, 241, 194, 46, 47, 48, 49, |
| 172844 | | - /* 70 */ 22, 254, 65, 253, 254, 255, 253, 194, 255, 194, |
| 172845 | | - /* 80 */ 263, 258, 259, 43, 44, 45, 46, 47, 48, 49, |
| 172846 | | - /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 276, 277, |
| 172847 | | - /* 100 */ 278, 285, 102, 103, 104, 105, 106, 107, 108, 109, |
| 172848 | | - /* 110 */ 110, 111, 112, 113, 59, 186, 187, 188, 189, 190, |
| 172849 | | - /* 120 */ 191, 310, 239, 317, 318, 196, 86, 198, 88, 317, |
| 172850 | | - /* 130 */ 19, 319, 317, 318, 205, 264, 25, 211, 212, 213, |
| 172851 | | - /* 140 */ 205, 121, 102, 103, 104, 105, 106, 107, 108, 109, |
| 172852 | | - /* 150 */ 110, 111, 112, 113, 43, 44, 45, 46, 47, 48, |
| 172853 | | - /* 160 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 240, |
| 172854 | | - /* 170 */ 241, 116, 117, 118, 119, 240, 241, 122, 123, 124, |
| 172855 | | - /* 180 */ 69, 298, 253, 194, 255, 106, 107, 132, 253, 141, |
| 172856 | | - /* 190 */ 255, 54, 55, 56, 57, 58, 207, 268, 102, 103, |
| 172857 | | - /* 200 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 172858 | | - /* 210 */ 214, 128, 129, 102, 103, 104, 105, 106, 107, 108, |
| 172859 | | - /* 220 */ 109, 110, 111, 112, 113, 134, 25, 136, 137, 300, |
| 172860 | | - /* 230 */ 165, 166, 153, 19, 155, 54, 55, 56, 57, 102, |
| 172861 | | - /* 240 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 172862 | | - /* 250 */ 113, 108, 109, 110, 111, 112, 113, 43, 44, 45, |
| 172863 | | - /* 260 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, |
| 172864 | | - /* 270 */ 56, 57, 276, 277, 278, 113, 194, 19, 22, 23, |
| 172865 | | - /* 280 */ 194, 67, 24, 102, 103, 104, 105, 106, 107, 108, |
| 172866 | | - /* 290 */ 109, 110, 111, 112, 113, 220, 250, 59, 252, 217, |
| 172867 | | - /* 300 */ 218, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 172868 | | - /* 310 */ 52, 53, 54, 55, 56, 57, 102, 103, 104, 105, |
| 172869 | | - /* 320 */ 106, 107, 108, 109, 110, 111, 112, 113, 106, 107, |
| 172870 | | - /* 330 */ 108, 109, 110, 111, 112, 113, 254, 59, 205, 138, |
| 172871 | | - /* 340 */ 139, 19, 20, 194, 22, 263, 22, 23, 231, 25, |
| 172872 | | - /* 350 */ 72, 276, 277, 278, 116, 117, 118, 101, 36, 76, |
| 172873 | | - /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 172874 | | - /* 370 */ 112, 113, 89, 240, 241, 92, 73, 194, 194, 73, |
| 172875 | | - /* 380 */ 19, 59, 188, 189, 190, 191, 253, 81, 255, 151, |
| 172876 | | - /* 390 */ 196, 25, 198, 71, 116, 117, 118, 311, 312, 205, |
| 172877 | | - /* 400 */ 217, 218, 316, 81, 43, 44, 45, 46, 47, 48, |
| 172878 | | - /* 410 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 270, |
| 172879 | | - /* 420 */ 22, 23, 100, 25, 59, 101, 138, 139, 106, 107, |
| 172880 | | - /* 430 */ 127, 128, 129, 127, 240, 241, 114, 254, 116, 117, |
| 172881 | | - /* 440 */ 118, 76, 76, 121, 138, 139, 263, 253, 264, 255, |
| 172882 | | - /* 450 */ 205, 275, 87, 19, 89, 89, 194, 92, 92, 199, |
| 172883 | | - /* 460 */ 138, 139, 268, 102, 103, 104, 105, 106, 107, 108, |
| 172884 | | - /* 470 */ 109, 110, 111, 112, 113, 153, 154, 155, 156, 157, |
| 172885 | | - /* 480 */ 81, 116, 117, 118, 129, 240, 241, 224, 19, 226, |
| 172886 | | - /* 490 */ 314, 315, 23, 25, 300, 59, 22, 234, 253, 101, |
| 172887 | | - /* 500 */ 255, 236, 237, 26, 194, 183, 194, 152, 72, 22, |
| 172888 | | - /* 510 */ 145, 150, 43, 44, 45, 46, 47, 48, 49, 50, |
| 172889 | | - /* 520 */ 51, 52, 53, 54, 55, 56, 57, 217, 218, 217, |
| 172890 | | - /* 530 */ 218, 19, 189, 59, 191, 23, 59, 138, 139, 196, |
| 172891 | | - /* 540 */ 135, 198, 232, 283, 232, 140, 59, 287, 205, 275, |
| 172892 | | - /* 550 */ 116, 205, 116, 117, 118, 43, 44, 45, 46, 47, |
| 172893 | | - /* 560 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 172894 | | - /* 570 */ 194, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 172895 | | - /* 580 */ 111, 112, 113, 240, 241, 194, 240, 241, 314, 315, |
| 172896 | | - /* 590 */ 116, 117, 118, 116, 117, 118, 253, 194, 255, 253, |
| 172897 | | - /* 600 */ 59, 255, 19, 116, 117, 118, 23, 22, 217, 218, |
| 172898 | | - /* 610 */ 142, 268, 205, 275, 102, 103, 104, 105, 106, 107, |
| 172899 | | - /* 620 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 172900 | | - /* 630 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172901 | | - /* 640 */ 57, 19, 194, 300, 59, 23, 119, 240, 241, 122, |
| 172902 | | - /* 650 */ 123, 124, 314, 315, 194, 236, 237, 194, 117, 132, |
| 172903 | | - /* 660 */ 253, 81, 255, 205, 59, 43, 44, 45, 46, 47, |
| 172904 | | - /* 670 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 172905 | | - /* 680 */ 217, 218, 194, 194, 194, 102, 103, 104, 105, 106, |
| 172906 | | - /* 690 */ 107, 108, 109, 110, 111, 112, 113, 294, 240, 241, |
| 172907 | | - /* 700 */ 120, 116, 117, 118, 59, 194, 217, 218, 211, 212, |
| 172908 | | - /* 710 */ 213, 253, 19, 255, 194, 19, 23, 254, 138, 139, |
| 172909 | | - /* 720 */ 24, 232, 117, 194, 102, 103, 104, 105, 106, 107, |
| 172910 | | - /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 172911 | | - /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172912 | | - /* 750 */ 57, 19, 264, 108, 76, 23, 127, 128, 129, 311, |
| 172913 | | - /* 760 */ 312, 116, 117, 118, 316, 87, 306, 89, 308, 194, |
| 172914 | | - /* 770 */ 92, 22, 59, 194, 22, 43, 44, 45, 46, 47, |
| 172915 | | - /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 172916 | | - /* 790 */ 194, 95, 217, 218, 265, 102, 103, 104, 105, 106, |
| 172917 | | - /* 800 */ 107, 108, 109, 110, 111, 112, 113, 232, 59, 113, |
| 172918 | | - /* 810 */ 25, 59, 194, 217, 218, 119, 120, 121, 122, 123, |
| 172919 | | - /* 820 */ 124, 125, 19, 145, 194, 194, 23, 131, 232, 116, |
| 172920 | | - /* 830 */ 117, 118, 35, 194, 102, 103, 104, 105, 106, 107, |
| 172921 | | - /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 172922 | | - /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172923 | | - /* 860 */ 57, 19, 194, 66, 194, 116, 117, 118, 116, 117, |
| 172924 | | - /* 870 */ 118, 74, 242, 294, 194, 194, 206, 23, 194, 25, |
| 172925 | | - /* 880 */ 194, 111, 112, 113, 25, 43, 44, 45, 46, 47, |
| 172926 | | - /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 172927 | | - /* 900 */ 24, 194, 194, 217, 218, 102, 103, 104, 105, 106, |
| 172928 | | - /* 910 */ 107, 108, 109, 110, 111, 112, 113, 241, 232, 194, |
| 172929 | | - /* 920 */ 212, 213, 242, 242, 217, 218, 242, 130, 11, 253, |
| 172930 | | - /* 930 */ 194, 255, 19, 265, 149, 59, 306, 194, 308, 232, |
| 172931 | | - /* 940 */ 309, 310, 217, 218, 102, 103, 104, 105, 106, 107, |
| 172932 | | - /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 172933 | | - /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172934 | | - /* 970 */ 57, 194, 194, 59, 194, 239, 19, 194, 25, 254, |
| 172935 | | - /* 980 */ 303, 304, 23, 194, 25, 126, 306, 306, 308, 308, |
| 172936 | | - /* 990 */ 306, 271, 308, 117, 286, 217, 218, 217, 218, 194, |
| 172937 | | - /* 1000 */ 194, 159, 45, 46, 47, 48, 49, 50, 51, 52, |
| 172938 | | - /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, |
| 172939 | | - /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 59, 239, 194, |
| 172940 | | - /* 1030 */ 116, 117, 118, 260, 254, 194, 240, 241, 194, 233, |
| 172941 | | - /* 1040 */ 205, 240, 241, 205, 239, 128, 129, 270, 265, 253, |
| 172942 | | - /* 1050 */ 194, 255, 217, 218, 253, 194, 255, 143, 280, 102, |
| 172943 | | - /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 172944 | | - /* 1070 */ 113, 118, 159, 217, 218, 240, 241, 118, 240, 241, |
| 172945 | | - /* 1080 */ 194, 194, 194, 239, 116, 117, 118, 22, 253, 254, |
| 172946 | | - /* 1090 */ 255, 253, 19, 255, 233, 194, 143, 24, 263, 212, |
| 172947 | | - /* 1100 */ 213, 194, 143, 217, 218, 217, 218, 261, 262, 271, |
| 172948 | | - /* 1110 */ 254, 143, 19, 7, 8, 9, 43, 44, 45, 46, |
| 172949 | | - /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172950 | | - /* 1130 */ 57, 16, 19, 22, 23, 294, 43, 44, 45, 46, |
| 172951 | | - /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172952 | | - /* 1150 */ 57, 312, 194, 214, 21, 316, 43, 44, 45, 46, |
| 172953 | | - /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 172954 | | - /* 1170 */ 57, 106, 107, 286, 194, 102, 103, 104, 105, 106, |
| 172955 | | - /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 207, 158, 59, |
| 172956 | | - /* 1190 */ 160, 22, 77, 24, 79, 102, 103, 104, 105, 106, |
| 172957 | | - /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 194, 194, 229, |
| 172958 | | - /* 1210 */ 194, 231, 101, 80, 22, 102, 103, 104, 105, 106, |
| 172959 | | - /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 288, 59, 12, |
| 172960 | | - /* 1230 */ 217, 218, 293, 217, 218, 19, 106, 107, 59, 19, |
| 172961 | | - /* 1240 */ 16, 127, 128, 129, 27, 115, 116, 117, 118, 194, |
| 172962 | | - /* 1250 */ 120, 59, 22, 194, 24, 194, 123, 100, 128, 42, |
| 172963 | | - /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 172964 | | - /* 1270 */ 54, 55, 56, 57, 117, 194, 217, 218, 121, 100, |
| 172965 | | - /* 1280 */ 63, 194, 245, 153, 194, 155, 117, 19, 115, 194, |
| 172966 | | - /* 1290 */ 73, 214, 194, 256, 161, 116, 117, 194, 217, 218, |
| 172967 | | - /* 1300 */ 121, 77, 194, 79, 217, 218, 194, 217, 218, 117, |
| 172968 | | - /* 1310 */ 153, 154, 155, 254, 46, 217, 218, 144, 102, 103, |
| 172969 | | - /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 172970 | | - /* 1330 */ 232, 270, 153, 154, 155, 115, 116, 66, 19, 20, |
| 172971 | | - /* 1340 */ 183, 22, 12, 312, 254, 194, 262, 316, 209, 210, |
| 172972 | | - /* 1350 */ 266, 239, 194, 194, 108, 36, 85, 27, 19, 20, |
| 172973 | | - /* 1360 */ 265, 22, 183, 245, 144, 94, 25, 48, 217, 218, |
| 172974 | | - /* 1370 */ 293, 194, 42, 270, 256, 36, 217, 218, 59, 194, |
| 172975 | | - /* 1380 */ 25, 135, 194, 115, 194, 161, 140, 194, 194, 15, |
| 172976 | | - /* 1390 */ 71, 194, 312, 63, 217, 218, 316, 194, 59, 131, |
| 172977 | | - /* 1400 */ 301, 302, 217, 218, 85, 217, 218, 217, 218, 90, |
| 172978 | | - /* 1410 */ 71, 217, 218, 19, 217, 218, 245, 146, 262, 100, |
| 172979 | | - /* 1420 */ 217, 218, 266, 265, 85, 106, 107, 256, 312, 90, |
| 172980 | | - /* 1430 */ 209, 210, 316, 114, 60, 116, 117, 118, 194, 100, |
| 172981 | | - /* 1440 */ 121, 194, 194, 145, 115, 106, 107, 19, 46, 19, |
| 172982 | | - /* 1450 */ 20, 24, 22, 114, 194, 116, 117, 118, 194, 245, |
| 172983 | | - /* 1460 */ 121, 194, 164, 194, 217, 218, 36, 194, 258, 259, |
| 172984 | | - /* 1470 */ 256, 194, 153, 154, 155, 156, 157, 217, 218, 150, |
| 172985 | | - /* 1480 */ 31, 217, 218, 142, 217, 218, 217, 218, 39, 59, |
| 172986 | | - /* 1490 */ 217, 218, 153, 154, 155, 156, 157, 149, 150, 5, |
| 172987 | | - /* 1500 */ 145, 71, 183, 245, 10, 11, 12, 13, 14, 194, |
| 172988 | | - /* 1510 */ 116, 17, 129, 227, 256, 85, 194, 115, 194, 23, |
| 172989 | | - /* 1520 */ 90, 25, 183, 99, 30, 97, 32, 22, 22, 194, |
| 172990 | | - /* 1530 */ 100, 194, 217, 218, 40, 152, 106, 107, 23, 217, |
| 172991 | | - /* 1540 */ 218, 194, 19, 20, 114, 22, 116, 117, 118, 257, |
| 172992 | | - /* 1550 */ 194, 121, 217, 218, 217, 218, 194, 133, 53, 36, |
| 172993 | | - /* 1560 */ 23, 23, 25, 25, 70, 120, 121, 61, 141, 7, |
| 172994 | | - /* 1570 */ 8, 121, 78, 217, 218, 81, 23, 227, 25, 217, |
| 172995 | | - /* 1580 */ 218, 131, 59, 153, 154, 155, 156, 157, 0, 1, |
| 172996 | | - /* 1590 */ 2, 59, 98, 5, 71, 23, 227, 25, 10, 11, |
| 172997 | | - /* 1600 */ 12, 13, 14, 83, 84, 17, 23, 23, 25, 25, |
| 172998 | | - /* 1610 */ 59, 194, 194, 183, 23, 23, 25, 25, 30, 194, |
| 172999 | | - /* 1620 */ 32, 19, 20, 100, 22, 194, 194, 133, 40, 106, |
| 173000 | | - /* 1630 */ 107, 108, 138, 139, 194, 217, 218, 114, 36, 116, |
| 173001 | | - /* 1640 */ 117, 118, 217, 218, 121, 194, 194, 194, 23, 117, |
| 173002 | | - /* 1650 */ 25, 194, 23, 23, 25, 25, 162, 194, 70, 194, |
| 173003 | | - /* 1660 */ 145, 59, 23, 153, 25, 155, 78, 194, 117, 81, |
| 173004 | | - /* 1670 */ 217, 218, 194, 71, 217, 218, 153, 154, 155, 156, |
| 173005 | | - /* 1680 */ 157, 194, 217, 218, 194, 23, 98, 25, 321, 194, |
| 173006 | | - /* 1690 */ 217, 218, 194, 19, 20, 194, 22, 153, 23, 155, |
| 173007 | | - /* 1700 */ 25, 194, 100, 194, 217, 218, 183, 194, 106, 107, |
| 173008 | | - /* 1710 */ 36, 194, 217, 218, 237, 194, 114, 243, 116, 117, |
| 173009 | | - /* 1720 */ 118, 133, 194, 121, 217, 218, 138, 139, 194, 194, |
| 173010 | | - /* 1730 */ 194, 290, 289, 59, 217, 218, 194, 194, 217, 218, |
| 173011 | | - /* 1740 */ 194, 194, 140, 194, 194, 71, 194, 244, 194, 194, |
| 173012 | | - /* 1750 */ 162, 217, 218, 194, 194, 153, 154, 155, 156, 157, |
| 173013 | | - /* 1760 */ 217, 218, 194, 217, 218, 194, 217, 218, 257, 217, |
| 173014 | | - /* 1770 */ 218, 217, 218, 257, 100, 194, 257, 217, 218, 257, |
| 173015 | | - /* 1780 */ 106, 107, 215, 299, 194, 183, 192, 194, 114, 194, |
| 173016 | | - /* 1790 */ 116, 117, 118, 1, 2, 121, 221, 5, 217, 218, |
| 173017 | | - /* 1800 */ 273, 197, 10, 11, 12, 13, 14, 217, 218, 17, |
| 173018 | | - /* 1810 */ 217, 218, 217, 218, 140, 194, 246, 194, 273, 295, |
| 173019 | | - /* 1820 */ 247, 273, 30, 247, 32, 269, 269, 153, 154, 155, |
| 173020 | | - /* 1830 */ 156, 157, 40, 246, 273, 295, 230, 226, 217, 218, |
| 173021 | | - /* 1840 */ 217, 218, 220, 261, 220, 282, 220, 19, 20, 244, |
| 173022 | | - /* 1850 */ 22, 250, 141, 250, 246, 60, 201, 183, 261, 261, |
| 173023 | | - /* 1860 */ 261, 201, 70, 299, 36, 299, 201, 38, 151, 150, |
| 173024 | | - /* 1870 */ 78, 285, 22, 81, 296, 296, 43, 235, 18, 238, |
| 173025 | | - /* 1880 */ 201, 274, 272, 238, 238, 238, 18, 59, 200, 149, |
| 173026 | | - /* 1890 */ 98, 247, 274, 274, 235, 247, 247, 247, 235, 71, |
| 173027 | | - /* 1900 */ 272, 201, 200, 158, 292, 62, 291, 201, 200, 22, |
| 173028 | | - /* 1910 */ 201, 222, 200, 222, 201, 200, 115, 219, 219, 64, |
| 173029 | | - /* 1920 */ 219, 228, 22, 126, 221, 133, 165, 222, 100, 225, |
| 173030 | | - /* 1930 */ 138, 139, 225, 219, 106, 107, 24, 219, 228, 219, |
| 173031 | | - /* 1940 */ 219, 307, 114, 113, 116, 117, 118, 315, 284, 121, |
| 173032 | | - /* 1950 */ 284, 222, 201, 91, 162, 320, 320, 82, 148, 267, |
| 173033 | | - /* 1960 */ 145, 267, 22, 279, 201, 158, 281, 251, 147, 146, |
| 173034 | | - /* 1970 */ 25, 203, 250, 249, 251, 248, 13, 247, 195, 195, |
| 173035 | | - /* 1980 */ 6, 153, 154, 155, 156, 157, 193, 193, 305, 193, |
| 173036 | | - /* 1990 */ 208, 305, 302, 214, 214, 214, 208, 223, 223, 214, |
| 173037 | | - /* 2000 */ 4, 215, 215, 214, 3, 22, 208, 163, 15, 23, |
| 173038 | | - /* 2010 */ 16, 183, 23, 139, 151, 130, 25, 20, 142, 24, |
| 173039 | | - /* 2020 */ 16, 144, 1, 142, 130, 130, 61, 37, 53, 151, |
| 173040 | | - /* 2030 */ 53, 53, 53, 130, 116, 1, 34, 141, 5, 22, |
| 173041 | | - /* 2040 */ 115, 161, 75, 25, 68, 141, 41, 115, 68, 24, |
| 173042 | | - /* 2050 */ 20, 19, 131, 125, 67, 67, 96, 22, 22, 22, |
| 173043 | | - /* 2060 */ 37, 23, 22, 24, 22, 59, 67, 23, 149, 28, |
| 173044 | | - /* 2070 */ 22, 25, 23, 23, 23, 22, 141, 34, 97, 23, |
| 173045 | | - /* 2080 */ 23, 34, 116, 22, 143, 25, 34, 75, 34, 34, |
| 173046 | | - /* 2090 */ 75, 88, 34, 86, 23, 22, 34, 25, 24, 34, |
| 173047 | | - /* 2100 */ 25, 93, 23, 44, 142, 23, 142, 23, 23, 22, |
| 173048 | | - /* 2110 */ 11, 25, 23, 25, 23, 22, 22, 22, 1, 23, |
| 173049 | | - /* 2120 */ 23, 23, 22, 22, 15, 141, 141, 25, 25, 1, |
| 173050 | | - /* 2130 */ 322, 322, 322, 135, 322, 322, 322, 322, 322, 322, |
| 173051 | | - /* 2140 */ 322, 141, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173052 | | - /* 2150 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173053 | | - /* 2160 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173054 | | - /* 2170 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173055 | | - /* 2180 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173056 | | - /* 2190 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173057 | | - /* 2200 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173711 | + /* 0 */ 276, 277, 278, 240, 241, 224, 194, 226, 194, 240, |
| 173712 | + /* 10 */ 241, 194, 216, 220, 194, 234, 253, 194, 255, 19, |
| 173713 | + /* 20 */ 224, 297, 253, 194, 255, 205, 212, 213, 205, 217, |
| 173714 | + /* 30 */ 218, 31, 205, 194, 217, 218, 194, 217, 218, 39, |
| 173715 | + /* 40 */ 217, 218, 312, 43, 44, 45, 316, 47, 48, 49, |
| 173716 | + /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 19, |
| 173717 | + /* 60 */ 240, 241, 194, 240, 241, 194, 254, 240, 241, 276, |
| 173718 | + /* 70 */ 277, 278, 233, 253, 254, 255, 253, 254, 255, 217, |
| 173719 | + /* 80 */ 253, 239, 255, 43, 44, 45, 263, 47, 48, 49, |
| 173720 | + /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 270, |
| 173721 | + /* 100 */ 286, 22, 23, 103, 104, 105, 106, 107, 108, 109, |
| 173722 | + /* 110 */ 110, 111, 112, 113, 114, 82, 47, 48, 49, 50, |
| 173723 | + /* 120 */ 186, 187, 188, 189, 190, 191, 189, 87, 191, 89, |
| 173724 | + /* 130 */ 196, 19, 198, 196, 317, 198, 319, 25, 194, 205, |
| 173725 | + /* 140 */ 298, 270, 205, 103, 104, 105, 106, 107, 108, 109, |
| 173726 | + /* 150 */ 110, 111, 112, 113, 114, 43, 44, 45, 11, 47, |
| 173727 | + /* 160 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 173728 | + /* 170 */ 58, 60, 139, 140, 240, 241, 214, 240, 241, 311, |
| 173729 | + /* 180 */ 312, 102, 70, 239, 316, 194, 19, 253, 77, 255, |
| 173730 | + /* 190 */ 253, 122, 255, 55, 56, 57, 58, 59, 207, 88, |
| 173731 | + /* 200 */ 194, 90, 268, 194, 93, 268, 107, 108, 109, 110, |
| 173732 | + /* 210 */ 111, 112, 113, 114, 47, 103, 104, 105, 106, 107, |
| 173733 | + /* 220 */ 108, 109, 110, 111, 112, 113, 114, 114, 117, 118, |
| 173734 | + /* 230 */ 119, 276, 277, 278, 300, 19, 194, 300, 276, 277, |
| 173735 | + /* 240 */ 278, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 173736 | + /* 250 */ 112, 113, 114, 55, 56, 57, 58, 146, 194, 43, |
| 173737 | + /* 260 */ 44, 45, 47, 47, 48, 49, 50, 51, 52, 53, |
| 173738 | + /* 270 */ 54, 55, 56, 57, 58, 82, 129, 130, 60, 129, |
| 173739 | + /* 280 */ 130, 217, 218, 116, 68, 25, 103, 104, 105, 106, |
| 173740 | + /* 290 */ 107, 108, 109, 110, 111, 112, 113, 114, 23, 132, |
| 173741 | + /* 300 */ 294, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 173742 | + /* 310 */ 112, 113, 114, 217, 121, 306, 194, 308, 26, 103, |
| 173743 | + /* 320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 173744 | + /* 330 */ 114, 116, 139, 140, 217, 117, 118, 119, 120, 19, |
| 173745 | + /* 340 */ 194, 123, 124, 125, 24, 109, 110, 111, 112, 113, |
| 173746 | + /* 350 */ 114, 133, 60, 311, 312, 250, 194, 252, 316, 19, |
| 173747 | + /* 360 */ 194, 166, 167, 43, 44, 45, 205, 47, 48, 49, |
| 173748 | + /* 370 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 217, |
| 173749 | + /* 380 */ 218, 317, 318, 43, 44, 45, 264, 47, 48, 49, |
| 173750 | + /* 390 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 139, |
| 173751 | + /* 400 */ 140, 240, 241, 139, 140, 188, 189, 190, 191, 117, |
| 173752 | + /* 410 */ 118, 119, 231, 196, 253, 198, 255, 194, 194, 258, |
| 173753 | + /* 420 */ 259, 146, 205, 103, 104, 105, 106, 107, 108, 109, |
| 173754 | + /* 430 */ 110, 111, 112, 113, 114, 109, 212, 213, 236, 237, |
| 173755 | + /* 440 */ 217, 218, 194, 103, 104, 105, 106, 107, 108, 109, |
| 173756 | + /* 450 */ 110, 111, 112, 113, 114, 194, 120, 240, 241, 123, |
| 173757 | + /* 460 */ 124, 125, 136, 194, 19, 74, 60, 141, 23, 133, |
| 173758 | + /* 470 */ 253, 194, 255, 82, 194, 309, 310, 254, 29, 317, |
| 173759 | + /* 480 */ 318, 194, 33, 22, 199, 268, 263, 239, 43, 44, |
| 173760 | + /* 490 */ 45, 151, 47, 48, 49, 50, 51, 52, 53, 54, |
| 173761 | + /* 500 */ 55, 56, 57, 58, 217, 218, 194, 60, 19, 146, |
| 173762 | + /* 510 */ 286, 242, 23, 107, 108, 66, 204, 300, 206, 128, |
| 173763 | + /* 520 */ 73, 60, 116, 117, 118, 119, 265, 121, 165, 60, |
| 173764 | + /* 530 */ 139, 140, 43, 44, 45, 129, 47, 48, 49, 50, |
| 173765 | + /* 540 */ 51, 52, 53, 54, 55, 56, 57, 58, 103, 104, |
| 173766 | + /* 550 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 173767 | + /* 560 */ 154, 194, 156, 194, 117, 118, 119, 280, 283, 205, |
| 173768 | + /* 570 */ 101, 220, 287, 19, 20, 306, 22, 308, 117, 118, |
| 173769 | + /* 580 */ 119, 211, 212, 213, 217, 218, 117, 118, 236, 237, |
| 173770 | + /* 590 */ 36, 122, 103, 104, 105, 106, 107, 108, 109, 110, |
| 173771 | + /* 600 */ 111, 112, 113, 114, 240, 241, 194, 60, 194, 194, |
| 173772 | + /* 610 */ 194, 194, 19, 194, 60, 194, 23, 253, 206, 255, |
| 173773 | + /* 620 */ 73, 254, 19, 154, 155, 156, 72, 276, 277, 278, |
| 173774 | + /* 630 */ 263, 217, 218, 217, 218, 271, 43, 44, 45, 271, |
| 173775 | + /* 640 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 173776 | + /* 650 */ 57, 58, 183, 194, 285, 101, 19, 214, 60, 242, |
| 173777 | + /* 660 */ 23, 107, 108, 109, 117, 118, 119, 16, 254, 115, |
| 173778 | + /* 670 */ 254, 117, 118, 119, 194, 60, 122, 263, 205, 264, |
| 173779 | + /* 680 */ 43, 44, 45, 264, 47, 48, 49, 50, 51, 52, |
| 173780 | + /* 690 */ 53, 54, 55, 56, 57, 58, 103, 104, 105, 106, |
| 173781 | + /* 700 */ 107, 108, 109, 110, 111, 112, 113, 114, 154, 155, |
| 173782 | + /* 710 */ 156, 157, 158, 240, 241, 117, 118, 119, 101, 205, |
| 173783 | + /* 720 */ 117, 19, 20, 306, 22, 308, 253, 74, 255, 78, |
| 173784 | + /* 730 */ 205, 80, 117, 118, 119, 118, 293, 183, 36, 122, |
| 173785 | + /* 740 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 173786 | + /* 750 */ 113, 114, 194, 294, 240, 241, 211, 212, 213, 144, |
| 173787 | + /* 760 */ 19, 23, 60, 25, 23, 240, 241, 253, 245, 255, |
| 173788 | + /* 770 */ 15, 154, 155, 156, 72, 217, 218, 194, 253, 256, |
| 173789 | + /* 780 */ 255, 128, 129, 130, 43, 44, 45, 22, 47, 48, |
| 173790 | + /* 790 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, |
| 173791 | + /* 800 */ 183, 19, 77, 101, 19, 128, 129, 130, 23, 107, |
| 173792 | + /* 810 */ 108, 60, 254, 88, 21, 90, 61, 115, 93, 117, |
| 173793 | + /* 820 */ 118, 119, 239, 22, 122, 60, 194, 205, 43, 44, |
| 173794 | + /* 830 */ 45, 205, 47, 48, 49, 50, 51, 52, 53, 54, |
| 173795 | + /* 840 */ 55, 56, 57, 58, 103, 104, 105, 106, 107, 108, |
| 173796 | + /* 850 */ 109, 110, 111, 112, 113, 114, 154, 155, 156, 157, |
| 173797 | + /* 860 */ 158, 60, 240, 241, 60, 116, 240, 241, 117, 118, |
| 173798 | + /* 870 */ 119, 146, 194, 19, 81, 253, 275, 255, 24, 253, |
| 173799 | + /* 880 */ 98, 255, 117, 118, 119, 183, 22, 194, 103, 104, |
| 173800 | + /* 890 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 173801 | + /* 900 */ 151, 194, 270, 152, 22, 23, 194, 25, 19, 202, |
| 173802 | + /* 910 */ 217, 218, 23, 109, 207, 314, 315, 124, 117, 118, |
| 173803 | + /* 920 */ 119, 117, 118, 119, 60, 232, 22, 23, 19, 25, |
| 173804 | + /* 930 */ 303, 304, 43, 44, 45, 22, 47, 48, 49, 50, |
| 173805 | + /* 940 */ 51, 52, 53, 54, 55, 56, 57, 58, 270, 227, |
| 173806 | + /* 950 */ 96, 60, 43, 44, 45, 162, 47, 48, 49, 50, |
| 173807 | + /* 960 */ 51, 52, 53, 54, 55, 56, 57, 58, 114, 112, |
| 173808 | + /* 970 */ 113, 114, 194, 60, 120, 121, 122, 123, 124, 125, |
| 173809 | + /* 980 */ 126, 117, 118, 119, 102, 25, 132, 107, 108, 194, |
| 173810 | + /* 990 */ 194, 227, 103, 104, 105, 106, 107, 108, 109, 110, |
| 173811 | + /* 1000 */ 111, 112, 113, 114, 194, 194, 102, 194, 117, 118, |
| 173812 | + /* 1010 */ 119, 233, 103, 104, 105, 106, 107, 108, 109, 110, |
| 173813 | + /* 1020 */ 111, 112, 113, 114, 194, 194, 19, 194, 217, 218, |
| 173814 | + /* 1030 */ 117, 118, 119, 241, 154, 144, 156, 135, 242, 137, |
| 173815 | + /* 1040 */ 138, 130, 19, 232, 194, 253, 23, 255, 217, 218, |
| 173816 | + /* 1050 */ 217, 218, 242, 16, 7, 8, 9, 25, 261, 262, |
| 173817 | + /* 1060 */ 265, 194, 19, 232, 153, 232, 43, 44, 45, 160, |
| 173818 | + /* 1070 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 173819 | + /* 1080 */ 57, 58, 194, 227, 217, 218, 43, 44, 45, 194, |
| 173820 | + /* 1090 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 173821 | + /* 1100 */ 57, 58, 306, 143, 308, 217, 218, 294, 12, 77, |
| 173822 | + /* 1110 */ 22, 23, 217, 218, 194, 78, 306, 80, 308, 194, |
| 173823 | + /* 1120 */ 232, 254, 90, 27, 117, 93, 103, 104, 105, 106, |
| 173824 | + /* 1130 */ 107, 108, 109, 110, 111, 112, 113, 114, 42, 194, |
| 173825 | + /* 1140 */ 35, 194, 217, 218, 214, 194, 103, 104, 105, 106, |
| 173826 | + /* 1150 */ 107, 108, 109, 110, 111, 112, 113, 114, 194, 239, |
| 173827 | + /* 1160 */ 64, 194, 217, 218, 217, 218, 209, 210, 217, 218, |
| 173828 | + /* 1170 */ 74, 207, 67, 22, 194, 77, 19, 232, 245, 232, |
| 173829 | + /* 1180 */ 75, 24, 312, 232, 217, 218, 316, 25, 90, 256, |
| 173830 | + /* 1190 */ 102, 93, 159, 229, 161, 231, 19, 217, 218, 162, |
| 173831 | + /* 1200 */ 43, 44, 45, 160, 47, 48, 49, 50, 51, 52, |
| 173832 | + /* 1210 */ 53, 54, 55, 56, 57, 58, 19, 23, 288, 25, |
| 173833 | + /* 1220 */ 43, 44, 45, 293, 47, 48, 49, 50, 51, 52, |
| 173834 | + /* 1230 */ 53, 54, 55, 56, 57, 58, 131, 22, 275, 24, |
| 173835 | + /* 1240 */ 43, 44, 45, 194, 47, 48, 49, 50, 51, 52, |
| 173836 | + /* 1250 */ 53, 54, 55, 56, 57, 58, 194, 194, 107, 108, |
| 173837 | + /* 1260 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 173838 | + /* 1270 */ 113, 114, 194, 25, 194, 60, 194, 314, 315, 194, |
| 173839 | + /* 1280 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 173840 | + /* 1290 */ 113, 114, 19, 194, 194, 217, 218, 217, 218, 25, |
| 173841 | + /* 1300 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 173842 | + /* 1310 */ 113, 114, 150, 119, 265, 312, 67, 217, 218, 316, |
| 173843 | + /* 1320 */ 19, 239, 194, 194, 128, 129, 130, 265, 265, 209, |
| 173844 | + /* 1330 */ 210, 31, 254, 118, 254, 86, 60, 194, 144, 39, |
| 173845 | + /* 1340 */ 19, 130, 275, 312, 95, 44, 45, 316, 47, 48, |
| 173846 | + /* 1350 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, |
| 173847 | + /* 1360 */ 217, 218, 24, 194, 153, 12, 45, 119, 47, 48, |
| 173848 | + /* 1370 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, |
| 173849 | + /* 1380 */ 27, 314, 315, 22, 312, 24, 217, 218, 316, 116, |
| 173850 | + /* 1390 */ 117, 22, 144, 25, 118, 42, 147, 194, 60, 19, |
| 173851 | + /* 1400 */ 20, 127, 22, 194, 103, 104, 105, 106, 107, 108, |
| 173852 | + /* 1410 */ 109, 110, 111, 112, 113, 114, 36, 64, 145, 194, |
| 173853 | + /* 1420 */ 217, 218, 194, 54, 103, 104, 105, 106, 107, 108, |
| 173854 | + /* 1430 */ 109, 110, 111, 112, 113, 114, 194, 22, 310, 25, |
| 173855 | + /* 1440 */ 60, 194, 217, 218, 194, 217, 218, 194, 260, 194, |
| 173856 | + /* 1450 */ 301, 302, 72, 262, 262, 194, 118, 266, 266, 217, |
| 173857 | + /* 1460 */ 218, 194, 82, 245, 217, 218, 194, 217, 218, 194, |
| 173858 | + /* 1470 */ 217, 218, 217, 218, 256, 60, 24, 194, 217, 218, |
| 173859 | + /* 1480 */ 194, 101, 194, 245, 217, 218, 194, 107, 108, 217, |
| 173860 | + /* 1490 */ 218, 22, 217, 218, 256, 115, 245, 117, 118, 119, |
| 173861 | + /* 1500 */ 217, 218, 122, 217, 218, 217, 218, 256, 22, 217, |
| 173862 | + /* 1510 */ 218, 116, 258, 259, 146, 19, 20, 194, 22, 139, |
| 173863 | + /* 1520 */ 140, 150, 151, 136, 23, 194, 25, 194, 141, 194, |
| 173864 | + /* 1530 */ 194, 62, 36, 118, 154, 155, 156, 157, 158, 100, |
| 173865 | + /* 1540 */ 145, 194, 154, 194, 156, 49, 194, 23, 194, 25, |
| 173866 | + /* 1550 */ 217, 218, 217, 218, 194, 257, 60, 143, 194, 60, |
| 173867 | + /* 1560 */ 194, 121, 122, 183, 217, 218, 217, 218, 72, 217, |
| 173868 | + /* 1570 */ 218, 217, 218, 134, 23, 194, 25, 217, 218, 7, |
| 173869 | + /* 1580 */ 8, 321, 86, 217, 218, 194, 122, 91, 19, 20, |
| 173870 | + /* 1590 */ 23, 22, 25, 23, 142, 25, 132, 101, 217, 218, |
| 173871 | + /* 1600 */ 194, 194, 194, 107, 108, 36, 194, 194, 217, 218, |
| 173872 | + /* 1610 */ 194, 115, 194, 117, 118, 119, 194, 118, 122, 194, |
| 173873 | + /* 1620 */ 23, 194, 25, 217, 218, 217, 218, 194, 142, 60, |
| 173874 | + /* 1630 */ 217, 218, 194, 217, 218, 217, 218, 84, 85, 217, |
| 173875 | + /* 1640 */ 218, 72, 217, 218, 217, 218, 60, 23, 60, 25, |
| 173876 | + /* 1650 */ 154, 155, 156, 157, 158, 86, 154, 194, 156, 194, |
| 173877 | + /* 1660 */ 91, 19, 20, 23, 22, 25, 194, 23, 194, 25, |
| 173878 | + /* 1670 */ 101, 23, 194, 25, 194, 194, 107, 108, 36, 183, |
| 173879 | + /* 1680 */ 217, 218, 217, 218, 115, 194, 117, 118, 119, 217, |
| 173880 | + /* 1690 */ 218, 122, 194, 237, 194, 217, 218, 217, 218, 194, |
| 173881 | + /* 1700 */ 194, 23, 60, 25, 118, 23, 118, 25, 217, 218, |
| 173882 | + /* 1710 */ 23, 194, 25, 194, 72, 217, 218, 217, 218, 23, |
| 173883 | + /* 1720 */ 194, 25, 194, 154, 155, 156, 157, 158, 86, 23, |
| 173884 | + /* 1730 */ 194, 25, 194, 91, 217, 218, 217, 218, 194, 194, |
| 173885 | + /* 1740 */ 194, 194, 194, 101, 194, 217, 218, 290, 194, 107, |
| 173886 | + /* 1750 */ 108, 194, 183, 217, 218, 194, 194, 115, 194, 117, |
| 173887 | + /* 1760 */ 118, 119, 194, 243, 122, 194, 289, 194, 194, 194, |
| 173888 | + /* 1770 */ 194, 257, 257, 257, 244, 257, 192, 273, 215, 269, |
| 173889 | + /* 1780 */ 246, 299, 269, 295, 247, 273, 247, 246, 295, 230, |
| 173890 | + /* 1790 */ 261, 226, 261, 261, 273, 273, 154, 155, 156, 157, |
| 173891 | + /* 1800 */ 158, 0, 1, 2, 221, 220, 5, 220, 250, 220, |
| 173892 | + /* 1810 */ 261, 10, 11, 12, 13, 14, 250, 282, 17, 197, |
| 173893 | + /* 1820 */ 61, 19, 20, 246, 22, 183, 244, 142, 201, 201, |
| 173894 | + /* 1830 */ 38, 30, 299, 32, 201, 152, 22, 151, 36, 299, |
| 173895 | + /* 1840 */ 43, 40, 235, 18, 238, 285, 238, 238, 296, 238, |
| 173896 | + /* 1850 */ 201, 296, 274, 272, 18, 200, 235, 150, 235, 247, |
| 173897 | + /* 1860 */ 247, 247, 60, 247, 274, 274, 272, 201, 200, 159, |
| 173898 | + /* 1870 */ 63, 292, 71, 201, 72, 200, 22, 201, 222, 200, |
| 173899 | + /* 1880 */ 79, 201, 222, 82, 291, 116, 219, 65, 200, 219, |
| 173900 | + /* 1890 */ 219, 228, 22, 127, 225, 166, 222, 24, 225, 114, |
| 173901 | + /* 1900 */ 99, 284, 221, 101, 284, 228, 307, 315, 219, 107, |
| 173902 | + /* 1910 */ 108, 219, 219, 219, 201, 92, 320, 115, 320, 117, |
| 173903 | + /* 1920 */ 118, 119, 222, 83, 122, 267, 267, 149, 146, 19, |
| 173904 | + /* 1930 */ 20, 22, 22, 279, 250, 134, 201, 148, 159, 249, |
| 173905 | + /* 1940 */ 139, 140, 251, 141, 25, 281, 36, 147, 251, 248, |
| 173906 | + /* 1950 */ 247, 203, 13, 195, 6, 195, 154, 155, 156, 157, |
| 173907 | + /* 1960 */ 158, 193, 305, 193, 163, 193, 305, 302, 214, 208, |
| 173908 | + /* 1970 */ 60, 214, 208, 223, 223, 4, 214, 214, 3, 22, |
| 173909 | + /* 1980 */ 215, 214, 72, 208, 164, 183, 215, 15, 23, 16, |
| 173910 | + /* 1990 */ 23, 140, 131, 152, 25, 143, 20, 16, 24, 1, |
| 173911 | + /* 2000 */ 145, 143, 131, 131, 62, 37, 54, 54, 152, 54, |
| 173912 | + /* 2010 */ 54, 101, 131, 117, 34, 1, 142, 107, 108, 22, |
| 173913 | + /* 2020 */ 5, 116, 162, 69, 25, 115, 76, 117, 118, 119, |
| 173914 | + /* 2030 */ 1, 2, 122, 69, 5, 41, 142, 116, 20, 10, |
| 173915 | + /* 2040 */ 11, 12, 13, 14, 24, 19, 17, 132, 5, 126, |
| 173916 | + /* 2050 */ 22, 141, 68, 10, 11, 12, 13, 14, 22, 30, |
| 173917 | + /* 2060 */ 17, 32, 22, 22, 154, 155, 156, 157, 158, 40, |
| 173918 | + /* 2070 */ 23, 68, 60, 30, 24, 32, 97, 28, 22, 68, |
| 173919 | + /* 2080 */ 23, 37, 34, 40, 150, 22, 25, 23, 23, 23, |
| 173920 | + /* 2090 */ 22, 98, 23, 183, 23, 117, 34, 22, 25, 89, |
| 173921 | + /* 2100 */ 71, 142, 144, 76, 34, 23, 34, 76, 79, 87, |
| 173922 | + /* 2110 */ 34, 82, 34, 94, 71, 34, 22, 24, 44, 34, |
| 173923 | + /* 2120 */ 25, 25, 79, 23, 23, 82, 143, 23, 99, 143, |
| 173924 | + /* 2130 */ 23, 22, 11, 25, 23, 25, 22, 22, 22, 1, |
| 173925 | + /* 2140 */ 23, 23, 99, 136, 22, 22, 142, 142, 142, 25, |
| 173926 | + /* 2150 */ 25, 23, 15, 1, 322, 322, 322, 322, 322, 322, |
| 173927 | + /* 2160 */ 322, 322, 322, 134, 322, 322, 322, 322, 139, 140, |
| 173928 | + /* 2170 */ 322, 322, 322, 322, 322, 322, 322, 134, 322, 322, |
| 173929 | + /* 2180 */ 322, 322, 139, 140, 322, 322, 322, 322, 322, 322, |
| 173930 | + /* 2190 */ 322, 322, 163, 322, 322, 322, 322, 322, 322, 322, |
| 173931 | + /* 2200 */ 322, 322, 322, 322, 322, 322, 163, 322, 322, 322, |
| 173058 | 173932 | /* 2210 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173059 | 173933 | /* 2220 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173060 | 173934 | /* 2230 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173061 | 173935 | /* 2240 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173062 | 173936 | /* 2250 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| | @@ -173064,181 +173938,188 @@ |
| 173064 | 173938 | /* 2270 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173065 | 173939 | /* 2280 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173066 | 173940 | /* 2290 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173067 | 173941 | /* 2300 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173068 | 173942 | /* 2310 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173069 | | - /* 2320 */ 322, 322, 322, 322, 322, 322, 322, 322, |
| 173943 | + /* 2320 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173944 | + /* 2330 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, |
| 173945 | + /* 2340 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, |
| 173946 | + /* 2350 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, |
| 173947 | + /* 2360 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, |
| 173948 | + /* 2370 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, |
| 173949 | + /* 2380 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, |
| 173950 | + /* 2390 */ 186, 186, 186, |
| 173070 | 173951 | }; |
| 173071 | 173952 | #define YY_SHIFT_COUNT (582) |
| 173072 | 173953 | #define YY_SHIFT_MIN (0) |
| 173073 | | -#define YY_SHIFT_MAX (2128) |
| 173954 | +#define YY_SHIFT_MAX (2152) |
| 173074 | 173955 | static const unsigned short int yy_shift_ofst[] = { |
| 173075 | | - /* 0 */ 1792, 1588, 1494, 322, 322, 399, 306, 1319, 1339, 1430, |
| 173076 | | - /* 10 */ 1828, 1828, 1828, 580, 399, 399, 399, 399, 399, 0, |
| 173077 | | - /* 20 */ 0, 214, 1093, 1828, 1828, 1828, 1828, 1828, 1828, 1828, |
| 173078 | | - /* 30 */ 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1130, 1130, |
| 173079 | | - /* 40 */ 365, 365, 55, 278, 436, 713, 713, 201, 201, 201, |
| 173080 | | - /* 50 */ 201, 40, 111, 258, 361, 469, 512, 583, 622, 693, |
| 173081 | | - /* 60 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, |
| 173082 | | - /* 70 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, |
| 173083 | | - /* 80 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1523, 1602, |
| 173084 | | - /* 90 */ 1674, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, |
| 173085 | | - /* 100 */ 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, |
| 173086 | | - /* 110 */ 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, |
| 173087 | | - /* 120 */ 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, |
| 173088 | | - /* 130 */ 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, |
| 173089 | | - /* 140 */ 137, 181, 181, 181, 181, 181, 181, 181, 96, 222, |
| 173090 | | - /* 150 */ 143, 477, 713, 1133, 1268, 713, 713, 79, 79, 713, |
| 173091 | | - /* 160 */ 770, 83, 65, 65, 65, 288, 162, 162, 2142, 2142, |
| 173092 | | - /* 170 */ 696, 696, 696, 238, 474, 474, 474, 474, 1217, 1217, |
| 173093 | | - /* 180 */ 678, 477, 324, 398, 713, 713, 713, 713, 713, 713, |
| 173094 | | - /* 190 */ 713, 713, 713, 713, 713, 713, 713, 713, 713, 713, |
| 173095 | | - /* 200 */ 713, 713, 713, 1220, 366, 366, 713, 917, 283, 283, |
| 173096 | | - /* 210 */ 434, 434, 605, 605, 1298, 2142, 2142, 2142, 2142, 2142, |
| 173097 | | - /* 220 */ 2142, 2142, 1179, 1157, 1157, 487, 527, 585, 645, 749, |
| 173098 | | - /* 230 */ 914, 968, 752, 713, 713, 713, 713, 713, 713, 713, |
| 173099 | | - /* 240 */ 713, 713, 713, 303, 713, 713, 713, 713, 713, 713, |
| 173100 | | - /* 250 */ 713, 713, 713, 713, 713, 713, 797, 797, 797, 713, |
| 173101 | | - /* 260 */ 713, 713, 959, 713, 713, 713, 1169, 1271, 713, 713, |
| 173102 | | - /* 270 */ 1330, 713, 713, 713, 713, 713, 713, 713, 713, 629, |
| 173103 | | - /* 280 */ 7, 91, 876, 876, 876, 876, 953, 91, 91, 1246, |
| 173104 | | - /* 290 */ 1065, 1106, 1374, 1329, 1348, 468, 1348, 1394, 785, 1329, |
| 173105 | | - /* 300 */ 1329, 785, 1329, 468, 1394, 859, 854, 1402, 1449, 1449, |
| 173106 | | - /* 310 */ 1449, 1173, 1173, 1173, 1173, 1355, 1355, 1030, 1341, 405, |
| 173107 | | - /* 320 */ 1230, 1795, 1795, 1711, 1711, 1829, 1829, 1711, 1717, 1719, |
| 173108 | | - /* 330 */ 1850, 1833, 1860, 1860, 1860, 1860, 1711, 1868, 1740, 1719, |
| 173109 | | - /* 340 */ 1719, 1740, 1850, 1833, 1740, 1833, 1740, 1711, 1868, 1745, |
| 173110 | | - /* 350 */ 1843, 1711, 1868, 1887, 1711, 1868, 1711, 1868, 1887, 1801, |
| 173111 | | - /* 360 */ 1801, 1801, 1855, 1900, 1900, 1887, 1801, 1797, 1801, 1855, |
| 173112 | | - /* 370 */ 1801, 1801, 1761, 1912, 1830, 1830, 1887, 1711, 1862, 1862, |
| 173113 | | - /* 380 */ 1875, 1875, 1810, 1815, 1940, 1711, 1807, 1810, 1821, 1823, |
| 173114 | | - /* 390 */ 1740, 1945, 1963, 1963, 1974, 1974, 1974, 2142, 2142, 2142, |
| 173115 | | - /* 400 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, |
| 173116 | | - /* 410 */ 2142, 2142, 20, 1224, 256, 1111, 1115, 1114, 1192, 1496, |
| 173117 | | - /* 420 */ 1424, 1505, 1427, 355, 1383, 1537, 1506, 1538, 1553, 1583, |
| 173118 | | - /* 430 */ 1584, 1591, 1625, 541, 1445, 1562, 1450, 1572, 1515, 1428, |
| 173119 | | - /* 440 */ 1532, 1592, 1629, 1520, 1630, 1639, 1510, 1544, 1662, 1675, |
| 173120 | | - /* 450 */ 1551, 48, 1996, 2001, 1983, 1844, 1993, 1994, 1986, 1989, |
| 173121 | | - /* 460 */ 1874, 1863, 1885, 1991, 1991, 1995, 1876, 1997, 1877, 2004, |
| 173122 | | - /* 470 */ 2021, 1881, 1894, 1991, 1895, 1965, 1990, 1991, 1878, 1975, |
| 173123 | | - /* 480 */ 1977, 1978, 1979, 1903, 1918, 2002, 1896, 2034, 2033, 2017, |
| 173124 | | - /* 490 */ 1925, 1880, 1976, 2018, 1980, 1967, 2005, 1904, 1932, 2025, |
| 173125 | | - /* 500 */ 2030, 2032, 1921, 1928, 2035, 1987, 2036, 2037, 2038, 2040, |
| 173126 | | - /* 510 */ 1988, 2006, 2039, 1960, 2041, 2042, 1999, 2023, 2044, 2043, |
| 173127 | | - /* 520 */ 1919, 2048, 2049, 2050, 2046, 2051, 2053, 1981, 1935, 2056, |
| 173128 | | - /* 530 */ 2057, 1966, 2047, 2061, 1941, 2060, 2052, 2054, 2055, 2058, |
| 173129 | | - /* 540 */ 2003, 2012, 2007, 2059, 2015, 2008, 2062, 2071, 2073, 2074, |
| 173130 | | - /* 550 */ 2072, 2075, 2065, 1962, 1964, 2079, 2060, 2082, 2084, 2085, |
| 173131 | | - /* 560 */ 2087, 2086, 2089, 2088, 2091, 2093, 2099, 2094, 2095, 2096, |
| 173132 | | - /* 570 */ 2097, 2100, 2101, 2102, 1998, 1984, 1985, 2000, 2103, 2098, |
| 173133 | | - /* 580 */ 2109, 2117, 2128, |
| 173134 | | -}; |
| 173135 | | -#define YY_REDUCE_COUNT (411) |
| 173136 | | -#define YY_REDUCE_MIN (-275) |
| 173137 | | -#define YY_REDUCE_MAX (1798) |
| 173956 | + /* 0 */ 2029, 1801, 2043, 1380, 1380, 33, 391, 1496, 1569, 1642, |
| 173957 | + /* 10 */ 702, 702, 702, 193, 33, 33, 33, 33, 33, 0, |
| 173958 | + /* 20 */ 0, 216, 1177, 702, 702, 702, 702, 702, 702, 702, |
| 173959 | + /* 30 */ 702, 702, 702, 702, 702, 702, 702, 702, 406, 406, |
| 173960 | + /* 40 */ 111, 111, 218, 447, 547, 598, 598, 260, 260, 260, |
| 173961 | + /* 50 */ 260, 40, 112, 320, 340, 445, 489, 593, 637, 741, |
| 173962 | + /* 60 */ 785, 889, 909, 1023, 1043, 1157, 1177, 1177, 1177, 1177, |
| 173963 | + /* 70 */ 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, |
| 173964 | + /* 80 */ 1177, 1177, 1177, 1177, 1197, 1177, 1301, 1321, 1321, 554, |
| 173965 | + /* 90 */ 1802, 1910, 702, 702, 702, 702, 702, 702, 702, 702, |
| 173966 | + /* 100 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702, |
| 173967 | + /* 110 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702, |
| 173968 | + /* 120 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702, |
| 173969 | + /* 130 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702, |
| 173970 | + /* 140 */ 702, 702, 138, 198, 198, 198, 198, 198, 198, 198, |
| 173971 | + /* 150 */ 183, 99, 236, 292, 598, 793, 167, 598, 598, 880, |
| 173972 | + /* 160 */ 880, 598, 857, 150, 195, 195, 195, 264, 113, 113, |
| 173973 | + /* 170 */ 2207, 2207, 854, 854, 854, 751, 765, 765, 765, 765, |
| 173974 | + /* 180 */ 1096, 1096, 725, 292, 882, 904, 598, 598, 598, 598, |
| 173975 | + /* 190 */ 598, 598, 598, 598, 598, 598, 598, 598, 598, 598, |
| 173976 | + /* 200 */ 598, 598, 598, 598, 598, 1273, 1032, 1032, 598, 147, |
| 173977 | + /* 210 */ 1098, 1098, 603, 603, 1276, 1276, 363, 2207, 2207, 2207, |
| 173978 | + /* 220 */ 2207, 2207, 2207, 2207, 469, 617, 617, 801, 336, 461, |
| 173979 | + /* 230 */ 804, 864, 615, 891, 913, 598, 598, 598, 598, 598, |
| 173980 | + /* 240 */ 598, 598, 598, 598, 598, 653, 598, 598, 598, 598, |
| 173981 | + /* 250 */ 598, 598, 598, 598, 598, 598, 598, 598, 1105, 1105, |
| 173982 | + /* 260 */ 1105, 598, 598, 598, 1194, 598, 598, 598, 1215, 1249, |
| 173983 | + /* 270 */ 598, 1353, 598, 598, 598, 598, 598, 598, 598, 598, |
| 173984 | + /* 280 */ 677, 449, 902, 1338, 1338, 1338, 1338, 1248, 902, 902, |
| 173985 | + /* 290 */ 326, 1151, 1047, 755, 749, 1371, 960, 1371, 1007, 1162, |
| 173986 | + /* 300 */ 749, 749, 1162, 749, 960, 1007, 1274, 738, 215, 1300, |
| 173987 | + /* 310 */ 1300, 1300, 1395, 1395, 1395, 1395, 1368, 1368, 1033, 1414, |
| 173988 | + /* 320 */ 1387, 1361, 1759, 1759, 1685, 1685, 1792, 1792, 1685, 1683, |
| 173989 | + /* 330 */ 1686, 1814, 1797, 1825, 1825, 1825, 1825, 1685, 1836, 1707, |
| 173990 | + /* 340 */ 1686, 1686, 1707, 1814, 1797, 1707, 1797, 1707, 1685, 1836, |
| 173991 | + /* 350 */ 1710, 1807, 1685, 1836, 1854, 1685, 1836, 1685, 1836, 1854, |
| 173992 | + /* 360 */ 1769, 1769, 1769, 1822, 1870, 1870, 1854, 1769, 1766, 1769, |
| 173993 | + /* 370 */ 1822, 1769, 1769, 1729, 1873, 1785, 1785, 1854, 1685, 1823, |
| 173994 | + /* 380 */ 1823, 1840, 1840, 1778, 1782, 1909, 1685, 1779, 1778, 1789, |
| 173995 | + /* 390 */ 1800, 1707, 1919, 1939, 1939, 1948, 1948, 1948, 2207, 2207, |
| 173996 | + /* 400 */ 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, |
| 173997 | + /* 410 */ 2207, 2207, 2207, 69, 1037, 79, 1088, 651, 1196, 1415, |
| 173998 | + /* 420 */ 1501, 1439, 1369, 1452, 911, 1211, 1524, 1469, 1551, 1567, |
| 173999 | + /* 430 */ 1570, 1624, 1640, 1644, 1499, 1440, 1572, 1464, 1597, 275, |
| 174000 | + /* 440 */ 782, 1586, 1648, 1678, 1553, 1682, 1687, 1388, 1502, 1696, |
| 174001 | + /* 450 */ 1706, 1588, 1486, 1971, 1975, 1957, 1820, 1972, 1973, 1965, |
| 174002 | + /* 460 */ 1967, 1851, 1841, 1861, 1969, 1969, 1974, 1852, 1976, 1855, |
| 174003 | + /* 470 */ 1981, 1998, 1858, 1871, 1969, 1872, 1942, 1968, 1969, 1856, |
| 174004 | + /* 480 */ 1952, 1953, 1955, 1956, 1881, 1896, 1980, 1874, 2014, 2015, |
| 174005 | + /* 490 */ 1997, 1905, 1860, 1954, 1999, 1964, 1950, 1994, 1894, 1921, |
| 174006 | + /* 500 */ 2020, 2018, 2026, 1915, 1923, 2028, 1984, 2036, 2040, 2047, |
| 174007 | + /* 510 */ 2041, 2003, 2012, 2050, 1979, 2049, 2056, 2011, 2044, 2057, |
| 174008 | + /* 520 */ 2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1959, |
| 174009 | + /* 530 */ 2069, 2071, 1978, 2062, 2075, 1958, 2073, 2070, 2072, 2076, |
| 174010 | + /* 540 */ 2078, 2010, 2027, 2022, 2074, 2031, 2019, 2081, 2082, 2094, |
| 174011 | + /* 550 */ 2093, 2095, 2096, 2085, 1983, 1986, 2100, 2073, 2101, 2104, |
| 174012 | + /* 560 */ 2107, 2109, 2108, 2110, 2111, 2114, 2121, 2115, 2116, 2117, |
| 174013 | + /* 570 */ 2118, 2122, 2123, 2124, 2007, 2004, 2005, 2006, 2125, 2128, |
| 174014 | + /* 580 */ 2137, 2138, 2152, |
| 174015 | +}; |
| 174016 | +#define YY_REDUCE_COUNT (412) |
| 174017 | +#define YY_REDUCE_MIN (-276) |
| 174018 | +#define YY_REDUCE_MAX (1775) |
| 173138 | 174019 | static const short yy_reduce_ofst[] = { |
| 173139 | | - /* 0 */ -71, 194, 343, 835, -180, -177, 838, -194, -188, -185, |
| 173140 | | - /* 10 */ -183, 82, 183, -65, 133, 245, 346, 407, 458, -178, |
| 173141 | | - /* 20 */ 75, -275, -4, 310, 312, 489, 575, 596, 463, 686, |
| 173142 | | - /* 30 */ 707, 725, 780, 1098, 856, 778, 1059, 1090, 708, 887, |
| 173143 | | - /* 40 */ 86, 448, 980, 630, 680, 681, 684, 796, 801, 796, |
| 173144 | | - /* 50 */ 801, -261, -261, -261, -261, -261, -261, -261, -261, -261, |
| 173145 | | - /* 60 */ -261, -261, -261, -261, -261, -261, -261, -261, -261, -261, |
| 173146 | | - /* 70 */ -261, -261, -261, -261, -261, -261, -261, -261, -261, -261, |
| 173147 | | - /* 80 */ -261, -261, -261, -261, -261, -261, -261, -261, 391, 886, |
| 173148 | | - /* 90 */ 888, 1013, 1016, 1081, 1087, 1151, 1159, 1177, 1185, 1188, |
| 173149 | | - /* 100 */ 1190, 1194, 1197, 1203, 1247, 1260, 1264, 1267, 1269, 1273, |
| 173150 | | - /* 110 */ 1315, 1322, 1335, 1337, 1356, 1362, 1418, 1425, 1453, 1457, |
| 173151 | | - /* 120 */ 1465, 1473, 1487, 1495, 1507, 1517, 1521, 1534, 1543, 1546, |
| 173152 | | - /* 130 */ 1549, 1552, 1554, 1560, 1581, 1590, 1593, 1595, 1621, 1623, |
| 173153 | | - /* 140 */ -261, -261, -261, -261, -261, -261, -261, -261, -261, -261, |
| 173154 | | - /* 150 */ -261, -186, -117, 260, 263, 460, 631, -74, 497, -181, |
| 173155 | | - /* 160 */ -261, 939, 176, 274, 338, 676, -261, -261, -261, -261, |
| 173156 | | - /* 170 */ -212, -212, -212, -184, 149, 777, 1061, 1103, 265, 419, |
| 173157 | | - /* 180 */ -254, 670, 677, 677, -11, -129, 184, 488, 736, 789, |
| 173158 | | - /* 190 */ 805, 844, 403, 529, 579, 668, 783, 841, 1158, 1112, |
| 173159 | | - /* 200 */ 806, 861, 1095, 846, 839, 1031, -189, 1077, 1080, 1116, |
| 173160 | | - /* 210 */ 1084, 1156, 1139, 1221, 46, 1099, 1037, 1118, 1171, 1214, |
| 173161 | | - /* 220 */ 1210, 1258, -210, -190, -176, -115, 117, 262, 376, 490, |
| 173162 | | - /* 230 */ 511, 520, 618, 639, 743, 901, 907, 958, 1014, 1055, |
| 173163 | | - /* 240 */ 1108, 1193, 1244, 720, 1248, 1277, 1324, 1347, 1417, 1431, |
| 173164 | | - /* 250 */ 1432, 1440, 1451, 1452, 1463, 1478, 1286, 1350, 1369, 1490, |
| 173165 | | - /* 260 */ 1498, 1501, 773, 1509, 1513, 1528, 1292, 1367, 1535, 1536, |
| 173166 | | - /* 270 */ 1477, 1542, 376, 1547, 1550, 1555, 1559, 1568, 1571, 1441, |
| 173167 | | - /* 280 */ 1443, 1474, 1511, 1516, 1519, 1522, 773, 1474, 1474, 1503, |
| 173168 | | - /* 290 */ 1567, 1594, 1484, 1527, 1556, 1570, 1557, 1524, 1573, 1545, |
| 173169 | | - /* 300 */ 1548, 1576, 1561, 1587, 1540, 1575, 1606, 1611, 1622, 1624, |
| 173170 | | - /* 310 */ 1626, 1582, 1597, 1598, 1599, 1601, 1603, 1563, 1608, 1605, |
| 173171 | | - /* 320 */ 1604, 1564, 1566, 1655, 1660, 1578, 1579, 1665, 1586, 1607, |
| 173172 | | - /* 330 */ 1610, 1642, 1641, 1645, 1646, 1647, 1679, 1688, 1644, 1618, |
| 173173 | | - /* 340 */ 1619, 1648, 1628, 1659, 1649, 1663, 1650, 1700, 1702, 1612, |
| 173174 | | - /* 350 */ 1615, 1706, 1708, 1689, 1709, 1712, 1713, 1715, 1691, 1698, |
| 173175 | | - /* 360 */ 1699, 1701, 1693, 1704, 1707, 1705, 1714, 1703, 1718, 1710, |
| 173176 | | - /* 370 */ 1720, 1721, 1632, 1634, 1664, 1666, 1729, 1751, 1635, 1636, |
| 173177 | | - /* 380 */ 1692, 1694, 1716, 1722, 1684, 1763, 1685, 1723, 1724, 1727, |
| 173178 | | - /* 390 */ 1730, 1768, 1783, 1784, 1793, 1794, 1796, 1683, 1686, 1690, |
| 173179 | | - /* 400 */ 1782, 1779, 1780, 1781, 1785, 1788, 1774, 1775, 1786, 1787, |
| 173180 | | - /* 410 */ 1789, 1798, |
| 174020 | + /* 0 */ -66, 217, -63, -177, -180, 161, 364, 64, -183, 162, |
| 174021 | + /* 10 */ 223, 367, 414, -173, 473, 514, 525, 622, 626, -207, |
| 174022 | + /* 20 */ 351, -276, -38, 693, 811, 831, 833, 888, -188, 945, |
| 174023 | + /* 30 */ 947, 416, 558, 951, 867, 287, 1078, 1080, -186, 224, |
| 174024 | + /* 40 */ -132, 42, 964, 269, 417, 796, 810, -237, -231, -237, |
| 174025 | + /* 50 */ -231, -45, -45, -45, -45, -45, -45, -45, -45, -45, |
| 174026 | + /* 60 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, |
| 174027 | + /* 70 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, |
| 174028 | + /* 80 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, 895, |
| 174029 | + /* 90 */ 925, 967, 980, 1100, 1143, 1169, 1203, 1225, 1228, 1242, |
| 174030 | + /* 100 */ 1247, 1250, 1253, 1255, 1261, 1267, 1272, 1275, 1283, 1286, |
| 174031 | + /* 110 */ 1288, 1292, 1333, 1335, 1347, 1349, 1352, 1354, 1360, 1366, |
| 174032 | + /* 120 */ 1381, 1391, 1406, 1408, 1413, 1416, 1418, 1422, 1425, 1427, |
| 174033 | + /* 130 */ 1463, 1465, 1472, 1478, 1480, 1491, 1498, 1500, 1517, 1519, |
| 174034 | + /* 140 */ 1528, 1536, -45, -45, -45, -45, -45, -45, -45, -45, |
| 174035 | + /* 150 */ -45, -45, -45, 312, -158, 285, -219, 9, 166, 370, |
| 174036 | + /* 160 */ 545, 707, -45, 930, 601, 963, 1067, 792, -45, -45, |
| 174037 | + /* 170 */ -45, -45, -204, -204, -204, 369, -171, -129, 632, 678, |
| 174038 | + /* 180 */ 202, 352, -270, 412, 627, 627, -9, 122, 415, 419, |
| 174039 | + /* 190 */ -56, 248, 583, 920, 6, 261, 459, 795, 1049, 813, |
| 174040 | + /* 200 */ 1062, 1082, -161, 778, 1063, 797, 870, 1003, 1128, 443, |
| 174041 | + /* 210 */ 1031, 1072, 1191, 1192, 957, 1120, 105, 1149, 523, 933, |
| 174042 | + /* 220 */ 1218, 1238, 1254, 1251, -138, 96, 117, 146, 181, 277, |
| 174043 | + /* 230 */ 280, 421, 480, 712, 830, 850, 1085, 1099, 1129, 1209, |
| 174044 | + /* 240 */ 1323, 1331, 1336, 1364, 1407, 368, 1412, 1433, 1438, 1474, |
| 174045 | + /* 250 */ 1481, 1505, 1506, 1526, 1538, 1544, 1545, 1546, 722, 764, |
| 174046 | + /* 260 */ 856, 1547, 1548, 1550, 1188, 1554, 1557, 1561, 1298, 1260, |
| 174047 | + /* 270 */ 1562, 1456, 1564, 280, 1568, 1571, 1573, 1574, 1575, 1576, |
| 174048 | + /* 280 */ 1457, 1477, 1520, 1514, 1515, 1516, 1518, 1188, 1520, 1520, |
| 174049 | + /* 290 */ 1530, 1563, 1584, 1482, 1504, 1510, 1534, 1513, 1488, 1537, |
| 174050 | + /* 300 */ 1512, 1521, 1539, 1522, 1541, 1493, 1583, 1559, 1565, 1585, |
| 174051 | + /* 310 */ 1587, 1589, 1529, 1531, 1532, 1549, 1558, 1566, 1535, 1577, |
| 174052 | + /* 320 */ 1582, 1622, 1533, 1540, 1627, 1628, 1552, 1555, 1633, 1560, |
| 174053 | + /* 330 */ 1578, 1581, 1607, 1606, 1608, 1609, 1611, 1649, 1655, 1612, |
| 174054 | + /* 340 */ 1590, 1591, 1613, 1594, 1621, 1614, 1623, 1616, 1666, 1668, |
| 174055 | + /* 350 */ 1579, 1593, 1672, 1675, 1656, 1676, 1679, 1680, 1688, 1660, |
| 174056 | + /* 360 */ 1667, 1670, 1671, 1663, 1669, 1673, 1674, 1689, 1681, 1692, |
| 174057 | + /* 370 */ 1677, 1693, 1694, 1592, 1599, 1617, 1620, 1700, 1713, 1596, |
| 174058 | + /* 380 */ 1598, 1658, 1659, 1691, 1684, 1654, 1735, 1664, 1697, 1690, |
| 174059 | + /* 390 */ 1701, 1703, 1748, 1758, 1760, 1768, 1770, 1772, 1657, 1661, |
| 174060 | + /* 400 */ 1665, 1761, 1754, 1757, 1762, 1763, 1764, 1750, 1751, 1765, |
| 174061 | + /* 410 */ 1771, 1767, 1775, |
| 173181 | 174062 | }; |
| 173182 | 174063 | static const YYACTIONTYPE yy_default[] = { |
| 173183 | 174064 | /* 0 */ 1663, 1663, 1663, 1491, 1254, 1367, 1254, 1254, 1254, 1254, |
| 173184 | 174065 | /* 10 */ 1491, 1491, 1491, 1254, 1254, 1254, 1254, 1254, 1254, 1397, |
| 173185 | 174066 | /* 20 */ 1397, 1544, 1287, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173186 | 174067 | /* 30 */ 1254, 1254, 1254, 1254, 1254, 1490, 1254, 1254, 1254, 1254, |
| 173187 | 174068 | /* 40 */ 1578, 1578, 1254, 1254, 1254, 1254, 1254, 1563, 1562, 1254, |
| 173188 | 174069 | /* 50 */ 1254, 1254, 1406, 1254, 1413, 1254, 1254, 1254, 1254, 1254, |
| 173189 | | - /* 60 */ 1492, 1493, 1254, 1254, 1254, 1543, 1545, 1508, 1420, 1419, |
| 173190 | | - /* 70 */ 1418, 1417, 1526, 1385, 1411, 1404, 1408, 1487, 1488, 1486, |
| 173191 | | - /* 80 */ 1641, 1493, 1492, 1254, 1407, 1455, 1471, 1454, 1254, 1254, |
| 174070 | + /* 60 */ 1492, 1493, 1254, 1254, 1254, 1254, 1543, 1545, 1508, 1420, |
| 174071 | + /* 70 */ 1419, 1418, 1417, 1526, 1385, 1411, 1404, 1408, 1487, 1488, |
| 174072 | + /* 80 */ 1486, 1641, 1493, 1492, 1254, 1407, 1455, 1471, 1454, 1254, |
| 173192 | 174073 | /* 90 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173193 | 174074 | /* 100 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173194 | 174075 | /* 110 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173195 | 174076 | /* 120 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173196 | 174077 | /* 130 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173197 | | - /* 140 */ 1463, 1470, 1469, 1468, 1477, 1467, 1464, 1457, 1456, 1458, |
| 173198 | | - /* 150 */ 1459, 1278, 1254, 1275, 1329, 1254, 1254, 1254, 1254, 1254, |
| 173199 | | - /* 160 */ 1460, 1287, 1448, 1447, 1446, 1254, 1474, 1461, 1473, 1472, |
| 173200 | | - /* 170 */ 1551, 1615, 1614, 1509, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173201 | | - /* 180 */ 1578, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174078 | + /* 140 */ 1254, 1254, 1463, 1470, 1469, 1468, 1477, 1467, 1464, 1457, |
| 174079 | + /* 150 */ 1456, 1458, 1459, 1278, 1254, 1275, 1329, 1254, 1254, 1254, |
| 174080 | + /* 160 */ 1254, 1254, 1460, 1287, 1448, 1447, 1446, 1254, 1474, 1461, |
| 174081 | + /* 170 */ 1473, 1472, 1551, 1615, 1614, 1509, 1254, 1254, 1254, 1254, |
| 174082 | + /* 180 */ 1254, 1254, 1578, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173202 | 174083 | /* 190 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173203 | | - /* 200 */ 1254, 1254, 1254, 1387, 1578, 1578, 1254, 1287, 1578, 1578, |
| 173204 | | - /* 210 */ 1388, 1388, 1283, 1283, 1391, 1558, 1358, 1358, 1358, 1358, |
| 173205 | | - /* 220 */ 1367, 1358, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173206 | | - /* 230 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1548, 1546, 1254, |
| 173207 | | - /* 240 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174084 | + /* 200 */ 1254, 1254, 1254, 1254, 1254, 1387, 1578, 1578, 1254, 1287, |
| 174085 | + /* 210 */ 1578, 1578, 1388, 1388, 1283, 1283, 1391, 1558, 1358, 1358, |
| 174086 | + /* 220 */ 1358, 1358, 1367, 1358, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174087 | + /* 230 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1548, |
| 174088 | + /* 240 */ 1546, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173208 | 174089 | /* 250 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173209 | | - /* 260 */ 1254, 1254, 1254, 1254, 1254, 1254, 1363, 1254, 1254, 1254, |
| 173210 | | - /* 270 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1608, 1254, |
| 173211 | | - /* 280 */ 1521, 1343, 1363, 1363, 1363, 1363, 1365, 1344, 1342, 1357, |
| 173212 | | - /* 290 */ 1288, 1261, 1655, 1423, 1412, 1364, 1412, 1652, 1410, 1423, |
| 173213 | | - /* 300 */ 1423, 1410, 1423, 1364, 1652, 1304, 1630, 1299, 1397, 1397, |
| 173214 | | - /* 310 */ 1397, 1387, 1387, 1387, 1387, 1391, 1391, 1489, 1364, 1357, |
| 173215 | | - /* 320 */ 1254, 1655, 1655, 1373, 1373, 1654, 1654, 1373, 1509, 1638, |
| 173216 | | - /* 330 */ 1432, 1332, 1338, 1338, 1338, 1338, 1373, 1272, 1410, 1638, |
| 173217 | | - /* 340 */ 1638, 1410, 1432, 1332, 1410, 1332, 1410, 1373, 1272, 1525, |
| 173218 | | - /* 350 */ 1649, 1373, 1272, 1499, 1373, 1272, 1373, 1272, 1499, 1330, |
| 173219 | | - /* 360 */ 1330, 1330, 1319, 1254, 1254, 1499, 1330, 1304, 1330, 1319, |
| 173220 | | - /* 370 */ 1330, 1330, 1596, 1254, 1503, 1503, 1499, 1373, 1588, 1588, |
| 173221 | | - /* 380 */ 1400, 1400, 1405, 1391, 1494, 1373, 1254, 1405, 1403, 1401, |
| 173222 | | - /* 390 */ 1410, 1322, 1611, 1611, 1607, 1607, 1607, 1660, 1660, 1558, |
| 173223 | | - /* 400 */ 1623, 1287, 1287, 1287, 1287, 1623, 1306, 1306, 1288, 1288, |
| 173224 | | - /* 410 */ 1287, 1623, 1254, 1254, 1254, 1254, 1254, 1254, 1618, 1254, |
| 173225 | | - /* 420 */ 1553, 1510, 1377, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173226 | | - /* 430 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1564, |
| 173227 | | - /* 440 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173228 | | - /* 450 */ 1254, 1437, 1254, 1257, 1555, 1254, 1254, 1254, 1254, 1254, |
| 173229 | | - /* 460 */ 1254, 1254, 1254, 1414, 1415, 1378, 1254, 1254, 1254, 1254, |
| 173230 | | - /* 470 */ 1254, 1254, 1254, 1429, 1254, 1254, 1254, 1424, 1254, 1254, |
| 173231 | | - /* 480 */ 1254, 1254, 1254, 1254, 1254, 1254, 1651, 1254, 1254, 1254, |
| 173232 | | - /* 490 */ 1254, 1254, 1254, 1524, 1523, 1254, 1254, 1375, 1254, 1254, |
| 174090 | + /* 260 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1363, 1254, |
| 174091 | + /* 270 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1608, |
| 174092 | + /* 280 */ 1254, 1521, 1343, 1363, 1363, 1363, 1363, 1365, 1344, 1342, |
| 174093 | + /* 290 */ 1357, 1288, 1261, 1655, 1423, 1412, 1364, 1412, 1652, 1410, |
| 174094 | + /* 300 */ 1423, 1423, 1410, 1423, 1364, 1652, 1304, 1630, 1299, 1397, |
| 174095 | + /* 310 */ 1397, 1397, 1387, 1387, 1387, 1387, 1391, 1391, 1489, 1364, |
| 174096 | + /* 320 */ 1357, 1254, 1655, 1655, 1373, 1373, 1654, 1654, 1373, 1509, |
| 174097 | + /* 330 */ 1638, 1432, 1332, 1338, 1338, 1338, 1338, 1373, 1272, 1410, |
| 174098 | + /* 340 */ 1638, 1638, 1410, 1432, 1332, 1410, 1332, 1410, 1373, 1272, |
| 174099 | + /* 350 */ 1525, 1649, 1373, 1272, 1499, 1373, 1272, 1373, 1272, 1499, |
| 174100 | + /* 360 */ 1330, 1330, 1330, 1319, 1254, 1254, 1499, 1330, 1304, 1330, |
| 174101 | + /* 370 */ 1319, 1330, 1330, 1596, 1254, 1503, 1503, 1499, 1373, 1588, |
| 174102 | + /* 380 */ 1588, 1400, 1400, 1405, 1391, 1494, 1373, 1254, 1405, 1403, |
| 174103 | + /* 390 */ 1401, 1410, 1322, 1611, 1611, 1607, 1607, 1607, 1660, 1660, |
| 174104 | + /* 400 */ 1558, 1623, 1287, 1287, 1287, 1287, 1623, 1306, 1306, 1288, |
| 174105 | + /* 410 */ 1288, 1287, 1623, 1254, 1254, 1254, 1254, 1254, 1254, 1618, |
| 174106 | + /* 420 */ 1254, 1553, 1510, 1377, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174107 | + /* 430 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174108 | + /* 440 */ 1564, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174109 | + /* 450 */ 1254, 1254, 1437, 1254, 1257, 1555, 1254, 1254, 1254, 1254, |
| 174110 | + /* 460 */ 1254, 1254, 1254, 1254, 1414, 1415, 1378, 1254, 1254, 1254, |
| 174111 | + /* 470 */ 1254, 1254, 1254, 1254, 1429, 1254, 1254, 1254, 1424, 1254, |
| 174112 | + /* 480 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1651, 1254, 1254, |
| 174113 | + /* 490 */ 1254, 1254, 1254, 1254, 1524, 1523, 1254, 1254, 1375, 1254, |
| 173233 | 174114 | /* 500 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173234 | | - /* 510 */ 1254, 1302, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174115 | + /* 510 */ 1254, 1254, 1302, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173235 | 174116 | /* 520 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173236 | | - /* 530 */ 1254, 1254, 1254, 1254, 1254, 1402, 1254, 1254, 1254, 1254, |
| 174117 | + /* 530 */ 1254, 1254, 1254, 1254, 1254, 1254, 1402, 1254, 1254, 1254, |
| 173237 | 174118 | /* 540 */ 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173238 | | - /* 550 */ 1593, 1392, 1254, 1254, 1254, 1254, 1642, 1254, 1254, 1254, |
| 173239 | | - /* 560 */ 1254, 1352, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 174119 | + /* 550 */ 1254, 1593, 1392, 1254, 1254, 1254, 1254, 1642, 1254, 1254, |
| 174120 | + /* 560 */ 1254, 1254, 1352, 1254, 1254, 1254, 1254, 1254, 1254, 1254, |
| 173240 | 174121 | /* 570 */ 1254, 1254, 1254, 1634, 1346, 1438, 1254, 1441, 1276, 1254, |
| 173241 | 174122 | /* 580 */ 1266, 1254, 1254, |
| 173242 | 174123 | }; |
| 173243 | 174124 | /********** End of lemon-generated parsing tables *****************************/ |
| 173244 | 174125 | |
| | @@ -173258,56 +174139,57 @@ |
| 173258 | 174139 | */ |
| 173259 | 174140 | #ifdef YYFALLBACK |
| 173260 | 174141 | static const YYCODETYPE yyFallback[] = { |
| 173261 | 174142 | 0, /* $ => nothing */ |
| 173262 | 174143 | 0, /* SEMI => nothing */ |
| 173263 | | - 59, /* EXPLAIN => ID */ |
| 173264 | | - 59, /* QUERY => ID */ |
| 173265 | | - 59, /* PLAN => ID */ |
| 173266 | | - 59, /* BEGIN => ID */ |
| 174144 | + 60, /* EXPLAIN => ID */ |
| 174145 | + 60, /* QUERY => ID */ |
| 174146 | + 60, /* PLAN => ID */ |
| 174147 | + 60, /* BEGIN => ID */ |
| 173267 | 174148 | 0, /* TRANSACTION => nothing */ |
| 173268 | | - 59, /* DEFERRED => ID */ |
| 173269 | | - 59, /* IMMEDIATE => ID */ |
| 173270 | | - 59, /* EXCLUSIVE => ID */ |
| 174149 | + 60, /* DEFERRED => ID */ |
| 174150 | + 60, /* IMMEDIATE => ID */ |
| 174151 | + 60, /* EXCLUSIVE => ID */ |
| 173271 | 174152 | 0, /* COMMIT => nothing */ |
| 173272 | | - 59, /* END => ID */ |
| 173273 | | - 59, /* ROLLBACK => ID */ |
| 173274 | | - 59, /* SAVEPOINT => ID */ |
| 173275 | | - 59, /* RELEASE => ID */ |
| 174153 | + 60, /* END => ID */ |
| 174154 | + 60, /* ROLLBACK => ID */ |
| 174155 | + 60, /* SAVEPOINT => ID */ |
| 174156 | + 60, /* RELEASE => ID */ |
| 173276 | 174157 | 0, /* TO => nothing */ |
| 173277 | 174158 | 0, /* TABLE => nothing */ |
| 173278 | 174159 | 0, /* CREATE => nothing */ |
| 173279 | | - 59, /* IF => ID */ |
| 174160 | + 60, /* IF => ID */ |
| 173280 | 174161 | 0, /* NOT => nothing */ |
| 173281 | 174162 | 0, /* EXISTS => nothing */ |
| 173282 | | - 59, /* TEMP => ID */ |
| 174163 | + 60, /* TEMP => ID */ |
| 173283 | 174164 | 0, /* LP => nothing */ |
| 173284 | 174165 | 0, /* RP => nothing */ |
| 173285 | 174166 | 0, /* AS => nothing */ |
| 173286 | 174167 | 0, /* COMMA => nothing */ |
| 173287 | | - 59, /* WITHOUT => ID */ |
| 173288 | | - 59, /* ABORT => ID */ |
| 173289 | | - 59, /* ACTION => ID */ |
| 173290 | | - 59, /* AFTER => ID */ |
| 173291 | | - 59, /* ANALYZE => ID */ |
| 173292 | | - 59, /* ASC => ID */ |
| 173293 | | - 59, /* ATTACH => ID */ |
| 173294 | | - 59, /* BEFORE => ID */ |
| 173295 | | - 59, /* BY => ID */ |
| 173296 | | - 59, /* CASCADE => ID */ |
| 173297 | | - 59, /* CAST => ID */ |
| 173298 | | - 59, /* CONFLICT => ID */ |
| 173299 | | - 59, /* DATABASE => ID */ |
| 173300 | | - 59, /* DESC => ID */ |
| 173301 | | - 59, /* DETACH => ID */ |
| 173302 | | - 59, /* EACH => ID */ |
| 173303 | | - 59, /* FAIL => ID */ |
| 174168 | + 60, /* WITHOUT => ID */ |
| 174169 | + 60, /* ABORT => ID */ |
| 174170 | + 60, /* ACTION => ID */ |
| 174171 | + 60, /* AFTER => ID */ |
| 174172 | + 60, /* ANALYZE => ID */ |
| 174173 | + 60, /* ASC => ID */ |
| 174174 | + 60, /* ATTACH => ID */ |
| 174175 | + 60, /* BEFORE => ID */ |
| 174176 | + 60, /* BY => ID */ |
| 174177 | + 60, /* CASCADE => ID */ |
| 174178 | + 60, /* CAST => ID */ |
| 174179 | + 60, /* CONFLICT => ID */ |
| 174180 | + 60, /* DATABASE => ID */ |
| 174181 | + 60, /* DESC => ID */ |
| 174182 | + 60, /* DETACH => ID */ |
| 174183 | + 60, /* EACH => ID */ |
| 174184 | + 60, /* FAIL => ID */ |
| 173304 | 174185 | 0, /* OR => nothing */ |
| 173305 | 174186 | 0, /* AND => nothing */ |
| 173306 | 174187 | 0, /* IS => nothing */ |
| 173307 | | - 59, /* MATCH => ID */ |
| 173308 | | - 59, /* LIKE_KW => ID */ |
| 174188 | + 0, /* ISNOT => nothing */ |
| 174189 | + 60, /* MATCH => ID */ |
| 174190 | + 60, /* LIKE_KW => ID */ |
| 173309 | 174191 | 0, /* BETWEEN => nothing */ |
| 173310 | 174192 | 0, /* IN => nothing */ |
| 173311 | 174193 | 0, /* ISNULL => nothing */ |
| 173312 | 174194 | 0, /* NOTNULL => nothing */ |
| 173313 | 174195 | 0, /* NE => nothing */ |
| | @@ -173316,51 +174198,51 @@ |
| 173316 | 174198 | 0, /* LE => nothing */ |
| 173317 | 174199 | 0, /* LT => nothing */ |
| 173318 | 174200 | 0, /* GE => nothing */ |
| 173319 | 174201 | 0, /* ESCAPE => nothing */ |
| 173320 | 174202 | 0, /* ID => nothing */ |
| 173321 | | - 59, /* COLUMNKW => ID */ |
| 173322 | | - 59, /* DO => ID */ |
| 173323 | | - 59, /* FOR => ID */ |
| 173324 | | - 59, /* IGNORE => ID */ |
| 173325 | | - 59, /* INITIALLY => ID */ |
| 173326 | | - 59, /* INSTEAD => ID */ |
| 173327 | | - 59, /* NO => ID */ |
| 173328 | | - 59, /* KEY => ID */ |
| 173329 | | - 59, /* OF => ID */ |
| 173330 | | - 59, /* OFFSET => ID */ |
| 173331 | | - 59, /* PRAGMA => ID */ |
| 173332 | | - 59, /* RAISE => ID */ |
| 173333 | | - 59, /* RECURSIVE => ID */ |
| 173334 | | - 59, /* REPLACE => ID */ |
| 173335 | | - 59, /* RESTRICT => ID */ |
| 173336 | | - 59, /* ROW => ID */ |
| 173337 | | - 59, /* ROWS => ID */ |
| 173338 | | - 59, /* TRIGGER => ID */ |
| 173339 | | - 59, /* VACUUM => ID */ |
| 173340 | | - 59, /* VIEW => ID */ |
| 173341 | | - 59, /* VIRTUAL => ID */ |
| 173342 | | - 59, /* WITH => ID */ |
| 173343 | | - 59, /* NULLS => ID */ |
| 173344 | | - 59, /* FIRST => ID */ |
| 173345 | | - 59, /* LAST => ID */ |
| 173346 | | - 59, /* CURRENT => ID */ |
| 173347 | | - 59, /* FOLLOWING => ID */ |
| 173348 | | - 59, /* PARTITION => ID */ |
| 173349 | | - 59, /* PRECEDING => ID */ |
| 173350 | | - 59, /* RANGE => ID */ |
| 173351 | | - 59, /* UNBOUNDED => ID */ |
| 173352 | | - 59, /* EXCLUDE => ID */ |
| 173353 | | - 59, /* GROUPS => ID */ |
| 173354 | | - 59, /* OTHERS => ID */ |
| 173355 | | - 59, /* TIES => ID */ |
| 173356 | | - 59, /* GENERATED => ID */ |
| 173357 | | - 59, /* ALWAYS => ID */ |
| 173358 | | - 59, /* MATERIALIZED => ID */ |
| 173359 | | - 59, /* REINDEX => ID */ |
| 173360 | | - 59, /* RENAME => ID */ |
| 173361 | | - 59, /* CTIME_KW => ID */ |
| 174203 | + 60, /* COLUMNKW => ID */ |
| 174204 | + 60, /* DO => ID */ |
| 174205 | + 60, /* FOR => ID */ |
| 174206 | + 60, /* IGNORE => ID */ |
| 174207 | + 60, /* INITIALLY => ID */ |
| 174208 | + 60, /* INSTEAD => ID */ |
| 174209 | + 60, /* NO => ID */ |
| 174210 | + 60, /* KEY => ID */ |
| 174211 | + 60, /* OF => ID */ |
| 174212 | + 60, /* OFFSET => ID */ |
| 174213 | + 60, /* PRAGMA => ID */ |
| 174214 | + 60, /* RAISE => ID */ |
| 174215 | + 60, /* RECURSIVE => ID */ |
| 174216 | + 60, /* REPLACE => ID */ |
| 174217 | + 60, /* RESTRICT => ID */ |
| 174218 | + 60, /* ROW => ID */ |
| 174219 | + 60, /* ROWS => ID */ |
| 174220 | + 60, /* TRIGGER => ID */ |
| 174221 | + 60, /* VACUUM => ID */ |
| 174222 | + 60, /* VIEW => ID */ |
| 174223 | + 60, /* VIRTUAL => ID */ |
| 174224 | + 60, /* WITH => ID */ |
| 174225 | + 60, /* NULLS => ID */ |
| 174226 | + 60, /* FIRST => ID */ |
| 174227 | + 60, /* LAST => ID */ |
| 174228 | + 60, /* CURRENT => ID */ |
| 174229 | + 60, /* FOLLOWING => ID */ |
| 174230 | + 60, /* PARTITION => ID */ |
| 174231 | + 60, /* PRECEDING => ID */ |
| 174232 | + 60, /* RANGE => ID */ |
| 174233 | + 60, /* UNBOUNDED => ID */ |
| 174234 | + 60, /* EXCLUDE => ID */ |
| 174235 | + 60, /* GROUPS => ID */ |
| 174236 | + 60, /* OTHERS => ID */ |
| 174237 | + 60, /* TIES => ID */ |
| 174238 | + 60, /* GENERATED => ID */ |
| 174239 | + 60, /* ALWAYS => ID */ |
| 174240 | + 60, /* MATERIALIZED => ID */ |
| 174241 | + 60, /* REINDEX => ID */ |
| 174242 | + 60, /* RENAME => ID */ |
| 174243 | + 60, /* CTIME_KW => ID */ |
| 173362 | 174244 | 0, /* ANY => nothing */ |
| 173363 | 174245 | 0, /* BITAND => nothing */ |
| 173364 | 174246 | 0, /* BITOR => nothing */ |
| 173365 | 174247 | 0, /* LSHIFT => nothing */ |
| 173366 | 174248 | 0, /* RSHIFT => nothing */ |
| | @@ -173427,14 +174309,13 @@ |
| 173427 | 174309 | 0, /* FILTER => nothing */ |
| 173428 | 174310 | 0, /* COLUMN => nothing */ |
| 173429 | 174311 | 0, /* AGG_FUNCTION => nothing */ |
| 173430 | 174312 | 0, /* AGG_COLUMN => nothing */ |
| 173431 | 174313 | 0, /* TRUEFALSE => nothing */ |
| 173432 | | - 0, /* ISNOT => nothing */ |
| 173433 | 174314 | 0, /* FUNCTION => nothing */ |
| 173434 | | - 0, /* UMINUS => nothing */ |
| 173435 | 174315 | 0, /* UPLUS => nothing */ |
| 174316 | + 0, /* UMINUS => nothing */ |
| 173436 | 174317 | 0, /* TRUTH => nothing */ |
| 173437 | 174318 | 0, /* REGISTER => nothing */ |
| 173438 | 174319 | 0, /* VECTOR => nothing */ |
| 173439 | 174320 | 0, /* SELECT_COLUMN => nothing */ |
| 173440 | 174321 | 0, /* IF_NULL_ROW => nothing */ |
| | @@ -173571,139 +174452,139 @@ |
| 173571 | 174452 | /* 41 */ "EACH", |
| 173572 | 174453 | /* 42 */ "FAIL", |
| 173573 | 174454 | /* 43 */ "OR", |
| 173574 | 174455 | /* 44 */ "AND", |
| 173575 | 174456 | /* 45 */ "IS", |
| 173576 | | - /* 46 */ "MATCH", |
| 173577 | | - /* 47 */ "LIKE_KW", |
| 173578 | | - /* 48 */ "BETWEEN", |
| 173579 | | - /* 49 */ "IN", |
| 173580 | | - /* 50 */ "ISNULL", |
| 173581 | | - /* 51 */ "NOTNULL", |
| 173582 | | - /* 52 */ "NE", |
| 173583 | | - /* 53 */ "EQ", |
| 173584 | | - /* 54 */ "GT", |
| 173585 | | - /* 55 */ "LE", |
| 173586 | | - /* 56 */ "LT", |
| 173587 | | - /* 57 */ "GE", |
| 173588 | | - /* 58 */ "ESCAPE", |
| 173589 | | - /* 59 */ "ID", |
| 173590 | | - /* 60 */ "COLUMNKW", |
| 173591 | | - /* 61 */ "DO", |
| 173592 | | - /* 62 */ "FOR", |
| 173593 | | - /* 63 */ "IGNORE", |
| 173594 | | - /* 64 */ "INITIALLY", |
| 173595 | | - /* 65 */ "INSTEAD", |
| 173596 | | - /* 66 */ "NO", |
| 173597 | | - /* 67 */ "KEY", |
| 173598 | | - /* 68 */ "OF", |
| 173599 | | - /* 69 */ "OFFSET", |
| 173600 | | - /* 70 */ "PRAGMA", |
| 173601 | | - /* 71 */ "RAISE", |
| 173602 | | - /* 72 */ "RECURSIVE", |
| 173603 | | - /* 73 */ "REPLACE", |
| 173604 | | - /* 74 */ "RESTRICT", |
| 173605 | | - /* 75 */ "ROW", |
| 173606 | | - /* 76 */ "ROWS", |
| 173607 | | - /* 77 */ "TRIGGER", |
| 173608 | | - /* 78 */ "VACUUM", |
| 173609 | | - /* 79 */ "VIEW", |
| 173610 | | - /* 80 */ "VIRTUAL", |
| 173611 | | - /* 81 */ "WITH", |
| 173612 | | - /* 82 */ "NULLS", |
| 173613 | | - /* 83 */ "FIRST", |
| 173614 | | - /* 84 */ "LAST", |
| 173615 | | - /* 85 */ "CURRENT", |
| 173616 | | - /* 86 */ "FOLLOWING", |
| 173617 | | - /* 87 */ "PARTITION", |
| 173618 | | - /* 88 */ "PRECEDING", |
| 173619 | | - /* 89 */ "RANGE", |
| 173620 | | - /* 90 */ "UNBOUNDED", |
| 173621 | | - /* 91 */ "EXCLUDE", |
| 173622 | | - /* 92 */ "GROUPS", |
| 173623 | | - /* 93 */ "OTHERS", |
| 173624 | | - /* 94 */ "TIES", |
| 173625 | | - /* 95 */ "GENERATED", |
| 173626 | | - /* 96 */ "ALWAYS", |
| 173627 | | - /* 97 */ "MATERIALIZED", |
| 173628 | | - /* 98 */ "REINDEX", |
| 173629 | | - /* 99 */ "RENAME", |
| 173630 | | - /* 100 */ "CTIME_KW", |
| 173631 | | - /* 101 */ "ANY", |
| 173632 | | - /* 102 */ "BITAND", |
| 173633 | | - /* 103 */ "BITOR", |
| 173634 | | - /* 104 */ "LSHIFT", |
| 173635 | | - /* 105 */ "RSHIFT", |
| 173636 | | - /* 106 */ "PLUS", |
| 173637 | | - /* 107 */ "MINUS", |
| 173638 | | - /* 108 */ "STAR", |
| 173639 | | - /* 109 */ "SLASH", |
| 173640 | | - /* 110 */ "REM", |
| 173641 | | - /* 111 */ "CONCAT", |
| 173642 | | - /* 112 */ "PTR", |
| 173643 | | - /* 113 */ "COLLATE", |
| 173644 | | - /* 114 */ "BITNOT", |
| 173645 | | - /* 115 */ "ON", |
| 173646 | | - /* 116 */ "INDEXED", |
| 173647 | | - /* 117 */ "STRING", |
| 173648 | | - /* 118 */ "JOIN_KW", |
| 173649 | | - /* 119 */ "CONSTRAINT", |
| 173650 | | - /* 120 */ "DEFAULT", |
| 173651 | | - /* 121 */ "NULL", |
| 173652 | | - /* 122 */ "PRIMARY", |
| 173653 | | - /* 123 */ "UNIQUE", |
| 173654 | | - /* 124 */ "CHECK", |
| 173655 | | - /* 125 */ "REFERENCES", |
| 173656 | | - /* 126 */ "AUTOINCR", |
| 173657 | | - /* 127 */ "INSERT", |
| 173658 | | - /* 128 */ "DELETE", |
| 173659 | | - /* 129 */ "UPDATE", |
| 173660 | | - /* 130 */ "SET", |
| 173661 | | - /* 131 */ "DEFERRABLE", |
| 173662 | | - /* 132 */ "FOREIGN", |
| 173663 | | - /* 133 */ "DROP", |
| 173664 | | - /* 134 */ "UNION", |
| 173665 | | - /* 135 */ "ALL", |
| 173666 | | - /* 136 */ "EXCEPT", |
| 173667 | | - /* 137 */ "INTERSECT", |
| 173668 | | - /* 138 */ "SELECT", |
| 173669 | | - /* 139 */ "VALUES", |
| 173670 | | - /* 140 */ "DISTINCT", |
| 173671 | | - /* 141 */ "DOT", |
| 173672 | | - /* 142 */ "FROM", |
| 173673 | | - /* 143 */ "JOIN", |
| 173674 | | - /* 144 */ "USING", |
| 173675 | | - /* 145 */ "ORDER", |
| 173676 | | - /* 146 */ "GROUP", |
| 173677 | | - /* 147 */ "HAVING", |
| 173678 | | - /* 148 */ "LIMIT", |
| 173679 | | - /* 149 */ "WHERE", |
| 173680 | | - /* 150 */ "RETURNING", |
| 173681 | | - /* 151 */ "INTO", |
| 173682 | | - /* 152 */ "NOTHING", |
| 173683 | | - /* 153 */ "FLOAT", |
| 173684 | | - /* 154 */ "BLOB", |
| 173685 | | - /* 155 */ "INTEGER", |
| 173686 | | - /* 156 */ "VARIABLE", |
| 173687 | | - /* 157 */ "CASE", |
| 173688 | | - /* 158 */ "WHEN", |
| 173689 | | - /* 159 */ "THEN", |
| 173690 | | - /* 160 */ "ELSE", |
| 173691 | | - /* 161 */ "INDEX", |
| 173692 | | - /* 162 */ "ALTER", |
| 173693 | | - /* 163 */ "ADD", |
| 173694 | | - /* 164 */ "WINDOW", |
| 173695 | | - /* 165 */ "OVER", |
| 173696 | | - /* 166 */ "FILTER", |
| 173697 | | - /* 167 */ "COLUMN", |
| 173698 | | - /* 168 */ "AGG_FUNCTION", |
| 173699 | | - /* 169 */ "AGG_COLUMN", |
| 173700 | | - /* 170 */ "TRUEFALSE", |
| 173701 | | - /* 171 */ "ISNOT", |
| 174457 | + /* 46 */ "ISNOT", |
| 174458 | + /* 47 */ "MATCH", |
| 174459 | + /* 48 */ "LIKE_KW", |
| 174460 | + /* 49 */ "BETWEEN", |
| 174461 | + /* 50 */ "IN", |
| 174462 | + /* 51 */ "ISNULL", |
| 174463 | + /* 52 */ "NOTNULL", |
| 174464 | + /* 53 */ "NE", |
| 174465 | + /* 54 */ "EQ", |
| 174466 | + /* 55 */ "GT", |
| 174467 | + /* 56 */ "LE", |
| 174468 | + /* 57 */ "LT", |
| 174469 | + /* 58 */ "GE", |
| 174470 | + /* 59 */ "ESCAPE", |
| 174471 | + /* 60 */ "ID", |
| 174472 | + /* 61 */ "COLUMNKW", |
| 174473 | + /* 62 */ "DO", |
| 174474 | + /* 63 */ "FOR", |
| 174475 | + /* 64 */ "IGNORE", |
| 174476 | + /* 65 */ "INITIALLY", |
| 174477 | + /* 66 */ "INSTEAD", |
| 174478 | + /* 67 */ "NO", |
| 174479 | + /* 68 */ "KEY", |
| 174480 | + /* 69 */ "OF", |
| 174481 | + /* 70 */ "OFFSET", |
| 174482 | + /* 71 */ "PRAGMA", |
| 174483 | + /* 72 */ "RAISE", |
| 174484 | + /* 73 */ "RECURSIVE", |
| 174485 | + /* 74 */ "REPLACE", |
| 174486 | + /* 75 */ "RESTRICT", |
| 174487 | + /* 76 */ "ROW", |
| 174488 | + /* 77 */ "ROWS", |
| 174489 | + /* 78 */ "TRIGGER", |
| 174490 | + /* 79 */ "VACUUM", |
| 174491 | + /* 80 */ "VIEW", |
| 174492 | + /* 81 */ "VIRTUAL", |
| 174493 | + /* 82 */ "WITH", |
| 174494 | + /* 83 */ "NULLS", |
| 174495 | + /* 84 */ "FIRST", |
| 174496 | + /* 85 */ "LAST", |
| 174497 | + /* 86 */ "CURRENT", |
| 174498 | + /* 87 */ "FOLLOWING", |
| 174499 | + /* 88 */ "PARTITION", |
| 174500 | + /* 89 */ "PRECEDING", |
| 174501 | + /* 90 */ "RANGE", |
| 174502 | + /* 91 */ "UNBOUNDED", |
| 174503 | + /* 92 */ "EXCLUDE", |
| 174504 | + /* 93 */ "GROUPS", |
| 174505 | + /* 94 */ "OTHERS", |
| 174506 | + /* 95 */ "TIES", |
| 174507 | + /* 96 */ "GENERATED", |
| 174508 | + /* 97 */ "ALWAYS", |
| 174509 | + /* 98 */ "MATERIALIZED", |
| 174510 | + /* 99 */ "REINDEX", |
| 174511 | + /* 100 */ "RENAME", |
| 174512 | + /* 101 */ "CTIME_KW", |
| 174513 | + /* 102 */ "ANY", |
| 174514 | + /* 103 */ "BITAND", |
| 174515 | + /* 104 */ "BITOR", |
| 174516 | + /* 105 */ "LSHIFT", |
| 174517 | + /* 106 */ "RSHIFT", |
| 174518 | + /* 107 */ "PLUS", |
| 174519 | + /* 108 */ "MINUS", |
| 174520 | + /* 109 */ "STAR", |
| 174521 | + /* 110 */ "SLASH", |
| 174522 | + /* 111 */ "REM", |
| 174523 | + /* 112 */ "CONCAT", |
| 174524 | + /* 113 */ "PTR", |
| 174525 | + /* 114 */ "COLLATE", |
| 174526 | + /* 115 */ "BITNOT", |
| 174527 | + /* 116 */ "ON", |
| 174528 | + /* 117 */ "INDEXED", |
| 174529 | + /* 118 */ "STRING", |
| 174530 | + /* 119 */ "JOIN_KW", |
| 174531 | + /* 120 */ "CONSTRAINT", |
| 174532 | + /* 121 */ "DEFAULT", |
| 174533 | + /* 122 */ "NULL", |
| 174534 | + /* 123 */ "PRIMARY", |
| 174535 | + /* 124 */ "UNIQUE", |
| 174536 | + /* 125 */ "CHECK", |
| 174537 | + /* 126 */ "REFERENCES", |
| 174538 | + /* 127 */ "AUTOINCR", |
| 174539 | + /* 128 */ "INSERT", |
| 174540 | + /* 129 */ "DELETE", |
| 174541 | + /* 130 */ "UPDATE", |
| 174542 | + /* 131 */ "SET", |
| 174543 | + /* 132 */ "DEFERRABLE", |
| 174544 | + /* 133 */ "FOREIGN", |
| 174545 | + /* 134 */ "DROP", |
| 174546 | + /* 135 */ "UNION", |
| 174547 | + /* 136 */ "ALL", |
| 174548 | + /* 137 */ "EXCEPT", |
| 174549 | + /* 138 */ "INTERSECT", |
| 174550 | + /* 139 */ "SELECT", |
| 174551 | + /* 140 */ "VALUES", |
| 174552 | + /* 141 */ "DISTINCT", |
| 174553 | + /* 142 */ "DOT", |
| 174554 | + /* 143 */ "FROM", |
| 174555 | + /* 144 */ "JOIN", |
| 174556 | + /* 145 */ "USING", |
| 174557 | + /* 146 */ "ORDER", |
| 174558 | + /* 147 */ "GROUP", |
| 174559 | + /* 148 */ "HAVING", |
| 174560 | + /* 149 */ "LIMIT", |
| 174561 | + /* 150 */ "WHERE", |
| 174562 | + /* 151 */ "RETURNING", |
| 174563 | + /* 152 */ "INTO", |
| 174564 | + /* 153 */ "NOTHING", |
| 174565 | + /* 154 */ "FLOAT", |
| 174566 | + /* 155 */ "BLOB", |
| 174567 | + /* 156 */ "INTEGER", |
| 174568 | + /* 157 */ "VARIABLE", |
| 174569 | + /* 158 */ "CASE", |
| 174570 | + /* 159 */ "WHEN", |
| 174571 | + /* 160 */ "THEN", |
| 174572 | + /* 161 */ "ELSE", |
| 174573 | + /* 162 */ "INDEX", |
| 174574 | + /* 163 */ "ALTER", |
| 174575 | + /* 164 */ "ADD", |
| 174576 | + /* 165 */ "WINDOW", |
| 174577 | + /* 166 */ "OVER", |
| 174578 | + /* 167 */ "FILTER", |
| 174579 | + /* 168 */ "COLUMN", |
| 174580 | + /* 169 */ "AGG_FUNCTION", |
| 174581 | + /* 170 */ "AGG_COLUMN", |
| 174582 | + /* 171 */ "TRUEFALSE", |
| 173702 | 174583 | /* 172 */ "FUNCTION", |
| 173703 | | - /* 173 */ "UMINUS", |
| 173704 | | - /* 174 */ "UPLUS", |
| 174584 | + /* 173 */ "UPLUS", |
| 174585 | + /* 174 */ "UMINUS", |
| 173705 | 174586 | /* 175 */ "TRUTH", |
| 173706 | 174587 | /* 176 */ "REGISTER", |
| 173707 | 174588 | /* 177 */ "VECTOR", |
| 173708 | 174589 | /* 178 */ "SELECT_COLUMN", |
| 173709 | 174590 | /* 179 */ "IF_NULL_ROW", |
| | @@ -174134,11 +175015,11 @@ |
| 174134 | 175015 | /* 275 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 174135 | 175016 | /* 276 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 174136 | 175017 | /* 277 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 174137 | 175018 | /* 278 */ "trigger_cmd ::= scanpt select scanpt", |
| 174138 | 175019 | /* 279 */ "expr ::= RAISE LP IGNORE RP", |
| 174139 | | - /* 280 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 175020 | + /* 280 */ "expr ::= RAISE LP raisetype COMMA expr RP", |
| 174140 | 175021 | /* 281 */ "raisetype ::= ROLLBACK", |
| 174141 | 175022 | /* 282 */ "raisetype ::= ABORT", |
| 174142 | 175023 | /* 283 */ "raisetype ::= FAIL", |
| 174143 | 175024 | /* 284 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 174144 | 175025 | /* 285 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| | @@ -175059,11 +175940,11 @@ |
| 175059 | 175940 | 293, /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 175060 | 175941 | 293, /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 175061 | 175942 | 293, /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 175062 | 175943 | 293, /* (278) trigger_cmd ::= scanpt select scanpt */ |
| 175063 | 175944 | 218, /* (279) expr ::= RAISE LP IGNORE RP */ |
| 175064 | | - 218, /* (280) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 175945 | + 218, /* (280) expr ::= RAISE LP raisetype COMMA expr RP */ |
| 175065 | 175946 | 237, /* (281) raisetype ::= ROLLBACK */ |
| 175066 | 175947 | 237, /* (282) raisetype ::= ABORT */ |
| 175067 | 175948 | 237, /* (283) raisetype ::= FAIL */ |
| 175068 | 175949 | 191, /* (284) cmd ::= DROP TRIGGER ifexists fullname */ |
| 175069 | 175950 | 191, /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| | @@ -175473,11 +176354,11 @@ |
| 175473 | 176354 | -9, /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 175474 | 176355 | -8, /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 175475 | 176356 | -6, /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 175476 | 176357 | -3, /* (278) trigger_cmd ::= scanpt select scanpt */ |
| 175477 | 176358 | -4, /* (279) expr ::= RAISE LP IGNORE RP */ |
| 175478 | | - -6, /* (280) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 176359 | + -6, /* (280) expr ::= RAISE LP raisetype COMMA expr RP */ |
| 175479 | 176360 | -1, /* (281) raisetype ::= ROLLBACK */ |
| 175480 | 176361 | -1, /* (282) raisetype ::= ABORT */ |
| 175481 | 176362 | -1, /* (283) raisetype ::= FAIL */ |
| 175482 | 176363 | -4, /* (284) cmd ::= DROP TRIGGER ifexists fullname */ |
| 175483 | 176364 | -6, /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| | @@ -176560,12 +177441,21 @@ |
| 176560 | 177441 | case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215); |
| 176561 | 177442 | {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/} |
| 176562 | 177443 | break; |
| 176563 | 177444 | case 216: /* expr ::= PLUS|MINUS expr */ |
| 176564 | 177445 | { |
| 176565 | | - yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy454, 0); |
| 176566 | | - /*A-overwrites-B*/ |
| 177446 | + Expr *p = yymsp[0].minor.yy454; |
| 177447 | + u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS); |
| 177448 | + assert( TK_UPLUS>TK_PLUS ); |
| 177449 | + assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) ); |
| 177450 | + if( p && p->op==TK_UPLUS ){ |
| 177451 | + p->op = op; |
| 177452 | + yymsp[-1].minor.yy454 = p; |
| 177453 | + }else{ |
| 177454 | + yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, op, p, 0); |
| 177455 | + /*A-overwrites-B*/ |
| 177456 | + } |
| 176567 | 177457 | } |
| 176568 | 177458 | break; |
| 176569 | 177459 | case 217: /* expr ::= expr PTR expr */ |
| 176570 | 177460 | { |
| 176571 | 177461 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy454); |
| | @@ -176849,13 +177739,13 @@ |
| 176849 | 177739 | if( yymsp[-3].minor.yy454 ){ |
| 176850 | 177740 | yymsp[-3].minor.yy454->affExpr = OE_Ignore; |
| 176851 | 177741 | } |
| 176852 | 177742 | } |
| 176853 | 177743 | break; |
| 176854 | | - case 280: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 177744 | + case 280: /* expr ::= RAISE LP raisetype COMMA expr RP */ |
| 176855 | 177745 | { |
| 176856 | | - yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 177746 | + yymsp[-5].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy454, 0); |
| 176857 | 177747 | if( yymsp[-5].minor.yy454 ) { |
| 176858 | 177748 | yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy144; |
| 176859 | 177749 | } |
| 176860 | 177750 | } |
| 176861 | 177751 | break; |
| | @@ -202282,11 +203172,11 @@ |
| 202282 | 203172 | }else{ |
| 202283 | 203173 | iScore += 1000; |
| 202284 | 203174 | } |
| 202285 | 203175 | mCover |= mPhrase; |
| 202286 | 203176 | |
| 202287 | | - for(j=0; j<pPhrase->nToken; j++){ |
| 203177 | + for(j=0; j<pPhrase->nToken && j<pIter->nSnippet; j++){ |
| 202288 | 203178 | mHighlight |= (mPos>>j); |
| 202289 | 203179 | } |
| 202290 | 203180 | |
| 202291 | 203181 | if( 0==(*pCsr & 0x0FE) ) break; |
| 202292 | 203182 | fts3GetDeltaPosition(&pCsr, &iCsr); |
| | @@ -208175,17 +209065,10 @@ |
| 208175 | 209065 | } |
| 208176 | 209066 | if( !eErr ) sqlite3_result_int64(ctx, cnt); |
| 208177 | 209067 | jsonParseFree(p); |
| 208178 | 209068 | } |
| 208179 | 209069 | |
| 208180 | | -/* True if the string is all digits */ |
| 208181 | | -static int jsonAllDigits(const char *z, int n){ |
| 208182 | | - int i; |
| 208183 | | - for(i=0; i<n && sqlite3Isdigit(z[i]); i++){} |
| 208184 | | - return i==n; |
| 208185 | | -} |
| 208186 | | - |
| 208187 | 209070 | /* True if the string is all alphanumerics and underscores */ |
| 208188 | 209071 | static int jsonAllAlphanum(const char *z, int n){ |
| 208189 | 209072 | int i; |
| 208190 | 209073 | for(i=0; i<n && (sqlite3Isalnum(z[i]) || z[i]=='_'); i++){} |
| 208191 | 209074 | return i==n; |
| | @@ -208244,14 +209127,20 @@ |
| 208244 | 209127 | ** convenience. |
| 208245 | 209128 | ** |
| 208246 | 209129 | ** NUMBER ==> $[NUMBER] // PG compatible |
| 208247 | 209130 | ** LABEL ==> $.LABEL // PG compatible |
| 208248 | 209131 | ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience |
| 209132 | + ** |
| 209133 | + ** Updated 2024-05-27: If the NUMBER is negative, then PG counts from |
| 209134 | + ** the right of the array. Hence for negative NUMBER: |
| 209135 | + ** |
| 209136 | + ** NUMBER ==> $[#NUMBER] // PG compatible |
| 208249 | 209137 | */ |
| 208250 | 209138 | jsonStringInit(&jx, ctx); |
| 208251 | | - if( jsonAllDigits(zPath, nPath) ){ |
| 209139 | + if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){ |
| 208252 | 209140 | jsonAppendRawNZ(&jx, "[", 1); |
| 209141 | + if( zPath[0]=='-' ) jsonAppendRawNZ(&jx,"#",1); |
| 208253 | 209142 | jsonAppendRaw(&jx, zPath, nPath); |
| 208254 | 209143 | jsonAppendRawNZ(&jx, "]", 2); |
| 208255 | 209144 | }else if( jsonAllAlphanum(zPath, nPath) ){ |
| 208256 | 209145 | jsonAppendRawNZ(&jx, ".", 1); |
| 208257 | 209146 | jsonAppendRaw(&jx, zPath, nPath); |
| | @@ -216631,11 +217520,11 @@ |
| 216631 | 217520 | const char *zLocale; /* Locale identifier - (eg. "jp_JP") */ |
| 216632 | 217521 | const char *zName; /* SQL Collation sequence name (eg. "japanese") */ |
| 216633 | 217522 | UCollator *pUCollator; /* ICU library collation object */ |
| 216634 | 217523 | int rc; /* Return code from sqlite3_create_collation_x() */ |
| 216635 | 217524 | |
| 216636 | | - assert(nArg==2); |
| 217525 | + assert(nArg==2 || nArg==3); |
| 216637 | 217526 | (void)nArg; /* Unused parameter */ |
| 216638 | 217527 | zLocale = (const char *)sqlite3_value_text(apArg[0]); |
| 216639 | 217528 | zName = (const char *)sqlite3_value_text(apArg[1]); |
| 216640 | 217529 | |
| 216641 | 217530 | if( !zLocale || !zName ){ |
| | @@ -216646,11 +217535,43 @@ |
| 216646 | 217535 | if( !U_SUCCESS(status) ){ |
| 216647 | 217536 | icuFunctionError(p, "ucol_open", status); |
| 216648 | 217537 | return; |
| 216649 | 217538 | } |
| 216650 | 217539 | assert(p); |
| 216651 | | - |
| 217540 | + if(nArg==3){ |
| 217541 | + const char *zOption = (const char*)sqlite3_value_text(apArg[2]); |
| 217542 | + static const struct { |
| 217543 | + const char *zName; |
| 217544 | + UColAttributeValue val; |
| 217545 | + } aStrength[] = { |
| 217546 | + { "PRIMARY", UCOL_PRIMARY }, |
| 217547 | + { "SECONDARY", UCOL_SECONDARY }, |
| 217548 | + { "TERTIARY", UCOL_TERTIARY }, |
| 217549 | + { "DEFAULT", UCOL_DEFAULT_STRENGTH }, |
| 217550 | + { "QUARTERNARY", UCOL_QUATERNARY }, |
| 217551 | + { "IDENTICAL", UCOL_IDENTICAL }, |
| 217552 | + }; |
| 217553 | + unsigned int i; |
| 217554 | + for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){ |
| 217555 | + if( sqlite3_stricmp(zOption,aStrength[i].zName)==0 ){ |
| 217556 | + ucol_setStrength(pUCollator, aStrength[i].val); |
| 217557 | + break; |
| 217558 | + } |
| 217559 | + } |
| 217560 | + if( i>=sizeof(aStrength)/sizeof(aStrength[0]) ){ |
| 217561 | + sqlite3_str *pStr = sqlite3_str_new(sqlite3_context_db_handle(p)); |
| 217562 | + sqlite3_str_appendf(pStr, |
| 217563 | + "unknown collation strength \"%s\" - should be one of:", |
| 217564 | + zOption); |
| 217565 | + for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){ |
| 217566 | + sqlite3_str_appendf(pStr, " %s", aStrength[i].zName); |
| 217567 | + } |
| 217568 | + sqlite3_result_error(p, sqlite3_str_value(pStr), -1); |
| 217569 | + sqlite3_free(sqlite3_str_finish(pStr)); |
| 217570 | + return; |
| 217571 | + } |
| 217572 | + } |
| 216652 | 217573 | rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator, |
| 216653 | 217574 | icuCollationColl, icuCollationDel |
| 216654 | 217575 | ); |
| 216655 | 217576 | if( rc!=SQLITE_OK ){ |
| 216656 | 217577 | ucol_close(pUCollator); |
| | @@ -216669,10 +217590,11 @@ |
| 216669 | 217590 | unsigned int enc; /* Optimal text encoding */ |
| 216670 | 217591 | unsigned char iContext; /* sqlite3_user_data() context */ |
| 216671 | 217592 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**); |
| 216672 | 217593 | } scalars[] = { |
| 216673 | 217594 | {"icu_load_collation",2,SQLITE_UTF8|SQLITE_DIRECTONLY,1, icuLoadCollation}, |
| 217595 | + {"icu_load_collation",3,SQLITE_UTF8|SQLITE_DIRECTONLY,1, icuLoadCollation}, |
| 216674 | 217596 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) |
| 216675 | 217597 | {"regexp", 2, SQLITE_ANY|SQLITEICU_EXTRAFLAGS, 0, icuRegexpFunc}, |
| 216676 | 217598 | {"lower", 1, SQLITE_UTF16|SQLITEICU_EXTRAFLAGS, 0, icuCaseFunc16}, |
| 216677 | 217599 | {"lower", 2, SQLITE_UTF16|SQLITEICU_EXTRAFLAGS, 0, icuCaseFunc16}, |
| 216678 | 217600 | {"upper", 1, SQLITE_UTF16|SQLITEICU_EXTRAFLAGS, 1, icuCaseFunc16}, |
| | @@ -228072,18 +228994,18 @@ |
| 228072 | 228994 | ** sufficient either for the 'T' or 'P' byte and the varint that follows |
| 228073 | 228995 | ** it, or for the two single byte values otherwise. */ |
| 228074 | 228996 | p->rc = sessionInputBuffer(&p->in, 2); |
| 228075 | 228997 | if( p->rc!=SQLITE_OK ) return p->rc; |
| 228076 | 228998 | |
| 228999 | + sessionDiscardData(&p->in); |
| 229000 | + p->in.iCurrent = p->in.iNext; |
| 229001 | + |
| 228077 | 229002 | /* If the iterator is already at the end of the changeset, return DONE. */ |
| 228078 | 229003 | if( p->in.iNext>=p->in.nData ){ |
| 228079 | 229004 | return SQLITE_DONE; |
| 228080 | 229005 | } |
| 228081 | 229006 | |
| 228082 | | - sessionDiscardData(&p->in); |
| 228083 | | - p->in.iCurrent = p->in.iNext; |
| 228084 | | - |
| 228085 | 229007 | op = p->in.aData[p->in.iNext++]; |
| 228086 | 229008 | while( op=='T' || op=='P' ){ |
| 228087 | 229009 | if( pbNew ) *pbNew = 1; |
| 228088 | 229010 | p->bPatchset = (op=='P'); |
| 228089 | 229011 | if( sessionChangesetReadTblhdr(p) ) return p->rc; |
| | @@ -229814,10 +230736,11 @@ |
| 229814 | 230736 | */ |
| 229815 | 230737 | struct sqlite3_changegroup { |
| 229816 | 230738 | int rc; /* Error code */ |
| 229817 | 230739 | int bPatch; /* True to accumulate patchsets */ |
| 229818 | 230740 | SessionTable *pList; /* List of tables in current patch */ |
| 230741 | + SessionBuffer rec; |
| 229819 | 230742 | |
| 229820 | 230743 | sqlite3 *db; /* Configured by changegroup_schema() */ |
| 229821 | 230744 | char *zDb; /* Configured by changegroup_schema() */ |
| 229822 | 230745 | }; |
| 229823 | 230746 | |
| | @@ -230112,112 +231035,132 @@ |
| 230112 | 231035 | |
| 230113 | 231036 | return rc; |
| 230114 | 231037 | } |
| 230115 | 231038 | |
| 230116 | 231039 | /* |
| 230117 | | -** Add all changes in the changeset traversed by the iterator passed as |
| 230118 | | -** the first argument to the changegroup hash tables. |
| 231040 | +** Locate or create a SessionTable object that may be used to add the |
| 231041 | +** change currently pointed to by iterator pIter to changegroup pGrp. |
| 231042 | +** If successful, set output variable (*ppTab) to point to the table |
| 231043 | +** object and return SQLITE_OK. Otherwise, if some error occurs, return |
| 231044 | +** an SQLite error code and leave (*ppTab) set to NULL. |
| 230119 | 231045 | */ |
| 230120 | | -static int sessionChangesetToHash( |
| 230121 | | - sqlite3_changeset_iter *pIter, /* Iterator to read from */ |
| 230122 | | - sqlite3_changegroup *pGrp, /* Changegroup object to add changeset to */ |
| 230123 | | - int bRebase /* True if hash table is for rebasing */ |
| 231046 | +static int sessionChangesetFindTable( |
| 231047 | + sqlite3_changegroup *pGrp, |
| 231048 | + const char *zTab, |
| 231049 | + sqlite3_changeset_iter *pIter, |
| 231050 | + SessionTable **ppTab |
| 230124 | 231051 | ){ |
| 230125 | | - u8 *aRec; |
| 230126 | | - int nRec; |
| 230127 | 231052 | int rc = SQLITE_OK; |
| 231053 | + SessionTable *pTab = 0; |
| 231054 | + int nTab = (int)strlen(zTab); |
| 231055 | + u8 *abPK = 0; |
| 231056 | + int nCol = 0; |
| 231057 | + |
| 231058 | + *ppTab = 0; |
| 231059 | + sqlite3changeset_pk(pIter, &abPK, &nCol); |
| 231060 | + |
| 231061 | + /* Search the list for an existing table */ |
| 231062 | + for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){ |
| 231063 | + if( 0==sqlite3_strnicmp(pTab->zName, zTab, nTab+1) ) break; |
| 231064 | + } |
| 231065 | + |
| 231066 | + /* If one was not found above, create a new table now */ |
| 231067 | + if( !pTab ){ |
| 231068 | + SessionTable **ppNew; |
| 231069 | + |
| 231070 | + pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nTab+1); |
| 231071 | + if( !pTab ){ |
| 231072 | + return SQLITE_NOMEM; |
| 231073 | + } |
| 231074 | + memset(pTab, 0, sizeof(SessionTable)); |
| 231075 | + pTab->nCol = nCol; |
| 231076 | + pTab->abPK = (u8*)&pTab[1]; |
| 231077 | + memcpy(pTab->abPK, abPK, nCol); |
| 231078 | + pTab->zName = (char*)&pTab->abPK[nCol]; |
| 231079 | + memcpy(pTab->zName, zTab, nTab+1); |
| 231080 | + |
| 231081 | + if( pGrp->db ){ |
| 231082 | + pTab->nCol = 0; |
| 231083 | + rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); |
| 231084 | + if( rc ){ |
| 231085 | + assert( pTab->azCol==0 ); |
| 231086 | + sqlite3_free(pTab); |
| 231087 | + return rc; |
| 231088 | + } |
| 231089 | + } |
| 231090 | + |
| 231091 | + /* The new object must be linked on to the end of the list, not |
| 231092 | + ** simply added to the start of it. This is to ensure that the |
| 231093 | + ** tables within the output of sqlite3changegroup_output() are in |
| 231094 | + ** the right order. */ |
| 231095 | + for(ppNew=&pGrp->pList; *ppNew; ppNew=&(*ppNew)->pNext); |
| 231096 | + *ppNew = pTab; |
| 231097 | + } |
| 231098 | + |
| 231099 | + /* Check that the table is compatible. */ |
| 231100 | + if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ |
| 231101 | + rc = SQLITE_SCHEMA; |
| 231102 | + } |
| 231103 | + |
| 231104 | + *ppTab = pTab; |
| 231105 | + return rc; |
| 231106 | +} |
| 231107 | + |
| 231108 | +/* |
| 231109 | +** Add the change currently indicated by iterator pIter to the hash table |
| 231110 | +** belonging to changegroup pGrp. |
| 231111 | +*/ |
| 231112 | +static int sessionOneChangeToHash( |
| 231113 | + sqlite3_changegroup *pGrp, |
| 231114 | + sqlite3_changeset_iter *pIter, |
| 231115 | + int bRebase |
| 231116 | +){ |
| 231117 | + int rc = SQLITE_OK; |
| 231118 | + int nCol = 0; |
| 231119 | + int op = 0; |
| 231120 | + int iHash = 0; |
| 231121 | + int bIndirect = 0; |
| 231122 | + SessionChange *pChange = 0; |
| 231123 | + SessionChange *pExist = 0; |
| 231124 | + SessionChange **pp = 0; |
| 230128 | 231125 | SessionTable *pTab = 0; |
| 230129 | | - SessionBuffer rec = {0, 0, 0}; |
| 230130 | | - |
| 230131 | | - while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ |
| 230132 | | - const char *zNew; |
| 230133 | | - int nCol; |
| 230134 | | - int op; |
| 230135 | | - int iHash; |
| 230136 | | - int bIndirect; |
| 230137 | | - SessionChange *pChange; |
| 230138 | | - SessionChange *pExist = 0; |
| 230139 | | - SessionChange **pp; |
| 230140 | | - |
| 230141 | | - /* Ensure that only changesets, or only patchsets, but not a mixture |
| 230142 | | - ** of both, are being combined. It is an error to try to combine a |
| 230143 | | - ** changeset and a patchset. */ |
| 230144 | | - if( pGrp->pList==0 ){ |
| 230145 | | - pGrp->bPatch = pIter->bPatchset; |
| 230146 | | - }else if( pIter->bPatchset!=pGrp->bPatch ){ |
| 230147 | | - rc = SQLITE_ERROR; |
| 230148 | | - break; |
| 230149 | | - } |
| 230150 | | - |
| 230151 | | - sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect); |
| 230152 | | - if( !pTab || sqlite3_stricmp(zNew, pTab->zName) ){ |
| 230153 | | - /* Search the list for a matching table */ |
| 230154 | | - int nNew = (int)strlen(zNew); |
| 230155 | | - u8 *abPK; |
| 230156 | | - |
| 230157 | | - sqlite3changeset_pk(pIter, &abPK, 0); |
| 230158 | | - for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){ |
| 230159 | | - if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break; |
| 230160 | | - } |
| 230161 | | - if( !pTab ){ |
| 230162 | | - SessionTable **ppTab; |
| 230163 | | - |
| 230164 | | - pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nNew+1); |
| 230165 | | - if( !pTab ){ |
| 230166 | | - rc = SQLITE_NOMEM; |
| 230167 | | - break; |
| 230168 | | - } |
| 230169 | | - memset(pTab, 0, sizeof(SessionTable)); |
| 230170 | | - pTab->nCol = nCol; |
| 230171 | | - pTab->abPK = (u8*)&pTab[1]; |
| 230172 | | - memcpy(pTab->abPK, abPK, nCol); |
| 230173 | | - pTab->zName = (char*)&pTab->abPK[nCol]; |
| 230174 | | - memcpy(pTab->zName, zNew, nNew+1); |
| 230175 | | - |
| 230176 | | - if( pGrp->db ){ |
| 230177 | | - pTab->nCol = 0; |
| 230178 | | - rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); |
| 230179 | | - if( rc ){ |
| 230180 | | - assert( pTab->azCol==0 ); |
| 230181 | | - sqlite3_free(pTab); |
| 230182 | | - break; |
| 230183 | | - } |
| 230184 | | - } |
| 230185 | | - |
| 230186 | | - /* The new object must be linked on to the end of the list, not |
| 230187 | | - ** simply added to the start of it. This is to ensure that the |
| 230188 | | - ** tables within the output of sqlite3changegroup_output() are in |
| 230189 | | - ** the right order. */ |
| 230190 | | - for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); |
| 230191 | | - *ppTab = pTab; |
| 230192 | | - } |
| 230193 | | - |
| 230194 | | - if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ |
| 230195 | | - rc = SQLITE_SCHEMA; |
| 230196 | | - break; |
| 230197 | | - } |
| 230198 | | - } |
| 230199 | | - |
| 230200 | | - if( nCol<pTab->nCol ){ |
| 230201 | | - assert( pGrp->db ); |
| 230202 | | - rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec); |
| 230203 | | - if( rc ) break; |
| 230204 | | - aRec = rec.aBuf; |
| 230205 | | - nRec = rec.nBuf; |
| 230206 | | - } |
| 230207 | | - |
| 230208 | | - if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 230209 | | - rc = SQLITE_NOMEM; |
| 230210 | | - break; |
| 230211 | | - } |
| 231126 | + u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2]; |
| 231127 | + int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2; |
| 231128 | + |
| 231129 | + /* Ensure that only changesets, or only patchsets, but not a mixture |
| 231130 | + ** of both, are being combined. It is an error to try to combine a |
| 231131 | + ** changeset and a patchset. */ |
| 231132 | + if( pGrp->pList==0 ){ |
| 231133 | + pGrp->bPatch = pIter->bPatchset; |
| 231134 | + }else if( pIter->bPatchset!=pGrp->bPatch ){ |
| 231135 | + rc = SQLITE_ERROR; |
| 231136 | + } |
| 231137 | + |
| 231138 | + if( rc==SQLITE_OK ){ |
| 231139 | + const char *zTab = 0; |
| 231140 | + sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect); |
| 231141 | + rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab); |
| 231142 | + } |
| 231143 | + |
| 231144 | + if( rc==SQLITE_OK && nCol<pTab->nCol ){ |
| 231145 | + SessionBuffer *pBuf = &pGrp->rec; |
| 231146 | + rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, pBuf); |
| 231147 | + aRec = pBuf->aBuf; |
| 231148 | + nRec = pBuf->nBuf; |
| 231149 | + assert( pGrp->db ); |
| 231150 | + } |
| 231151 | + |
| 231152 | + if( rc==SQLITE_OK && sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 231153 | + rc = SQLITE_NOMEM; |
| 231154 | + } |
| 231155 | + |
| 231156 | + if( rc==SQLITE_OK ){ |
| 231157 | + /* Search for existing entry. If found, remove it from the hash table. |
| 231158 | + ** Code below may link it back in. */ |
| 230212 | 231159 | iHash = sessionChangeHash( |
| 230213 | 231160 | pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange |
| 230214 | 231161 | ); |
| 230215 | | - |
| 230216 | | - /* Search for existing entry. If found, remove it from the hash table. |
| 230217 | | - ** Code below may link it back in. |
| 230218 | | - */ |
| 230219 | 231162 | for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){ |
| 230220 | 231163 | int bPkOnly1 = 0; |
| 230221 | 231164 | int bPkOnly2 = 0; |
| 230222 | 231165 | if( pIter->bPatchset ){ |
| 230223 | 231166 | bPkOnly1 = (*pp)->op==SQLITE_DELETE; |
| | @@ -230228,23 +231171,45 @@ |
| 230228 | 231171 | *pp = (*pp)->pNext; |
| 230229 | 231172 | pTab->nEntry--; |
| 230230 | 231173 | break; |
| 230231 | 231174 | } |
| 230232 | 231175 | } |
| 231176 | + } |
| 230233 | 231177 | |
| 231178 | + if( rc==SQLITE_OK ){ |
| 230234 | 231179 | rc = sessionChangeMerge(pTab, bRebase, |
| 230235 | 231180 | pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange |
| 230236 | 231181 | ); |
| 230237 | | - if( rc ) break; |
| 230238 | | - if( pChange ){ |
| 230239 | | - pChange->pNext = pTab->apChange[iHash]; |
| 230240 | | - pTab->apChange[iHash] = pChange; |
| 230241 | | - pTab->nEntry++; |
| 230242 | | - } |
| 231182 | + } |
| 231183 | + if( rc==SQLITE_OK && pChange ){ |
| 231184 | + pChange->pNext = pTab->apChange[iHash]; |
| 231185 | + pTab->apChange[iHash] = pChange; |
| 231186 | + pTab->nEntry++; |
| 230243 | 231187 | } |
| 230244 | 231188 | |
| 230245 | | - sqlite3_free(rec.aBuf); |
| 231189 | + if( rc==SQLITE_OK ) rc = pIter->rc; |
| 231190 | + return rc; |
| 231191 | +} |
| 231192 | + |
| 231193 | +/* |
| 231194 | +** Add all changes in the changeset traversed by the iterator passed as |
| 231195 | +** the first argument to the changegroup hash tables. |
| 231196 | +*/ |
| 231197 | +static int sessionChangesetToHash( |
| 231198 | + sqlite3_changeset_iter *pIter, /* Iterator to read from */ |
| 231199 | + sqlite3_changegroup *pGrp, /* Changegroup object to add changeset to */ |
| 231200 | + int bRebase /* True if hash table is for rebasing */ |
| 231201 | +){ |
| 231202 | + u8 *aRec; |
| 231203 | + int nRec; |
| 231204 | + int rc = SQLITE_OK; |
| 231205 | + |
| 231206 | + while( SQLITE_ROW==(sessionChangesetNext(pIter, &aRec, &nRec, 0)) ){ |
| 231207 | + rc = sessionOneChangeToHash(pGrp, pIter, bRebase); |
| 231208 | + if( rc!=SQLITE_OK ) break; |
| 231209 | + } |
| 231210 | + |
| 230246 | 231211 | if( rc==SQLITE_OK ) rc = pIter->rc; |
| 230247 | 231212 | return rc; |
| 230248 | 231213 | } |
| 230249 | 231214 | |
| 230250 | 231215 | /* |
| | @@ -230367,10 +231332,27 @@ |
| 230367 | 231332 | rc = sessionChangesetToHash(pIter, pGrp, 0); |
| 230368 | 231333 | } |
| 230369 | 231334 | sqlite3changeset_finalize(pIter); |
| 230370 | 231335 | return rc; |
| 230371 | 231336 | } |
| 231337 | + |
| 231338 | +/* |
| 231339 | +** Add a single change to a changeset-group. |
| 231340 | +*/ |
| 231341 | +SQLITE_API int sqlite3changegroup_add_change( |
| 231342 | + sqlite3_changegroup *pGrp, |
| 231343 | + sqlite3_changeset_iter *pIter |
| 231344 | +){ |
| 231345 | + if( pIter->in.iCurrent==pIter->in.iNext |
| 231346 | + || pIter->rc!=SQLITE_OK |
| 231347 | + || pIter->bInvert |
| 231348 | + ){ |
| 231349 | + /* Iterator does not point to any valid entry or is an INVERT iterator. */ |
| 231350 | + return SQLITE_ERROR; |
| 231351 | + } |
| 231352 | + return sessionOneChangeToHash(pGrp, pIter, 0); |
| 231353 | +} |
| 230372 | 231354 | |
| 230373 | 231355 | /* |
| 230374 | 231356 | ** Obtain a buffer containing a changeset representing the concatenation |
| 230375 | 231357 | ** of all changesets added to the group so far. |
| 230376 | 231358 | */ |
| | @@ -230417,10 +231399,11 @@ |
| 230417 | 231399 | */ |
| 230418 | 231400 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ |
| 230419 | 231401 | if( pGrp ){ |
| 230420 | 231402 | sqlite3_free(pGrp->zDb); |
| 230421 | 231403 | sessionDeleteTable(0, pGrp->pList); |
| 231404 | + sqlite3_free(pGrp->rec.aBuf); |
| 230422 | 231405 | sqlite3_free(pGrp); |
| 230423 | 231406 | } |
| 230424 | 231407 | } |
| 230425 | 231408 | |
| 230426 | 231409 | /* |
| | @@ -230818,10 +231801,11 @@ |
| 230818 | 231801 | ** Destroy a rebaser object |
| 230819 | 231802 | */ |
| 230820 | 231803 | SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){ |
| 230821 | 231804 | if( p ){ |
| 230822 | 231805 | sessionDeleteTable(0, p->grp.pList); |
| 231806 | + sqlite3_free(p->grp.rec.aBuf); |
| 230823 | 231807 | sqlite3_free(p); |
| 230824 | 231808 | } |
| 230825 | 231809 | } |
| 230826 | 231810 | |
| 230827 | 231811 | /* |
| | @@ -230915,12 +231899,12 @@ |
| 230915 | 231899 | |
| 230916 | 231900 | /* |
| 230917 | 231901 | ** EXTENSION API FUNCTIONS |
| 230918 | 231902 | ** |
| 230919 | 231903 | ** xUserData(pFts): |
| 230920 | | -** Return a copy of the context pointer the extension function was |
| 230921 | | -** registered with. |
| 231904 | +** Return a copy of the pUserData pointer passed to the xCreateFunction() |
| 231905 | +** API when the extension function was registered. |
| 230922 | 231906 | ** |
| 230923 | 231907 | ** xColumnTotalSize(pFts, iCol, pnToken): |
| 230924 | 231908 | ** If parameter iCol is less than zero, set output variable *pnToken |
| 230925 | 231909 | ** to the total number of tokens in the FTS5 table. Or, if iCol is |
| 230926 | 231910 | ** non-negative but less than the number of columns in the table, return |
| | @@ -231097,10 +232081,14 @@ |
| 231097 | 232081 | ** This API can be quite slow if used with an FTS5 table created with the |
| 231098 | 232082 | ** "detail=none" or "detail=column" option. If the FTS5 table is created |
| 231099 | 232083 | ** with either "detail=none" or "detail=column" and "content=" option |
| 231100 | 232084 | ** (i.e. if it is a contentless table), then this API always iterates |
| 231101 | 232085 | ** through an empty set (all calls to xPhraseFirst() set iCol to -1). |
| 232086 | +** |
| 232087 | +** In all cases, matches are visited in (column ASC, offset ASC) order. |
| 232088 | +** i.e. all those in column 0, sorted by offset, followed by those in |
| 232089 | +** column 1, etc. |
| 231102 | 232090 | ** |
| 231103 | 232091 | ** xPhraseNext() |
| 231104 | 232092 | ** See xPhraseFirst above. |
| 231105 | 232093 | ** |
| 231106 | 232094 | ** xPhraseFirstColumn() |
| | @@ -231628,10 +232616,19 @@ |
| 231628 | 232616 | ** Interface to code in fts5_config.c. fts5_config.c contains contains code |
| 231629 | 232617 | ** to parse the arguments passed to the CREATE VIRTUAL TABLE statement. |
| 231630 | 232618 | */ |
| 231631 | 232619 | |
| 231632 | 232620 | typedef struct Fts5Config Fts5Config; |
| 232621 | +typedef struct Fts5TokenizerConfig Fts5TokenizerConfig; |
| 232622 | + |
| 232623 | +struct Fts5TokenizerConfig { |
| 232624 | + Fts5Tokenizer *pTok; |
| 232625 | + fts5_tokenizer *pTokApi; |
| 232626 | + const char **azArg; |
| 232627 | + int nArg; |
| 232628 | + int ePattern; /* FTS_PATTERN_XXX constant */ |
| 232629 | +}; |
| 231633 | 232630 | |
| 231634 | 232631 | /* |
| 231635 | 232632 | ** An instance of the following structure encodes all information that can |
| 231636 | 232633 | ** be gleaned from the CREATE VIRTUAL TABLE statement. |
| 231637 | 232634 | ** |
| | @@ -231670,10 +232667,11 @@ |
| 231670 | 232667 | ** INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex); |
| 231671 | 232668 | ** |
| 231672 | 232669 | */ |
| 231673 | 232670 | struct Fts5Config { |
| 231674 | 232671 | sqlite3 *db; /* Database handle */ |
| 232672 | + Fts5Global *pGlobal; /* Global fts5 object for handle db */ |
| 231675 | 232673 | char *zDb; /* Database holding FTS index (e.g. "main") */ |
| 231676 | 232674 | char *zName; /* Name of FTS index */ |
| 231677 | 232675 | int nCol; /* Number of columns */ |
| 231678 | 232676 | char **azCol; /* Column names */ |
| 231679 | 232677 | u8 *abUnindexed; /* True for unindexed columns */ |
| | @@ -231685,14 +232683,12 @@ |
| 231685 | 232683 | char *zContentRowid; /* "content_rowid=" option value */ |
| 231686 | 232684 | int bColumnsize; /* "columnsize=" option value (dflt==1) */ |
| 231687 | 232685 | int bTokendata; /* "tokendata=" option value (dflt==0) */ |
| 231688 | 232686 | int eDetail; /* FTS5_DETAIL_XXX value */ |
| 231689 | 232687 | char *zContentExprlist; |
| 231690 | | - Fts5Tokenizer *pTok; |
| 231691 | | - fts5_tokenizer *pTokApi; |
| 232688 | + Fts5TokenizerConfig t; |
| 231692 | 232689 | int bLock; /* True when table is preparing statement */ |
| 231693 | | - int ePattern; /* FTS_PATTERN_XXX constant */ |
| 231694 | 232690 | |
| 231695 | 232691 | /* Values loaded from the %_config table */ |
| 231696 | 232692 | int iVersion; /* fts5 file format 'version' */ |
| 231697 | 232693 | int iCookie; /* Incremented when %_config is modified */ |
| 231698 | 232694 | int pgsz; /* Approximate page size used in %_data */ |
| | @@ -232083,17 +233079,11 @@ |
| 232083 | 233079 | sqlite3_vtab base; /* Base class used by SQLite core */ |
| 232084 | 233080 | Fts5Config *pConfig; /* Virtual table configuration */ |
| 232085 | 233081 | Fts5Index *pIndex; /* Full-text index */ |
| 232086 | 233082 | }; |
| 232087 | 233083 | |
| 232088 | | -static int sqlite3Fts5GetTokenizer( |
| 232089 | | - Fts5Global*, |
| 232090 | | - const char **azArg, |
| 232091 | | - int nArg, |
| 232092 | | - Fts5Config*, |
| 232093 | | - char **pzErr |
| 232094 | | -); |
| 233084 | +static int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig); |
| 232095 | 233085 | |
| 232096 | 233086 | static Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64); |
| 232097 | 233087 | |
| 232098 | 233088 | static int sqlite3Fts5FlushToDisk(Fts5Table*); |
| 232099 | 233089 | |
| | @@ -232352,10 +233342,11 @@ |
| 232352 | 233342 | static int sqlite3Fts5TokenizerInit(fts5_api*); |
| 232353 | 233343 | static int sqlite3Fts5TokenizerPattern( |
| 232354 | 233344 | int (*xCreate)(void*, const char**, int, Fts5Tokenizer**), |
| 232355 | 233345 | Fts5Tokenizer *pTok |
| 232356 | 233346 | ); |
| 233347 | +static int sqlite3Fts5TokenizerPreload(Fts5TokenizerConfig*); |
| 232357 | 233348 | /* |
| 232358 | 233349 | ** End of interface to code in fts5_tokenizer.c. |
| 232359 | 233350 | **************************************************************************/ |
| 232360 | 233351 | |
| 232361 | 233352 | /************************************************************************** |
| | @@ -235303,11 +236294,10 @@ |
| 235303 | 236294 | ** an error occurs, an SQLite error code is returned and an error message |
| 235304 | 236295 | ** may be left in *pzErr. It is the responsibility of the caller to |
| 235305 | 236296 | ** eventually free any such error message using sqlite3_free(). |
| 235306 | 236297 | */ |
| 235307 | 236298 | static int fts5ConfigParseSpecial( |
| 235308 | | - Fts5Global *pGlobal, |
| 235309 | 236299 | Fts5Config *pConfig, /* Configuration object to update */ |
| 235310 | 236300 | const char *zCmd, /* Special command to parse */ |
| 235311 | 236301 | const char *zArg, /* Argument to parse */ |
| 235312 | 236302 | char **pzErr /* OUT: Error message */ |
| 235313 | 236303 | ){ |
| | @@ -235367,16 +236357,15 @@ |
| 235367 | 236357 | } |
| 235368 | 236358 | |
| 235369 | 236359 | if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){ |
| 235370 | 236360 | const char *p = (const char*)zArg; |
| 235371 | 236361 | sqlite3_int64 nArg = strlen(zArg) + 1; |
| 235372 | | - char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg); |
| 235373 | | - char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2); |
| 235374 | | - char *pSpace = pDel; |
| 236362 | + char **azArg = sqlite3Fts5MallocZero(&rc, (sizeof(char*) + 2) * nArg); |
| 235375 | 236363 | |
| 235376 | | - if( azArg && pSpace ){ |
| 235377 | | - if( pConfig->pTok ){ |
| 236364 | + if( azArg ){ |
| 236365 | + char *pSpace = (char*)&azArg[nArg]; |
| 236366 | + if( pConfig->t.azArg ){ |
| 235378 | 236367 | *pzErr = sqlite3_mprintf("multiple tokenize=... directives"); |
| 235379 | 236368 | rc = SQLITE_ERROR; |
| 235380 | 236369 | }else{ |
| 235381 | 236370 | for(nArg=0; p && *p; nArg++){ |
| 235382 | 236371 | const char *p2 = fts5ConfigSkipWhitespace(p); |
| | @@ -235395,20 +236384,18 @@ |
| 235395 | 236384 | } |
| 235396 | 236385 | if( p==0 ){ |
| 235397 | 236386 | *pzErr = sqlite3_mprintf("parse error in tokenize directive"); |
| 235398 | 236387 | rc = SQLITE_ERROR; |
| 235399 | 236388 | }else{ |
| 235400 | | - rc = sqlite3Fts5GetTokenizer(pGlobal, |
| 235401 | | - (const char**)azArg, (int)nArg, pConfig, |
| 235402 | | - pzErr |
| 235403 | | - ); |
| 236389 | + pConfig->t.azArg = (const char**)azArg; |
| 236390 | + pConfig->t.nArg = nArg; |
| 236391 | + azArg = 0; |
| 235404 | 236392 | } |
| 235405 | 236393 | } |
| 235406 | 236394 | } |
| 235407 | | - |
| 235408 | 236395 | sqlite3_free(azArg); |
| 235409 | | - sqlite3_free(pDel); |
| 236396 | + |
| 235410 | 236397 | return rc; |
| 235411 | 236398 | } |
| 235412 | 236399 | |
| 235413 | 236400 | if( sqlite3_strnicmp("content", zCmd, nCmd)==0 ){ |
| 235414 | 236401 | if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){ |
| | @@ -235481,20 +236468,10 @@ |
| 235481 | 236468 | |
| 235482 | 236469 | *pzErr = sqlite3_mprintf("unrecognized option: \"%.*s\"", nCmd, zCmd); |
| 235483 | 236470 | return SQLITE_ERROR; |
| 235484 | 236471 | } |
| 235485 | 236472 | |
| 235486 | | -/* |
| 235487 | | -** Allocate an instance of the default tokenizer ("simple") at |
| 235488 | | -** Fts5Config.pTokenizer. Return SQLITE_OK if successful, or an SQLite error |
| 235489 | | -** code if an error occurs. |
| 235490 | | -*/ |
| 235491 | | -static int fts5ConfigDefaultTokenizer(Fts5Global *pGlobal, Fts5Config *pConfig){ |
| 235492 | | - assert( pConfig->pTok==0 && pConfig->pTokApi==0 ); |
| 235493 | | - return sqlite3Fts5GetTokenizer(pGlobal, 0, 0, pConfig, 0); |
| 235494 | | -} |
| 235495 | | - |
| 235496 | 236473 | /* |
| 235497 | 236474 | ** Gobble up the first bareword or quoted word from the input buffer zIn. |
| 235498 | 236475 | ** Return a pointer to the character immediately following the last in |
| 235499 | 236476 | ** the gobbled word if successful, or a NULL pointer otherwise (failed |
| 235500 | 236477 | ** to find close-quote character). |
| | @@ -235623,10 +236600,11 @@ |
| 235623 | 236600 | sqlite3_int64 nByte; |
| 235624 | 236601 | |
| 235625 | 236602 | *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config)); |
| 235626 | 236603 | if( pRet==0 ) return SQLITE_NOMEM; |
| 235627 | 236604 | memset(pRet, 0, sizeof(Fts5Config)); |
| 236605 | + pRet->pGlobal = pGlobal; |
| 235628 | 236606 | pRet->db = db; |
| 235629 | 236607 | pRet->iCookie = -1; |
| 235630 | 236608 | |
| 235631 | 236609 | nByte = nArg * (sizeof(char*) + sizeof(u8)); |
| 235632 | 236610 | pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte); |
| | @@ -235671,11 +236649,11 @@ |
| 235671 | 236649 | if( z==0 ){ |
| 235672 | 236650 | *pzErr = sqlite3_mprintf("parse error in \"%s\"", zOrig); |
| 235673 | 236651 | rc = SQLITE_ERROR; |
| 235674 | 236652 | }else{ |
| 235675 | 236653 | if( bOption ){ |
| 235676 | | - rc = fts5ConfigParseSpecial(pGlobal, pRet, |
| 236654 | + rc = fts5ConfigParseSpecial(pRet, |
| 235677 | 236655 | ALWAYS(zOne)?zOne:"", |
| 235678 | 236656 | zTwo?zTwo:"", |
| 235679 | 236657 | pzErr |
| 235680 | 236658 | ); |
| 235681 | 236659 | }else{ |
| | @@ -235709,17 +236687,10 @@ |
| 235709 | 236687 | "contentless_delete=1 is incompatible with columnsize=0" |
| 235710 | 236688 | ); |
| 235711 | 236689 | rc = SQLITE_ERROR; |
| 235712 | 236690 | } |
| 235713 | 236691 | |
| 235714 | | - /* If a tokenizer= option was successfully parsed, the tokenizer has |
| 235715 | | - ** already been allocated. Otherwise, allocate an instance of the default |
| 235716 | | - ** tokenizer (unicode61) now. */ |
| 235717 | | - if( rc==SQLITE_OK && pRet->pTok==0 ){ |
| 235718 | | - rc = fts5ConfigDefaultTokenizer(pGlobal, pRet); |
| 235719 | | - } |
| 235720 | | - |
| 235721 | 236692 | /* If no zContent option was specified, fill in the default values. */ |
| 235722 | 236693 | if( rc==SQLITE_OK && pRet->zContent==0 ){ |
| 235723 | 236694 | const char *zTail = 0; |
| 235724 | 236695 | assert( pRet->eContent==FTS5_CONTENT_NORMAL |
| 235725 | 236696 | || pRet->eContent==FTS5_CONTENT_NONE |
| | @@ -235757,13 +236728,14 @@ |
| 235757 | 236728 | ** Free the configuration object passed as the only argument. |
| 235758 | 236729 | */ |
| 235759 | 236730 | static void sqlite3Fts5ConfigFree(Fts5Config *pConfig){ |
| 235760 | 236731 | if( pConfig ){ |
| 235761 | 236732 | int i; |
| 235762 | | - if( pConfig->pTok ){ |
| 235763 | | - pConfig->pTokApi->xDelete(pConfig->pTok); |
| 236733 | + if( pConfig->t.pTok ){ |
| 236734 | + pConfig->t.pTokApi->xDelete(pConfig->t.pTok); |
| 235764 | 236735 | } |
| 236736 | + sqlite3_free((char*)pConfig->t.azArg); |
| 235765 | 236737 | sqlite3_free(pConfig->zDb); |
| 235766 | 236738 | sqlite3_free(pConfig->zName); |
| 235767 | 236739 | for(i=0; i<pConfig->nCol; i++){ |
| 235768 | 236740 | sqlite3_free(pConfig->azCol[i]); |
| 235769 | 236741 | } |
| | @@ -235834,14 +236806,22 @@ |
| 235834 | 236806 | int flags, /* FTS5_TOKENIZE_* flags */ |
| 235835 | 236807 | const char *pText, int nText, /* Text to tokenize */ |
| 235836 | 236808 | void *pCtx, /* Context passed to xToken() */ |
| 235837 | 236809 | int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ |
| 235838 | 236810 | ){ |
| 235839 | | - if( pText==0 ) return SQLITE_OK; |
| 235840 | | - return pConfig->pTokApi->xTokenize( |
| 235841 | | - pConfig->pTok, pCtx, flags, pText, nText, xToken |
| 235842 | | - ); |
| 236811 | + int rc = SQLITE_OK; |
| 236812 | + if( pText ){ |
| 236813 | + if( pConfig->t.pTok==0 ){ |
| 236814 | + rc = sqlite3Fts5LoadTokenizer(pConfig); |
| 236815 | + } |
| 236816 | + if( rc==SQLITE_OK ){ |
| 236817 | + rc = pConfig->t.pTokApi->xTokenize( |
| 236818 | + pConfig->t.pTok, pCtx, flags, pText, nText, xToken |
| 236819 | + ); |
| 236820 | + } |
| 236821 | + } |
| 236822 | + return rc; |
| 235843 | 236823 | } |
| 235844 | 236824 | |
| 235845 | 236825 | /* |
| 235846 | 236826 | ** Argument pIn points to the first character in what is expected to be |
| 235847 | 236827 | ** a comma-separated list of SQL literals followed by a ')' character. |
| | @@ -236434,11 +237414,15 @@ |
| 236434 | 237414 | }else{ |
| 236435 | 237415 | sqlite3Fts5ParseNodeFree(sParse.pExpr); |
| 236436 | 237416 | } |
| 236437 | 237417 | |
| 236438 | 237418 | sqlite3_free(sParse.apPhrase); |
| 236439 | | - *pzErr = sParse.zErr; |
| 237419 | + if( 0==*pzErr ){ |
| 237420 | + *pzErr = sParse.zErr; |
| 237421 | + }else{ |
| 237422 | + sqlite3_free(sParse.zErr); |
| 237423 | + } |
| 236440 | 237424 | return sParse.rc; |
| 236441 | 237425 | } |
| 236442 | 237426 | |
| 236443 | 237427 | /* |
| 236444 | 237428 | ** Assuming that buffer z is at least nByte bytes in size and contains a |
| | @@ -237981,10 +238965,11 @@ |
| 237981 | 238965 | ** no token characters at all. (e.g ... MATCH '""'). */ |
| 237982 | 238966 | sCtx.pPhrase = sqlite3Fts5MallocZero(&pParse->rc, sizeof(Fts5ExprPhrase)); |
| 237983 | 238967 | }else if( sCtx.pPhrase->nTerm ){ |
| 237984 | 238968 | sCtx.pPhrase->aTerm[sCtx.pPhrase->nTerm-1].bPrefix = (u8)bPrefix; |
| 237985 | 238969 | } |
| 238970 | + assert( pParse->apPhrase!=0 ); |
| 237986 | 238971 | pParse->apPhrase[pParse->nPhrase-1] = sCtx.pPhrase; |
| 237987 | 238972 | } |
| 237988 | 238973 | |
| 237989 | 238974 | return sCtx.pPhrase; |
| 237990 | 238975 | } |
| | @@ -238000,11 +238985,11 @@ |
| 238000 | 238985 | ){ |
| 238001 | 238986 | int rc = SQLITE_OK; /* Return code */ |
| 238002 | 238987 | Fts5ExprPhrase *pOrig = 0; /* The phrase extracted from pExpr */ |
| 238003 | 238988 | Fts5Expr *pNew = 0; /* Expression to return via *ppNew */ |
| 238004 | 238989 | TokenCtx sCtx = {0,0,0}; /* Context object for fts5ParseTokenize */ |
| 238005 | | - if( iPhrase<0 || iPhrase>=pExpr->nPhrase ){ |
| 238990 | + if( !pExpr || iPhrase<0 || iPhrase>=pExpr->nPhrase ){ |
| 238006 | 238991 | rc = SQLITE_RANGE; |
| 238007 | 238992 | }else{ |
| 238008 | 238993 | pOrig = pExpr->apExprPhrase[iPhrase]; |
| 238009 | 238994 | pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr)); |
| 238010 | 238995 | } |
| | @@ -238575,10 +239560,12 @@ |
| 238575 | 239560 | || pPrev->eType==FTS5_TERM |
| 238576 | 239561 | || pPrev->eType==FTS5_EOF |
| 238577 | 239562 | ); |
| 238578 | 239563 | |
| 238579 | 239564 | if( pRight->eType==FTS5_EOF ){ |
| 239565 | + assert( pParse->apPhrase!=0 ); |
| 239566 | + assert( pParse->nPhrase>0 ); |
| 238580 | 239567 | assert( pParse->apPhrase[pParse->nPhrase-1]==pRight->pNear->apPhrase[0] ); |
| 238581 | 239568 | sqlite3Fts5ParseNodeFree(pRight); |
| 238582 | 239569 | pRet = pLeft; |
| 238583 | 239570 | pParse->nPhrase--; |
| 238584 | 239571 | } |
| | @@ -249406,12 +250393,16 @@ |
| 249406 | 250393 | if( rc==SQLITE_OK ){ |
| 249407 | 250394 | rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr); |
| 249408 | 250395 | assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 ); |
| 249409 | 250396 | } |
| 249410 | 250397 | if( rc==SQLITE_OK ){ |
| 250398 | + pConfig->pzErrmsg = pzErr; |
| 249411 | 250399 | pTab->p.pConfig = pConfig; |
| 249412 | 250400 | pTab->pGlobal = pGlobal; |
| 250401 | + if( bCreate || sqlite3Fts5TokenizerPreload(&pConfig->t) ){ |
| 250402 | + rc = sqlite3Fts5LoadTokenizer(pConfig); |
| 250403 | + } |
| 249413 | 250404 | } |
| 249414 | 250405 | |
| 249415 | 250406 | /* Open the index sub-system */ |
| 249416 | 250407 | if( rc==SQLITE_OK ){ |
| 249417 | 250408 | rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->p.pIndex, pzErr); |
| | @@ -249429,24 +250420,22 @@ |
| 249429 | 250420 | rc = sqlite3Fts5ConfigDeclareVtab(pConfig); |
| 249430 | 250421 | } |
| 249431 | 250422 | |
| 249432 | 250423 | /* Load the initial configuration */ |
| 249433 | 250424 | if( rc==SQLITE_OK ){ |
| 249434 | | - assert( pConfig->pzErrmsg==0 ); |
| 249435 | | - pConfig->pzErrmsg = pzErr; |
| 249436 | 250425 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 249437 | 250426 | sqlite3Fts5IndexRollback(pTab->p.pIndex); |
| 249438 | | - pConfig->pzErrmsg = 0; |
| 249439 | 250427 | } |
| 249440 | 250428 | |
| 249441 | 250429 | if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
| 249442 | 250430 | rc = sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, (int)1); |
| 249443 | 250431 | } |
| 249444 | 250432 | if( rc==SQLITE_OK ){ |
| 249445 | 250433 | rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); |
| 249446 | 250434 | } |
| 249447 | 250435 | |
| 250436 | + if( pConfig ) pConfig->pzErrmsg = 0; |
| 249448 | 250437 | if( rc!=SQLITE_OK ){ |
| 249449 | 250438 | fts5FreeVtab(pTab); |
| 249450 | 250439 | pTab = 0; |
| 249451 | 250440 | }else if( bCreate ){ |
| 249452 | 250441 | fts5CheckTransactionState(pTab, FTS5_BEGIN, 0); |
| | @@ -249510,14 +250499,14 @@ |
| 249510 | 250499 | Fts5Config *pConfig, |
| 249511 | 250500 | struct sqlite3_index_constraint *p |
| 249512 | 250501 | ){ |
| 249513 | 250502 | assert( FTS5_PATTERN_GLOB==SQLITE_INDEX_CONSTRAINT_GLOB ); |
| 249514 | 250503 | assert( FTS5_PATTERN_LIKE==SQLITE_INDEX_CONSTRAINT_LIKE ); |
| 249515 | | - if( pConfig->ePattern==FTS5_PATTERN_GLOB && p->op==FTS5_PATTERN_GLOB ){ |
| 250504 | + if( pConfig->t.ePattern==FTS5_PATTERN_GLOB && p->op==FTS5_PATTERN_GLOB ){ |
| 249516 | 250505 | return 1; |
| 249517 | 250506 | } |
| 249518 | | - if( pConfig->ePattern==FTS5_PATTERN_LIKE |
| 250507 | + if( pConfig->t.ePattern==FTS5_PATTERN_LIKE |
| 249519 | 250508 | && (p->op==FTS5_PATTERN_LIKE || p->op==FTS5_PATTERN_GLOB) |
| 249520 | 250509 | ){ |
| 249521 | 250510 | return 1; |
| 249522 | 250511 | } |
| 249523 | 250512 | return 0; |
| | @@ -249560,15 +250549,15 @@ |
| 249560 | 250549 | ** A > or >= against the rowid: ">" |
| 249561 | 250550 | ** |
| 249562 | 250551 | ** This function ensures that there is at most one "r" or "=". And that if |
| 249563 | 250552 | ** there exists an "=" then there is no "<" or ">". |
| 249564 | 250553 | ** |
| 250554 | +** If an unusable MATCH operator is present in the WHERE clause, then |
| 250555 | +** SQLITE_CONSTRAINT is returned. |
| 250556 | +** |
| 249565 | 250557 | ** Costs are assigned as follows: |
| 249566 | 250558 | ** |
| 249567 | | -** a) If an unusable MATCH operator is present in the WHERE clause, the |
| 249568 | | -** cost is unconditionally set to 1e50 (a really big number). |
| 249569 | | -** |
| 249570 | 250559 | ** a) If a MATCH operator is present, the cost depends on the other |
| 249571 | 250560 | ** constraints also present. As follows: |
| 249572 | 250561 | ** |
| 249573 | 250562 | ** * No other constraints: cost=1000.0 |
| 249574 | 250563 | ** * One rowid range constraint: cost=750.0 |
| | @@ -249596,11 +250585,11 @@ |
| 249596 | 250585 | int iCons = 0; |
| 249597 | 250586 | |
| 249598 | 250587 | int bSeenEq = 0; |
| 249599 | 250588 | int bSeenGt = 0; |
| 249600 | 250589 | int bSeenLt = 0; |
| 249601 | | - int bSeenMatch = 0; |
| 250590 | + int nSeenMatch = 0; |
| 249602 | 250591 | int bSeenRank = 0; |
| 249603 | 250592 | |
| 249604 | 250593 | |
| 249605 | 250594 | assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH ); |
| 249606 | 250595 | assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH ); |
| | @@ -249627,22 +250616,19 @@ |
| 249627 | 250616 | || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol>=nCol) |
| 249628 | 250617 | ){ |
| 249629 | 250618 | /* A MATCH operator or equivalent */ |
| 249630 | 250619 | if( p->usable==0 || iCol<0 ){ |
| 249631 | 250620 | /* As there exists an unusable MATCH constraint this is an |
| 249632 | | - ** unusable plan. Set a prohibitively high cost. */ |
| 249633 | | - pInfo->estimatedCost = 1e50; |
| 249634 | | - assert( iIdxStr < pInfo->nConstraint*6 + 1 ); |
| 249635 | | - idxStr[iIdxStr] = 0; |
| 249636 | | - return SQLITE_OK; |
| 250621 | + ** unusable plan. Return SQLITE_CONSTRAINT. */ |
| 250622 | + return SQLITE_CONSTRAINT; |
| 249637 | 250623 | }else{ |
| 249638 | 250624 | if( iCol==nCol+1 ){ |
| 249639 | 250625 | if( bSeenRank ) continue; |
| 249640 | 250626 | idxStr[iIdxStr++] = 'r'; |
| 249641 | 250627 | bSeenRank = 1; |
| 249642 | 250628 | }else if( iCol>=0 ){ |
| 249643 | | - bSeenMatch = 1; |
| 250629 | + nSeenMatch++; |
| 249644 | 250630 | idxStr[iIdxStr++] = 'M'; |
| 249645 | 250631 | sqlite3_snprintf(6, &idxStr[iIdxStr], "%d", iCol); |
| 249646 | 250632 | idxStr += strlen(&idxStr[iIdxStr]); |
| 249647 | 250633 | assert( idxStr[iIdxStr]=='\0' ); |
| 249648 | 250634 | } |
| | @@ -249655,10 +250641,11 @@ |
| 249655 | 250641 | idxStr[iIdxStr++] = p->op==FTS5_PATTERN_LIKE ? 'L' : 'G'; |
| 249656 | 250642 | sqlite3_snprintf(6, &idxStr[iIdxStr], "%d", iCol); |
| 249657 | 250643 | idxStr += strlen(&idxStr[iIdxStr]); |
| 249658 | 250644 | pInfo->aConstraintUsage[i].argvIndex = ++iCons; |
| 249659 | 250645 | assert( idxStr[iIdxStr]=='\0' ); |
| 250646 | + nSeenMatch++; |
| 249660 | 250647 | }else if( bSeenEq==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol<0 ){ |
| 249661 | 250648 | idxStr[iIdxStr++] = '='; |
| 249662 | 250649 | bSeenEq = 1; |
| 249663 | 250650 | pInfo->aConstraintUsage[i].argvIndex = ++iCons; |
| 249664 | 250651 | } |
| | @@ -249691,11 +250678,11 @@ |
| 249691 | 250678 | ** |
| 249692 | 250679 | ** Note that tokendata=1 tables cannot currently handle "ORDER BY rowid DESC". |
| 249693 | 250680 | */ |
| 249694 | 250681 | if( pInfo->nOrderBy==1 ){ |
| 249695 | 250682 | int iSort = pInfo->aOrderBy[0].iColumn; |
| 249696 | | - if( iSort==(pConfig->nCol+1) && bSeenMatch ){ |
| 250683 | + if( iSort==(pConfig->nCol+1) && nSeenMatch>0 ){ |
| 249697 | 250684 | idxFlags |= FTS5_BI_ORDER_RANK; |
| 249698 | 250685 | }else if( iSort==-1 && (!pInfo->aOrderBy[0].desc || !pConfig->bTokendata) ){ |
| 249699 | 250686 | idxFlags |= FTS5_BI_ORDER_ROWID; |
| 249700 | 250687 | } |
| 249701 | 250688 | if( BitFlagTest(idxFlags, FTS5_BI_ORDER_RANK|FTS5_BI_ORDER_ROWID) ){ |
| | @@ -249706,18 +250693,21 @@ |
| 249706 | 250693 | } |
| 249707 | 250694 | } |
| 249708 | 250695 | |
| 249709 | 250696 | /* Calculate the estimated cost based on the flags set in idxFlags. */ |
| 249710 | 250697 | if( bSeenEq ){ |
| 249711 | | - pInfo->estimatedCost = bSeenMatch ? 100.0 : 10.0; |
| 249712 | | - if( bSeenMatch==0 ) fts5SetUniqueFlag(pInfo); |
| 250698 | + pInfo->estimatedCost = nSeenMatch ? 1000.0 : 10.0; |
| 250699 | + if( nSeenMatch==0 ) fts5SetUniqueFlag(pInfo); |
| 249713 | 250700 | }else if( bSeenLt && bSeenGt ){ |
| 249714 | | - pInfo->estimatedCost = bSeenMatch ? 500.0 : 250000.0; |
| 250701 | + pInfo->estimatedCost = nSeenMatch ? 5000.0 : 250000.0; |
| 249715 | 250702 | }else if( bSeenLt || bSeenGt ){ |
| 249716 | | - pInfo->estimatedCost = bSeenMatch ? 750.0 : 750000.0; |
| 250703 | + pInfo->estimatedCost = nSeenMatch ? 7500.0 : 750000.0; |
| 249717 | 250704 | }else{ |
| 249718 | | - pInfo->estimatedCost = bSeenMatch ? 1000.0 : 1000000.0; |
| 250705 | + pInfo->estimatedCost = nSeenMatch ? 10000.0 : 1000000.0; |
| 250706 | + } |
| 250707 | + for(i=1; i<nSeenMatch; i++){ |
| 250708 | + pInfo->estimatedCost *= 0.4; |
| 249719 | 250709 | } |
| 249720 | 250710 | |
| 249721 | 250711 | pInfo->idxNum = idxFlags; |
| 249722 | 250712 | return SQLITE_OK; |
| 249723 | 250713 | } |
| | @@ -249989,10 +250979,11 @@ |
| 249989 | 250979 | "%s", sqlite3_errmsg(pConfig->db) |
| 249990 | 250980 | ); |
| 249991 | 250981 | } |
| 249992 | 250982 | }else{ |
| 249993 | 250983 | rc = SQLITE_OK; |
| 250984 | + CsrFlagSet(pCsr, FTS5CSR_REQUIRE_DOCSIZE); |
| 249994 | 250985 | } |
| 249995 | 250986 | break; |
| 249996 | 250987 | } |
| 249997 | 250988 | } |
| 249998 | 250989 | } |
| | @@ -250462,13 +251453,17 @@ |
| 250462 | 251453 | */ |
| 250463 | 251454 | static i64 fts5CursorRowid(Fts5Cursor *pCsr){ |
| 250464 | 251455 | assert( pCsr->ePlan==FTS5_PLAN_MATCH |
| 250465 | 251456 | || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH |
| 250466 | 251457 | || pCsr->ePlan==FTS5_PLAN_SOURCE |
| 251458 | + || pCsr->ePlan==FTS5_PLAN_SCAN |
| 251459 | + || pCsr->ePlan==FTS5_PLAN_ROWID |
| 250467 | 251460 | ); |
| 250468 | 251461 | if( pCsr->pSorter ){ |
| 250469 | 251462 | return pCsr->pSorter->iRowid; |
| 251463 | + }else if( pCsr->ePlan>=FTS5_PLAN_SCAN ){ |
| 251464 | + return sqlite3_column_int64(pCsr->pStmt, 0); |
| 250470 | 251465 | }else{ |
| 250471 | 251466 | return sqlite3Fts5ExprRowid(pCsr->pExpr); |
| 250472 | 251467 | } |
| 250473 | 251468 | } |
| 250474 | 251469 | |
| | @@ -250481,24 +251476,14 @@ |
| 250481 | 251476 | static int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ |
| 250482 | 251477 | Fts5Cursor *pCsr = (Fts5Cursor*)pCursor; |
| 250483 | 251478 | int ePlan = pCsr->ePlan; |
| 250484 | 251479 | |
| 250485 | 251480 | assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 ); |
| 250486 | | - switch( ePlan ){ |
| 250487 | | - case FTS5_PLAN_SPECIAL: |
| 250488 | | - *pRowid = 0; |
| 250489 | | - break; |
| 250490 | | - |
| 250491 | | - case FTS5_PLAN_SOURCE: |
| 250492 | | - case FTS5_PLAN_MATCH: |
| 250493 | | - case FTS5_PLAN_SORTED_MATCH: |
| 250494 | | - *pRowid = fts5CursorRowid(pCsr); |
| 250495 | | - break; |
| 250496 | | - |
| 250497 | | - default: |
| 250498 | | - *pRowid = sqlite3_column_int64(pCsr->pStmt, 0); |
| 250499 | | - break; |
| 251481 | + if( ePlan==FTS5_PLAN_SPECIAL ){ |
| 251482 | + *pRowid = 0; |
| 251483 | + }else{ |
| 251484 | + *pRowid = fts5CursorRowid(pCsr); |
| 250500 | 251485 | } |
| 250501 | 251486 | |
| 250502 | 251487 | return SQLITE_OK; |
| 250503 | 251488 | } |
| 250504 | 251489 | |
| | @@ -250729,10 +251714,11 @@ |
| 250729 | 251714 | "'delete' may not be used with a contentless_delete=1 table" |
| 250730 | 251715 | ); |
| 250731 | 251716 | rc = SQLITE_ERROR; |
| 250732 | 251717 | }else{ |
| 250733 | 251718 | rc = fts5SpecialDelete(pTab, apVal); |
| 251719 | + bUpdateOrDelete = 1; |
| 250734 | 251720 | } |
| 250735 | 251721 | }else{ |
| 250736 | 251722 | rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]); |
| 250737 | 251723 | } |
| 250738 | 251724 | }else{ |
| | @@ -251889,11 +252875,11 @@ |
| 251889 | 252875 | } |
| 251890 | 252876 | |
| 251891 | 252877 | return rc; |
| 251892 | 252878 | } |
| 251893 | 252879 | |
| 251894 | | -static int sqlite3Fts5GetTokenizer( |
| 252880 | +int fts5GetTokenizer( |
| 251895 | 252881 | Fts5Global *pGlobal, |
| 251896 | 252882 | const char **azArg, |
| 251897 | 252883 | int nArg, |
| 251898 | 252884 | Fts5Config *pConfig, |
| 251899 | 252885 | char **pzErr |
| | @@ -251903,32 +252889,45 @@ |
| 251903 | 252889 | |
| 251904 | 252890 | pMod = fts5LocateTokenizer(pGlobal, nArg==0 ? 0 : azArg[0]); |
| 251905 | 252891 | if( pMod==0 ){ |
| 251906 | 252892 | assert( nArg>0 ); |
| 251907 | 252893 | rc = SQLITE_ERROR; |
| 251908 | | - *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); |
| 252894 | + if( pzErr ) *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); |
| 251909 | 252895 | }else{ |
| 251910 | 252896 | rc = pMod->x.xCreate( |
| 251911 | | - pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->pTok |
| 252897 | + pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->t.pTok |
| 251912 | 252898 | ); |
| 251913 | | - pConfig->pTokApi = &pMod->x; |
| 252899 | + pConfig->t.pTokApi = &pMod->x; |
| 251914 | 252900 | if( rc!=SQLITE_OK ){ |
| 251915 | | - if( pzErr ) *pzErr = sqlite3_mprintf("error in tokenizer constructor"); |
| 252901 | + if( pzErr && rc!=SQLITE_NOMEM ){ |
| 252902 | + *pzErr = sqlite3_mprintf("error in tokenizer constructor"); |
| 252903 | + } |
| 251916 | 252904 | }else{ |
| 251917 | | - pConfig->ePattern = sqlite3Fts5TokenizerPattern( |
| 251918 | | - pMod->x.xCreate, pConfig->pTok |
| 252905 | + pConfig->t.ePattern = sqlite3Fts5TokenizerPattern( |
| 252906 | + pMod->x.xCreate, pConfig->t.pTok |
| 251919 | 252907 | ); |
| 251920 | 252908 | } |
| 251921 | 252909 | } |
| 251922 | 252910 | |
| 251923 | 252911 | if( rc!=SQLITE_OK ){ |
| 251924 | | - pConfig->pTokApi = 0; |
| 251925 | | - pConfig->pTok = 0; |
| 252912 | + pConfig->t.pTokApi = 0; |
| 252913 | + pConfig->t.pTok = 0; |
| 251926 | 252914 | } |
| 251927 | 252915 | |
| 251928 | 252916 | return rc; |
| 251929 | 252917 | } |
| 252918 | + |
| 252919 | +/* |
| 252920 | +** Attempt to instantiate the tokenizer. |
| 252921 | +*/ |
| 252922 | +static int sqlite3Fts5LoadTokenizer(Fts5Config *pConfig){ |
| 252923 | + return fts5GetTokenizer( |
| 252924 | + pConfig->pGlobal, pConfig->t.azArg, pConfig->t.nArg, |
| 252925 | + pConfig, pConfig->pzErrmsg |
| 252926 | + ); |
| 252927 | +} |
| 252928 | + |
| 251930 | 252929 | |
| 251931 | 252930 | static void fts5ModuleDestroy(void *pCtx){ |
| 251932 | 252931 | Fts5TokenizerModule *pTok, *pNextTok; |
| 251933 | 252932 | Fts5Auxiliary *pAux, *pNextAux; |
| 251934 | 252933 | Fts5Global *pGlobal = (Fts5Global*)pCtx; |
| | @@ -251969,11 +252968,11 @@ |
| 251969 | 252968 | int nArg, /* Number of args */ |
| 251970 | 252969 | sqlite3_value **apUnused /* Function arguments */ |
| 251971 | 252970 | ){ |
| 251972 | 252971 | assert( nArg==0 ); |
| 251973 | 252972 | UNUSED_PARAM2(nArg, apUnused); |
| 251974 | | - sqlite3_result_text(pCtx, "fts5: 2024-03-26 11:14:52 a49296de0061931badaf3db6b965131a78b1c6c21b1eeb62815ea7adf767d0b3", -1, SQLITE_TRANSIENT); |
| 252973 | + sqlite3_result_text(pCtx, "fts5: 2024-07-03 20:19:33 baa83b460c677c210c7fa3f20314d7e05f305aed8a69026bc5fa106a3de4ea38", -1, SQLITE_TRANSIENT); |
| 251975 | 252974 | } |
| 251976 | 252975 | |
| 251977 | 252976 | /* |
| 251978 | 252977 | ** Return true if zName is the extension on one of the shadow tables used |
| 251979 | 252978 | ** by this module. |
| | @@ -252004,21 +253003,27 @@ |
| 252004 | 253003 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 252005 | 253004 | int rc; |
| 252006 | 253005 | |
| 252007 | 253006 | assert( pzErr!=0 && *pzErr==0 ); |
| 252008 | 253007 | UNUSED_PARAM(isQuick); |
| 253008 | + assert( pTab->p.pConfig->pzErrmsg==0 ); |
| 253009 | + pTab->p.pConfig->pzErrmsg = pzErr; |
| 252009 | 253010 | rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, 0); |
| 252010 | | - if( (rc&0xff)==SQLITE_CORRUPT ){ |
| 252011 | | - *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", |
| 252012 | | - zSchema, zTabname); |
| 252013 | | - rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM; |
| 252014 | | - }else if( rc!=SQLITE_OK ){ |
| 252015 | | - *pzErr = sqlite3_mprintf("unable to validate the inverted index for" |
| 252016 | | - " FTS5 table %s.%s: %s", |
| 252017 | | - zSchema, zTabname, sqlite3_errstr(rc)); |
| 252018 | | - } |
| 253011 | + if( *pzErr==0 && rc!=SQLITE_OK ){ |
| 253012 | + if( (rc&0xff)==SQLITE_CORRUPT ){ |
| 253013 | + *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", |
| 253014 | + zSchema, zTabname); |
| 253015 | + rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM; |
| 253016 | + }else{ |
| 253017 | + *pzErr = sqlite3_mprintf("unable to validate the inverted index for" |
| 253018 | + " FTS5 table %s.%s: %s", |
| 253019 | + zSchema, zTabname, sqlite3_errstr(rc)); |
| 253020 | + } |
| 253021 | + } |
| 253022 | + |
| 252019 | 253023 | sqlite3Fts5IndexCloseReader(pTab->p.pIndex); |
| 253024 | + pTab->p.pConfig->pzErrmsg = 0; |
| 252020 | 253025 | |
| 252021 | 253026 | return rc; |
| 252022 | 253027 | } |
| 252023 | 253028 | |
| 252024 | 253029 | static int fts5Init(sqlite3 *db){ |
| | @@ -254796,10 +255801,20 @@ |
| 254796 | 255801 | return p->bFold ? FTS5_PATTERN_LIKE : FTS5_PATTERN_GLOB; |
| 254797 | 255802 | } |
| 254798 | 255803 | } |
| 254799 | 255804 | return FTS5_PATTERN_NONE; |
| 254800 | 255805 | } |
| 255806 | + |
| 255807 | +/* |
| 255808 | +** Return true if the tokenizer described by p->azArg[] is the trigram |
| 255809 | +** tokenizer. This tokenizer needs to be loaded before xBestIndex is |
| 255810 | +** called for the first time in order to correctly handle LIKE/GLOB. |
| 255811 | +*/ |
| 255812 | +static int sqlite3Fts5TokenizerPreload(Fts5TokenizerConfig *p){ |
| 255813 | + return (p->nArg>=1 && 0==sqlite3_stricmp(p->azArg[0], "trigram")); |
| 255814 | +} |
| 255815 | + |
| 254801 | 255816 | |
| 254802 | 255817 | /* |
| 254803 | 255818 | ** Register all built-in tokenizers with FTS5. |
| 254804 | 255819 | */ |
| 254805 | 255820 | static int sqlite3Fts5TokenizerInit(fts5_api *pApi){ |
| | @@ -256016,10 +257031,11 @@ |
| 256016 | 257031 | Fts5IndexIter *pIter; /* Term/rowid iterator object */ |
| 256017 | 257032 | void *pStruct; /* From sqlite3Fts5StructureRef() */ |
| 256018 | 257033 | |
| 256019 | 257034 | int nLeTerm; /* Size of zLeTerm in bytes */ |
| 256020 | 257035 | char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */ |
| 257036 | + int colUsed; /* Copy of sqlite3_index_info.colUsed */ |
| 256021 | 257037 | |
| 256022 | 257038 | /* These are used by 'col' tables only */ |
| 256023 | 257039 | int iCol; |
| 256024 | 257040 | i64 *aCnt; |
| 256025 | 257041 | i64 *aDoc; |
| | @@ -256042,13 +257058,15 @@ |
| 256042 | 257058 | #define FTS5_VOCAB_INST_SCHEMA "term, doc, col, offset" |
| 256043 | 257059 | |
| 256044 | 257060 | /* |
| 256045 | 257061 | ** Bits for the mask used as the idxNum value by xBestIndex/xFilter. |
| 256046 | 257062 | */ |
| 256047 | | -#define FTS5_VOCAB_TERM_EQ 0x01 |
| 256048 | | -#define FTS5_VOCAB_TERM_GE 0x02 |
| 256049 | | -#define FTS5_VOCAB_TERM_LE 0x04 |
| 257063 | +#define FTS5_VOCAB_TERM_EQ 0x0100 |
| 257064 | +#define FTS5_VOCAB_TERM_GE 0x0200 |
| 257065 | +#define FTS5_VOCAB_TERM_LE 0x0400 |
| 257066 | + |
| 257067 | +#define FTS5_VOCAB_COLUSED_MASK 0xFF |
| 256050 | 257068 | |
| 256051 | 257069 | |
| 256052 | 257070 | /* |
| 256053 | 257071 | ** Translate a string containing an fts5vocab table type to an |
| 256054 | 257072 | ** FTS5_VOCAB_XXX constant. If successful, set *peType to the output |
| | @@ -256221,14 +257239,16 @@ |
| 256221 | 257239 | ){ |
| 256222 | 257240 | int i; |
| 256223 | 257241 | int iTermEq = -1; |
| 256224 | 257242 | int iTermGe = -1; |
| 256225 | 257243 | int iTermLe = -1; |
| 256226 | | - int idxNum = 0; |
| 257244 | + int idxNum = (int)pInfo->colUsed; |
| 256227 | 257245 | int nArg = 0; |
| 256228 | 257246 | |
| 256229 | 257247 | UNUSED_PARAM(pUnused); |
| 257248 | + |
| 257249 | + assert( (pInfo->colUsed & FTS5_VOCAB_COLUSED_MASK)==pInfo->colUsed ); |
| 256230 | 257250 | |
| 256231 | 257251 | for(i=0; i<pInfo->nConstraint; i++){ |
| 256232 | 257252 | struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; |
| 256233 | 257253 | if( p->usable==0 ) continue; |
| 256234 | 257254 | if( p->iColumn==0 ){ /* term column */ |
| | @@ -256317,11 +257337,11 @@ |
| 256317 | 257337 | rc = sqlite3_finalize(pStmt); |
| 256318 | 257338 | pStmt = 0; |
| 256319 | 257339 | if( rc==SQLITE_OK ){ |
| 256320 | 257340 | pVTab->zErrMsg = sqlite3_mprintf( |
| 256321 | 257341 | "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl |
| 256322 | | - ); |
| 257342 | + ); |
| 256323 | 257343 | rc = SQLITE_ERROR; |
| 256324 | 257344 | } |
| 256325 | 257345 | }else{ |
| 256326 | 257346 | rc = sqlite3Fts5FlushToDisk(pFts5); |
| 256327 | 257347 | } |
| | @@ -256477,13 +257497,23 @@ |
| 256477 | 257497 | pPos = pCsr->pIter->pData; |
| 256478 | 257498 | nPos = pCsr->pIter->nData; |
| 256479 | 257499 | |
| 256480 | 257500 | switch( pTab->eType ){ |
| 256481 | 257501 | case FTS5_VOCAB_ROW: |
| 256482 | | - if( eDetail==FTS5_DETAIL_FULL ){ |
| 256483 | | - while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ |
| 256484 | | - pCsr->aCnt[0]++; |
| 257502 | + /* Do not bother counting the number of instances if the "cnt" |
| 257503 | + ** column is not being read (according to colUsed). */ |
| 257504 | + if( eDetail==FTS5_DETAIL_FULL && (pCsr->colUsed & 0x04) ){ |
| 257505 | + while( iPos<nPos ){ |
| 257506 | + u32 ii; |
| 257507 | + fts5FastGetVarint32(pPos, iPos, ii); |
| 257508 | + if( ii==1 ){ |
| 257509 | + /* New column in the position list */ |
| 257510 | + fts5FastGetVarint32(pPos, iPos, ii); |
| 257511 | + }else{ |
| 257512 | + /* An instance - increment pCsr->aCnt[] */ |
| 257513 | + pCsr->aCnt[0]++; |
| 257514 | + } |
| 256485 | 257515 | } |
| 256486 | 257516 | } |
| 256487 | 257517 | pCsr->aDoc[0]++; |
| 256488 | 257518 | break; |
| 256489 | 257519 | |
| | @@ -256577,10 +257607,11 @@ |
| 256577 | 257607 | |
| 256578 | 257608 | fts5VocabResetCursor(pCsr); |
| 256579 | 257609 | if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++]; |
| 256580 | 257610 | if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++]; |
| 256581 | 257611 | if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++]; |
| 257612 | + pCsr->colUsed = (idxNum & FTS5_VOCAB_COLUSED_MASK); |
| 256582 | 257613 | |
| 256583 | 257614 | if( pEq ){ |
| 256584 | 257615 | zTerm = (const char *)sqlite3_value_text(pEq); |
| 256585 | 257616 | nTerm = sqlite3_value_bytes(pEq); |
| 256586 | 257617 | f = FTS5INDEX_QUERY_NOTOKENDATA; |
| 256587 | 257618 | |