| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.18.0. By combining all the individual C code files into this |
| 3 | +** version 3.19.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. |
| | @@ -396,13 +396,13 @@ |
| 396 | 396 | ** |
| 397 | 397 | ** See also: [sqlite3_libversion()], |
| 398 | 398 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 399 | 399 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 400 | 400 | */ |
| 401 | | -#define SQLITE_VERSION "3.18.0" |
| 402 | | -#define SQLITE_VERSION_NUMBER 3018000 |
| 403 | | -#define SQLITE_SOURCE_ID "2017-03-28 18:48:43 424a0d380332858ee55bdebc4af3789f74e70a2b3ba1cf29d84b9b4bcf3e2e37" |
| 401 | +#define SQLITE_VERSION "3.19.0" |
| 402 | +#define SQLITE_VERSION_NUMBER 3019000 |
| 403 | +#define SQLITE_SOURCE_ID "2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40" |
| 404 | 404 | |
| 405 | 405 | /* |
| 406 | 406 | ** CAPI3REF: Run-Time Library Version Numbers |
| 407 | 407 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 408 | 408 | ** |
| | @@ -1132,11 +1132,11 @@ |
| 1132 | 1132 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 1133 | 1133 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 1134 | 1134 | ** opcode allows these two values (10 retries and 25 milliseconds of delay) |
| 1135 | 1135 | ** to be adjusted. The values are changed for all database connections |
| 1136 | 1136 | ** within the same process. The argument is a pointer to an array of two |
| 1137 | | -** integers where the first integer i the new retry count and the second |
| 1137 | +** integers where the first integer is the new retry count and the second |
| 1138 | 1138 | ** integer is the delay. If either integer is negative, then the setting |
| 1139 | 1139 | ** is not changed but instead the prior value of that setting is written |
| 1140 | 1140 | ** into the array entry, allowing the current retry settings to be |
| 1141 | 1141 | ** interrogated. The zDbName parameter is ignored. |
| 1142 | 1142 | ** |
| | @@ -2486,13 +2486,10 @@ |
| 2486 | 2486 | ** that are started after the running statement count reaches zero are |
| 2487 | 2487 | ** not effected by the sqlite3_interrupt(). |
| 2488 | 2488 | ** ^A call to sqlite3_interrupt(D) that occurs when there are no running |
| 2489 | 2489 | ** SQL statements is a no-op and has no effect on SQL statements |
| 2490 | 2490 | ** that are started after the sqlite3_interrupt() call returns. |
| 2491 | | -** |
| 2492 | | -** If the database connection closes while [sqlite3_interrupt()] |
| 2493 | | -** is running then bad things will likely happen. |
| 2494 | 2491 | */ |
| 2495 | 2492 | SQLITE_API void sqlite3_interrupt(sqlite3*); |
| 2496 | 2493 | |
| 2497 | 2494 | /* |
| 2498 | 2495 | ** CAPI3REF: Determine If An SQL Statement Is Complete |
| | @@ -2951,10 +2948,11 @@ |
| 2951 | 2948 | SQLITE_API void sqlite3_randomness(int N, void *P); |
| 2952 | 2949 | |
| 2953 | 2950 | /* |
| 2954 | 2951 | ** CAPI3REF: Compile-Time Authorization Callbacks |
| 2955 | 2952 | ** METHOD: sqlite3 |
| 2953 | +** KEYWORDS: {authorizer callback} |
| 2956 | 2954 | ** |
| 2957 | 2955 | ** ^This routine registers an authorizer callback with a particular |
| 2958 | 2956 | ** [database connection], supplied in the first argument. |
| 2959 | 2957 | ** ^The authorizer callback is invoked as SQL statements are being compiled |
| 2960 | 2958 | ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], |
| | @@ -2978,20 +2976,26 @@ |
| 2978 | 2976 | ** |
| 2979 | 2977 | ** ^The first parameter to the authorizer callback is a copy of the third |
| 2980 | 2978 | ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter |
| 2981 | 2979 | ** to the callback is an integer [SQLITE_COPY | action code] that specifies |
| 2982 | 2980 | ** the particular action to be authorized. ^The third through sixth parameters |
| 2983 | | -** to the callback are zero-terminated strings that contain additional |
| 2984 | | -** details about the action to be authorized. |
| 2981 | +** to the callback are either NULL pointers or zero-terminated strings |
| 2982 | +** that contain additional details about the action to be authorized. |
| 2983 | +** Applications must always be prepared to encounter a NULL pointer in any |
| 2984 | +** of the third through the sixth parameters of the authorization callback. |
| 2985 | 2985 | ** |
| 2986 | 2986 | ** ^If the action code is [SQLITE_READ] |
| 2987 | 2987 | ** and the callback returns [SQLITE_IGNORE] then the |
| 2988 | 2988 | ** [prepared statement] statement is constructed to substitute |
| 2989 | 2989 | ** a NULL value in place of the table column that would have |
| 2990 | 2990 | ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] |
| 2991 | 2991 | ** return can be used to deny an untrusted user access to individual |
| 2992 | 2992 | ** columns of a table. |
| 2993 | +** ^When a table is referenced by a [SELECT] but no column values are |
| 2994 | +** extracted from that table (for example in a query like |
| 2995 | +** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback |
| 2996 | +** is invoked once for that table with a column name that is an empty string. |
| 2993 | 2997 | ** ^If the action code is [SQLITE_DELETE] and the callback returns |
| 2994 | 2998 | ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the |
| 2995 | 2999 | ** [truncate optimization] is disabled and all rows are deleted individually. |
| 2996 | 3000 | ** |
| 2997 | 3001 | ** An authorizer is used when [sqlite3_prepare | preparing] |
| | @@ -3980,11 +3984,11 @@ |
| 3980 | 3984 | ** Unprotected sqlite3_value objects may only be used with |
| 3981 | 3985 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. |
| 3982 | 3986 | ** The [sqlite3_value_blob | sqlite3_value_type()] family of |
| 3983 | 3987 | ** interfaces require protected sqlite3_value objects. |
| 3984 | 3988 | */ |
| 3985 | | -typedef struct Mem sqlite3_value; |
| 3989 | +typedef struct sqlite3_value sqlite3_value; |
| 3986 | 3990 | |
| 3987 | 3991 | /* |
| 3988 | 3992 | ** CAPI3REF: SQL Function Context Object |
| 3989 | 3993 | ** |
| 3990 | 3994 | ** The context in which an SQL function executes is stored in an |
| | @@ -5034,14 +5038,15 @@ |
| 5034 | 5038 | ** metadata associated with the pattern string. |
| 5035 | 5039 | ** Then as long as the pattern string remains the same, |
| 5036 | 5040 | ** the compiled regular expression can be reused on multiple |
| 5037 | 5041 | ** invocations of the same function. |
| 5038 | 5042 | ** |
| 5039 | | -** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata |
| 5040 | | -** associated by the sqlite3_set_auxdata() function with the Nth argument |
| 5041 | | -** value to the application-defined function. ^If there is no metadata |
| 5042 | | -** associated with the function argument, this sqlite3_get_auxdata() interface |
| 5043 | +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata |
| 5044 | +** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 5045 | +** value to the application-defined function. ^N is zero for the left-most |
| 5046 | +** function argument. ^If there is no metadata |
| 5047 | +** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 5043 | 5048 | ** returns a NULL pointer. |
| 5044 | 5049 | ** |
| 5045 | 5050 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th |
| 5046 | 5051 | ** argument of the application-defined function. ^Subsequent |
| 5047 | 5052 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| | @@ -5067,10 +5072,14 @@ |
| 5067 | 5072 | ** sqlite3_set_auxdata() has been called. |
| 5068 | 5073 | ** |
| 5069 | 5074 | ** ^(In practice, metadata is preserved between function calls for |
| 5070 | 5075 | ** function parameters that are compile-time constants, including literal |
| 5071 | 5076 | ** values and [parameters] and expressions composed from the same.)^ |
| 5077 | +** |
| 5078 | +** The value of the N parameter to these interfaces should be non-negative. |
| 5079 | +** Future enhancements may make use of negative N values to define new |
| 5080 | +** kinds of function caching behavior. |
| 5072 | 5081 | ** |
| 5073 | 5082 | ** These routines must be called from the same thread in which |
| 5074 | 5083 | ** the SQL function is running. |
| 5075 | 5084 | */ |
| 5076 | 5085 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| | @@ -9662,11 +9671,11 @@ |
| 9662 | 9671 | ** |
| 9663 | 9672 | ** As well as the regular sqlite3changegroup_add() and |
| 9664 | 9673 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 9665 | 9674 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 9666 | 9675 | */ |
| 9667 | | -int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 9676 | +SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 9668 | 9677 | |
| 9669 | 9678 | /* |
| 9670 | 9679 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 9671 | 9680 | ** |
| 9672 | 9681 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| | @@ -9739,11 +9748,11 @@ |
| 9739 | 9748 | ** function returns SQLITE_NOMEM. In all cases, if an error occurs the |
| 9740 | 9749 | ** final contents of the changegroup is undefined. |
| 9741 | 9750 | ** |
| 9742 | 9751 | ** If no error occurs, SQLITE_OK is returned. |
| 9743 | 9752 | */ |
| 9744 | | -int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 9753 | +SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 9745 | 9754 | |
| 9746 | 9755 | /* |
| 9747 | 9756 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| 9748 | 9757 | ** |
| 9749 | 9758 | ** Obtain a buffer containing a changeset (or patchset) representing the |
| | @@ -9765,20 +9774,20 @@ |
| 9765 | 9774 | ** is returned and the output variables are set to the size of and a |
| 9766 | 9775 | ** pointer to the output buffer, respectively. In this case it is the |
| 9767 | 9776 | ** responsibility of the caller to eventually free the buffer using a |
| 9768 | 9777 | ** call to sqlite3_free(). |
| 9769 | 9778 | */ |
| 9770 | | -int sqlite3changegroup_output( |
| 9779 | +SQLITE_API int sqlite3changegroup_output( |
| 9771 | 9780 | sqlite3_changegroup*, |
| 9772 | 9781 | int *pnData, /* OUT: Size of output buffer in bytes */ |
| 9773 | 9782 | void **ppData /* OUT: Pointer to output buffer */ |
| 9774 | 9783 | ); |
| 9775 | 9784 | |
| 9776 | 9785 | /* |
| 9777 | 9786 | ** CAPI3REF: Delete A Changegroup Object |
| 9778 | 9787 | */ |
| 9779 | | -void sqlite3changegroup_delete(sqlite3_changegroup*); |
| 9788 | +SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); |
| 9780 | 9789 | |
| 9781 | 9790 | /* |
| 9782 | 9791 | ** CAPI3REF: Apply A Changeset To A Database |
| 9783 | 9792 | ** |
| 9784 | 9793 | ** Apply a changeset to a database. This function attempts to update the |
| | @@ -10163,15 +10172,15 @@ |
| 10163 | 10172 | SQLITE_API int sqlite3session_patchset_strm( |
| 10164 | 10173 | sqlite3_session *pSession, |
| 10165 | 10174 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 10166 | 10175 | void *pOut |
| 10167 | 10176 | ); |
| 10168 | | -int sqlite3changegroup_add_strm(sqlite3_changegroup*, |
| 10177 | +SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, |
| 10169 | 10178 | int (*xInput)(void *pIn, void *pData, int *pnData), |
| 10170 | 10179 | void *pIn |
| 10171 | 10180 | ); |
| 10172 | | -int sqlite3changegroup_output_strm(sqlite3_changegroup*, |
| 10181 | +SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, |
| 10173 | 10182 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 10174 | 10183 | void *pOut |
| 10175 | 10184 | ); |
| 10176 | 10185 | |
| 10177 | 10186 | |
| | @@ -11451,80 +11460,80 @@ |
| 11451 | 11460 | #define TK_LP 22 |
| 11452 | 11461 | #define TK_RP 23 |
| 11453 | 11462 | #define TK_AS 24 |
| 11454 | 11463 | #define TK_WITHOUT 25 |
| 11455 | 11464 | #define TK_COMMA 26 |
| 11456 | | -#define TK_OR 27 |
| 11457 | | -#define TK_AND 28 |
| 11458 | | -#define TK_IS 29 |
| 11459 | | -#define TK_MATCH 30 |
| 11460 | | -#define TK_LIKE_KW 31 |
| 11461 | | -#define TK_BETWEEN 32 |
| 11462 | | -#define TK_IN 33 |
| 11463 | | -#define TK_ISNULL 34 |
| 11464 | | -#define TK_NOTNULL 35 |
| 11465 | | -#define TK_NE 36 |
| 11466 | | -#define TK_EQ 37 |
| 11467 | | -#define TK_GT 38 |
| 11468 | | -#define TK_LE 39 |
| 11469 | | -#define TK_LT 40 |
| 11470 | | -#define TK_GE 41 |
| 11471 | | -#define TK_ESCAPE 42 |
| 11472 | | -#define TK_BITAND 43 |
| 11473 | | -#define TK_BITOR 44 |
| 11474 | | -#define TK_LSHIFT 45 |
| 11475 | | -#define TK_RSHIFT 46 |
| 11476 | | -#define TK_PLUS 47 |
| 11477 | | -#define TK_MINUS 48 |
| 11478 | | -#define TK_STAR 49 |
| 11479 | | -#define TK_SLASH 50 |
| 11480 | | -#define TK_REM 51 |
| 11481 | | -#define TK_CONCAT 52 |
| 11482 | | -#define TK_COLLATE 53 |
| 11483 | | -#define TK_BITNOT 54 |
| 11484 | | -#define TK_ID 55 |
| 11485 | | -#define TK_INDEXED 56 |
| 11486 | | -#define TK_ABORT 57 |
| 11487 | | -#define TK_ACTION 58 |
| 11488 | | -#define TK_AFTER 59 |
| 11489 | | -#define TK_ANALYZE 60 |
| 11490 | | -#define TK_ASC 61 |
| 11491 | | -#define TK_ATTACH 62 |
| 11492 | | -#define TK_BEFORE 63 |
| 11493 | | -#define TK_BY 64 |
| 11494 | | -#define TK_CASCADE 65 |
| 11495 | | -#define TK_CAST 66 |
| 11496 | | -#define TK_COLUMNKW 67 |
| 11497 | | -#define TK_CONFLICT 68 |
| 11498 | | -#define TK_DATABASE 69 |
| 11499 | | -#define TK_DESC 70 |
| 11500 | | -#define TK_DETACH 71 |
| 11501 | | -#define TK_EACH 72 |
| 11502 | | -#define TK_FAIL 73 |
| 11503 | | -#define TK_FOR 74 |
| 11504 | | -#define TK_IGNORE 75 |
| 11505 | | -#define TK_INITIALLY 76 |
| 11506 | | -#define TK_INSTEAD 77 |
| 11507 | | -#define TK_NO 78 |
| 11508 | | -#define TK_KEY 79 |
| 11509 | | -#define TK_OF 80 |
| 11510 | | -#define TK_OFFSET 81 |
| 11511 | | -#define TK_PRAGMA 82 |
| 11512 | | -#define TK_RAISE 83 |
| 11513 | | -#define TK_RECURSIVE 84 |
| 11514 | | -#define TK_REPLACE 85 |
| 11515 | | -#define TK_RESTRICT 86 |
| 11516 | | -#define TK_ROW 87 |
| 11517 | | -#define TK_TRIGGER 88 |
| 11518 | | -#define TK_VACUUM 89 |
| 11519 | | -#define TK_VIEW 90 |
| 11520 | | -#define TK_VIRTUAL 91 |
| 11521 | | -#define TK_WITH 92 |
| 11522 | | -#define TK_REINDEX 93 |
| 11523 | | -#define TK_RENAME 94 |
| 11524 | | -#define TK_CTIME_KW 95 |
| 11525 | | -#define TK_ANY 96 |
| 11465 | +#define TK_ID 27 |
| 11466 | +#define TK_ABORT 28 |
| 11467 | +#define TK_ACTION 29 |
| 11468 | +#define TK_AFTER 30 |
| 11469 | +#define TK_ANALYZE 31 |
| 11470 | +#define TK_ASC 32 |
| 11471 | +#define TK_ATTACH 33 |
| 11472 | +#define TK_BEFORE 34 |
| 11473 | +#define TK_BY 35 |
| 11474 | +#define TK_CASCADE 36 |
| 11475 | +#define TK_CAST 37 |
| 11476 | +#define TK_COLUMNKW 38 |
| 11477 | +#define TK_CONFLICT 39 |
| 11478 | +#define TK_DATABASE 40 |
| 11479 | +#define TK_DESC 41 |
| 11480 | +#define TK_DETACH 42 |
| 11481 | +#define TK_EACH 43 |
| 11482 | +#define TK_FAIL 44 |
| 11483 | +#define TK_FOR 45 |
| 11484 | +#define TK_IGNORE 46 |
| 11485 | +#define TK_INITIALLY 47 |
| 11486 | +#define TK_INSTEAD 48 |
| 11487 | +#define TK_LIKE_KW 49 |
| 11488 | +#define TK_MATCH 50 |
| 11489 | +#define TK_NO 51 |
| 11490 | +#define TK_KEY 52 |
| 11491 | +#define TK_OF 53 |
| 11492 | +#define TK_OFFSET 54 |
| 11493 | +#define TK_PRAGMA 55 |
| 11494 | +#define TK_RAISE 56 |
| 11495 | +#define TK_RECURSIVE 57 |
| 11496 | +#define TK_REPLACE 58 |
| 11497 | +#define TK_RESTRICT 59 |
| 11498 | +#define TK_ROW 60 |
| 11499 | +#define TK_TRIGGER 61 |
| 11500 | +#define TK_VACUUM 62 |
| 11501 | +#define TK_VIEW 63 |
| 11502 | +#define TK_VIRTUAL 64 |
| 11503 | +#define TK_WITH 65 |
| 11504 | +#define TK_REINDEX 66 |
| 11505 | +#define TK_RENAME 67 |
| 11506 | +#define TK_CTIME_KW 68 |
| 11507 | +#define TK_ANY 69 |
| 11508 | +#define TK_OR 70 |
| 11509 | +#define TK_AND 71 |
| 11510 | +#define TK_IS 72 |
| 11511 | +#define TK_BETWEEN 73 |
| 11512 | +#define TK_IN 74 |
| 11513 | +#define TK_ISNULL 75 |
| 11514 | +#define TK_NOTNULL 76 |
| 11515 | +#define TK_NE 77 |
| 11516 | +#define TK_EQ 78 |
| 11517 | +#define TK_GT 79 |
| 11518 | +#define TK_LE 80 |
| 11519 | +#define TK_LT 81 |
| 11520 | +#define TK_GE 82 |
| 11521 | +#define TK_ESCAPE 83 |
| 11522 | +#define TK_BITAND 84 |
| 11523 | +#define TK_BITOR 85 |
| 11524 | +#define TK_LSHIFT 86 |
| 11525 | +#define TK_RSHIFT 87 |
| 11526 | +#define TK_PLUS 88 |
| 11527 | +#define TK_MINUS 89 |
| 11528 | +#define TK_STAR 90 |
| 11529 | +#define TK_SLASH 91 |
| 11530 | +#define TK_REM 92 |
| 11531 | +#define TK_CONCAT 93 |
| 11532 | +#define TK_COLLATE 94 |
| 11533 | +#define TK_BITNOT 95 |
| 11534 | +#define TK_INDEXED 96 |
| 11526 | 11535 | #define TK_STRING 97 |
| 11527 | 11536 | #define TK_JOIN_KW 98 |
| 11528 | 11537 | #define TK_CONSTRAINT 99 |
| 11529 | 11538 | #define TK_DEFAULT 100 |
| 11530 | 11539 | #define TK_NULL 101 |
| | @@ -11584,14 +11593,15 @@ |
| 11584 | 11593 | #define TK_UMINUS 155 |
| 11585 | 11594 | #define TK_UPLUS 156 |
| 11586 | 11595 | #define TK_REGISTER 157 |
| 11587 | 11596 | #define TK_VECTOR 158 |
| 11588 | 11597 | #define TK_SELECT_COLUMN 159 |
| 11589 | | -#define TK_ASTERISK 160 |
| 11590 | | -#define TK_SPAN 161 |
| 11591 | | -#define TK_SPACE 162 |
| 11592 | | -#define TK_ILLEGAL 163 |
| 11598 | +#define TK_IF_NULL_ROW 160 |
| 11599 | +#define TK_ASTERISK 161 |
| 11600 | +#define TK_SPAN 162 |
| 11601 | +#define TK_SPACE 163 |
| 11602 | +#define TK_ILLEGAL 164 |
| 11593 | 11603 | |
| 11594 | 11604 | /* The token codes above must all fit in 8 bits */ |
| 11595 | 11605 | #define TKFLG_MASK 0xff |
| 11596 | 11606 | |
| 11597 | 11607 | /* Flags that can be added to a token code when it is not |
| | @@ -12458,11 +12468,11 @@ |
| 12458 | 12468 | */ |
| 12459 | 12469 | struct BtreePayload { |
| 12460 | 12470 | const void *pKey; /* Key content for indexes. NULL for tables */ |
| 12461 | 12471 | sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */ |
| 12462 | 12472 | const void *pData; /* Data for tables. NULL for indexes */ |
| 12463 | | - struct Mem *aMem; /* First of nMem value in the unpacked pKey */ |
| 12473 | + sqlite3_value *aMem; /* First of nMem value in the unpacked pKey */ |
| 12464 | 12474 | u16 nMem; /* Number of aMem[] value. Might be zero */ |
| 12465 | 12475 | int nData; /* Size of pData. 0 if none. */ |
| 12466 | 12476 | int nZero; /* Extra zero data appended after pData,nData */ |
| 12467 | 12477 | }; |
| 12468 | 12478 | |
| | @@ -12588,11 +12598,11 @@ |
| 12588 | 12598 | |
| 12589 | 12599 | /* |
| 12590 | 12600 | ** The names of the following types declared in vdbeInt.h are required |
| 12591 | 12601 | ** for the VdbeOp definition. |
| 12592 | 12602 | */ |
| 12593 | | -typedef struct Mem Mem; |
| 12603 | +typedef struct sqlite3_value Mem; |
| 12594 | 12604 | typedef struct SubProgram SubProgram; |
| 12595 | 12605 | |
| 12596 | 12606 | /* |
| 12597 | 12607 | ** A single instruction of the virtual machine has an opcode |
| 12598 | 12608 | ** and as many as three operands. The instruction is recorded |
| | @@ -12748,151 +12758,153 @@ |
| 12748 | 12758 | #define OP_Jump 18 |
| 12749 | 12759 | #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */ |
| 12750 | 12760 | #define OP_Once 20 |
| 12751 | 12761 | #define OP_If 21 |
| 12752 | 12762 | #define OP_IfNot 22 |
| 12753 | | -#define OP_SeekLT 23 /* synopsis: key=r[P3@P4] */ |
| 12754 | | -#define OP_SeekLE 24 /* synopsis: key=r[P3@P4] */ |
| 12755 | | -#define OP_SeekGE 25 /* synopsis: key=r[P3@P4] */ |
| 12756 | | -#define OP_SeekGT 26 /* synopsis: key=r[P3@P4] */ |
| 12757 | | -#define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 12758 | | -#define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 12759 | | -#define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */ |
| 12760 | | -#define OP_NotFound 30 /* synopsis: key=r[P3@P4] */ |
| 12761 | | -#define OP_Found 31 /* synopsis: key=r[P3@P4] */ |
| 12762 | | -#define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */ |
| 12763 | | -#define OP_NotExists 33 /* synopsis: intkey=r[P3] */ |
| 12764 | | -#define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 12765 | | -#define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 12766 | | -#define OP_Ne 36 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 12767 | | -#define OP_Eq 37 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 12768 | | -#define OP_Gt 38 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 12769 | | -#define OP_Le 39 /* same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 12770 | | -#define OP_Lt 40 /* same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 12771 | | -#define OP_Ge 41 /* same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 12772 | | -#define OP_ElseNotEq 42 /* same as TK_ESCAPE */ |
| 12773 | | -#define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 12774 | | -#define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 12775 | | -#define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 12776 | | -#define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 12777 | | -#define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 12778 | | -#define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 12779 | | -#define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 12780 | | -#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 12781 | | -#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 12782 | | -#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 12783 | | -#define OP_Last 53 |
| 12784 | | -#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 12785 | | -#define OP_IfSmaller 55 |
| 12786 | | -#define OP_SorterSort 56 |
| 12787 | | -#define OP_Sort 57 |
| 12788 | | -#define OP_Rewind 58 |
| 12789 | | -#define OP_IdxLE 59 /* synopsis: key=r[P3@P4] */ |
| 12790 | | -#define OP_IdxGT 60 /* synopsis: key=r[P3@P4] */ |
| 12791 | | -#define OP_IdxLT 61 /* synopsis: key=r[P3@P4] */ |
| 12792 | | -#define OP_IdxGE 62 /* synopsis: key=r[P3@P4] */ |
| 12793 | | -#define OP_RowSetRead 63 /* synopsis: r[P3]=rowset(P1) */ |
| 12794 | | -#define OP_RowSetTest 64 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 12795 | | -#define OP_Program 65 |
| 12796 | | -#define OP_FkIfZero 66 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 12797 | | -#define OP_IfPos 67 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 12798 | | -#define OP_IfNotZero 68 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 12799 | | -#define OP_DecrJumpZero 69 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 12800 | | -#define OP_IncrVacuum 70 |
| 12801 | | -#define OP_VNext 71 |
| 12802 | | -#define OP_Init 72 /* synopsis: Start at P2 */ |
| 12803 | | -#define OP_Return 73 |
| 12804 | | -#define OP_EndCoroutine 74 |
| 12805 | | -#define OP_HaltIfNull 75 /* synopsis: if r[P3]=null halt */ |
| 12806 | | -#define OP_Halt 76 |
| 12807 | | -#define OP_Integer 77 /* synopsis: r[P2]=P1 */ |
| 12808 | | -#define OP_Int64 78 /* synopsis: r[P2]=P4 */ |
| 12809 | | -#define OP_String 79 /* synopsis: r[P2]='P4' (len=P1) */ |
| 12810 | | -#define OP_Null 80 /* synopsis: r[P2..P3]=NULL */ |
| 12811 | | -#define OP_SoftNull 81 /* synopsis: r[P1]=NULL */ |
| 12812 | | -#define OP_Blob 82 /* synopsis: r[P2]=P4 (len=P1) */ |
| 12813 | | -#define OP_Variable 83 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 12814 | | -#define OP_Move 84 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 12815 | | -#define OP_Copy 85 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 12816 | | -#define OP_SCopy 86 /* synopsis: r[P2]=r[P1] */ |
| 12817 | | -#define OP_IntCopy 87 /* synopsis: r[P2]=r[P1] */ |
| 12818 | | -#define OP_ResultRow 88 /* synopsis: output=r[P1@P2] */ |
| 12819 | | -#define OP_CollSeq 89 |
| 12820 | | -#define OP_Function0 90 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12821 | | -#define OP_Function 91 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12822 | | -#define OP_AddImm 92 /* synopsis: r[P1]=r[P1]+P2 */ |
| 12823 | | -#define OP_RealAffinity 93 |
| 12763 | +#define OP_IfNullRow 23 /* synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */ |
| 12764 | +#define OP_SeekLT 24 /* synopsis: key=r[P3@P4] */ |
| 12765 | +#define OP_SeekLE 25 /* synopsis: key=r[P3@P4] */ |
| 12766 | +#define OP_SeekGE 26 /* synopsis: key=r[P3@P4] */ |
| 12767 | +#define OP_SeekGT 27 /* synopsis: key=r[P3@P4] */ |
| 12768 | +#define OP_NoConflict 28 /* synopsis: key=r[P3@P4] */ |
| 12769 | +#define OP_NotFound 29 /* synopsis: key=r[P3@P4] */ |
| 12770 | +#define OP_Found 30 /* synopsis: key=r[P3@P4] */ |
| 12771 | +#define OP_SeekRowid 31 /* synopsis: intkey=r[P3] */ |
| 12772 | +#define OP_NotExists 32 /* synopsis: intkey=r[P3] */ |
| 12773 | +#define OP_Last 33 |
| 12774 | +#define OP_IfSmaller 34 |
| 12775 | +#define OP_SorterSort 35 |
| 12776 | +#define OP_Sort 36 |
| 12777 | +#define OP_Rewind 37 |
| 12778 | +#define OP_IdxLE 38 /* synopsis: key=r[P3@P4] */ |
| 12779 | +#define OP_IdxGT 39 /* synopsis: key=r[P3@P4] */ |
| 12780 | +#define OP_IdxLT 40 /* synopsis: key=r[P3@P4] */ |
| 12781 | +#define OP_IdxGE 41 /* synopsis: key=r[P3@P4] */ |
| 12782 | +#define OP_RowSetRead 42 /* synopsis: r[P3]=rowset(P1) */ |
| 12783 | +#define OP_RowSetTest 43 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 12784 | +#define OP_Program 44 |
| 12785 | +#define OP_FkIfZero 45 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 12786 | +#define OP_IfPos 46 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 12787 | +#define OP_IfNotZero 47 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 12788 | +#define OP_DecrJumpZero 48 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 12789 | +#define OP_IncrVacuum 49 |
| 12790 | +#define OP_VNext 50 |
| 12791 | +#define OP_Init 51 /* synopsis: Start at P2 */ |
| 12792 | +#define OP_Return 52 |
| 12793 | +#define OP_EndCoroutine 53 |
| 12794 | +#define OP_HaltIfNull 54 /* synopsis: if r[P3]=null halt */ |
| 12795 | +#define OP_Halt 55 |
| 12796 | +#define OP_Integer 56 /* synopsis: r[P2]=P1 */ |
| 12797 | +#define OP_Int64 57 /* synopsis: r[P2]=P4 */ |
| 12798 | +#define OP_String 58 /* synopsis: r[P2]='P4' (len=P1) */ |
| 12799 | +#define OP_Null 59 /* synopsis: r[P2..P3]=NULL */ |
| 12800 | +#define OP_SoftNull 60 /* synopsis: r[P1]=NULL */ |
| 12801 | +#define OP_Blob 61 /* synopsis: r[P2]=P4 (len=P1) */ |
| 12802 | +#define OP_Variable 62 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 12803 | +#define OP_Move 63 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 12804 | +#define OP_Copy 64 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 12805 | +#define OP_SCopy 65 /* synopsis: r[P2]=r[P1] */ |
| 12806 | +#define OP_IntCopy 66 /* synopsis: r[P2]=r[P1] */ |
| 12807 | +#define OP_ResultRow 67 /* synopsis: output=r[P1@P2] */ |
| 12808 | +#define OP_CollSeq 68 |
| 12809 | +#define OP_Function0 69 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12810 | +#define OP_Or 70 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 12811 | +#define OP_And 71 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 12812 | +#define OP_Function 72 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12813 | +#define OP_AddImm 73 /* synopsis: r[P1]=r[P1]+P2 */ |
| 12814 | +#define OP_RealAffinity 74 |
| 12815 | +#define OP_IsNull 75 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 12816 | +#define OP_NotNull 76 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 12817 | +#define OP_Ne 77 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 12818 | +#define OP_Eq 78 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 12819 | +#define OP_Gt 79 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 12820 | +#define OP_Le 80 /* same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 12821 | +#define OP_Lt 81 /* same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 12822 | +#define OP_Ge 82 /* same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 12823 | +#define OP_ElseNotEq 83 /* same as TK_ESCAPE */ |
| 12824 | +#define OP_BitAnd 84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 12825 | +#define OP_BitOr 85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 12826 | +#define OP_ShiftLeft 86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 12827 | +#define OP_ShiftRight 87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 12828 | +#define OP_Add 88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 12829 | +#define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 12830 | +#define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 12831 | +#define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 12832 | +#define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 12833 | +#define OP_Concat 93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 12824 | 12834 | #define OP_Cast 94 /* synopsis: affinity(r[P1]) */ |
| 12825 | | -#define OP_Permutation 95 |
| 12826 | | -#define OP_Compare 96 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 12835 | +#define OP_BitNot 95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 12836 | +#define OP_Permutation 96 |
| 12827 | 12837 | #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 12828 | | -#define OP_Column 98 /* synopsis: r[P3]=PX */ |
| 12829 | | -#define OP_Affinity 99 /* synopsis: affinity(r[P1@P2]) */ |
| 12830 | | -#define OP_MakeRecord 100 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 12831 | | -#define OP_Count 101 /* synopsis: r[P2]=count() */ |
| 12832 | | -#define OP_ReadCookie 102 |
| 12833 | | -#define OP_SetCookie 103 |
| 12834 | | -#define OP_ReopenIdx 104 /* synopsis: root=P2 iDb=P3 */ |
| 12835 | | -#define OP_OpenRead 105 /* synopsis: root=P2 iDb=P3 */ |
| 12836 | | -#define OP_OpenWrite 106 /* synopsis: root=P2 iDb=P3 */ |
| 12837 | | -#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2 */ |
| 12838 | | -#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2 */ |
| 12839 | | -#define OP_SorterOpen 109 |
| 12840 | | -#define OP_SequenceTest 110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 12841 | | -#define OP_OpenPseudo 111 /* synopsis: P3 columns in r[P2] */ |
| 12842 | | -#define OP_Close 112 |
| 12843 | | -#define OP_ColumnsUsed 113 |
| 12844 | | -#define OP_Sequence 114 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 12845 | | -#define OP_NewRowid 115 /* synopsis: r[P2]=rowid */ |
| 12846 | | -#define OP_Insert 116 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 12847 | | -#define OP_InsertInt 117 /* synopsis: intkey=P3 data=r[P2] */ |
| 12848 | | -#define OP_Delete 118 |
| 12849 | | -#define OP_ResetCount 119 |
| 12850 | | -#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 12851 | | -#define OP_SorterData 121 /* synopsis: r[P2]=data */ |
| 12852 | | -#define OP_RowData 122 /* synopsis: r[P2]=data */ |
| 12853 | | -#define OP_Rowid 123 /* synopsis: r[P2]=rowid */ |
| 12854 | | -#define OP_NullRow 124 |
| 12855 | | -#define OP_SorterInsert 125 /* synopsis: key=r[P2] */ |
| 12856 | | -#define OP_IdxInsert 126 /* synopsis: key=r[P2] */ |
| 12857 | | -#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */ |
| 12858 | | -#define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */ |
| 12859 | | -#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */ |
| 12860 | | -#define OP_Destroy 130 |
| 12861 | | -#define OP_Clear 131 |
| 12838 | +#define OP_Compare 98 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 12839 | +#define OP_Column 99 /* synopsis: r[P3]=PX */ |
| 12840 | +#define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */ |
| 12841 | +#define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 12842 | +#define OP_Count 102 /* synopsis: r[P2]=count() */ |
| 12843 | +#define OP_ReadCookie 103 |
| 12844 | +#define OP_SetCookie 104 |
| 12845 | +#define OP_ReopenIdx 105 /* synopsis: root=P2 iDb=P3 */ |
| 12846 | +#define OP_OpenRead 106 /* synopsis: root=P2 iDb=P3 */ |
| 12847 | +#define OP_OpenWrite 107 /* synopsis: root=P2 iDb=P3 */ |
| 12848 | +#define OP_OpenDup 108 |
| 12849 | +#define OP_OpenAutoindex 109 /* synopsis: nColumn=P2 */ |
| 12850 | +#define OP_OpenEphemeral 110 /* synopsis: nColumn=P2 */ |
| 12851 | +#define OP_SorterOpen 111 |
| 12852 | +#define OP_SequenceTest 112 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 12853 | +#define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */ |
| 12854 | +#define OP_Close 114 |
| 12855 | +#define OP_ColumnsUsed 115 |
| 12856 | +#define OP_Sequence 116 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 12857 | +#define OP_NewRowid 117 /* synopsis: r[P2]=rowid */ |
| 12858 | +#define OP_Insert 118 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 12859 | +#define OP_InsertInt 119 /* synopsis: intkey=P3 data=r[P2] */ |
| 12860 | +#define OP_Delete 120 |
| 12861 | +#define OP_ResetCount 121 |
| 12862 | +#define OP_SorterCompare 122 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 12863 | +#define OP_SorterData 123 /* synopsis: r[P2]=data */ |
| 12864 | +#define OP_RowData 124 /* synopsis: r[P2]=data */ |
| 12865 | +#define OP_Rowid 125 /* synopsis: r[P2]=rowid */ |
| 12866 | +#define OP_NullRow 126 |
| 12867 | +#define OP_SorterInsert 127 /* synopsis: key=r[P2] */ |
| 12868 | +#define OP_IdxInsert 128 /* synopsis: key=r[P2] */ |
| 12869 | +#define OP_IdxDelete 129 /* synopsis: key=r[P2@P3] */ |
| 12870 | +#define OP_Seek 130 /* synopsis: Move P3 to P1.rowid */ |
| 12871 | +#define OP_IdxRowid 131 /* synopsis: r[P2]=rowid */ |
| 12862 | 12872 | #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 12863 | | -#define OP_ResetSorter 133 |
| 12864 | | -#define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */ |
| 12865 | | -#define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */ |
| 12866 | | -#define OP_SqlExec 136 |
| 12867 | | -#define OP_ParseSchema 137 |
| 12868 | | -#define OP_LoadAnalysis 138 |
| 12869 | | -#define OP_DropTable 139 |
| 12870 | | -#define OP_DropIndex 140 |
| 12871 | | -#define OP_DropTrigger 141 |
| 12872 | | -#define OP_IntegrityCk 142 |
| 12873 | | -#define OP_RowSetAdd 143 /* synopsis: rowset(P1)=r[P2] */ |
| 12874 | | -#define OP_Param 144 |
| 12875 | | -#define OP_FkCounter 145 /* synopsis: fkctr[P1]+=P2 */ |
| 12876 | | -#define OP_MemMax 146 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 12877 | | -#define OP_OffsetLimit 147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 12878 | | -#define OP_AggStep0 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12879 | | -#define OP_AggStep 149 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12880 | | -#define OP_AggFinal 150 /* synopsis: accum=r[P1] N=P2 */ |
| 12881 | | -#define OP_Expire 151 |
| 12882 | | -#define OP_TableLock 152 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 12883 | | -#define OP_VBegin 153 |
| 12884 | | -#define OP_VCreate 154 |
| 12885 | | -#define OP_VDestroy 155 |
| 12886 | | -#define OP_VOpen 156 |
| 12887 | | -#define OP_VColumn 157 /* synopsis: r[P3]=vcolumn(P2) */ |
| 12888 | | -#define OP_VRename 158 |
| 12889 | | -#define OP_Pagecount 159 |
| 12890 | | -#define OP_MaxPgcnt 160 |
| 12891 | | -#define OP_CursorHint 161 |
| 12892 | | -#define OP_Noop 162 |
| 12893 | | -#define OP_Explain 163 |
| 12873 | +#define OP_Destroy 133 |
| 12874 | +#define OP_Clear 134 |
| 12875 | +#define OP_ResetSorter 135 |
| 12876 | +#define OP_CreateIndex 136 /* synopsis: r[P2]=root iDb=P1 */ |
| 12877 | +#define OP_CreateTable 137 /* synopsis: r[P2]=root iDb=P1 */ |
| 12878 | +#define OP_SqlExec 138 |
| 12879 | +#define OP_ParseSchema 139 |
| 12880 | +#define OP_LoadAnalysis 140 |
| 12881 | +#define OP_DropTable 141 |
| 12882 | +#define OP_DropIndex 142 |
| 12883 | +#define OP_DropTrigger 143 |
| 12884 | +#define OP_IntegrityCk 144 |
| 12885 | +#define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */ |
| 12886 | +#define OP_Param 146 |
| 12887 | +#define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */ |
| 12888 | +#define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 12889 | +#define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 12890 | +#define OP_AggStep0 150 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12891 | +#define OP_AggStep 151 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12892 | +#define OP_AggFinal 152 /* synopsis: accum=r[P1] N=P2 */ |
| 12893 | +#define OP_Expire 153 |
| 12894 | +#define OP_TableLock 154 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 12895 | +#define OP_VBegin 155 |
| 12896 | +#define OP_VCreate 156 |
| 12897 | +#define OP_VDestroy 157 |
| 12898 | +#define OP_VOpen 158 |
| 12899 | +#define OP_VColumn 159 /* synopsis: r[P3]=vcolumn(P2) */ |
| 12900 | +#define OP_VRename 160 |
| 12901 | +#define OP_Pagecount 161 |
| 12902 | +#define OP_MaxPgcnt 162 |
| 12903 | +#define OP_CursorHint 163 |
| 12904 | +#define OP_Noop 164 |
| 12905 | +#define OP_Explain 165 |
| 12894 | 12906 | |
| 12895 | 12907 | /* Properties such as "out2" or "jump" that are specified in |
| 12896 | 12908 | ** comments following the "case" for each opcode in the vdbe.c |
| 12897 | 12909 | ** are encoded into bitvectors as follows: |
| 12898 | 12910 | */ |
| | @@ -12903,37 +12915,37 @@ |
| 12903 | 12915 | #define OPFLG_OUT2 0x10 /* out2: P2 is an output */ |
| 12904 | 12916 | #define OPFLG_OUT3 0x20 /* out3: P3 is an output */ |
| 12905 | 12917 | #define OPFLG_INITIALIZER {\ |
| 12906 | 12918 | /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 12907 | 12919 | /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\ |
| 12908 | | -/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\ |
| 12909 | | -/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\ |
| 12910 | | -/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 12911 | | -/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 12912 | | -/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\ |
| 12913 | | -/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23,\ |
| 12914 | | -/* 64 */ 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01,\ |
| 12915 | | -/* 72 */ 0x01, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ |
| 12916 | | -/* 80 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ |
| 12917 | | -/* 88 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\ |
| 12918 | | -/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 12920 | +/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x01,\ |
| 12921 | +/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ |
| 12922 | +/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 12923 | +/* 40 */ 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01, 0x03, 0x03,\ |
| 12924 | +/* 48 */ 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x00,\ |
| 12925 | +/* 56 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\ |
| 12926 | +/* 64 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\ |
| 12927 | +/* 72 */ 0x00, 0x02, 0x02, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 12928 | +/* 80 */ 0x0b, 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26,\ |
| 12929 | +/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x02, 0x12,\ |
| 12930 | +/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ |
| 12919 | 12931 | /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12920 | | -/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 12921 | | -/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\ |
| 12922 | | -/* 128 */ 0x00, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\ |
| 12923 | | -/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\ |
| 12924 | | -/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\ |
| 12925 | | -/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\ |
| 12926 | | -/* 160 */ 0x10, 0x00, 0x00, 0x00,} |
| 12932 | +/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 12933 | +/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04,\ |
| 12934 | +/* 128 */ 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\ |
| 12935 | +/* 136 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12936 | +/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\ |
| 12937 | +/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12938 | +/* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,} |
| 12927 | 12939 | |
| 12928 | 12940 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 12929 | 12941 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 12930 | 12942 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 12931 | 12943 | ** generated this include file strives to group all JUMP opcodes |
| 12932 | 12944 | ** together near the beginning of the list. |
| 12933 | 12945 | */ |
| 12934 | | -#define SQLITE_MX_JUMP_OPCODE 72 /* Maximum JUMP opcode */ |
| 12946 | +#define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */ |
| 12935 | 12947 | |
| 12936 | 12948 | /************** End of opcodes.h *********************************************/ |
| 12937 | 12949 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 12938 | 12950 | |
| 12939 | 12951 | /* |
| | @@ -15209,10 +15221,11 @@ |
| 15209 | 15221 | ** of the result column in the form: DATABASE.TABLE.COLUMN. This later |
| 15210 | 15222 | ** form is used for name resolution with nested FROM clauses. |
| 15211 | 15223 | */ |
| 15212 | 15224 | struct ExprList { |
| 15213 | 15225 | int nExpr; /* Number of expressions on the list */ |
| 15226 | + int nAlloc; /* Number of a[] slots allocated */ |
| 15214 | 15227 | struct ExprList_item { /* For each expression in the list */ |
| 15215 | 15228 | Expr *pExpr; /* The parse tree for this expression */ |
| 15216 | 15229 | char *zName; /* Token associated with this expression */ |
| 15217 | 15230 | char *zSpan; /* Original text of the expression */ |
| 15218 | 15231 | u8 sortOrder; /* 1 for DESC or 0 for ASC */ |
| | @@ -15224,11 +15237,11 @@ |
| 15224 | 15237 | u16 iOrderByCol; /* For ORDER BY, column number in result set */ |
| 15225 | 15238 | u16 iAlias; /* Index into Parse.aAlias[] for zName */ |
| 15226 | 15239 | } x; |
| 15227 | 15240 | int iConstExprReg; /* Register in which Expr value is cached */ |
| 15228 | 15241 | } u; |
| 15229 | | - } *a; /* Alloc a power of two greater or equal to nExpr */ |
| 15242 | + } a[1]; /* One slot for each expression in the list */ |
| 15230 | 15243 | }; |
| 15231 | 15244 | |
| 15232 | 15245 | /* |
| 15233 | 15246 | ** An instance of this structure is used by the parser to record both |
| 15234 | 15247 | ** the parse tree for an expression and the span of input text for an |
| | @@ -16081,18 +16094,21 @@ |
| 16081 | 16094 | int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ |
| 16082 | 16095 | void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ |
| 16083 | 16096 | int walkerDepth; /* Number of subqueries */ |
| 16084 | 16097 | u8 eCode; /* A small processing code */ |
| 16085 | 16098 | union { /* Extra data for callback */ |
| 16086 | | - NameContext *pNC; /* Naming context */ |
| 16087 | | - int n; /* A counter */ |
| 16088 | | - int iCur; /* A cursor number */ |
| 16089 | | - SrcList *pSrcList; /* FROM clause */ |
| 16090 | | - struct SrcCount *pSrcCount; /* Counting column references */ |
| 16091 | | - struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 16092 | | - int *aiCol; /* array of column indexes */ |
| 16093 | | - struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 16099 | + NameContext *pNC; /* Naming context */ |
| 16100 | + int n; /* A counter */ |
| 16101 | + int iCur; /* A cursor number */ |
| 16102 | + SrcList *pSrcList; /* FROM clause */ |
| 16103 | + struct SrcCount *pSrcCount; /* Counting column references */ |
| 16104 | + struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 16105 | + int *aiCol; /* array of column indexes */ |
| 16106 | + struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 16107 | + struct IdxExprTrans *pIdxTrans; /* Convert indexed expr to column */ |
| 16108 | + ExprList *pGroupBy; /* GROUP BY clause */ |
| 16109 | + struct HavingToWhereCtx *pHavingCtx; /* HAVING to WHERE clause ctx */ |
| 16094 | 16110 | } u; |
| 16095 | 16111 | }; |
| 16096 | 16112 | |
| 16097 | 16113 | /* Forward declarations */ |
| 16098 | 16114 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); |
| | @@ -16242,10 +16258,11 @@ |
| 16242 | 16258 | SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64); |
| 16243 | 16259 | SQLITE_PRIVATE void *sqlite3Realloc(void*, u64); |
| 16244 | 16260 | SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64); |
| 16245 | 16261 | SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64); |
| 16246 | 16262 | SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*); |
| 16263 | +SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*); |
| 16247 | 16264 | SQLITE_PRIVATE int sqlite3MallocSize(void*); |
| 16248 | 16265 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*); |
| 16249 | 16266 | SQLITE_PRIVATE void *sqlite3ScratchMalloc(int); |
| 16250 | 16267 | SQLITE_PRIVATE void sqlite3ScratchFree(void*); |
| 16251 | 16268 | SQLITE_PRIVATE void *sqlite3PageMalloc(int); |
| | @@ -16557,10 +16574,11 @@ |
| 16557 | 16574 | SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *); |
| 16558 | 16575 | SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*); |
| 16559 | 16576 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); |
| 16560 | 16577 | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*); |
| 16561 | 16578 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 16579 | +SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); |
| 16562 | 16580 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); |
| 16563 | 16581 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 16564 | 16582 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 16565 | 16583 | #endif |
| 16566 | 16584 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*); |
| | @@ -17266,13 +17284,20 @@ |
| 17266 | 17284 | ** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options. |
| 17267 | 17285 | ** |
| 17268 | 17286 | ** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally |
| 17269 | 17287 | ** disabled. The default value may be changed by compiling with the |
| 17270 | 17288 | ** SQLITE_USE_URI symbol defined. |
| 17289 | +** |
| 17290 | +** URI filenames are enabled by default if SQLITE_HAS_CODEC is |
| 17291 | +** enabled. |
| 17271 | 17292 | */ |
| 17272 | 17293 | #ifndef SQLITE_USE_URI |
| 17273 | | -# define SQLITE_USE_URI 0 |
| 17294 | +# ifdef SQLITE_HAS_CODEC |
| 17295 | +# define SQLITE_USE_URI 1 |
| 17296 | +# else |
| 17297 | +# define SQLITE_USE_URI 0 |
| 17298 | +# endif |
| 17274 | 17299 | #endif |
| 17275 | 17300 | |
| 17276 | 17301 | /* EVIDENCE-OF: R-38720-18127 The default setting is determined by the |
| 17277 | 17302 | ** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if |
| 17278 | 17303 | ** that compile-time option is omitted. |
| | @@ -18092,11 +18117,11 @@ |
| 18092 | 18117 | /* |
| 18093 | 18118 | ** Internally, the vdbe manipulates nearly all SQL values as Mem |
| 18094 | 18119 | ** structures. Each Mem struct may cache multiple representations (string, |
| 18095 | 18120 | ** integer etc.) of the same value. |
| 18096 | 18121 | */ |
| 18097 | | -struct Mem { |
| 18122 | +struct sqlite3_value { |
| 18098 | 18123 | union MemValue { |
| 18099 | 18124 | double r; /* Real value used when MEM_Real is set in flags */ |
| 18100 | 18125 | i64 i; /* Integer value used when MEM_Int is set in flags */ |
| 18101 | 18126 | int nZero; /* Used when bit MEM_Zero is set in flags */ |
| 18102 | 18127 | FuncDef *pDef; /* Used only when flags==MEM_Agg */ |
| | @@ -18194,15 +18219,15 @@ |
| 18194 | 18219 | ** of this structure. All such structures associated with a single VM |
| 18195 | 18220 | ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed |
| 18196 | 18221 | ** when the VM is halted (if not before). |
| 18197 | 18222 | */ |
| 18198 | 18223 | struct AuxData { |
| 18199 | | - int iOp; /* Instruction number of OP_Function opcode */ |
| 18200 | | - int iArg; /* Index of function argument. */ |
| 18224 | + int iAuxOp; /* Instruction number of OP_Function opcode */ |
| 18225 | + int iAuxArg; /* Index of function argument. */ |
| 18201 | 18226 | void *pAux; /* Aux data pointer */ |
| 18202 | | - void (*xDelete)(void *); /* Destructor for the aux data */ |
| 18203 | | - AuxData *pNext; /* Next element in list */ |
| 18227 | + void (*xDeleteAux)(void*); /* Destructor for the aux data */ |
| 18228 | + AuxData *pNextAux; /* Next element in list */ |
| 18204 | 18229 | }; |
| 18205 | 18230 | |
| 18206 | 18231 | /* |
| 18207 | 18232 | ** The "context" argument for an installable function. A pointer to an |
| 18208 | 18233 | ** instance of this structure is the first argument to the routines used |
| | @@ -19222,12 +19247,14 @@ |
| 19222 | 19247 | if( p->validYMD ) return; |
| 19223 | 19248 | if( !p->validJD ){ |
| 19224 | 19249 | p->Y = 2000; |
| 19225 | 19250 | p->M = 1; |
| 19226 | 19251 | p->D = 1; |
| 19252 | + }else if( !validJulianDay(p->iJD) ){ |
| 19253 | + datetimeError(p); |
| 19254 | + return; |
| 19227 | 19255 | }else{ |
| 19228 | | - assert( validJulianDay(p->iJD) ); |
| 19229 | 19256 | Z = (int)((p->iJD + 43200000)/86400000); |
| 19230 | 19257 | A = (int)((Z - 1867216.25)/36524.25); |
| 19231 | 19258 | A = Z + 1 + A - (A/4); |
| 19232 | 19259 | B = A + 1524; |
| 19233 | 19260 | C = (int)((B - 122.1)/365.25); |
| | @@ -24659,15 +24686,16 @@ |
| 24659 | 24686 | *db->pnBytesFreed += sqlite3DbMallocSize(db,p); |
| 24660 | 24687 | } |
| 24661 | 24688 | |
| 24662 | 24689 | /* |
| 24663 | 24690 | ** Free memory that might be associated with a particular database |
| 24664 | | -** connection. |
| 24691 | +** connection. Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op. |
| 24692 | +** The sqlite3DbFreeNN(D,X) version requires that X be non-NULL. |
| 24665 | 24693 | */ |
| 24666 | | -SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){ |
| 24694 | +SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3 *db, void *p){ |
| 24667 | 24695 | assert( db==0 || sqlite3_mutex_held(db->mutex) ); |
| 24668 | | - if( p==0 ) return; |
| 24696 | + assert( p!=0 ); |
| 24669 | 24697 | if( db ){ |
| 24670 | 24698 | if( db->pnBytesFreed ){ |
| 24671 | 24699 | measureAllocationSize(db, p); |
| 24672 | 24700 | return; |
| 24673 | 24701 | } |
| | @@ -24686,10 +24714,14 @@ |
| 24686 | 24714 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 24687 | 24715 | assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 24688 | 24716 | assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) ); |
| 24689 | 24717 | sqlite3MemdebugSetType(p, MEMTYPE_HEAP); |
| 24690 | 24718 | sqlite3_free(p); |
| 24719 | +} |
| 24720 | +SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){ |
| 24721 | + assert( db==0 || sqlite3_mutex_held(db->mutex) ); |
| 24722 | + if( p ) sqlite3DbFreeNN(db, p); |
| 24691 | 24723 | } |
| 24692 | 24724 | |
| 24693 | 24725 | /* |
| 24694 | 24726 | ** Change the size of an existing memory allocation |
| 24695 | 24727 | */ |
| | @@ -26379,19 +26411,24 @@ |
| 26379 | 26411 | ** Generate a human-readable explanation of an expression tree. |
| 26380 | 26412 | */ |
| 26381 | 26413 | SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){ |
| 26382 | 26414 | const char *zBinOp = 0; /* Binary operator */ |
| 26383 | 26415 | const char *zUniOp = 0; /* Unary operator */ |
| 26384 | | - char zFlgs[30]; |
| 26416 | + char zFlgs[60]; |
| 26385 | 26417 | pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 26386 | 26418 | if( pExpr==0 ){ |
| 26387 | 26419 | sqlite3TreeViewLine(pView, "nil"); |
| 26388 | 26420 | sqlite3TreeViewPop(pView); |
| 26389 | 26421 | return; |
| 26390 | 26422 | } |
| 26391 | 26423 | if( pExpr->flags ){ |
| 26392 | | - sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags); |
| 26424 | + if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 26425 | + sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x iRJT=%d", |
| 26426 | + pExpr->flags, pExpr->iRightJoinTable); |
| 26427 | + }else{ |
| 26428 | + sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags); |
| 26429 | + } |
| 26393 | 26430 | }else{ |
| 26394 | 26431 | zFlgs[0] = 0; |
| 26395 | 26432 | } |
| 26396 | 26433 | switch( pExpr->op ){ |
| 26397 | 26434 | case TK_AGG_COLUMN: { |
| | @@ -26605,10 +26642,15 @@ |
| 26605 | 26642 | } |
| 26606 | 26643 | case TK_SELECT_COLUMN: { |
| 26607 | 26644 | sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn); |
| 26608 | 26645 | sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0); |
| 26609 | 26646 | break; |
| 26647 | + } |
| 26648 | + case TK_IF_NULL_ROW: { |
| 26649 | + sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable); |
| 26650 | + sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 26651 | + break; |
| 26610 | 26652 | } |
| 26611 | 26653 | default: { |
| 26612 | 26654 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); |
| 26613 | 26655 | break; |
| 26614 | 26656 | } |
| | @@ -28325,10 +28367,11 @@ |
| 28325 | 28367 | }else{ |
| 28326 | 28368 | return 0; |
| 28327 | 28369 | } |
| 28328 | 28370 | } |
| 28329 | 28371 | #endif |
| 28372 | + if( !sqlite3Isdigit(zNum[0]) ) return 0; |
| 28330 | 28373 | while( zNum[0]=='0' ) zNum++; |
| 28331 | 28374 | for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){ |
| 28332 | 28375 | v = v*10 + c; |
| 28333 | 28376 | } |
| 28334 | 28377 | |
| | @@ -29488,151 +29531,153 @@ |
| 29488 | 29531 | /* 18 */ "Jump" OpHelp(""), |
| 29489 | 29532 | /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"), |
| 29490 | 29533 | /* 20 */ "Once" OpHelp(""), |
| 29491 | 29534 | /* 21 */ "If" OpHelp(""), |
| 29492 | 29535 | /* 22 */ "IfNot" OpHelp(""), |
| 29493 | | - /* 23 */ "SeekLT" OpHelp("key=r[P3@P4]"), |
| 29494 | | - /* 24 */ "SeekLE" OpHelp("key=r[P3@P4]"), |
| 29495 | | - /* 25 */ "SeekGE" OpHelp("key=r[P3@P4]"), |
| 29496 | | - /* 26 */ "SeekGT" OpHelp("key=r[P3@P4]"), |
| 29497 | | - /* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 29498 | | - /* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 29499 | | - /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 29500 | | - /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 29501 | | - /* 31 */ "Found" OpHelp("key=r[P3@P4]"), |
| 29502 | | - /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 29503 | | - /* 33 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 29504 | | - /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 29505 | | - /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 29506 | | - /* 36 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 29507 | | - /* 37 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 29508 | | - /* 38 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 29509 | | - /* 39 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 29510 | | - /* 40 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 29511 | | - /* 41 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 29512 | | - /* 42 */ "ElseNotEq" OpHelp(""), |
| 29513 | | - /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 29514 | | - /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 29515 | | - /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 29516 | | - /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 29517 | | - /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 29518 | | - /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 29519 | | - /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 29520 | | - /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 29521 | | - /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 29522 | | - /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 29523 | | - /* 53 */ "Last" OpHelp(""), |
| 29524 | | - /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 29525 | | - /* 55 */ "IfSmaller" OpHelp(""), |
| 29526 | | - /* 56 */ "SorterSort" OpHelp(""), |
| 29527 | | - /* 57 */ "Sort" OpHelp(""), |
| 29528 | | - /* 58 */ "Rewind" OpHelp(""), |
| 29529 | | - /* 59 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 29530 | | - /* 60 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 29531 | | - /* 61 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 29532 | | - /* 62 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 29533 | | - /* 63 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 29534 | | - /* 64 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 29535 | | - /* 65 */ "Program" OpHelp(""), |
| 29536 | | - /* 66 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 29537 | | - /* 67 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 29538 | | - /* 68 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 29539 | | - /* 69 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 29540 | | - /* 70 */ "IncrVacuum" OpHelp(""), |
| 29541 | | - /* 71 */ "VNext" OpHelp(""), |
| 29542 | | - /* 72 */ "Init" OpHelp("Start at P2"), |
| 29543 | | - /* 73 */ "Return" OpHelp(""), |
| 29544 | | - /* 74 */ "EndCoroutine" OpHelp(""), |
| 29545 | | - /* 75 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 29546 | | - /* 76 */ "Halt" OpHelp(""), |
| 29547 | | - /* 77 */ "Integer" OpHelp("r[P2]=P1"), |
| 29548 | | - /* 78 */ "Int64" OpHelp("r[P2]=P4"), |
| 29549 | | - /* 79 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 29550 | | - /* 80 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 29551 | | - /* 81 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 29552 | | - /* 82 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 29553 | | - /* 83 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 29554 | | - /* 84 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 29555 | | - /* 85 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 29556 | | - /* 86 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 29557 | | - /* 87 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 29558 | | - /* 88 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 29559 | | - /* 89 */ "CollSeq" OpHelp(""), |
| 29560 | | - /* 90 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29561 | | - /* 91 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29562 | | - /* 92 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 29563 | | - /* 93 */ "RealAffinity" OpHelp(""), |
| 29536 | + /* 23 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"), |
| 29537 | + /* 24 */ "SeekLT" OpHelp("key=r[P3@P4]"), |
| 29538 | + /* 25 */ "SeekLE" OpHelp("key=r[P3@P4]"), |
| 29539 | + /* 26 */ "SeekGE" OpHelp("key=r[P3@P4]"), |
| 29540 | + /* 27 */ "SeekGT" OpHelp("key=r[P3@P4]"), |
| 29541 | + /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 29542 | + /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 29543 | + /* 30 */ "Found" OpHelp("key=r[P3@P4]"), |
| 29544 | + /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 29545 | + /* 32 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 29546 | + /* 33 */ "Last" OpHelp(""), |
| 29547 | + /* 34 */ "IfSmaller" OpHelp(""), |
| 29548 | + /* 35 */ "SorterSort" OpHelp(""), |
| 29549 | + /* 36 */ "Sort" OpHelp(""), |
| 29550 | + /* 37 */ "Rewind" OpHelp(""), |
| 29551 | + /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 29552 | + /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 29553 | + /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 29554 | + /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 29555 | + /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 29556 | + /* 43 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 29557 | + /* 44 */ "Program" OpHelp(""), |
| 29558 | + /* 45 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 29559 | + /* 46 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 29560 | + /* 47 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 29561 | + /* 48 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 29562 | + /* 49 */ "IncrVacuum" OpHelp(""), |
| 29563 | + /* 50 */ "VNext" OpHelp(""), |
| 29564 | + /* 51 */ "Init" OpHelp("Start at P2"), |
| 29565 | + /* 52 */ "Return" OpHelp(""), |
| 29566 | + /* 53 */ "EndCoroutine" OpHelp(""), |
| 29567 | + /* 54 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 29568 | + /* 55 */ "Halt" OpHelp(""), |
| 29569 | + /* 56 */ "Integer" OpHelp("r[P2]=P1"), |
| 29570 | + /* 57 */ "Int64" OpHelp("r[P2]=P4"), |
| 29571 | + /* 58 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 29572 | + /* 59 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 29573 | + /* 60 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 29574 | + /* 61 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 29575 | + /* 62 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 29576 | + /* 63 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 29577 | + /* 64 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 29578 | + /* 65 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 29579 | + /* 66 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 29580 | + /* 67 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 29581 | + /* 68 */ "CollSeq" OpHelp(""), |
| 29582 | + /* 69 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29583 | + /* 70 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 29584 | + /* 71 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 29585 | + /* 72 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29586 | + /* 73 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 29587 | + /* 74 */ "RealAffinity" OpHelp(""), |
| 29588 | + /* 75 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 29589 | + /* 76 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 29590 | + /* 77 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 29591 | + /* 78 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 29592 | + /* 79 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 29593 | + /* 80 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 29594 | + /* 81 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 29595 | + /* 82 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 29596 | + /* 83 */ "ElseNotEq" OpHelp(""), |
| 29597 | + /* 84 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 29598 | + /* 85 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 29599 | + /* 86 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 29600 | + /* 87 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 29601 | + /* 88 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 29602 | + /* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 29603 | + /* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 29604 | + /* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 29605 | + /* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 29606 | + /* 93 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 29564 | 29607 | /* 94 */ "Cast" OpHelp("affinity(r[P1])"), |
| 29565 | | - /* 95 */ "Permutation" OpHelp(""), |
| 29566 | | - /* 96 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 29608 | + /* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 29609 | + /* 96 */ "Permutation" OpHelp(""), |
| 29567 | 29610 | /* 97 */ "String8" OpHelp("r[P2]='P4'"), |
| 29568 | | - /* 98 */ "Column" OpHelp("r[P3]=PX"), |
| 29569 | | - /* 99 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 29570 | | - /* 100 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29571 | | - /* 101 */ "Count" OpHelp("r[P2]=count()"), |
| 29572 | | - /* 102 */ "ReadCookie" OpHelp(""), |
| 29573 | | - /* 103 */ "SetCookie" OpHelp(""), |
| 29574 | | - /* 104 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 29575 | | - /* 105 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 29576 | | - /* 106 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 29577 | | - /* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 29578 | | - /* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 29579 | | - /* 109 */ "SorterOpen" OpHelp(""), |
| 29580 | | - /* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 29581 | | - /* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 29582 | | - /* 112 */ "Close" OpHelp(""), |
| 29583 | | - /* 113 */ "ColumnsUsed" OpHelp(""), |
| 29584 | | - /* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 29585 | | - /* 115 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 29586 | | - /* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 29587 | | - /* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 29588 | | - /* 118 */ "Delete" OpHelp(""), |
| 29589 | | - /* 119 */ "ResetCount" OpHelp(""), |
| 29590 | | - /* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 29591 | | - /* 121 */ "SorterData" OpHelp("r[P2]=data"), |
| 29592 | | - /* 122 */ "RowData" OpHelp("r[P2]=data"), |
| 29593 | | - /* 123 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 29594 | | - /* 124 */ "NullRow" OpHelp(""), |
| 29595 | | - /* 125 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 29596 | | - /* 126 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 29597 | | - /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 29598 | | - /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 29599 | | - /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 29600 | | - /* 130 */ "Destroy" OpHelp(""), |
| 29601 | | - /* 131 */ "Clear" OpHelp(""), |
| 29611 | + /* 98 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 29612 | + /* 99 */ "Column" OpHelp("r[P3]=PX"), |
| 29613 | + /* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 29614 | + /* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29615 | + /* 102 */ "Count" OpHelp("r[P2]=count()"), |
| 29616 | + /* 103 */ "ReadCookie" OpHelp(""), |
| 29617 | + /* 104 */ "SetCookie" OpHelp(""), |
| 29618 | + /* 105 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 29619 | + /* 106 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 29620 | + /* 107 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 29621 | + /* 108 */ "OpenDup" OpHelp(""), |
| 29622 | + /* 109 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 29623 | + /* 110 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 29624 | + /* 111 */ "SorterOpen" OpHelp(""), |
| 29625 | + /* 112 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 29626 | + /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 29627 | + /* 114 */ "Close" OpHelp(""), |
| 29628 | + /* 115 */ "ColumnsUsed" OpHelp(""), |
| 29629 | + /* 116 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 29630 | + /* 117 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 29631 | + /* 118 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 29632 | + /* 119 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 29633 | + /* 120 */ "Delete" OpHelp(""), |
| 29634 | + /* 121 */ "ResetCount" OpHelp(""), |
| 29635 | + /* 122 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 29636 | + /* 123 */ "SorterData" OpHelp("r[P2]=data"), |
| 29637 | + /* 124 */ "RowData" OpHelp("r[P2]=data"), |
| 29638 | + /* 125 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 29639 | + /* 126 */ "NullRow" OpHelp(""), |
| 29640 | + /* 127 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 29641 | + /* 128 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 29642 | + /* 129 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 29643 | + /* 130 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 29644 | + /* 131 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 29602 | 29645 | /* 132 */ "Real" OpHelp("r[P2]=P4"), |
| 29603 | | - /* 133 */ "ResetSorter" OpHelp(""), |
| 29604 | | - /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 29605 | | - /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29606 | | - /* 136 */ "SqlExec" OpHelp(""), |
| 29607 | | - /* 137 */ "ParseSchema" OpHelp(""), |
| 29608 | | - /* 138 */ "LoadAnalysis" OpHelp(""), |
| 29609 | | - /* 139 */ "DropTable" OpHelp(""), |
| 29610 | | - /* 140 */ "DropIndex" OpHelp(""), |
| 29611 | | - /* 141 */ "DropTrigger" OpHelp(""), |
| 29612 | | - /* 142 */ "IntegrityCk" OpHelp(""), |
| 29613 | | - /* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 29614 | | - /* 144 */ "Param" OpHelp(""), |
| 29615 | | - /* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 29616 | | - /* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 29617 | | - /* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 29618 | | - /* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29619 | | - /* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29620 | | - /* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 29621 | | - /* 151 */ "Expire" OpHelp(""), |
| 29622 | | - /* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 29623 | | - /* 153 */ "VBegin" OpHelp(""), |
| 29624 | | - /* 154 */ "VCreate" OpHelp(""), |
| 29625 | | - /* 155 */ "VDestroy" OpHelp(""), |
| 29626 | | - /* 156 */ "VOpen" OpHelp(""), |
| 29627 | | - /* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 29628 | | - /* 158 */ "VRename" OpHelp(""), |
| 29629 | | - /* 159 */ "Pagecount" OpHelp(""), |
| 29630 | | - /* 160 */ "MaxPgcnt" OpHelp(""), |
| 29631 | | - /* 161 */ "CursorHint" OpHelp(""), |
| 29632 | | - /* 162 */ "Noop" OpHelp(""), |
| 29633 | | - /* 163 */ "Explain" OpHelp(""), |
| 29646 | + /* 133 */ "Destroy" OpHelp(""), |
| 29647 | + /* 134 */ "Clear" OpHelp(""), |
| 29648 | + /* 135 */ "ResetSorter" OpHelp(""), |
| 29649 | + /* 136 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 29650 | + /* 137 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29651 | + /* 138 */ "SqlExec" OpHelp(""), |
| 29652 | + /* 139 */ "ParseSchema" OpHelp(""), |
| 29653 | + /* 140 */ "LoadAnalysis" OpHelp(""), |
| 29654 | + /* 141 */ "DropTable" OpHelp(""), |
| 29655 | + /* 142 */ "DropIndex" OpHelp(""), |
| 29656 | + /* 143 */ "DropTrigger" OpHelp(""), |
| 29657 | + /* 144 */ "IntegrityCk" OpHelp(""), |
| 29658 | + /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 29659 | + /* 146 */ "Param" OpHelp(""), |
| 29660 | + /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 29661 | + /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 29662 | + /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 29663 | + /* 150 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29664 | + /* 151 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29665 | + /* 152 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 29666 | + /* 153 */ "Expire" OpHelp(""), |
| 29667 | + /* 154 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 29668 | + /* 155 */ "VBegin" OpHelp(""), |
| 29669 | + /* 156 */ "VCreate" OpHelp(""), |
| 29670 | + /* 157 */ "VDestroy" OpHelp(""), |
| 29671 | + /* 158 */ "VOpen" OpHelp(""), |
| 29672 | + /* 159 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 29673 | + /* 160 */ "VRename" OpHelp(""), |
| 29674 | + /* 161 */ "Pagecount" OpHelp(""), |
| 29675 | + /* 162 */ "MaxPgcnt" OpHelp(""), |
| 29676 | + /* 163 */ "CursorHint" OpHelp(""), |
| 29677 | + /* 164 */ "Noop" OpHelp(""), |
| 29678 | + /* 165 */ "Explain" OpHelp(""), |
| 29634 | 29679 | }; |
| 29635 | 29680 | return azName[i]; |
| 29636 | 29681 | } |
| 29637 | 29682 | #endif |
| 29638 | 29683 | |
| | @@ -45243,21 +45288,20 @@ |
| 45243 | 45288 | } |
| 45244 | 45289 | zBulk = pCache->pBulk = sqlite3Malloc( szBulk ); |
| 45245 | 45290 | sqlite3EndBenignMalloc(); |
| 45246 | 45291 | if( zBulk ){ |
| 45247 | 45292 | int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc; |
| 45248 | | - int i; |
| 45249 | | - for(i=0; i<nBulk; i++){ |
| 45293 | + do{ |
| 45250 | 45294 | PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; |
| 45251 | 45295 | pX->page.pBuf = zBulk; |
| 45252 | 45296 | pX->page.pExtra = &pX[1]; |
| 45253 | 45297 | pX->isBulkLocal = 1; |
| 45254 | 45298 | pX->isAnchor = 0; |
| 45255 | 45299 | pX->pNext = pCache->pFree; |
| 45256 | 45300 | pCache->pFree = pX; |
| 45257 | 45301 | zBulk += pCache->szAlloc; |
| 45258 | | - } |
| 45302 | + }while( --nBulk ); |
| 45259 | 45303 | } |
| 45260 | 45304 | return pCache->pFree!=0; |
| 45261 | 45305 | } |
| 45262 | 45306 | |
| 45263 | 45307 | /* |
| | @@ -46169,11 +46213,11 @@ |
| 46169 | 46213 | */ |
| 46170 | 46214 | SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){ |
| 46171 | 46215 | int nFree = 0; |
| 46172 | 46216 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 46173 | 46217 | assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
| 46174 | | - if( sqlite3GlobalConfig.nPage==0 ){ |
| 46218 | + if( sqlite3GlobalConfig.pPage==0 ){ |
| 46175 | 46219 | PgHdr1 *p; |
| 46176 | 46220 | pcache1EnterMutex(&pcache1.grp); |
| 46177 | 46221 | while( (nReq<0 || nFree<nReq) |
| 46178 | 46222 | && (p=pcache1.grp.lru.pLruPrev)!=0 |
| 46179 | 46223 | && p->isAnchor==0 |
| | @@ -49129,10 +49173,15 @@ |
| 49129 | 49173 | Pgno pgno; /* The page number of a page in journal */ |
| 49130 | 49174 | u32 cksum; /* Checksum used for sanity checking */ |
| 49131 | 49175 | char *aData; /* Temporary storage for the page */ |
| 49132 | 49176 | sqlite3_file *jfd; /* The file descriptor for the journal file */ |
| 49133 | 49177 | int isSynced; /* True if journal page is synced */ |
| 49178 | +#ifdef SQLITE_HAS_CODEC |
| 49179 | + /* The jrnlEnc flag is true if Journal pages should be passed through |
| 49180 | + ** the codec. It is false for pure in-memory journals. */ |
| 49181 | + const int jrnlEnc = (isMainJrnl || pPager->subjInMemory==0); |
| 49182 | +#endif |
| 49134 | 49183 | |
| 49135 | 49184 | assert( (isMainJrnl&~1)==0 ); /* isMainJrnl is 0 or 1 */ |
| 49136 | 49185 | assert( (isSavepnt&~1)==0 ); /* isSavepnt is 0 or 1 */ |
| 49137 | 49186 | assert( isMainJrnl || pDone ); /* pDone always used on sub-journals */ |
| 49138 | 49187 | assert( isSavepnt || pDone==0 ); /* pDone never used on non-savepoint */ |
| | @@ -49252,18 +49301,38 @@ |
| 49252 | 49301 | && isSynced |
| 49253 | 49302 | ){ |
| 49254 | 49303 | i64 ofst = (pgno-1)*(i64)pPager->pageSize; |
| 49255 | 49304 | testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 ); |
| 49256 | 49305 | assert( !pagerUseWal(pPager) ); |
| 49306 | + |
| 49307 | + /* Write the data read from the journal back into the database file. |
| 49308 | + ** This is usually safe even for an encrypted database - as the data |
| 49309 | + ** was encrypted before it was written to the journal file. The exception |
| 49310 | + ** is if the data was just read from an in-memory sub-journal. In that |
| 49311 | + ** case it must be encrypted here before it is copied into the database |
| 49312 | + ** file. */ |
| 49313 | +#ifdef SQLITE_HAS_CODEC |
| 49314 | + if( !jrnlEnc ){ |
| 49315 | + CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData); |
| 49316 | + rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst); |
| 49317 | + CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT); |
| 49318 | + }else |
| 49319 | +#endif |
| 49257 | 49320 | rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst); |
| 49321 | + |
| 49258 | 49322 | if( pgno>pPager->dbFileSize ){ |
| 49259 | 49323 | pPager->dbFileSize = pgno; |
| 49260 | 49324 | } |
| 49261 | 49325 | if( pPager->pBackup ){ |
| 49262 | | - CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT); |
| 49326 | +#ifdef SQLITE_HAS_CODEC |
| 49327 | + if( jrnlEnc ){ |
| 49328 | + CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT); |
| 49329 | + sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData); |
| 49330 | + CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData); |
| 49331 | + }else |
| 49332 | +#endif |
| 49263 | 49333 | sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData); |
| 49264 | | - CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData); |
| 49265 | 49334 | } |
| 49266 | 49335 | }else if( !isMainJrnl && pPg==0 ){ |
| 49267 | 49336 | /* If this is a rollback of a savepoint and data was not written to |
| 49268 | 49337 | ** the database and the page is not in-memory, there is a potential |
| 49269 | 49338 | ** problem. When the page is next fetched by the b-tree layer, it |
| | @@ -49311,11 +49380,13 @@ |
| 49311 | 49380 | if( pgno==1 ){ |
| 49312 | 49381 | memcpy(&pPager->dbFileVers, &((u8*)pData)[24],sizeof(pPager->dbFileVers)); |
| 49313 | 49382 | } |
| 49314 | 49383 | |
| 49315 | 49384 | /* Decode the page just read from disk */ |
| 49316 | | - CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); |
| 49385 | +#if SQLITE_HAS_CODEC |
| 49386 | + if( jrnlEnc ){ CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); } |
| 49387 | +#endif |
| 49317 | 49388 | sqlite3PcacheRelease(pPg); |
| 49318 | 49389 | } |
| 49319 | 49390 | return rc; |
| 49320 | 49391 | } |
| 49321 | 49392 | |
| | @@ -51323,12 +51394,17 @@ |
| 51323 | 51394 | ** write the journal record into the file. */ |
| 51324 | 51395 | if( rc==SQLITE_OK ){ |
| 51325 | 51396 | void *pData = pPg->pData; |
| 51326 | 51397 | i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize); |
| 51327 | 51398 | char *pData2; |
| 51328 | | - |
| 51329 | | - CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2); |
| 51399 | + |
| 51400 | +#if SQLITE_HAS_CODEC |
| 51401 | + if( !pPager->subjInMemory ){ |
| 51402 | + CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2); |
| 51403 | + }else |
| 51404 | +#endif |
| 51405 | + pData2 = pData; |
| 51330 | 51406 | PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno)); |
| 51331 | 51407 | rc = write32bits(pPager->sjfd, offset, pPg->pgno); |
| 51332 | 51408 | if( rc==SQLITE_OK ){ |
| 51333 | 51409 | rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4); |
| 51334 | 51410 | } |
| | @@ -58476,14 +58552,14 @@ |
| 58476 | 58552 | /* All fields above are zeroed when the cursor is allocated. See |
| 58477 | 58553 | ** sqlite3BtreeCursorZero(). Fields that follow must be manually |
| 58478 | 58554 | ** initialized. */ |
| 58479 | 58555 | i8 iPage; /* Index of current page in apPage */ |
| 58480 | 58556 | u8 curIntKey; /* Value of apPage[0]->intKey */ |
| 58481 | | - struct KeyInfo *pKeyInfo; /* Argument passed to comparison function */ |
| 58482 | | - void *padding1; /* Make object size a multiple of 16 */ |
| 58483 | | - u16 aiIdx[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ |
| 58484 | | - MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ |
| 58557 | + u16 ix; /* Current index for apPage[iPage] */ |
| 58558 | + u16 aiIdx[BTCURSOR_MAX_DEPTH-1]; /* Current index in apPage[i] */ |
| 58559 | + struct KeyInfo *pKeyInfo; /* Arg passed to comparison function */ |
| 58560 | + MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ |
| 58485 | 58561 | }; |
| 58486 | 58562 | |
| 58487 | 58563 | /* |
| 58488 | 58564 | ** Legal values for BtCursor.curFlags |
| 58489 | 58565 | */ |
| | @@ -59455,10 +59531,11 @@ |
| 59455 | 59531 | ** rowid iRow is being replaced or deleted. In this case invalidate |
| 59456 | 59532 | ** only those incrblob cursors open on that specific row. |
| 59457 | 59533 | */ |
| 59458 | 59534 | static void invalidateIncrblobCursors( |
| 59459 | 59535 | Btree *pBtree, /* The database file to check */ |
| 59536 | + Pgno pgnoRoot, /* The table that might be changing */ |
| 59460 | 59537 | i64 iRow, /* The rowid that might be changing */ |
| 59461 | 59538 | int isClearTable /* True if all rows are being deleted */ |
| 59462 | 59539 | ){ |
| 59463 | 59540 | BtCursor *p; |
| 59464 | 59541 | if( pBtree->hasIncrblobCur==0 ) return; |
| | @@ -59465,20 +59542,20 @@ |
| 59465 | 59542 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 59466 | 59543 | pBtree->hasIncrblobCur = 0; |
| 59467 | 59544 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 59468 | 59545 | if( (p->curFlags & BTCF_Incrblob)!=0 ){ |
| 59469 | 59546 | pBtree->hasIncrblobCur = 1; |
| 59470 | | - if( isClearTable || p->info.nKey==iRow ){ |
| 59547 | + if( p->pgnoRoot==pgnoRoot && (isClearTable || p->info.nKey==iRow) ){ |
| 59471 | 59548 | p->eState = CURSOR_INVALID; |
| 59472 | 59549 | } |
| 59473 | 59550 | } |
| 59474 | 59551 | } |
| 59475 | 59552 | } |
| 59476 | 59553 | |
| 59477 | 59554 | #else |
| 59478 | 59555 | /* Stub function when INCRBLOB is omitted */ |
| 59479 | | - #define invalidateIncrblobCursors(x,y,z) |
| 59556 | + #define invalidateIncrblobCursors(w,x,y,z) |
| 59480 | 59557 | #endif /* SQLITE_OMIT_INCRBLOB */ |
| 59481 | 59558 | |
| 59482 | 59559 | /* |
| 59483 | 59560 | ** Set bit pgno of the BtShared.pHasContent bitvec. This is called |
| 59484 | 59561 | ** when a page that previously contained data becomes a free-list leaf |
| | @@ -63272,21 +63349,21 @@ |
| 63272 | 63349 | #ifndef NDEBUG |
| 63273 | 63350 | static void assertCellInfo(BtCursor *pCur){ |
| 63274 | 63351 | CellInfo info; |
| 63275 | 63352 | int iPage = pCur->iPage; |
| 63276 | 63353 | memset(&info, 0, sizeof(info)); |
| 63277 | | - btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info); |
| 63354 | + btreeParseCell(pCur->apPage[iPage], pCur->ix, &info); |
| 63278 | 63355 | assert( CORRUPT_DB || memcmp(&info, &pCur->info, sizeof(info))==0 ); |
| 63279 | 63356 | } |
| 63280 | 63357 | #else |
| 63281 | 63358 | #define assertCellInfo(x) |
| 63282 | 63359 | #endif |
| 63283 | 63360 | static SQLITE_NOINLINE void getCellInfo(BtCursor *pCur){ |
| 63284 | 63361 | if( pCur->info.nSize==0 ){ |
| 63285 | 63362 | int iPage = pCur->iPage; |
| 63286 | 63363 | pCur->curFlags |= BTCF_ValidNKey; |
| 63287 | | - btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info); |
| 63364 | + btreeParseCell(pCur->apPage[iPage],pCur->ix,&pCur->info); |
| 63288 | 63365 | }else{ |
| 63289 | 63366 | assertCellInfo(pCur); |
| 63290 | 63367 | } |
| 63291 | 63368 | } |
| 63292 | 63369 | |
| | @@ -63489,11 +63566,11 @@ |
| 63489 | 63566 | #endif |
| 63490 | 63567 | |
| 63491 | 63568 | assert( pPage ); |
| 63492 | 63569 | assert( eOp==0 || eOp==1 ); |
| 63493 | 63570 | assert( pCur->eState==CURSOR_VALID ); |
| 63494 | | - assert( pCur->aiIdx[pCur->iPage]<pPage->nCell ); |
| 63571 | + assert( pCur->ix<pPage->nCell ); |
| 63495 | 63572 | assert( cursorHoldsMutex(pCur) ); |
| 63496 | 63573 | |
| 63497 | 63574 | getCellInfo(pCur); |
| 63498 | 63575 | aPayload = pCur->info.pPayload; |
| 63499 | 63576 | assert( offset+amt <= pCur->info.nPayload ); |
| | @@ -63676,11 +63753,11 @@ |
| 63676 | 63753 | */ |
| 63677 | 63754 | SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){ |
| 63678 | 63755 | assert( cursorHoldsMutex(pCur) ); |
| 63679 | 63756 | assert( pCur->eState==CURSOR_VALID ); |
| 63680 | 63757 | assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] ); |
| 63681 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 63758 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 63682 | 63759 | return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0); |
| 63683 | 63760 | } |
| 63684 | 63761 | |
| 63685 | 63762 | /* |
| 63686 | 63763 | ** This variant of sqlite3BtreePayload() works even if the cursor has not |
| | @@ -63738,11 +63815,11 @@ |
| 63738 | 63815 | u32 amt; |
| 63739 | 63816 | assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]); |
| 63740 | 63817 | assert( pCur->eState==CURSOR_VALID ); |
| 63741 | 63818 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 63742 | 63819 | assert( cursorOwnsBtShared(pCur) ); |
| 63743 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 63820 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 63744 | 63821 | assert( pCur->info.nSize>0 ); |
| 63745 | 63822 | assert( pCur->info.pPayload>pCur->apPage[pCur->iPage]->aData || CORRUPT_DB ); |
| 63746 | 63823 | assert( pCur->info.pPayload<pCur->apPage[pCur->iPage]->aDataEnd ||CORRUPT_DB); |
| 63747 | 63824 | amt = (int)(pCur->apPage[pCur->iPage]->aDataEnd - pCur->info.pPayload); |
| 63748 | 63825 | if( pCur->info.nLocal<amt ) amt = pCur->info.nLocal; |
| | @@ -63789,12 +63866,12 @@ |
| 63789 | 63866 | if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){ |
| 63790 | 63867 | return SQLITE_CORRUPT_BKPT; |
| 63791 | 63868 | } |
| 63792 | 63869 | pCur->info.nSize = 0; |
| 63793 | 63870 | pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 63794 | | - pCur->iPage++; |
| 63795 | | - pCur->aiIdx[pCur->iPage] = 0; |
| 63871 | + pCur->aiIdx[pCur->iPage++] = pCur->ix; |
| 63872 | + pCur->ix = 0; |
| 63796 | 63873 | return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage], |
| 63797 | 63874 | pCur, pCur->curPagerFlags); |
| 63798 | 63875 | } |
| 63799 | 63876 | |
| 63800 | 63877 | #ifdef SQLITE_DEBUG |
| | @@ -63838,10 +63915,11 @@ |
| 63838 | 63915 | pCur->apPage[pCur->iPage]->pgno |
| 63839 | 63916 | ); |
| 63840 | 63917 | testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell ); |
| 63841 | 63918 | pCur->info.nSize = 0; |
| 63842 | 63919 | pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 63920 | + pCur->ix = pCur->aiIdx[pCur->iPage-1]; |
| 63843 | 63921 | releasePageNotNull(pCur->apPage[pCur->iPage--]); |
| 63844 | 63922 | } |
| 63845 | 63923 | |
| 63846 | 63924 | /* |
| 63847 | 63925 | ** Move the cursor to point to the root page of its b-tree structure. |
| | @@ -63919,11 +63997,11 @@ |
| 63919 | 63997 | if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){ |
| 63920 | 63998 | return SQLITE_CORRUPT_BKPT; |
| 63921 | 63999 | } |
| 63922 | 64000 | |
| 63923 | 64001 | skip_init: |
| 63924 | | - pCur->aiIdx[0] = 0; |
| 64002 | + pCur->ix = 0; |
| 63925 | 64003 | pCur->info.nSize = 0; |
| 63926 | 64004 | pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl); |
| 63927 | 64005 | |
| 63928 | 64006 | pRoot = pCur->apPage[0]; |
| 63929 | 64007 | if( pRoot->nCell>0 ){ |
| | @@ -63953,12 +64031,12 @@ |
| 63953 | 64031 | MemPage *pPage; |
| 63954 | 64032 | |
| 63955 | 64033 | assert( cursorOwnsBtShared(pCur) ); |
| 63956 | 64034 | assert( pCur->eState==CURSOR_VALID ); |
| 63957 | 64035 | while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){ |
| 63958 | | - assert( pCur->aiIdx[pCur->iPage]<pPage->nCell ); |
| 63959 | | - pgno = get4byte(findCell(pPage, pCur->aiIdx[pCur->iPage])); |
| 64036 | + assert( pCur->ix<pPage->nCell ); |
| 64037 | + pgno = get4byte(findCell(pPage, pCur->ix)); |
| 63960 | 64038 | rc = moveToChild(pCur, pgno); |
| 63961 | 64039 | } |
| 63962 | 64040 | return rc; |
| 63963 | 64041 | } |
| 63964 | 64042 | |
| | @@ -63979,15 +64057,15 @@ |
| 63979 | 64057 | |
| 63980 | 64058 | assert( cursorOwnsBtShared(pCur) ); |
| 63981 | 64059 | assert( pCur->eState==CURSOR_VALID ); |
| 63982 | 64060 | while( !(pPage = pCur->apPage[pCur->iPage])->leaf ){ |
| 63983 | 64061 | pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 63984 | | - pCur->aiIdx[pCur->iPage] = pPage->nCell; |
| 64062 | + pCur->ix = pPage->nCell; |
| 63985 | 64063 | rc = moveToChild(pCur, pgno); |
| 63986 | 64064 | if( rc ) return rc; |
| 63987 | 64065 | } |
| 63988 | | - pCur->aiIdx[pCur->iPage] = pPage->nCell-1; |
| 64066 | + pCur->ix = pPage->nCell-1; |
| 63989 | 64067 | assert( pCur->info.nSize==0 ); |
| 63990 | 64068 | assert( (pCur->curFlags & BTCF_ValidNKey)==0 ); |
| 63991 | 64069 | return SQLITE_OK; |
| 63992 | 64070 | } |
| 63993 | 64071 | |
| | @@ -64031,11 +64109,11 @@ |
| 64031 | 64109 | ** to the last entry in the b-tree. */ |
| 64032 | 64110 | int ii; |
| 64033 | 64111 | for(ii=0; ii<pCur->iPage; ii++){ |
| 64034 | 64112 | assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); |
| 64035 | 64113 | } |
| 64036 | | - assert( pCur->aiIdx[pCur->iPage]==pCur->apPage[pCur->iPage]->nCell-1 ); |
| 64114 | + assert( pCur->ix==pCur->apPage[pCur->iPage]->nCell-1 ); |
| 64037 | 64115 | assert( pCur->apPage[pCur->iPage]->leaf ); |
| 64038 | 64116 | #endif |
| 64039 | 64117 | return SQLITE_OK; |
| 64040 | 64118 | } |
| 64041 | 64119 | |
| | @@ -64178,11 +64256,11 @@ |
| 64178 | 64256 | assert( pPage->intKey==(pIdxKey==0) ); |
| 64179 | 64257 | lwr = 0; |
| 64180 | 64258 | upr = pPage->nCell-1; |
| 64181 | 64259 | assert( biasRight==0 || biasRight==1 ); |
| 64182 | 64260 | idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ |
| 64183 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64261 | + pCur->ix = (u16)idx; |
| 64184 | 64262 | if( xRecordCompare==0 ){ |
| 64185 | 64263 | for(;;){ |
| 64186 | 64264 | i64 nCellKey; |
| 64187 | 64265 | pCell = findCellPastPtr(pPage, idx); |
| 64188 | 64266 | if( pPage->intKeyLeaf ){ |
| | @@ -64197,11 +64275,11 @@ |
| 64197 | 64275 | }else if( nCellKey>intKey ){ |
| 64198 | 64276 | upr = idx-1; |
| 64199 | 64277 | if( lwr>upr ){ c = +1; break; } |
| 64200 | 64278 | }else{ |
| 64201 | 64279 | assert( nCellKey==intKey ); |
| 64202 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64280 | + pCur->ix = (u16)idx; |
| 64203 | 64281 | if( !pPage->leaf ){ |
| 64204 | 64282 | lwr = idx; |
| 64205 | 64283 | goto moveto_next_layer; |
| 64206 | 64284 | }else{ |
| 64207 | 64285 | pCur->curFlags |= BTCF_ValidNKey; |
| | @@ -64266,11 +64344,11 @@ |
| 64266 | 64344 | pCellKey = sqlite3Malloc( nCell+18 ); |
| 64267 | 64345 | if( pCellKey==0 ){ |
| 64268 | 64346 | rc = SQLITE_NOMEM_BKPT; |
| 64269 | 64347 | goto moveto_finish; |
| 64270 | 64348 | } |
| 64271 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64349 | + pCur->ix = (u16)idx; |
| 64272 | 64350 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); |
| 64273 | 64351 | pCur->curFlags &= ~BTCF_ValidOvfl; |
| 64274 | 64352 | if( rc ){ |
| 64275 | 64353 | sqlite3_free(pCellKey); |
| 64276 | 64354 | goto moveto_finish; |
| | @@ -64288,11 +64366,11 @@ |
| 64288 | 64366 | upr = idx-1; |
| 64289 | 64367 | }else{ |
| 64290 | 64368 | assert( c==0 ); |
| 64291 | 64369 | *pRes = 0; |
| 64292 | 64370 | rc = SQLITE_OK; |
| 64293 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64371 | + pCur->ix = (u16)idx; |
| 64294 | 64372 | if( pIdxKey->errCode ) rc = SQLITE_CORRUPT; |
| 64295 | 64373 | goto moveto_finish; |
| 64296 | 64374 | } |
| 64297 | 64375 | if( lwr>upr ) break; |
| 64298 | 64376 | assert( lwr+upr>=0 ); |
| | @@ -64300,12 +64378,12 @@ |
| 64300 | 64378 | } |
| 64301 | 64379 | } |
| 64302 | 64380 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 64303 | 64381 | assert( pPage->isInit ); |
| 64304 | 64382 | if( pPage->leaf ){ |
| 64305 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 64306 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64383 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 64384 | + pCur->ix = (u16)idx; |
| 64307 | 64385 | *pRes = c; |
| 64308 | 64386 | rc = SQLITE_OK; |
| 64309 | 64387 | goto moveto_finish; |
| 64310 | 64388 | } |
| 64311 | 64389 | moveto_next_layer: |
| | @@ -64312,11 +64390,11 @@ |
| 64312 | 64390 | if( lwr>=pPage->nCell ){ |
| 64313 | 64391 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 64314 | 64392 | }else{ |
| 64315 | 64393 | chldPg = get4byte(findCell(pPage, lwr)); |
| 64316 | 64394 | } |
| 64317 | | - pCur->aiIdx[pCur->iPage] = (u16)lwr; |
| 64395 | + pCur->ix = (u16)lwr; |
| 64318 | 64396 | rc = moveToChild(pCur, chldPg); |
| 64319 | 64397 | if( rc ) break; |
| 64320 | 64398 | } |
| 64321 | 64399 | moveto_finish: |
| 64322 | 64400 | pCur->info.nSize = 0; |
| | @@ -64413,11 +64491,11 @@ |
| 64413 | 64491 | pCur->skipNext = 0; |
| 64414 | 64492 | } |
| 64415 | 64493 | } |
| 64416 | 64494 | |
| 64417 | 64495 | pPage = pCur->apPage[pCur->iPage]; |
| 64418 | | - idx = ++pCur->aiIdx[pCur->iPage]; |
| 64496 | + idx = ++pCur->ix; |
| 64419 | 64497 | assert( pPage->isInit ); |
| 64420 | 64498 | |
| 64421 | 64499 | /* If the database file is corrupt, it is possible for the value of idx |
| 64422 | 64500 | ** to be invalid here. This can only occur if a second cursor modifies |
| 64423 | 64501 | ** the page while cursor pCur is holding a reference to it. Which can |
| | @@ -64437,11 +64515,11 @@ |
| 64437 | 64515 | pCur->eState = CURSOR_INVALID; |
| 64438 | 64516 | return SQLITE_OK; |
| 64439 | 64517 | } |
| 64440 | 64518 | moveToParent(pCur); |
| 64441 | 64519 | pPage = pCur->apPage[pCur->iPage]; |
| 64442 | | - }while( pCur->aiIdx[pCur->iPage]>=pPage->nCell ); |
| 64520 | + }while( pCur->ix>=pPage->nCell ); |
| 64443 | 64521 | if( pPage->intKey ){ |
| 64444 | 64522 | return sqlite3BtreeNext(pCur, pRes); |
| 64445 | 64523 | }else{ |
| 64446 | 64524 | return SQLITE_OK; |
| 64447 | 64525 | } |
| | @@ -64461,12 +64539,12 @@ |
| 64461 | 64539 | pCur->info.nSize = 0; |
| 64462 | 64540 | pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 64463 | 64541 | *pRes = 0; |
| 64464 | 64542 | if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur, pRes); |
| 64465 | 64543 | pPage = pCur->apPage[pCur->iPage]; |
| 64466 | | - if( (++pCur->aiIdx[pCur->iPage])>=pPage->nCell ){ |
| 64467 | | - pCur->aiIdx[pCur->iPage]--; |
| 64544 | + if( (++pCur->ix)>=pPage->nCell ){ |
| 64545 | + pCur->ix--; |
| 64468 | 64546 | return btreeNext(pCur, pRes); |
| 64469 | 64547 | } |
| 64470 | 64548 | if( pPage->leaf ){ |
| 64471 | 64549 | return SQLITE_OK; |
| 64472 | 64550 | }else{ |
| | @@ -64526,16 +64604,16 @@ |
| 64526 | 64604 | } |
| 64527 | 64605 | |
| 64528 | 64606 | pPage = pCur->apPage[pCur->iPage]; |
| 64529 | 64607 | assert( pPage->isInit ); |
| 64530 | 64608 | if( !pPage->leaf ){ |
| 64531 | | - int idx = pCur->aiIdx[pCur->iPage]; |
| 64609 | + int idx = pCur->ix; |
| 64532 | 64610 | rc = moveToChild(pCur, get4byte(findCell(pPage, idx))); |
| 64533 | 64611 | if( rc ) return rc; |
| 64534 | 64612 | rc = moveToRightmost(pCur); |
| 64535 | 64613 | }else{ |
| 64536 | | - while( pCur->aiIdx[pCur->iPage]==0 ){ |
| 64614 | + while( pCur->ix==0 ){ |
| 64537 | 64615 | if( pCur->iPage==0 ){ |
| 64538 | 64616 | pCur->eState = CURSOR_INVALID; |
| 64539 | 64617 | *pRes = 1; |
| 64540 | 64618 | return SQLITE_OK; |
| 64541 | 64619 | } |
| | @@ -64542,11 +64620,11 @@ |
| 64542 | 64620 | moveToParent(pCur); |
| 64543 | 64621 | } |
| 64544 | 64622 | assert( pCur->info.nSize==0 ); |
| 64545 | 64623 | assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 ); |
| 64546 | 64624 | |
| 64547 | | - pCur->aiIdx[pCur->iPage]--; |
| 64625 | + pCur->ix--; |
| 64548 | 64626 | pPage = pCur->apPage[pCur->iPage]; |
| 64549 | 64627 | if( pPage->intKey && !pPage->leaf ){ |
| 64550 | 64628 | rc = sqlite3BtreePrevious(pCur, pRes); |
| 64551 | 64629 | }else{ |
| 64552 | 64630 | rc = SQLITE_OK; |
| | @@ -64561,16 +64639,16 @@ |
| 64561 | 64639 | assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); |
| 64562 | 64640 | *pRes = 0; |
| 64563 | 64641 | pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey); |
| 64564 | 64642 | pCur->info.nSize = 0; |
| 64565 | 64643 | if( pCur->eState!=CURSOR_VALID |
| 64566 | | - || pCur->aiIdx[pCur->iPage]==0 |
| 64644 | + || pCur->ix==0 |
| 64567 | 64645 | || pCur->apPage[pCur->iPage]->leaf==0 |
| 64568 | 64646 | ){ |
| 64569 | 64647 | return btreePrevious(pCur, pRes); |
| 64570 | 64648 | } |
| 64571 | | - pCur->aiIdx[pCur->iPage]--; |
| 64649 | + pCur->ix--; |
| 64572 | 64650 | return SQLITE_OK; |
| 64573 | 64651 | } |
| 64574 | 64652 | |
| 64575 | 64653 | /* |
| 64576 | 64654 | ** Allocate a new page from the database file. |
| | @@ -66888,12 +66966,12 @@ |
| 66888 | 66966 | assert( balance_deeper_called==0 ); |
| 66889 | 66967 | VVA_ONLY( balance_deeper_called++ ); |
| 66890 | 66968 | rc = balance_deeper(pPage, &pCur->apPage[1]); |
| 66891 | 66969 | if( rc==SQLITE_OK ){ |
| 66892 | 66970 | pCur->iPage = 1; |
| 66971 | + pCur->ix = 0; |
| 66893 | 66972 | pCur->aiIdx[0] = 0; |
| 66894 | | - pCur->aiIdx[1] = 0; |
| 66895 | 66973 | assert( pCur->apPage[1]->nOverflow ); |
| 66896 | 66974 | } |
| 66897 | 66975 | }else{ |
| 66898 | 66976 | break; |
| 66899 | 66977 | } |
| | @@ -67066,11 +67144,11 @@ |
| 67066 | 67144 | |
| 67067 | 67145 | if( pCur->pKeyInfo==0 ){ |
| 67068 | 67146 | assert( pX->pKey==0 ); |
| 67069 | 67147 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 67070 | 67148 | ** cursors open on the row being replaced */ |
| 67071 | | - invalidateIncrblobCursors(p, pX->nKey, 0); |
| 67149 | + invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); |
| 67072 | 67150 | |
| 67073 | 67151 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 67074 | 67152 | ** to a row with the same key as the new entry being inserted. */ |
| 67075 | 67153 | assert( (flags & BTREE_SAVEPOSITION)==0 || |
| 67076 | 67154 | ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) ); |
| | @@ -67078,13 +67156,10 @@ |
| 67078 | 67156 | /* If the cursor is currently on the last row and we are appending a |
| 67079 | 67157 | ** new row onto the end, set the "loc" to avoid an unnecessary |
| 67080 | 67158 | ** btreeMoveto() call */ |
| 67081 | 67159 | if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){ |
| 67082 | 67160 | loc = 0; |
| 67083 | | - }else if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0 |
| 67084 | | - && pCur->info.nKey==pX->nKey-1 ){ |
| 67085 | | - loc = -1; |
| 67086 | 67161 | }else if( loc==0 ){ |
| 67087 | 67162 | rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc); |
| 67088 | 67163 | if( rc ) return rc; |
| 67089 | 67164 | } |
| 67090 | 67165 | }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){ |
| | @@ -67118,11 +67193,11 @@ |
| 67118 | 67193 | assert( newCell!=0 ); |
| 67119 | 67194 | rc = fillInCell(pPage, newCell, pX, &szNew); |
| 67120 | 67195 | if( rc ) goto end_insert; |
| 67121 | 67196 | assert( szNew==pPage->xCellSize(pPage, newCell) ); |
| 67122 | 67197 | assert( szNew <= MX_CELL_SIZE(pBt) ); |
| 67123 | | - idx = pCur->aiIdx[pCur->iPage]; |
| 67198 | + idx = pCur->ix; |
| 67124 | 67199 | if( loc==0 ){ |
| 67125 | 67200 | CellInfo info; |
| 67126 | 67201 | assert( idx<pPage->nCell ); |
| 67127 | 67202 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 67128 | 67203 | if( rc ){ |
| | @@ -67146,11 +67221,12 @@ |
| 67146 | 67221 | } |
| 67147 | 67222 | dropCell(pPage, idx, info.nSize, &rc); |
| 67148 | 67223 | if( rc ) goto end_insert; |
| 67149 | 67224 | }else if( loc<0 && pPage->nCell>0 ){ |
| 67150 | 67225 | assert( pPage->leaf ); |
| 67151 | | - idx = ++pCur->aiIdx[pCur->iPage]; |
| 67226 | + idx = ++pCur->ix; |
| 67227 | + pCur->curFlags &= ~BTCF_ValidNKey; |
| 67152 | 67228 | }else{ |
| 67153 | 67229 | assert( pPage->leaf ); |
| 67154 | 67230 | } |
| 67155 | 67231 | insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); |
| 67156 | 67232 | assert( pPage->nOverflow==0 || rc==SQLITE_OK ); |
| | @@ -67242,16 +67318,16 @@ |
| 67242 | 67318 | assert( pBt->inTransaction==TRANS_WRITE ); |
| 67243 | 67319 | assert( (pBt->btsFlags & BTS_READ_ONLY)==0 ); |
| 67244 | 67320 | assert( pCur->curFlags & BTCF_WriteFlag ); |
| 67245 | 67321 | assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) ); |
| 67246 | 67322 | assert( !hasReadConflicts(p, pCur->pgnoRoot) ); |
| 67247 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 67323 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 67248 | 67324 | assert( pCur->eState==CURSOR_VALID ); |
| 67249 | 67325 | assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); |
| 67250 | 67326 | |
| 67251 | 67327 | iCellDepth = pCur->iPage; |
| 67252 | | - iCellIdx = pCur->aiIdx[iCellDepth]; |
| 67328 | + iCellIdx = pCur->ix; |
| 67253 | 67329 | pPage = pCur->apPage[iCellDepth]; |
| 67254 | 67330 | pCell = findCell(pPage, iCellIdx); |
| 67255 | 67331 | |
| 67256 | 67332 | /* If the bPreserve flag is set to true, then the cursor position must |
| 67257 | 67333 | ** be preserved following this delete operation. If the current delete |
| | @@ -67296,11 +67372,11 @@ |
| 67296 | 67372 | } |
| 67297 | 67373 | |
| 67298 | 67374 | /* If this is a delete operation to remove a row from a table b-tree, |
| 67299 | 67375 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 67300 | 67376 | if( pCur->pKeyInfo==0 ){ |
| 67301 | | - invalidateIncrblobCursors(p, pCur->info.nKey, 0); |
| 67377 | + invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 67302 | 67378 | } |
| 67303 | 67379 | |
| 67304 | 67380 | /* Make the page containing the entry to be deleted writable. Then free any |
| 67305 | 67381 | ** overflow pages associated with the entry and finally remove the cell |
| 67306 | 67382 | ** itself from within the page. */ |
| | @@ -67364,11 +67440,11 @@ |
| 67364 | 67440 | assert( pPage==pCur->apPage[pCur->iPage] || CORRUPT_DB ); |
| 67365 | 67441 | assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell ); |
| 67366 | 67442 | pCur->eState = CURSOR_SKIPNEXT; |
| 67367 | 67443 | if( iCellIdx>=pPage->nCell ){ |
| 67368 | 67444 | pCur->skipNext = -1; |
| 67369 | | - pCur->aiIdx[iCellDepth] = pPage->nCell-1; |
| 67445 | + pCur->ix = pPage->nCell-1; |
| 67370 | 67446 | }else{ |
| 67371 | 67447 | pCur->skipNext = 1; |
| 67372 | 67448 | } |
| 67373 | 67449 | }else{ |
| 67374 | 67450 | rc = moveToRoot(pCur); |
| | @@ -67623,11 +67699,11 @@ |
| 67623 | 67699 | |
| 67624 | 67700 | if( SQLITE_OK==rc ){ |
| 67625 | 67701 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 67626 | 67702 | ** is the root of a table b-tree - if it is not, the following call is |
| 67627 | 67703 | ** a no-op). */ |
| 67628 | | - invalidateIncrblobCursors(p, 0, 1); |
| 67704 | + invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); |
| 67629 | 67705 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 67630 | 67706 | } |
| 67631 | 67707 | sqlite3BtreeLeave(p); |
| 67632 | 67708 | return rc; |
| 67633 | 67709 | } |
| | @@ -67877,20 +67953,20 @@ |
| 67877 | 67953 | /* All pages of the b-tree have been visited. Return successfully. */ |
| 67878 | 67954 | *pnEntry = nEntry; |
| 67879 | 67955 | return moveToRoot(pCur); |
| 67880 | 67956 | } |
| 67881 | 67957 | moveToParent(pCur); |
| 67882 | | - }while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell ); |
| 67958 | + }while ( pCur->ix>=pCur->apPage[pCur->iPage]->nCell ); |
| 67883 | 67959 | |
| 67884 | | - pCur->aiIdx[pCur->iPage]++; |
| 67960 | + pCur->ix++; |
| 67885 | 67961 | pPage = pCur->apPage[pCur->iPage]; |
| 67886 | 67962 | } |
| 67887 | 67963 | |
| 67888 | 67964 | /* Descend to the child node of the cell that the cursor currently |
| 67889 | 67965 | ** points at. This is the right-child if (iIdx==pPage->nCell). |
| 67890 | 67966 | */ |
| 67891 | | - iIdx = pCur->aiIdx[pCur->iPage]; |
| 67967 | + iIdx = pCur->ix; |
| 67892 | 67968 | if( iIdx==pPage->nCell ){ |
| 67893 | 67969 | rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); |
| 67894 | 67970 | }else{ |
| 67895 | 67971 | rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx))); |
| 67896 | 67972 | } |
| | @@ -68271,10 +68347,11 @@ |
| 68271 | 68347 | if( pPage->intKey ){ |
| 68272 | 68348 | if( keyCanBeEqual ? (info.nKey > maxKey) : (info.nKey >= maxKey) ){ |
| 68273 | 68349 | checkAppendMsg(pCheck, "Rowid %lld out of order", info.nKey); |
| 68274 | 68350 | } |
| 68275 | 68351 | maxKey = info.nKey; |
| 68352 | + keyCanBeEqual = 0; /* Only the first key on the page may ==maxKey */ |
| 68276 | 68353 | } |
| 68277 | 68354 | |
| 68278 | 68355 | /* Check the content overflow list */ |
| 68279 | 68356 | if( info.nPayload>info.nLocal ){ |
| 68280 | 68357 | int nPage; /* Number of pages on the overflow chain */ |
| | @@ -69656,10 +69733,14 @@ |
| 69656 | 69733 | assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 ); |
| 69657 | 69734 | |
| 69658 | 69735 | /* Cannot be both MEM_Int and MEM_Real at the same time */ |
| 69659 | 69736 | assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); |
| 69660 | 69737 | |
| 69738 | + /* Cannot be both MEM_Null and some other type */ |
| 69739 | + assert( (p->flags & MEM_Null)==0 || |
| 69740 | + (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob))==0 ); |
| 69741 | + |
| 69661 | 69742 | /* The szMalloc field holds the correct memory allocation size */ |
| 69662 | 69743 | assert( p->szMalloc==0 |
| 69663 | 69744 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 69664 | 69745 | |
| 69665 | 69746 | /* If p holds a string or blob, the Mem.z must point to exactly |
| | @@ -69741,30 +69822,28 @@ |
| 69741 | 69822 | assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 69742 | 69823 | testcase( bPreserve && pMem->z==0 ); |
| 69743 | 69824 | |
| 69744 | 69825 | assert( pMem->szMalloc==0 |
| 69745 | 69826 | || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) ); |
| 69746 | | - if( pMem->szMalloc<n ){ |
| 69747 | | - if( n<32 ) n = 32; |
| 69748 | | - if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){ |
| 69749 | | - pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 69750 | | - bPreserve = 0; |
| 69751 | | - }else{ |
| 69752 | | - if( pMem->szMalloc>0 ) sqlite3DbFree(pMem->db, pMem->zMalloc); |
| 69753 | | - pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n); |
| 69754 | | - } |
| 69755 | | - if( pMem->zMalloc==0 ){ |
| 69756 | | - sqlite3VdbeMemSetNull(pMem); |
| 69757 | | - pMem->z = 0; |
| 69758 | | - pMem->szMalloc = 0; |
| 69759 | | - return SQLITE_NOMEM_BKPT; |
| 69760 | | - }else{ |
| 69761 | | - pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc); |
| 69762 | | - } |
| 69763 | | - } |
| 69764 | | - |
| 69765 | | - if( bPreserve && pMem->z && pMem->z!=pMem->zMalloc ){ |
| 69827 | + if( n<32 ) n = 32; |
| 69828 | + if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){ |
| 69829 | + pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 69830 | + bPreserve = 0; |
| 69831 | + }else{ |
| 69832 | + if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 69833 | + pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n); |
| 69834 | + } |
| 69835 | + if( pMem->zMalloc==0 ){ |
| 69836 | + sqlite3VdbeMemSetNull(pMem); |
| 69837 | + pMem->z = 0; |
| 69838 | + pMem->szMalloc = 0; |
| 69839 | + return SQLITE_NOMEM_BKPT; |
| 69840 | + }else{ |
| 69841 | + pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc); |
| 69842 | + } |
| 69843 | + |
| 69844 | + if( bPreserve && pMem->z && ALWAYS(pMem->z!=pMem->zMalloc) ){ |
| 69766 | 69845 | memcpy(pMem->zMalloc, pMem->z, pMem->n); |
| 69767 | 69846 | } |
| 69768 | 69847 | if( (pMem->flags&MEM_Dyn)!=0 ){ |
| 69769 | 69848 | assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC ); |
| 69770 | 69849 | pMem->xDel((void *)(pMem->z)); |
| | @@ -69957,11 +70036,11 @@ |
| 69957 | 70036 | ctx.pOut = &t; |
| 69958 | 70037 | ctx.pMem = pMem; |
| 69959 | 70038 | ctx.pFunc = pFunc; |
| 69960 | 70039 | pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */ |
| 69961 | 70040 | assert( (pMem->flags & MEM_Dyn)==0 ); |
| 69962 | | - if( pMem->szMalloc>0 ) sqlite3DbFree(pMem->db, pMem->zMalloc); |
| 70041 | + if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 69963 | 70042 | memcpy(pMem, &t, sizeof(t)); |
| 69964 | 70043 | rc = ctx.isError; |
| 69965 | 70044 | } |
| 69966 | 70045 | return rc; |
| 69967 | 70046 | } |
| | @@ -70008,11 +70087,11 @@ |
| 70008 | 70087 | static SQLITE_NOINLINE void vdbeMemClear(Mem *p){ |
| 70009 | 70088 | if( VdbeMemDynamic(p) ){ |
| 70010 | 70089 | vdbeMemClearExternAndSetNull(p); |
| 70011 | 70090 | } |
| 70012 | 70091 | if( p->szMalloc ){ |
| 70013 | | - sqlite3DbFree(p->db, p->zMalloc); |
| 70092 | + sqlite3DbFreeNN(p->db, p->zMalloc); |
| 70014 | 70093 | p->szMalloc = 0; |
| 70015 | 70094 | } |
| 70016 | 70095 | p->z = 0; |
| 70017 | 70096 | } |
| 70018 | 70097 | |
| | @@ -70036,11 +70115,11 @@ |
| 70036 | 70115 | /* |
| 70037 | 70116 | ** Convert a 64-bit IEEE double into a 64-bit signed integer. |
| 70038 | 70117 | ** If the double is out of range of a 64-bit signed integer then |
| 70039 | 70118 | ** return the closest available 64-bit signed integer. |
| 70040 | 70119 | */ |
| 70041 | | -static i64 doubleToInt64(double r){ |
| 70120 | +static SQLITE_NOINLINE i64 doubleToInt64(double r){ |
| 70042 | 70121 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 70043 | 70122 | /* When floating-point is omitted, double and int64 are the same thing */ |
| 70044 | 70123 | return r; |
| 70045 | 70124 | #else |
| 70046 | 70125 | /* |
| | @@ -70072,10 +70151,15 @@ |
| 70072 | 70151 | ** it into an integer and return that. If pMem represents an |
| 70073 | 70152 | ** an SQL-NULL value, return 0. |
| 70074 | 70153 | ** |
| 70075 | 70154 | ** If pMem represents a string value, its encoding might be changed. |
| 70076 | 70155 | */ |
| 70156 | +static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){ |
| 70157 | + i64 value = 0; |
| 70158 | + sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc); |
| 70159 | + return value; |
| 70160 | +} |
| 70077 | 70161 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){ |
| 70078 | 70162 | int flags; |
| 70079 | 70163 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 70080 | 70164 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 70081 | 70165 | flags = pMem->flags; |
| | @@ -70082,14 +70166,12 @@ |
| 70082 | 70166 | if( flags & MEM_Int ){ |
| 70083 | 70167 | return pMem->u.i; |
| 70084 | 70168 | }else if( flags & MEM_Real ){ |
| 70085 | 70169 | return doubleToInt64(pMem->u.r); |
| 70086 | 70170 | }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 70087 | | - i64 value = 0; |
| 70088 | 70171 | assert( pMem->z || pMem->n==0 ); |
| 70089 | | - sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc); |
| 70090 | | - return value; |
| 70172 | + return memIntValue(pMem); |
| 70091 | 70173 | }else{ |
| 70092 | 70174 | return 0; |
| 70093 | 70175 | } |
| 70094 | 70176 | } |
| 70095 | 70177 | |
| | @@ -70097,22 +70179,25 @@ |
| 70097 | 70179 | ** Return the best representation of pMem that we can get into a |
| 70098 | 70180 | ** double. If pMem is already a double or an integer, return its |
| 70099 | 70181 | ** value. If it is a string or blob, try to convert it to a double. |
| 70100 | 70182 | ** If it is a NULL, return 0.0. |
| 70101 | 70183 | */ |
| 70184 | +static SQLITE_NOINLINE double memRealValue(Mem *pMem){ |
| 70185 | + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 70186 | + double val = (double)0; |
| 70187 | + sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc); |
| 70188 | + return val; |
| 70189 | +} |
| 70102 | 70190 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){ |
| 70103 | 70191 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 70104 | 70192 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 70105 | 70193 | if( pMem->flags & MEM_Real ){ |
| 70106 | 70194 | return pMem->u.r; |
| 70107 | 70195 | }else if( pMem->flags & MEM_Int ){ |
| 70108 | 70196 | return (double)pMem->u.i; |
| 70109 | 70197 | }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ |
| 70110 | | - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 70111 | | - double val = (double)0; |
| 70112 | | - sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc); |
| 70113 | | - return val; |
| 70198 | + return memRealValue(pMem); |
| 70114 | 70199 | }else{ |
| 70115 | 70200 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 70116 | 70201 | return (double)0; |
| 70117 | 70202 | } |
| 70118 | 70203 | } |
| | @@ -70733,11 +70818,11 @@ |
| 70733 | 70818 | for(i=0; i<nCol; i++){ |
| 70734 | 70819 | pRec->aMem[i].flags = MEM_Null; |
| 70735 | 70820 | pRec->aMem[i].db = db; |
| 70736 | 70821 | } |
| 70737 | 70822 | }else{ |
| 70738 | | - sqlite3DbFree(db, pRec); |
| 70823 | + sqlite3DbFreeNN(db, pRec); |
| 70739 | 70824 | pRec = 0; |
| 70740 | 70825 | } |
| 70741 | 70826 | } |
| 70742 | 70827 | if( pRec==0 ) return 0; |
| 70743 | 70828 | p->ppRec[0] = pRec; |
| | @@ -70845,11 +70930,11 @@ |
| 70845 | 70930 | } |
| 70846 | 70931 | if( apVal ){ |
| 70847 | 70932 | for(i=0; i<nVal; i++){ |
| 70848 | 70933 | sqlite3ValueFree(apVal[i]); |
| 70849 | 70934 | } |
| 70850 | | - sqlite3DbFree(db, apVal); |
| 70935 | + sqlite3DbFreeNN(db, apVal); |
| 70851 | 70936 | } |
| 70852 | 70937 | |
| 70853 | 70938 | *ppVal = pVal; |
| 70854 | 70939 | return rc; |
| 70855 | 70940 | } |
| | @@ -71044,11 +71129,11 @@ |
| 71044 | 71129 | }else{ |
| 71045 | 71130 | aRet[0] = nSerial+1; |
| 71046 | 71131 | putVarint32(&aRet[1], iSerial); |
| 71047 | 71132 | sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial); |
| 71048 | 71133 | sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT); |
| 71049 | | - sqlite3DbFree(db, aRet); |
| 71134 | + sqlite3DbFreeNN(db, aRet); |
| 71050 | 71135 | } |
| 71051 | 71136 | } |
| 71052 | 71137 | |
| 71053 | 71138 | /* |
| 71054 | 71139 | ** Register built-in functions used to help read ANALYZE data. |
| | @@ -71271,11 +71356,11 @@ |
| 71271 | 71356 | sqlite3 *db = aMem[0].db; |
| 71272 | 71357 | for(i=0; i<nCol; i++){ |
| 71273 | 71358 | sqlite3VdbeMemRelease(&aMem[i]); |
| 71274 | 71359 | } |
| 71275 | 71360 | sqlite3KeyInfoUnref(pRec->pKeyInfo); |
| 71276 | | - sqlite3DbFree(db, pRec); |
| 71361 | + sqlite3DbFreeNN(db, pRec); |
| 71277 | 71362 | } |
| 71278 | 71363 | } |
| 71279 | 71364 | #endif /* ifdef SQLITE_ENABLE_STAT4 */ |
| 71280 | 71365 | |
| 71281 | 71366 | /* |
| | @@ -71295,11 +71380,11 @@ |
| 71295 | 71380 | ** Free an sqlite3_value object |
| 71296 | 71381 | */ |
| 71297 | 71382 | SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){ |
| 71298 | 71383 | if( !v ) return; |
| 71299 | 71384 | sqlite3VdbeMemRelease((Mem *)v); |
| 71300 | | - sqlite3DbFree(((Mem*)v)->db, v); |
| 71385 | + sqlite3DbFreeNN(((Mem*)v)->db, v); |
| 71301 | 71386 | } |
| 71302 | 71387 | |
| 71303 | 71388 | /* |
| 71304 | 71389 | ** The sqlite3ValueBytes() routine returns the number of bytes in the |
| 71305 | 71390 | ** sqlite3_value object assuming that it uses the encoding "enc". |
| | @@ -72138,11 +72223,11 @@ |
| 72138 | 72223 | ** If the input FuncDef structure is ephemeral, then free it. If |
| 72139 | 72224 | ** the FuncDef is not ephermal, then do nothing. |
| 72140 | 72225 | */ |
| 72141 | 72226 | static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ |
| 72142 | 72227 | if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){ |
| 72143 | | - sqlite3DbFree(db, pDef); |
| 72228 | + sqlite3DbFreeNN(db, pDef); |
| 72144 | 72229 | } |
| 72145 | 72230 | } |
| 72146 | 72231 | |
| 72147 | 72232 | static void vdbeFreeOpArray(sqlite3 *, Op *, int); |
| 72148 | 72233 | |
| | @@ -72149,15 +72234,15 @@ |
| 72149 | 72234 | /* |
| 72150 | 72235 | ** Delete a P4 value if necessary. |
| 72151 | 72236 | */ |
| 72152 | 72237 | static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){ |
| 72153 | 72238 | if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); |
| 72154 | | - sqlite3DbFree(db, p); |
| 72239 | + sqlite3DbFreeNN(db, p); |
| 72155 | 72240 | } |
| 72156 | 72241 | static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){ |
| 72157 | 72242 | freeEphemeralFunction(db, p->pFunc); |
| 72158 | | - sqlite3DbFree(db, p); |
| 72243 | + sqlite3DbFreeNN(db, p); |
| 72159 | 72244 | } |
| 72160 | 72245 | static void freeP4(sqlite3 *db, int p4type, void *p4){ |
| 72161 | 72246 | assert( db ); |
| 72162 | 72247 | switch( p4type ){ |
| 72163 | 72248 | case P4_FUNCCTX: { |
| | @@ -72206,18 +72291,18 @@ |
| 72206 | 72291 | ** nOp entries. |
| 72207 | 72292 | */ |
| 72208 | 72293 | static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){ |
| 72209 | 72294 | if( aOp ){ |
| 72210 | 72295 | Op *pOp; |
| 72211 | | - for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ |
| 72296 | + for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){ |
| 72212 | 72297 | if( pOp->p4type ) freeP4(db, pOp->p4type, pOp->p4.p); |
| 72213 | 72298 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 72214 | 72299 | sqlite3DbFree(db, pOp->zComment); |
| 72215 | 72300 | #endif |
| 72216 | 72301 | } |
| 72302 | + sqlite3DbFreeNN(db, aOp); |
| 72217 | 72303 | } |
| 72218 | | - sqlite3DbFree(db, aOp); |
| 72219 | 72304 | } |
| 72220 | 72305 | |
| 72221 | 72306 | /* |
| 72222 | 72307 | ** Link the SubProgram object passed as the second argument into the linked |
| 72223 | 72308 | ** list at Vdbe.pSubProgram. This list is used to delete all sub-program |
| | @@ -72886,11 +72971,11 @@ |
| 72886 | 72971 | testcase( p->flags & MEM_Frame ); |
| 72887 | 72972 | testcase( p->flags & MEM_RowSet ); |
| 72888 | 72973 | if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){ |
| 72889 | 72974 | sqlite3VdbeMemRelease(p); |
| 72890 | 72975 | }else if( p->szMalloc ){ |
| 72891 | | - sqlite3DbFree(db, p->zMalloc); |
| 72976 | + sqlite3DbFreeNN(db, p->zMalloc); |
| 72892 | 72977 | p->szMalloc = 0; |
| 72893 | 72978 | } |
| 72894 | 72979 | |
| 72895 | 72980 | p->flags = MEM_Undefined; |
| 72896 | 72981 | }while( (++p)<pEnd ); |
| | @@ -73362,12 +73447,12 @@ |
| 73362 | 73447 | case CURTYPE_SORTER: { |
| 73363 | 73448 | sqlite3VdbeSorterClose(p->db, pCx); |
| 73364 | 73449 | break; |
| 73365 | 73450 | } |
| 73366 | 73451 | case CURTYPE_BTREE: { |
| 73367 | | - if( pCx->pBtx ){ |
| 73368 | | - sqlite3BtreeClose(pCx->pBtx); |
| 73452 | + if( pCx->isEphemeral ){ |
| 73453 | + if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx); |
| 73369 | 73454 | /* The pCx->pCursor will be close automatically, if it exists, by |
| 73370 | 73455 | ** the call above. */ |
| 73371 | 73456 | }else{ |
| 73372 | 73457 | assert( pCx->uc.pCursor!=0 ); |
| 73373 | 73458 | sqlite3BtreeCloseCursor(pCx->uc.pCursor); |
| | @@ -74257,11 +74342,10 @@ |
| 74257 | 74342 | } |
| 74258 | 74343 | fclose(out); |
| 74259 | 74344 | } |
| 74260 | 74345 | } |
| 74261 | 74346 | #endif |
| 74262 | | - p->iCurrentTime = 0; |
| 74263 | 74347 | p->magic = VDBE_MAGIC_RESET; |
| 74264 | 74348 | return p->rc & db->errMask; |
| 74265 | 74349 | } |
| 74266 | 74350 | |
| 74267 | 74351 | /* |
| | @@ -74296,20 +74380,22 @@ |
| 74296 | 74380 | */ |
| 74297 | 74381 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){ |
| 74298 | 74382 | while( *pp ){ |
| 74299 | 74383 | AuxData *pAux = *pp; |
| 74300 | 74384 | if( (iOp<0) |
| 74301 | | - || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) |
| 74385 | + || (pAux->iAuxOp==iOp |
| 74386 | + && pAux->iAuxArg>=0 |
| 74387 | + && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg)))) |
| 74302 | 74388 | ){ |
| 74303 | | - testcase( pAux->iArg==31 ); |
| 74304 | | - if( pAux->xDelete ){ |
| 74305 | | - pAux->xDelete(pAux->pAux); |
| 74389 | + testcase( pAux->iAuxArg==31 ); |
| 74390 | + if( pAux->xDeleteAux ){ |
| 74391 | + pAux->xDeleteAux(pAux->pAux); |
| 74306 | 74392 | } |
| 74307 | | - *pp = pAux->pNext; |
| 74393 | + *pp = pAux->pNextAux; |
| 74308 | 74394 | sqlite3DbFree(db, pAux); |
| 74309 | 74395 | }else{ |
| 74310 | | - pp= &pAux->pNext; |
| 74396 | + pp= &pAux->pNextAux; |
| 74311 | 74397 | } |
| 74312 | 74398 | } |
| 74313 | 74399 | } |
| 74314 | 74400 | |
| 74315 | 74401 | /* |
| | @@ -74367,11 +74453,11 @@ |
| 74367 | 74453 | if( p->pNext ){ |
| 74368 | 74454 | p->pNext->pPrev = p->pPrev; |
| 74369 | 74455 | } |
| 74370 | 74456 | p->magic = VDBE_MAGIC_DEAD; |
| 74371 | 74457 | p->db = 0; |
| 74372 | | - sqlite3DbFree(db, p); |
| 74458 | + sqlite3DbFreeNN(db, p); |
| 74373 | 74459 | } |
| 74374 | 74460 | |
| 74375 | 74461 | /* |
| 74376 | 74462 | ** The cursor "p" has a pending seek operation that has not yet been |
| 74377 | 74463 | ** carried out. Seek the cursor now. If an error occurs, return |
| | @@ -75926,11 +76012,11 @@ |
| 75926 | 76012 | int i; |
| 75927 | 76013 | for(i=0; i<nField; i++){ |
| 75928 | 76014 | Mem *pMem = &p->aMem[i]; |
| 75929 | 76015 | if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem); |
| 75930 | 76016 | } |
| 75931 | | - sqlite3DbFree(db, p); |
| 76017 | + sqlite3DbFreeNN(db, p); |
| 75932 | 76018 | } |
| 75933 | 76019 | } |
| 75934 | 76020 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 75935 | 76021 | |
| 75936 | 76022 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| | @@ -75993,11 +76079,11 @@ |
| 75993 | 76079 | if( preupdate.aNew ){ |
| 75994 | 76080 | int i; |
| 75995 | 76081 | for(i=0; i<pCsr->nField; i++){ |
| 75996 | 76082 | sqlite3VdbeMemRelease(&preupdate.aNew[i]); |
| 75997 | 76083 | } |
| 75998 | | - sqlite3DbFree(db, preupdate.aNew); |
| 76084 | + sqlite3DbFreeNN(db, preupdate.aNew); |
| 75999 | 76085 | } |
| 76000 | 76086 | } |
| 76001 | 76087 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 76002 | 76088 | |
| 76003 | 76089 | /************** End of vdbeaux.c *********************************************/ |
| | @@ -76806,10 +76892,16 @@ |
| 76806 | 76892 | } |
| 76807 | 76893 | |
| 76808 | 76894 | /* |
| 76809 | 76895 | ** Return the auxiliary data pointer, if any, for the iArg'th argument to |
| 76810 | 76896 | ** the user-function defined by pCtx. |
| 76897 | +** |
| 76898 | +** The left-most argument is 0. |
| 76899 | +** |
| 76900 | +** Undocumented behavior: If iArg is negative then access a cache of |
| 76901 | +** auxiliary data pointers that is available to all functions within a |
| 76902 | +** single prepared statement. The iArg values must match. |
| 76811 | 76903 | */ |
| 76812 | 76904 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 76813 | 76905 | AuxData *pAuxData; |
| 76814 | 76906 | |
| 76815 | 76907 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| | @@ -76816,21 +76908,28 @@ |
| 76816 | 76908 | #if SQLITE_ENABLE_STAT3_OR_STAT4 |
| 76817 | 76909 | if( pCtx->pVdbe==0 ) return 0; |
| 76818 | 76910 | #else |
| 76819 | 76911 | assert( pCtx->pVdbe!=0 ); |
| 76820 | 76912 | #endif |
| 76821 | | - for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 76822 | | - if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 76913 | + for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){ |
| 76914 | + if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){ |
| 76915 | + return pAuxData->pAux; |
| 76916 | + } |
| 76823 | 76917 | } |
| 76824 | | - |
| 76825 | | - return (pAuxData ? pAuxData->pAux : 0); |
| 76918 | + return 0; |
| 76826 | 76919 | } |
| 76827 | 76920 | |
| 76828 | 76921 | /* |
| 76829 | 76922 | ** Set the auxiliary data pointer and delete function, for the iArg'th |
| 76830 | 76923 | ** argument to the user-function defined by pCtx. Any previous value is |
| 76831 | 76924 | ** deleted by calling the delete function specified when it was set. |
| 76925 | +** |
| 76926 | +** The left-most argument is 0. |
| 76927 | +** |
| 76928 | +** Undocumented behavior: If iArg is negative then make the data available |
| 76929 | +** to all functions within the current prepared statement using iArg as an |
| 76930 | +** access code. |
| 76832 | 76931 | */ |
| 76833 | 76932 | SQLITE_API void sqlite3_set_auxdata( |
| 76834 | 76933 | sqlite3_context *pCtx, |
| 76835 | 76934 | int iArg, |
| 76836 | 76935 | void *pAux, |
| | @@ -76838,37 +76937,38 @@ |
| 76838 | 76937 | ){ |
| 76839 | 76938 | AuxData *pAuxData; |
| 76840 | 76939 | Vdbe *pVdbe = pCtx->pVdbe; |
| 76841 | 76940 | |
| 76842 | 76941 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 76843 | | - if( iArg<0 ) goto failed; |
| 76844 | 76942 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 76845 | 76943 | if( pVdbe==0 ) goto failed; |
| 76846 | 76944 | #else |
| 76847 | 76945 | assert( pVdbe!=0 ); |
| 76848 | 76946 | #endif |
| 76849 | 76947 | |
| 76850 | | - for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 76851 | | - if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 76948 | + for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){ |
| 76949 | + if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){ |
| 76950 | + break; |
| 76951 | + } |
| 76852 | 76952 | } |
| 76853 | 76953 | if( pAuxData==0 ){ |
| 76854 | 76954 | pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData)); |
| 76855 | 76955 | if( !pAuxData ) goto failed; |
| 76856 | | - pAuxData->iOp = pCtx->iOp; |
| 76857 | | - pAuxData->iArg = iArg; |
| 76858 | | - pAuxData->pNext = pVdbe->pAuxData; |
| 76956 | + pAuxData->iAuxOp = pCtx->iOp; |
| 76957 | + pAuxData->iAuxArg = iArg; |
| 76958 | + pAuxData->pNextAux = pVdbe->pAuxData; |
| 76859 | 76959 | pVdbe->pAuxData = pAuxData; |
| 76860 | 76960 | if( pCtx->fErrorOrAux==0 ){ |
| 76861 | 76961 | pCtx->isError = 0; |
| 76862 | 76962 | pCtx->fErrorOrAux = 1; |
| 76863 | 76963 | } |
| 76864 | | - }else if( pAuxData->xDelete ){ |
| 76865 | | - pAuxData->xDelete(pAuxData->pAux); |
| 76964 | + }else if( pAuxData->xDeleteAux ){ |
| 76965 | + pAuxData->xDeleteAux(pAuxData->pAux); |
| 76866 | 76966 | } |
| 76867 | 76967 | |
| 76868 | 76968 | pAuxData->pAux = pAux; |
| 76869 | | - pAuxData->xDelete = xDelete; |
| 76969 | + pAuxData->xDeleteAux = xDelete; |
| 76870 | 76970 | return; |
| 76871 | 76971 | |
| 76872 | 76972 | failed: |
| 76873 | 76973 | if( xDelete ){ |
| 76874 | 76974 | xDelete(pAux); |
| | @@ -78579,10 +78679,11 @@ |
| 78579 | 78679 | } |
| 78580 | 78680 | static void registerTrace(int iReg, Mem *p){ |
| 78581 | 78681 | printf("REG[%d] = ", iReg); |
| 78582 | 78682 | memTracePrint(p); |
| 78583 | 78683 | printf("\n"); |
| 78684 | + sqlite3VdbeCheckMemInvariants(p); |
| 78584 | 78685 | } |
| 78585 | 78686 | #endif |
| 78586 | 78687 | |
| 78587 | 78688 | #ifdef SQLITE_DEBUG |
| 78588 | 78689 | # define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M) |
| | @@ -78945,11 +79046,11 @@ |
| 78945 | 79046 | case OP_Goto: { /* jump */ |
| 78946 | 79047 | jump_to_p2_and_check_for_interrupt: |
| 78947 | 79048 | pOp = &aOp[pOp->p2 - 1]; |
| 78948 | 79049 | |
| 78949 | 79050 | /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev, |
| 78950 | | - ** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon |
| 79051 | + ** OP_VNext, or OP_SorterNext) all jump here upon |
| 78951 | 79052 | ** completion. Check to see if sqlite3_interrupt() has been called |
| 78952 | 79053 | ** or if the progress callback needs to be invoked. |
| 78953 | 79054 | ** |
| 78954 | 79055 | ** This code uses unstructured "goto" statements and does not look clean. |
| 78955 | 79056 | ** But that is not due to sloppy coding habits. The code is written this |
| | @@ -79333,11 +79434,11 @@ |
| 79333 | 79434 | ** previously copied using OP_SCopy, the copies will continue to be valid. |
| 79334 | 79435 | */ |
| 79335 | 79436 | case OP_SoftNull: { |
| 79336 | 79437 | assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); |
| 79337 | 79438 | pOut = &aMem[pOp->p1]; |
| 79338 | | - pOut->flags = (pOut->flags|MEM_Null)&~MEM_Undefined; |
| 79439 | + pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null; |
| 79339 | 79440 | break; |
| 79340 | 79441 | } |
| 79341 | 79442 | |
| 79342 | 79443 | /* Opcode: Blob P1 P2 * P4 * |
| 79343 | 79444 | ** Synopsis: r[P2]=P4 (len=P1) |
| | @@ -79676,11 +79777,10 @@ |
| 79676 | 79777 | type1 = numericType(pIn1); |
| 79677 | 79778 | pIn2 = &aMem[pOp->p2]; |
| 79678 | 79779 | type2 = numericType(pIn2); |
| 79679 | 79780 | pOut = &aMem[pOp->p3]; |
| 79680 | 79781 | flags = pIn1->flags | pIn2->flags; |
| 79681 | | - if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; |
| 79682 | 79782 | if( (type1 & type2 & MEM_Int)!=0 ){ |
| 79683 | 79783 | iA = pIn1->u.i; |
| 79684 | 79784 | iB = pIn2->u.i; |
| 79685 | 79785 | bIntint = 1; |
| 79686 | 79786 | switch( pOp->opcode ){ |
| | @@ -79700,10 +79800,12 @@ |
| 79700 | 79800 | break; |
| 79701 | 79801 | } |
| 79702 | 79802 | } |
| 79703 | 79803 | pOut->u.i = iB; |
| 79704 | 79804 | MemSetTypeFlag(pOut, MEM_Int); |
| 79805 | + }else if( (flags & MEM_Null)!=0 ){ |
| 79806 | + goto arithmetic_result_is_null; |
| 79705 | 79807 | }else{ |
| 79706 | 79808 | bIntint = 0; |
| 79707 | 79809 | fp_math: |
| 79708 | 79810 | rA = sqlite3VdbeRealValue(pIn1); |
| 79709 | 79811 | rB = sqlite3VdbeRealValue(pIn2); |
| | @@ -79747,11 +79849,11 @@ |
| 79747 | 79849 | break; |
| 79748 | 79850 | } |
| 79749 | 79851 | |
| 79750 | 79852 | /* Opcode: CollSeq P1 * * P4 |
| 79751 | 79853 | ** |
| 79752 | | -** P4 is a pointer to a CollSeq struct. If the next call to a user function |
| 79854 | +** P4 is a pointer to a CollSeq object. If the next call to a user function |
| 79753 | 79855 | ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will |
| 79754 | 79856 | ** be returned. This is used by the built-in min(), max() and nullif() |
| 79755 | 79857 | ** functions. |
| 79756 | 79858 | ** |
| 79757 | 79859 | ** If P1 is not zero, then it is a register that a subsequent min() or |
| | @@ -80028,15 +80130,15 @@ |
| 80028 | 80130 | ** Synopsis: affinity(r[P1]) |
| 80029 | 80131 | ** |
| 80030 | 80132 | ** Force the value in register P1 to be the type defined by P2. |
| 80031 | 80133 | ** |
| 80032 | 80134 | ** <ul> |
| 80033 | | -** <li value="97"> TEXT |
| 80034 | | -** <li value="98"> BLOB |
| 80035 | | -** <li value="99"> NUMERIC |
| 80036 | | -** <li value="100"> INTEGER |
| 80037 | | -** <li value="101"> REAL |
| 80135 | +** <li> P2=='A' → BLOB |
| 80136 | +** <li> P2=='B' → TEXT |
| 80137 | +** <li> P2=='C' → NUMERIC |
| 80138 | +** <li> P2=='D' → INTEGER |
| 80139 | +** <li> P2=='E' → REAL |
| 80038 | 80140 | ** </ul> |
| 80039 | 80141 | ** |
| 80040 | 80142 | ** A NULL value is not changed by this routine. It remains NULL. |
| 80041 | 80143 | */ |
| 80042 | 80144 | case OP_Cast: { /* in1 */ |
| | @@ -80610,10 +80712,27 @@ |
| 80610 | 80712 | if( (pIn1->flags & MEM_Null)==0 ){ |
| 80611 | 80713 | goto jump_to_p2; |
| 80612 | 80714 | } |
| 80613 | 80715 | break; |
| 80614 | 80716 | } |
| 80717 | + |
| 80718 | +/* Opcode: IfNullRow P1 P2 P3 * * |
| 80719 | +** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2 |
| 80720 | +** |
| 80721 | +** Check the cursor P1 to see if it is currently pointing at a NULL row. |
| 80722 | +** If it is, then set register P3 to NULL and jump immediately to P2. |
| 80723 | +** If P1 is not on a NULL row, then fall through without making any |
| 80724 | +** changes. |
| 80725 | +*/ |
| 80726 | +case OP_IfNullRow: { /* jump */ |
| 80727 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 80728 | + if( p->apCsr[pOp->p1]->nullRow ){ |
| 80729 | + sqlite3VdbeMemSetNull(aMem + pOp->p3); |
| 80730 | + goto jump_to_p2; |
| 80731 | + } |
| 80732 | + break; |
| 80733 | +} |
| 80615 | 80734 | |
| 80616 | 80735 | /* Opcode: Column P1 P2 P3 P4 P5 |
| 80617 | 80736 | ** Synopsis: r[P3]=PX |
| 80618 | 80737 | ** |
| 80619 | 80738 | ** Interpret the data that cursor P1 points to as a structure built using |
| | @@ -80622,20 +80741,20 @@ |
| 80622 | 80741 | ** from this record. If there are less that (P2+1) |
| 80623 | 80742 | ** values in the record, extract a NULL. |
| 80624 | 80743 | ** |
| 80625 | 80744 | ** The value extracted is stored in register P3. |
| 80626 | 80745 | ** |
| 80627 | | -** If the column contains fewer than P2 fields, then extract a NULL. Or, |
| 80746 | +** If the record contains fewer than P2 fields, then extract a NULL. Or, |
| 80628 | 80747 | ** if the P4 argument is a P4_MEM use the value of the P4 argument as |
| 80629 | 80748 | ** the result. |
| 80630 | 80749 | ** |
| 80631 | 80750 | ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, |
| 80632 | 80751 | ** then the cache of the cursor is reset prior to extracting the column. |
| 80633 | 80752 | ** The first OP_Column against a pseudo-table after the value of the content |
| 80634 | 80753 | ** register has changed should have this bit set. |
| 80635 | 80754 | ** |
| 80636 | | -** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when |
| 80755 | +** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then |
| 80637 | 80756 | ** the result is guaranteed to only be used as the argument of a length() |
| 80638 | 80757 | ** or typeof() function, respectively. The loading of large blobs can be |
| 80639 | 80758 | ** skipped for length() and all content loading can be skipped for typeof(). |
| 80640 | 80759 | */ |
| 80641 | 80760 | case OP_Column: { |
| | @@ -80886,28 +81005,28 @@ |
| 80886 | 81005 | /* Opcode: Affinity P1 P2 * P4 * |
| 80887 | 81006 | ** Synopsis: affinity(r[P1@P2]) |
| 80888 | 81007 | ** |
| 80889 | 81008 | ** Apply affinities to a range of P2 registers starting with P1. |
| 80890 | 81009 | ** |
| 80891 | | -** P4 is a string that is P2 characters long. The nth character of the |
| 80892 | | -** string indicates the column affinity that should be used for the nth |
| 81010 | +** P4 is a string that is P2 characters long. The N-th character of the |
| 81011 | +** string indicates the column affinity that should be used for the N-th |
| 80893 | 81012 | ** memory cell in the range. |
| 80894 | 81013 | */ |
| 80895 | 81014 | case OP_Affinity: { |
| 80896 | 81015 | const char *zAffinity; /* The affinity to be applied */ |
| 80897 | | - char cAff; /* A single character of affinity */ |
| 80898 | 81016 | |
| 80899 | 81017 | zAffinity = pOp->p4.z; |
| 80900 | 81018 | assert( zAffinity!=0 ); |
| 81019 | + assert( pOp->p2>0 ); |
| 80901 | 81020 | assert( zAffinity[pOp->p2]==0 ); |
| 80902 | 81021 | pIn1 = &aMem[pOp->p1]; |
| 80903 | | - while( (cAff = *(zAffinity++))!=0 ){ |
| 81022 | + do{ |
| 80904 | 81023 | assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] ); |
| 80905 | 81024 | assert( memIsValid(pIn1) ); |
| 80906 | | - applyAffinity(pIn1, cAff, encoding); |
| 81025 | + applyAffinity(pIn1, *(zAffinity++), encoding); |
| 80907 | 81026 | pIn1++; |
| 80908 | | - } |
| 81027 | + }while( zAffinity[0] ); |
| 80909 | 81028 | break; |
| 80910 | 81029 | } |
| 80911 | 81030 | |
| 80912 | 81031 | /* Opcode: MakeRecord P1 P2 P3 P4 * |
| 80913 | 81032 | ** Synopsis: r[P3]=mkrec(r[P1@P2]) |
| | @@ -80914,12 +81033,12 @@ |
| 80914 | 81033 | ** |
| 80915 | 81034 | ** Convert P2 registers beginning with P1 into the [record format] |
| 80916 | 81035 | ** use as a data record in a database table or as a key |
| 80917 | 81036 | ** in an index. The OP_Column opcode can decode the record later. |
| 80918 | 81037 | ** |
| 80919 | | -** P4 may be a string that is P2 characters long. The nth character of the |
| 80920 | | -** string indicates the column affinity that should be used for the nth |
| 81038 | +** P4 may be a string that is P2 characters long. The N-th character of the |
| 81039 | +** string indicates the column affinity that should be used for the N-th |
| 80921 | 81040 | ** field of the index key. |
| 80922 | 81041 | ** |
| 80923 | 81042 | ** The mapping from character to affinity is given by the SQLITE_AFF_ |
| 80924 | 81043 | ** macros defined in sqliteInt.h. |
| 80925 | 81044 | ** |
| | @@ -81074,11 +81193,10 @@ |
| 81074 | 81193 | pOut->flags = MEM_Blob; |
| 81075 | 81194 | if( nZero ){ |
| 81076 | 81195 | pOut->u.nZero = nZero; |
| 81077 | 81196 | pOut->flags |= MEM_Zero; |
| 81078 | 81197 | } |
| 81079 | | - pOut->enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ |
| 81080 | 81198 | REGISTER_TRACE(pOp->p3, pOut); |
| 81081 | 81199 | UPDATE_MAX_BLOBSIZE(pOut); |
| 81082 | 81200 | break; |
| 81083 | 81201 | } |
| 81084 | 81202 | |
| | @@ -81703,10 +81821,41 @@ |
| 81703 | 81821 | sqlite3BtreeCursorHintFlags(pCur->uc.pCursor, |
| 81704 | 81822 | (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ))); |
| 81705 | 81823 | if( rc ) goto abort_due_to_error; |
| 81706 | 81824 | break; |
| 81707 | 81825 | } |
| 81826 | + |
| 81827 | +/* Opcode: OpenDup P1 P2 * * * |
| 81828 | +** |
| 81829 | +** Open a new cursor P1 that points to the same ephemeral table as |
| 81830 | +** cursor P2. The P2 cursor must have been opened by a prior OP_OpenEphemeral |
| 81831 | +** opcode. Only ephemeral cursors may be duplicated. |
| 81832 | +** |
| 81833 | +** Duplicate ephemeral cursors are used for self-joins of materialized views. |
| 81834 | +*/ |
| 81835 | +case OP_OpenDup: { |
| 81836 | + VdbeCursor *pOrig; /* The original cursor to be duplicated */ |
| 81837 | + VdbeCursor *pCx; /* The new cursor */ |
| 81838 | + |
| 81839 | + pOrig = p->apCsr[pOp->p2]; |
| 81840 | + assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */ |
| 81841 | + |
| 81842 | + pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); |
| 81843 | + if( pCx==0 ) goto no_mem; |
| 81844 | + pCx->nullRow = 1; |
| 81845 | + pCx->isEphemeral = 1; |
| 81846 | + pCx->pKeyInfo = pOrig->pKeyInfo; |
| 81847 | + pCx->isTable = pOrig->isTable; |
| 81848 | + rc = sqlite3BtreeCursor(pOrig->pBtx, MASTER_ROOT, BTREE_WRCSR, |
| 81849 | + pCx->pKeyInfo, pCx->uc.pCursor); |
| 81850 | + /* The sqlite3BtreeCursor() routine can only fail for the first cursor |
| 81851 | + ** opened for a database. Since there is already an open cursor when this |
| 81852 | + ** opcode is run, the sqlite3BtreeCursor() cannot fail */ |
| 81853 | + assert( rc==SQLITE_OK ); |
| 81854 | + break; |
| 81855 | +} |
| 81856 | + |
| 81708 | 81857 | |
| 81709 | 81858 | /* Opcode: OpenEphemeral P1 P2 * P4 P5 |
| 81710 | 81859 | ** Synopsis: nColumn=P2 |
| 81711 | 81860 | ** |
| 81712 | 81861 | ** Open a new cursor P1 to a transient table. |
| | @@ -82239,14 +82388,16 @@ |
| 82239 | 82388 | } |
| 82240 | 82389 | #endif |
| 82241 | 82390 | pIdxKey = &r; |
| 82242 | 82391 | pFree = 0; |
| 82243 | 82392 | }else{ |
| 82393 | + assert( pIn3->flags & MEM_Blob ); |
| 82394 | + rc = ExpandBlob(pIn3); |
| 82395 | + assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); |
| 82396 | + if( rc ) goto no_mem; |
| 82244 | 82397 | pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo); |
| 82245 | 82398 | if( pIdxKey==0 ) goto no_mem; |
| 82246 | | - assert( pIn3->flags & MEM_Blob ); |
| 82247 | | - (void)ExpandBlob(pIn3); |
| 82248 | 82399 | sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey); |
| 82249 | 82400 | } |
| 82250 | 82401 | pIdxKey->default_rc = 0; |
| 82251 | 82402 | takeJump = 0; |
| 82252 | 82403 | if( pOp->opcode==OP_NoConflict ){ |
| | @@ -82259,11 +82410,11 @@ |
| 82259 | 82410 | break; |
| 82260 | 82411 | } |
| 82261 | 82412 | } |
| 82262 | 82413 | } |
| 82263 | 82414 | rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res); |
| 82264 | | - if( pFree ) sqlite3DbFree(db, pFree); |
| 82415 | + if( pFree ) sqlite3DbFreeNN(db, pFree); |
| 82265 | 82416 | if( rc!=SQLITE_OK ){ |
| 82266 | 82417 | goto abort_due_to_error; |
| 82267 | 82418 | } |
| 82268 | 82419 | pC->seekResult = res; |
| 82269 | 82420 | alreadyExists = (res==0); |
| | @@ -83569,14 +83720,21 @@ |
| 83569 | 83720 | ** |
| 83570 | 83721 | ** If AUTOVACUUM is enabled then it is possible that another root page |
| 83571 | 83722 | ** might be moved into the newly deleted root page in order to keep all |
| 83572 | 83723 | ** root pages contiguous at the beginning of the database. The former |
| 83573 | 83724 | ** value of the root page that moved - its value before the move occurred - |
| 83574 | | -** is stored in register P2. If no page |
| 83575 | | -** movement was required (because the table being dropped was already |
| 83576 | | -** the last one in the database) then a zero is stored in register P2. |
| 83577 | | -** If AUTOVACUUM is disabled then a zero is stored in register P2. |
| 83725 | +** is stored in register P2. If no page movement was required (because the |
| 83726 | +** table being dropped was already the last one in the database) then a |
| 83727 | +** zero is stored in register P2. If AUTOVACUUM is disabled then a zero |
| 83728 | +** is stored in register P2. |
| 83729 | +** |
| 83730 | +** This opcode throws an error if there are any active reader VMs when |
| 83731 | +** it is invoked. This is done to avoid the difficulty associated with |
| 83732 | +** updating existing cursors when a root page is moved in an AUTOVACUUM |
| 83733 | +** database. This error is thrown even if the database is not an AUTOVACUUM |
| 83734 | +** db in order to avoid introducing an incompatibility between autovacuum |
| 83735 | +** and non-autovacuum modes. |
| 83578 | 83736 | ** |
| 83579 | 83737 | ** See also: Clear |
| 83580 | 83738 | */ |
| 83581 | 83739 | case OP_Destroy: { /* out2 */ |
| 83582 | 83740 | int iMoved; |
| | @@ -83777,11 +83935,11 @@ |
| 83777 | 83935 | db->init.busy = 1; |
| 83778 | 83936 | initData.rc = SQLITE_OK; |
| 83779 | 83937 | assert( !db->mallocFailed ); |
| 83780 | 83938 | rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); |
| 83781 | 83939 | if( rc==SQLITE_OK ) rc = initData.rc; |
| 83782 | | - sqlite3DbFree(db, zSql); |
| 83940 | + sqlite3DbFreeNN(db, zSql); |
| 83783 | 83941 | db->init.busy = 0; |
| 83784 | 83942 | } |
| 83785 | 83943 | } |
| 83786 | 83944 | if( rc ){ |
| 83787 | 83945 | sqlite3ResetAllSchemasOfConnection(db); |
| | @@ -83905,11 +84063,11 @@ |
| 83905 | 84063 | #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ |
| 83906 | 84064 | |
| 83907 | 84065 | /* Opcode: RowSetAdd P1 P2 * * * |
| 83908 | 84066 | ** Synopsis: rowset(P1)=r[P2] |
| 83909 | 84067 | ** |
| 83910 | | -** Insert the integer value held by register P2 into a boolean index |
| 84068 | +** Insert the integer value held by register P2 into a RowSet object |
| 83911 | 84069 | ** held in register P1. |
| 83912 | 84070 | ** |
| 83913 | 84071 | ** An assertion fails if P2 is not an integer. |
| 83914 | 84072 | */ |
| 83915 | 84073 | case OP_RowSetAdd: { /* in1, in2 */ |
| | @@ -83925,12 +84083,13 @@ |
| 83925 | 84083 | } |
| 83926 | 84084 | |
| 83927 | 84085 | /* Opcode: RowSetRead P1 P2 P3 * * |
| 83928 | 84086 | ** Synopsis: r[P3]=rowset(P1) |
| 83929 | 84087 | ** |
| 83930 | | -** Extract the smallest value from boolean index P1 and put that value into |
| 83931 | | -** register P3. Or, if boolean index P1 is initially empty, leave P3 |
| 84088 | +** Extract the smallest value from the RowSet object in P1 |
| 84089 | +** and put that value into register P3. |
| 84090 | +** Or, if RowSet object P1 is initially empty, leave P3 |
| 83932 | 84091 | ** unchanged and jump to instruction P2. |
| 83933 | 84092 | */ |
| 83934 | 84093 | case OP_RowSetRead: { /* jump, in1, out3 */ |
| 83935 | 84094 | i64 val; |
| 83936 | 84095 | |
| | @@ -83957,19 +84116,18 @@ |
| 83957 | 84116 | ** contains a RowSet object and that RowSet object contains |
| 83958 | 84117 | ** the value held in P3, jump to register P2. Otherwise, insert the |
| 83959 | 84118 | ** integer in P3 into the RowSet and continue on to the |
| 83960 | 84119 | ** next opcode. |
| 83961 | 84120 | ** |
| 83962 | | -** The RowSet object is optimized for the case where successive sets |
| 83963 | | -** of integers, where each set contains no duplicates. Each set |
| 83964 | | -** of values is identified by a unique P4 value. The first set |
| 83965 | | -** must have P4==0, the final set P4=-1. P4 must be either -1 or |
| 83966 | | -** non-negative. For non-negative values of P4 only the lower 4 |
| 83967 | | -** bits are significant. |
| 84121 | +** The RowSet object is optimized for the case where sets of integers |
| 84122 | +** are inserted in distinct phases, which each set contains no duplicates. |
| 84123 | +** Each set is identified by a unique P4 value. The first set |
| 84124 | +** must have P4==0, the final set must have P4==-1, and for all other sets |
| 84125 | +** must have P4>0. |
| 83968 | 84126 | ** |
| 83969 | 84127 | ** This allows optimizations: (a) when P4==0 there is no need to test |
| 83970 | | -** the rowset object for P3, as it is guaranteed not to contain it, |
| 84128 | +** the RowSet object for P3, as it is guaranteed not to contain it, |
| 83971 | 84129 | ** (b) when P4==-1 there is no need to insert the value, as it will |
| 83972 | 84130 | ** never be tested for, and (c) when a value that is part of set X is |
| 83973 | 84131 | ** inserted, there is no need to search to see if the same value was |
| 83974 | 84132 | ** previously inserted as part of set X (only if it was previously |
| 83975 | 84133 | ** inserted as part of some other set). |
| | @@ -86705,41 +86863,40 @@ |
| 86705 | 86863 | int res; /* Return value */ |
| 86706 | 86864 | |
| 86707 | 86865 | assert( (s1>0 && s1<7) || s1==8 || s1==9 ); |
| 86708 | 86866 | assert( (s2>0 && s2<7) || s2==8 || s2==9 ); |
| 86709 | 86867 | |
| 86710 | | - if( s1>7 && s2>7 ){ |
| 86711 | | - res = s1 - s2; |
| 86712 | | - }else{ |
| 86713 | | - if( s1==s2 ){ |
| 86714 | | - if( (*v1 ^ *v2) & 0x80 ){ |
| 86715 | | - /* The two values have different signs */ |
| 86716 | | - res = (*v1 & 0x80) ? -1 : +1; |
| 86717 | | - }else{ |
| 86718 | | - /* The two values have the same sign. Compare using memcmp(). */ |
| 86719 | | - static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8 }; |
| 86720 | | - int i; |
| 86721 | | - res = 0; |
| 86722 | | - for(i=0; i<aLen[s1]; i++){ |
| 86723 | | - if( (res = v1[i] - v2[i]) ) break; |
| 86724 | | - } |
| 86725 | | - } |
| 86726 | | - }else{ |
| 86727 | | - if( s2>7 ){ |
| 86728 | | - res = +1; |
| 86729 | | - }else if( s1>7 ){ |
| 86730 | | - res = -1; |
| 86731 | | - }else{ |
| 86732 | | - res = s1 - s2; |
| 86733 | | - } |
| 86734 | | - assert( res!=0 ); |
| 86735 | | - |
| 86736 | | - if( res>0 ){ |
| 86737 | | - if( *v1 & 0x80 ) res = -1; |
| 86738 | | - }else{ |
| 86739 | | - if( *v2 & 0x80 ) res = +1; |
| 86740 | | - } |
| 86868 | + if( s1==s2 ){ |
| 86869 | + /* The two values have the same sign. Compare using memcmp(). */ |
| 86870 | + static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8, 0, 0, 0 }; |
| 86871 | + const u8 n = aLen[s1]; |
| 86872 | + int i; |
| 86873 | + res = 0; |
| 86874 | + for(i=0; i<n; i++){ |
| 86875 | + if( (res = v1[i] - v2[i])!=0 ){ |
| 86876 | + if( ((v1[0] ^ v2[0]) & 0x80)!=0 ){ |
| 86877 | + res = v1[0] & 0x80 ? -1 : +1; |
| 86878 | + } |
| 86879 | + break; |
| 86880 | + } |
| 86881 | + } |
| 86882 | + }else if( s1>7 && s2>7 ){ |
| 86883 | + res = s1 - s2; |
| 86884 | + }else{ |
| 86885 | + if( s2>7 ){ |
| 86886 | + res = +1; |
| 86887 | + }else if( s1>7 ){ |
| 86888 | + res = -1; |
| 86889 | + }else{ |
| 86890 | + res = s1 - s2; |
| 86891 | + } |
| 86892 | + assert( res!=0 ); |
| 86893 | + |
| 86894 | + if( res>0 ){ |
| 86895 | + if( *v1 & 0x80 ) res = -1; |
| 86896 | + }else{ |
| 86897 | + if( *v2 & 0x80 ) res = +1; |
| 86741 | 86898 | } |
| 86742 | 86899 | } |
| 86743 | 86900 | |
| 86744 | 86901 | if( res==0 ){ |
| 86745 | 86902 | if( pTask->pSorter->pKeyInfo->nField>1 ){ |
| | @@ -90790,11 +90947,11 @@ |
| 90790 | 90947 | if( op==TK_CAST ){ |
| 90791 | 90948 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 90792 | 90949 | return sqlite3AffinityType(pExpr->u.zToken, 0); |
| 90793 | 90950 | } |
| 90794 | 90951 | #endif |
| 90795 | | - if( op==TK_AGG_COLUMN || op==TK_COLUMN ){ |
| 90952 | + if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->pTab ){ |
| 90796 | 90953 | return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn); |
| 90797 | 90954 | } |
| 90798 | 90955 | if( op==TK_SELECT_COLUMN ){ |
| 90799 | 90956 | assert( pExpr->pLeft->flags&EP_xIsSelect ); |
| 90800 | 90957 | return sqlite3ExprAffinity( |
| | @@ -91084,11 +91241,10 @@ |
| 91084 | 91241 | }else{ |
| 91085 | 91242 | return 1; |
| 91086 | 91243 | } |
| 91087 | 91244 | } |
| 91088 | 91245 | |
| 91089 | | -#ifndef SQLITE_OMIT_SUBQUERY |
| 91090 | 91246 | /* |
| 91091 | 91247 | ** Return a pointer to a subexpression of pVector that is the i-th |
| 91092 | 91248 | ** column of the vector (numbered starting with 0). The caller must |
| 91093 | 91249 | ** ensure that i is within range. |
| 91094 | 91250 | ** |
| | @@ -91112,13 +91268,11 @@ |
| 91112 | 91268 | return pVector->x.pList->a[i].pExpr; |
| 91113 | 91269 | } |
| 91114 | 91270 | } |
| 91115 | 91271 | return pVector; |
| 91116 | 91272 | } |
| 91117 | | -#endif /* !defined(SQLITE_OMIT_SUBQUERY) */ |
| 91118 | 91273 | |
| 91119 | | -#ifndef SQLITE_OMIT_SUBQUERY |
| 91120 | 91274 | /* |
| 91121 | 91275 | ** Compute and return a new Expr object which when passed to |
| 91122 | 91276 | ** sqlite3ExprCode() will generate all necessary code to compute |
| 91123 | 91277 | ** the iField-th column of the vector expression pVector. |
| 91124 | 91278 | ** |
| | @@ -91172,11 +91326,10 @@ |
| 91172 | 91326 | if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr; |
| 91173 | 91327 | pRet = sqlite3ExprDup(pParse->db, pVector, 0); |
| 91174 | 91328 | } |
| 91175 | 91329 | return pRet; |
| 91176 | 91330 | } |
| 91177 | | -#endif /* !define(SQLITE_OMIT_SUBQUERY) */ |
| 91178 | 91331 | |
| 91179 | 91332 | /* |
| 91180 | 91333 | ** If expression pExpr is of type TK_SELECT, generate code to evaluate |
| 91181 | 91334 | ** it. Return the register in which the result is stored (or, if the |
| 91182 | 91335 | ** sub-select returns more than one column, the first in an array |
| | @@ -91688,11 +91841,11 @@ |
| 91688 | 91841 | if( pExpr==0 ) return; |
| 91689 | 91842 | assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); |
| 91690 | 91843 | z = pExpr->u.zToken; |
| 91691 | 91844 | assert( z!=0 ); |
| 91692 | 91845 | assert( z[0]!=0 ); |
| 91693 | | - assert( n==sqlite3Strlen30(z) ); |
| 91846 | + assert( n==(u32)sqlite3Strlen30(z) ); |
| 91694 | 91847 | if( z[1]==0 ){ |
| 91695 | 91848 | /* Wildcard of the form "?". Assign the next variable number */ |
| 91696 | 91849 | assert( z[0]=='?' ); |
| 91697 | 91850 | x = (ynVar)(++pParse->nVar); |
| 91698 | 91851 | }else{ |
| | @@ -91770,11 +91923,11 @@ |
| 91770 | 91923 | sqlite3ExprListDelete(db, p->x.pList); |
| 91771 | 91924 | } |
| 91772 | 91925 | } |
| 91773 | 91926 | if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken); |
| 91774 | 91927 | if( !ExprHasProperty(p, EP_Static) ){ |
| 91775 | | - sqlite3DbFree(db, p); |
| 91928 | + sqlite3DbFreeNN(db, p); |
| 91776 | 91929 | } |
| 91777 | 91930 | } |
| 91778 | 91931 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ |
| 91779 | 91932 | if( p ) sqlite3ExprDeleteNN(db, p); |
| 91780 | 91933 | } |
| | @@ -92037,19 +92190,15 @@ |
| 92037 | 92190 | struct ExprList_item *pItem, *pOldItem; |
| 92038 | 92191 | int i; |
| 92039 | 92192 | Expr *pPriorSelectCol = 0; |
| 92040 | 92193 | assert( db!=0 ); |
| 92041 | 92194 | if( p==0 ) return 0; |
| 92042 | | - pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 92195 | + pNew = sqlite3DbMallocRawNN(db, |
| 92196 | + sizeof(*pNew)+sizeof(pNew->a[0])*(p->nExpr-1) ); |
| 92043 | 92197 | if( pNew==0 ) return 0; |
| 92044 | | - pNew->nExpr = i = p->nExpr; |
| 92045 | | - if( (flags & EXPRDUP_REDUCE)==0 ) for(i=1; i<p->nExpr; i+=i){} |
| 92046 | | - pNew->a = pItem = sqlite3DbMallocRawNN(db, i*sizeof(p->a[0]) ); |
| 92047 | | - if( pItem==0 ){ |
| 92048 | | - sqlite3DbFree(db, pNew); |
| 92049 | | - return 0; |
| 92050 | | - } |
| 92198 | + pNew->nAlloc = pNew->nExpr = p->nExpr; |
| 92199 | + pItem = pNew->a; |
| 92051 | 92200 | pOldItem = p->a; |
| 92052 | 92201 | for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){ |
| 92053 | 92202 | Expr *pOldExpr = pOldItem->pExpr; |
| 92054 | 92203 | Expr *pNewExpr; |
| 92055 | 92204 | pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags); |
| | @@ -92136,11 +92285,11 @@ |
| 92136 | 92285 | pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 92137 | 92286 | if( pNew==0 ) return 0; |
| 92138 | 92287 | pNew->nId = p->nId; |
| 92139 | 92288 | pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) ); |
| 92140 | 92289 | if( pNew->a==0 ){ |
| 92141 | | - sqlite3DbFree(db, pNew); |
| 92290 | + sqlite3DbFreeNN(db, pNew); |
| 92142 | 92291 | return 0; |
| 92143 | 92292 | } |
| 92144 | 92293 | /* Note that because the size of the allocation for p->a[] is not |
| 92145 | 92294 | ** necessarily a power of two, sqlite3IdListAppend() may not be called |
| 92146 | 92295 | ** on the duplicate created by this function. */ |
| | @@ -92207,35 +92356,33 @@ |
| 92207 | 92356 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend( |
| 92208 | 92357 | Parse *pParse, /* Parsing context */ |
| 92209 | 92358 | ExprList *pList, /* List to which to append. Might be NULL */ |
| 92210 | 92359 | Expr *pExpr /* Expression to be appended. Might be NULL */ |
| 92211 | 92360 | ){ |
| 92361 | + struct ExprList_item *pItem; |
| 92212 | 92362 | sqlite3 *db = pParse->db; |
| 92213 | 92363 | assert( db!=0 ); |
| 92214 | 92364 | if( pList==0 ){ |
| 92215 | 92365 | pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) ); |
| 92216 | 92366 | if( pList==0 ){ |
| 92217 | 92367 | goto no_mem; |
| 92218 | 92368 | } |
| 92219 | 92369 | pList->nExpr = 0; |
| 92220 | | - pList->a = sqlite3DbMallocRawNN(db, sizeof(pList->a[0])); |
| 92221 | | - if( pList->a==0 ) goto no_mem; |
| 92222 | | - }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ |
| 92223 | | - struct ExprList_item *a; |
| 92224 | | - assert( pList->nExpr>0 ); |
| 92225 | | - a = sqlite3DbRealloc(db, pList->a, pList->nExpr*2*sizeof(pList->a[0])); |
| 92226 | | - if( a==0 ){ |
| 92370 | + pList->nAlloc = 1; |
| 92371 | + }else if( pList->nExpr==pList->nAlloc ){ |
| 92372 | + ExprList *pNew; |
| 92373 | + pNew = sqlite3DbRealloc(db, pList, |
| 92374 | + sizeof(*pList)+(2*pList->nAlloc - 1)*sizeof(pList->a[0])); |
| 92375 | + if( pNew==0 ){ |
| 92227 | 92376 | goto no_mem; |
| 92228 | 92377 | } |
| 92229 | | - pList->a = a; |
| 92230 | | - } |
| 92231 | | - assert( pList->a!=0 ); |
| 92232 | | - if( 1 ){ |
| 92233 | | - struct ExprList_item *pItem = &pList->a[pList->nExpr++]; |
| 92234 | | - memset(pItem, 0, sizeof(*pItem)); |
| 92235 | | - pItem->pExpr = pExpr; |
| 92236 | | - } |
| 92378 | + pList = pNew; |
| 92379 | + pList->nAlloc *= 2; |
| 92380 | + } |
| 92381 | + pItem = &pList->a[pList->nExpr++]; |
| 92382 | + memset(pItem, 0, sizeof(*pItem)); |
| 92383 | + pItem->pExpr = pExpr; |
| 92237 | 92384 | return pList; |
| 92238 | 92385 | |
| 92239 | 92386 | no_mem: |
| 92240 | 92387 | /* Avoid leaking memory if malloc has failed. */ |
| 92241 | 92388 | sqlite3ExprDelete(db, pExpr); |
| | @@ -92288,24 +92435,23 @@ |
| 92288 | 92435 | pList->a[pList->nExpr-1].zName = pColumns->a[i].zName; |
| 92289 | 92436 | pColumns->a[i].zName = 0; |
| 92290 | 92437 | } |
| 92291 | 92438 | } |
| 92292 | 92439 | |
| 92293 | | - if( pExpr->op==TK_SELECT ){ |
| 92294 | | - if( pList && pList->a[iFirst].pExpr ){ |
| 92295 | | - Expr *pFirst = pList->a[iFirst].pExpr; |
| 92296 | | - assert( pFirst->op==TK_SELECT_COLUMN ); |
| 92297 | | - |
| 92298 | | - /* Store the SELECT statement in pRight so it will be deleted when |
| 92299 | | - ** sqlite3ExprListDelete() is called */ |
| 92300 | | - pFirst->pRight = pExpr; |
| 92301 | | - pExpr = 0; |
| 92302 | | - |
| 92303 | | - /* Remember the size of the LHS in iTable so that we can check that |
| 92304 | | - ** the RHS and LHS sizes match during code generation. */ |
| 92305 | | - pFirst->iTable = pColumns->nId; |
| 92306 | | - } |
| 92440 | + if( !db->mallocFailed && pExpr->op==TK_SELECT && ALWAYS(pList!=0) ){ |
| 92441 | + Expr *pFirst = pList->a[iFirst].pExpr; |
| 92442 | + assert( pFirst!=0 ); |
| 92443 | + assert( pFirst->op==TK_SELECT_COLUMN ); |
| 92444 | + |
| 92445 | + /* Store the SELECT statement in pRight so it will be deleted when |
| 92446 | + ** sqlite3ExprListDelete() is called */ |
| 92447 | + pFirst->pRight = pExpr; |
| 92448 | + pExpr = 0; |
| 92449 | + |
| 92450 | + /* Remember the size of the LHS in iTable so that we can check that |
| 92451 | + ** the RHS and LHS sizes match during code generation. */ |
| 92452 | + pFirst->iTable = pColumns->nId; |
| 92307 | 92453 | } |
| 92308 | 92454 | |
| 92309 | 92455 | vector_append_error: |
| 92310 | 92456 | sqlite3ExprDelete(db, pExpr); |
| 92311 | 92457 | sqlite3IdListDelete(db, pColumns); |
| | @@ -92395,20 +92541,20 @@ |
| 92395 | 92541 | |
| 92396 | 92542 | /* |
| 92397 | 92543 | ** Delete an entire expression list. |
| 92398 | 92544 | */ |
| 92399 | 92545 | static SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){ |
| 92400 | | - int i; |
| 92401 | | - struct ExprList_item *pItem; |
| 92402 | | - assert( pList->a!=0 || pList->nExpr==0 ); |
| 92403 | | - for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){ |
| 92546 | + int i = pList->nExpr; |
| 92547 | + struct ExprList_item *pItem = pList->a; |
| 92548 | + assert( pList->nExpr>0 ); |
| 92549 | + do{ |
| 92404 | 92550 | sqlite3ExprDelete(db, pItem->pExpr); |
| 92405 | 92551 | sqlite3DbFree(db, pItem->zName); |
| 92406 | 92552 | sqlite3DbFree(db, pItem->zSpan); |
| 92407 | | - } |
| 92408 | | - sqlite3DbFree(db, pList->a); |
| 92409 | | - sqlite3DbFree(db, pList); |
| 92553 | + pItem++; |
| 92554 | + }while( --i>0 ); |
| 92555 | + sqlite3DbFreeNN(db, pList); |
| 92410 | 92556 | } |
| 92411 | 92557 | SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){ |
| 92412 | 92558 | if( pList ) exprListDeleteNN(db, pList); |
| 92413 | 92559 | } |
| 92414 | 92560 | |
| | @@ -92554,10 +92700,69 @@ |
| 92554 | 92700 | */ |
| 92555 | 92701 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){ |
| 92556 | 92702 | return exprIsConst(p, 3, iCur); |
| 92557 | 92703 | } |
| 92558 | 92704 | |
| 92705 | + |
| 92706 | +/* |
| 92707 | +** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). |
| 92708 | +*/ |
| 92709 | +static int exprNodeIsConstantOrGroupBy(Walker *pWalker, Expr *pExpr){ |
| 92710 | + ExprList *pGroupBy = pWalker->u.pGroupBy; |
| 92711 | + int i; |
| 92712 | + |
| 92713 | + /* Check if pExpr is identical to any GROUP BY term. If so, consider |
| 92714 | + ** it constant. */ |
| 92715 | + for(i=0; i<pGroupBy->nExpr; i++){ |
| 92716 | + Expr *p = pGroupBy->a[i].pExpr; |
| 92717 | + if( sqlite3ExprCompare(pExpr, p, -1)<2 ){ |
| 92718 | + CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p); |
| 92719 | + if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){ |
| 92720 | + return WRC_Prune; |
| 92721 | + } |
| 92722 | + } |
| 92723 | + } |
| 92724 | + |
| 92725 | + /* Check if pExpr is a sub-select. If so, consider it variable. */ |
| 92726 | + if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 92727 | + pWalker->eCode = 0; |
| 92728 | + return WRC_Abort; |
| 92729 | + } |
| 92730 | + |
| 92731 | + return exprNodeIsConstant(pWalker, pExpr); |
| 92732 | +} |
| 92733 | + |
| 92734 | +/* |
| 92735 | +** Walk the expression tree passed as the first argument. Return non-zero |
| 92736 | +** if the expression consists entirely of constants or copies of terms |
| 92737 | +** in pGroupBy that sort with the BINARY collation sequence. |
| 92738 | +** |
| 92739 | +** This routine is used to determine if a term of the HAVING clause can |
| 92740 | +** be promoted into the WHERE clause. In order for such a promotion to work, |
| 92741 | +** the value of the HAVING clause term must be the same for all members of |
| 92742 | +** a "group". The requirement that the GROUP BY term must be BINARY |
| 92743 | +** assumes that no other collating sequence will have a finer-grained |
| 92744 | +** grouping than binary. In other words (A=B COLLATE binary) implies |
| 92745 | +** A=B in every other collating sequence. The requirement that the |
| 92746 | +** GROUP BY be BINARY is stricter than necessary. It would also work |
| 92747 | +** to promote HAVING clauses that use the same alternative collating |
| 92748 | +** sequence as the GROUP BY term, but that is much harder to check, |
| 92749 | +** alternative collating sequences are uncommon, and this is only an |
| 92750 | +** optimization, so we take the easy way out and simply require the |
| 92751 | +** GROUP BY to use the BINARY collating sequence. |
| 92752 | +*/ |
| 92753 | +SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){ |
| 92754 | + Walker w; |
| 92755 | + memset(&w, 0, sizeof(w)); |
| 92756 | + w.eCode = 1; |
| 92757 | + w.xExprCallback = exprNodeIsConstantOrGroupBy; |
| 92758 | + w.u.pGroupBy = pGroupBy; |
| 92759 | + w.pParse = pParse; |
| 92760 | + sqlite3WalkExpr(&w, p); |
| 92761 | + return w.eCode; |
| 92762 | +} |
| 92763 | + |
| 92559 | 92764 | /* |
| 92560 | 92765 | ** Walk an expression tree. Return non-zero if the expression is constant |
| 92561 | 92766 | ** or a function call with constant arguments. Return and 0 if there |
| 92562 | 92767 | ** are any variables. |
| 92563 | 92768 | ** |
| | @@ -93931,10 +94136,14 @@ |
| 93931 | 94136 | Table *pTab, /* The table containing the value */ |
| 93932 | 94137 | int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */ |
| 93933 | 94138 | int iCol, /* Index of the column to extract */ |
| 93934 | 94139 | int regOut /* Extract the value into this register */ |
| 93935 | 94140 | ){ |
| 94141 | + if( pTab==0 ){ |
| 94142 | + sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut); |
| 94143 | + return; |
| 94144 | + } |
| 93936 | 94145 | if( iCol<0 || iCol==pTab->iPKey ){ |
| 93937 | 94146 | sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); |
| 93938 | 94147 | }else{ |
| 93939 | 94148 | int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; |
| 93940 | 94149 | int x = iCol; |
| | @@ -94087,11 +94296,15 @@ |
| 94087 | 94296 | if( nResult==1 ){ |
| 94088 | 94297 | iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable); |
| 94089 | 94298 | }else{ |
| 94090 | 94299 | *piFreeable = 0; |
| 94091 | 94300 | if( p->op==TK_SELECT ){ |
| 94301 | +#if SQLITE_OMIT_SUBQUERY |
| 94302 | + iResult = 0; |
| 94303 | +#else |
| 94092 | 94304 | iResult = sqlite3CodeSubselect(pParse, p, 0, 0); |
| 94305 | +#endif |
| 94093 | 94306 | }else{ |
| 94094 | 94307 | int i; |
| 94095 | 94308 | iResult = pParse->nMem+1; |
| 94096 | 94309 | pParse->nMem += nResult; |
| 94097 | 94310 | for(i=0; i<nResult; i++){ |
| | @@ -94623,10 +94836,21 @@ |
| 94623 | 94836 | |
| 94624 | 94837 | case TK_VECTOR: { |
| 94625 | 94838 | sqlite3ErrorMsg(pParse, "row value misused"); |
| 94626 | 94839 | break; |
| 94627 | 94840 | } |
| 94841 | + |
| 94842 | + case TK_IF_NULL_ROW: { |
| 94843 | + int addrINR; |
| 94844 | + addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable); |
| 94845 | + sqlite3ExprCachePush(pParse); |
| 94846 | + inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 94847 | + sqlite3ExprCachePop(pParse); |
| 94848 | + sqlite3VdbeJumpHere(v, addrINR); |
| 94849 | + sqlite3VdbeChangeP3(v, addrINR, inReg); |
| 94850 | + break; |
| 94851 | + } |
| 94628 | 94852 | |
| 94629 | 94853 | /* |
| 94630 | 94854 | ** Form A: |
| 94631 | 94855 | ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END |
| 94632 | 94856 | ** |
| | @@ -99401,10 +99625,22 @@ |
| 99401 | 99625 | } |
| 99402 | 99626 | |
| 99403 | 99627 | if( db->xAuth==0 ){ |
| 99404 | 99628 | return SQLITE_OK; |
| 99405 | 99629 | } |
| 99630 | + |
| 99631 | + /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the |
| 99632 | + ** callback are either NULL pointers or zero-terminated strings that |
| 99633 | + ** contain additional details about the action to be authorized. |
| 99634 | + ** |
| 99635 | + ** The following testcase() macros show that any of the 3rd through 6th |
| 99636 | + ** parameters can be either NULL or a string. */ |
| 99637 | + testcase( zArg1==0 ); |
| 99638 | + testcase( zArg2==0 ); |
| 99639 | + testcase( zArg3==0 ); |
| 99640 | + testcase( pParse->zAuthContext==0 ); |
| 99641 | + |
| 99406 | 99642 | rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext |
| 99407 | 99643 | #ifdef SQLITE_USER_AUTHENTICATION |
| 99408 | 99644 | ,db->auth.zAuthUser |
| 99409 | 99645 | #endif |
| 99410 | 99646 | ); |
| | @@ -103072,11 +103308,11 @@ |
| 103072 | 103308 | if( pList==0 ) return; |
| 103073 | 103309 | for(i=0; i<pList->nId; i++){ |
| 103074 | 103310 | sqlite3DbFree(db, pList->a[i].zName); |
| 103075 | 103311 | } |
| 103076 | 103312 | sqlite3DbFree(db, pList->a); |
| 103077 | | - sqlite3DbFree(db, pList); |
| 103313 | + sqlite3DbFreeNN(db, pList); |
| 103078 | 103314 | } |
| 103079 | 103315 | |
| 103080 | 103316 | /* |
| 103081 | 103317 | ** Return the index in pList of the identifier named zId. Return -1 |
| 103082 | 103318 | ** if not found. |
| | @@ -103262,11 +103498,11 @@ |
| 103262 | 103498 | sqlite3DeleteTable(db, pItem->pTab); |
| 103263 | 103499 | sqlite3SelectDelete(db, pItem->pSelect); |
| 103264 | 103500 | sqlite3ExprDelete(db, pItem->pOn); |
| 103265 | 103501 | sqlite3IdListDelete(db, pItem->pUsing); |
| 103266 | 103502 | } |
| 103267 | | - sqlite3DbFree(db, pList); |
| 103503 | + sqlite3DbFreeNN(db, pList); |
| 103268 | 103504 | } |
| 103269 | 103505 | |
| 103270 | 103506 | /* |
| 103271 | 103507 | ** This routine is called by the parser to add a new term to the |
| 103272 | 103508 | ** end of a growing FROM clause. The "p" parameter is the part of |
| | @@ -104736,11 +104972,18 @@ |
| 104736 | 104972 | |
| 104737 | 104973 | #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION |
| 104738 | 104974 | /* Special case: A DELETE without a WHERE clause deletes everything. |
| 104739 | 104975 | ** It is easier just to erase the whole table. Prior to version 3.6.5, |
| 104740 | 104976 | ** this optimization caused the row change count (the value returned by |
| 104741 | | - ** API function sqlite3_count_changes) to be set incorrectly. */ |
| 104977 | + ** API function sqlite3_count_changes) to be set incorrectly. |
| 104978 | + ** |
| 104979 | + ** The "rcauth==SQLITE_OK" terms is the |
| 104980 | + ** IMPLEMENATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and |
| 104981 | + ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but |
| 104982 | + ** the truncate optimization is disabled and all rows are deleted |
| 104983 | + ** individually. |
| 104984 | + */ |
| 104742 | 104985 | if( rcauth==SQLITE_OK |
| 104743 | 104986 | && pWhere==0 |
| 104744 | 104987 | && !bComplex |
| 104745 | 104988 | && !IsVirtual(pTab) |
| 104746 | 104989 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| | @@ -108246,42 +108489,57 @@ |
| 108246 | 108489 | ** entry in the aChange[] array is set to -1. If the column is modified, |
| 108247 | 108490 | ** the value is 0 or greater. Parameter chngRowid is set to true if the |
| 108248 | 108491 | ** UPDATE statement modifies the rowid fields of the table. |
| 108249 | 108492 | ** |
| 108250 | 108493 | ** If any foreign key processing will be required, this function returns |
| 108251 | | -** true. If there is no foreign key related processing, this function |
| 108252 | | -** returns false. |
| 108494 | +** non-zero. If there is no foreign key related processing, this function |
| 108495 | +** returns zero. |
| 108496 | +** |
| 108497 | +** For an UPDATE, this function returns 2 if: |
| 108498 | +** |
| 108499 | +** * There are any FKs for which pTab is the child and the parent table, or |
| 108500 | +** * the UPDATE modifies one or more parent keys for which the action is |
| 108501 | +** not "NO ACTION" (i.e. is CASCADE, SET DEFAULT or SET NULL). |
| 108502 | +** |
| 108503 | +** Or, assuming some other foreign key processing is required, 1. |
| 108253 | 108504 | */ |
| 108254 | 108505 | SQLITE_PRIVATE int sqlite3FkRequired( |
| 108255 | 108506 | Parse *pParse, /* Parse context */ |
| 108256 | 108507 | Table *pTab, /* Table being modified */ |
| 108257 | 108508 | int *aChange, /* Non-NULL for UPDATE operations */ |
| 108258 | 108509 | int chngRowid /* True for UPDATE that affects rowid */ |
| 108259 | 108510 | ){ |
| 108511 | + int eRet = 0; |
| 108260 | 108512 | if( pParse->db->flags&SQLITE_ForeignKeys ){ |
| 108261 | 108513 | if( !aChange ){ |
| 108262 | 108514 | /* A DELETE operation. Foreign key processing is required if the |
| 108263 | 108515 | ** table in question is either the child or parent table for any |
| 108264 | 108516 | ** foreign key constraint. */ |
| 108265 | | - return (sqlite3FkReferences(pTab) || pTab->pFKey); |
| 108517 | + eRet = (sqlite3FkReferences(pTab) || pTab->pFKey); |
| 108266 | 108518 | }else{ |
| 108267 | 108519 | /* This is an UPDATE. Foreign key processing is only required if the |
| 108268 | 108520 | ** operation modifies one or more child or parent key columns. */ |
| 108269 | 108521 | FKey *p; |
| 108270 | 108522 | |
| 108271 | 108523 | /* Check if any child key columns are being modified. */ |
| 108272 | 108524 | for(p=pTab->pFKey; p; p=p->pNextFrom){ |
| 108273 | | - if( fkChildIsModified(pTab, p, aChange, chngRowid) ) return 1; |
| 108525 | + if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) return 2; |
| 108526 | + if( fkChildIsModified(pTab, p, aChange, chngRowid) ){ |
| 108527 | + eRet = 1; |
| 108528 | + } |
| 108274 | 108529 | } |
| 108275 | 108530 | |
| 108276 | 108531 | /* Check if any parent key columns are being modified. */ |
| 108277 | 108532 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 108278 | | - if( fkParentIsModified(pTab, p, aChange, chngRowid) ) return 1; |
| 108533 | + if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 108534 | + if( p->aAction[1]!=OE_None ) return 2; |
| 108535 | + eRet = 1; |
| 108536 | + } |
| 108279 | 108537 | } |
| 108280 | 108538 | } |
| 108281 | 108539 | } |
| 108282 | | - return 0; |
| 108540 | + return eRet; |
| 108283 | 108541 | } |
| 108284 | 108542 | |
| 108285 | 108543 | /* |
| 108286 | 108544 | ** This function is called when an UPDATE or DELETE operation is being |
| 108287 | 108545 | ** compiled on table pTab, which is the parent table of foreign-key pFKey. |
| | @@ -112787,11 +113045,11 @@ |
| 112787 | 113045 | /* ColNames: */ 0, 0, |
| 112788 | 113046 | /* iArg: */ 0 }, |
| 112789 | 113047 | #endif |
| 112790 | 113048 | {/* zName: */ "optimize", |
| 112791 | 113049 | /* ePragTyp: */ PragTyp_OPTIMIZE, |
| 112792 | | - /* ePragFlg: */ PragFlg_Result1, |
| 113050 | + /* ePragFlg: */ PragFlg_Result1|PragFlg_NeedSchema, |
| 112793 | 113051 | /* ColNames: */ 0, 0, |
| 112794 | 113052 | /* iArg: */ 0 }, |
| 112795 | 113053 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 112796 | 113054 | {/* zName: */ "page_count", |
| 112797 | 113055 | /* ePragTyp: */ PragTyp_PAGE_COUNT, |
| | @@ -114287,37 +114545,41 @@ |
| 114287 | 114545 | if( pParent ){ |
| 114288 | 114546 | x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); |
| 114289 | 114547 | assert( x==0 ); |
| 114290 | 114548 | } |
| 114291 | 114549 | addrOk = sqlite3VdbeMakeLabel(v); |
| 114292 | | - if( pParent && pIdx==0 ){ |
| 114293 | | - int iKey = pFK->aCol[0].iFrom; |
| 114294 | | - assert( iKey>=0 && iKey<pTab->nCol ); |
| 114295 | | - if( iKey!=pTab->iPKey ){ |
| 114296 | | - sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); |
| 114297 | | - sqlite3ColumnDefault(v, pTab, iKey, regRow); |
| 114298 | | - sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v); |
| 114299 | | - }else{ |
| 114300 | | - sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); |
| 114301 | | - } |
| 114302 | | - sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v); |
| 114550 | + |
| 114551 | + /* Generate code to read the child key values into registers |
| 114552 | + ** regRow..regRow+n. If any of the child key values are NULL, this |
| 114553 | + ** row cannot cause an FK violation. Jump directly to addrOk in |
| 114554 | + ** this case. */ |
| 114555 | + for(j=0; j<pFK->nCol; j++){ |
| 114556 | + int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom; |
| 114557 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j); |
| 114558 | + sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v); |
| 114559 | + } |
| 114560 | + |
| 114561 | + /* Generate code to query the parent index for a matching parent |
| 114562 | + ** key. If a match is found, jump to addrOk. */ |
| 114563 | + if( pIdx ){ |
| 114564 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey, |
| 114565 | + sqlite3IndexAffinityStr(db,pIdx), pFK->nCol); |
| 114566 | + sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 114567 | + VdbeCoverage(v); |
| 114568 | + }else if( pParent ){ |
| 114569 | + int jmp = sqlite3VdbeCurrentAddr(v)+2; |
| 114570 | + sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v); |
| 114303 | 114571 | sqlite3VdbeGoto(v, addrOk); |
| 114304 | | - sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 114572 | + assert( pFK->nCol==1 ); |
| 114573 | + } |
| 114574 | + |
| 114575 | + /* Generate code to report an FK violation to the caller. */ |
| 114576 | + if( HasRowid(pTab) ){ |
| 114577 | + sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); |
| 114305 | 114578 | }else{ |
| 114306 | | - for(j=0; j<pFK->nCol; j++){ |
| 114307 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, |
| 114308 | | - aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j); |
| 114309 | | - sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v); |
| 114310 | | - } |
| 114311 | | - if( pParent ){ |
| 114312 | | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey, |
| 114313 | | - sqlite3IndexAffinityStr(db,pIdx), pFK->nCol); |
| 114314 | | - sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 114315 | | - VdbeCoverage(v); |
| 114316 | | - } |
| 114317 | | - } |
| 114318 | | - sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); |
| 114579 | + sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1); |
| 114580 | + } |
| 114319 | 114581 | sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1); |
| 114320 | 114582 | sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); |
| 114321 | 114583 | sqlite3VdbeResolveLabel(v, addrOk); |
| 114322 | 114584 | sqlite3DbFree(db, aiCols); |
| 114323 | 114585 | } |
| | @@ -114499,29 +114761,32 @@ |
| 114499 | 114761 | integrityCheckResultRow(v, 3); |
| 114500 | 114762 | sqlite3VdbeJumpHere(v, jmp2); |
| 114501 | 114763 | } |
| 114502 | 114764 | /* Verify CHECK constraints */ |
| 114503 | 114765 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 114504 | | - int addrCkFault = sqlite3VdbeMakeLabel(v); |
| 114505 | | - int addrCkOk = sqlite3VdbeMakeLabel(v); |
| 114506 | | - ExprList *pCheck = pTab->pCheck; |
| 114507 | | - char *zErr; |
| 114508 | | - int k; |
| 114509 | | - pParse->iSelfTab = iDataCur; |
| 114510 | | - sqlite3ExprCachePush(pParse); |
| 114511 | | - for(k=pCheck->nExpr-1; k>0; k--){ |
| 114512 | | - sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0); |
| 114513 | | - } |
| 114514 | | - sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, |
| 114515 | | - SQLITE_JUMPIFNULL); |
| 114516 | | - sqlite3VdbeResolveLabel(v, addrCkFault); |
| 114517 | | - zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s", |
| 114518 | | - pTab->zName); |
| 114519 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 114520 | | - integrityCheckResultRow(v, 3); |
| 114521 | | - sqlite3VdbeResolveLabel(v, addrCkOk); |
| 114522 | | - sqlite3ExprCachePop(pParse); |
| 114766 | + ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0); |
| 114767 | + if( db->mallocFailed==0 ){ |
| 114768 | + int addrCkFault = sqlite3VdbeMakeLabel(v); |
| 114769 | + int addrCkOk = sqlite3VdbeMakeLabel(v); |
| 114770 | + char *zErr; |
| 114771 | + int k; |
| 114772 | + pParse->iSelfTab = iDataCur; |
| 114773 | + sqlite3ExprCachePush(pParse); |
| 114774 | + for(k=pCheck->nExpr-1; k>0; k--){ |
| 114775 | + sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0); |
| 114776 | + } |
| 114777 | + sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, |
| 114778 | + SQLITE_JUMPIFNULL); |
| 114779 | + sqlite3VdbeResolveLabel(v, addrCkFault); |
| 114780 | + zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s", |
| 114781 | + pTab->zName); |
| 114782 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 114783 | + integrityCheckResultRow(v, 3); |
| 114784 | + sqlite3VdbeResolveLabel(v, addrCkOk); |
| 114785 | + sqlite3ExprCachePop(pParse); |
| 114786 | + } |
| 114787 | + sqlite3ExprListDelete(db, pCheck); |
| 114523 | 114788 | } |
| 114524 | 114789 | /* Validate index entries for the current row */ |
| 114525 | 114790 | for(j=0, pIdx=pTab->pIndex; pIdx && !isQuick; pIdx=pIdx->pNext, j++){ |
| 114526 | 114791 | int jmp2, jmp3, jmp4, jmp5; |
| 114527 | 114792 | int ckUniq = sqlite3VdbeMakeLabel(v); |
| | @@ -116321,11 +116586,11 @@ |
| 116321 | 116586 | sqlite3ExprDelete(db, p->pHaving); |
| 116322 | 116587 | sqlite3ExprListDelete(db, p->pOrderBy); |
| 116323 | 116588 | sqlite3ExprDelete(db, p->pLimit); |
| 116324 | 116589 | sqlite3ExprDelete(db, p->pOffset); |
| 116325 | 116590 | if( p->pWith ) sqlite3WithDelete(db, p->pWith); |
| 116326 | | - if( bFree ) sqlite3DbFree(db, p); |
| 116591 | + if( bFree ) sqlite3DbFreeNN(db, p); |
| 116327 | 116592 | p = pPrior; |
| 116328 | 116593 | bFree = 1; |
| 116329 | 116594 | } |
| 116330 | 116595 | } |
| 116331 | 116596 | |
| | @@ -116357,18 +116622,17 @@ |
| 116357 | 116622 | Expr *pLimit, /* LIMIT value. NULL means not used */ |
| 116358 | 116623 | Expr *pOffset /* OFFSET value. NULL means no offset */ |
| 116359 | 116624 | ){ |
| 116360 | 116625 | Select *pNew; |
| 116361 | 116626 | Select standin; |
| 116362 | | - sqlite3 *db = pParse->db; |
| 116363 | | - pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 116627 | + pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) ); |
| 116364 | 116628 | if( pNew==0 ){ |
| 116365 | | - assert( db->mallocFailed ); |
| 116629 | + assert( pParse->db->mallocFailed ); |
| 116366 | 116630 | pNew = &standin; |
| 116367 | 116631 | } |
| 116368 | 116632 | if( pEList==0 ){ |
| 116369 | | - pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ASTERISK,0)); |
| 116633 | + pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(pParse->db,TK_ASTERISK,0)); |
| 116370 | 116634 | } |
| 116371 | 116635 | pNew->pEList = pEList; |
| 116372 | 116636 | pNew->op = TK_SELECT; |
| 116373 | 116637 | pNew->selFlags = selFlags; |
| 116374 | 116638 | pNew->iLimit = 0; |
| | @@ -116377,11 +116641,11 @@ |
| 116377 | 116641 | pNew->zSelName[0] = 0; |
| 116378 | 116642 | #endif |
| 116379 | 116643 | pNew->addrOpenEphm[0] = -1; |
| 116380 | 116644 | pNew->addrOpenEphm[1] = -1; |
| 116381 | 116645 | pNew->nSelectRow = 0; |
| 116382 | | - if( pSrc==0 ) pSrc = sqlite3DbMallocZero(db, sizeof(*pSrc)); |
| 116646 | + if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc)); |
| 116383 | 116647 | pNew->pSrc = pSrc; |
| 116384 | 116648 | pNew->pWhere = pWhere; |
| 116385 | 116649 | pNew->pGroupBy = pGroupBy; |
| 116386 | 116650 | pNew->pHaving = pHaving; |
| 116387 | 116651 | pNew->pOrderBy = pOrderBy; |
| | @@ -116388,13 +116652,13 @@ |
| 116388 | 116652 | pNew->pPrior = 0; |
| 116389 | 116653 | pNew->pNext = 0; |
| 116390 | 116654 | pNew->pLimit = pLimit; |
| 116391 | 116655 | pNew->pOffset = pOffset; |
| 116392 | 116656 | pNew->pWith = 0; |
| 116393 | | - assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 ); |
| 116394 | | - if( db->mallocFailed ) { |
| 116395 | | - clearSelect(db, pNew, pNew!=&standin); |
| 116657 | + assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || pParse->db->mallocFailed!=0 ); |
| 116658 | + if( pParse->db->mallocFailed ) { |
| 116659 | + clearSelect(pParse->db, pNew, pNew!=&standin); |
| 116396 | 116660 | pNew = 0; |
| 116397 | 116661 | }else{ |
| 116398 | 116662 | assert( pNew->pSrc!=0 || pParse->nErr>0 ); |
| 116399 | 116663 | } |
| 116400 | 116664 | assert( pNew!=&standin ); |
| | @@ -117300,11 +117564,11 @@ |
| 117300 | 117564 | */ |
| 117301 | 117565 | SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){ |
| 117302 | 117566 | if( p ){ |
| 117303 | 117567 | assert( p->nRef>0 ); |
| 117304 | 117568 | p->nRef--; |
| 117305 | | - if( p->nRef==0 ) sqlite3DbFree(p->db, p); |
| 117569 | + if( p->nRef==0 ) sqlite3DbFreeNN(p->db, p); |
| 117306 | 117570 | } |
| 117307 | 117571 | } |
| 117308 | 117572 | |
| 117309 | 117573 | /* |
| 117310 | 117574 | ** Make a new pointer to a KeyInfo object |
| | @@ -117775,10 +118039,11 @@ |
| 117775 | 118039 | Vdbe *v = pParse->pVdbe; |
| 117776 | 118040 | int i; |
| 117777 | 118041 | NameContext sNC; |
| 117778 | 118042 | sNC.pSrcList = pTabList; |
| 117779 | 118043 | sNC.pParse = pParse; |
| 118044 | + sNC.pNext = 0; |
| 117780 | 118045 | for(i=0; i<pEList->nExpr; i++){ |
| 117781 | 118046 | Expr *p = pEList->a[i].pExpr; |
| 117782 | 118047 | const char *zType; |
| 117783 | 118048 | #ifdef SQLITE_ENABLE_COLUMN_METADATA |
| 117784 | 118049 | const char *zOrigDb = 0; |
| | @@ -117798,10 +118063,23 @@ |
| 117798 | 118063 | #endif |
| 117799 | 118064 | sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT); |
| 117800 | 118065 | } |
| 117801 | 118066 | #endif /* !defined(SQLITE_OMIT_DECLTYPE) */ |
| 117802 | 118067 | } |
| 118068 | + |
| 118069 | +/* |
| 118070 | +** Return the Table objecct in the SrcList that has cursor iCursor. |
| 118071 | +** Or return NULL if no such Table object exists in the SrcList. |
| 118072 | +*/ |
| 118073 | +static Table *tableWithCursor(SrcList *pList, int iCursor){ |
| 118074 | + int j; |
| 118075 | + for(j=0; j<pList->nSrc; j++){ |
| 118076 | + if( pList->a[j].iCursor==iCursor ) return pList->a[j].pTab; |
| 118077 | + } |
| 118078 | + return 0; |
| 118079 | +} |
| 118080 | + |
| 117803 | 118081 | |
| 117804 | 118082 | /* |
| 117805 | 118083 | ** Generate code that will tell the VDBE the names of columns |
| 117806 | 118084 | ** in the result set. This information is used to provide the |
| 117807 | 118085 | ** azCol[] values in the callback. |
| | @@ -117810,11 +118088,12 @@ |
| 117810 | 118088 | Parse *pParse, /* Parser context */ |
| 117811 | 118089 | SrcList *pTabList, /* List of tables */ |
| 117812 | 118090 | ExprList *pEList /* Expressions defining the result set */ |
| 117813 | 118091 | ){ |
| 117814 | 118092 | Vdbe *v = pParse->pVdbe; |
| 117815 | | - int i, j; |
| 118093 | + int i; |
| 118094 | + Table *pTab; |
| 117816 | 118095 | sqlite3 *db = pParse->db; |
| 117817 | 118096 | int fullNames, shortNames; |
| 117818 | 118097 | |
| 117819 | 118098 | #ifndef SQLITE_OMIT_EXPLAIN |
| 117820 | 118099 | /* If this is an EXPLAIN, skip this step */ |
| | @@ -117835,19 +118114,15 @@ |
| 117835 | 118114 | p = pEList->a[i].pExpr; |
| 117836 | 118115 | if( NEVER(p==0) ) continue; |
| 117837 | 118116 | if( pEList->a[i].zName ){ |
| 117838 | 118117 | char *zName = pEList->a[i].zName; |
| 117839 | 118118 | sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); |
| 117840 | | - }else if( p->op==TK_COLUMN || p->op==TK_AGG_COLUMN ){ |
| 117841 | | - Table *pTab; |
| 118119 | + }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) |
| 118120 | + && (pTab = tableWithCursor(pTabList, p->iTable))!=0 |
| 118121 | + ){ |
| 117842 | 118122 | char *zCol; |
| 117843 | 118123 | int iCol = p->iColumn; |
| 117844 | | - for(j=0; ALWAYS(j<pTabList->nSrc); j++){ |
| 117845 | | - if( pTabList->a[j].iCursor==p->iTable ) break; |
| 117846 | | - } |
| 117847 | | - assert( j<pTabList->nSrc ); |
| 117848 | | - pTab = pTabList->a[j].pTab; |
| 117849 | 118124 | if( iCol<0 ) iCol = pTab->iPKey; |
| 117850 | 118125 | assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) ); |
| 117851 | 118126 | if( iCol<0 ){ |
| 117852 | 118127 | zCol = "rowid"; |
| 117853 | 118128 | }else{ |
| | @@ -117925,11 +118200,11 @@ |
| 117925 | 118200 | Table *pTab; /* Table associated with this expression */ |
| 117926 | 118201 | while( pColExpr->op==TK_DOT ){ |
| 117927 | 118202 | pColExpr = pColExpr->pRight; |
| 117928 | 118203 | assert( pColExpr!=0 ); |
| 117929 | 118204 | } |
| 117930 | | - if( pColExpr->op==TK_COLUMN && ALWAYS(pColExpr->pTab!=0) ){ |
| 118205 | + if( pColExpr->op==TK_COLUMN && pColExpr->pTab!=0 ){ |
| 117931 | 118206 | /* For columns use the column name name */ |
| 117932 | 118207 | int iCol = pColExpr->iColumn; |
| 117933 | 118208 | pTab = pColExpr->pTab; |
| 117934 | 118209 | if( iCol<0 ) iCol = pTab->iPKey; |
| 117935 | 118210 | zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid"; |
| | @@ -119145,11 +119420,11 @@ |
| 119145 | 119420 | if( j==nOrderBy ){ |
| 119146 | 119421 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0); |
| 119147 | 119422 | if( pNew==0 ) return SQLITE_NOMEM_BKPT; |
| 119148 | 119423 | pNew->flags |= EP_IntValue; |
| 119149 | 119424 | pNew->u.iValue = i; |
| 119150 | | - pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); |
| 119425 | + p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); |
| 119151 | 119426 | if( pOrderBy ) pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i; |
| 119152 | 119427 | } |
| 119153 | 119428 | } |
| 119154 | 119429 | } |
| 119155 | 119430 | |
| | @@ -119379,13 +119654,28 @@ |
| 119379 | 119654 | return pParse->nErr!=0; |
| 119380 | 119655 | } |
| 119381 | 119656 | #endif |
| 119382 | 119657 | |
| 119383 | 119658 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 119659 | + |
| 119660 | +/* An instance of the SubstContext object describes an substitution edit |
| 119661 | +** to be performed on a parse tree. |
| 119662 | +** |
| 119663 | +** All references to columns in table iTable are to be replaced by corresponding |
| 119664 | +** expressions in pEList. |
| 119665 | +*/ |
| 119666 | +typedef struct SubstContext { |
| 119667 | + Parse *pParse; /* The parsing context */ |
| 119668 | + int iTable; /* Replace references to this table */ |
| 119669 | + int iNewTable; /* New table number */ |
| 119670 | + int isLeftJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */ |
| 119671 | + ExprList *pEList; /* Replacement expressions */ |
| 119672 | +} SubstContext; |
| 119673 | + |
| 119384 | 119674 | /* Forward Declarations */ |
| 119385 | | -static void substExprList(Parse*, ExprList*, int, ExprList*); |
| 119386 | | -static void substSelect(Parse*, Select *, int, ExprList*, int); |
| 119675 | +static void substExprList(SubstContext*, ExprList*); |
| 119676 | +static void substSelect(SubstContext*, Select*, int); |
| 119387 | 119677 | |
| 119388 | 119678 | /* |
| 119389 | 119679 | ** Scan through the expression pExpr. Replace every reference to |
| 119390 | 119680 | ** a column in table number iTable with a copy of the iColumn-th |
| 119391 | 119681 | ** entry in pEList. (But leave references to the ROWID column |
| | @@ -119392,33 +119682,42 @@ |
| 119392 | 119682 | ** unchanged.) |
| 119393 | 119683 | ** |
| 119394 | 119684 | ** This routine is part of the flattening procedure. A subquery |
| 119395 | 119685 | ** whose result set is defined by pEList appears as entry in the |
| 119396 | 119686 | ** FROM clause of a SELECT such that the VDBE cursor assigned to that |
| 119397 | | -** FORM clause entry is iTable. This routine make the necessary |
| 119687 | +** FORM clause entry is iTable. This routine makes the necessary |
| 119398 | 119688 | ** changes to pExpr so that it refers directly to the source table |
| 119399 | 119689 | ** of the subquery rather the result set of the subquery. |
| 119400 | 119690 | */ |
| 119401 | 119691 | static Expr *substExpr( |
| 119402 | | - Parse *pParse, /* Report errors here */ |
| 119403 | | - Expr *pExpr, /* Expr in which substitution occurs */ |
| 119404 | | - int iTable, /* Table to be substituted */ |
| 119405 | | - ExprList *pEList /* Substitute expressions */ |
| 119692 | + SubstContext *pSubst, /* Description of the substitution */ |
| 119693 | + Expr *pExpr /* Expr in which substitution occurs */ |
| 119406 | 119694 | ){ |
| 119407 | | - sqlite3 *db = pParse->db; |
| 119408 | 119695 | if( pExpr==0 ) return 0; |
| 119409 | | - if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){ |
| 119696 | + if( ExprHasProperty(pExpr, EP_FromJoin) && pExpr->iRightJoinTable==pSubst->iTable ){ |
| 119697 | + pExpr->iRightJoinTable = pSubst->iNewTable; |
| 119698 | + } |
| 119699 | + if( pExpr->op==TK_COLUMN && pExpr->iTable==pSubst->iTable ){ |
| 119410 | 119700 | if( pExpr->iColumn<0 ){ |
| 119411 | 119701 | pExpr->op = TK_NULL; |
| 119412 | 119702 | }else{ |
| 119413 | 119703 | Expr *pNew; |
| 119414 | | - Expr *pCopy = pEList->a[pExpr->iColumn].pExpr; |
| 119415 | | - assert( pEList!=0 && pExpr->iColumn<pEList->nExpr ); |
| 119704 | + Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr; |
| 119705 | + Expr ifNullRow; |
| 119706 | + assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr ); |
| 119416 | 119707 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 119417 | 119708 | if( sqlite3ExprIsVector(pCopy) ){ |
| 119418 | | - sqlite3VectorErrorMsg(pParse, pCopy); |
| 119709 | + sqlite3VectorErrorMsg(pSubst->pParse, pCopy); |
| 119419 | 119710 | }else{ |
| 119711 | + sqlite3 *db = pSubst->pParse->db; |
| 119712 | + if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){ |
| 119713 | + memset(&ifNullRow, 0, sizeof(ifNullRow)); |
| 119714 | + ifNullRow.op = TK_IF_NULL_ROW; |
| 119715 | + ifNullRow.pLeft = pCopy; |
| 119716 | + ifNullRow.iTable = pSubst->iNewTable; |
| 119717 | + pCopy = &ifNullRow; |
| 119718 | + } |
| 119420 | 119719 | pNew = sqlite3ExprDup(db, pCopy, 0); |
| 119421 | 119720 | if( pNew && (pExpr->flags & EP_FromJoin) ){ |
| 119422 | 119721 | pNew->iRightJoinTable = pExpr->iRightJoinTable; |
| 119423 | 119722 | pNew->flags |= EP_FromJoin; |
| 119424 | 119723 | } |
| | @@ -119425,55 +119724,51 @@ |
| 119425 | 119724 | sqlite3ExprDelete(db, pExpr); |
| 119426 | 119725 | pExpr = pNew; |
| 119427 | 119726 | } |
| 119428 | 119727 | } |
| 119429 | 119728 | }else{ |
| 119430 | | - pExpr->pLeft = substExpr(pParse, pExpr->pLeft, iTable, pEList); |
| 119431 | | - pExpr->pRight = substExpr(pParse, pExpr->pRight, iTable, pEList); |
| 119729 | + pExpr->pLeft = substExpr(pSubst, pExpr->pLeft); |
| 119730 | + pExpr->pRight = substExpr(pSubst, pExpr->pRight); |
| 119432 | 119731 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 119433 | | - substSelect(pParse, pExpr->x.pSelect, iTable, pEList, 1); |
| 119732 | + substSelect(pSubst, pExpr->x.pSelect, 1); |
| 119434 | 119733 | }else{ |
| 119435 | | - substExprList(pParse, pExpr->x.pList, iTable, pEList); |
| 119734 | + substExprList(pSubst, pExpr->x.pList); |
| 119436 | 119735 | } |
| 119437 | 119736 | } |
| 119438 | 119737 | return pExpr; |
| 119439 | 119738 | } |
| 119440 | 119739 | static void substExprList( |
| 119441 | | - Parse *pParse, /* Report errors here */ |
| 119442 | | - ExprList *pList, /* List to scan and in which to make substitutes */ |
| 119443 | | - int iTable, /* Table to be substituted */ |
| 119444 | | - ExprList *pEList /* Substitute values */ |
| 119740 | + SubstContext *pSubst, /* Description of the substitution */ |
| 119741 | + ExprList *pList /* List to scan and in which to make substitutes */ |
| 119445 | 119742 | ){ |
| 119446 | 119743 | int i; |
| 119447 | 119744 | if( pList==0 ) return; |
| 119448 | 119745 | for(i=0; i<pList->nExpr; i++){ |
| 119449 | | - pList->a[i].pExpr = substExpr(pParse, pList->a[i].pExpr, iTable, pEList); |
| 119746 | + pList->a[i].pExpr = substExpr(pSubst, pList->a[i].pExpr); |
| 119450 | 119747 | } |
| 119451 | 119748 | } |
| 119452 | 119749 | static void substSelect( |
| 119453 | | - Parse *pParse, /* Report errors here */ |
| 119454 | | - Select *p, /* SELECT statement in which to make substitutions */ |
| 119455 | | - int iTable, /* Table to be replaced */ |
| 119456 | | - ExprList *pEList, /* Substitute values */ |
| 119457 | | - int doPrior /* Do substitutes on p->pPrior too */ |
| 119750 | + SubstContext *pSubst, /* Description of the substitution */ |
| 119751 | + Select *p, /* SELECT statement in which to make substitutions */ |
| 119752 | + int doPrior /* Do substitutes on p->pPrior too */ |
| 119458 | 119753 | ){ |
| 119459 | 119754 | SrcList *pSrc; |
| 119460 | 119755 | struct SrcList_item *pItem; |
| 119461 | 119756 | int i; |
| 119462 | 119757 | if( !p ) return; |
| 119463 | 119758 | do{ |
| 119464 | | - substExprList(pParse, p->pEList, iTable, pEList); |
| 119465 | | - substExprList(pParse, p->pGroupBy, iTable, pEList); |
| 119466 | | - substExprList(pParse, p->pOrderBy, iTable, pEList); |
| 119467 | | - p->pHaving = substExpr(pParse, p->pHaving, iTable, pEList); |
| 119468 | | - p->pWhere = substExpr(pParse, p->pWhere, iTable, pEList); |
| 119759 | + substExprList(pSubst, p->pEList); |
| 119760 | + substExprList(pSubst, p->pGroupBy); |
| 119761 | + substExprList(pSubst, p->pOrderBy); |
| 119762 | + p->pHaving = substExpr(pSubst, p->pHaving); |
| 119763 | + p->pWhere = substExpr(pSubst, p->pWhere); |
| 119469 | 119764 | pSrc = p->pSrc; |
| 119470 | 119765 | assert( pSrc!=0 ); |
| 119471 | 119766 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ |
| 119472 | | - substSelect(pParse, pItem->pSelect, iTable, pEList, 1); |
| 119767 | + substSelect(pSubst, pItem->pSelect, 1); |
| 119473 | 119768 | if( pItem->fg.isTabFunc ){ |
| 119474 | | - substExprList(pParse, pItem->u1.pFuncArg, iTable, pEList); |
| 119769 | + substExprList(pSubst, pItem->u1.pFuncArg); |
| 119475 | 119770 | } |
| 119476 | 119771 | } |
| 119477 | 119772 | }while( doPrior && (p = p->pPrior)!=0 ); |
| 119478 | 119773 | } |
| 119479 | 119774 | #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */ |
| | @@ -119512,12 +119807,12 @@ |
| 119512 | 119807 | ** (2) The subquery is not an aggregate or (2a) the outer query is not a join |
| 119513 | 119808 | ** and (2b) the outer query does not use subqueries other than the one |
| 119514 | 119809 | ** FROM-clause subquery that is a candidate for flattening. (2b is |
| 119515 | 119810 | ** due to ticket [2f7170d73bf9abf80] from 2015-02-09.) |
| 119516 | 119811 | ** |
| 119517 | | -** (3) The subquery is not the right operand of a left outer join |
| 119518 | | -** (Originally ticket #306. Strengthened by ticket #3300) |
| 119812 | +** (3) The subquery is not the right operand of a LEFT JOIN |
| 119813 | +** or the subquery is not itself a join. |
| 119519 | 119814 | ** |
| 119520 | 119815 | ** (4) The subquery is not DISTINCT. |
| 119521 | 119816 | ** |
| 119522 | 119817 | ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT |
| 119523 | 119818 | ** sub-queries that were excluded from this optimization. Restriction |
| | @@ -119525,11 +119820,11 @@ |
| 119525 | 119820 | ** |
| 119526 | 119821 | ** (6) The subquery does not use aggregates or the outer query is not |
| 119527 | 119822 | ** DISTINCT. |
| 119528 | 119823 | ** |
| 119529 | 119824 | ** (7) The subquery has a FROM clause. TODO: For subqueries without |
| 119530 | | -** A FROM clause, consider adding a FROM close with the special |
| 119825 | +** A FROM clause, consider adding a FROM clause with the special |
| 119531 | 119826 | ** table sqlite_once that consists of a single row containing a |
| 119532 | 119827 | ** single NULL. |
| 119533 | 119828 | ** |
| 119534 | 119829 | ** (8) The subquery does not use LIMIT or the outer query is not a join. |
| 119535 | 119830 | ** |
| | @@ -119631,10 +119926,12 @@ |
| 119631 | 119926 | Select *pSub1; /* Pointer to the rightmost select in sub-query */ |
| 119632 | 119927 | SrcList *pSrc; /* The FROM clause of the outer query */ |
| 119633 | 119928 | SrcList *pSubSrc; /* The FROM clause of the subquery */ |
| 119634 | 119929 | ExprList *pList; /* The result set of the outer query */ |
| 119635 | 119930 | int iParent; /* VDBE cursor number of the pSub result set temp table */ |
| 119931 | + int iNewParent = -1;/* Replacement table for iParent */ |
| 119932 | + int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ |
| 119636 | 119933 | int i; /* Loop counter */ |
| 119637 | 119934 | Expr *pWhere; /* The WHERE clause */ |
| 119638 | 119935 | struct SrcList_item *pSubitem; /* The subquery */ |
| 119639 | 119936 | sqlite3 *db = pParse->db; |
| 119640 | 119937 | |
| | @@ -119657,11 +119954,11 @@ |
| 119657 | 119954 | || (sqlite3ExprListFlags(p->pOrderBy) & EP_Subquery)!=0 |
| 119658 | 119955 | ){ |
| 119659 | 119956 | return 0; /* Restriction (2b) */ |
| 119660 | 119957 | } |
| 119661 | 119958 | } |
| 119662 | | - |
| 119959 | + |
| 119663 | 119960 | pSubSrc = pSub->pSrc; |
| 119664 | 119961 | assert( pSubSrc ); |
| 119665 | 119962 | /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, |
| 119666 | 119963 | ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET |
| 119667 | 119964 | ** because they could be computed at compile-time. But when LIMIT and OFFSET |
| | @@ -119695,44 +119992,29 @@ |
| 119695 | 119992 | } |
| 119696 | 119993 | if( (p->selFlags & SF_Recursive) && pSub->pPrior ){ |
| 119697 | 119994 | return 0; /* Restriction (23) */ |
| 119698 | 119995 | } |
| 119699 | 119996 | |
| 119700 | | - /* OBSOLETE COMMENT 1: |
| 119701 | | - ** Restriction 3: If the subquery is a join, make sure the subquery is |
| 119702 | | - ** not used as the right operand of an outer join. Examples of why this |
| 119703 | | - ** is not allowed: |
| 119997 | + /* |
| 119998 | + ** If the subquery is the right operand of a LEFT JOIN, then the |
| 119999 | + ** subquery may not be a join itself. Example of why this is not allowed: |
| 119704 | 120000 | ** |
| 119705 | 120001 | ** t1 LEFT OUTER JOIN (t2 JOIN t3) |
| 119706 | 120002 | ** |
| 119707 | 120003 | ** If we flatten the above, we would get |
| 119708 | 120004 | ** |
| 119709 | 120005 | ** (t1 LEFT OUTER JOIN t2) JOIN t3 |
| 119710 | 120006 | ** |
| 119711 | 120007 | ** which is not at all the same thing. |
| 119712 | 120008 | ** |
| 119713 | | - ** OBSOLETE COMMENT 2: |
| 119714 | | - ** Restriction 12: If the subquery is the right operand of a left outer |
| 119715 | | - ** join, make sure the subquery has no WHERE clause. |
| 119716 | | - ** An examples of why this is not allowed: |
| 119717 | | - ** |
| 119718 | | - ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) |
| 119719 | | - ** |
| 119720 | | - ** If we flatten the above, we would get |
| 119721 | | - ** |
| 119722 | | - ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 |
| 119723 | | - ** |
| 119724 | | - ** But the t2.x>0 test will always fail on a NULL row of t2, which |
| 119725 | | - ** effectively converts the OUTER JOIN into an INNER JOIN. |
| 119726 | | - ** |
| 119727 | | - ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: |
| 119728 | | - ** Ticket #3300 shows that flattening the right term of a LEFT JOIN |
| 119729 | | - ** is fraught with danger. Best to avoid the whole thing. If the |
| 119730 | | - ** subquery is the right term of a LEFT JOIN, then do not flatten. |
| 120009 | + ** See also tickets #306, #350, and #3300. |
| 119731 | 120010 | */ |
| 119732 | 120011 | if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 119733 | | - return 0; |
| 120012 | + isLeftJoin = 1; |
| 120013 | + if( pSubSrc->nSrc>1 ){ |
| 120014 | + return 0; /* Restriction (3) */ |
| 120015 | + } |
| 119734 | 120016 | } |
| 119735 | 120017 | |
| 119736 | 120018 | /* Restriction 17: If the sub-query is a compound SELECT, then it must |
| 119737 | 120019 | ** use only the UNION ALL operator. And none of the simple select queries |
| 119738 | 120020 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| | @@ -119937,10 +120219,11 @@ |
| 119937 | 120219 | */ |
| 119938 | 120220 | for(i=0; i<nSubSrc; i++){ |
| 119939 | 120221 | sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing); |
| 119940 | 120222 | assert( pSrc->a[i+iFrom].fg.isTabFunc==0 ); |
| 119941 | 120223 | pSrc->a[i+iFrom] = pSubSrc->a[i]; |
| 120224 | + iNewParent = pSubSrc->a[i].iCursor; |
| 119942 | 120225 | memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); |
| 119943 | 120226 | } |
| 119944 | 120227 | pSrc->a[iFrom].fg.jointype = jointype; |
| 119945 | 120228 | |
| 119946 | 120229 | /* Now begin substituting subquery result set expressions for |
| | @@ -119982,10 +120265,13 @@ |
| 119982 | 120265 | assert( pSub->pPrior==0 ); |
| 119983 | 120266 | pParent->pOrderBy = pOrderBy; |
| 119984 | 120267 | pSub->pOrderBy = 0; |
| 119985 | 120268 | } |
| 119986 | 120269 | pWhere = sqlite3ExprDup(db, pSub->pWhere, 0); |
| 120270 | + if( isLeftJoin ){ |
| 120271 | + setJoinExpr(pWhere, iNewParent); |
| 120272 | + } |
| 119987 | 120273 | if( subqueryIsAgg ){ |
| 119988 | 120274 | assert( pParent->pHaving==0 ); |
| 119989 | 120275 | pParent->pHaving = pParent->pWhere; |
| 119990 | 120276 | pParent->pWhere = pWhere; |
| 119991 | 120277 | pParent->pHaving = sqlite3ExprAnd(db, |
| | @@ -119995,11 +120281,17 @@ |
| 119995 | 120281 | pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0); |
| 119996 | 120282 | }else{ |
| 119997 | 120283 | pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere); |
| 119998 | 120284 | } |
| 119999 | 120285 | if( db->mallocFailed==0 ){ |
| 120000 | | - substSelect(pParse, pParent, iParent, pSub->pEList, 0); |
| 120286 | + SubstContext x; |
| 120287 | + x.pParse = pParse; |
| 120288 | + x.iTable = iParent; |
| 120289 | + x.iNewTable = iNewParent; |
| 120290 | + x.isLeftJoin = isLeftJoin; |
| 120291 | + x.pEList = pSub->pEList; |
| 120292 | + substSelect(&x, pParent, 0); |
| 120001 | 120293 | } |
| 120002 | 120294 | |
| 120003 | 120295 | /* The flattened query is distinct if either the inner or the |
| 120004 | 120296 | ** outer query is distinct. |
| 120005 | 120297 | */ |
| | @@ -120098,12 +120390,18 @@ |
| 120098 | 120390 | } |
| 120099 | 120391 | if( ExprHasProperty(pWhere,EP_FromJoin) ) return 0; /* restriction 5 */ |
| 120100 | 120392 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ |
| 120101 | 120393 | nChng++; |
| 120102 | 120394 | while( pSubq ){ |
| 120395 | + SubstContext x; |
| 120103 | 120396 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| 120104 | | - pNew = substExpr(pParse, pNew, iCursor, pSubq->pEList); |
| 120397 | + x.pParse = pParse; |
| 120398 | + x.iTable = iCursor; |
| 120399 | + x.iNewTable = iCursor; |
| 120400 | + x.isLeftJoin = 0; |
| 120401 | + x.pEList = pSubq->pEList; |
| 120402 | + pNew = substExpr(&x, pNew); |
| 120105 | 120403 | pSubq->pWhere = sqlite3ExprAnd(pParse->db, pSubq->pWhere, pNew); |
| 120106 | 120404 | pSubq = pSubq->pPrior; |
| 120107 | 120405 | } |
| 120108 | 120406 | } |
| 120109 | 120407 | return nChng; |
| | @@ -121090,10 +121388,107 @@ |
| 121090 | 121388 | } |
| 121091 | 121389 | } |
| 121092 | 121390 | #else |
| 121093 | 121391 | # define explainSimpleCount(a,b,c) |
| 121094 | 121392 | #endif |
| 121393 | + |
| 121394 | +/* |
| 121395 | +** Context object for havingToWhereExprCb(). |
| 121396 | +*/ |
| 121397 | +struct HavingToWhereCtx { |
| 121398 | + Expr **ppWhere; |
| 121399 | + ExprList *pGroupBy; |
| 121400 | +}; |
| 121401 | + |
| 121402 | +/* |
| 121403 | +** sqlite3WalkExpr() callback used by havingToWhere(). |
| 121404 | +** |
| 121405 | +** If the node passed to the callback is a TK_AND node, return |
| 121406 | +** WRC_Continue to tell sqlite3WalkExpr() to iterate through child nodes. |
| 121407 | +** |
| 121408 | +** Otherwise, return WRC_Prune. In this case, also check if the |
| 121409 | +** sub-expression matches the criteria for being moved to the WHERE |
| 121410 | +** clause. If so, add it to the WHERE clause and replace the sub-expression |
| 121411 | +** within the HAVING expression with a constant "1". |
| 121412 | +*/ |
| 121413 | +static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ |
| 121414 | + if( pExpr->op!=TK_AND ){ |
| 121415 | + struct HavingToWhereCtx *p = pWalker->u.pHavingCtx; |
| 121416 | + if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, p->pGroupBy) ){ |
| 121417 | + sqlite3 *db = pWalker->pParse->db; |
| 121418 | + Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0); |
| 121419 | + if( pNew ){ |
| 121420 | + Expr *pWhere = *(p->ppWhere); |
| 121421 | + SWAP(Expr, *pNew, *pExpr); |
| 121422 | + pNew = sqlite3ExprAnd(db, pWhere, pNew); |
| 121423 | + *(p->ppWhere) = pNew; |
| 121424 | + } |
| 121425 | + } |
| 121426 | + return WRC_Prune; |
| 121427 | + } |
| 121428 | + return WRC_Continue; |
| 121429 | +} |
| 121430 | + |
| 121431 | +/* |
| 121432 | +** Transfer eligible terms from the HAVING clause of a query, which is |
| 121433 | +** processed after grouping, to the WHERE clause, which is processed before |
| 121434 | +** grouping. For example, the query: |
| 121435 | +** |
| 121436 | +** SELECT * FROM <tables> WHERE a=? GROUP BY b HAVING b=? AND c=? |
| 121437 | +** |
| 121438 | +** can be rewritten as: |
| 121439 | +** |
| 121440 | +** SELECT * FROM <tables> WHERE a=? AND b=? GROUP BY b HAVING c=? |
| 121441 | +** |
| 121442 | +** A term of the HAVING expression is eligible for transfer if it consists |
| 121443 | +** entirely of constants and expressions that are also GROUP BY terms that |
| 121444 | +** use the "BINARY" collation sequence. |
| 121445 | +*/ |
| 121446 | +static void havingToWhere( |
| 121447 | + Parse *pParse, |
| 121448 | + ExprList *pGroupBy, |
| 121449 | + Expr *pHaving, |
| 121450 | + Expr **ppWhere |
| 121451 | +){ |
| 121452 | + struct HavingToWhereCtx sCtx; |
| 121453 | + Walker sWalker; |
| 121454 | + |
| 121455 | + sCtx.ppWhere = ppWhere; |
| 121456 | + sCtx.pGroupBy = pGroupBy; |
| 121457 | + |
| 121458 | + memset(&sWalker, 0, sizeof(sWalker)); |
| 121459 | + sWalker.pParse = pParse; |
| 121460 | + sWalker.xExprCallback = havingToWhereExprCb; |
| 121461 | + sWalker.u.pHavingCtx = &sCtx; |
| 121462 | + sqlite3WalkExpr(&sWalker, pHaving); |
| 121463 | +} |
| 121464 | + |
| 121465 | +/* |
| 121466 | +** Check to see if the pThis entry of pTabList is a self-join of a prior view. |
| 121467 | +** If it is, then return the SrcList_item for the prior view. If it is not, |
| 121468 | +** then return 0. |
| 121469 | +*/ |
| 121470 | +static struct SrcList_item *isSelfJoinView( |
| 121471 | + SrcList *pTabList, /* Search for self-joins in this FROM clause */ |
| 121472 | + struct SrcList_item *pThis /* Search for prior reference to this subquery */ |
| 121473 | +){ |
| 121474 | + struct SrcList_item *pItem; |
| 121475 | + for(pItem = pTabList->a; pItem<pThis; pItem++){ |
| 121476 | + if( pItem->pSelect==0 ) continue; |
| 121477 | + if( pItem->fg.viaCoroutine ) continue; |
| 121478 | + if( pItem->zName==0 ) continue; |
| 121479 | + if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue; |
| 121480 | + if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue; |
| 121481 | + if( sqlite3ExprCompare(pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) ){ |
| 121482 | + /* The view was modified by some other optimization such as |
| 121483 | + ** pushDownWhereTerms() */ |
| 121484 | + continue; |
| 121485 | + } |
| 121486 | + return pItem; |
| 121487 | + } |
| 121488 | + return 0; |
| 121489 | +} |
| 121095 | 121490 | |
| 121096 | 121491 | /* |
| 121097 | 121492 | ** Generate code for the SELECT statement given in the p argument. |
| 121098 | 121493 | ** |
| 121099 | 121494 | ** The results are returned according to the SelectDest structure. |
| | @@ -121230,17 +121625,42 @@ |
| 121230 | 121625 | #endif |
| 121231 | 121626 | return rc; |
| 121232 | 121627 | } |
| 121233 | 121628 | #endif |
| 121234 | 121629 | |
| 121235 | | - /* Generate code for all sub-queries in the FROM clause |
| 121630 | + /* For each term in the FROM clause, do two things: |
| 121631 | + ** (1) Authorized unreferenced tables |
| 121632 | + ** (2) Generate code for all sub-queries |
| 121236 | 121633 | */ |
| 121237 | | -#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 121238 | 121634 | for(i=0; i<pTabList->nSrc; i++){ |
| 121239 | 121635 | struct SrcList_item *pItem = &pTabList->a[i]; |
| 121240 | 121636 | SelectDest dest; |
| 121241 | | - Select *pSub = pItem->pSelect; |
| 121637 | + Select *pSub; |
| 121638 | + |
| 121639 | + /* Issue SQLITE_READ authorizations with a fake column name for any tables that |
| 121640 | + ** are referenced but from which no values are extracted. Examples of where these |
| 121641 | + ** kinds of null SQLITE_READ authorizations would occur: |
| 121642 | + ** |
| 121643 | + ** SELECT count(*) FROM t1; -- SQLITE_READ t1."" |
| 121644 | + ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2."" |
| 121645 | + ** |
| 121646 | + ** The fake column name is an empty string. It is possible for a table to |
| 121647 | + ** have a column named by the empty string, in which case there is no way to |
| 121648 | + ** distinguish between an unreferenced table and an actual reference to the |
| 121649 | + ** "" column. The original design was for the fake column name to be a NULL, |
| 121650 | + ** which would be unambiguous. But legacy authorization callbacks might |
| 121651 | + ** assume the column name is non-NULL and segfault. The use of an empty string |
| 121652 | + ** for the fake column name seems safer. |
| 121653 | + */ |
| 121654 | + if( pItem->colUsed==0 ){ |
| 121655 | + sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase); |
| 121656 | + } |
| 121657 | + |
| 121658 | +#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 121659 | + /* Generate code for all sub-queries in the FROM clause |
| 121660 | + */ |
| 121661 | + pSub = pItem->pSelect; |
| 121242 | 121662 | if( pSub==0 ) continue; |
| 121243 | 121663 | |
| 121244 | 121664 | /* Sometimes the code for a subquery will be generated more than |
| 121245 | 121665 | ** once, if the subquery is part of the WHERE clause in a LEFT JOIN, |
| 121246 | 121666 | ** for example. In that case, do not regenerate the code to manifest |
| | @@ -121247,10 +121667,14 @@ |
| 121247 | 121667 | ** a view or the co-routine to implement a view. The first instance |
| 121248 | 121668 | ** is sufficient, though the subroutine to manifest the view does need |
| 121249 | 121669 | ** to be invoked again. */ |
| 121250 | 121670 | if( pItem->addrFillSub ){ |
| 121251 | 121671 | if( pItem->fg.viaCoroutine==0 ){ |
| 121672 | + /* The subroutine that manifests the view might be a one-time routine, |
| 121673 | + ** or it might need to be rerun on each iteration because it |
| 121674 | + ** encodes a correlated subquery. */ |
| 121675 | + testcase( sqlite3VdbeGetOp(v, pItem->addrFillSub)->opcode==OP_Once ); |
| 121252 | 121676 | sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub); |
| 121253 | 121677 | } |
| 121254 | 121678 | continue; |
| 121255 | 121679 | } |
| 121256 | 121680 | |
| | @@ -121321,10 +121745,12 @@ |
| 121321 | 121745 | ** is a register allocated to hold the subroutine return address |
| 121322 | 121746 | */ |
| 121323 | 121747 | int topAddr; |
| 121324 | 121748 | int onceAddr = 0; |
| 121325 | 121749 | int retAddr; |
| 121750 | + struct SrcList_item *pPrior; |
| 121751 | + |
| 121326 | 121752 | assert( pItem->addrFillSub==0 ); |
| 121327 | 121753 | pItem->regReturn = ++pParse->nMem; |
| 121328 | 121754 | topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn); |
| 121329 | 121755 | pItem->addrFillSub = topAddr+1; |
| 121330 | 121756 | if( pItem->fg.isCorrelated==0 ){ |
| | @@ -121334,24 +121760,29 @@ |
| 121334 | 121760 | onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 121335 | 121761 | VdbeComment((v, "materialize \"%s\"", pItem->pTab->zName)); |
| 121336 | 121762 | }else{ |
| 121337 | 121763 | VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName)); |
| 121338 | 121764 | } |
| 121339 | | - sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 121340 | | - explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); |
| 121341 | | - sqlite3Select(pParse, pSub, &dest); |
| 121765 | + pPrior = isSelfJoinView(pTabList, pItem); |
| 121766 | + if( pPrior ){ |
| 121767 | + sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); |
| 121768 | + }else{ |
| 121769 | + sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 121770 | + explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); |
| 121771 | + sqlite3Select(pParse, pSub, &dest); |
| 121772 | + } |
| 121342 | 121773 | pItem->pTab->nRowLogEst = pSub->nSelectRow; |
| 121343 | 121774 | if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); |
| 121344 | 121775 | retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn); |
| 121345 | 121776 | VdbeComment((v, "end %s", pItem->pTab->zName)); |
| 121346 | 121777 | sqlite3VdbeChangeP1(v, topAddr, retAddr); |
| 121347 | 121778 | sqlite3ClearTempRegCache(pParse); |
| 121348 | 121779 | } |
| 121349 | 121780 | if( db->mallocFailed ) goto select_end; |
| 121350 | 121781 | pParse->nHeight -= sqlite3SelectExprHeight(p); |
| 121782 | +#endif |
| 121351 | 121783 | } |
| 121352 | | -#endif |
| 121353 | 121784 | |
| 121354 | 121785 | /* Various elements of the SELECT copied into local variables for |
| 121355 | 121786 | ** convenience */ |
| 121356 | 121787 | pEList = p->pEList; |
| 121357 | 121788 | pWhere = p->pWhere; |
| | @@ -121555,10 +121986,15 @@ |
| 121555 | 121986 | sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0; |
| 121556 | 121987 | sAggInfo.pGroupBy = pGroupBy; |
| 121557 | 121988 | sqlite3ExprAnalyzeAggList(&sNC, pEList); |
| 121558 | 121989 | sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy); |
| 121559 | 121990 | if( pHaving ){ |
| 121991 | + if( pGroupBy ){ |
| 121992 | + assert( pWhere==p->pWhere ); |
| 121993 | + havingToWhere(pParse, pGroupBy, pHaving, &p->pWhere); |
| 121994 | + pWhere = p->pWhere; |
| 121995 | + } |
| 121560 | 121996 | sqlite3ExprAnalyzeAggregates(&sNC, pHaving); |
| 121561 | 121997 | } |
| 121562 | 121998 | sAggInfo.nAccumulator = sAggInfo.nColumn; |
| 121563 | 121999 | for(i=0; i<sAggInfo.nFunc; i++){ |
| 121564 | 122000 | assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) ); |
| | @@ -123567,11 +124003,11 @@ |
| 123567 | 124003 | ** |
| 123568 | 124004 | ** FIXME: Be smarter about omitting indexes that use expressions. |
| 123569 | 124005 | */ |
| 123570 | 124006 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 123571 | 124007 | int reg; |
| 123572 | | - if( chngKey || hasFK || pIdx->pPartIdxWhere || pIdx==pPk ){ |
| 124008 | + if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){ |
| 123573 | 124009 | reg = ++pParse->nMem; |
| 123574 | 124010 | pParse->nMem += pIdx->nColumn; |
| 123575 | 124011 | }else{ |
| 123576 | 124012 | reg = 0; |
| 123577 | 124013 | for(i=0; i<pIdx->nKeyCol; i++){ |
| | @@ -123922,11 +124358,11 @@ |
| 123922 | 124358 | ** is the column index supplied by the user. |
| 123923 | 124359 | */ |
| 123924 | 124360 | assert( regNew==regNewRowid+1 ); |
| 123925 | 124361 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 123926 | 124362 | sqlite3VdbeAddOp3(v, OP_Delete, iDataCur, |
| 123927 | | - OPFLAG_ISUPDATE | ((hasFK || chngKey) ? 0 : OPFLAG_ISNOOP), |
| 124363 | + OPFLAG_ISUPDATE | ((hasFK>1 || chngKey) ? 0 : OPFLAG_ISNOOP), |
| 123928 | 124364 | regNewRowid |
| 123929 | 124365 | ); |
| 123930 | 124366 | if( eOnePass==ONEPASS_MULTI ){ |
| 123931 | 124367 | assert( hasFK==0 && chngKey==0 ); |
| 123932 | 124368 | sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION); |
| | @@ -123933,11 +124369,11 @@ |
| 123933 | 124369 | } |
| 123934 | 124370 | if( !pParse->nested ){ |
| 123935 | 124371 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); |
| 123936 | 124372 | } |
| 123937 | 124373 | #else |
| 123938 | | - if( hasFK || chngKey ){ |
| 124374 | + if( hasFK>1 || chngKey ){ |
| 123939 | 124375 | sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0); |
| 123940 | 124376 | } |
| 123941 | 124377 | #endif |
| 123942 | 124378 | if( bReplace || chngKey ){ |
| 123943 | 124379 | sqlite3VdbeJumpHere(v, addr1); |
| | @@ -125576,11 +126012,11 @@ |
| 125576 | 126012 | |
| 125577 | 126013 | /* Check to see the left operand is a column in a virtual table */ |
| 125578 | 126014 | if( NEVER(pExpr==0) ) return pDef; |
| 125579 | 126015 | if( pExpr->op!=TK_COLUMN ) return pDef; |
| 125580 | 126016 | pTab = pExpr->pTab; |
| 125581 | | - if( NEVER(pTab==0) ) return pDef; |
| 126017 | + if( pTab==0 ) return pDef; |
| 125582 | 126018 | if( !IsVirtual(pTab) ) return pDef; |
| 125583 | 126019 | pVtab = sqlite3GetVTable(db, pTab)->pVtab; |
| 125584 | 126020 | assert( pVtab!=0 ); |
| 125585 | 126021 | assert( pVtab->pModule!=0 ); |
| 125586 | 126022 | pMod = (sqlite3_module *)pVtab->pModule; |
| | @@ -125911,10 +126347,11 @@ |
| 125911 | 126347 | union { |
| 125912 | 126348 | struct { /* Information for internal btree tables */ |
| 125913 | 126349 | u16 nEq; /* Number of equality constraints */ |
| 125914 | 126350 | u16 nBtm; /* Size of BTM vector */ |
| 125915 | 126351 | u16 nTop; /* Size of TOP vector */ |
| 126352 | + u16 nIdxCol; /* Index column used for ORDER BY */ |
| 125916 | 126353 | Index *pIndex; /* Index used, or NULL */ |
| 125917 | 126354 | } btree; |
| 125918 | 126355 | struct { /* Information for virtual tables */ |
| 125919 | 126356 | int idxNum; /* Index number */ |
| 125920 | 126357 | u8 needFree; /* True if sqlite3_free(idxStr) is needed */ |
| | @@ -126204,10 +126641,11 @@ |
| 126204 | 126641 | struct WhereInfo { |
| 126205 | 126642 | Parse *pParse; /* Parsing and code generating context */ |
| 126206 | 126643 | SrcList *pTabList; /* List of tables in the join */ |
| 126207 | 126644 | ExprList *pOrderBy; /* The ORDER BY clause or NULL */ |
| 126208 | 126645 | ExprList *pResultSet; /* Result set of the query */ |
| 126646 | + Expr *pWhere; /* The complete WHERE clause */ |
| 126209 | 126647 | LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ |
| 126210 | 126648 | int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| 126211 | 126649 | int iContinue; /* Jump here to continue with next record */ |
| 126212 | 126650 | int iBreak; /* Jump here to break out of the loop */ |
| 126213 | 126651 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| | @@ -127363,10 +127801,73 @@ |
| 127363 | 127801 | }else{ |
| 127364 | 127802 | assert( nReg==1 ); |
| 127365 | 127803 | sqlite3ExprCode(pParse, p, iReg); |
| 127366 | 127804 | } |
| 127367 | 127805 | } |
| 127806 | + |
| 127807 | +/* An instance of the IdxExprTrans object carries information about a |
| 127808 | +** mapping from an expression on table columns into a column in an index |
| 127809 | +** down through the Walker. |
| 127810 | +*/ |
| 127811 | +typedef struct IdxExprTrans { |
| 127812 | + Expr *pIdxExpr; /* The index expression */ |
| 127813 | + int iTabCur; /* The cursor of the corresponding table */ |
| 127814 | + int iIdxCur; /* The cursor for the index */ |
| 127815 | + int iIdxCol; /* The column for the index */ |
| 127816 | +} IdxExprTrans; |
| 127817 | + |
| 127818 | +/* The walker node callback used to transform matching expressions into |
| 127819 | +** a reference to an index column for an index on an expression. |
| 127820 | +** |
| 127821 | +** If pExpr matches, then transform it into a reference to the index column |
| 127822 | +** that contains the value of pExpr. |
| 127823 | +*/ |
| 127824 | +static int whereIndexExprTransNode(Walker *p, Expr *pExpr){ |
| 127825 | + IdxExprTrans *pX = p->u.pIdxTrans; |
| 127826 | + if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){ |
| 127827 | + pExpr->op = TK_COLUMN; |
| 127828 | + pExpr->iTable = pX->iIdxCur; |
| 127829 | + pExpr->iColumn = pX->iIdxCol; |
| 127830 | + pExpr->pTab = 0; |
| 127831 | + return WRC_Prune; |
| 127832 | + }else{ |
| 127833 | + return WRC_Continue; |
| 127834 | + } |
| 127835 | +} |
| 127836 | + |
| 127837 | +/* |
| 127838 | +** For an indexes on expression X, locate every instance of expression X in pExpr |
| 127839 | +** and change that subexpression into a reference to the appropriate column of |
| 127840 | +** the index. |
| 127841 | +*/ |
| 127842 | +static void whereIndexExprTrans( |
| 127843 | + Index *pIdx, /* The Index */ |
| 127844 | + int iTabCur, /* Cursor of the table that is being indexed */ |
| 127845 | + int iIdxCur, /* Cursor of the index itself */ |
| 127846 | + WhereInfo *pWInfo /* Transform expressions in this WHERE clause */ |
| 127847 | +){ |
| 127848 | + int iIdxCol; /* Column number of the index */ |
| 127849 | + ExprList *aColExpr; /* Expressions that are indexed */ |
| 127850 | + Walker w; |
| 127851 | + IdxExprTrans x; |
| 127852 | + aColExpr = pIdx->aColExpr; |
| 127853 | + if( aColExpr==0 ) return; /* Not an index on expressions */ |
| 127854 | + memset(&w, 0, sizeof(w)); |
| 127855 | + w.xExprCallback = whereIndexExprTransNode; |
| 127856 | + w.u.pIdxTrans = &x; |
| 127857 | + x.iTabCur = iTabCur; |
| 127858 | + x.iIdxCur = iIdxCur; |
| 127859 | + for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){ |
| 127860 | + if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue; |
| 127861 | + assert( aColExpr->a[iIdxCol].pExpr!=0 ); |
| 127862 | + x.iIdxCol = iIdxCol; |
| 127863 | + x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; |
| 127864 | + sqlite3WalkExpr(&w, pWInfo->pWhere); |
| 127865 | + sqlite3WalkExprList(&w, pWInfo->pOrderBy); |
| 127866 | + sqlite3WalkExprList(&w, pWInfo->pResultSet); |
| 127867 | + } |
| 127868 | +} |
| 127368 | 127869 | |
| 127369 | 127870 | /* |
| 127370 | 127871 | ** Generate code for the start of the iLevel-th loop in the WHERE clause |
| 127371 | 127872 | ** implementation described by pWInfo. |
| 127372 | 127873 | */ |
| | @@ -127391,10 +127892,12 @@ |
| 127391 | 127892 | int addrBrk; /* Jump here to break out of the loop */ |
| 127392 | 127893 | int addrHalt; /* addrBrk for the outermost loop */ |
| 127393 | 127894 | int addrCont; /* Jump here to continue with next cycle */ |
| 127394 | 127895 | int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ |
| 127395 | 127896 | int iReleaseReg = 0; /* Temp register to free before returning */ |
| 127897 | + Index *pIdx = 0; /* Index used by loop (if any) */ |
| 127898 | + int loopAgain; /* True if constraint generator loop should repeat */ |
| 127396 | 127899 | |
| 127397 | 127900 | pParse = pWInfo->pParse; |
| 127398 | 127901 | v = pParse->pVdbe; |
| 127399 | 127902 | pWC = &pWInfo->sWC; |
| 127400 | 127903 | db = pParse->db; |
| | @@ -127716,11 +128219,10 @@ |
| 127716 | 128219 | WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */ |
| 127717 | 128220 | int startEq; /* True if range start uses ==, >= or <= */ |
| 127718 | 128221 | int endEq; /* True if range end uses ==, >= or <= */ |
| 127719 | 128222 | int start_constraints; /* Start of range is constrained */ |
| 127720 | 128223 | int nConstraint; /* Number of constraint terms */ |
| 127721 | | - Index *pIdx; /* The index we will be using */ |
| 127722 | 128224 | int iIdxCur; /* The VDBE cursor for the index */ |
| 127723 | 128225 | int nExtraReg = 0; /* Number of extra registers needed */ |
| 127724 | 128226 | int op; /* Instruction opcode */ |
| 127725 | 128227 | char *zStartAff; /* Affinity for start of range constraint */ |
| 127726 | 128228 | char *zEndAff = 0; /* Affinity for end of range constraint */ |
| | @@ -127944,10 +128446,17 @@ |
| 127944 | 128446 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j); |
| 127945 | 128447 | } |
| 127946 | 128448 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont, |
| 127947 | 128449 | iRowidReg, pPk->nKeyCol); VdbeCoverage(v); |
| 127948 | 128450 | } |
| 128451 | + |
| 128452 | + /* If pIdx is an index on one or more expressions, then look through |
| 128453 | + ** all the expressions in pWInfo and try to transform matching expressions |
| 128454 | + ** into reference to index columns. |
| 128455 | + */ |
| 128456 | + whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo); |
| 128457 | + |
| 127949 | 128458 | |
| 127950 | 128459 | /* Record the instruction used to terminate the loop. */ |
| 127951 | 128460 | if( pLoop->wsFlags & WHERE_ONEROW ){ |
| 127952 | 128461 | pLevel->op = OP_Noop; |
| 127953 | 128462 | }else if( bRev ){ |
| | @@ -127960,10 +128469,11 @@ |
| 127960 | 128469 | if( (pLoop->wsFlags & WHERE_CONSTRAINT)==0 ){ |
| 127961 | 128470 | pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; |
| 127962 | 128471 | }else{ |
| 127963 | 128472 | assert( pLevel->p5==0 ); |
| 127964 | 128473 | } |
| 128474 | + if( omitTable ) pIdx = 0; |
| 127965 | 128475 | }else |
| 127966 | 128476 | |
| 127967 | 128477 | #ifndef SQLITE_OMIT_OR_OPTIMIZATION |
| 127968 | 128478 | if( pLoop->wsFlags & WHERE_MULTI_OR ){ |
| 127969 | 128479 | /* Case 5: Two or more separately indexed terms connected by OR |
| | @@ -128277,47 +128787,60 @@ |
| 128277 | 128787 | pLevel->addrVisit = sqlite3VdbeCurrentAddr(v); |
| 128278 | 128788 | #endif |
| 128279 | 128789 | |
| 128280 | 128790 | /* Insert code to test every subexpression that can be completely |
| 128281 | 128791 | ** computed using the current set of tables. |
| 128792 | + ** |
| 128793 | + ** This loop may run either once (pIdx==0) or twice (pIdx!=0). If |
| 128794 | + ** it is run twice, then the first iteration codes those sub-expressions |
| 128795 | + ** that can be computed using columns from pIdx only (without seeking |
| 128796 | + ** the main table cursor). |
| 128282 | 128797 | */ |
| 128283 | | - for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 128284 | | - Expr *pE; |
| 128285 | | - int skipLikeAddr = 0; |
| 128286 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 128287 | | - testcase( pTerm->wtFlags & TERM_CODED ); |
| 128288 | | - if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 128289 | | - if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 128290 | | - testcase( pWInfo->untestedTerms==0 |
| 128291 | | - && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ); |
| 128292 | | - pWInfo->untestedTerms = 1; |
| 128293 | | - continue; |
| 128294 | | - } |
| 128295 | | - pE = pTerm->pExpr; |
| 128296 | | - assert( pE!=0 ); |
| 128297 | | - if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){ |
| 128298 | | - continue; |
| 128299 | | - } |
| 128300 | | - if( pTerm->wtFlags & TERM_LIKECOND ){ |
| 128301 | | - /* If the TERM_LIKECOND flag is set, that means that the range search |
| 128302 | | - ** is sufficient to guarantee that the LIKE operator is true, so we |
| 128303 | | - ** can skip the call to the like(A,B) function. But this only works |
| 128304 | | - ** for strings. So do not skip the call to the function on the pass |
| 128305 | | - ** that compares BLOBs. */ |
| 128798 | + do{ |
| 128799 | + loopAgain = 0; |
| 128800 | + for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 128801 | + Expr *pE; |
| 128802 | + int skipLikeAddr = 0; |
| 128803 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 128804 | + testcase( pTerm->wtFlags & TERM_CODED ); |
| 128805 | + if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 128806 | + if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 128807 | + testcase( pWInfo->untestedTerms==0 |
| 128808 | + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ); |
| 128809 | + pWInfo->untestedTerms = 1; |
| 128810 | + continue; |
| 128811 | + } |
| 128812 | + pE = pTerm->pExpr; |
| 128813 | + assert( pE!=0 ); |
| 128814 | + if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){ |
| 128815 | + continue; |
| 128816 | + } |
| 128817 | + if( pIdx && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){ |
| 128818 | + loopAgain = 1; |
| 128819 | + continue; |
| 128820 | + } |
| 128821 | + if( pTerm->wtFlags & TERM_LIKECOND ){ |
| 128822 | + /* If the TERM_LIKECOND flag is set, that means that the range search |
| 128823 | + ** is sufficient to guarantee that the LIKE operator is true, so we |
| 128824 | + ** can skip the call to the like(A,B) function. But this only works |
| 128825 | + ** for strings. So do not skip the call to the function on the pass |
| 128826 | + ** that compares BLOBs. */ |
| 128306 | 128827 | #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS |
| 128307 | | - continue; |
| 128828 | + continue; |
| 128308 | 128829 | #else |
| 128309 | | - u32 x = pLevel->iLikeRepCntr; |
| 128310 | | - assert( x>0 ); |
| 128311 | | - skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)? OP_IfNot : OP_If, (int)(x>>1)); |
| 128312 | | - VdbeCoverage(v); |
| 128830 | + u32 x = pLevel->iLikeRepCntr; |
| 128831 | + assert( x>0 ); |
| 128832 | + skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1)); |
| 128833 | + VdbeCoverage(v); |
| 128313 | 128834 | #endif |
| 128835 | + } |
| 128836 | + sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); |
| 128837 | + if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); |
| 128838 | + pTerm->wtFlags |= TERM_CODED; |
| 128314 | 128839 | } |
| 128315 | | - sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); |
| 128316 | | - if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); |
| 128317 | | - pTerm->wtFlags |= TERM_CODED; |
| 128318 | | - } |
| 128840 | + pIdx = 0; |
| 128841 | + }while( loopAgain ); |
| 128319 | 128842 | |
| 128320 | 128843 | /* Insert code to test for implied constraints based on transitivity |
| 128321 | 128844 | ** of the "==" operator. |
| 128322 | 128845 | ** |
| 128323 | 128846 | ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123" |
| | @@ -129206,31 +129729,50 @@ |
| 129206 | 129729 | |
| 129207 | 129730 | /* |
| 129208 | 129731 | ** Expression pExpr is one operand of a comparison operator that might |
| 129209 | 129732 | ** be useful for indexing. This routine checks to see if pExpr appears |
| 129210 | 129733 | ** in any index. Return TRUE (1) if pExpr is an indexed term and return |
| 129211 | | -** FALSE (0) if not. If TRUE is returned, also set *piCur to the cursor |
| 129212 | | -** number of the table that is indexed and *piColumn to the column number |
| 129734 | +** FALSE (0) if not. If TRUE is returned, also set aiCurCol[0] to the cursor |
| 129735 | +** number of the table that is indexed and aiCurCol[1] to the column number |
| 129213 | 129736 | ** of the column that is indexed, or XN_EXPR (-2) if an expression is being |
| 129214 | 129737 | ** indexed. |
| 129215 | 129738 | ** |
| 129216 | 129739 | ** If pExpr is a TK_COLUMN column reference, then this routine always returns |
| 129217 | 129740 | ** true even if that particular column is not indexed, because the column |
| 129218 | 129741 | ** might be added to an automatic index later. |
| 129219 | 129742 | */ |
| 129220 | | -static int exprMightBeIndexed( |
| 129743 | +static SQLITE_NOINLINE int exprMightBeIndexed2( |
| 129221 | 129744 | SrcList *pFrom, /* The FROM clause */ |
| 129222 | | - int op, /* The specific comparison operator */ |
| 129223 | 129745 | Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */ |
| 129224 | | - Expr *pExpr, /* An operand of a comparison operator */ |
| 129225 | | - int *piCur, /* Write the referenced table cursor number here */ |
| 129226 | | - int *piColumn /* Write the referenced table column number here */ |
| 129746 | + int *aiCurCol, /* Write the referenced table cursor and column here */ |
| 129747 | + Expr *pExpr /* An operand of a comparison operator */ |
| 129227 | 129748 | ){ |
| 129228 | 129749 | Index *pIdx; |
| 129229 | 129750 | int i; |
| 129230 | 129751 | int iCur; |
| 129231 | | - |
| 129752 | + for(i=0; mPrereq>1; i++, mPrereq>>=1){} |
| 129753 | + iCur = pFrom->a[i].iCursor; |
| 129754 | + for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 129755 | + if( pIdx->aColExpr==0 ) continue; |
| 129756 | + for(i=0; i<pIdx->nKeyCol; i++){ |
| 129757 | + if( pIdx->aiColumn[i]!=XN_EXPR ) continue; |
| 129758 | + if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 129759 | + aiCurCol[0] = iCur; |
| 129760 | + aiCurCol[1] = XN_EXPR; |
| 129761 | + return 1; |
| 129762 | + } |
| 129763 | + } |
| 129764 | + } |
| 129765 | + return 0; |
| 129766 | +} |
| 129767 | +static int exprMightBeIndexed( |
| 129768 | + SrcList *pFrom, /* The FROM clause */ |
| 129769 | + Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */ |
| 129770 | + int *aiCurCol, /* Write the referenced table cursor & column here */ |
| 129771 | + Expr *pExpr, /* An operand of a comparison operator */ |
| 129772 | + int op /* The specific comparison operator */ |
| 129773 | +){ |
| 129232 | 129774 | /* If this expression is a vector to the left or right of a |
| 129233 | 129775 | ** inequality constraint (>, <, >= or <=), perform the processing |
| 129234 | 129776 | ** on the first element of the vector. */ |
| 129235 | 129777 | assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE ); |
| 129236 | 129778 | assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE ); |
| | @@ -129238,30 +129780,17 @@ |
| 129238 | 129780 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ |
| 129239 | 129781 | pExpr = pExpr->x.pList->a[0].pExpr; |
| 129240 | 129782 | } |
| 129241 | 129783 | |
| 129242 | 129784 | if( pExpr->op==TK_COLUMN ){ |
| 129243 | | - *piCur = pExpr->iTable; |
| 129244 | | - *piColumn = pExpr->iColumn; |
| 129785 | + aiCurCol[0] = pExpr->iTable; |
| 129786 | + aiCurCol[1] = pExpr->iColumn; |
| 129245 | 129787 | return 1; |
| 129246 | 129788 | } |
| 129247 | 129789 | if( mPrereq==0 ) return 0; /* No table references */ |
| 129248 | 129790 | if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */ |
| 129249 | | - for(i=0; mPrereq>1; i++, mPrereq>>=1){} |
| 129250 | | - iCur = pFrom->a[i].iCursor; |
| 129251 | | - for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 129252 | | - if( pIdx->aColExpr==0 ) continue; |
| 129253 | | - for(i=0; i<pIdx->nKeyCol; i++){ |
| 129254 | | - if( pIdx->aiColumn[i]!=XN_EXPR ) continue; |
| 129255 | | - if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 129256 | | - *piCur = iCur; |
| 129257 | | - *piColumn = XN_EXPR; |
| 129258 | | - return 1; |
| 129259 | | - } |
| 129260 | | - } |
| 129261 | | - } |
| 129262 | | - return 0; |
| 129791 | + return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr); |
| 129263 | 129792 | } |
| 129264 | 129793 | |
| 129265 | 129794 | /* |
| 129266 | 129795 | ** The input to this routine is an WhereTerm structure with only the |
| 129267 | 129796 | ** "pExpr" field filled in. The job of this routine is to analyze the |
| | @@ -129337,11 +129866,11 @@ |
| 129337 | 129866 | pTerm->prereqAll = prereqAll; |
| 129338 | 129867 | pTerm->leftCursor = -1; |
| 129339 | 129868 | pTerm->iParent = -1; |
| 129340 | 129869 | pTerm->eOperator = 0; |
| 129341 | 129870 | if( allowedOp(op) ){ |
| 129342 | | - int iCur, iColumn; |
| 129871 | + int aiCurCol[2]; |
| 129343 | 129872 | Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft); |
| 129344 | 129873 | Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight); |
| 129345 | 129874 | u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV; |
| 129346 | 129875 | |
| 129347 | 129876 | if( pTerm->iField>0 ){ |
| | @@ -129348,18 +129877,18 @@ |
| 129348 | 129877 | assert( op==TK_IN ); |
| 129349 | 129878 | assert( pLeft->op==TK_VECTOR ); |
| 129350 | 129879 | pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr; |
| 129351 | 129880 | } |
| 129352 | 129881 | |
| 129353 | | - if( exprMightBeIndexed(pSrc, op, prereqLeft, pLeft, &iCur, &iColumn) ){ |
| 129354 | | - pTerm->leftCursor = iCur; |
| 129355 | | - pTerm->u.leftColumn = iColumn; |
| 129882 | + if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){ |
| 129883 | + pTerm->leftCursor = aiCurCol[0]; |
| 129884 | + pTerm->u.leftColumn = aiCurCol[1]; |
| 129356 | 129885 | pTerm->eOperator = operatorMask(op) & opMask; |
| 129357 | 129886 | } |
| 129358 | 129887 | if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; |
| 129359 | 129888 | if( pRight |
| 129360 | | - && exprMightBeIndexed(pSrc, op, pTerm->prereqRight, pRight, &iCur,&iColumn) |
| 129889 | + && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op) |
| 129361 | 129890 | ){ |
| 129362 | 129891 | WhereTerm *pNew; |
| 129363 | 129892 | Expr *pDup; |
| 129364 | 129893 | u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */ |
| 129365 | 129894 | assert( pTerm->iField==0 ); |
| | @@ -129385,12 +129914,12 @@ |
| 129385 | 129914 | }else{ |
| 129386 | 129915 | pDup = pExpr; |
| 129387 | 129916 | pNew = pTerm; |
| 129388 | 129917 | } |
| 129389 | 129918 | exprCommute(pParse, pDup); |
| 129390 | | - pNew->leftCursor = iCur; |
| 129391 | | - pNew->u.leftColumn = iColumn; |
| 129919 | + pNew->leftCursor = aiCurCol[0]; |
| 129920 | + pNew->u.leftColumn = aiCurCol[1]; |
| 129392 | 129921 | testcase( (prereqLeft | extraRight) != prereqLeft ); |
| 129393 | 129922 | pNew->prereqRight = prereqLeft | extraRight; |
| 129394 | 129923 | pNew->prereqAll = prereqAll; |
| 129395 | 129924 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; |
| 129396 | 129925 | } |
| | @@ -131618,21 +132147,21 @@ |
| 131618 | 132147 | sqlite3_free(p->u.vtab.idxStr); |
| 131619 | 132148 | p->u.vtab.needFree = 0; |
| 131620 | 132149 | p->u.vtab.idxStr = 0; |
| 131621 | 132150 | }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){ |
| 131622 | 132151 | sqlite3DbFree(db, p->u.btree.pIndex->zColAff); |
| 131623 | | - sqlite3DbFree(db, p->u.btree.pIndex); |
| 132152 | + sqlite3DbFreeNN(db, p->u.btree.pIndex); |
| 131624 | 132153 | p->u.btree.pIndex = 0; |
| 131625 | 132154 | } |
| 131626 | 132155 | } |
| 131627 | 132156 | } |
| 131628 | 132157 | |
| 131629 | 132158 | /* |
| 131630 | 132159 | ** Deallocate internal memory used by a WhereLoop object |
| 131631 | 132160 | */ |
| 131632 | 132161 | static void whereLoopClear(sqlite3 *db, WhereLoop *p){ |
| 131633 | | - if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFree(db, p->aLTerm); |
| 132162 | + if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm); |
| 131634 | 132163 | whereLoopClearUnion(db, p); |
| 131635 | 132164 | whereLoopInit(p); |
| 131636 | 132165 | } |
| 131637 | 132166 | |
| 131638 | 132167 | /* |
| | @@ -131643,11 +132172,11 @@ |
| 131643 | 132172 | if( p->nLSlot>=n ) return SQLITE_OK; |
| 131644 | 132173 | n = (n+7)&~7; |
| 131645 | 132174 | paNew = sqlite3DbMallocRawNN(db, sizeof(p->aLTerm[0])*n); |
| 131646 | 132175 | if( paNew==0 ) return SQLITE_NOMEM_BKPT; |
| 131647 | 132176 | memcpy(paNew, p->aLTerm, sizeof(p->aLTerm[0])*p->nLSlot); |
| 131648 | | - if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFree(db, p->aLTerm); |
| 132177 | + if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm); |
| 131649 | 132178 | p->aLTerm = paNew; |
| 131650 | 132179 | p->nLSlot = n; |
| 131651 | 132180 | return SQLITE_OK; |
| 131652 | 132181 | } |
| 131653 | 132182 | |
| | @@ -131673,11 +132202,11 @@ |
| 131673 | 132202 | /* |
| 131674 | 132203 | ** Delete a WhereLoop object |
| 131675 | 132204 | */ |
| 131676 | 132205 | static void whereLoopDelete(sqlite3 *db, WhereLoop *p){ |
| 131677 | 132206 | whereLoopClear(db, p); |
| 131678 | | - sqlite3DbFree(db, p); |
| 132207 | + sqlite3DbFreeNN(db, p); |
| 131679 | 132208 | } |
| 131680 | 132209 | |
| 131681 | 132210 | /* |
| 131682 | 132211 | ** Free a WhereInfo structure |
| 131683 | 132212 | */ |
| | @@ -131694,11 +132223,11 @@ |
| 131694 | 132223 | while( pWInfo->pLoops ){ |
| 131695 | 132224 | WhereLoop *p = pWInfo->pLoops; |
| 131696 | 132225 | pWInfo->pLoops = p->pNextLoop; |
| 131697 | 132226 | whereLoopDelete(db, p); |
| 131698 | 132227 | } |
| 131699 | | - sqlite3DbFree(db, pWInfo); |
| 132228 | + sqlite3DbFreeNN(db, pWInfo); |
| 131700 | 132229 | } |
| 131701 | 132230 | } |
| 131702 | 132231 | |
| 131703 | 132232 | /* |
| 131704 | 132233 | ** Return TRUE if all of the following are true: |
| | @@ -133085,11 +133614,11 @@ |
| 133085 | 133614 | pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn); |
| 133086 | 133615 | } |
| 133087 | 133616 | } |
| 133088 | 133617 | |
| 133089 | 133618 | if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); |
| 133090 | | - sqlite3DbFree(pParse->db, p); |
| 133619 | + sqlite3DbFreeNN(pParse->db, p); |
| 133091 | 133620 | return rc; |
| 133092 | 133621 | } |
| 133093 | 133622 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 133094 | 133623 | |
| 133095 | 133624 | /* |
| | @@ -133269,11 +133798,11 @@ |
| 133269 | 133798 | whereLoopClear(db, pNew); |
| 133270 | 133799 | return rc; |
| 133271 | 133800 | } |
| 133272 | 133801 | |
| 133273 | 133802 | /* |
| 133274 | | -** Examine a WherePath (with the addition of the extra WhereLoop of the 5th |
| 133803 | +** Examine a WherePath (with the addition of the extra WhereLoop of the 6th |
| 133275 | 133804 | ** parameters) to see if it outputs rows in the requested ORDER BY |
| 133276 | 133805 | ** (or GROUP BY) without requiring a separate sort operation. Return N: |
| 133277 | 133806 | ** |
| 133278 | 133807 | ** N>0: N terms of the ORDER BY clause are satisfied |
| 133279 | 133808 | ** N==0: No terms of the ORDER BY clause are satisfied |
| | @@ -133364,10 +133893,12 @@ |
| 133364 | 133893 | pLoop = pLast; |
| 133365 | 133894 | } |
| 133366 | 133895 | if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){ |
| 133367 | 133896 | if( pLoop->u.vtab.isOrdered ) obSat = obDone; |
| 133368 | 133897 | break; |
| 133898 | + }else{ |
| 133899 | + pLoop->u.btree.nIdxCol = 0; |
| 133369 | 133900 | } |
| 133370 | 133901 | iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor; |
| 133371 | 133902 | |
| 133372 | 133903 | /* Mark off any ORDER BY term X that is a column in the table of |
| 133373 | 133904 | ** the current loop for which there is term in the WHERE |
| | @@ -133509,10 +134040,11 @@ |
| 133509 | 134040 | if( iColumn>=0 ){ |
| 133510 | 134041 | pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr); |
| 133511 | 134042 | if( !pColl ) pColl = db->pDfltColl; |
| 133512 | 134043 | if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue; |
| 133513 | 134044 | } |
| 134045 | + pLoop->u.btree.nIdxCol = j+1; |
| 133514 | 134046 | isMatch = 1; |
| 133515 | 134047 | break; |
| 133516 | 134048 | } |
| 133517 | 134049 | if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){ |
| 133518 | 134050 | /* Make sure the sort order is compatible in an ORDER BY clause. |
| | @@ -133940,11 +134472,11 @@ |
| 133940 | 134472 | nFrom = nTo; |
| 133941 | 134473 | } |
| 133942 | 134474 | |
| 133943 | 134475 | if( nFrom==0 ){ |
| 133944 | 134476 | sqlite3ErrorMsg(pParse, "no query solution"); |
| 133945 | | - sqlite3DbFree(db, pSpace); |
| 134477 | + sqlite3DbFreeNN(db, pSpace); |
| 133946 | 134478 | return SQLITE_ERROR; |
| 133947 | 134479 | } |
| 133948 | 134480 | |
| 133949 | 134481 | /* Find the lowest cost path. pFrom will be left pointing to that path */ |
| 133950 | 134482 | pFrom = aFrom; |
| | @@ -134016,11 +134548,11 @@ |
| 134016 | 134548 | |
| 134017 | 134549 | |
| 134018 | 134550 | pWInfo->nRowOut = pFrom->nRow; |
| 134019 | 134551 | |
| 134020 | 134552 | /* Free temporary memory and return success */ |
| 134021 | | - sqlite3DbFree(db, pSpace); |
| 134553 | + sqlite3DbFreeNN(db, pSpace); |
| 134022 | 134554 | return SQLITE_OK; |
| 134023 | 134555 | } |
| 134024 | 134556 | |
| 134025 | 134557 | /* |
| 134026 | 134558 | ** Most queries use only a single table (they are not joins) and have |
| | @@ -134094,11 +134626,12 @@ |
| 134094 | 134626 | } |
| 134095 | 134627 | } |
| 134096 | 134628 | if( pLoop->wsFlags ){ |
| 134097 | 134629 | pLoop->nOut = (LogEst)1; |
| 134098 | 134630 | pWInfo->a[0].pWLoop = pLoop; |
| 134099 | | - pLoop->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); |
| 134631 | + assert( pWInfo->sMaskSet.n==1 && iCur==pWInfo->sMaskSet.ix[0] ); |
| 134632 | + pLoop->maskSelf = 1; /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */ |
| 134100 | 134633 | pWInfo->a[0].iTabCur = iCur; |
| 134101 | 134634 | pWInfo->nRowOut = 1; |
| 134102 | 134635 | if( pWInfo->pOrderBy ) pWInfo->nOBSat = pWInfo->pOrderBy->nExpr; |
| 134103 | 134636 | if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ |
| 134104 | 134637 | pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE; |
| | @@ -134278,10 +134811,11 @@ |
| 134278 | 134811 | goto whereBeginError; |
| 134279 | 134812 | } |
| 134280 | 134813 | pWInfo->pParse = pParse; |
| 134281 | 134814 | pWInfo->pTabList = pTabList; |
| 134282 | 134815 | pWInfo->pOrderBy = pOrderBy; |
| 134816 | + pWInfo->pWhere = pWhere; |
| 134283 | 134817 | pWInfo->pResultSet = pResultSet; |
| 134284 | 134818 | pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; |
| 134285 | 134819 | pWInfo->nLevel = nTabList; |
| 134286 | 134820 | pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); |
| 134287 | 134821 | pWInfo->wctrlFlags = wctrlFlags; |
| | @@ -134588,10 +135122,11 @@ |
| 134588 | 135122 | sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb); |
| 134589 | 135123 | sqlite3VdbeSetP4KeyInfo(pParse, pIx); |
| 134590 | 135124 | if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0 |
| 134591 | 135125 | && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0 |
| 134592 | 135126 | && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 |
| 135127 | + && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED |
| 134593 | 135128 | ){ |
| 134594 | 135129 | sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */ |
| 134595 | 135130 | } |
| 134596 | 135131 | VdbeComment((v, "%s", pIx->zName)); |
| 134597 | 135132 | #ifdef SQLITE_ENABLE_COLUMN_USED_MASK |
| | @@ -134676,18 +135211,47 @@ |
| 134676 | 135211 | sqlite3ExprCacheClear(pParse); |
| 134677 | 135212 | for(i=pWInfo->nLevel-1; i>=0; i--){ |
| 134678 | 135213 | int addr; |
| 134679 | 135214 | pLevel = &pWInfo->a[i]; |
| 134680 | 135215 | pLoop = pLevel->pWLoop; |
| 134681 | | - sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 134682 | 135216 | if( pLevel->op!=OP_Noop ){ |
| 135217 | +#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 135218 | + int addrSeek = 0; |
| 135219 | + Index *pIdx; |
| 135220 | + int n; |
| 135221 | + if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED |
| 135222 | + && (pLoop->wsFlags & WHERE_INDEXED)!=0 |
| 135223 | + && (pIdx = pLoop->u.btree.pIndex)->hasStat1 |
| 135224 | + && (n = pLoop->u.btree.nIdxCol)>0 |
| 135225 | + && pIdx->aiRowLogEst[n]>=36 |
| 135226 | + ){ |
| 135227 | + int r1 = pParse->nMem+1; |
| 135228 | + int j, op; |
| 135229 | + for(j=0; j<n; j++){ |
| 135230 | + sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j); |
| 135231 | + } |
| 135232 | + pParse->nMem += n+1; |
| 135233 | + op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT; |
| 135234 | + addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n); |
| 135235 | + VdbeCoverageIf(v, op==OP_SeekLT); |
| 135236 | + VdbeCoverageIf(v, op==OP_SeekGT); |
| 135237 | + sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2); |
| 135238 | + } |
| 135239 | +#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */ |
| 135240 | + /* The common case: Advance to the next row */ |
| 135241 | + sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 134683 | 135242 | sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3); |
| 134684 | 135243 | sqlite3VdbeChangeP5(v, pLevel->p5); |
| 134685 | 135244 | VdbeCoverage(v); |
| 134686 | 135245 | VdbeCoverageIf(v, pLevel->op==OP_Next); |
| 134687 | 135246 | VdbeCoverageIf(v, pLevel->op==OP_Prev); |
| 134688 | 135247 | VdbeCoverageIf(v, pLevel->op==OP_VNext); |
| 135248 | +#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 135249 | + if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek); |
| 135250 | +#endif |
| 135251 | + }else{ |
| 135252 | + sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 134689 | 135253 | } |
| 134690 | 135254 | if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){ |
| 134691 | 135255 | struct InLoop *pIn; |
| 134692 | 135256 | int j; |
| 134693 | 135257 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); |
| | @@ -134806,10 +135370,12 @@ |
| 134806 | 135370 | assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 |
| 134807 | 135371 | || pWInfo->eOnePass ); |
| 134808 | 135372 | }else if( pOp->opcode==OP_Rowid ){ |
| 134809 | 135373 | pOp->p1 = pLevel->iIdxCur; |
| 134810 | 135374 | pOp->opcode = OP_IdxRowid; |
| 135375 | + }else if( pOp->opcode==OP_IfNullRow ){ |
| 135376 | + pOp->p1 = pLevel->iIdxCur; |
| 134811 | 135377 | } |
| 134812 | 135378 | } |
| 134813 | 135379 | } |
| 134814 | 135380 | } |
| 134815 | 135381 | |
| | @@ -135115,11 +135681,11 @@ |
| 135115 | 135681 | #endif |
| 135116 | 135682 | /************* Begin control #defines *****************************************/ |
| 135117 | 135683 | #define YYCODETYPE unsigned char |
| 135118 | 135684 | #define YYNOCODE 252 |
| 135119 | 135685 | #define YYACTIONTYPE unsigned short int |
| 135120 | | -#define YYWILDCARD 96 |
| 135686 | +#define YYWILDCARD 69 |
| 135121 | 135687 | #define sqlite3ParserTOKENTYPE Token |
| 135122 | 135688 | typedef union { |
| 135123 | 135689 | int yyinit; |
| 135124 | 135690 | sqlite3ParserTOKENTYPE yy0; |
| 135125 | 135691 | Expr* yy72; |
| | @@ -135222,419 +135788,419 @@ |
| 135222 | 135788 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 135223 | 135789 | ** shifting non-terminals after a reduce. |
| 135224 | 135790 | ** yy_default[] Default action for each state. |
| 135225 | 135791 | ** |
| 135226 | 135792 | *********** Begin parsing tables **********************************************/ |
| 135227 | | -#define YY_ACTTAB_COUNT (1567) |
| 135793 | +#define YY_ACTTAB_COUNT (1566) |
| 135228 | 135794 | static const YYACTIONTYPE yy_action[] = { |
| 135229 | | - /* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100, |
| 135230 | | - /* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, |
| 135231 | | - /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95, |
| 135232 | | - /* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824, |
| 135233 | | - /* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856, |
| 135234 | | - /* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96, |
| 135235 | | - /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135236 | | - /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976, |
| 135237 | | - /* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100, |
| 135238 | | - /* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, |
| 135239 | | - /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95, |
| 135240 | | - /* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325, |
| 135241 | | - /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90, |
| 135242 | | - /* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135243 | | - /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94, |
| 135244 | | - /* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413, |
| 135245 | | - /* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853, |
| 135246 | | - /* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60, |
| 135247 | | - /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135248 | | - /* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99, |
| 135249 | | - /* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135250 | | - /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95, |
| 135251 | | - /* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698, |
| 135252 | | - /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853, |
| 135253 | | - /* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347, |
| 135254 | | - /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135255 | | - /* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99, |
| 135256 | | - /* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135257 | | - /* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95, |
| 135258 | | - /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178, |
| 135259 | | - /* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853, |
| 135260 | | - /* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375, |
| 135261 | | - /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135262 | | - /* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99, |
| 135263 | | - /* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135264 | | - /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95, |
| 135265 | | - /* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92, |
| 135266 | | - /* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853, |
| 135267 | | - /* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920, |
| 135268 | | - /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135269 | | - /* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99, |
| 135270 | | - /* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135271 | | - /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95, |
| 135272 | | - /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957, |
| 135273 | | - /* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853, |
| 135274 | | - /* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450, |
| 135275 | | - /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135276 | | - /* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52, |
| 135277 | | - /* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978, |
| 135278 | | - /* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, |
| 135279 | | - /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94, |
| 135280 | | - /* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961, |
| 135281 | | - /* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845, |
| 135282 | | - /* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96, |
| 135283 | | - /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842, |
| 135284 | | - /* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978, |
| 135285 | | - /* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, |
| 135286 | | - /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94, |
| 135287 | | - /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340, |
| 135288 | | - /* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845, |
| 135289 | | - /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96, |
| 135290 | | - /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445, |
| 135291 | | - /* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957, |
| 135292 | | - /* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282, |
| 135293 | | - /* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245, |
| 135294 | | - /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83, |
| 135295 | | - /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246, |
| 135296 | | - /* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243, |
| 135297 | | - /* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224, |
| 135298 | | - /* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427, |
| 135299 | | - /* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452, |
| 135300 | | - /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270, |
| 135301 | | - /* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429, |
| 135302 | | - /* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52, |
| 135303 | | - /* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229, |
| 135304 | | - /* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85, |
| 135305 | | - /* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355, |
| 135306 | | - /* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86, |
| 135307 | | - /* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96, |
| 135308 | | - /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135309 | | - /* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976, |
| 135310 | | - /* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789, |
| 135311 | | - /* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261, |
| 135312 | | - /* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826, |
| 135313 | | - /* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95, |
| 135314 | | - /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957, |
| 135315 | | - /* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2, |
| 135316 | | - /* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708, |
| 135317 | | - /* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778, |
| 135318 | | - /* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450, |
| 135319 | | - /* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226, |
| 135320 | | - /* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10, |
| 135321 | | - /* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157, |
| 135322 | | - /* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434, |
| 135323 | | - /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959, |
| 135324 | | - /* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10, |
| 135325 | | - /* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171, |
| 135326 | | - /* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450, |
| 135327 | | - /* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824, |
| 135328 | | - /* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10, |
| 135329 | | - /* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198, |
| 135330 | | - /* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825, |
| 135331 | | - /* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91, |
| 135332 | | - /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135333 | | - /* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268, |
| 135334 | | - /* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450, |
| 135335 | | - /* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433, |
| 135336 | | - /* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12, |
| 135337 | | - /* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162, |
| 135338 | | - /* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450, |
| 135339 | | - /* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40, |
| 135340 | | - /* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28, |
| 135341 | | - /* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450, |
| 135342 | | - /* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767, |
| 135343 | | - /* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47, |
| 135344 | | - /* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172, |
| 135345 | | - /* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122, |
| 135346 | | - /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56, |
| 135347 | | - /* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817, |
| 135348 | | - /* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817, |
| 135349 | | - /* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119, |
| 135350 | | - /* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111, |
| 135351 | | - /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911, |
| 135352 | | - /* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331, |
| 135353 | | - /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197, |
| 135354 | | - /* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436, |
| 135355 | | - /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932, |
| 135356 | | - /* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202, |
| 135357 | | - /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883, |
| 135358 | | - /* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74, |
| 135359 | | - /* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892, |
| 135360 | | - /* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432, |
| 135361 | | - /* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289, |
| 135362 | | - /* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828, |
| 135363 | | - /* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435, |
| 135364 | | - /* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880, |
| 135365 | | - /* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72, |
| 135366 | | - /* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383, |
| 135367 | | - /* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266, |
| 135368 | | - /* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322, |
| 135369 | | - /* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421, |
| 135370 | | - /* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346, |
| 135371 | | - /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239, |
| 135372 | | - /* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213, |
| 135373 | | - /* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677, |
| 135374 | | - /* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166, |
| 135375 | | - /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891, |
| 135376 | | - /* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258, |
| 135377 | | - /* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187, |
| 135378 | | - /* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149, |
| 135379 | | - /* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396, |
| 135380 | | - /* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131, |
| 135381 | | - /* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220, |
| 135382 | | - /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874, |
| 135383 | | - /* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437, |
| 135384 | | - /* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829, |
| 135385 | | - /* 1560 */ 695, 87, 312, 211, 1291, 1290, 309, |
| 135795 | + /* 0 */ 325, 411, 343, 752, 752, 203, 946, 354, 976, 98, |
| 135796 | + /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95, |
| 135797 | + /* 20 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 813, |
| 135798 | + /* 30 */ 978, 978, 98, 98, 98, 98, 20, 96, 96, 96, |
| 135799 | + /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89, |
| 135800 | + /* 50 */ 178, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135801 | + /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95, |
| 135802 | + /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 976, 262, |
| 135803 | + /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 791, |
| 135804 | + /* 90 */ 242, 412, 21, 957, 379, 280, 93, 351, 792, 95, |
| 135805 | + /* 100 */ 95, 94, 94, 94, 93, 351, 978, 978, 96, 96, |
| 135806 | + /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 813, |
| 135807 | + /* 120 */ 329, 242, 412, 913, 832, 913, 132, 99, 100, 90, |
| 135808 | + /* 130 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98, |
| 135809 | + /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94, |
| 135810 | + /* 150 */ 93, 351, 325, 825, 349, 348, 120, 819, 120, 75, |
| 135811 | + /* 160 */ 52, 52, 957, 958, 959, 760, 984, 146, 361, 262, |
| 135812 | + /* 170 */ 370, 261, 957, 982, 961, 983, 92, 89, 178, 371, |
| 135813 | + /* 180 */ 230, 371, 978, 978, 817, 361, 360, 101, 824, 824, |
| 135814 | + /* 190 */ 826, 384, 24, 964, 381, 428, 413, 369, 985, 380, |
| 135815 | + /* 200 */ 985, 708, 325, 99, 100, 90, 853, 856, 845, 845, |
| 135816 | + /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96, |
| 135817 | + /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 957, 132, |
| 135818 | + /* 230 */ 897, 450, 978, 978, 896, 60, 94, 94, 94, 93, |
| 135819 | + /* 240 */ 351, 957, 958, 959, 961, 103, 361, 957, 385, 334, |
| 135820 | + /* 250 */ 702, 52, 52, 99, 100, 90, 853, 856, 845, 845, |
| 135821 | + /* 260 */ 97, 97, 98, 98, 98, 98, 698, 96, 96, 96, |
| 135822 | + /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455, |
| 135823 | + /* 280 */ 670, 450, 227, 61, 157, 243, 344, 114, 701, 888, |
| 135824 | + /* 290 */ 147, 832, 957, 373, 747, 957, 320, 957, 958, 959, |
| 135825 | + /* 300 */ 194, 10, 10, 402, 399, 398, 888, 890, 978, 978, |
| 135826 | + /* 310 */ 762, 171, 170, 157, 397, 337, 957, 958, 959, 702, |
| 135827 | + /* 320 */ 825, 310, 153, 957, 819, 321, 82, 23, 80, 99, |
| 135828 | + /* 330 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135829 | + /* 340 */ 98, 98, 894, 96, 96, 96, 96, 95, 95, 94, |
| 135830 | + /* 350 */ 94, 94, 93, 351, 325, 824, 824, 826, 277, 231, |
| 135831 | + /* 360 */ 300, 957, 958, 959, 957, 958, 959, 888, 194, 25, |
| 135832 | + /* 370 */ 450, 402, 399, 398, 957, 355, 300, 450, 957, 74, |
| 135833 | + /* 380 */ 450, 1, 397, 132, 978, 978, 957, 224, 224, 813, |
| 135834 | + /* 390 */ 10, 10, 957, 958, 959, 968, 132, 52, 52, 415, |
| 135835 | + /* 400 */ 52, 52, 739, 739, 339, 99, 100, 90, 853, 856, |
| 135836 | + /* 410 */ 845, 845, 97, 97, 98, 98, 98, 98, 790, 96, |
| 135837 | + /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135838 | + /* 430 */ 325, 789, 428, 418, 706, 428, 427, 1270, 1270, 262, |
| 135839 | + /* 440 */ 370, 261, 957, 957, 958, 959, 757, 957, 958, 959, |
| 135840 | + /* 450 */ 450, 756, 450, 734, 713, 957, 958, 959, 443, 711, |
| 135841 | + /* 460 */ 978, 978, 734, 394, 92, 89, 178, 447, 447, 447, |
| 135842 | + /* 470 */ 51, 51, 52, 52, 439, 778, 700, 92, 89, 178, |
| 135843 | + /* 480 */ 172, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135844 | + /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95, |
| 135845 | + /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 916, |
| 135846 | + /* 510 */ 699, 957, 958, 959, 92, 89, 178, 224, 224, 157, |
| 135847 | + /* 520 */ 241, 221, 419, 299, 776, 917, 416, 375, 450, 415, |
| 135848 | + /* 530 */ 58, 324, 737, 737, 920, 379, 978, 978, 379, 777, |
| 135849 | + /* 540 */ 449, 918, 363, 740, 296, 686, 9, 9, 52, 52, |
| 135850 | + /* 550 */ 234, 330, 234, 256, 417, 741, 280, 99, 100, 90, |
| 135851 | + /* 560 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98, |
| 135852 | + /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94, |
| 135853 | + /* 580 */ 93, 351, 325, 423, 72, 450, 833, 120, 368, 450, |
| 135854 | + /* 590 */ 10, 10, 5, 301, 203, 450, 177, 976, 253, 420, |
| 135855 | + /* 600 */ 255, 776, 200, 175, 233, 10, 10, 842, 842, 36, |
| 135856 | + /* 610 */ 36, 1299, 978, 978, 729, 37, 37, 349, 348, 425, |
| 135857 | + /* 620 */ 203, 260, 776, 976, 232, 937, 1326, 876, 338, 1326, |
| 135858 | + /* 630 */ 422, 854, 857, 99, 100, 90, 853, 856, 845, 845, |
| 135859 | + /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96, |
| 135860 | + /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 846, |
| 135861 | + /* 660 */ 450, 985, 818, 985, 1209, 450, 916, 976, 720, 350, |
| 135862 | + /* 670 */ 350, 350, 935, 177, 450, 937, 1327, 254, 198, 1327, |
| 135863 | + /* 680 */ 12, 12, 917, 403, 450, 27, 27, 250, 978, 978, |
| 135864 | + /* 690 */ 118, 721, 162, 976, 38, 38, 268, 176, 918, 776, |
| 135865 | + /* 700 */ 433, 1275, 946, 354, 39, 39, 317, 998, 325, 99, |
| 135866 | + /* 710 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135867 | + /* 720 */ 98, 98, 935, 96, 96, 96, 96, 95, 95, 94, |
| 135868 | + /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 978, 978, |
| 135869 | + /* 740 */ 717, 317, 936, 341, 900, 900, 387, 673, 674, 675, |
| 135870 | + /* 750 */ 275, 996, 318, 999, 40, 40, 41, 41, 268, 99, |
| 135871 | + /* 760 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135872 | + /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94, |
| 135873 | + /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 999, 450, |
| 135874 | + /* 790 */ 692, 331, 42, 42, 791, 270, 450, 273, 450, 228, |
| 135875 | + /* 800 */ 450, 298, 450, 792, 450, 28, 28, 29, 29, 31, |
| 135876 | + /* 810 */ 31, 450, 817, 450, 978, 978, 43, 43, 44, 44, |
| 135877 | + /* 820 */ 45, 45, 11, 11, 46, 46, 893, 78, 893, 268, |
| 135878 | + /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 853, 856, |
| 135879 | + /* 840 */ 845, 845, 97, 97, 98, 98, 98, 98, 450, 96, |
| 135880 | + /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135881 | + /* 860 */ 325, 450, 117, 450, 749, 158, 450, 696, 48, 48, |
| 135882 | + /* 870 */ 229, 919, 450, 928, 450, 415, 450, 335, 450, 245, |
| 135883 | + /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 817, |
| 135884 | + /* 890 */ 978, 978, 34, 34, 122, 122, 123, 123, 124, 124, |
| 135885 | + /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195, |
| 135886 | + /* 910 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135887 | + /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95, |
| 135888 | + /* 930 */ 95, 94, 94, 94, 93, 351, 450, 696, 450, 817, |
| 135889 | + /* 940 */ 978, 978, 975, 884, 106, 106, 268, 886, 268, 944, |
| 135890 | + /* 950 */ 2, 892, 268, 892, 336, 716, 53, 53, 107, 107, |
| 135891 | + /* 960 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135892 | + /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95, |
| 135893 | + /* 980 */ 95, 94, 94, 94, 93, 351, 450, 746, 450, 742, |
| 135894 | + /* 990 */ 978, 978, 715, 267, 108, 108, 446, 331, 332, 133, |
| 135895 | + /* 1000 */ 223, 175, 301, 225, 386, 933, 104, 104, 121, 121, |
| 135896 | + /* 1010 */ 325, 99, 88, 90, 853, 856, 845, 845, 97, 97, |
| 135897 | + /* 1020 */ 98, 98, 98, 98, 817, 96, 96, 96, 96, 95, |
| 135898 | + /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167, |
| 135899 | + /* 1040 */ 978, 978, 932, 815, 372, 319, 202, 202, 374, 263, |
| 135900 | + /* 1050 */ 395, 202, 74, 208, 726, 727, 119, 119, 112, 112, |
| 135901 | + /* 1060 */ 325, 407, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135902 | + /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95, |
| 135903 | + /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 757, 450, 345, |
| 135904 | + /* 1090 */ 978, 978, 756, 278, 111, 111, 74, 719, 718, 709, |
| 135905 | + /* 1100 */ 286, 883, 754, 1289, 257, 77, 109, 109, 110, 110, |
| 135906 | + /* 1110 */ 908, 285, 810, 90, 853, 856, 845, 845, 97, 97, |
| 135907 | + /* 1120 */ 98, 98, 98, 98, 911, 96, 96, 96, 96, 95, |
| 135908 | + /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3, |
| 135909 | + /* 1140 */ 1202, 450, 745, 132, 352, 120, 689, 86, 445, 785, |
| 135910 | + /* 1150 */ 3, 767, 202, 377, 448, 352, 907, 120, 55, 55, |
| 135911 | + /* 1160 */ 450, 57, 57, 828, 879, 448, 450, 208, 450, 709, |
| 135912 | + /* 1170 */ 450, 883, 237, 434, 436, 120, 440, 429, 362, 120, |
| 135913 | + /* 1180 */ 54, 54, 132, 450, 434, 832, 52, 52, 26, 26, |
| 135914 | + /* 1190 */ 30, 30, 382, 132, 409, 444, 832, 694, 264, 390, |
| 135915 | + /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120, |
| 135916 | + /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 819, 730, |
| 135917 | + /* 1220 */ 714, 428, 430, 85, 352, 452, 451, 120, 120, 819, |
| 135918 | + /* 1230 */ 378, 218, 281, 828, 783, 816, 86, 445, 410, 3, |
| 135919 | + /* 1240 */ 763, 774, 431, 432, 352, 302, 303, 823, 697, 824, |
| 135920 | + /* 1250 */ 824, 826, 827, 19, 448, 691, 680, 679, 681, 951, |
| 135921 | + /* 1260 */ 824, 824, 826, 827, 19, 289, 159, 291, 293, 7, |
| 135922 | + /* 1270 */ 316, 173, 259, 434, 805, 364, 252, 910, 376, 713, |
| 135923 | + /* 1280 */ 295, 435, 168, 993, 400, 832, 284, 881, 880, 205, |
| 135924 | + /* 1290 */ 954, 308, 927, 86, 445, 990, 3, 925, 333, 144, |
| 135925 | + /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 761, 137, 366, |
| 135926 | + /* 1310 */ 802, 448, 85, 352, 452, 451, 139, 226, 819, 140, |
| 135927 | + /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 683, |
| 135928 | + /* 1330 */ 434, 185, 141, 912, 142, 160, 148, 812, 875, 383, |
| 135929 | + /* 1340 */ 189, 67, 832, 180, 389, 248, 895, 775, 219, 824, |
| 135930 | + /* 1350 */ 824, 826, 827, 19, 247, 190, 266, 154, 391, 271, |
| 135931 | + /* 1360 */ 191, 192, 83, 84, 682, 406, 733, 182, 322, 85, |
| 135932 | + /* 1370 */ 352, 452, 451, 732, 183, 819, 342, 132, 181, 711, |
| 135933 | + /* 1380 */ 731, 421, 76, 445, 705, 3, 323, 704, 283, 724, |
| 135934 | + /* 1390 */ 352, 771, 703, 966, 723, 71, 204, 6, 288, 290, |
| 135935 | + /* 1400 */ 448, 772, 770, 769, 79, 292, 824, 824, 826, 827, |
| 135936 | + /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 861, 753, 434, |
| 135937 | + /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306, |
| 135938 | + /* 1430 */ 307, 832, 213, 688, 22, 952, 453, 214, 216, 217, |
| 135939 | + /* 1440 */ 454, 677, 115, 676, 671, 125, 126, 235, 127, 669, |
| 135940 | + /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352, |
| 135941 | + /* 1460 */ 452, 451, 134, 179, 819, 357, 113, 891, 811, 889, |
| 135942 | + /* 1470 */ 136, 128, 138, 743, 258, 184, 906, 143, 145, 63, |
| 135943 | + /* 1480 */ 64, 65, 66, 129, 909, 905, 187, 186, 8, 13, |
| 135944 | + /* 1490 */ 188, 265, 898, 149, 202, 824, 824, 826, 827, 19, |
| 135945 | + /* 1500 */ 388, 987, 150, 161, 285, 685, 392, 396, 151, 722, |
| 135946 | + /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 831, 830, |
| 135947 | + /* 1520 */ 131, 859, 751, 70, 16, 414, 755, 4, 784, 220, |
| 135948 | + /* 1530 */ 222, 174, 152, 437, 779, 201, 17, 77, 74, 18, |
| 135949 | + /* 1540 */ 874, 860, 858, 915, 863, 914, 207, 206, 941, 163, |
| 135950 | + /* 1550 */ 210, 942, 209, 164, 441, 862, 165, 211, 829, 695, |
| 135951 | + /* 1560 */ 87, 312, 309, 947, 1291, 1290, |
| 135386 | 135952 | }; |
| 135387 | 135953 | static const YYCODETYPE yy_lookahead[] = { |
| 135388 | | - /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28, |
| 135389 | | - /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 135390 | | - /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| 135391 | | - /* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133, |
| 135392 | | - /* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33, |
| 135393 | | - /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43, |
| 135394 | | - /* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 135395 | | - /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97, |
| 135396 | | - /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28, |
| 135397 | | - /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 135398 | | - /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| 135399 | | - /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19, |
| 135400 | | - /* 120 */ 16, 22, 92, 172, 173, 52, 53, 27, 28, 29, |
| 135401 | | - /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
| 135402 | | - /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49, |
| 135403 | | - /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208, |
| 135404 | | - /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32, |
| 135405 | | - /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79, |
| 135406 | | - /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135407 | | - /* 190 */ 53, 19, 88, 157, 90, 23, 97, 98, 193, 27, |
| 135408 | | - /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135409 | | - /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 135410 | | - /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172, |
| 135411 | | - /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32, |
| 135412 | | - /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187, |
| 135413 | | - /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135414 | | - /* 260 */ 53, 19, 22, 23, 228, 23, 26, 231, 152, 27, |
| 135415 | | - /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135416 | | - /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47, |
| 135417 | | - /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223, |
| 135418 | | - /* 300 */ 23, 96, 152, 172, 27, 28, 29, 30, 31, 32, |
| 135419 | | - /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152, |
| 135420 | | - /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135421 | | - /* 330 */ 53, 19, 0, 1, 2, 23, 96, 190, 191, 27, |
| 135422 | | - /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135423 | | - /* 350 */ 38, 39, 40, 41, 238, 43, 44, 45, 46, 47, |
| 135424 | | - /* 360 */ 48, 49, 50, 51, 52, 53, 19, 185, 218, 221, |
| 135425 | | - /* 370 */ 222, 223, 152, 152, 27, 28, 29, 30, 31, 32, |
| 135426 | | - /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 241, |
| 135427 | | - /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135428 | | - /* 400 */ 53, 19, 152, 168, 169, 170, 22, 190, 191, 27, |
| 135429 | | - /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135430 | | - /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 135431 | | - /* 430 */ 48, 49, 50, 51, 52, 53, 19, 19, 218, 55, |
| 135432 | | - /* 440 */ 56, 24, 22, 152, 27, 28, 29, 30, 31, 32, |
| 135433 | | - /* 450 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152, |
| 135434 | | - /* 460 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135435 | | - /* 470 */ 53, 250, 194, 195, 56, 55, 56, 55, 19, 172, |
| 135436 | | - /* 480 */ 173, 97, 98, 152, 206, 138, 27, 28, 29, 30, |
| 135437 | | - /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
| 135438 | | - /* 500 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50, |
| 135439 | | - /* 510 */ 51, 52, 53, 19, 207, 208, 152, 97, 98, 97, |
| 135440 | | - /* 520 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35, |
| 135441 | | - /* 530 */ 36, 37, 38, 39, 40, 41, 181, 43, 44, 45, |
| 135442 | | - /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 30, |
| 135443 | | - /* 550 */ 31, 32, 33, 247, 248, 19, 152, 28, 29, 30, |
| 135444 | | - /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
| 135445 | | - /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50, |
| 135446 | | - /* 580 */ 51, 52, 53, 19, 168, 169, 170, 238, 19, 53, |
| 135447 | | - /* 590 */ 152, 172, 173, 29, 30, 31, 32, 33, 34, 35, |
| 135448 | | - /* 600 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45, |
| 135449 | | - /* 610 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 20, |
| 135450 | | - /* 620 */ 101, 22, 23, 169, 170, 56, 207, 85, 55, 56, |
| 135451 | | - /* 630 */ 23, 19, 20, 26, 22, 99, 100, 101, 102, 103, |
| 135452 | | - /* 640 */ 104, 105, 238, 152, 152, 210, 47, 48, 112, 152, |
| 135453 | | - /* 650 */ 108, 109, 110, 54, 55, 56, 221, 222, 223, 47, |
| 135454 | | - /* 660 */ 48, 119, 120, 172, 173, 66, 54, 55, 56, 152, |
| 135455 | | - /* 670 */ 97, 98, 99, 148, 149, 102, 103, 104, 66, 154, |
| 135456 | | - /* 680 */ 23, 156, 83, 26, 230, 152, 113, 152, 163, 194, |
| 135457 | | - /* 690 */ 195, 92, 92, 30, 95, 83, 97, 98, 207, 208, |
| 135458 | | - /* 700 */ 101, 206, 179, 180, 92, 172, 173, 95, 152, 97, |
| 135459 | | - /* 710 */ 98, 188, 99, 101, 219, 102, 103, 104, 152, 119, |
| 135460 | | - /* 720 */ 120, 196, 55, 56, 19, 20, 113, 22, 193, 163, |
| 135461 | | - /* 730 */ 11, 132, 133, 134, 135, 136, 24, 65, 172, 173, |
| 135462 | | - /* 740 */ 207, 208, 250, 152, 132, 133, 134, 135, 136, 193, |
| 135463 | | - /* 750 */ 78, 84, 47, 48, 49, 98, 199, 152, 86, 54, |
| 135464 | | - /* 760 */ 55, 56, 196, 152, 97, 98, 209, 55, 163, 244, |
| 135465 | | - /* 770 */ 107, 66, 152, 207, 208, 164, 175, 172, 173, 19, |
| 135466 | | - /* 780 */ 20, 124, 22, 111, 38, 39, 40, 41, 83, 43, |
| 135467 | | - /* 790 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 135468 | | - /* 800 */ 95, 196, 97, 98, 85, 152, 101, 47, 48, 97, |
| 135469 | | - /* 810 */ 85, 92, 207, 193, 54, 55, 56, 92, 49, 175, |
| 135470 | | - /* 820 */ 55, 56, 221, 222, 223, 12, 66, 108, 109, 110, |
| 135471 | | - /* 830 */ 137, 163, 139, 108, 109, 110, 26, 132, 133, 134, |
| 135472 | | - /* 840 */ 135, 136, 152, 83, 43, 44, 45, 46, 47, 48, |
| 135473 | | - /* 850 */ 49, 50, 51, 52, 53, 95, 26, 97, 98, 55, |
| 135474 | | - /* 860 */ 56, 101, 97, 98, 196, 221, 222, 223, 146, 147, |
| 135475 | | - /* 870 */ 57, 171, 152, 22, 26, 19, 20, 49, 22, 179, |
| 135476 | | - /* 880 */ 108, 109, 110, 55, 56, 116, 73, 219, 75, 124, |
| 135477 | | - /* 890 */ 121, 152, 132, 133, 134, 135, 136, 163, 85, 152, |
| 135478 | | - /* 900 */ 232, 97, 98, 47, 48, 237, 55, 56, 98, 5, |
| 135479 | | - /* 910 */ 54, 55, 56, 193, 10, 11, 12, 13, 14, 172, |
| 135480 | | - /* 920 */ 173, 17, 66, 47, 48, 97, 98, 152, 124, 152, |
| 135481 | | - /* 930 */ 196, 55, 56, 186, 124, 152, 106, 160, 152, 83, |
| 135482 | | - /* 940 */ 152, 164, 152, 61, 22, 211, 212, 152, 97, 98, |
| 135483 | | - /* 950 */ 152, 95, 70, 97, 98, 172, 173, 101, 172, 173, |
| 135484 | | - /* 960 */ 172, 173, 172, 173, 60, 181, 62, 172, 173, 47, |
| 135485 | | - /* 970 */ 48, 123, 186, 97, 98, 71, 100, 55, 56, 152, |
| 135486 | | - /* 980 */ 181, 186, 21, 107, 152, 109, 82, 163, 132, 133, |
| 135487 | | - /* 990 */ 134, 135, 136, 89, 16, 207, 92, 93, 19, 172, |
| 135488 | | - /* 1000 */ 173, 169, 170, 195, 55, 56, 12, 152, 132, 30, |
| 135489 | | - /* 1010 */ 134, 47, 48, 186, 206, 225, 152, 95, 114, 97, |
| 135490 | | - /* 1020 */ 196, 245, 246, 101, 152, 38, 39, 40, 41, 42, |
| 135491 | | - /* 1030 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135492 | | - /* 1040 */ 53, 152, 163, 219, 152, 141, 97, 98, 193, 152, |
| 135493 | | - /* 1050 */ 152, 57, 91, 164, 132, 133, 134, 152, 55, 152, |
| 135494 | | - /* 1060 */ 152, 237, 230, 152, 103, 193, 88, 73, 90, 75, |
| 135495 | | - /* 1070 */ 172, 173, 183, 152, 185, 196, 152, 172, 173, 172, |
| 135496 | | - /* 1080 */ 173, 217, 152, 172, 173, 152, 107, 22, 152, 24, |
| 135497 | | - /* 1090 */ 193, 112, 152, 172, 173, 152, 132, 242, 134, 152, |
| 135498 | | - /* 1100 */ 97, 140, 152, 92, 152, 172, 173, 152, 172, 173, |
| 135499 | | - /* 1110 */ 152, 100, 172, 173, 152, 172, 173, 152, 140, 172, |
| 135500 | | - /* 1120 */ 173, 152, 172, 173, 172, 173, 152, 172, 173, 152, |
| 135501 | | - /* 1130 */ 172, 173, 152, 152, 172, 173, 152, 172, 173, 213, |
| 135502 | | - /* 1140 */ 152, 172, 173, 152, 152, 152, 172, 173, 152, 172, |
| 135503 | | - /* 1150 */ 173, 152, 172, 173, 152, 210, 172, 173, 152, 26, |
| 135504 | | - /* 1160 */ 172, 173, 152, 172, 173, 172, 173, 152, 172, 173, |
| 135505 | | - /* 1170 */ 152, 172, 173, 152, 172, 173, 152, 59, 172, 173, |
| 135506 | | - /* 1180 */ 152, 63, 172, 173, 152, 193, 152, 152, 152, 152, |
| 135507 | | - /* 1190 */ 172, 173, 152, 172, 173, 77, 172, 173, 152, 152, |
| 135508 | | - /* 1200 */ 172, 173, 152, 152, 172, 173, 172, 173, 172, 173, |
| 135509 | | - /* 1210 */ 152, 22, 172, 173, 152, 152, 152, 22, 172, 173, |
| 135510 | | - /* 1220 */ 152, 152, 152, 172, 173, 152, 7, 8, 9, 163, |
| 135511 | | - /* 1230 */ 172, 173, 22, 23, 172, 173, 172, 173, 166, 167, |
| 135512 | | - /* 1240 */ 172, 173, 172, 173, 55, 172, 173, 22, 23, 108, |
| 135513 | | - /* 1250 */ 109, 110, 217, 152, 217, 166, 167, 163, 163, 163, |
| 135514 | | - /* 1260 */ 163, 163, 196, 130, 217, 211, 212, 217, 116, 23, |
| 135515 | | - /* 1270 */ 22, 101, 26, 121, 23, 23, 23, 26, 26, 26, |
| 135516 | | - /* 1280 */ 23, 23, 112, 26, 26, 37, 97, 100, 101, 55, |
| 135517 | | - /* 1290 */ 196, 196, 196, 196, 196, 23, 23, 55, 26, 26, |
| 135518 | | - /* 1300 */ 7, 8, 23, 152, 23, 26, 96, 26, 132, 132, |
| 135519 | | - /* 1310 */ 134, 134, 23, 152, 152, 26, 152, 122, 152, 191, |
| 135520 | | - /* 1320 */ 152, 96, 234, 152, 152, 152, 152, 152, 197, 210, |
| 135521 | | - /* 1330 */ 152, 97, 152, 152, 210, 233, 210, 198, 150, 97, |
| 135522 | | - /* 1340 */ 184, 201, 239, 214, 214, 201, 239, 180, 214, 227, |
| 135523 | | - /* 1350 */ 200, 198, 155, 67, 243, 176, 69, 175, 175, 175, |
| 135524 | | - /* 1360 */ 122, 159, 159, 240, 159, 240, 22, 220, 27, 130, |
| 135525 | | - /* 1370 */ 201, 18, 159, 18, 189, 158, 158, 220, 192, 159, |
| 135526 | | - /* 1380 */ 137, 236, 192, 192, 192, 189, 74, 189, 159, 235, |
| 135527 | | - /* 1390 */ 159, 158, 22, 177, 201, 201, 159, 107, 158, 177, |
| 135528 | | - /* 1400 */ 159, 174, 158, 76, 174, 182, 174, 106, 182, 125, |
| 135529 | | - /* 1410 */ 174, 107, 177, 22, 159, 216, 215, 137, 159, 53, |
| 135530 | | - /* 1420 */ 216, 176, 215, 174, 174, 216, 215, 215, 174, 229, |
| 135531 | | - /* 1430 */ 216, 129, 224, 177, 126, 229, 127, 177, 128, 25, |
| 135532 | | - /* 1440 */ 162, 226, 26, 161, 13, 153, 6, 153, 151, 151, |
| 135533 | | - /* 1450 */ 151, 151, 205, 165, 178, 178, 165, 4, 3, 22, |
| 135534 | | - /* 1460 */ 165, 142, 15, 94, 202, 204, 203, 201, 16, 23, |
| 135535 | | - /* 1470 */ 249, 23, 120, 249, 246, 111, 131, 123, 20, 16, |
| 135536 | | - /* 1480 */ 1, 125, 123, 111, 56, 64, 37, 37, 131, 122, |
| 135537 | | - /* 1490 */ 1, 37, 5, 37, 22, 107, 26, 80, 140, 80, |
| 135538 | | - /* 1500 */ 87, 72, 107, 20, 24, 19, 112, 105, 23, 79, |
| 135539 | | - /* 1510 */ 22, 79, 22, 22, 22, 58, 22, 79, 23, 68, |
| 135540 | | - /* 1520 */ 23, 23, 26, 116, 22, 26, 23, 22, 122, 23, |
| 135541 | | - /* 1530 */ 23, 56, 64, 22, 124, 26, 26, 64, 64, 23, |
| 135542 | | - /* 1540 */ 23, 23, 23, 11, 23, 22, 26, 23, 22, 24, |
| 135543 | | - /* 1550 */ 1, 23, 22, 26, 251, 24, 23, 22, 122, 23, |
| 135544 | | - /* 1560 */ 23, 22, 15, 122, 122, 122, 23, |
| 135545 | | -}; |
| 135546 | | -#define YY_SHIFT_USE_DFLT (1567) |
| 135954 | + /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79, |
| 135955 | + /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, |
| 135956 | + /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58, |
| 135957 | + /* 30 */ 49, 50, 79, 80, 81, 82, 22, 84, 85, 86, |
| 135958 | + /* 40 */ 87, 88, 89, 90, 91, 92, 93, 94, 221, 222, |
| 135959 | + /* 50 */ 223, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135960 | + /* 60 */ 79, 80, 81, 82, 94, 84, 85, 86, 87, 88, |
| 135961 | + /* 70 */ 89, 90, 91, 92, 93, 94, 19, 94, 97, 108, |
| 135962 | + /* 80 */ 109, 110, 99, 100, 101, 102, 103, 104, 105, 32, |
| 135963 | + /* 90 */ 119, 120, 78, 27, 152, 112, 93, 94, 41, 88, |
| 135964 | + /* 100 */ 89, 90, 91, 92, 93, 94, 49, 50, 84, 85, |
| 135965 | + /* 110 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 58, |
| 135966 | + /* 120 */ 157, 119, 120, 163, 68, 163, 65, 70, 71, 72, |
| 135967 | + /* 130 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 135968 | + /* 140 */ 152, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 135969 | + /* 150 */ 93, 94, 19, 97, 88, 89, 196, 101, 196, 26, |
| 135970 | + /* 160 */ 172, 173, 96, 97, 98, 210, 100, 22, 152, 108, |
| 135971 | + /* 170 */ 109, 110, 27, 107, 27, 109, 221, 222, 223, 219, |
| 135972 | + /* 180 */ 238, 219, 49, 50, 152, 169, 170, 54, 132, 133, |
| 135973 | + /* 190 */ 134, 228, 232, 171, 231, 207, 208, 237, 132, 237, |
| 135974 | + /* 200 */ 134, 179, 19, 70, 71, 72, 73, 74, 75, 76, |
| 135975 | + /* 210 */ 77, 78, 79, 80, 81, 82, 152, 84, 85, 86, |
| 135976 | + /* 220 */ 87, 88, 89, 90, 91, 92, 93, 94, 27, 65, |
| 135977 | + /* 230 */ 30, 152, 49, 50, 34, 52, 90, 91, 92, 93, |
| 135978 | + /* 240 */ 94, 96, 97, 98, 97, 22, 230, 27, 48, 217, |
| 135979 | + /* 250 */ 27, 172, 173, 70, 71, 72, 73, 74, 75, 76, |
| 135980 | + /* 260 */ 77, 78, 79, 80, 81, 82, 172, 84, 85, 86, |
| 135981 | + /* 270 */ 87, 88, 89, 90, 91, 92, 93, 94, 19, 148, |
| 135982 | + /* 280 */ 149, 152, 218, 24, 152, 154, 207, 156, 172, 152, |
| 135983 | + /* 290 */ 22, 68, 27, 152, 163, 27, 164, 96, 97, 98, |
| 135984 | + /* 300 */ 99, 172, 173, 102, 103, 104, 169, 170, 49, 50, |
| 135985 | + /* 310 */ 90, 88, 89, 152, 113, 186, 96, 97, 98, 96, |
| 135986 | + /* 320 */ 97, 160, 57, 27, 101, 164, 137, 196, 139, 70, |
| 135987 | + /* 330 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 135988 | + /* 340 */ 81, 82, 11, 84, 85, 86, 87, 88, 89, 90, |
| 135989 | + /* 350 */ 91, 92, 93, 94, 19, 132, 133, 134, 23, 218, |
| 135990 | + /* 360 */ 152, 96, 97, 98, 96, 97, 98, 230, 99, 22, |
| 135991 | + /* 370 */ 152, 102, 103, 104, 27, 244, 152, 152, 27, 26, |
| 135992 | + /* 380 */ 152, 22, 113, 65, 49, 50, 27, 194, 195, 58, |
| 135993 | + /* 390 */ 172, 173, 96, 97, 98, 185, 65, 172, 173, 206, |
| 135994 | + /* 400 */ 172, 173, 190, 191, 186, 70, 71, 72, 73, 74, |
| 135995 | + /* 410 */ 75, 76, 77, 78, 79, 80, 81, 82, 175, 84, |
| 135996 | + /* 420 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 135997 | + /* 430 */ 19, 175, 207, 208, 23, 207, 208, 119, 120, 108, |
| 135998 | + /* 440 */ 109, 110, 27, 96, 97, 98, 116, 96, 97, 98, |
| 135999 | + /* 450 */ 152, 121, 152, 179, 180, 96, 97, 98, 250, 106, |
| 136000 | + /* 460 */ 49, 50, 188, 19, 221, 222, 223, 168, 169, 170, |
| 136001 | + /* 470 */ 172, 173, 172, 173, 250, 124, 172, 221, 222, 223, |
| 136002 | + /* 480 */ 26, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 136003 | + /* 490 */ 79, 80, 81, 82, 50, 84, 85, 86, 87, 88, |
| 136004 | + /* 500 */ 89, 90, 91, 92, 93, 94, 19, 207, 208, 12, |
| 136005 | + /* 510 */ 23, 96, 97, 98, 221, 222, 223, 194, 195, 152, |
| 136006 | + /* 520 */ 199, 23, 19, 225, 26, 28, 152, 152, 152, 206, |
| 136007 | + /* 530 */ 209, 164, 190, 191, 241, 152, 49, 50, 152, 124, |
| 136008 | + /* 540 */ 152, 44, 219, 46, 152, 21, 172, 173, 172, 173, |
| 136009 | + /* 550 */ 183, 107, 185, 16, 163, 58, 112, 70, 71, 72, |
| 136010 | + /* 560 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 136011 | + /* 570 */ 152, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 136012 | + /* 580 */ 93, 94, 19, 207, 130, 152, 23, 196, 64, 152, |
| 136013 | + /* 590 */ 172, 173, 22, 152, 24, 152, 98, 27, 61, 96, |
| 136014 | + /* 600 */ 63, 26, 211, 212, 186, 172, 173, 49, 50, 172, |
| 136015 | + /* 610 */ 173, 23, 49, 50, 26, 172, 173, 88, 89, 186, |
| 136016 | + /* 620 */ 24, 238, 124, 27, 238, 22, 23, 103, 187, 26, |
| 136017 | + /* 630 */ 152, 73, 74, 70, 71, 72, 73, 74, 75, 76, |
| 136018 | + /* 640 */ 77, 78, 79, 80, 81, 82, 152, 84, 85, 86, |
| 136019 | + /* 650 */ 87, 88, 89, 90, 91, 92, 93, 94, 19, 101, |
| 136020 | + /* 660 */ 152, 132, 23, 134, 140, 152, 12, 97, 36, 168, |
| 136021 | + /* 670 */ 169, 170, 69, 98, 152, 22, 23, 140, 50, 26, |
| 136022 | + /* 680 */ 172, 173, 28, 51, 152, 172, 173, 193, 49, 50, |
| 136023 | + /* 690 */ 22, 59, 24, 97, 172, 173, 152, 152, 44, 124, |
| 136024 | + /* 700 */ 46, 0, 1, 2, 172, 173, 22, 23, 19, 70, |
| 136025 | + /* 710 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 136026 | + /* 720 */ 81, 82, 69, 84, 85, 86, 87, 88, 89, 90, |
| 136027 | + /* 730 */ 91, 92, 93, 94, 152, 107, 152, 193, 49, 50, |
| 136028 | + /* 740 */ 181, 22, 23, 111, 108, 109, 110, 7, 8, 9, |
| 136029 | + /* 750 */ 16, 247, 248, 69, 172, 173, 172, 173, 152, 70, |
| 136030 | + /* 760 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 136031 | + /* 770 */ 81, 82, 152, 84, 85, 86, 87, 88, 89, 90, |
| 136032 | + /* 780 */ 91, 92, 93, 94, 19, 152, 242, 152, 69, 152, |
| 136033 | + /* 790 */ 166, 167, 172, 173, 32, 61, 152, 63, 152, 193, |
| 136034 | + /* 800 */ 152, 152, 152, 41, 152, 172, 173, 172, 173, 172, |
| 136035 | + /* 810 */ 173, 152, 152, 152, 49, 50, 172, 173, 172, 173, |
| 136036 | + /* 820 */ 172, 173, 172, 173, 172, 173, 132, 138, 134, 152, |
| 136037 | + /* 830 */ 152, 172, 173, 172, 173, 70, 71, 72, 73, 74, |
| 136038 | + /* 840 */ 75, 76, 77, 78, 79, 80, 81, 82, 152, 84, |
| 136039 | + /* 850 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 136040 | + /* 860 */ 19, 152, 22, 152, 195, 24, 152, 27, 172, 173, |
| 136041 | + /* 870 */ 193, 193, 152, 152, 152, 206, 152, 217, 152, 152, |
| 136042 | + /* 880 */ 152, 172, 173, 172, 173, 152, 172, 173, 152, 152, |
| 136043 | + /* 890 */ 49, 50, 172, 173, 172, 173, 172, 173, 172, 173, |
| 136044 | + /* 900 */ 172, 173, 152, 138, 152, 172, 173, 108, 109, 110, |
| 136045 | + /* 910 */ 19, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 136046 | + /* 920 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 136047 | + /* 930 */ 89, 90, 91, 92, 93, 94, 152, 97, 152, 152, |
| 136048 | + /* 940 */ 49, 50, 26, 193, 172, 173, 152, 152, 152, 146, |
| 136049 | + /* 950 */ 147, 132, 152, 134, 217, 181, 172, 173, 172, 173, |
| 136050 | + /* 960 */ 19, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 136051 | + /* 970 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 136052 | + /* 980 */ 89, 90, 91, 92, 93, 94, 152, 193, 152, 193, |
| 136053 | + /* 990 */ 49, 50, 181, 193, 172, 173, 166, 167, 245, 246, |
| 136054 | + /* 1000 */ 211, 212, 152, 22, 217, 152, 172, 173, 172, 173, |
| 136055 | + /* 1010 */ 19, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 136056 | + /* 1020 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 136057 | + /* 1030 */ 89, 90, 91, 92, 93, 94, 152, 187, 152, 123, |
| 136058 | + /* 1040 */ 49, 50, 23, 23, 23, 26, 26, 26, 23, 23, |
| 136059 | + /* 1050 */ 23, 26, 26, 26, 7, 8, 172, 173, 172, 173, |
| 136060 | + /* 1060 */ 19, 90, 71, 72, 73, 74, 75, 76, 77, 78, |
| 136061 | + /* 1070 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 136062 | + /* 1080 */ 89, 90, 91, 92, 93, 94, 152, 116, 152, 217, |
| 136063 | + /* 1090 */ 49, 50, 121, 23, 172, 173, 26, 100, 101, 27, |
| 136064 | + /* 1100 */ 101, 27, 23, 122, 152, 26, 172, 173, 172, 173, |
| 136065 | + /* 1110 */ 152, 112, 163, 72, 73, 74, 75, 76, 77, 78, |
| 136066 | + /* 1120 */ 79, 80, 81, 82, 163, 84, 85, 86, 87, 88, |
| 136067 | + /* 1130 */ 89, 90, 91, 92, 93, 94, 19, 20, 152, 22, |
| 136068 | + /* 1140 */ 23, 152, 163, 65, 27, 196, 163, 19, 20, 23, |
| 136069 | + /* 1150 */ 22, 213, 26, 19, 37, 27, 152, 196, 172, 173, |
| 136070 | + /* 1160 */ 152, 172, 173, 27, 23, 37, 152, 26, 152, 97, |
| 136071 | + /* 1170 */ 152, 97, 210, 56, 163, 196, 163, 163, 100, 196, |
| 136072 | + /* 1180 */ 172, 173, 65, 152, 56, 68, 172, 173, 172, 173, |
| 136073 | + /* 1190 */ 172, 173, 152, 65, 163, 163, 68, 23, 152, 234, |
| 136074 | + /* 1200 */ 26, 152, 152, 172, 173, 88, 89, 196, 152, 196, |
| 136075 | + /* 1210 */ 196, 152, 95, 96, 97, 98, 88, 89, 101, 152, |
| 136076 | + /* 1220 */ 152, 207, 208, 95, 96, 97, 98, 196, 196, 101, |
| 136077 | + /* 1230 */ 96, 233, 152, 97, 152, 152, 19, 20, 207, 22, |
| 136078 | + /* 1240 */ 152, 152, 152, 191, 27, 152, 152, 152, 152, 132, |
| 136079 | + /* 1250 */ 133, 134, 135, 136, 37, 152, 152, 152, 152, 152, |
| 136080 | + /* 1260 */ 132, 133, 134, 135, 136, 210, 197, 210, 210, 198, |
| 136081 | + /* 1270 */ 150, 184, 239, 56, 201, 214, 214, 201, 239, 180, |
| 136082 | + /* 1280 */ 214, 227, 198, 38, 176, 68, 175, 175, 175, 122, |
| 136083 | + /* 1290 */ 155, 200, 159, 19, 20, 40, 22, 159, 159, 22, |
| 136084 | + /* 1300 */ 70, 27, 130, 243, 240, 88, 89, 90, 189, 18, |
| 136085 | + /* 1310 */ 201, 37, 95, 96, 97, 98, 192, 5, 101, 192, |
| 136086 | + /* 1320 */ 220, 240, 10, 11, 12, 13, 14, 159, 18, 17, |
| 136087 | + /* 1330 */ 56, 158, 192, 201, 192, 220, 189, 189, 201, 159, |
| 136088 | + /* 1340 */ 158, 137, 68, 31, 45, 33, 236, 159, 159, 132, |
| 136089 | + /* 1350 */ 133, 134, 135, 136, 42, 158, 235, 22, 177, 159, |
| 136090 | + /* 1360 */ 158, 158, 88, 89, 159, 107, 174, 55, 177, 95, |
| 136091 | + /* 1370 */ 96, 97, 98, 174, 62, 101, 47, 65, 66, 106, |
| 136092 | + /* 1380 */ 174, 125, 19, 20, 174, 22, 177, 176, 174, 182, |
| 136093 | + /* 1390 */ 27, 216, 174, 174, 182, 107, 159, 22, 215, 215, |
| 136094 | + /* 1400 */ 37, 216, 216, 216, 137, 215, 132, 133, 134, 135, |
| 136095 | + /* 1410 */ 136, 215, 159, 177, 94, 177, 129, 224, 205, 56, |
| 136096 | + /* 1420 */ 226, 126, 128, 203, 229, 204, 114, 229, 127, 202, |
| 136097 | + /* 1430 */ 201, 68, 25, 162, 26, 13, 161, 153, 153, 6, |
| 136098 | + /* 1440 */ 151, 151, 178, 151, 151, 165, 165, 178, 165, 4, |
| 136099 | + /* 1450 */ 249, 88, 89, 141, 3, 142, 22, 249, 95, 96, |
| 136100 | + /* 1460 */ 97, 98, 246, 15, 101, 67, 16, 23, 120, 23, |
| 136101 | + /* 1470 */ 131, 111, 123, 20, 16, 125, 1, 123, 131, 78, |
| 136102 | + /* 1480 */ 78, 78, 78, 111, 96, 1, 122, 35, 5, 22, |
| 136103 | + /* 1490 */ 107, 140, 53, 53, 26, 132, 133, 134, 135, 136, |
| 136104 | + /* 1500 */ 43, 60, 107, 24, 112, 20, 19, 52, 22, 29, |
| 136105 | + /* 1510 */ 105, 22, 22, 52, 23, 22, 22, 52, 23, 23, |
| 136106 | + /* 1520 */ 39, 23, 116, 26, 22, 26, 23, 22, 96, 23, |
| 136107 | + /* 1530 */ 23, 122, 22, 24, 124, 35, 35, 26, 26, 35, |
| 136108 | + /* 1540 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22, |
| 136109 | + /* 1550 */ 122, 23, 26, 22, 24, 23, 22, 122, 23, 23, |
| 136110 | + /* 1560 */ 22, 15, 23, 1, 122, 122, |
| 136111 | +}; |
| 136112 | +#define YY_SHIFT_USE_DFLT (1566) |
| 135547 | 136113 | #define YY_SHIFT_COUNT (455) |
| 135548 | | -#define YY_SHIFT_MIN (-94) |
| 135549 | | -#define YY_SHIFT_MAX (1549) |
| 136114 | +#define YY_SHIFT_MIN (-114) |
| 136115 | +#define YY_SHIFT_MAX (1562) |
| 135550 | 136116 | static const short yy_shift_ofst[] = { |
| 135551 | | - /* 0 */ 40, 599, 904, 612, 760, 760, 760, 760, 725, -19, |
| 135552 | | - /* 10 */ 16, 16, 100, 760, 760, 760, 760, 760, 760, 760, |
| 135553 | | - /* 20 */ 876, 876, 573, 542, 719, 600, 61, 137, 172, 207, |
| 135554 | | - /* 30 */ 242, 277, 312, 347, 382, 417, 459, 459, 459, 459, |
| 135555 | | - /* 40 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, |
| 135556 | | - /* 50 */ 459, 459, 459, 494, 459, 529, 564, 564, 705, 760, |
| 135557 | | - /* 60 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135558 | | - /* 70 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135559 | | - /* 80 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135560 | | - /* 90 */ 856, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135561 | | - /* 100 */ 760, 760, 760, 760, 987, 746, 746, 746, 746, 746, |
| 135562 | | - /* 110 */ 801, 23, 32, 949, 961, 979, 964, 964, 949, 73, |
| 135563 | | - /* 120 */ 113, -51, 1567, 1567, 1567, 536, 536, 536, 99, 99, |
| 135564 | | - /* 130 */ 813, 813, 667, 205, 240, 949, 949, 949, 949, 949, |
| 135565 | | - /* 140 */ 949, 949, 949, 949, 949, 949, 949, 949, 949, 949, |
| 135566 | | - /* 150 */ 949, 949, 949, 949, 949, 332, 1011, 422, 422, 113, |
| 135567 | | - /* 160 */ 30, 30, 30, 30, 30, 30, 1567, 1567, 1567, 922, |
| 135568 | | - /* 170 */ -94, -94, 384, 613, 828, 420, 765, 804, 851, 949, |
| 135569 | | - /* 180 */ 949, 949, 949, 949, 949, 949, 949, 949, 949, 949, |
| 135570 | | - /* 190 */ 949, 949, 949, 949, 949, 672, 672, 672, 949, 949, |
| 135571 | | - /* 200 */ 657, 949, 949, 949, -18, 949, 949, 994, 949, 949, |
| 135572 | | - /* 210 */ 949, 949, 949, 949, 949, 949, 949, 949, 772, 1118, |
| 135573 | | - /* 220 */ 712, 712, 712, 810, 45, 769, 1219, 1133, 418, 418, |
| 135574 | | - /* 230 */ 569, 1133, 569, 830, 607, 663, 882, 418, 693, 882, |
| 135575 | | - /* 240 */ 882, 848, 1152, 1065, 1286, 1238, 1238, 1287, 1287, 1238, |
| 135576 | | - /* 250 */ 1344, 1341, 1239, 1353, 1353, 1353, 1353, 1238, 1355, 1239, |
| 135577 | | - /* 260 */ 1344, 1341, 1341, 1239, 1238, 1355, 1243, 1312, 1238, 1238, |
| 135578 | | - /* 270 */ 1355, 1370, 1238, 1355, 1238, 1355, 1370, 1290, 1290, 1290, |
| 135579 | | - /* 280 */ 1327, 1370, 1290, 1301, 1290, 1327, 1290, 1290, 1284, 1304, |
| 135580 | | - /* 290 */ 1284, 1304, 1284, 1304, 1284, 1304, 1238, 1391, 1238, 1280, |
| 135581 | | - /* 300 */ 1370, 1366, 1366, 1370, 1302, 1308, 1310, 1309, 1239, 1414, |
| 135582 | | - /* 310 */ 1416, 1431, 1431, 1440, 1440, 1440, 1440, 1567, 1567, 1567, |
| 135583 | | - /* 320 */ 1567, 1567, 1567, 1567, 1567, 519, 978, 1210, 1225, 104, |
| 135584 | | - /* 330 */ 1141, 1189, 1246, 1248, 1251, 1252, 1253, 1257, 1258, 1273, |
| 135585 | | - /* 340 */ 1003, 1187, 1293, 1170, 1272, 1279, 1234, 1281, 1176, 1177, |
| 135586 | | - /* 350 */ 1289, 1242, 1195, 1453, 1455, 1437, 1319, 1447, 1369, 1452, |
| 135587 | | - /* 360 */ 1446, 1448, 1352, 1345, 1364, 1354, 1458, 1356, 1463, 1479, |
| 135588 | | - /* 370 */ 1359, 1357, 1449, 1450, 1454, 1456, 1372, 1428, 1421, 1367, |
| 135589 | | - /* 380 */ 1489, 1487, 1472, 1388, 1358, 1417, 1470, 1419, 1413, 1429, |
| 135590 | | - /* 390 */ 1395, 1480, 1483, 1486, 1394, 1402, 1488, 1430, 1490, 1491, |
| 135591 | | - /* 400 */ 1485, 1492, 1432, 1457, 1494, 1438, 1451, 1495, 1497, 1498, |
| 135592 | | - /* 410 */ 1496, 1407, 1502, 1503, 1505, 1499, 1406, 1506, 1507, 1475, |
| 135593 | | - /* 420 */ 1468, 1511, 1410, 1509, 1473, 1510, 1474, 1516, 1509, 1517, |
| 135594 | | - /* 430 */ 1518, 1519, 1520, 1521, 1523, 1532, 1524, 1526, 1525, 1527, |
| 135595 | | - /* 440 */ 1528, 1530, 1531, 1527, 1533, 1535, 1536, 1537, 1539, 1436, |
| 135596 | | - /* 450 */ 1441, 1442, 1443, 1543, 1547, 1549, |
| 136117 | + /* 0 */ 5, 1117, 1312, 1128, 1274, 1274, 1274, 1274, 61, -19, |
| 136118 | + /* 10 */ 57, 57, 183, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136119 | + /* 20 */ 66, 66, 201, -29, 331, 318, 133, 259, 335, 411, |
| 136120 | + /* 30 */ 487, 563, 639, 689, 765, 841, 891, 891, 891, 891, |
| 136121 | + /* 40 */ 891, 891, 891, 891, 891, 891, 891, 891, 891, 891, |
| 136122 | + /* 50 */ 891, 891, 891, 941, 891, 991, 1041, 1041, 1217, 1274, |
| 136123 | + /* 60 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136124 | + /* 70 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136125 | + /* 80 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136126 | + /* 90 */ 1363, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136127 | + /* 100 */ 1274, 1274, 1274, 1274, -70, -47, -47, -47, -47, -47, |
| 136128 | + /* 110 */ 24, 11, 146, 296, 524, 444, 529, 529, 296, 3, |
| 136129 | + /* 120 */ 2, -30, 1566, 1566, 1566, -17, -17, -17, 145, 145, |
| 136130 | + /* 130 */ 497, 497, 265, 603, 653, 296, 296, 296, 296, 296, |
| 136131 | + /* 140 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, |
| 136132 | + /* 150 */ 296, 296, 296, 296, 296, 701, 1078, 147, 147, 2, |
| 136133 | + /* 160 */ 164, 164, 164, 164, 164, 164, 1566, 1566, 1566, 223, |
| 136134 | + /* 170 */ 56, 56, 268, 269, 220, 347, 351, 415, 359, 296, |
| 136135 | + /* 180 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, |
| 136136 | + /* 190 */ 296, 296, 296, 296, 296, 632, 632, 632, 296, 296, |
| 136137 | + /* 200 */ 498, 296, 296, 296, 570, 296, 296, 654, 296, 296, |
| 136138 | + /* 210 */ 296, 296, 296, 296, 296, 296, 296, 296, 636, 200, |
| 136139 | + /* 220 */ 596, 596, 596, 575, -114, 971, 740, 454, 503, 503, |
| 136140 | + /* 230 */ 1134, 454, 1134, 353, 588, 628, 762, 503, 189, 762, |
| 136141 | + /* 240 */ 762, 916, 330, 668, 1245, 1167, 1167, 1255, 1255, 1167, |
| 136142 | + /* 250 */ 1277, 1230, 1172, 1291, 1291, 1291, 1291, 1167, 1310, 1172, |
| 136143 | + /* 260 */ 1277, 1230, 1230, 1172, 1167, 1310, 1204, 1299, 1167, 1167, |
| 136144 | + /* 270 */ 1310, 1335, 1167, 1310, 1167, 1310, 1335, 1258, 1258, 1258, |
| 136145 | + /* 280 */ 1329, 1335, 1258, 1273, 1258, 1329, 1258, 1258, 1256, 1288, |
| 136146 | + /* 290 */ 1256, 1288, 1256, 1288, 1256, 1288, 1167, 1375, 1167, 1267, |
| 136147 | + /* 300 */ 1335, 1320, 1320, 1335, 1287, 1295, 1294, 1301, 1172, 1407, |
| 136148 | + /* 310 */ 1408, 1422, 1422, 1433, 1433, 1433, 1433, 1566, 1566, 1566, |
| 136149 | + /* 320 */ 1566, 1566, 1566, 1566, 1566, 558, 537, 684, 719, 734, |
| 136150 | + /* 330 */ 799, 840, 1019, 14, 1020, 1021, 1025, 1026, 1027, 1070, |
| 136151 | + /* 340 */ 1072, 997, 1047, 999, 1079, 1126, 1074, 1141, 694, 819, |
| 136152 | + /* 350 */ 1174, 1136, 981, 1445, 1451, 1434, 1313, 1448, 1398, 1450, |
| 136153 | + /* 360 */ 1444, 1446, 1348, 1339, 1360, 1349, 1453, 1350, 1458, 1475, |
| 136154 | + /* 370 */ 1354, 1347, 1401, 1402, 1403, 1404, 1372, 1388, 1452, 1364, |
| 136155 | + /* 380 */ 1484, 1483, 1467, 1383, 1351, 1439, 1468, 1440, 1441, 1457, |
| 136156 | + /* 390 */ 1395, 1479, 1485, 1487, 1392, 1405, 1486, 1455, 1489, 1490, |
| 136157 | + /* 400 */ 1491, 1493, 1461, 1480, 1494, 1465, 1481, 1495, 1496, 1498, |
| 136158 | + /* 410 */ 1497, 1406, 1502, 1503, 1505, 1499, 1409, 1506, 1507, 1432, |
| 136159 | + /* 420 */ 1500, 1510, 1410, 1511, 1501, 1512, 1504, 1517, 1511, 1518, |
| 136160 | + /* 430 */ 1519, 1520, 1521, 1522, 1524, 1533, 1525, 1527, 1509, 1526, |
| 136161 | + /* 440 */ 1528, 1531, 1530, 1526, 1532, 1534, 1535, 1536, 1538, 1428, |
| 136162 | + /* 450 */ 1435, 1442, 1443, 1539, 1546, 1562, |
| 135597 | 136163 | }; |
| 135598 | | -#define YY_REDUCE_USE_DFLT (-130) |
| 136164 | +#define YY_REDUCE_USE_DFLT (-174) |
| 135599 | 136165 | #define YY_REDUCE_COUNT (324) |
| 135600 | | -#define YY_REDUCE_MIN (-129) |
| 135601 | | -#define YY_REDUCE_MAX (1300) |
| 136166 | +#define YY_REDUCE_MIN (-173) |
| 136167 | +#define YY_REDUCE_MAX (1293) |
| 135602 | 136168 | static const short yy_reduce_ofst[] = { |
| 135603 | | - /* 0 */ -29, 566, 525, 605, -49, 307, 491, 533, 668, 435, |
| 135604 | | - /* 10 */ 601, 644, 148, 747, 786, 795, 419, 788, 827, 790, |
| 135605 | | - /* 20 */ 454, 832, 889, 495, 824, 734, 76, 76, 76, 76, |
| 135606 | | - /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, |
| 135607 | | - /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, |
| 135608 | | - /* 50 */ 76, 76, 76, 76, 76, 76, 76, 76, 783, 898, |
| 135609 | | - /* 60 */ 905, 907, 911, 921, 933, 936, 940, 943, 947, 950, |
| 135610 | | - /* 70 */ 952, 955, 958, 962, 965, 969, 974, 977, 980, 984, |
| 135611 | | - /* 80 */ 988, 991, 993, 996, 999, 1002, 1006, 1010, 1018, 1021, |
| 135612 | | - /* 90 */ 1024, 1028, 1032, 1034, 1036, 1040, 1046, 1051, 1058, 1062, |
| 135613 | | - /* 100 */ 1064, 1068, 1070, 1073, 76, 76, 76, 76, 76, 76, |
| 135614 | | - /* 110 */ 76, 76, 76, 855, 36, 523, 235, 416, 777, 76, |
| 135615 | | - /* 120 */ 278, 76, 76, 76, 76, 700, 700, 700, 150, 220, |
| 135616 | | - /* 130 */ 147, 217, 221, 306, 306, 611, 5, 535, 556, 620, |
| 135617 | | - /* 140 */ 720, 872, 897, 116, 864, 349, 1035, 1037, 404, 1047, |
| 135618 | | - /* 150 */ 992, -129, 1050, 492, 62, 722, 879, 1072, 1089, 808, |
| 135619 | | - /* 160 */ 1066, 1094, 1095, 1096, 1097, 1098, 776, 1054, 557, 57, |
| 135620 | | - /* 170 */ 112, 131, 167, 182, 250, 272, 291, 331, 364, 438, |
| 135621 | | - /* 180 */ 497, 517, 591, 653, 690, 739, 775, 798, 892, 908, |
| 135622 | | - /* 190 */ 924, 930, 1015, 1063, 1069, 355, 784, 799, 981, 1101, |
| 135623 | | - /* 200 */ 926, 1151, 1161, 1162, 945, 1164, 1166, 1128, 1168, 1171, |
| 135624 | | - /* 210 */ 1172, 250, 1173, 1174, 1175, 1178, 1180, 1181, 1088, 1102, |
| 135625 | | - /* 220 */ 1119, 1124, 1126, 926, 1131, 1139, 1188, 1140, 1129, 1130, |
| 135626 | | - /* 230 */ 1103, 1144, 1107, 1179, 1156, 1167, 1182, 1134, 1122, 1183, |
| 135627 | | - /* 240 */ 1184, 1150, 1153, 1197, 1111, 1202, 1203, 1123, 1125, 1205, |
| 135628 | | - /* 250 */ 1147, 1185, 1169, 1186, 1190, 1191, 1192, 1213, 1217, 1193, |
| 135629 | | - /* 260 */ 1157, 1196, 1198, 1194, 1220, 1218, 1145, 1154, 1229, 1231, |
| 135630 | | - /* 270 */ 1233, 1216, 1237, 1240, 1241, 1244, 1222, 1227, 1230, 1232, |
| 135631 | | - /* 280 */ 1223, 1235, 1236, 1245, 1249, 1226, 1250, 1254, 1199, 1201, |
| 135632 | | - /* 290 */ 1204, 1207, 1209, 1211, 1214, 1212, 1255, 1208, 1259, 1215, |
| 135633 | | - /* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278, |
| 135634 | | - /* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228, |
| 135635 | | - /* 320 */ 1288, 1291, 1276, 1277, 1295, |
| 136169 | + /* 0 */ -119, 1014, 131, 1031, -12, 225, 228, 300, -40, -45, |
| 136170 | + /* 10 */ 243, 256, 293, 129, 218, 418, 79, 376, 433, 298, |
| 136171 | + /* 20 */ 16, 137, 367, 323, -38, 391, -173, -173, -173, -173, |
| 136172 | + /* 30 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173, |
| 136173 | + /* 40 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173, |
| 136174 | + /* 50 */ -173, -173, -173, -173, -173, -173, -173, -173, 374, 437, |
| 136175 | + /* 60 */ 443, 508, 513, 522, 532, 582, 584, 620, 633, 635, |
| 136176 | + /* 70 */ 637, 644, 646, 648, 650, 652, 659, 661, 696, 709, |
| 136177 | + /* 80 */ 711, 714, 720, 722, 724, 726, 728, 733, 772, 784, |
| 136178 | + /* 90 */ 786, 822, 834, 836, 884, 886, 922, 934, 936, 986, |
| 136179 | + /* 100 */ 989, 1008, 1016, 1018, -173, -173, -173, -173, -173, -173, |
| 136180 | + /* 110 */ -173, -173, -173, 544, -37, 274, 299, 501, 161, -173, |
| 136181 | + /* 120 */ 193, -173, -173, -173, -173, 22, 22, 22, 64, 141, |
| 136182 | + /* 130 */ 212, 342, 208, 504, 504, 132, 494, 606, 677, 678, |
| 136183 | + /* 140 */ 750, 794, 796, -58, 32, 383, 660, 737, 386, 787, |
| 136184 | + /* 150 */ 800, 441, 872, 224, 850, 803, 949, 624, 830, 669, |
| 136185 | + /* 160 */ 961, 979, 983, 1011, 1013, 1032, 753, 789, 321, 94, |
| 136186 | + /* 170 */ 116, 304, 375, 210, 388, 392, 478, 545, 649, 721, |
| 136187 | + /* 180 */ 727, 736, 752, 795, 853, 952, 958, 1004, 1040, 1046, |
| 136188 | + /* 190 */ 1049, 1050, 1056, 1059, 1067, 559, 774, 811, 1068, 1080, |
| 136189 | + /* 200 */ 938, 1082, 1083, 1088, 962, 1089, 1090, 1052, 1093, 1094, |
| 136190 | + /* 210 */ 1095, 388, 1096, 1103, 1104, 1105, 1106, 1107, 965, 998, |
| 136191 | + /* 220 */ 1055, 1057, 1058, 938, 1069, 1071, 1120, 1073, 1061, 1062, |
| 136192 | + /* 230 */ 1033, 1076, 1039, 1108, 1087, 1099, 1111, 1066, 1054, 1112, |
| 136193 | + /* 240 */ 1113, 1091, 1084, 1135, 1060, 1133, 1138, 1064, 1081, 1139, |
| 136194 | + /* 250 */ 1100, 1119, 1109, 1124, 1127, 1140, 1142, 1168, 1173, 1132, |
| 136195 | + /* 260 */ 1115, 1147, 1148, 1137, 1180, 1182, 1110, 1121, 1188, 1189, |
| 136196 | + /* 270 */ 1197, 1181, 1200, 1202, 1205, 1203, 1191, 1192, 1199, 1206, |
| 136197 | + /* 280 */ 1207, 1209, 1210, 1211, 1214, 1212, 1218, 1219, 1175, 1183, |
| 136198 | + /* 290 */ 1185, 1184, 1186, 1190, 1187, 1196, 1237, 1193, 1253, 1194, |
| 136199 | + /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271, |
| 136200 | + /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216, |
| 136201 | + /* 320 */ 1280, 1281, 1264, 1269, 1283, |
| 135636 | 136202 | }; |
| 135637 | 136203 | static const YYACTIONTYPE yy_default[] = { |
| 135638 | 136204 | /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096, |
| 135639 | 136205 | /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201, |
| 135640 | 136206 | /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332, |
| | @@ -135700,104 +136266,77 @@ |
| 135700 | 136266 | */ |
| 135701 | 136267 | #ifdef YYFALLBACK |
| 135702 | 136268 | static const YYCODETYPE yyFallback[] = { |
| 135703 | 136269 | 0, /* $ => nothing */ |
| 135704 | 136270 | 0, /* SEMI => nothing */ |
| 135705 | | - 55, /* EXPLAIN => ID */ |
| 135706 | | - 55, /* QUERY => ID */ |
| 135707 | | - 55, /* PLAN => ID */ |
| 135708 | | - 55, /* BEGIN => ID */ |
| 136271 | + 27, /* EXPLAIN => ID */ |
| 136272 | + 27, /* QUERY => ID */ |
| 136273 | + 27, /* PLAN => ID */ |
| 136274 | + 27, /* BEGIN => ID */ |
| 135709 | 136275 | 0, /* TRANSACTION => nothing */ |
| 135710 | | - 55, /* DEFERRED => ID */ |
| 135711 | | - 55, /* IMMEDIATE => ID */ |
| 135712 | | - 55, /* EXCLUSIVE => ID */ |
| 136276 | + 27, /* DEFERRED => ID */ |
| 136277 | + 27, /* IMMEDIATE => ID */ |
| 136278 | + 27, /* EXCLUSIVE => ID */ |
| 135713 | 136279 | 0, /* COMMIT => nothing */ |
| 135714 | | - 55, /* END => ID */ |
| 135715 | | - 55, /* ROLLBACK => ID */ |
| 135716 | | - 55, /* SAVEPOINT => ID */ |
| 135717 | | - 55, /* RELEASE => ID */ |
| 136280 | + 27, /* END => ID */ |
| 136281 | + 27, /* ROLLBACK => ID */ |
| 136282 | + 27, /* SAVEPOINT => ID */ |
| 136283 | + 27, /* RELEASE => ID */ |
| 135718 | 136284 | 0, /* TO => nothing */ |
| 135719 | 136285 | 0, /* TABLE => nothing */ |
| 135720 | 136286 | 0, /* CREATE => nothing */ |
| 135721 | | - 55, /* IF => ID */ |
| 136287 | + 27, /* IF => ID */ |
| 135722 | 136288 | 0, /* NOT => nothing */ |
| 135723 | 136289 | 0, /* EXISTS => nothing */ |
| 135724 | | - 55, /* TEMP => ID */ |
| 136290 | + 27, /* TEMP => ID */ |
| 135725 | 136291 | 0, /* LP => nothing */ |
| 135726 | 136292 | 0, /* RP => nothing */ |
| 135727 | 136293 | 0, /* AS => nothing */ |
| 135728 | | - 55, /* WITHOUT => ID */ |
| 136294 | + 27, /* WITHOUT => ID */ |
| 135729 | 136295 | 0, /* COMMA => nothing */ |
| 135730 | | - 0, /* OR => nothing */ |
| 135731 | | - 0, /* AND => nothing */ |
| 135732 | | - 0, /* IS => nothing */ |
| 135733 | | - 55, /* MATCH => ID */ |
| 135734 | | - 55, /* LIKE_KW => ID */ |
| 135735 | | - 0, /* BETWEEN => nothing */ |
| 135736 | | - 0, /* IN => nothing */ |
| 135737 | | - 0, /* ISNULL => nothing */ |
| 135738 | | - 0, /* NOTNULL => nothing */ |
| 135739 | | - 0, /* NE => nothing */ |
| 135740 | | - 0, /* EQ => nothing */ |
| 135741 | | - 0, /* GT => nothing */ |
| 135742 | | - 0, /* LE => nothing */ |
| 135743 | | - 0, /* LT => nothing */ |
| 135744 | | - 0, /* GE => nothing */ |
| 135745 | | - 0, /* ESCAPE => nothing */ |
| 135746 | | - 0, /* BITAND => nothing */ |
| 135747 | | - 0, /* BITOR => nothing */ |
| 135748 | | - 0, /* LSHIFT => nothing */ |
| 135749 | | - 0, /* RSHIFT => nothing */ |
| 135750 | | - 0, /* PLUS => nothing */ |
| 135751 | | - 0, /* MINUS => nothing */ |
| 135752 | | - 0, /* STAR => nothing */ |
| 135753 | | - 0, /* SLASH => nothing */ |
| 135754 | | - 0, /* REM => nothing */ |
| 135755 | | - 0, /* CONCAT => nothing */ |
| 135756 | | - 0, /* COLLATE => nothing */ |
| 135757 | | - 0, /* BITNOT => nothing */ |
| 135758 | 136296 | 0, /* ID => nothing */ |
| 135759 | | - 0, /* INDEXED => nothing */ |
| 135760 | | - 55, /* ABORT => ID */ |
| 135761 | | - 55, /* ACTION => ID */ |
| 135762 | | - 55, /* AFTER => ID */ |
| 135763 | | - 55, /* ANALYZE => ID */ |
| 135764 | | - 55, /* ASC => ID */ |
| 135765 | | - 55, /* ATTACH => ID */ |
| 135766 | | - 55, /* BEFORE => ID */ |
| 135767 | | - 55, /* BY => ID */ |
| 135768 | | - 55, /* CASCADE => ID */ |
| 135769 | | - 55, /* CAST => ID */ |
| 135770 | | - 55, /* COLUMNKW => ID */ |
| 135771 | | - 55, /* CONFLICT => ID */ |
| 135772 | | - 55, /* DATABASE => ID */ |
| 135773 | | - 55, /* DESC => ID */ |
| 135774 | | - 55, /* DETACH => ID */ |
| 135775 | | - 55, /* EACH => ID */ |
| 135776 | | - 55, /* FAIL => ID */ |
| 135777 | | - 55, /* FOR => ID */ |
| 135778 | | - 55, /* IGNORE => ID */ |
| 135779 | | - 55, /* INITIALLY => ID */ |
| 135780 | | - 55, /* INSTEAD => ID */ |
| 135781 | | - 55, /* NO => ID */ |
| 135782 | | - 55, /* KEY => ID */ |
| 135783 | | - 55, /* OF => ID */ |
| 135784 | | - 55, /* OFFSET => ID */ |
| 135785 | | - 55, /* PRAGMA => ID */ |
| 135786 | | - 55, /* RAISE => ID */ |
| 135787 | | - 55, /* RECURSIVE => ID */ |
| 135788 | | - 55, /* REPLACE => ID */ |
| 135789 | | - 55, /* RESTRICT => ID */ |
| 135790 | | - 55, /* ROW => ID */ |
| 135791 | | - 55, /* TRIGGER => ID */ |
| 135792 | | - 55, /* VACUUM => ID */ |
| 135793 | | - 55, /* VIEW => ID */ |
| 135794 | | - 55, /* VIRTUAL => ID */ |
| 135795 | | - 55, /* WITH => ID */ |
| 135796 | | - 55, /* REINDEX => ID */ |
| 135797 | | - 55, /* RENAME => ID */ |
| 135798 | | - 55, /* CTIME_KW => ID */ |
| 136297 | + 27, /* ABORT => ID */ |
| 136298 | + 27, /* ACTION => ID */ |
| 136299 | + 27, /* AFTER => ID */ |
| 136300 | + 27, /* ANALYZE => ID */ |
| 136301 | + 27, /* ASC => ID */ |
| 136302 | + 27, /* ATTACH => ID */ |
| 136303 | + 27, /* BEFORE => ID */ |
| 136304 | + 27, /* BY => ID */ |
| 136305 | + 27, /* CASCADE => ID */ |
| 136306 | + 27, /* CAST => ID */ |
| 136307 | + 27, /* COLUMNKW => ID */ |
| 136308 | + 27, /* CONFLICT => ID */ |
| 136309 | + 27, /* DATABASE => ID */ |
| 136310 | + 27, /* DESC => ID */ |
| 136311 | + 27, /* DETACH => ID */ |
| 136312 | + 27, /* EACH => ID */ |
| 136313 | + 27, /* FAIL => ID */ |
| 136314 | + 27, /* FOR => ID */ |
| 136315 | + 27, /* IGNORE => ID */ |
| 136316 | + 27, /* INITIALLY => ID */ |
| 136317 | + 27, /* INSTEAD => ID */ |
| 136318 | + 27, /* LIKE_KW => ID */ |
| 136319 | + 27, /* MATCH => ID */ |
| 136320 | + 27, /* NO => ID */ |
| 136321 | + 27, /* KEY => ID */ |
| 136322 | + 27, /* OF => ID */ |
| 136323 | + 27, /* OFFSET => ID */ |
| 136324 | + 27, /* PRAGMA => ID */ |
| 136325 | + 27, /* RAISE => ID */ |
| 136326 | + 27, /* RECURSIVE => ID */ |
| 136327 | + 27, /* REPLACE => ID */ |
| 136328 | + 27, /* RESTRICT => ID */ |
| 136329 | + 27, /* ROW => ID */ |
| 136330 | + 27, /* TRIGGER => ID */ |
| 136331 | + 27, /* VACUUM => ID */ |
| 136332 | + 27, /* VIEW => ID */ |
| 136333 | + 27, /* VIRTUAL => ID */ |
| 136334 | + 27, /* WITH => ID */ |
| 136335 | + 27, /* REINDEX => ID */ |
| 136336 | + 27, /* RENAME => ID */ |
| 136337 | + 27, /* CTIME_KW => ID */ |
| 135799 | 136338 | }; |
| 135800 | 136339 | #endif /* YYFALLBACK */ |
| 135801 | 136340 | |
| 135802 | 136341 | /* The following structure represents a single element of the |
| 135803 | 136342 | ** parser's stack. Information stored includes: |
| | @@ -135885,29 +136424,29 @@ |
| 135885 | 136424 | "PLAN", "BEGIN", "TRANSACTION", "DEFERRED", |
| 135886 | 136425 | "IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", |
| 135887 | 136426 | "ROLLBACK", "SAVEPOINT", "RELEASE", "TO", |
| 135888 | 136427 | "TABLE", "CREATE", "IF", "NOT", |
| 135889 | 136428 | "EXISTS", "TEMP", "LP", "RP", |
| 135890 | | - "AS", "WITHOUT", "COMMA", "OR", |
| 135891 | | - "AND", "IS", "MATCH", "LIKE_KW", |
| 135892 | | - "BETWEEN", "IN", "ISNULL", "NOTNULL", |
| 135893 | | - "NE", "EQ", "GT", "LE", |
| 135894 | | - "LT", "GE", "ESCAPE", "BITAND", |
| 135895 | | - "BITOR", "LSHIFT", "RSHIFT", "PLUS", |
| 135896 | | - "MINUS", "STAR", "SLASH", "REM", |
| 135897 | | - "CONCAT", "COLLATE", "BITNOT", "ID", |
| 135898 | | - "INDEXED", "ABORT", "ACTION", "AFTER", |
| 135899 | | - "ANALYZE", "ASC", "ATTACH", "BEFORE", |
| 135900 | | - "BY", "CASCADE", "CAST", "COLUMNKW", |
| 135901 | | - "CONFLICT", "DATABASE", "DESC", "DETACH", |
| 135902 | | - "EACH", "FAIL", "FOR", "IGNORE", |
| 135903 | | - "INITIALLY", "INSTEAD", "NO", "KEY", |
| 135904 | | - "OF", "OFFSET", "PRAGMA", "RAISE", |
| 135905 | | - "RECURSIVE", "REPLACE", "RESTRICT", "ROW", |
| 135906 | | - "TRIGGER", "VACUUM", "VIEW", "VIRTUAL", |
| 135907 | | - "WITH", "REINDEX", "RENAME", "CTIME_KW", |
| 135908 | | - "ANY", "STRING", "JOIN_KW", "CONSTRAINT", |
| 136429 | + "AS", "WITHOUT", "COMMA", "ID", |
| 136430 | + "ABORT", "ACTION", "AFTER", "ANALYZE", |
| 136431 | + "ASC", "ATTACH", "BEFORE", "BY", |
| 136432 | + "CASCADE", "CAST", "COLUMNKW", "CONFLICT", |
| 136433 | + "DATABASE", "DESC", "DETACH", "EACH", |
| 136434 | + "FAIL", "FOR", "IGNORE", "INITIALLY", |
| 136435 | + "INSTEAD", "LIKE_KW", "MATCH", "NO", |
| 136436 | + "KEY", "OF", "OFFSET", "PRAGMA", |
| 136437 | + "RAISE", "RECURSIVE", "REPLACE", "RESTRICT", |
| 136438 | + "ROW", "TRIGGER", "VACUUM", "VIEW", |
| 136439 | + "VIRTUAL", "WITH", "REINDEX", "RENAME", |
| 136440 | + "CTIME_KW", "ANY", "OR", "AND", |
| 136441 | + "IS", "BETWEEN", "IN", "ISNULL", |
| 136442 | + "NOTNULL", "NE", "EQ", "GT", |
| 136443 | + "LE", "LT", "GE", "ESCAPE", |
| 136444 | + "BITAND", "BITOR", "LSHIFT", "RSHIFT", |
| 136445 | + "PLUS", "MINUS", "STAR", "SLASH", |
| 136446 | + "REM", "CONCAT", "COLLATE", "BITNOT", |
| 136447 | + "INDEXED", "STRING", "JOIN_KW", "CONSTRAINT", |
| 135909 | 136448 | "DEFAULT", "NULL", "PRIMARY", "UNIQUE", |
| 135910 | 136449 | "CHECK", "REFERENCES", "AUTOINCR", "ON", |
| 135911 | 136450 | "INSERT", "DELETE", "UPDATE", "SET", |
| 135912 | 136451 | "DEFERRABLE", "FOREIGN", "DROP", "UNION", |
| 135913 | 136452 | "ALL", "EXCEPT", "INTERSECT", "SELECT", |
| | @@ -139502,11 +140041,11 @@ |
| 139502 | 140041 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 139503 | 140042 | sqlite3DbFree(db, pParse->pVList); |
| 139504 | 140043 | while( pParse->pAinc ){ |
| 139505 | 140044 | AutoincInfo *p = pParse->pAinc; |
| 139506 | 140045 | pParse->pAinc = p->pNext; |
| 139507 | | - sqlite3DbFree(db, p); |
| 140046 | + sqlite3DbFreeNN(db, p); |
| 139508 | 140047 | } |
| 139509 | 140048 | while( pParse->pZombieTab ){ |
| 139510 | 140049 | Table *p = pParse->pZombieTab; |
| 139511 | 140050 | pParse->pZombieTab = p->pNextZombie; |
| 139512 | 140051 | sqlite3DeleteTable(db, p); |
| | @@ -142996,20 +143535,22 @@ |
| 142996 | 143535 | sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0); |
| 142997 | 143536 | } |
| 142998 | 143537 | #endif |
| 142999 | 143538 | #if defined(SQLITE_HAS_CODEC) |
| 143000 | 143539 | if( rc==SQLITE_OK ){ |
| 143001 | | - const char *zHexKey = sqlite3_uri_parameter(zOpen, "hexkey"); |
| 143002 | | - if( zHexKey && zHexKey[0] ){ |
| 143540 | + const char *zKey; |
| 143541 | + if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){; |
| 143003 | 143542 | u8 iByte; |
| 143004 | 143543 | int i; |
| 143005 | | - char zKey[40]; |
| 143006 | | - for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zHexKey[i]); i++){ |
| 143007 | | - iByte = (iByte<<4) + sqlite3HexToInt(zHexKey[i]); |
| 143008 | | - if( (i&1)!=0 ) zKey[i/2] = iByte; |
| 143544 | + char zDecoded[40]; |
| 143545 | + for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){ |
| 143546 | + iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]); |
| 143547 | + if( (i&1)!=0 ) zDecoded[i/2] = iByte; |
| 143009 | 143548 | } |
| 143010 | | - sqlite3_key_v2(db, 0, zKey, i/2); |
| 143549 | + sqlite3_key_v2(db, 0, zDecoded, i/2); |
| 143550 | + }else if( (zKey = sqlite3_uri_parameter(zOpen, "key"))!=0 ){ |
| 143551 | + sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey)); |
| 143011 | 143552 | } |
| 143012 | 143553 | } |
| 143013 | 143554 | #endif |
| 143014 | 143555 | sqlite3_free(zOpen); |
| 143015 | 143556 | return rc & 0xff; |
| | @@ -145610,12 +146151,12 @@ |
| 145610 | 146151 | *v = b; |
| 145611 | 146152 | return (int)(p - pStart); |
| 145612 | 146153 | } |
| 145613 | 146154 | |
| 145614 | 146155 | /* |
| 145615 | | -** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a |
| 145616 | | -** 32-bit integer before it is returned. |
| 146156 | +** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to |
| 146157 | +** a non-negative 32-bit integer before it is returned. |
| 145617 | 146158 | */ |
| 145618 | 146159 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){ |
| 145619 | 146160 | u32 a; |
| 145620 | 146161 | |
| 145621 | 146162 | #ifndef fts3GetVarint32 |
| | @@ -145627,11 +146168,13 @@ |
| 145627 | 146168 | |
| 145628 | 146169 | GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *pi, 2); |
| 145629 | 146170 | GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3); |
| 145630 | 146171 | GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4); |
| 145631 | 146172 | a = (a & 0x0FFFFFFF ); |
| 145632 | | - *pi = (int)(a | ((u32)(*p & 0x0F) << 28)); |
| 146173 | + *pi = (int)(a | ((u32)(*p & 0x07) << 28)); |
| 146174 | + assert( 0==(a & 0x80000000) ); |
| 146175 | + assert( *pi>=0 ); |
| 145633 | 146176 | return 5; |
| 145634 | 146177 | } |
| 145635 | 146178 | |
| 145636 | 146179 | /* |
| 145637 | 146180 | ** Return the number of bytes required to encode v as a varint |
| | @@ -146457,69 +147000,70 @@ |
| 146457 | 147000 | struct Fts4Option *pOp = &aFts4Opt[iOpt]; |
| 146458 | 147001 | if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){ |
| 146459 | 147002 | break; |
| 146460 | 147003 | } |
| 146461 | 147004 | } |
| 146462 | | - if( iOpt==SizeofArray(aFts4Opt) ){ |
| 146463 | | - sqlite3Fts3ErrMsg(pzErr, "unrecognized parameter: %s", z); |
| 146464 | | - rc = SQLITE_ERROR; |
| 146465 | | - }else{ |
| 146466 | | - switch( iOpt ){ |
| 146467 | | - case 0: /* MATCHINFO */ |
| 146468 | | - if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){ |
| 146469 | | - sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo: %s", zVal); |
| 146470 | | - rc = SQLITE_ERROR; |
| 146471 | | - } |
| 146472 | | - bNoDocsize = 1; |
| 146473 | | - break; |
| 146474 | | - |
| 146475 | | - case 1: /* PREFIX */ |
| 146476 | | - sqlite3_free(zPrefix); |
| 146477 | | - zPrefix = zVal; |
| 146478 | | - zVal = 0; |
| 146479 | | - break; |
| 146480 | | - |
| 146481 | | - case 2: /* COMPRESS */ |
| 146482 | | - sqlite3_free(zCompress); |
| 146483 | | - zCompress = zVal; |
| 146484 | | - zVal = 0; |
| 146485 | | - break; |
| 146486 | | - |
| 146487 | | - case 3: /* UNCOMPRESS */ |
| 146488 | | - sqlite3_free(zUncompress); |
| 146489 | | - zUncompress = zVal; |
| 146490 | | - zVal = 0; |
| 146491 | | - break; |
| 146492 | | - |
| 146493 | | - case 4: /* ORDER */ |
| 146494 | | - if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3)) |
| 146495 | | - && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4)) |
| 146496 | | - ){ |
| 146497 | | - sqlite3Fts3ErrMsg(pzErr, "unrecognized order: %s", zVal); |
| 146498 | | - rc = SQLITE_ERROR; |
| 146499 | | - } |
| 146500 | | - bDescIdx = (zVal[0]=='d' || zVal[0]=='D'); |
| 146501 | | - break; |
| 146502 | | - |
| 146503 | | - case 5: /* CONTENT */ |
| 146504 | | - sqlite3_free(zContent); |
| 146505 | | - zContent = zVal; |
| 146506 | | - zVal = 0; |
| 146507 | | - break; |
| 146508 | | - |
| 146509 | | - case 6: /* LANGUAGEID */ |
| 146510 | | - assert( iOpt==6 ); |
| 146511 | | - sqlite3_free(zLanguageid); |
| 146512 | | - zLanguageid = zVal; |
| 146513 | | - zVal = 0; |
| 146514 | | - break; |
| 146515 | | - |
| 146516 | | - case 7: /* NOTINDEXED */ |
| 146517 | | - azNotindexed[nNotindexed++] = zVal; |
| 146518 | | - zVal = 0; |
| 146519 | | - break; |
| 146520 | | - } |
| 147005 | + switch( iOpt ){ |
| 147006 | + case 0: /* MATCHINFO */ |
| 147007 | + if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){ |
| 147008 | + sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo: %s", zVal); |
| 147009 | + rc = SQLITE_ERROR; |
| 147010 | + } |
| 147011 | + bNoDocsize = 1; |
| 147012 | + break; |
| 147013 | + |
| 147014 | + case 1: /* PREFIX */ |
| 147015 | + sqlite3_free(zPrefix); |
| 147016 | + zPrefix = zVal; |
| 147017 | + zVal = 0; |
| 147018 | + break; |
| 147019 | + |
| 147020 | + case 2: /* COMPRESS */ |
| 147021 | + sqlite3_free(zCompress); |
| 147022 | + zCompress = zVal; |
| 147023 | + zVal = 0; |
| 147024 | + break; |
| 147025 | + |
| 147026 | + case 3: /* UNCOMPRESS */ |
| 147027 | + sqlite3_free(zUncompress); |
| 147028 | + zUncompress = zVal; |
| 147029 | + zVal = 0; |
| 147030 | + break; |
| 147031 | + |
| 147032 | + case 4: /* ORDER */ |
| 147033 | + if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3)) |
| 147034 | + && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4)) |
| 147035 | + ){ |
| 147036 | + sqlite3Fts3ErrMsg(pzErr, "unrecognized order: %s", zVal); |
| 147037 | + rc = SQLITE_ERROR; |
| 147038 | + } |
| 147039 | + bDescIdx = (zVal[0]=='d' || zVal[0]=='D'); |
| 147040 | + break; |
| 147041 | + |
| 147042 | + case 5: /* CONTENT */ |
| 147043 | + sqlite3_free(zContent); |
| 147044 | + zContent = zVal; |
| 147045 | + zVal = 0; |
| 147046 | + break; |
| 147047 | + |
| 147048 | + case 6: /* LANGUAGEID */ |
| 147049 | + assert( iOpt==6 ); |
| 147050 | + sqlite3_free(zLanguageid); |
| 147051 | + zLanguageid = zVal; |
| 147052 | + zVal = 0; |
| 147053 | + break; |
| 147054 | + |
| 147055 | + case 7: /* NOTINDEXED */ |
| 147056 | + azNotindexed[nNotindexed++] = zVal; |
| 147057 | + zVal = 0; |
| 147058 | + break; |
| 147059 | + |
| 147060 | + default: |
| 147061 | + assert( iOpt==SizeofArray(aFts4Opt) ); |
| 147062 | + sqlite3Fts3ErrMsg(pzErr, "unrecognized parameter: %s", z); |
| 147063 | + rc = SQLITE_ERROR; |
| 147064 | + break; |
| 146521 | 147065 | } |
| 146522 | 147066 | sqlite3_free(zVal); |
| 146523 | 147067 | } |
| 146524 | 147068 | } |
| 146525 | 147069 | |
| | @@ -147084,11 +147628,12 @@ |
| 147084 | 147628 | zCsr += fts3GetVarint32(zCsr, &nPrefix); |
| 147085 | 147629 | } |
| 147086 | 147630 | isFirstTerm = 0; |
| 147087 | 147631 | zCsr += fts3GetVarint32(zCsr, &nSuffix); |
| 147088 | 147632 | |
| 147089 | | - if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){ |
| 147633 | + assert( nPrefix>=0 && nSuffix>=0 ); |
| 147634 | + if( &zCsr[nSuffix]>zEnd ){ |
| 147090 | 147635 | rc = FTS_CORRUPT_VTAB; |
| 147091 | 147636 | goto finish_scan; |
| 147092 | 147637 | } |
| 147093 | 147638 | if( nPrefix+nSuffix>nAlloc ){ |
| 147094 | 147639 | char *zNew; |
| | @@ -147894,11 +148439,11 @@ |
| 147894 | 148439 | bWritten = 1; |
| 147895 | 148440 | } |
| 147896 | 148441 | fts3ColumnlistCopy(0, &p); |
| 147897 | 148442 | } |
| 147898 | 148443 | |
| 147899 | | - while( p<pEnd && *p==0x01 ){ |
| 148444 | + while( p<pEnd ){ |
| 147900 | 148445 | sqlite3_int64 iCol; |
| 147901 | 148446 | p++; |
| 147902 | 148447 | p += sqlite3Fts3GetVarint(p, &iCol); |
| 147903 | 148448 | if( *p==0x02 ){ |
| 147904 | 148449 | if( bWritten==0 ){ |
| | @@ -148574,37 +149119,42 @@ |
| 148574 | 149119 | Fts3Table *p = (Fts3Table *)pCursor->pVtab; |
| 148575 | 149120 | |
| 148576 | 149121 | /* The column value supplied by SQLite must be in range. */ |
| 148577 | 149122 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 148578 | 149123 | |
| 148579 | | - if( iCol==p->nColumn+1 ){ |
| 148580 | | - /* This call is a request for the "docid" column. Since "docid" is an |
| 148581 | | - ** alias for "rowid", use the xRowid() method to obtain the value. |
| 148582 | | - */ |
| 148583 | | - sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| 148584 | | - }else if( iCol==p->nColumn ){ |
| 148585 | | - /* The extra column whose name is the same as the table. |
| 148586 | | - ** Return a blob which is a pointer to the cursor. */ |
| 148587 | | - sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT); |
| 148588 | | - }else if( iCol==p->nColumn+2 && pCsr->pExpr ){ |
| 148589 | | - sqlite3_result_int64(pCtx, pCsr->iLangid); |
| 148590 | | - }else{ |
| 148591 | | - /* The requested column is either a user column (one that contains |
| 148592 | | - ** indexed data), or the language-id column. */ |
| 148593 | | - rc = fts3CursorSeek(0, pCsr); |
| 148594 | | - |
| 148595 | | - if( rc==SQLITE_OK ){ |
| 148596 | | - if( iCol==p->nColumn+2 ){ |
| 148597 | | - int iLangid = 0; |
| 148598 | | - if( p->zLanguageid ){ |
| 148599 | | - iLangid = sqlite3_column_int(pCsr->pStmt, p->nColumn+1); |
| 148600 | | - } |
| 148601 | | - sqlite3_result_int(pCtx, iLangid); |
| 148602 | | - }else if( sqlite3_data_count(pCsr->pStmt)>(iCol+1) ){ |
| 149124 | + switch( iCol-p->nColumn ){ |
| 149125 | + case 0: |
| 149126 | + /* The special 'table-name' column */ |
| 149127 | + sqlite3_result_blob(pCtx, &pCsr, sizeof(Fts3Cursor*), SQLITE_TRANSIENT); |
| 149128 | + sqlite3_result_subtype(pCtx, SQLITE_BLOB); |
| 149129 | + break; |
| 149130 | + |
| 149131 | + case 1: |
| 149132 | + /* The docid column */ |
| 149133 | + sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| 149134 | + break; |
| 149135 | + |
| 149136 | + case 2: |
| 149137 | + if( pCsr->pExpr ){ |
| 149138 | + sqlite3_result_int64(pCtx, pCsr->iLangid); |
| 149139 | + break; |
| 149140 | + }else if( p->zLanguageid==0 ){ |
| 149141 | + sqlite3_result_int(pCtx, 0); |
| 149142 | + break; |
| 149143 | + }else{ |
| 149144 | + iCol = p->nColumn; |
| 149145 | + /* fall-through */ |
| 149146 | + } |
| 149147 | + |
| 149148 | + default: |
| 149149 | + /* A user column. Or, if this is a full-table scan, possibly the |
| 149150 | + ** language-id column. Seek the cursor. */ |
| 149151 | + rc = fts3CursorSeek(0, pCsr); |
| 149152 | + if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){ |
| 148603 | 149153 | sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); |
| 148604 | 149154 | } |
| 148605 | | - } |
| 149155 | + break; |
| 148606 | 149156 | } |
| 148607 | 149157 | |
| 148608 | 149158 | assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); |
| 148609 | 149159 | return rc; |
| 148610 | 149160 | } |
| | @@ -148680,21 +149230,15 @@ |
| 148680 | 149230 | ** if an error occurs. |
| 148681 | 149231 | */ |
| 148682 | 149232 | static int fts3SetHasStat(Fts3Table *p){ |
| 148683 | 149233 | int rc = SQLITE_OK; |
| 148684 | 149234 | if( p->bHasStat==2 ){ |
| 148685 | | - const char *zFmt ="SELECT 1 FROM %Q.sqlite_master WHERE tbl_name='%q_stat'"; |
| 148686 | | - char *zSql = sqlite3_mprintf(zFmt, p->zDb, p->zName); |
| 148687 | | - if( zSql ){ |
| 148688 | | - sqlite3_stmt *pStmt = 0; |
| 148689 | | - rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 148690 | | - if( rc==SQLITE_OK ){ |
| 148691 | | - int bHasStat = (sqlite3_step(pStmt)==SQLITE_ROW); |
| 148692 | | - rc = sqlite3_finalize(pStmt); |
| 148693 | | - if( rc==SQLITE_OK ) p->bHasStat = (u8)bHasStat; |
| 148694 | | - } |
| 148695 | | - sqlite3_free(zSql); |
| 149235 | + char *zTbl = sqlite3_mprintf("%s_stat", p->zName); |
| 149236 | + if( zTbl ){ |
| 149237 | + int res = sqlite3_table_column_metadata(p->db, p->zDb, zTbl, 0,0,0,0,0,0); |
| 149238 | + sqlite3_free(zTbl); |
| 149239 | + p->bHasStat = (res==SQLITE_OK); |
| 148696 | 149240 | }else{ |
| 148697 | 149241 | rc = SQLITE_NOMEM; |
| 148698 | 149242 | } |
| 148699 | 149243 | } |
| 148700 | 149244 | return rc; |
| | @@ -148797,22 +149341,20 @@ |
| 148797 | 149341 | sqlite3_context *pContext, /* SQL function call context */ |
| 148798 | 149342 | const char *zFunc, /* Function name */ |
| 148799 | 149343 | sqlite3_value *pVal, /* argv[0] passed to function */ |
| 148800 | 149344 | Fts3Cursor **ppCsr /* OUT: Store cursor handle here */ |
| 148801 | 149345 | ){ |
| 148802 | | - Fts3Cursor *pRet; |
| 148803 | | - if( sqlite3_value_type(pVal)!=SQLITE_BLOB |
| 148804 | | - || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *) |
| 148805 | | - ){ |
| 149346 | + int rc = SQLITE_OK; |
| 149347 | + if( sqlite3_value_subtype(pVal)==SQLITE_BLOB ){ |
| 149348 | + *ppCsr = *(Fts3Cursor**)sqlite3_value_blob(pVal); |
| 149349 | + }else{ |
| 148806 | 149350 | char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc); |
| 148807 | 149351 | sqlite3_result_error(pContext, zErr, -1); |
| 148808 | 149352 | sqlite3_free(zErr); |
| 148809 | | - return SQLITE_ERROR; |
| 149353 | + rc = SQLITE_ERROR; |
| 148810 | 149354 | } |
| 148811 | | - memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *)); |
| 148812 | | - *ppCsr = pRet; |
| 148813 | | - return SQLITE_OK; |
| 149355 | + return rc; |
| 148814 | 149356 | } |
| 148815 | 149357 | |
| 148816 | 149358 | /* |
| 148817 | 149359 | ** Implementation of the snippet() function for FTS3 |
| 148818 | 149360 | */ |
| | @@ -149195,11 +149737,11 @@ |
| 149195 | 149737 | rc = sqlite3Fts3ExprInitTestInterface(db); |
| 149196 | 149738 | } |
| 149197 | 149739 | #endif |
| 149198 | 149740 | |
| 149199 | 149741 | /* Create the virtual table wrapper around the hash-table and overload |
| 149200 | | - ** the two scalar functions. If this is successful, register the |
| 149742 | + ** the four scalar functions. If this is successful, register the |
| 149201 | 149743 | ** module with sqlite. |
| 149202 | 149744 | */ |
| 149203 | 149745 | if( SQLITE_OK==rc |
| 149204 | 149746 | && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer")) |
| 149205 | 149747 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) |
| | @@ -149778,11 +150320,11 @@ |
| 149778 | 150320 | |
| 149779 | 150321 | /* This is only called if it is guaranteed that the phrase has at least |
| 149780 | 150322 | ** one incremental token. In which case the bIncr flag is set. */ |
| 149781 | 150323 | assert( p->bIncr==1 ); |
| 149782 | 150324 | |
| 149783 | | - if( p->nToken==1 && p->bIncr ){ |
| 150325 | + if( p->nToken==1 ){ |
| 149784 | 150326 | rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr, |
| 149785 | 150327 | &pDL->iDocid, &pDL->pList, &pDL->nList |
| 149786 | 150328 | ); |
| 149787 | 150329 | if( pDL->pList==0 ) bEof = 1; |
| 149788 | 150330 | }else{ |
| | @@ -150011,10 +150553,11 @@ |
| 150011 | 150553 | ** of data that will fit on a single leaf page of an intkey table in |
| 150012 | 150554 | ** this database, then the average docsize is 1. Otherwise, it is 1 plus |
| 150013 | 150555 | ** the number of overflow pages consumed by a record B bytes in size. |
| 150014 | 150556 | */ |
| 150015 | 150557 | static int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){ |
| 150558 | + int rc = SQLITE_OK; |
| 150016 | 150559 | if( pCsr->nRowAvg==0 ){ |
| 150017 | 150560 | /* The average document size, which is required to calculate the cost |
| 150018 | 150561 | ** of each doclist, has not yet been determined. Read the required |
| 150019 | 150562 | ** data from the %_stat table to calculate it. |
| 150020 | 150563 | ** |
| | @@ -150023,11 +150566,10 @@ |
| 150023 | 150566 | ** The first varint is the number of documents currently stored in |
| 150024 | 150567 | ** the table. The following nCol varints contain the total amount of |
| 150025 | 150568 | ** data stored in all rows of each column of the table, from left |
| 150026 | 150569 | ** to right. |
| 150027 | 150570 | */ |
| 150028 | | - int rc; |
| 150029 | 150571 | Fts3Table *p = (Fts3Table*)pCsr->base.pVtab; |
| 150030 | 150572 | sqlite3_stmt *pStmt; |
| 150031 | 150573 | sqlite3_int64 nDoc = 0; |
| 150032 | 150574 | sqlite3_int64 nByte = 0; |
| 150033 | 150575 | const char *pEnd; |
| | @@ -150050,15 +150592,14 @@ |
| 150050 | 150592 | |
| 150051 | 150593 | pCsr->nDoc = nDoc; |
| 150052 | 150594 | pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz); |
| 150053 | 150595 | assert( pCsr->nRowAvg>0 ); |
| 150054 | 150596 | rc = sqlite3_reset(pStmt); |
| 150055 | | - if( rc!=SQLITE_OK ) return rc; |
| 150056 | 150597 | } |
| 150057 | 150598 | |
| 150058 | 150599 | *pnPage = pCsr->nRowAvg; |
| 150059 | | - return SQLITE_OK; |
| 150600 | + return rc; |
| 150060 | 150601 | } |
| 150061 | 150602 | |
| 150062 | 150603 | /* |
| 150063 | 150604 | ** This function is called to select the tokens (if any) that will be |
| 150064 | 150605 | ** deferred. The array aTC[] has already been populated when this is |
| | @@ -150404,11 +150945,12 @@ |
| 150404 | 150945 | } |
| 150405 | 150946 | } |
| 150406 | 150947 | pExpr->iDocid = pLeft->iDocid; |
| 150407 | 150948 | pExpr->bEof = (pLeft->bEof || pRight->bEof); |
| 150408 | 150949 | if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){ |
| 150409 | | - if( pRight->pPhrase && pRight->pPhrase->doclist.aAll ){ |
| 150950 | + assert( pRight->eType==FTSQUERY_PHRASE ); |
| 150951 | + if( pRight->pPhrase->doclist.aAll ){ |
| 150410 | 150952 | Fts3Doclist *pDl = &pRight->pPhrase->doclist; |
| 150411 | 150953 | while( *pRc==SQLITE_OK && pRight->bEof==0 ){ |
| 150412 | 150954 | memset(pDl->pList, 0, pDl->nList); |
| 150413 | 150955 | fts3EvalNextRow(pCsr, pRight, pRc); |
| 150414 | 150956 | } |
| | @@ -150433,11 +150975,11 @@ |
| 150433 | 150975 | assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid ); |
| 150434 | 150976 | assert( pRight->bStart || pLeft->iDocid==pRight->iDocid ); |
| 150435 | 150977 | |
| 150436 | 150978 | if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){ |
| 150437 | 150979 | fts3EvalNextRow(pCsr, pLeft, pRc); |
| 150438 | | - }else if( pLeft->bEof || (pRight->bEof==0 && iCmp>0) ){ |
| 150980 | + }else if( pLeft->bEof || iCmp>0 ){ |
| 150439 | 150981 | fts3EvalNextRow(pCsr, pRight, pRc); |
| 150440 | 150982 | }else{ |
| 150441 | 150983 | fts3EvalNextRow(pCsr, pLeft, pRc); |
| 150442 | 150984 | fts3EvalNextRow(pCsr, pRight, pRc); |
| 150443 | 150985 | } |
| | @@ -150525,55 +151067,51 @@ |
| 150525 | 151067 | ** left-hand child may be either a phrase or a NEAR node. There are |
| 150526 | 151068 | ** no exceptions to this - it's the way the parser in fts3_expr.c works. |
| 150527 | 151069 | */ |
| 150528 | 151070 | if( *pRc==SQLITE_OK |
| 150529 | 151071 | && pExpr->eType==FTSQUERY_NEAR |
| 150530 | | - && pExpr->bEof==0 |
| 150531 | 151072 | && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR) |
| 150532 | 151073 | ){ |
| 150533 | 151074 | Fts3Expr *p; |
| 150534 | 151075 | int nTmp = 0; /* Bytes of temp space */ |
| 150535 | 151076 | char *aTmp; /* Temp space for PoslistNearMerge() */ |
| 150536 | 151077 | |
| 150537 | 151078 | /* Allocate temporary working space. */ |
| 150538 | 151079 | for(p=pExpr; p->pLeft; p=p->pLeft){ |
| 151080 | + assert( p->pRight->pPhrase->doclist.nList>0 ); |
| 150539 | 151081 | nTmp += p->pRight->pPhrase->doclist.nList; |
| 150540 | 151082 | } |
| 150541 | 151083 | nTmp += p->pPhrase->doclist.nList; |
| 150542 | | - if( nTmp==0 ){ |
| 150543 | | - res = 0; |
| 150544 | | - }else{ |
| 150545 | | - aTmp = sqlite3_malloc(nTmp*2); |
| 150546 | | - if( !aTmp ){ |
| 150547 | | - *pRc = SQLITE_NOMEM; |
| 150548 | | - res = 0; |
| 150549 | | - }else{ |
| 150550 | | - char *aPoslist = p->pPhrase->doclist.pList; |
| 150551 | | - int nToken = p->pPhrase->nToken; |
| 150552 | | - |
| 150553 | | - for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){ |
| 150554 | | - Fts3Phrase *pPhrase = p->pRight->pPhrase; |
| 150555 | | - int nNear = p->nNear; |
| 150556 | | - res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 150557 | | - } |
| 150558 | | - |
| 150559 | | - aPoslist = pExpr->pRight->pPhrase->doclist.pList; |
| 150560 | | - nToken = pExpr->pRight->pPhrase->nToken; |
| 150561 | | - for(p=pExpr->pLeft; p && res; p=p->pLeft){ |
| 150562 | | - int nNear; |
| 150563 | | - Fts3Phrase *pPhrase; |
| 150564 | | - assert( p->pParent && p->pParent->pLeft==p ); |
| 150565 | | - nNear = p->pParent->nNear; |
| 150566 | | - pPhrase = ( |
| 150567 | | - p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase |
| 150568 | | - ); |
| 150569 | | - res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 150570 | | - } |
| 150571 | | - } |
| 150572 | | - |
| 150573 | | - sqlite3_free(aTmp); |
| 150574 | | - } |
| 151084 | + aTmp = sqlite3_malloc(nTmp*2); |
| 151085 | + if( !aTmp ){ |
| 151086 | + *pRc = SQLITE_NOMEM; |
| 151087 | + res = 0; |
| 151088 | + }else{ |
| 151089 | + char *aPoslist = p->pPhrase->doclist.pList; |
| 151090 | + int nToken = p->pPhrase->nToken; |
| 151091 | + |
| 151092 | + for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){ |
| 151093 | + Fts3Phrase *pPhrase = p->pRight->pPhrase; |
| 151094 | + int nNear = p->nNear; |
| 151095 | + res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 151096 | + } |
| 151097 | + |
| 151098 | + aPoslist = pExpr->pRight->pPhrase->doclist.pList; |
| 151099 | + nToken = pExpr->pRight->pPhrase->nToken; |
| 151100 | + for(p=pExpr->pLeft; p && res; p=p->pLeft){ |
| 151101 | + int nNear; |
| 151102 | + Fts3Phrase *pPhrase; |
| 151103 | + assert( p->pParent && p->pParent->pLeft==p ); |
| 151104 | + nNear = p->pParent->nNear; |
| 151105 | + pPhrase = ( |
| 151106 | + p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase |
| 151107 | + ); |
| 151108 | + res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 151109 | + } |
| 151110 | + } |
| 151111 | + |
| 151112 | + sqlite3_free(aTmp); |
| 150575 | 151113 | } |
| 150576 | 151114 | |
| 150577 | 151115 | return res; |
| 150578 | 151116 | } |
| 150579 | 151117 | |
| | @@ -166676,16 +167214,40 @@ |
| 166676 | 167214 | , pRtree->zDb, pRtree->zName, zNewName |
| 166677 | 167215 | , pRtree->zDb, pRtree->zName, zNewName |
| 166678 | 167216 | , pRtree->zDb, pRtree->zName, zNewName |
| 166679 | 167217 | ); |
| 166680 | 167218 | if( zSql ){ |
| 167219 | + nodeBlobReset(pRtree); |
| 166681 | 167220 | rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0); |
| 166682 | 167221 | sqlite3_free(zSql); |
| 166683 | 167222 | } |
| 166684 | 167223 | return rc; |
| 166685 | 167224 | } |
| 166686 | 167225 | |
| 167226 | +/* |
| 167227 | +** The xSavepoint method. |
| 167228 | +** |
| 167229 | +** This module does not need to do anything to support savepoints. However, |
| 167230 | +** it uses this hook to close any open blob handle. This is done because a |
| 167231 | +** DROP TABLE command - which fortunately always opens a savepoint - cannot |
| 167232 | +** succeed if there are any open blob handles. i.e. if the blob handle were |
| 167233 | +** not closed here, the following would fail: |
| 167234 | +** |
| 167235 | +** BEGIN; |
| 167236 | +** INSERT INTO rtree... |
| 167237 | +** DROP TABLE <tablename>; -- Would fail with SQLITE_LOCKED |
| 167238 | +** COMMIT; |
| 167239 | +*/ |
| 167240 | +static int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){ |
| 167241 | + Rtree *pRtree = (Rtree *)pVtab; |
| 167242 | + int iwt = pRtree->inWrTrans; |
| 167243 | + UNUSED_PARAMETER(iSavepoint); |
| 167244 | + pRtree->inWrTrans = 0; |
| 167245 | + nodeBlobReset(pRtree); |
| 167246 | + pRtree->inWrTrans = iwt; |
| 167247 | + return SQLITE_OK; |
| 167248 | +} |
| 166687 | 167249 | |
| 166688 | 167250 | /* |
| 166689 | 167251 | ** This function populates the pRtree->nRowEst variable with an estimate |
| 166690 | 167252 | ** of the number of rows in the virtual table. If possible, this is based |
| 166691 | 167253 | ** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST. |
| | @@ -166728,11 +167290,11 @@ |
| 166728 | 167290 | |
| 166729 | 167291 | return rc; |
| 166730 | 167292 | } |
| 166731 | 167293 | |
| 166732 | 167294 | static sqlite3_module rtreeModule = { |
| 166733 | | - 0, /* iVersion */ |
| 167295 | + 2, /* iVersion */ |
| 166734 | 167296 | rtreeCreate, /* xCreate - create a table */ |
| 166735 | 167297 | rtreeConnect, /* xConnect - connect to an existing table */ |
| 166736 | 167298 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ |
| 166737 | 167299 | rtreeDisconnect, /* xDisconnect - Disconnect from a table */ |
| 166738 | 167300 | rtreeDestroy, /* xDestroy - Drop a table */ |
| | @@ -166748,11 +167310,11 @@ |
| 166748 | 167310 | rtreeEndTransaction, /* xSync - sync transaction */ |
| 166749 | 167311 | rtreeEndTransaction, /* xCommit - commit transaction */ |
| 166750 | 167312 | rtreeEndTransaction, /* xRollback - rollback transaction */ |
| 166751 | 167313 | 0, /* xFindFunction - function overloading */ |
| 166752 | 167314 | rtreeRename, /* xRename - rename the table */ |
| 166753 | | - 0, /* xSavepoint */ |
| 167315 | + rtreeSavepoint, /* xSavepoint */ |
| 166754 | 167316 | 0, /* xRelease */ |
| 166755 | 167317 | 0, /* xRollbackTo */ |
| 166756 | 167318 | }; |
| 166757 | 167319 | |
| 166758 | 167320 | static int rtreeSqlInit( |
| | @@ -178905,10 +179467,11 @@ |
| 178905 | 179467 | #ifndef SQLITE_AMALGAMATION |
| 178906 | 179468 | /* Unsigned integer types. These are already defined in the sqliteInt.h, |
| 178907 | 179469 | ** but the definitions need to be repeated for separate compilation. */ |
| 178908 | 179470 | typedef sqlite3_uint64 u64; |
| 178909 | 179471 | typedef unsigned int u32; |
| 179472 | + typedef unsigned short int u16; |
| 178910 | 179473 | typedef unsigned char u8; |
| 178911 | 179474 | #endif |
| 178912 | 179475 | |
| 178913 | 179476 | /* Objects */ |
| 178914 | 179477 | typedef struct JsonString JsonString; |
| | @@ -178984,12 +179547,23 @@ |
| 178984 | 179547 | JsonNode *aNode; /* Array of nodes containing the parse */ |
| 178985 | 179548 | const char *zJson; /* Original JSON string */ |
| 178986 | 179549 | u32 *aUp; /* Index of parent of each node */ |
| 178987 | 179550 | u8 oom; /* Set to true if out of memory */ |
| 178988 | 179551 | u8 nErr; /* Number of errors seen */ |
| 179552 | + u16 iDepth; /* Nesting depth */ |
| 179553 | + int nJson; /* Length of the zJson string in bytes */ |
| 178989 | 179554 | }; |
| 178990 | 179555 | |
| 179556 | +/* |
| 179557 | +** Maximum nesting depth of JSON for this implementation. |
| 179558 | +** |
| 179559 | +** This limit is needed to avoid a stack overflow in the recursive |
| 179560 | +** descent parser. A depth of 2000 is far deeper than any sane JSON |
| 179561 | +** should go. |
| 179562 | +*/ |
| 179563 | +#define JSON_MAX_DEPTH 2000 |
| 179564 | + |
| 178991 | 179565 | /************************************************************************** |
| 178992 | 179566 | ** Utility routines for dealing with JsonString objects |
| 178993 | 179567 | **************************************************************************/ |
| 178994 | 179568 | |
| 178995 | 179569 | /* Set the JsonString object to an empty string |
| | @@ -179216,10 +179790,18 @@ |
| 179216 | 179790 | pParse->nNode = 0; |
| 179217 | 179791 | pParse->nAlloc = 0; |
| 179218 | 179792 | sqlite3_free(pParse->aUp); |
| 179219 | 179793 | pParse->aUp = 0; |
| 179220 | 179794 | } |
| 179795 | + |
| 179796 | +/* |
| 179797 | +** Free a JsonParse object that was obtained from sqlite3_malloc(). |
| 179798 | +*/ |
| 179799 | +static void jsonParseFree(JsonParse *pParse){ |
| 179800 | + jsonParseReset(pParse); |
| 179801 | + sqlite3_free(pParse); |
| 179802 | +} |
| 179221 | 179803 | |
| 179222 | 179804 | /* |
| 179223 | 179805 | ** Convert the JsonNode pNode into a pure JSON string and |
| 179224 | 179806 | ** append to pOut. Subsubstructure is also included. Return |
| 179225 | 179807 | ** the number of JsonNode objects that are encoded. |
| | @@ -179542,35 +180124,39 @@ |
| 179542 | 180124 | char c; |
| 179543 | 180125 | u32 j; |
| 179544 | 180126 | int iThis; |
| 179545 | 180127 | int x; |
| 179546 | 180128 | JsonNode *pNode; |
| 179547 | | - while( safe_isspace(pParse->zJson[i]) ){ i++; } |
| 179548 | | - if( (c = pParse->zJson[i])=='{' ){ |
| 180129 | + const char *z = pParse->zJson; |
| 180130 | + while( safe_isspace(z[i]) ){ i++; } |
| 180131 | + if( (c = z[i])=='{' ){ |
| 179549 | 180132 | /* Parse object */ |
| 179550 | 180133 | iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); |
| 179551 | 180134 | if( iThis<0 ) return -1; |
| 179552 | 180135 | for(j=i+1;;j++){ |
| 179553 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 180136 | + while( safe_isspace(z[j]) ){ j++; } |
| 180137 | + if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| 179554 | 180138 | x = jsonParseValue(pParse, j); |
| 179555 | 180139 | if( x<0 ){ |
| 180140 | + pParse->iDepth--; |
| 179556 | 180141 | if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; |
| 179557 | 180142 | return -1; |
| 179558 | 180143 | } |
| 179559 | 180144 | if( pParse->oom ) return -1; |
| 179560 | 180145 | pNode = &pParse->aNode[pParse->nNode-1]; |
| 179561 | 180146 | if( pNode->eType!=JSON_STRING ) return -1; |
| 179562 | 180147 | pNode->jnFlags |= JNODE_LABEL; |
| 179563 | 180148 | j = x; |
| 179564 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 179565 | | - if( pParse->zJson[j]!=':' ) return -1; |
| 180149 | + while( safe_isspace(z[j]) ){ j++; } |
| 180150 | + if( z[j]!=':' ) return -1; |
| 179566 | 180151 | j++; |
| 179567 | 180152 | x = jsonParseValue(pParse, j); |
| 180153 | + pParse->iDepth--; |
| 179568 | 180154 | if( x<0 ) return -1; |
| 179569 | 180155 | j = x; |
| 179570 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 179571 | | - c = pParse->zJson[j]; |
| 180156 | + while( safe_isspace(z[j]) ){ j++; } |
| 180157 | + c = z[j]; |
| 179572 | 180158 | if( c==',' ) continue; |
| 179573 | 180159 | if( c!='}' ) return -1; |
| 179574 | 180160 | break; |
| 179575 | 180161 | } |
| 179576 | 180162 | pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; |
| | @@ -179578,19 +180164,21 @@ |
| 179578 | 180164 | }else if( c=='[' ){ |
| 179579 | 180165 | /* Parse array */ |
| 179580 | 180166 | iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); |
| 179581 | 180167 | if( iThis<0 ) return -1; |
| 179582 | 180168 | for(j=i+1;;j++){ |
| 179583 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 180169 | + while( safe_isspace(z[j]) ){ j++; } |
| 180170 | + if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| 179584 | 180171 | x = jsonParseValue(pParse, j); |
| 180172 | + pParse->iDepth--; |
| 179585 | 180173 | if( x<0 ){ |
| 179586 | 180174 | if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; |
| 179587 | 180175 | return -1; |
| 179588 | 180176 | } |
| 179589 | 180177 | j = x; |
| 179590 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 179591 | | - c = pParse->zJson[j]; |
| 180178 | + while( safe_isspace(z[j]) ){ j++; } |
| 180179 | + c = z[j]; |
| 179592 | 180180 | if( c==',' ) continue; |
| 179593 | 180181 | if( c!=']' ) return -1; |
| 179594 | 180182 | break; |
| 179595 | 180183 | } |
| 179596 | 180184 | pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; |
| | @@ -179598,75 +180186,83 @@ |
| 179598 | 180186 | }else if( c=='"' ){ |
| 179599 | 180187 | /* Parse string */ |
| 179600 | 180188 | u8 jnFlags = 0; |
| 179601 | 180189 | j = i+1; |
| 179602 | 180190 | for(;;){ |
| 179603 | | - c = pParse->zJson[j]; |
| 179604 | | - if( c==0 ) return -1; |
| 180191 | + c = z[j]; |
| 180192 | + if( (c & ~0x1f)==0 ){ |
| 180193 | + /* Control characters are not allowed in strings */ |
| 180194 | + return -1; |
| 180195 | + } |
| 179605 | 180196 | if( c=='\\' ){ |
| 179606 | | - c = pParse->zJson[++j]; |
| 180197 | + c = z[++j]; |
| 179607 | 180198 | if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' |
| 179608 | 180199 | || c=='n' || c=='r' || c=='t' |
| 179609 | | - || (c=='u' && jsonIs4Hex(pParse->zJson+j+1)) ){ |
| 180200 | + || (c=='u' && jsonIs4Hex(z+j+1)) ){ |
| 179610 | 180201 | jnFlags = JNODE_ESCAPE; |
| 179611 | 180202 | }else{ |
| 179612 | 180203 | return -1; |
| 179613 | 180204 | } |
| 179614 | 180205 | }else if( c=='"' ){ |
| 179615 | 180206 | break; |
| 179616 | 180207 | } |
| 179617 | 180208 | j++; |
| 179618 | 180209 | } |
| 179619 | | - jsonParseAddNode(pParse, JSON_STRING, j+1-i, &pParse->zJson[i]); |
| 180210 | + jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]); |
| 179620 | 180211 | if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags; |
| 179621 | 180212 | return j+1; |
| 179622 | 180213 | }else if( c=='n' |
| 179623 | | - && strncmp(pParse->zJson+i,"null",4)==0 |
| 179624 | | - && !safe_isalnum(pParse->zJson[i+4]) ){ |
| 180214 | + && strncmp(z+i,"null",4)==0 |
| 180215 | + && !safe_isalnum(z[i+4]) ){ |
| 179625 | 180216 | jsonParseAddNode(pParse, JSON_NULL, 0, 0); |
| 179626 | 180217 | return i+4; |
| 179627 | 180218 | }else if( c=='t' |
| 179628 | | - && strncmp(pParse->zJson+i,"true",4)==0 |
| 179629 | | - && !safe_isalnum(pParse->zJson[i+4]) ){ |
| 180219 | + && strncmp(z+i,"true",4)==0 |
| 180220 | + && !safe_isalnum(z[i+4]) ){ |
| 179630 | 180221 | jsonParseAddNode(pParse, JSON_TRUE, 0, 0); |
| 179631 | 180222 | return i+4; |
| 179632 | 180223 | }else if( c=='f' |
| 179633 | | - && strncmp(pParse->zJson+i,"false",5)==0 |
| 179634 | | - && !safe_isalnum(pParse->zJson[i+5]) ){ |
| 180224 | + && strncmp(z+i,"false",5)==0 |
| 180225 | + && !safe_isalnum(z[i+5]) ){ |
| 179635 | 180226 | jsonParseAddNode(pParse, JSON_FALSE, 0, 0); |
| 179636 | 180227 | return i+5; |
| 179637 | 180228 | }else if( c=='-' || (c>='0' && c<='9') ){ |
| 179638 | 180229 | /* Parse number */ |
| 179639 | 180230 | u8 seenDP = 0; |
| 179640 | 180231 | u8 seenE = 0; |
| 180232 | + assert( '-' < '0' ); |
| 180233 | + if( c<='0' ){ |
| 180234 | + j = c=='-' ? i+1 : i; |
| 180235 | + if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1; |
| 180236 | + } |
| 179641 | 180237 | j = i+1; |
| 179642 | 180238 | for(;; j++){ |
| 179643 | | - c = pParse->zJson[j]; |
| 180239 | + c = z[j]; |
| 179644 | 180240 | if( c>='0' && c<='9' ) continue; |
| 179645 | 180241 | if( c=='.' ){ |
| 179646 | | - if( pParse->zJson[j-1]=='-' ) return -1; |
| 180242 | + if( z[j-1]=='-' ) return -1; |
| 179647 | 180243 | if( seenDP ) return -1; |
| 179648 | 180244 | seenDP = 1; |
| 179649 | 180245 | continue; |
| 179650 | 180246 | } |
| 179651 | 180247 | if( c=='e' || c=='E' ){ |
| 179652 | | - if( pParse->zJson[j-1]<'0' ) return -1; |
| 180248 | + if( z[j-1]<'0' ) return -1; |
| 179653 | 180249 | if( seenE ) return -1; |
| 179654 | 180250 | seenDP = seenE = 1; |
| 179655 | | - c = pParse->zJson[j+1]; |
| 180251 | + c = z[j+1]; |
| 179656 | 180252 | if( c=='+' || c=='-' ){ |
| 179657 | 180253 | j++; |
| 179658 | | - c = pParse->zJson[j+1]; |
| 180254 | + c = z[j+1]; |
| 179659 | 180255 | } |
| 179660 | 180256 | if( c<'0' || c>'9' ) return -1; |
| 179661 | 180257 | continue; |
| 179662 | 180258 | } |
| 179663 | 180259 | break; |
| 179664 | 180260 | } |
| 179665 | | - if( pParse->zJson[j-1]<'0' ) return -1; |
| 180261 | + if( z[j-1]<'0' ) return -1; |
| 179666 | 180262 | jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT, |
| 179667 | | - j - i, &pParse->zJson[i]); |
| 180263 | + j - i, &z[i]); |
| 179668 | 180264 | return j; |
| 179669 | 180265 | }else if( c=='}' ){ |
| 179670 | 180266 | return -2; /* End of {...} */ |
| 179671 | 180267 | }else if( c==']' ){ |
| 179672 | 180268 | return -3; /* End of [...] */ |
| | @@ -179694,10 +180290,11 @@ |
| 179694 | 180290 | if( zJson==0 ) return 1; |
| 179695 | 180291 | pParse->zJson = zJson; |
| 179696 | 180292 | i = jsonParseValue(pParse, 0); |
| 179697 | 180293 | if( pParse->oom ) i = -1; |
| 179698 | 180294 | if( i>0 ){ |
| 180295 | + assert( pParse->iDepth==0 ); |
| 179699 | 180296 | while( safe_isspace(zJson[i]) ) i++; |
| 179700 | 180297 | if( zJson[i] ) i = -1; |
| 179701 | 180298 | } |
| 179702 | 180299 | if( i<=0 ){ |
| 179703 | 180300 | if( pCtx!=0 ){ |
| | @@ -179752,10 +180349,53 @@ |
| 179752 | 180349 | return SQLITE_NOMEM; |
| 179753 | 180350 | } |
| 179754 | 180351 | jsonParseFillInParentage(pParse, 0, 0); |
| 179755 | 180352 | return SQLITE_OK; |
| 179756 | 180353 | } |
| 180354 | + |
| 180355 | +/* |
| 180356 | +** Magic number used for the JSON parse cache in sqlite3_get_auxdata() |
| 180357 | +*/ |
| 180358 | +#define JSON_CACHE_ID (-429938) |
| 180359 | + |
| 180360 | +/* |
| 180361 | +** Obtain a complete parse of the JSON found in the first argument |
| 180362 | +** of the argv array. Use the sqlite3_get_auxdata() cache for this |
| 180363 | +** parse if it is available. If the cache is not available or if it |
| 180364 | +** is no longer valid, parse the JSON again and return the new parse, |
| 180365 | +** and also register the new parse so that it will be available for |
| 180366 | +** future sqlite3_get_auxdata() calls. |
| 180367 | +*/ |
| 180368 | +static JsonParse *jsonParseCached( |
| 180369 | + sqlite3_context *pCtx, |
| 180370 | + sqlite3_value **argv |
| 180371 | +){ |
| 180372 | + const char *zJson = (const char*)sqlite3_value_text(argv[0]); |
| 180373 | + int nJson = sqlite3_value_bytes(argv[0]); |
| 180374 | + JsonParse *p; |
| 180375 | + if( zJson==0 ) return 0; |
| 180376 | + p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID); |
| 180377 | + if( p && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){ |
| 180378 | + p->nErr = 0; |
| 180379 | + return p; /* The cached entry matches, so return it */ |
| 180380 | + } |
| 180381 | + p = sqlite3_malloc( sizeof(*p) + nJson + 1 ); |
| 180382 | + if( p==0 ){ |
| 180383 | + sqlite3_result_error_nomem(pCtx); |
| 180384 | + return 0; |
| 180385 | + } |
| 180386 | + memset(p, 0, sizeof(*p)); |
| 180387 | + p->zJson = (char*)&p[1]; |
| 180388 | + memcpy((char*)p->zJson, zJson, nJson+1); |
| 180389 | + if( jsonParse(p, pCtx, p->zJson) ){ |
| 180390 | + sqlite3_free(p); |
| 180391 | + return 0; |
| 180392 | + } |
| 180393 | + p->nJson = nJson; |
| 180394 | + sqlite3_set_auxdata(pCtx, JSON_CACHE_ID, p, (void(*)(void*))jsonParseFree); |
| 180395 | + return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID); |
| 180396 | +} |
| 179757 | 180397 | |
| 179758 | 180398 | /* |
| 179759 | 180399 | ** Compare the OBJECT label at pNode against zKey,nKey. Return true on |
| 179760 | 180400 | ** a match. |
| 179761 | 180401 | */ |
| | @@ -180118,33 +180758,34 @@ |
| 180118 | 180758 | static void jsonArrayLengthFunc( |
| 180119 | 180759 | sqlite3_context *ctx, |
| 180120 | 180760 | int argc, |
| 180121 | 180761 | sqlite3_value **argv |
| 180122 | 180762 | ){ |
| 180123 | | - JsonParse x; /* The parse */ |
| 180763 | + JsonParse *p; /* The parse */ |
| 180124 | 180764 | sqlite3_int64 n = 0; |
| 180125 | 180765 | u32 i; |
| 180126 | 180766 | JsonNode *pNode; |
| 180127 | 180767 | |
| 180128 | | - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; |
| 180129 | | - assert( x.nNode ); |
| 180768 | + p = jsonParseCached(ctx, argv); |
| 180769 | + if( p==0 ) return; |
| 180770 | + assert( p->nNode ); |
| 180130 | 180771 | if( argc==2 ){ |
| 180131 | 180772 | const char *zPath = (const char*)sqlite3_value_text(argv[1]); |
| 180132 | | - pNode = jsonLookup(&x, zPath, 0, ctx); |
| 180773 | + pNode = jsonLookup(p, zPath, 0, ctx); |
| 180133 | 180774 | }else{ |
| 180134 | | - pNode = x.aNode; |
| 180775 | + pNode = p->aNode; |
| 180135 | 180776 | } |
| 180136 | 180777 | if( pNode==0 ){ |
| 180137 | | - x.nErr = 1; |
| 180138 | | - }else if( pNode->eType==JSON_ARRAY ){ |
| 180778 | + return; |
| 180779 | + } |
| 180780 | + if( pNode->eType==JSON_ARRAY ){ |
| 180139 | 180781 | assert( (pNode->jnFlags & JNODE_APPEND)==0 ); |
| 180140 | 180782 | for(i=1; i<=pNode->n; n++){ |
| 180141 | 180783 | i += jsonNodeSize(&pNode[i]); |
| 180142 | 180784 | } |
| 180143 | 180785 | } |
| 180144 | | - if( x.nErr==0 ) sqlite3_result_int64(ctx, n); |
| 180145 | | - jsonParseReset(&x); |
| 180786 | + sqlite3_result_int64(ctx, n); |
| 180146 | 180787 | } |
| 180147 | 180788 | |
| 180148 | 180789 | /* |
| 180149 | 180790 | ** json_extract(JSON, PATH, ...) |
| 180150 | 180791 | ** |
| | @@ -180156,24 +180797,25 @@ |
| 180156 | 180797 | static void jsonExtractFunc( |
| 180157 | 180798 | sqlite3_context *ctx, |
| 180158 | 180799 | int argc, |
| 180159 | 180800 | sqlite3_value **argv |
| 180160 | 180801 | ){ |
| 180161 | | - JsonParse x; /* The parse */ |
| 180802 | + JsonParse *p; /* The parse */ |
| 180162 | 180803 | JsonNode *pNode; |
| 180163 | 180804 | const char *zPath; |
| 180164 | 180805 | JsonString jx; |
| 180165 | 180806 | int i; |
| 180166 | 180807 | |
| 180167 | 180808 | if( argc<2 ) return; |
| 180168 | | - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; |
| 180809 | + p = jsonParseCached(ctx, argv); |
| 180810 | + if( p==0 ) return; |
| 180169 | 180811 | jsonInit(&jx, ctx); |
| 180170 | 180812 | jsonAppendChar(&jx, '['); |
| 180171 | 180813 | for(i=1; i<argc; i++){ |
| 180172 | 180814 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 180173 | | - pNode = jsonLookup(&x, zPath, 0, ctx); |
| 180174 | | - if( x.nErr ) break; |
| 180815 | + pNode = jsonLookup(p, zPath, 0, ctx); |
| 180816 | + if( p->nErr ) break; |
| 180175 | 180817 | if( argc>2 ){ |
| 180176 | 180818 | jsonAppendSeparator(&jx); |
| 180177 | 180819 | if( pNode ){ |
| 180178 | 180820 | jsonRenderNode(pNode, &jx, 0); |
| 180179 | 180821 | }else{ |
| | @@ -180187,18 +180829,17 @@ |
| 180187 | 180829 | jsonAppendChar(&jx, ']'); |
| 180188 | 180830 | jsonResult(&jx); |
| 180189 | 180831 | sqlite3_result_subtype(ctx, JSON_SUBTYPE); |
| 180190 | 180832 | } |
| 180191 | 180833 | jsonReset(&jx); |
| 180192 | | - jsonParseReset(&x); |
| 180193 | 180834 | } |
| 180194 | 180835 | |
| 180195 | 180836 | /* This is the RFC 7396 MergePatch algorithm. |
| 180196 | 180837 | */ |
| 180197 | 180838 | static JsonNode *jsonMergePatch( |
| 180198 | 180839 | JsonParse *pParse, /* The JSON parser that contains the TARGET */ |
| 180199 | | - int iTarget, /* Node of the TARGET in pParse */ |
| 180840 | + u32 iTarget, /* Node of the TARGET in pParse */ |
| 180200 | 180841 | JsonNode *pPatch /* The PATCH */ |
| 180201 | 180842 | ){ |
| 180202 | 180843 | u32 i, j; |
| 180203 | 180844 | u32 iRoot; |
| 180204 | 180845 | JsonNode *pTarget; |
| | @@ -182203,13 +182844,13 @@ |
| 182203 | 182844 | i64 iDocid /* Docid to add or remove data from */ |
| 182204 | 182845 | ); |
| 182205 | 182846 | |
| 182206 | 182847 | /* |
| 182207 | 182848 | ** Flush any data stored in the in-memory hash tables to the database. |
| 182208 | | -** If the bCommit flag is true, also close any open blob handles. |
| 182849 | +** Also close any open blob handles. |
| 182209 | 182850 | */ |
| 182210 | | -static int sqlite3Fts5IndexSync(Fts5Index *p, int bCommit); |
| 182851 | +static int sqlite3Fts5IndexSync(Fts5Index *p); |
| 182211 | 182852 | |
| 182212 | 182853 | /* |
| 182213 | 182854 | ** Discard any data stored in the in-memory hash tables. Do not write it |
| 182214 | 182855 | ** to the database. Additionally, assume that the contents of the %_data |
| 182215 | 182856 | ** table may have changed on disk. So any in-memory caches of %_data |
| | @@ -182375,11 +183016,11 @@ |
| 182375 | 183016 | |
| 182376 | 183017 | static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol); |
| 182377 | 183018 | static int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg); |
| 182378 | 183019 | static int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow); |
| 182379 | 183020 | |
| 182380 | | -static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit); |
| 183021 | +static int sqlite3Fts5StorageSync(Fts5Storage *p); |
| 182381 | 183022 | static int sqlite3Fts5StorageRollback(Fts5Storage *p); |
| 182382 | 183023 | |
| 182383 | 183024 | static int sqlite3Fts5StorageConfigValue( |
| 182384 | 183025 | Fts5Storage *p, const char*, sqlite3_value*, int |
| 182385 | 183026 | ); |
| | @@ -182411,10 +183052,11 @@ |
| 182411 | 183052 | }; |
| 182412 | 183053 | |
| 182413 | 183054 | /* Parse a MATCH expression. */ |
| 182414 | 183055 | static int sqlite3Fts5ExprNew( |
| 182415 | 183056 | Fts5Config *pConfig, |
| 183057 | + int iCol, /* Column on LHS of MATCH operator */ |
| 182416 | 183058 | const char *zExpr, |
| 182417 | 183059 | Fts5Expr **ppNew, |
| 182418 | 183060 | char **pzErr |
| 182419 | 183061 | ); |
| 182420 | 183062 | |
| | @@ -182495,11 +183137,11 @@ |
| 182495 | 183137 | static void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*); |
| 182496 | 183138 | static void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*); |
| 182497 | 183139 | static void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); |
| 182498 | 183140 | |
| 182499 | 183141 | static void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); |
| 182500 | | -static void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); |
| 183142 | +static void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNode*, Fts5Colset*); |
| 182501 | 183143 | static Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); |
| 182502 | 183144 | static void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); |
| 182503 | 183145 | static void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); |
| 182504 | 183146 | |
| 182505 | 183147 | /* |
| | @@ -182552,16 +183194,16 @@ |
| 182552 | 183194 | #define FTS5_OR 1 |
| 182553 | 183195 | #define FTS5_AND 2 |
| 182554 | 183196 | #define FTS5_NOT 3 |
| 182555 | 183197 | #define FTS5_TERM 4 |
| 182556 | 183198 | #define FTS5_COLON 5 |
| 182557 | | -#define FTS5_LP 6 |
| 182558 | | -#define FTS5_RP 7 |
| 182559 | | -#define FTS5_MINUS 8 |
| 182560 | | -#define FTS5_LCP 9 |
| 182561 | | -#define FTS5_RCP 10 |
| 182562 | | -#define FTS5_STRING 11 |
| 183199 | +#define FTS5_MINUS 6 |
| 183200 | +#define FTS5_LCP 7 |
| 183201 | +#define FTS5_RCP 8 |
| 183202 | +#define FTS5_STRING 9 |
| 183203 | +#define FTS5_LP 10 |
| 183204 | +#define FTS5_RP 11 |
| 182563 | 183205 | #define FTS5_COMMA 12 |
| 182564 | 183206 | #define FTS5_PLUS 13 |
| 182565 | 183207 | #define FTS5_STAR 14 |
| 182566 | 183208 | |
| 182567 | 183209 | /* |
| | @@ -182693,20 +183335,20 @@ |
| 182693 | 183335 | #endif |
| 182694 | 183336 | #define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse; |
| 182695 | 183337 | #define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse |
| 182696 | 183338 | #define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse = fts5yypParser->pParse |
| 182697 | 183339 | #define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse = pParse |
| 182698 | | -#define fts5YYNSTATE 29 |
| 182699 | | -#define fts5YYNRULE 26 |
| 182700 | | -#define fts5YY_MAX_SHIFT 28 |
| 182701 | | -#define fts5YY_MIN_SHIFTREDUCE 45 |
| 182702 | | -#define fts5YY_MAX_SHIFTREDUCE 70 |
| 182703 | | -#define fts5YY_MIN_REDUCE 71 |
| 182704 | | -#define fts5YY_MAX_REDUCE 96 |
| 182705 | | -#define fts5YY_ERROR_ACTION 97 |
| 182706 | | -#define fts5YY_ACCEPT_ACTION 98 |
| 182707 | | -#define fts5YY_NO_ACTION 99 |
| 183340 | +#define fts5YYNSTATE 33 |
| 183341 | +#define fts5YYNRULE 27 |
| 183342 | +#define fts5YY_MAX_SHIFT 32 |
| 183343 | +#define fts5YY_MIN_SHIFTREDUCE 50 |
| 183344 | +#define fts5YY_MAX_SHIFTREDUCE 76 |
| 183345 | +#define fts5YY_MIN_REDUCE 77 |
| 183346 | +#define fts5YY_MAX_REDUCE 103 |
| 183347 | +#define fts5YY_ERROR_ACTION 104 |
| 183348 | +#define fts5YY_ACCEPT_ACTION 105 |
| 183349 | +#define fts5YY_NO_ACTION 106 |
| 182708 | 183350 | /************* End control #defines *******************************************/ |
| 182709 | 183351 | |
| 182710 | 183352 | /* Define the fts5yytestcase() macro to be a no-op if is not already defined |
| 182711 | 183353 | ** otherwise. |
| 182712 | 183354 | ** |
| | @@ -182774,54 +183416,58 @@ |
| 182774 | 183416 | ** fts5yy_reduce_ofst[] For each state, the offset into fts5yy_action for |
| 182775 | 183417 | ** shifting non-terminals after a reduce. |
| 182776 | 183418 | ** fts5yy_default[] Default action for each state. |
| 182777 | 183419 | ** |
| 182778 | 183420 | *********** Begin parsing tables **********************************************/ |
| 182779 | | -#define fts5YY_ACTTAB_COUNT (85) |
| 183421 | +#define fts5YY_ACTTAB_COUNT (98) |
| 182780 | 183422 | static const fts5YYACTIONTYPE fts5yy_action[] = { |
| 182781 | | - /* 0 */ 98, 16, 51, 5, 53, 27, 83, 7, 26, 15, |
| 182782 | | - /* 10 */ 51, 5, 53, 27, 13, 69, 26, 48, 51, 5, |
| 182783 | | - /* 20 */ 53, 27, 19, 11, 26, 9, 20, 51, 5, 53, |
| 182784 | | - /* 30 */ 27, 13, 22, 26, 28, 51, 5, 53, 27, 68, |
| 182785 | | - /* 40 */ 1, 26, 19, 11, 17, 9, 52, 10, 53, 27, |
| 182786 | | - /* 50 */ 23, 24, 26, 54, 3, 4, 2, 26, 6, 21, |
| 182787 | | - /* 60 */ 49, 71, 3, 4, 2, 7, 56, 59, 55, 59, |
| 182788 | | - /* 70 */ 4, 2, 12, 69, 58, 60, 18, 67, 62, 69, |
| 182789 | | - /* 80 */ 25, 66, 8, 14, 2, |
| 183423 | + /* 0 */ 105, 19, 63, 6, 26, 66, 65, 24, 24, 17, |
| 183424 | + /* 10 */ 63, 6, 26, 16, 65, 54, 24, 18, 63, 6, |
| 183425 | + /* 20 */ 26, 10, 65, 12, 24, 75, 59, 63, 6, 26, |
| 183426 | + /* 30 */ 13, 65, 75, 24, 20, 63, 6, 26, 74, 65, |
| 183427 | + /* 40 */ 56, 24, 27, 63, 6, 26, 73, 65, 21, 24, |
| 183428 | + /* 50 */ 23, 15, 30, 11, 1, 64, 22, 25, 9, 65, |
| 183429 | + /* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77, |
| 183430 | + /* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12, |
| 183431 | + /* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32, |
| 183432 | + /* 90 */ 8, 28, 5, 3, 51, 55, 72, 14, |
| 182790 | 183433 | }; |
| 182791 | 183434 | static const fts5YYCODETYPE fts5yy_lookahead[] = { |
| 182792 | | - /* 0 */ 16, 17, 18, 19, 20, 21, 5, 6, 24, 17, |
| 182793 | | - /* 10 */ 18, 19, 20, 21, 11, 14, 24, 17, 18, 19, |
| 182794 | | - /* 20 */ 20, 21, 8, 9, 24, 11, 17, 18, 19, 20, |
| 182795 | | - /* 30 */ 21, 11, 12, 24, 17, 18, 19, 20, 21, 26, |
| 182796 | | - /* 40 */ 6, 24, 8, 9, 22, 11, 18, 11, 20, 21, |
| 182797 | | - /* 50 */ 24, 25, 24, 20, 1, 2, 3, 24, 23, 24, |
| 182798 | | - /* 60 */ 7, 0, 1, 2, 3, 6, 10, 11, 10, 11, |
| 182799 | | - /* 70 */ 2, 3, 9, 14, 11, 11, 22, 26, 7, 14, |
| 182800 | | - /* 80 */ 13, 11, 5, 11, 3, |
| 183435 | + /* 0 */ 16, 17, 18, 19, 20, 22, 22, 24, 24, 17, |
| 183436 | + /* 10 */ 18, 19, 20, 7, 22, 9, 24, 17, 18, 19, |
| 183437 | + /* 20 */ 20, 10, 22, 9, 24, 14, 17, 18, 19, 20, |
| 183438 | + /* 30 */ 9, 22, 14, 24, 17, 18, 19, 20, 26, 22, |
| 183439 | + /* 40 */ 9, 24, 17, 18, 19, 20, 26, 22, 21, 24, |
| 183440 | + /* 50 */ 6, 7, 13, 9, 10, 18, 21, 20, 5, 22, |
| 183441 | + /* 60 */ 5, 24, 3, 1, 2, 3, 1, 2, 3, 0, |
| 183442 | + /* 70 */ 1, 2, 3, 11, 6, 7, 11, 9, 5, 9, |
| 183443 | + /* 80 */ 10, 9, 11, 10, 12, 8, 9, 14, 24, 25, |
| 183444 | + /* 90 */ 23, 24, 2, 3, 8, 9, 9, 9, |
| 182801 | 183445 | }; |
| 182802 | | -#define fts5YY_SHIFT_USE_DFLT (85) |
| 182803 | | -#define fts5YY_SHIFT_COUNT (28) |
| 183446 | +#define fts5YY_SHIFT_USE_DFLT (98) |
| 183447 | +#define fts5YY_SHIFT_COUNT (32) |
| 182804 | 183448 | #define fts5YY_SHIFT_MIN (0) |
| 182805 | | -#define fts5YY_SHIFT_MAX (81) |
| 183449 | +#define fts5YY_SHIFT_MAX (90) |
| 182806 | 183450 | static const unsigned char fts5yy_shift_ofst[] = { |
| 182807 | | - /* 0 */ 34, 34, 34, 34, 34, 14, 20, 3, 36, 1, |
| 182808 | | - /* 10 */ 59, 64, 64, 65, 65, 53, 61, 56, 58, 63, |
| 182809 | | - /* 20 */ 68, 67, 70, 67, 71, 72, 67, 77, 81, |
| 183451 | + /* 0 */ 44, 44, 44, 44, 44, 44, 68, 70, 72, 14, |
| 183452 | + /* 10 */ 21, 73, 11, 18, 18, 31, 31, 62, 65, 69, |
| 183453 | + /* 20 */ 90, 77, 86, 6, 39, 53, 55, 59, 39, 87, |
| 183454 | + /* 30 */ 88, 39, 71, |
| 182810 | 183455 | }; |
| 182811 | | -#define fts5YY_REDUCE_USE_DFLT (-17) |
| 182812 | | -#define fts5YY_REDUCE_COUNT (14) |
| 182813 | | -#define fts5YY_REDUCE_MIN (-16) |
| 182814 | | -#define fts5YY_REDUCE_MAX (54) |
| 183456 | +#define fts5YY_REDUCE_USE_DFLT (-18) |
| 183457 | +#define fts5YY_REDUCE_COUNT (16) |
| 183458 | +#define fts5YY_REDUCE_MIN (-17) |
| 183459 | +#define fts5YY_REDUCE_MAX (67) |
| 182815 | 183460 | static const signed char fts5yy_reduce_ofst[] = { |
| 182816 | | - /* 0 */ -16, -8, 0, 9, 17, 28, 26, 35, 33, 13, |
| 182817 | | - /* 10 */ 13, 22, 54, 13, 51, |
| 183461 | + /* 0 */ -16, -8, 0, 9, 17, 25, 37, -17, 64, -17, |
| 183462 | + /* 10 */ 67, 12, 12, 12, 20, 27, 35, |
| 182818 | 183463 | }; |
| 182819 | 183464 | static const fts5YYACTIONTYPE fts5yy_default[] = { |
| 182820 | | - /* 0 */ 97, 97, 97, 97, 97, 76, 91, 97, 97, 96, |
| 182821 | | - /* 10 */ 96, 97, 97, 96, 96, 97, 97, 97, 97, 97, |
| 182822 | | - /* 20 */ 73, 89, 97, 90, 97, 97, 87, 97, 72, |
| 183465 | + /* 0 */ 104, 104, 104, 104, 104, 104, 89, 104, 98, 104, |
| 183466 | + /* 10 */ 104, 103, 103, 103, 103, 104, 104, 104, 104, 104, |
| 183467 | + /* 20 */ 85, 104, 104, 104, 94, 104, 104, 84, 96, 104, |
| 183468 | + /* 30 */ 104, 97, 104, |
| 182823 | 183469 | }; |
| 182824 | 183470 | /********** End of lemon-generated parsing tables *****************************/ |
| 182825 | 183471 | |
| 182826 | 183472 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 182827 | 183473 | ** If a construct like the following: |
| | @@ -182923,49 +183569,50 @@ |
| 182923 | 183569 | #ifndef NDEBUG |
| 182924 | 183570 | /* For tracing shifts, the names of all terminals and nonterminals |
| 182925 | 183571 | ** are required. The following table supplies these names */ |
| 182926 | 183572 | static const char *const fts5yyTokenName[] = { |
| 182927 | 183573 | "$", "OR", "AND", "NOT", |
| 182928 | | - "TERM", "COLON", "LP", "RP", |
| 182929 | | - "MINUS", "LCP", "RCP", "STRING", |
| 183574 | + "TERM", "COLON", "MINUS", "LCP", |
| 183575 | + "RCP", "STRING", "LP", "RP", |
| 182930 | 183576 | "COMMA", "PLUS", "STAR", "error", |
| 182931 | 183577 | "input", "expr", "cnearset", "exprlist", |
| 182932 | | - "nearset", "colset", "colsetlist", "nearphrases", |
| 183578 | + "colset", "colsetlist", "nearset", "nearphrases", |
| 182933 | 183579 | "phrase", "neardist_opt", "star_opt", |
| 182934 | 183580 | }; |
| 182935 | 183581 | #endif /* NDEBUG */ |
| 182936 | 183582 | |
| 182937 | 183583 | #ifndef NDEBUG |
| 182938 | 183584 | /* For tracing reduce actions, the names of all rules are required. |
| 182939 | 183585 | */ |
| 182940 | 183586 | static const char *const fts5yyRuleName[] = { |
| 182941 | 183587 | /* 0 */ "input ::= expr", |
| 182942 | | - /* 1 */ "expr ::= expr AND expr", |
| 182943 | | - /* 2 */ "expr ::= expr OR expr", |
| 182944 | | - /* 3 */ "expr ::= expr NOT expr", |
| 182945 | | - /* 4 */ "expr ::= LP expr RP", |
| 182946 | | - /* 5 */ "expr ::= exprlist", |
| 182947 | | - /* 6 */ "exprlist ::= cnearset", |
| 182948 | | - /* 7 */ "exprlist ::= exprlist cnearset", |
| 182949 | | - /* 8 */ "cnearset ::= nearset", |
| 182950 | | - /* 9 */ "cnearset ::= colset COLON nearset", |
| 182951 | | - /* 10 */ "colset ::= MINUS LCP colsetlist RCP", |
| 182952 | | - /* 11 */ "colset ::= LCP colsetlist RCP", |
| 182953 | | - /* 12 */ "colset ::= STRING", |
| 182954 | | - /* 13 */ "colset ::= MINUS STRING", |
| 182955 | | - /* 14 */ "colsetlist ::= colsetlist STRING", |
| 182956 | | - /* 15 */ "colsetlist ::= STRING", |
| 182957 | | - /* 16 */ "nearset ::= phrase", |
| 182958 | | - /* 17 */ "nearset ::= STRING LP nearphrases neardist_opt RP", |
| 182959 | | - /* 18 */ "nearphrases ::= phrase", |
| 182960 | | - /* 19 */ "nearphrases ::= nearphrases phrase", |
| 182961 | | - /* 20 */ "neardist_opt ::=", |
| 182962 | | - /* 21 */ "neardist_opt ::= COMMA STRING", |
| 182963 | | - /* 22 */ "phrase ::= phrase PLUS STRING star_opt", |
| 182964 | | - /* 23 */ "phrase ::= STRING star_opt", |
| 182965 | | - /* 24 */ "star_opt ::= STAR", |
| 182966 | | - /* 25 */ "star_opt ::=", |
| 183588 | + /* 1 */ "colset ::= MINUS LCP colsetlist RCP", |
| 183589 | + /* 2 */ "colset ::= LCP colsetlist RCP", |
| 183590 | + /* 3 */ "colset ::= STRING", |
| 183591 | + /* 4 */ "colset ::= MINUS STRING", |
| 183592 | + /* 5 */ "colsetlist ::= colsetlist STRING", |
| 183593 | + /* 6 */ "colsetlist ::= STRING", |
| 183594 | + /* 7 */ "expr ::= expr AND expr", |
| 183595 | + /* 8 */ "expr ::= expr OR expr", |
| 183596 | + /* 9 */ "expr ::= expr NOT expr", |
| 183597 | + /* 10 */ "expr ::= colset COLON LP expr RP", |
| 183598 | + /* 11 */ "expr ::= LP expr RP", |
| 183599 | + /* 12 */ "expr ::= exprlist", |
| 183600 | + /* 13 */ "exprlist ::= cnearset", |
| 183601 | + /* 14 */ "exprlist ::= exprlist cnearset", |
| 183602 | + /* 15 */ "cnearset ::= nearset", |
| 183603 | + /* 16 */ "cnearset ::= colset COLON nearset", |
| 183604 | + /* 17 */ "nearset ::= phrase", |
| 183605 | + /* 18 */ "nearset ::= STRING LP nearphrases neardist_opt RP", |
| 183606 | + /* 19 */ "nearphrases ::= phrase", |
| 183607 | + /* 20 */ "nearphrases ::= nearphrases phrase", |
| 183608 | + /* 21 */ "neardist_opt ::=", |
| 183609 | + /* 22 */ "neardist_opt ::= COMMA STRING", |
| 183610 | + /* 23 */ "phrase ::= phrase PLUS STRING star_opt", |
| 183611 | + /* 24 */ "phrase ::= STRING star_opt", |
| 183612 | + /* 25 */ "star_opt ::= STAR", |
| 183613 | + /* 26 */ "star_opt ::=", |
| 182967 | 183614 | }; |
| 182968 | 183615 | #endif /* NDEBUG */ |
| 182969 | 183616 | |
| 182970 | 183617 | |
| 182971 | 183618 | #if fts5YYSTACKDEPTH<=0 |
| | @@ -183091,21 +183738,21 @@ |
| 183091 | 183738 | case 19: /* exprlist */ |
| 183092 | 183739 | { |
| 183093 | 183740 | sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); |
| 183094 | 183741 | } |
| 183095 | 183742 | break; |
| 183096 | | - case 20: /* nearset */ |
| 183743 | + case 20: /* colset */ |
| 183744 | + case 21: /* colsetlist */ |
| 183745 | +{ |
| 183746 | + sqlite3_free((fts5yypminor->fts5yy11)); |
| 183747 | +} |
| 183748 | + break; |
| 183749 | + case 22: /* nearset */ |
| 183097 | 183750 | case 23: /* nearphrases */ |
| 183098 | 183751 | { |
| 183099 | 183752 | sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); |
| 183100 | 183753 | } |
| 183101 | | - break; |
| 183102 | | - case 21: /* colset */ |
| 183103 | | - case 22: /* colsetlist */ |
| 183104 | | -{ |
| 183105 | | - sqlite3_free((fts5yypminor->fts5yy11)); |
| 183106 | | -} |
| 183107 | 183754 | break; |
| 183108 | 183755 | case 24: /* phrase */ |
| 183109 | 183756 | { |
| 183110 | 183757 | sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); |
| 183111 | 183758 | } |
| | @@ -183360,27 +184007,28 @@ |
| 183360 | 184007 | static const struct { |
| 183361 | 184008 | fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
| 183362 | 184009 | unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
| 183363 | 184010 | } fts5yyRuleInfo[] = { |
| 183364 | 184011 | { 16, 1 }, |
| 184012 | + { 20, 4 }, |
| 184013 | + { 20, 3 }, |
| 184014 | + { 20, 1 }, |
| 184015 | + { 20, 2 }, |
| 184016 | + { 21, 2 }, |
| 184017 | + { 21, 1 }, |
| 183365 | 184018 | { 17, 3 }, |
| 183366 | 184019 | { 17, 3 }, |
| 183367 | 184020 | { 17, 3 }, |
| 184021 | + { 17, 5 }, |
| 183368 | 184022 | { 17, 3 }, |
| 183369 | 184023 | { 17, 1 }, |
| 183370 | 184024 | { 19, 1 }, |
| 183371 | 184025 | { 19, 2 }, |
| 183372 | 184026 | { 18, 1 }, |
| 183373 | 184027 | { 18, 3 }, |
| 183374 | | - { 21, 4 }, |
| 183375 | | - { 21, 3 }, |
| 183376 | | - { 21, 1 }, |
| 183377 | | - { 21, 2 }, |
| 183378 | | - { 22, 2 }, |
| 183379 | 184028 | { 22, 1 }, |
| 183380 | | - { 20, 1 }, |
| 183381 | | - { 20, 5 }, |
| 184029 | + { 22, 5 }, |
| 183382 | 184030 | { 23, 1 }, |
| 183383 | 184031 | { 23, 2 }, |
| 183384 | 184032 | { 25, 0 }, |
| 183385 | 184033 | { 25, 2 }, |
| 183386 | 184034 | { 24, 4 }, |
| | @@ -183451,132 +184099,139 @@ |
| 183451 | 184099 | /********** Begin reduce actions **********************************************/ |
| 183452 | 184100 | fts5YYMINORTYPE fts5yylhsminor; |
| 183453 | 184101 | case 0: /* input ::= expr */ |
| 183454 | 184102 | { sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); } |
| 183455 | 184103 | break; |
| 183456 | | - case 1: /* expr ::= expr AND expr */ |
| 183457 | | -{ |
| 183458 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183459 | | -} |
| 183460 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183461 | | - break; |
| 183462 | | - case 2: /* expr ::= expr OR expr */ |
| 183463 | | -{ |
| 183464 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183465 | | -} |
| 183466 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183467 | | - break; |
| 183468 | | - case 3: /* expr ::= expr NOT expr */ |
| 183469 | | -{ |
| 183470 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183471 | | -} |
| 183472 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183473 | | - break; |
| 183474 | | - case 4: /* expr ::= LP expr RP */ |
| 183475 | | -{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;} |
| 183476 | | - break; |
| 183477 | | - case 5: /* expr ::= exprlist */ |
| 183478 | | - case 6: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==6); |
| 183479 | | -{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;} |
| 183480 | | - fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183481 | | - break; |
| 183482 | | - case 7: /* exprlist ::= exprlist cnearset */ |
| 183483 | | -{ |
| 183484 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24); |
| 183485 | | -} |
| 183486 | | - fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183487 | | - break; |
| 183488 | | - case 8: /* cnearset ::= nearset */ |
| 183489 | | -{ |
| 183490 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 183491 | | -} |
| 183492 | | - fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183493 | | - break; |
| 183494 | | - case 9: /* cnearset ::= colset COLON nearset */ |
| 183495 | | -{ |
| 183496 | | - sqlite3Fts5ParseSetColset(pParse, fts5yymsp[0].minor.fts5yy46, fts5yymsp[-2].minor.fts5yy11); |
| 183497 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 183498 | | -} |
| 183499 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183500 | | - break; |
| 183501 | | - case 10: /* colset ::= MINUS LCP colsetlist RCP */ |
| 183502 | | -{ |
| 183503 | | - fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 183504 | | -} |
| 183505 | | - break; |
| 183506 | | - case 11: /* colset ::= LCP colsetlist RCP */ |
| 183507 | | -{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; } |
| 183508 | | - break; |
| 183509 | | - case 12: /* colset ::= STRING */ |
| 183510 | | -{ |
| 183511 | | - fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183512 | | -} |
| 183513 | | - fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183514 | | - break; |
| 183515 | | - case 13: /* colset ::= MINUS STRING */ |
| 183516 | | -{ |
| 183517 | | - fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183518 | | - fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 183519 | | -} |
| 183520 | | - break; |
| 183521 | | - case 14: /* colsetlist ::= colsetlist STRING */ |
| 183522 | | -{ |
| 183523 | | - fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); } |
| 183524 | | - fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183525 | | - break; |
| 183526 | | - case 15: /* colsetlist ::= STRING */ |
| 183527 | | -{ |
| 183528 | | - fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183529 | | -} |
| 183530 | | - fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183531 | | - break; |
| 183532 | | - case 16: /* nearset ::= phrase */ |
| 183533 | | -{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } |
| 183534 | | - fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183535 | | - break; |
| 183536 | | - case 17: /* nearset ::= STRING LP nearphrases neardist_opt RP */ |
| 184104 | + case 1: /* colset ::= MINUS LCP colsetlist RCP */ |
| 184105 | +{ |
| 184106 | + fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 184107 | +} |
| 184108 | + break; |
| 184109 | + case 2: /* colset ::= LCP colsetlist RCP */ |
| 184110 | +{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; } |
| 184111 | + break; |
| 184112 | + case 3: /* colset ::= STRING */ |
| 184113 | +{ |
| 184114 | + fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 184115 | +} |
| 184116 | + fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 184117 | + break; |
| 184118 | + case 4: /* colset ::= MINUS STRING */ |
| 184119 | +{ |
| 184120 | + fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 184121 | + fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 184122 | +} |
| 184123 | + break; |
| 184124 | + case 5: /* colsetlist ::= colsetlist STRING */ |
| 184125 | +{ |
| 184126 | + fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); } |
| 184127 | + fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 184128 | + break; |
| 184129 | + case 6: /* colsetlist ::= STRING */ |
| 184130 | +{ |
| 184131 | + fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 184132 | +} |
| 184133 | + fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 184134 | + break; |
| 184135 | + case 7: /* expr ::= expr AND expr */ |
| 184136 | +{ |
| 184137 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 184138 | +} |
| 184139 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184140 | + break; |
| 184141 | + case 8: /* expr ::= expr OR expr */ |
| 184142 | +{ |
| 184143 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 184144 | +} |
| 184145 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184146 | + break; |
| 184147 | + case 9: /* expr ::= expr NOT expr */ |
| 184148 | +{ |
| 184149 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 184150 | +} |
| 184151 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184152 | + break; |
| 184153 | + case 10: /* expr ::= colset COLON LP expr RP */ |
| 184154 | +{ |
| 184155 | + sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11); |
| 184156 | + fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24; |
| 184157 | +} |
| 184158 | + fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184159 | + break; |
| 184160 | + case 11: /* expr ::= LP expr RP */ |
| 184161 | +{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;} |
| 184162 | + break; |
| 184163 | + case 12: /* expr ::= exprlist */ |
| 184164 | + case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13); |
| 184165 | +{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;} |
| 184166 | + fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184167 | + break; |
| 184168 | + case 14: /* exprlist ::= exprlist cnearset */ |
| 184169 | +{ |
| 184170 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24); |
| 184171 | +} |
| 184172 | + fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184173 | + break; |
| 184174 | + case 15: /* cnearset ::= nearset */ |
| 184175 | +{ |
| 184176 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 184177 | +} |
| 184178 | + fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184179 | + break; |
| 184180 | + case 16: /* cnearset ::= colset COLON nearset */ |
| 184181 | +{ |
| 184182 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 184183 | + sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11); |
| 184184 | +} |
| 184185 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184186 | + break; |
| 184187 | + case 17: /* nearset ::= phrase */ |
| 184188 | +{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } |
| 184189 | + fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 184190 | + break; |
| 184191 | + case 18: /* nearset ::= STRING LP nearphrases neardist_opt RP */ |
| 183537 | 184192 | { |
| 183538 | 184193 | sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0); |
| 183539 | 184194 | sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0); |
| 183540 | 184195 | fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46; |
| 183541 | 184196 | } |
| 183542 | 184197 | fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183543 | 184198 | break; |
| 183544 | | - case 18: /* nearphrases ::= phrase */ |
| 184199 | + case 19: /* nearphrases ::= phrase */ |
| 183545 | 184200 | { |
| 183546 | 184201 | fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); |
| 183547 | 184202 | } |
| 183548 | 184203 | fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183549 | 184204 | break; |
| 183550 | | - case 19: /* nearphrases ::= nearphrases phrase */ |
| 184205 | + case 20: /* nearphrases ::= nearphrases phrase */ |
| 183551 | 184206 | { |
| 183552 | 184207 | fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53); |
| 183553 | 184208 | } |
| 183554 | 184209 | fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183555 | 184210 | break; |
| 183556 | | - case 20: /* neardist_opt ::= */ |
| 184211 | + case 21: /* neardist_opt ::= */ |
| 183557 | 184212 | { fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; } |
| 183558 | 184213 | break; |
| 183559 | | - case 21: /* neardist_opt ::= COMMA STRING */ |
| 184214 | + case 22: /* neardist_opt ::= COMMA STRING */ |
| 183560 | 184215 | { fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; } |
| 183561 | 184216 | break; |
| 183562 | | - case 22: /* phrase ::= phrase PLUS STRING star_opt */ |
| 184217 | + case 23: /* phrase ::= phrase PLUS STRING star_opt */ |
| 183563 | 184218 | { |
| 183564 | 184219 | fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); |
| 183565 | 184220 | } |
| 183566 | 184221 | fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53; |
| 183567 | 184222 | break; |
| 183568 | | - case 23: /* phrase ::= STRING star_opt */ |
| 184223 | + case 24: /* phrase ::= STRING star_opt */ |
| 183569 | 184224 | { |
| 183570 | 184225 | fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); |
| 183571 | 184226 | } |
| 183572 | 184227 | fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53; |
| 183573 | 184228 | break; |
| 183574 | | - case 24: /* star_opt ::= STAR */ |
| 184229 | + case 25: /* star_opt ::= STAR */ |
| 183575 | 184230 | { fts5yymsp[0].minor.fts5yy4 = 1; } |
| 183576 | 184231 | break; |
| 183577 | | - case 25: /* star_opt ::= */ |
| 184232 | + case 26: /* star_opt ::= */ |
| 183578 | 184233 | { fts5yymsp[1].minor.fts5yy4 = 0; } |
| 183579 | 184234 | break; |
| 183580 | 184235 | default: |
| 183581 | 184236 | break; |
| 183582 | 184237 | /********** End reduce actions ************************************************/ |
| | @@ -184614,13 +185269,15 @@ |
| 184614 | 185269 | Fts5Buffer *pBuf, |
| 184615 | 185270 | u32 nData, |
| 184616 | 185271 | const u8 *pData |
| 184617 | 185272 | ){ |
| 184618 | 185273 | assert_nc( *pRc || nData>=0 ); |
| 184619 | | - if( fts5BufferGrow(pRc, pBuf, nData) ) return; |
| 184620 | | - memcpy(&pBuf->p[pBuf->n], pData, nData); |
| 184621 | | - pBuf->n += nData; |
| 185274 | + if( nData ){ |
| 185275 | + if( fts5BufferGrow(pRc, pBuf, nData) ) return; |
| 185276 | + memcpy(&pBuf->p[pBuf->n], pData, nData); |
| 185277 | + pBuf->n += nData; |
| 185278 | + } |
| 184622 | 185279 | } |
| 184623 | 185280 | |
| 184624 | 185281 | /* |
| 184625 | 185282 | ** Append the nul-terminated string zStr to the buffer pBuf. This function |
| 184626 | 185283 | ** ensures that the byte following the buffer data is set to 0x00, even |
| | @@ -184793,12 +185450,12 @@ |
| 184793 | 185450 | |
| 184794 | 185451 | static void *sqlite3Fts5MallocZero(int *pRc, int nByte){ |
| 184795 | 185452 | void *pRet = 0; |
| 184796 | 185453 | if( *pRc==SQLITE_OK ){ |
| 184797 | 185454 | pRet = sqlite3_malloc(nByte); |
| 184798 | | - if( pRet==0 && nByte>0 ){ |
| 184799 | | - *pRc = SQLITE_NOMEM; |
| 185455 | + if( pRet==0 ){ |
| 185456 | + if( nByte>0 ) *pRc = SQLITE_NOMEM; |
| 184800 | 185457 | }else{ |
| 184801 | 185458 | memset(pRet, 0, nByte); |
| 184802 | 185459 | } |
| 184803 | 185460 | } |
| 184804 | 185461 | return pRet; |
| | @@ -186115,10 +186772,11 @@ |
| 186115 | 186772 | static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); } |
| 186116 | 186773 | static void fts5ParseFree(void *p){ sqlite3_free(p); } |
| 186117 | 186774 | |
| 186118 | 186775 | static int sqlite3Fts5ExprNew( |
| 186119 | 186776 | Fts5Config *pConfig, /* FTS5 Configuration */ |
| 186777 | + int iCol, |
| 186120 | 186778 | const char *zExpr, /* Expression text */ |
| 186121 | 186779 | Fts5Expr **ppNew, |
| 186122 | 186780 | char **pzErr |
| 186123 | 186781 | ){ |
| 186124 | 186782 | Fts5Parse sParse; |
| | @@ -186138,10 +186796,22 @@ |
| 186138 | 186796 | do { |
| 186139 | 186797 | t = fts5ExprGetToken(&sParse, &z, &token); |
| 186140 | 186798 | sqlite3Fts5Parser(pEngine, t, token, &sParse); |
| 186141 | 186799 | }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF ); |
| 186142 | 186800 | sqlite3Fts5ParserFree(pEngine, fts5ParseFree); |
| 186801 | + |
| 186802 | + /* If the LHS of the MATCH expression was a user column, apply the |
| 186803 | + ** implicit column-filter. */ |
| 186804 | + if( iCol<pConfig->nCol && sParse.pExpr && sParse.rc==SQLITE_OK ){ |
| 186805 | + int n = sizeof(Fts5Colset); |
| 186806 | + Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n); |
| 186807 | + if( pColset ){ |
| 186808 | + pColset->nCol = 1; |
| 186809 | + pColset->aiCol[0] = iCol; |
| 186810 | + sqlite3Fts5ParseSetColset(&sParse, sParse.pExpr, pColset); |
| 186811 | + } |
| 186812 | + } |
| 186143 | 186813 | |
| 186144 | 186814 | assert( sParse.rc!=SQLITE_OK || sParse.zErr==0 ); |
| 186145 | 186815 | if( sParse.rc==SQLITE_OK ){ |
| 186146 | 186816 | *ppNew = pNew = sqlite3_malloc(sizeof(Fts5Expr)); |
| 186147 | 186817 | if( pNew==0 ){ |
| | @@ -187788,29 +188458,114 @@ |
| 187788 | 188458 | } |
| 187789 | 188459 | |
| 187790 | 188460 | return pRet; |
| 187791 | 188461 | } |
| 187792 | 188462 | |
| 188463 | +/* |
| 188464 | +** If argument pOrig is NULL, or if (*pRc) is set to anything other than |
| 188465 | +** SQLITE_OK when this function is called, NULL is returned. |
| 188466 | +** |
| 188467 | +** Otherwise, a copy of (*pOrig) is made into memory obtained from |
| 188468 | +** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation |
| 188469 | +** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned. |
| 188470 | +*/ |
| 188471 | +static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){ |
| 188472 | + Fts5Colset *pRet; |
| 188473 | + if( pOrig ){ |
| 188474 | + int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int); |
| 188475 | + pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte); |
| 188476 | + if( pRet ){ |
| 188477 | + memcpy(pRet, pOrig, nByte); |
| 188478 | + } |
| 188479 | + }else{ |
| 188480 | + pRet = 0; |
| 188481 | + } |
| 188482 | + return pRet; |
| 188483 | +} |
| 188484 | + |
| 188485 | +/* |
| 188486 | +** Remove from colset pColset any columns that are not also in colset pMerge. |
| 188487 | +*/ |
| 188488 | +static void fts5MergeColset(Fts5Colset *pColset, Fts5Colset *pMerge){ |
| 188489 | + int iIn = 0; /* Next input in pColset */ |
| 188490 | + int iMerge = 0; /* Next input in pMerge */ |
| 188491 | + int iOut = 0; /* Next output slot in pColset */ |
| 188492 | + |
| 188493 | + while( iIn<pColset->nCol && iMerge<pMerge->nCol ){ |
| 188494 | + int iDiff = pColset->aiCol[iIn] - pMerge->aiCol[iMerge]; |
| 188495 | + if( iDiff==0 ){ |
| 188496 | + pColset->aiCol[iOut++] = pMerge->aiCol[iMerge]; |
| 188497 | + iMerge++; |
| 188498 | + iIn++; |
| 188499 | + }else if( iDiff>0 ){ |
| 188500 | + iMerge++; |
| 188501 | + }else{ |
| 188502 | + iIn++; |
| 188503 | + } |
| 188504 | + } |
| 188505 | + pColset->nCol = iOut; |
| 188506 | +} |
| 188507 | + |
| 188508 | +/* |
| 188509 | +** Recursively apply colset pColset to expression node pNode and all of |
| 188510 | +** its decendents. If (*ppFree) is not NULL, it contains a spare copy |
| 188511 | +** of pColset. This function may use the spare copy and set (*ppFree) to |
| 188512 | +** zero, or it may create copies of pColset using fts5CloneColset(). |
| 188513 | +*/ |
| 188514 | +static void fts5ParseSetColset( |
| 188515 | + Fts5Parse *pParse, |
| 188516 | + Fts5ExprNode *pNode, |
| 188517 | + Fts5Colset *pColset, |
| 188518 | + Fts5Colset **ppFree |
| 188519 | +){ |
| 188520 | + if( pParse->rc==SQLITE_OK ){ |
| 188521 | + assert( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING |
| 188522 | + || pNode->eType==FTS5_AND || pNode->eType==FTS5_OR |
| 188523 | + || pNode->eType==FTS5_NOT || pNode->eType==FTS5_EOF |
| 188524 | + ); |
| 188525 | + if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){ |
| 188526 | + Fts5ExprNearset *pNear = pNode->pNear; |
| 188527 | + if( pNear->pColset ){ |
| 188528 | + fts5MergeColset(pNear->pColset, pColset); |
| 188529 | + if( pNear->pColset->nCol==0 ){ |
| 188530 | + pNode->eType = FTS5_EOF; |
| 188531 | + pNode->xNext = 0; |
| 188532 | + } |
| 188533 | + }else if( *ppFree ){ |
| 188534 | + pNear->pColset = pColset; |
| 188535 | + *ppFree = 0; |
| 188536 | + }else{ |
| 188537 | + pNear->pColset = fts5CloneColset(&pParse->rc, pColset); |
| 188538 | + } |
| 188539 | + }else{ |
| 188540 | + int i; |
| 188541 | + assert( pNode->eType!=FTS5_EOF || pNode->nChild==0 ); |
| 188542 | + for(i=0; i<pNode->nChild; i++){ |
| 188543 | + fts5ParseSetColset(pParse, pNode->apChild[i], pColset, ppFree); |
| 188544 | + } |
| 188545 | + } |
| 188546 | + } |
| 188547 | +} |
| 188548 | + |
| 188549 | +/* |
| 188550 | +** Apply colset pColset to expression node pExpr and all of its descendents. |
| 188551 | +*/ |
| 187793 | 188552 | static void sqlite3Fts5ParseSetColset( |
| 187794 | 188553 | Fts5Parse *pParse, |
| 187795 | | - Fts5ExprNearset *pNear, |
| 188554 | + Fts5ExprNode *pExpr, |
| 187796 | 188555 | Fts5Colset *pColset |
| 187797 | 188556 | ){ |
| 188557 | + Fts5Colset *pFree = pColset; |
| 187798 | 188558 | if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){ |
| 187799 | 188559 | pParse->rc = SQLITE_ERROR; |
| 187800 | 188560 | pParse->zErr = sqlite3_mprintf( |
| 187801 | 188561 | "fts5: column queries are not supported (detail=none)" |
| 187802 | 188562 | ); |
| 187803 | | - sqlite3_free(pColset); |
| 187804 | | - return; |
| 187805 | | - } |
| 187806 | | - |
| 187807 | | - if( pNear ){ |
| 187808 | | - pNear->pColset = pColset; |
| 187809 | | - }else{ |
| 187810 | | - sqlite3_free(pColset); |
| 187811 | | - } |
| 188563 | + }else{ |
| 188564 | + fts5ParseSetColset(pParse, pExpr, pColset, &pFree); |
| 188565 | + } |
| 188566 | + sqlite3_free(pFree); |
| 187812 | 188567 | } |
| 187813 | 188568 | |
| 187814 | 188569 | static void fts5ExprAssignXNext(Fts5ExprNode *pNode){ |
| 187815 | 188570 | switch( pNode->eType ){ |
| 187816 | 188571 | case FTS5_STRING: { |
| | @@ -188260,11 +189015,11 @@ |
| 188260 | 189015 | |
| 188261 | 189016 | zExpr = (const char*)sqlite3_value_text(apVal[0]); |
| 188262 | 189017 | |
| 188263 | 189018 | rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr); |
| 188264 | 189019 | if( rc==SQLITE_OK ){ |
| 188265 | | - rc = sqlite3Fts5ExprNew(pConfig, zExpr, &pExpr, &zErr); |
| 189020 | + rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr); |
| 188266 | 189021 | } |
| 188267 | 189022 | if( rc==SQLITE_OK ){ |
| 188268 | 189023 | char *zText; |
| 188269 | 189024 | if( pExpr->pRoot->xNext==0 ){ |
| 188270 | 189025 | zText = sqlite3_mprintf(""); |
| | @@ -188657,13 +189412,14 @@ |
| 188657 | 189412 | Fts5HashEntry **aSlot; /* Array of hash slots */ |
| 188658 | 189413 | }; |
| 188659 | 189414 | |
| 188660 | 189415 | /* |
| 188661 | 189416 | ** Each entry in the hash table is represented by an object of the |
| 188662 | | -** following type. Each object, its key (zKey[]) and its current data |
| 188663 | | -** are stored in a single memory allocation. The position list data |
| 188664 | | -** immediately follows the key data in memory. |
| 189417 | +** following type. Each object, its key (a nul-terminated string) and |
| 189418 | +** its current data are stored in a single memory allocation. The |
| 189419 | +** key immediately follows the object in memory. The position list |
| 189420 | +** data immediately follows the key data in memory. |
| 188665 | 189421 | ** |
| 188666 | 189422 | ** The data that follows the key is in a similar, but not identical format |
| 188667 | 189423 | ** to the doclist data stored in the database. It is: |
| 188668 | 189424 | ** |
| 188669 | 189425 | ** * Rowid, as a varint |
| | @@ -188683,24 +189439,24 @@ |
| 188683 | 189439 | Fts5HashEntry *pScanNext; /* Next entry in sorted order */ |
| 188684 | 189440 | |
| 188685 | 189441 | int nAlloc; /* Total size of allocation */ |
| 188686 | 189442 | int iSzPoslist; /* Offset of space for 4-byte poslist size */ |
| 188687 | 189443 | int nData; /* Total bytes of data (incl. structure) */ |
| 188688 | | - int nKey; /* Length of zKey[] in bytes */ |
| 189444 | + int nKey; /* Length of key in bytes */ |
| 188689 | 189445 | u8 bDel; /* Set delete-flag @ iSzPoslist */ |
| 188690 | 189446 | u8 bContent; /* Set content-flag (detail=none mode) */ |
| 188691 | 189447 | i16 iCol; /* Column of last value written */ |
| 188692 | 189448 | int iPos; /* Position of last value written */ |
| 188693 | 189449 | i64 iRowid; /* Rowid of last value written */ |
| 188694 | | - char zKey[8]; /* Nul-terminated entry key */ |
| 188695 | 189450 | }; |
| 188696 | 189451 | |
| 188697 | 189452 | /* |
| 188698 | | -** Size of Fts5HashEntry without the zKey[] array. |
| 189453 | +** Eqivalent to: |
| 189454 | +** |
| 189455 | +** char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; } |
| 188699 | 189456 | */ |
| 188700 | | -#define FTS5_HASHENTRYSIZE (sizeof(Fts5HashEntry)-8) |
| 188701 | | - |
| 189457 | +#define fts5EntryKey(p) ( ((char *)(&(p)[1])) ) |
| 188702 | 189458 | |
| 188703 | 189459 | |
| 188704 | 189460 | /* |
| 188705 | 189461 | ** Allocate a new hash table. |
| 188706 | 189462 | */ |
| | @@ -188794,11 +189550,11 @@ |
| 188794 | 189550 | for(i=0; i<pHash->nSlot; i++){ |
| 188795 | 189551 | while( apOld[i] ){ |
| 188796 | 189552 | int iHash; |
| 188797 | 189553 | Fts5HashEntry *p = apOld[i]; |
| 188798 | 189554 | apOld[i] = p->pHashNext; |
| 188799 | | - iHash = fts5HashKey(nNew, (u8*)p->zKey, (int)strlen(p->zKey)); |
| 189555 | + iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), strlen(fts5EntryKey(p))); |
| 188800 | 189556 | p->pHashNext = apNew[iHash]; |
| 188801 | 189557 | apNew[iHash] = p; |
| 188802 | 189558 | } |
| 188803 | 189559 | } |
| 188804 | 189560 | |
| | @@ -188865,22 +189621,24 @@ |
| 188865 | 189621 | bNew = (pHash->eDetail==FTS5_DETAIL_FULL); |
| 188866 | 189622 | |
| 188867 | 189623 | /* Attempt to locate an existing hash entry */ |
| 188868 | 189624 | iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken); |
| 188869 | 189625 | for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ |
| 188870 | | - if( p->zKey[0]==bByte |
| 189626 | + char *zKey = fts5EntryKey(p); |
| 189627 | + if( zKey[0]==bByte |
| 188871 | 189628 | && p->nKey==nToken |
| 188872 | | - && memcmp(&p->zKey[1], pToken, nToken)==0 |
| 189629 | + && memcmp(&zKey[1], pToken, nToken)==0 |
| 188873 | 189630 | ){ |
| 188874 | 189631 | break; |
| 188875 | 189632 | } |
| 188876 | 189633 | } |
| 188877 | 189634 | |
| 188878 | 189635 | /* If an existing hash entry cannot be found, create a new one. */ |
| 188879 | 189636 | if( p==0 ){ |
| 188880 | 189637 | /* Figure out how much space to allocate */ |
| 188881 | | - int nByte = FTS5_HASHENTRYSIZE + (nToken+1) + 1 + 64; |
| 189638 | + char *zKey; |
| 189639 | + int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64; |
| 188882 | 189640 | if( nByte<128 ) nByte = 128; |
| 188883 | 189641 | |
| 188884 | 189642 | /* Grow the Fts5Hash.aSlot[] array if necessary. */ |
| 188885 | 189643 | if( (pHash->nEntry*2)>=pHash->nSlot ){ |
| 188886 | 189644 | int rc = fts5HashResize(pHash); |
| | @@ -188889,18 +189647,19 @@ |
| 188889 | 189647 | } |
| 188890 | 189648 | |
| 188891 | 189649 | /* Allocate new Fts5HashEntry and add it to the hash table. */ |
| 188892 | 189650 | p = (Fts5HashEntry*)sqlite3_malloc(nByte); |
| 188893 | 189651 | if( !p ) return SQLITE_NOMEM; |
| 188894 | | - memset(p, 0, FTS5_HASHENTRYSIZE); |
| 189652 | + memset(p, 0, sizeof(Fts5HashEntry)); |
| 188895 | 189653 | p->nAlloc = nByte; |
| 188896 | | - p->zKey[0] = bByte; |
| 188897 | | - memcpy(&p->zKey[1], pToken, nToken); |
| 188898 | | - assert( iHash==fts5HashKey(pHash->nSlot, (u8*)p->zKey, nToken+1) ); |
| 189654 | + zKey = fts5EntryKey(p); |
| 189655 | + zKey[0] = bByte; |
| 189656 | + memcpy(&zKey[1], pToken, nToken); |
| 189657 | + assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) ); |
| 188899 | 189658 | p->nKey = nToken; |
| 188900 | | - p->zKey[nToken+1] = '\0'; |
| 188901 | | - p->nData = nToken+1 + 1 + FTS5_HASHENTRYSIZE; |
| 189659 | + zKey[nToken+1] = '\0'; |
| 189660 | + p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry); |
| 188902 | 189661 | p->pHashNext = pHash->aSlot[iHash]; |
| 188903 | 189662 | pHash->aSlot[iHash] = p; |
| 188904 | 189663 | pHash->nEntry++; |
| 188905 | 189664 | |
| 188906 | 189665 | /* Add the first rowid field to the hash-entry */ |
| | @@ -189014,13 +189773,15 @@ |
| 189014 | 189773 | }else if( p2==0 ){ |
| 189015 | 189774 | *ppOut = p1; |
| 189016 | 189775 | p1 = 0; |
| 189017 | 189776 | }else{ |
| 189018 | 189777 | int i = 0; |
| 189019 | | - while( p1->zKey[i]==p2->zKey[i] ) i++; |
| 189778 | + char *zKey1 = fts5EntryKey(p1); |
| 189779 | + char *zKey2 = fts5EntryKey(p2); |
| 189780 | + while( zKey1[i]==zKey2[i] ) i++; |
| 189020 | 189781 | |
| 189021 | | - if( ((u8)p1->zKey[i])>((u8)p2->zKey[i]) ){ |
| 189782 | + if( ((u8)zKey1[i])>((u8)zKey2[i]) ){ |
| 189022 | 189783 | /* p2 is smaller */ |
| 189023 | 189784 | *ppOut = p2; |
| 189024 | 189785 | ppOut = &p2->pScanNext; |
| 189025 | 189786 | p2 = p2->pScanNext; |
| 189026 | 189787 | }else{ |
| | @@ -189059,11 +189820,11 @@ |
| 189059 | 189820 | memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot); |
| 189060 | 189821 | |
| 189061 | 189822 | for(iSlot=0; iSlot<pHash->nSlot; iSlot++){ |
| 189062 | 189823 | Fts5HashEntry *pIter; |
| 189063 | 189824 | for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){ |
| 189064 | | - if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){ |
| 189825 | + if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){ |
| 189065 | 189826 | Fts5HashEntry *pEntry = pIter; |
| 189066 | 189827 | pEntry->pScanNext = 0; |
| 189067 | 189828 | for(i=0; ap[i]; i++){ |
| 189068 | 189829 | pEntry = fts5HashEntryMerge(pEntry, ap[i]); |
| 189069 | 189830 | ap[i] = 0; |
| | @@ -189092,20 +189853,22 @@ |
| 189092 | 189853 | const char *pTerm, int nTerm, /* Query term */ |
| 189093 | 189854 | const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */ |
| 189094 | 189855 | int *pnDoclist /* OUT: Size of doclist in bytes */ |
| 189095 | 189856 | ){ |
| 189096 | 189857 | unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm); |
| 189858 | + char *zKey; |
| 189097 | 189859 | Fts5HashEntry *p; |
| 189098 | 189860 | |
| 189099 | 189861 | for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ |
| 189100 | | - if( memcmp(p->zKey, pTerm, nTerm)==0 && p->zKey[nTerm]==0 ) break; |
| 189862 | + zKey = fts5EntryKey(p); |
| 189863 | + if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break; |
| 189101 | 189864 | } |
| 189102 | 189865 | |
| 189103 | 189866 | if( p ){ |
| 189104 | 189867 | fts5HashAddPoslistSize(pHash, p); |
| 189105 | | - *ppDoclist = (const u8*)&p->zKey[nTerm+1]; |
| 189106 | | - *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1); |
| 189868 | + *ppDoclist = (const u8*)&zKey[nTerm+1]; |
| 189869 | + *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1); |
| 189107 | 189870 | }else{ |
| 189108 | 189871 | *ppDoclist = 0; |
| 189109 | 189872 | *pnDoclist = 0; |
| 189110 | 189873 | } |
| 189111 | 189874 | |
| | @@ -189134,15 +189897,16 @@ |
| 189134 | 189897 | const u8 **ppDoclist, /* OUT: pointer to doclist */ |
| 189135 | 189898 | int *pnDoclist /* OUT: size of doclist in bytes */ |
| 189136 | 189899 | ){ |
| 189137 | 189900 | Fts5HashEntry *p; |
| 189138 | 189901 | if( (p = pHash->pScan) ){ |
| 189139 | | - int nTerm = (int)strlen(p->zKey); |
| 189902 | + char *zKey = fts5EntryKey(p); |
| 189903 | + int nTerm = (int)strlen(zKey); |
| 189140 | 189904 | fts5HashAddPoslistSize(pHash, p); |
| 189141 | | - *pzTerm = p->zKey; |
| 189142 | | - *ppDoclist = (const u8*)&p->zKey[nTerm+1]; |
| 189143 | | - *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1); |
| 189905 | + *pzTerm = zKey; |
| 189906 | + *ppDoclist = (const u8*)&zKey[nTerm+1]; |
| 189907 | + *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1); |
| 189144 | 189908 | }else{ |
| 189145 | 189909 | *pzTerm = 0; |
| 189146 | 189910 | *ppDoclist = 0; |
| 189147 | 189911 | *pnDoclist = 0; |
| 189148 | 189912 | } |
| | @@ -189776,11 +190540,10 @@ |
| 189776 | 190540 | sqlite3_blob *pReader = p->pReader; |
| 189777 | 190541 | p->pReader = 0; |
| 189778 | 190542 | sqlite3_blob_close(pReader); |
| 189779 | 190543 | } |
| 189780 | 190544 | } |
| 189781 | | - |
| 189782 | 190545 | |
| 189783 | 190546 | /* |
| 189784 | 190547 | ** Retrieve a record from the %_data table. |
| 189785 | 190548 | ** |
| 189786 | 190549 | ** If an error occurs, NULL is returned and an error left in the |
| | @@ -192028,11 +192791,12 @@ |
| 192028 | 192791 | Fts5Iter *pIter, |
| 192029 | 192792 | int *pbNewTerm /* OUT: True if *might* be new term */ |
| 192030 | 192793 | ){ |
| 192031 | 192794 | assert( pIter->bSkipEmpty ); |
| 192032 | 192795 | if( p->rc==SQLITE_OK ){ |
| 192033 | | - do { |
| 192796 | + *pbNewTerm = 0; |
| 192797 | + do{ |
| 192034 | 192798 | int iFirst = pIter->aFirst[1].iFirst; |
| 192035 | 192799 | Fts5SegIter *pSeg = &pIter->aSeg[iFirst]; |
| 192036 | 192800 | int bNewTerm = 0; |
| 192037 | 192801 | |
| 192038 | 192802 | assert( p->rc==SQLITE_OK ); |
| | @@ -192041,12 +192805,10 @@ |
| 192041 | 192805 | || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg) |
| 192042 | 192806 | ){ |
| 192043 | 192807 | fts5MultiIterAdvanced(p, pIter, iFirst, 1); |
| 192044 | 192808 | fts5MultiIterSetEof(pIter); |
| 192045 | 192809 | *pbNewTerm = 1; |
| 192046 | | - }else{ |
| 192047 | | - *pbNewTerm = 0; |
| 192048 | 192810 | } |
| 192049 | 192811 | fts5AssertMultiIterSetup(p, pIter); |
| 192050 | 192812 | |
| 192051 | 192813 | }while( fts5MultiIterIsEmpty(p, pIter) ); |
| 192052 | 192814 | } |
| | @@ -192308,27 +193070,27 @@ |
| 192308 | 193070 | } |
| 192309 | 193071 | |
| 192310 | 193072 | return p - (*pa); |
| 192311 | 193073 | } |
| 192312 | 193074 | |
| 192313 | | -static int fts5IndexExtractColset ( |
| 193075 | +static void fts5IndexExtractColset( |
| 193076 | + int *pRc, |
| 192314 | 193077 | Fts5Colset *pColset, /* Colset to filter on */ |
| 192315 | 193078 | const u8 *pPos, int nPos, /* Position list */ |
| 192316 | 193079 | Fts5Buffer *pBuf /* Output buffer */ |
| 192317 | 193080 | ){ |
| 192318 | | - int rc = SQLITE_OK; |
| 192319 | | - int i; |
| 192320 | | - |
| 192321 | | - fts5BufferZero(pBuf); |
| 192322 | | - for(i=0; i<pColset->nCol; i++){ |
| 192323 | | - const u8 *pSub = pPos; |
| 192324 | | - int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]); |
| 192325 | | - if( nSub ){ |
| 192326 | | - fts5BufferAppendBlob(&rc, pBuf, nSub, pSub); |
| 193081 | + if( *pRc==SQLITE_OK ){ |
| 193082 | + int i; |
| 193083 | + fts5BufferZero(pBuf); |
| 193084 | + for(i=0; i<pColset->nCol; i++){ |
| 193085 | + const u8 *pSub = pPos; |
| 193086 | + int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]); |
| 193087 | + if( nSub ){ |
| 193088 | + fts5BufferAppendBlob(pRc, pBuf, nSub, pSub); |
| 193089 | + } |
| 192327 | 193090 | } |
| 192328 | 193091 | } |
| 192329 | | - return rc; |
| 192330 | 193092 | } |
| 192331 | 193093 | |
| 192332 | 193094 | /* |
| 192333 | 193095 | ** xSetOutputs callback used by detail=none tables. |
| 192334 | 193096 | */ |
| | @@ -192448,12 +193210,13 @@ |
| 192448 | 193210 | const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset]; |
| 192449 | 193211 | if( pColset->nCol==1 ){ |
| 192450 | 193212 | pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]); |
| 192451 | 193213 | pIter->base.pData = a; |
| 192452 | 193214 | }else{ |
| 193215 | + int *pRc = &pIter->pIndex->rc; |
| 192453 | 193216 | fts5BufferZero(&pIter->poslist); |
| 192454 | | - fts5IndexExtractColset(pColset, a, pSeg->nPos, &pIter->poslist); |
| 193217 | + fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, &pIter->poslist); |
| 192455 | 193218 | pIter->base.pData = pIter->poslist.p; |
| 192456 | 193219 | pIter->base.nData = pIter->poslist.n; |
| 192457 | 193220 | } |
| 192458 | 193221 | }else{ |
| 192459 | 193222 | /* The data is distributed over two or more pages. Copy it into the |
| | @@ -192994,13 +193757,10 @@ |
| 192994 | 193757 | static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){ |
| 192995 | 193758 | static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 }; |
| 192996 | 193759 | Fts5PageWriter *pPage = &pWriter->writer; |
| 192997 | 193760 | i64 iRowid; |
| 192998 | 193761 | |
| 192999 | | -static int nCall = 0; |
| 193000 | | -nCall++; |
| 193001 | | - |
| 193002 | 193762 | assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) ); |
| 193003 | 193763 | |
| 193004 | 193764 | /* Set the szLeaf header field. */ |
| 193005 | 193765 | assert( 0==fts5GetU16(&pPage->buf.p[2]) ); |
| 193006 | 193766 | fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n); |
| | @@ -193345,10 +194105,11 @@ |
| 193345 | 194105 | Fts5StructureSegment *pSeg; /* Output segment */ |
| 193346 | 194106 | Fts5Buffer term; |
| 193347 | 194107 | int bOldest; /* True if the output segment is the oldest */ |
| 193348 | 194108 | int eDetail = p->pConfig->eDetail; |
| 193349 | 194109 | const int flags = FTS5INDEX_QUERY_NOOUTPUT; |
| 194110 | + int bTermWritten = 0; /* True if current term already output */ |
| 193350 | 194111 | |
| 193351 | 194112 | assert( iLvl<pStruct->nLevel ); |
| 193352 | 194113 | assert( pLvl->nMerge<=pLvl->nSeg ); |
| 193353 | 194114 | |
| 193354 | 194115 | memset(&writer, 0, sizeof(Fts5SegWriter)); |
| | @@ -193398,22 +194159,26 @@ |
| 193398 | 194159 | Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ]; |
| 193399 | 194160 | int nPos; /* position-list size field value */ |
| 193400 | 194161 | int nTerm; |
| 193401 | 194162 | const u8 *pTerm; |
| 193402 | 194163 | |
| 193403 | | - /* Check for key annihilation. */ |
| 193404 | | - if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue; |
| 193405 | | - |
| 193406 | 194164 | pTerm = fts5MultiIterTerm(pIter, &nTerm); |
| 193407 | 194165 | if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){ |
| 193408 | 194166 | if( pnRem && writer.nLeafWritten>nRem ){ |
| 193409 | 194167 | break; |
| 193410 | 194168 | } |
| 194169 | + fts5BufferSet(&p->rc, &term, nTerm, pTerm); |
| 194170 | + bTermWritten =0; |
| 194171 | + } |
| 193411 | 194172 | |
| 194173 | + /* Check for key annihilation. */ |
| 194174 | + if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue; |
| 194175 | + |
| 194176 | + if( p->rc==SQLITE_OK && bTermWritten==0 ){ |
| 193412 | 194177 | /* This is a new term. Append a term to the output segment. */ |
| 193413 | 194178 | fts5WriteAppendTerm(p, &writer, nTerm, pTerm); |
| 193414 | | - fts5BufferSet(&p->rc, &term, nTerm, pTerm); |
| 194179 | + bTermWritten = 1; |
| 193415 | 194180 | } |
| 193416 | 194181 | |
| 193417 | 194182 | /* Append the rowid to the output */ |
| 193418 | 194183 | /* WRITEPOSLISTSIZE */ |
| 193419 | 194184 | fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter)); |
| | @@ -194241,11 +195006,11 @@ |
| 194241 | 195006 | |
| 194242 | 195007 | pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n); |
| 194243 | 195008 | if( pData ){ |
| 194244 | 195009 | pData->p = (u8*)&pData[1]; |
| 194245 | 195010 | pData->nn = pData->szLeaf = doclist.n; |
| 194246 | | - memcpy(pData->p, doclist.p, doclist.n); |
| 195011 | + if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n); |
| 194247 | 195012 | fts5MultiIterNew2(p, pData, bDesc, ppIter); |
| 194248 | 195013 | } |
| 194249 | 195014 | fts5BufferFree(&doclist); |
| 194250 | 195015 | } |
| 194251 | 195016 | |
| | @@ -194280,14 +195045,14 @@ |
| 194280 | 195045 | } |
| 194281 | 195046 | |
| 194282 | 195047 | /* |
| 194283 | 195048 | ** Commit data to disk. |
| 194284 | 195049 | */ |
| 194285 | | -static int sqlite3Fts5IndexSync(Fts5Index *p, int bCommit){ |
| 195050 | +static int sqlite3Fts5IndexSync(Fts5Index *p){ |
| 194286 | 195051 | assert( p->rc==SQLITE_OK ); |
| 194287 | 195052 | fts5IndexFlush(p); |
| 194288 | | - if( bCommit ) fts5CloseReader(p); |
| 195053 | + fts5CloseReader(p); |
| 194289 | 195054 | return fts5IndexReturn(p); |
| 194290 | 195055 | } |
| 194291 | 195056 | |
| 194292 | 195057 | /* |
| 194293 | 195058 | ** Discard any data stored in the in-memory hash tables. Do not write it |
| | @@ -194480,11 +195245,11 @@ |
| 194480 | 195245 | /* If the QUERY_SCAN flag is set, all other flags must be clear. */ |
| 194481 | 195246 | assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN ); |
| 194482 | 195247 | |
| 194483 | 195248 | if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){ |
| 194484 | 195249 | int iIdx = 0; /* Index to search */ |
| 194485 | | - memcpy(&buf.p[1], pToken, nToken); |
| 195250 | + if( nToken ) memcpy(&buf.p[1], pToken, nToken); |
| 194486 | 195251 | |
| 194487 | 195252 | /* Figure out which index to search and set iIdx accordingly. If this |
| 194488 | 195253 | ** is a prefix query for which there is no prefix index, set iIdx to |
| 194489 | 195254 | ** greater than pConfig->nPrefix to indicate that the query will be |
| 194490 | 195255 | ** satisfied by scanning multiple terms in the main index. |
| | @@ -194529,11 +195294,11 @@ |
| 194529 | 195294 | if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg); |
| 194530 | 195295 | } |
| 194531 | 195296 | } |
| 194532 | 195297 | |
| 194533 | 195298 | if( p->rc ){ |
| 194534 | | - sqlite3Fts5IterClose(&pRet->base); |
| 195299 | + sqlite3Fts5IterClose((Fts5IndexIter*)pRet); |
| 194535 | 195300 | pRet = 0; |
| 194536 | 195301 | fts5CloseReader(p); |
| 194537 | 195302 | } |
| 194538 | 195303 | |
| 194539 | 195304 | *ppIter = &pRet->base; |
| | @@ -196147,10 +196912,11 @@ |
| 196147 | 196912 | ** Costs are not modified by the ORDER BY clause. |
| 196148 | 196913 | */ |
| 196149 | 196914 | static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ |
| 196150 | 196915 | Fts5Table *pTab = (Fts5Table*)pVTab; |
| 196151 | 196916 | Fts5Config *pConfig = pTab->pConfig; |
| 196917 | + const int nCol = pConfig->nCol; |
| 196152 | 196918 | int idxFlags = 0; /* Parameter passed through to xFilter() */ |
| 196153 | 196919 | int bHasMatch; |
| 196154 | 196920 | int iNext; |
| 196155 | 196921 | int i; |
| 196156 | 196922 | |
| | @@ -196172,28 +196938,38 @@ |
| 196172 | 196938 | FTS5_BI_ROWID_GE, 0, 0, -1}, |
| 196173 | 196939 | }; |
| 196174 | 196940 | |
| 196175 | 196941 | int aColMap[3]; |
| 196176 | 196942 | aColMap[0] = -1; |
| 196177 | | - aColMap[1] = pConfig->nCol; |
| 196178 | | - aColMap[2] = pConfig->nCol+1; |
| 196943 | + aColMap[1] = nCol; |
| 196944 | + aColMap[2] = nCol+1; |
| 196179 | 196945 | |
| 196180 | 196946 | /* Set idxFlags flags for all WHERE clause terms that will be used. */ |
| 196181 | 196947 | for(i=0; i<pInfo->nConstraint; i++){ |
| 196182 | 196948 | struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; |
| 196183 | | - int j; |
| 196184 | | - for(j=0; j<ArraySize(aConstraint); j++){ |
| 196185 | | - struct Constraint *pC = &aConstraint[j]; |
| 196186 | | - if( p->iColumn==aColMap[pC->iCol] && p->op & pC->op ){ |
| 196187 | | - if( p->usable ){ |
| 196949 | + int iCol = p->iColumn; |
| 196950 | + |
| 196951 | + if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol) |
| 196952 | + || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol) |
| 196953 | + ){ |
| 196954 | + /* A MATCH operator or equivalent */ |
| 196955 | + if( p->usable ){ |
| 196956 | + idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16); |
| 196957 | + aConstraint[0].iConsIndex = i; |
| 196958 | + }else{ |
| 196959 | + /* As there exists an unusable MATCH constraint this is an |
| 196960 | + ** unusable plan. Set a prohibitively high cost. */ |
| 196961 | + pInfo->estimatedCost = 1e50; |
| 196962 | + return SQLITE_OK; |
| 196963 | + } |
| 196964 | + }else{ |
| 196965 | + int j; |
| 196966 | + for(j=1; j<ArraySize(aConstraint); j++){ |
| 196967 | + struct Constraint *pC = &aConstraint[j]; |
| 196968 | + if( iCol==aColMap[pC->iCol] && p->op & pC->op && p->usable ){ |
| 196188 | 196969 | pC->iConsIndex = i; |
| 196189 | 196970 | idxFlags |= pC->fts5op; |
| 196190 | | - }else if( j==0 ){ |
| 196191 | | - /* As there exists an unusable MATCH constraint this is an |
| 196192 | | - ** unusable plan. Set a prohibitively high cost. */ |
| 196193 | | - pInfo->estimatedCost = 1e50; |
| 196194 | | - return SQLITE_OK; |
| 196195 | 196971 | } |
| 196196 | 196972 | } |
| 196197 | 196973 | } |
| 196198 | 196974 | } |
| 196199 | 196975 | |
| | @@ -196764,10 +197540,11 @@ |
| 196764 | 197540 | sqlite3_value *pMatch = 0; /* <tbl> MATCH ? expression (or NULL) */ |
| 196765 | 197541 | sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */ |
| 196766 | 197542 | sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */ |
| 196767 | 197543 | sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */ |
| 196768 | 197544 | sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */ |
| 197545 | + int iCol; /* Column on LHS of MATCH operator */ |
| 196769 | 197546 | char **pzErrmsg = pConfig->pzErrmsg; |
| 196770 | 197547 | |
| 196771 | 197548 | UNUSED_PARAM(zUnused); |
| 196772 | 197549 | UNUSED_PARAM(nVal); |
| 196773 | 197550 | |
| | @@ -196794,10 +197571,12 @@ |
| 196794 | 197571 | if( BitFlagTest(idxNum, FTS5_BI_MATCH) ) pMatch = apVal[iVal++]; |
| 196795 | 197572 | if( BitFlagTest(idxNum, FTS5_BI_RANK) ) pRank = apVal[iVal++]; |
| 196796 | 197573 | if( BitFlagTest(idxNum, FTS5_BI_ROWID_EQ) ) pRowidEq = apVal[iVal++]; |
| 196797 | 197574 | if( BitFlagTest(idxNum, FTS5_BI_ROWID_LE) ) pRowidLe = apVal[iVal++]; |
| 196798 | 197575 | if( BitFlagTest(idxNum, FTS5_BI_ROWID_GE) ) pRowidGe = apVal[iVal++]; |
| 197576 | + iCol = (idxNum>>16); |
| 197577 | + assert( iCol>=0 && iCol<=pConfig->nCol ); |
| 196799 | 197578 | assert( iVal==nVal ); |
| 196800 | 197579 | bOrderByRank = ((idxNum & FTS5_BI_ORDER_RANK) ? 1 : 0); |
| 196801 | 197580 | pCsr->bDesc = bDesc = ((idxNum & FTS5_BI_ORDER_DESC) ? 1 : 0); |
| 196802 | 197581 | |
| 196803 | 197582 | /* Set the cursor upper and lower rowid limits. Only some strategies |
| | @@ -196840,11 +197619,11 @@ |
| 196840 | 197619 | ** indicates that the MATCH expression is not a full text query, |
| 196841 | 197620 | ** but a request for an internal parameter. */ |
| 196842 | 197621 | rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]); |
| 196843 | 197622 | }else{ |
| 196844 | 197623 | char **pzErr = &pTab->base.zErrMsg; |
| 196845 | | - rc = sqlite3Fts5ExprNew(pConfig, zExpr, &pCsr->pExpr, pzErr); |
| 197624 | + rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr); |
| 196846 | 197625 | if( rc==SQLITE_OK ){ |
| 196847 | 197626 | if( bOrderByRank ){ |
| 196848 | 197627 | pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; |
| 196849 | 197628 | rc = fts5CursorFirstSorted(pTab, pCsr, bDesc); |
| 196850 | 197629 | }else{ |
| | @@ -197220,11 +197999,11 @@ |
| 197220 | 197999 | int rc; |
| 197221 | 198000 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 197222 | 198001 | fts5CheckTransactionState(pTab, FTS5_SYNC, 0); |
| 197223 | 198002 | pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg; |
| 197224 | 198003 | fts5TripCursors(pTab); |
| 197225 | | - rc = sqlite3Fts5StorageSync(pTab->pStorage, 1); |
| 198004 | + rc = sqlite3Fts5StorageSync(pTab->pStorage); |
| 197226 | 198005 | pTab->pConfig->pzErrmsg = 0; |
| 197227 | 198006 | return rc; |
| 197228 | 198007 | } |
| 197229 | 198008 | |
| 197230 | 198009 | /* |
| | @@ -198031,11 +198810,11 @@ |
| 198031 | 198810 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 198032 | 198811 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 198033 | 198812 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 198034 | 198813 | fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); |
| 198035 | 198814 | fts5TripCursors(pTab); |
| 198036 | | - return sqlite3Fts5StorageSync(pTab->pStorage, 0); |
| 198815 | + return sqlite3Fts5StorageSync(pTab->pStorage); |
| 198037 | 198816 | } |
| 198038 | 198817 | |
| 198039 | 198818 | /* |
| 198040 | 198819 | ** The xRelease() method. |
| 198041 | 198820 | ** |
| | @@ -198044,11 +198823,11 @@ |
| 198044 | 198823 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 198045 | 198824 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 198046 | 198825 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 198047 | 198826 | fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); |
| 198048 | 198827 | fts5TripCursors(pTab); |
| 198049 | | - return sqlite3Fts5StorageSync(pTab->pStorage, 0); |
| 198828 | + return sqlite3Fts5StorageSync(pTab->pStorage); |
| 198050 | 198829 | } |
| 198051 | 198830 | |
| 198052 | 198831 | /* |
| 198053 | 198832 | ** The xRollbackTo() method. |
| 198054 | 198833 | ** |
| | @@ -198255,11 +199034,11 @@ |
| 198255 | 199034 | int nArg, /* Number of args */ |
| 198256 | 199035 | sqlite3_value **apUnused /* Function arguments */ |
| 198257 | 199036 | ){ |
| 198258 | 199037 | assert( nArg==0 ); |
| 198259 | 199038 | UNUSED_PARAM2(nArg, apUnused); |
| 198260 | | - sqlite3_result_text(pCtx, "fts5: 2017-03-28 18:48:43 424a0d380332858ee55bdebc4af3789f74e70a2b3ba1cf29d84b9b4bcf3e2e37", -1, SQLITE_TRANSIENT); |
| 199039 | + sqlite3_result_text(pCtx, "fts5: 2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40", -1, SQLITE_TRANSIENT); |
| 198261 | 199040 | } |
| 198262 | 199041 | |
| 198263 | 199042 | static int fts5Init(sqlite3 *db){ |
| 198264 | 199043 | static const sqlite3_module fts5Mod = { |
| 198265 | 199044 | /* iVersion */ 2, |
| | @@ -198591,11 +199370,11 @@ |
| 198591 | 199370 | } |
| 198592 | 199371 | } |
| 198593 | 199372 | |
| 198594 | 199373 | static int sqlite3Fts5StorageRename(Fts5Storage *pStorage, const char *zName){ |
| 198595 | 199374 | Fts5Config *pConfig = pStorage->pConfig; |
| 198596 | | - int rc = sqlite3Fts5StorageSync(pStorage, 1); |
| 199375 | + int rc = sqlite3Fts5StorageSync(pStorage); |
| 198597 | 199376 | |
| 198598 | 199377 | fts5StorageRenameOne(pConfig, &rc, "data", zName); |
| 198599 | 199378 | fts5StorageRenameOne(pConfig, &rc, "idx", zName); |
| 198600 | 199379 | fts5StorageRenameOne(pConfig, &rc, "config", zName); |
| 198601 | 199380 | if( pConfig->bColumnsize ){ |
| | @@ -199454,19 +200233,19 @@ |
| 199454 | 200233 | } |
| 199455 | 200234 | |
| 199456 | 200235 | /* |
| 199457 | 200236 | ** Flush any data currently held in-memory to disk. |
| 199458 | 200237 | */ |
| 199459 | | -static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit){ |
| 200238 | +static int sqlite3Fts5StorageSync(Fts5Storage *p){ |
| 199460 | 200239 | int rc = SQLITE_OK; |
| 199461 | 200240 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 199462 | 200241 | if( p->bTotalsValid ){ |
| 199463 | 200242 | rc = fts5StorageSaveTotals(p); |
| 199464 | | - if( bCommit ) p->bTotalsValid = 0; |
| 200243 | + p->bTotalsValid = 0; |
| 199465 | 200244 | } |
| 199466 | 200245 | if( rc==SQLITE_OK ){ |
| 199467 | | - rc = sqlite3Fts5IndexSync(p->pIndex, bCommit); |
| 200246 | + rc = sqlite3Fts5IndexSync(p->pIndex); |
| 199468 | 200247 | } |
| 199469 | 200248 | sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid); |
| 199470 | 200249 | return rc; |
| 199471 | 200250 | } |
| 199472 | 200251 | |
| 199473 | 200252 | |