diff options
| author | 2023-11-22 18:23:34 +0100 | |
|---|---|---|
| committer | 2023-11-22 18:23:34 +0100 | |
| commit | 72dea06ef909328a021c242e96f1e9abd133f60c (patch) | |
| tree | 4728c25478ac732ac12f03ecf159d25674402adf /c/sqlite3.c | |
| parent | Update vtab.zig (diff) | |
| parent | Merged from upstream (diff) | |
| download | zig-sqlite-72dea06ef909328a021c242e96f1e9abd133f60c.tar.gz zig-sqlite-72dea06ef909328a021c242e96f1e9abd133f60c.tar.xz zig-sqlite-72dea06ef909328a021c242e96f1e9abd133f60c.zip | |
Merge pull request #143 from edyu/master
Update to sqlite 3.44.0
Diffstat (limited to 'c/sqlite3.c')
| -rw-r--r-- | c/sqlite3.c | 6485 |
1 files changed, 4144 insertions, 2341 deletions
diff --git a/c/sqlite3.c b/c/sqlite3.c index 1884b08..8f9309a 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.43.1. By combining all the individual C code files into this | 3 | ** version 3.44.0. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements | 6 | ** possible if the files were compiled separately. Performance improvements |
| @@ -18,7 +18,7 @@ | |||
| 18 | ** separate file. This file contains only code for the core SQLite library. | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | ** | 19 | ** |
| 20 | ** The content in this amalgamation comes from Fossil check-in | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | ** d3a40c05c49e1a49264912b1a05bc2143ac. | 21 | ** 17129ba1ff7f0daf37100ee82d507aef7827. |
| 22 | */ | 22 | */ |
| 23 | #define SQLITE_CORE 1 | 23 | #define SQLITE_CORE 1 |
| 24 | #define SQLITE_AMALGAMATION 1 | 24 | #define SQLITE_AMALGAMATION 1 |
| @@ -459,9 +459,9 @@ extern "C" { | |||
| 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | ** [sqlite_version()] and [sqlite_source_id()]. | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | */ | 461 | */ |
| 462 | #define SQLITE_VERSION "3.43.1" | 462 | #define SQLITE_VERSION "3.44.0" |
| 463 | #define SQLITE_VERSION_NUMBER 3043001 | 463 | #define SQLITE_VERSION_NUMBER 3044000 |
| 464 | #define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" | 464 | #define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" |
| 465 | 465 | ||
| 466 | /* | 466 | /* |
| 467 | ** CAPI3REF: Run-Time Library Version Numbers | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -2440,7 +2440,7 @@ struct sqlite3_mem_methods { | |||
| 2440 | ** is stored in each sorted record and the required column values loaded | 2440 | ** is stored in each sorted record and the required column values loaded |
| 2441 | ** from the database as records are returned in sorted order. The default | 2441 | ** from the database as records are returned in sorted order. The default |
| 2442 | ** value for this option is to never use this optimization. Specifying a | 2442 | ** value for this option is to never use this optimization. Specifying a |
| 2443 | ** negative value for this option restores the default behaviour. | 2443 | ** negative value for this option restores the default behavior. |
| 2444 | ** This option is only available if SQLite is compiled with the | 2444 | ** This option is only available if SQLite is compiled with the |
| 2445 | ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. | 2445 | ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. |
| 2446 | ** | 2446 | ** |
| @@ -2615,7 +2615,7 @@ struct sqlite3_mem_methods { | |||
| 2615 | ** database handle, SQLite checks if this will mean that there are now no | 2615 | ** database handle, SQLite checks if this will mean that there are now no |
| 2616 | ** connections at all to the database. If so, it performs a checkpoint | 2616 | ** connections at all to the database. If so, it performs a checkpoint |
| 2617 | ** operation before closing the connection. This option may be used to | 2617 | ** operation before closing the connection. This option may be used to |
| 2618 | ** override this behaviour. The first parameter passed to this operation | 2618 | ** override this behavior. The first parameter passed to this operation |
| 2619 | ** is an integer - positive to disable checkpoints-on-close, or zero (the | 2619 | ** is an integer - positive to disable checkpoints-on-close, or zero (the |
| 2620 | ** default) to enable them, and negative to leave the setting unchanged. | 2620 | ** default) to enable them, and negative to leave the setting unchanged. |
| 2621 | ** The second parameter is a pointer to an integer | 2621 | ** The second parameter is a pointer to an integer |
| @@ -4268,6 +4268,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename); | |||
| 4268 | ** | 4268 | ** |
| 4269 | ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | 4269 | ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language |
| 4270 | ** text that describes the error, as either UTF-8 or UTF-16 respectively. | 4270 | ** text that describes the error, as either UTF-8 or UTF-16 respectively. |
| 4271 | ** (See how SQLite handles [invalid UTF] for exceptions to this rule.) | ||
| 4271 | ** ^(Memory to hold the error message string is managed internally. | 4272 | ** ^(Memory to hold the error message string is managed internally. |
| 4272 | ** The application does not need to worry about freeing the result. | 4273 | ** The application does not need to worry about freeing the result. |
| 4273 | ** However, the error string might be overwritten or deallocated by | 4274 | ** However, the error string might be overwritten or deallocated by |
| @@ -5638,6 +5639,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); | |||
| 5638 | */ | 5639 | */ |
| 5639 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); | 5640 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5640 | 5641 | ||
| 5642 | |||
| 5641 | /* | 5643 | /* |
| 5642 | ** CAPI3REF: Create Or Redefine SQL Functions | 5644 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5643 | ** KEYWORDS: {function creation routines} | 5645 | ** KEYWORDS: {function creation routines} |
| @@ -6192,32 +6194,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); | |||
| 6192 | ** METHOD: sqlite3_context | 6194 | ** METHOD: sqlite3_context |
| 6193 | ** | 6195 | ** |
| 6194 | ** These functions may be used by (non-aggregate) SQL functions to | 6196 | ** These functions may be used by (non-aggregate) SQL functions to |
| 6195 | ** associate metadata with argument values. If the same value is passed to | 6197 | ** associate auxiliary data with argument values. If the same argument |
| 6196 | ** multiple invocations of the same SQL function during query execution, under | 6198 | ** value is passed to multiple invocations of the same SQL function during |
| 6197 | ** some circumstances the associated metadata may be preserved. An example | 6199 | ** query execution, under some circumstances the associated auxiliary data |
| 6198 | ** of where this might be useful is in a regular-expression matching | 6200 | ** might be preserved. An example of where this might be useful is in a |
| 6199 | ** function. The compiled version of the regular expression can be stored as | 6201 | ** regular-expression matching function. The compiled version of the regular |
| 6200 | ** metadata associated with the pattern string. | 6202 | ** expression can be stored as auxiliary data associated with the pattern string. |
| 6201 | ** Then as long as the pattern string remains the same, | 6203 | ** Then as long as the pattern string remains the same, |
| 6202 | ** the compiled regular expression can be reused on multiple | 6204 | ** the compiled regular expression can be reused on multiple |
| 6203 | ** invocations of the same function. | 6205 | ** invocations of the same function. |
| 6204 | ** | 6206 | ** |
| 6205 | ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata | 6207 | ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data |
| 6206 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument | 6208 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 6207 | ** value to the application-defined function. ^N is zero for the left-most | 6209 | ** value to the application-defined function. ^N is zero for the left-most |
| 6208 | ** function argument. ^If there is no metadata | 6210 | ** function argument. ^If there is no auxiliary data |
| 6209 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface | 6211 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 6210 | ** returns a NULL pointer. | 6212 | ** returns a NULL pointer. |
| 6211 | ** | 6213 | ** |
| 6212 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th | 6214 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the |
| 6213 | ** argument of the application-defined function. ^Subsequent | 6215 | ** N-th argument of the application-defined function. ^Subsequent |
| 6214 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent | 6216 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| 6215 | ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or | 6217 | ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or |
| 6216 | ** NULL if the metadata has been discarded. | 6218 | ** NULL if the auxiliary data has been discarded. |
| 6217 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, | 6219 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 6218 | ** SQLite will invoke the destructor function X with parameter P exactly | 6220 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 6219 | ** once, when the metadata is discarded. | 6221 | ** once, when the auxiliary data is discarded. |
| 6220 | ** SQLite is free to discard the metadata at any time, including: <ul> | 6222 | ** SQLite is free to discard the auxiliary data at any time, including: <ul> |
| 6221 | ** <li> ^(when the corresponding function parameter changes)^, or | 6223 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 6222 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the | 6224 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 6223 | ** SQL statement)^, or | 6225 | ** SQL statement)^, or |
| @@ -6233,7 +6235,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); | |||
| 6233 | ** function implementation should not make any use of P after | 6235 | ** function implementation should not make any use of P after |
| 6234 | ** sqlite3_set_auxdata() has been called. | 6236 | ** sqlite3_set_auxdata() has been called. |
| 6235 | ** | 6237 | ** |
| 6236 | ** ^(In practice, metadata is preserved between function calls for | 6238 | ** ^(In practice, auxiliary data is preserved between function calls for |
| 6237 | ** function parameters that are compile-time constants, including literal | 6239 | ** function parameters that are compile-time constants, including literal |
| 6238 | ** values and [parameters] and expressions composed from the same.)^ | 6240 | ** values and [parameters] and expressions composed from the same.)^ |
| 6239 | ** | 6241 | ** |
| @@ -6243,10 +6245,67 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); | |||
| 6243 | ** | 6245 | ** |
| 6244 | ** These routines must be called from the same thread in which | 6246 | ** These routines must be called from the same thread in which |
| 6245 | ** the SQL function is running. | 6247 | ** the SQL function is running. |
| 6248 | ** | ||
| 6249 | ** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. | ||
| 6246 | */ | 6250 | */ |
| 6247 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); | 6251 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 6248 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); | 6252 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 6249 | 6253 | ||
| 6254 | /* | ||
| 6255 | ** CAPI3REF: Database Connection Client Data | ||
| 6256 | ** METHOD: sqlite3 | ||
| 6257 | ** | ||
| 6258 | ** These functions are used to associate one or more named pointers | ||
| 6259 | ** with a [database connection]. | ||
| 6260 | ** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P | ||
| 6261 | ** to be attached to [database connection] D using name N. Subsequent | ||
| 6262 | ** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P | ||
| 6263 | ** or a NULL pointer if there were no prior calls to | ||
| 6264 | ** sqlite3_set_clientdata() with the same values of D and N. | ||
| 6265 | ** Names are compared using strcmp() and are thus case sensitive. | ||
| 6266 | ** | ||
| 6267 | ** If P and X are both non-NULL, then the destructor X is invoked with | ||
| 6268 | ** argument P on the first of the following occurrences: | ||
| 6269 | ** <ul> | ||
| 6270 | ** <li> An out-of-memory error occurs during the call to | ||
| 6271 | ** sqlite3_set_clientdata() which attempts to register pointer P. | ||
| 6272 | ** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made | ||
| 6273 | ** with the same D and N parameters. | ||
| 6274 | ** <li> The database connection closes. SQLite does not make any guarantees | ||
| 6275 | ** about the order in which destructors are called, only that all | ||
| 6276 | ** destructors will be called exactly once at some point during the | ||
| 6277 | ** database connection closing process. | ||
| 6278 | ** </ul> | ||
| 6279 | ** | ||
| 6280 | ** SQLite does not do anything with client data other than invoke | ||
| 6281 | ** destructors on the client data at the appropriate time. The intended | ||
| 6282 | ** use for client data is to provide a mechanism for wrapper libraries | ||
| 6283 | ** to store additional information about an SQLite database connection. | ||
| 6284 | ** | ||
| 6285 | ** There is no limit (other than available memory) on the number of different | ||
| 6286 | ** client data pointers (with different names) that can be attached to a | ||
| 6287 | ** single database connection. However, the implementation is optimized | ||
| 6288 | ** for the case of having only one or two different client data names. | ||
| 6289 | ** Applications and wrapper libraries are discouraged from using more than | ||
| 6290 | ** one client data name each. | ||
| 6291 | ** | ||
| 6292 | ** There is no way to enumerate the client data pointers | ||
| 6293 | ** associated with a database connection. The N parameter can be thought | ||
| 6294 | ** of as a secret key such that only code that knows the secret key is able | ||
| 6295 | ** to access the associated data. | ||
| 6296 | ** | ||
| 6297 | ** Security Warning: These interfaces should not be exposed in scripting | ||
| 6298 | ** languages or in other circumstances where it might be possible for an | ||
| 6299 | ** an attacker to invoke them. Any agent that can invoke these interfaces | ||
| 6300 | ** can probably also take control of the process. | ||
| 6301 | ** | ||
| 6302 | ** Database connection client data is only available for SQLite | ||
| 6303 | ** version 3.44.0 ([dateof:3.44.0]) and later. | ||
| 6304 | ** | ||
| 6305 | ** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. | ||
| 6306 | */ | ||
| 6307 | SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); | ||
| 6308 | SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); | ||
| 6250 | 6309 | ||
| 6251 | /* | 6310 | /* |
| 6252 | ** CAPI3REF: Constants Defining Special Destructor Behavior | 6311 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| @@ -6879,7 +6938,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); | |||
| 6879 | SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); | 6938 | SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); |
| 6880 | 6939 | ||
| 6881 | /* | 6940 | /* |
| 6882 | ** CAPI3REF: Allowed return values from [sqlite3_txn_state()] | 6941 | ** CAPI3REF: Allowed return values from sqlite3_txn_state() |
| 6883 | ** KEYWORDS: {transaction state} | 6942 | ** KEYWORDS: {transaction state} |
| 6884 | ** | 6943 | ** |
| 6885 | ** These constants define the current transaction state of a database file. | 6944 | ** These constants define the current transaction state of a database file. |
| @@ -7011,7 +7070,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); | |||
| 7011 | ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all | 7070 | ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all |
| 7012 | ** previous invocations for that database connection. ^If the callback | 7071 | ** previous invocations for that database connection. ^If the callback |
| 7013 | ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, | 7072 | ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, |
| 7014 | ** then the autovacuum steps callback is cancelled. The return value | 7073 | ** then the autovacuum steps callback is canceled. The return value |
| 7015 | ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might | 7074 | ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might |
| 7016 | ** be some other error code if something goes wrong. The current | 7075 | ** be some other error code if something goes wrong. The current |
| 7017 | ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other | 7076 | ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other |
| @@ -7530,6 +7589,10 @@ struct sqlite3_module { | |||
| 7530 | /* The methods above are in versions 1 and 2 of the sqlite_module object. | 7589 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7531 | ** Those below are for version 3 and greater. */ | 7590 | ** Those below are for version 3 and greater. */ |
| 7532 | int (*xShadowName)(const char*); | 7591 | int (*xShadowName)(const char*); |
| 7592 | /* The methods above are in versions 1 through 3 of the sqlite_module object. | ||
| 7593 | ** Those below are for version 4 and greater. */ | ||
| 7594 | int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema, | ||
| 7595 | const char *zTabName, int mFlags, char **pzErr); | ||
| 7533 | }; | 7596 | }; |
| 7534 | 7597 | ||
| 7535 | /* | 7598 | /* |
| @@ -8017,7 +8080,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); | |||
| 8017 | ** code is returned and the transaction rolled back. | 8080 | ** code is returned and the transaction rolled back. |
| 8018 | ** | 8081 | ** |
| 8019 | ** Calling this function with an argument that is not a NULL pointer or an | 8082 | ** Calling this function with an argument that is not a NULL pointer or an |
| 8020 | ** open blob handle results in undefined behaviour. ^Calling this routine | 8083 | ** open blob handle results in undefined behavior. ^Calling this routine |
| 8021 | ** with a null pointer (such as would be returned by a failed call to | 8084 | ** with a null pointer (such as would be returned by a failed call to |
| 8022 | ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function | 8085 | ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function |
| 8023 | ** is passed a valid open blob handle, the values returned by the | 8086 | ** is passed a valid open blob handle, the values returned by the |
| @@ -8497,6 +8560,7 @@ SQLITE_API int sqlite3_test_control(int op, ...); | |||
| 8497 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 | 8560 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8498 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 | 8561 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8499 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ | 8562 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8563 | #define SQLITE_TESTCTRL_FK_NO_ACTION 7 | ||
| 8500 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 | 8564 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8501 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 | 8565 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8502 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 | 8566 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| @@ -9558,8 +9622,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); | |||
| 9558 | ** blocked connection already has a registered unlock-notify callback, | 9622 | ** blocked connection already has a registered unlock-notify callback, |
| 9559 | ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is | 9623 | ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is |
| 9560 | ** called with a NULL pointer as its second argument, then any existing | 9624 | ** called with a NULL pointer as its second argument, then any existing |
| 9561 | ** unlock-notify callback is cancelled. ^The blocked connections | 9625 | ** unlock-notify callback is canceled. ^The blocked connections |
| 9562 | ** unlock-notify callback may also be cancelled by closing the blocked | 9626 | ** unlock-notify callback may also be canceled by closing the blocked |
| 9563 | ** connection using [sqlite3_close()]. | 9627 | ** connection using [sqlite3_close()]. |
| 9564 | ** | 9628 | ** |
| 9565 | ** The unlock-notify callback is not reentrant. If an application invokes | 9629 | ** The unlock-notify callback is not reentrant. If an application invokes |
| @@ -10862,6 +10926,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c | |||
| 10862 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy | 10926 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10863 | ** of the database exists. | 10927 | ** of the database exists. |
| 10864 | ** | 10928 | ** |
| 10929 | ** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, | ||
| 10930 | ** the returned buffer content will remain accessible and unchanged | ||
| 10931 | ** until either the next write operation on the connection or when | ||
| 10932 | ** the connection is closed, and applications must not modify the | ||
| 10933 | ** buffer. If the bit had been clear, the returned buffer will not | ||
| 10934 | ** be accessed by SQLite after the call. | ||
| 10935 | ** | ||
| 10865 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the | 10936 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10866 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory | 10937 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10867 | ** allocation error occurs. | 10938 | ** allocation error occurs. |
| @@ -10910,6 +10981,9 @@ SQLITE_API unsigned char *sqlite3_serialize( | |||
| 10910 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() | 10981 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() |
| 10911 | ** if writes on the database cause it to grow larger than M bytes. | 10982 | ** if writes on the database cause it to grow larger than M bytes. |
| 10912 | ** | 10983 | ** |
| 10984 | ** Applications must not modify the buffer P or invalidate it before | ||
| 10985 | ** the database connection D is closed. | ||
| 10986 | ** | ||
| 10913 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the | 10987 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 10914 | ** database is currently in a read transaction or is involved in a backup | 10988 | ** database is currently in a read transaction or is involved in a backup |
| 10915 | ** operation. | 10989 | ** operation. |
| @@ -10918,6 +10992,13 @@ SQLITE_API unsigned char *sqlite3_serialize( | |||
| 10918 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the | 10992 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10919 | ** function returns SQLITE_ERROR. | 10993 | ** function returns SQLITE_ERROR. |
| 10920 | ** | 10994 | ** |
| 10995 | ** The deserialized database should not be in [WAL mode]. If the database | ||
| 10996 | ** is in WAL mode, then any attempt to use the database file will result | ||
| 10997 | ** in an [SQLITE_CANTOPEN] error. The application can set the | ||
| 10998 | ** [file format version numbers] (bytes 18 and 19) of the input database P | ||
| 10999 | ** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the | ||
| 11000 | ** database file into rollback mode and work around this limitation. | ||
| 11001 | ** | ||
| 10921 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the | 11002 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10922 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then | 11003 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10923 | ** [sqlite3_free()] is invoked on argument P prior to returning. | 11004 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| @@ -11991,6 +12072,18 @@ SQLITE_API int sqlite3changeset_concat( | |||
| 11991 | 12072 | ||
| 11992 | 12073 | ||
| 11993 | /* | 12074 | /* |
| 12075 | ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset | ||
| 12076 | */ | ||
| 12077 | SQLITE_API int sqlite3changeset_upgrade( | ||
| 12078 | sqlite3 *db, | ||
| 12079 | const char *zDb, | ||
| 12080 | int nIn, const void *pIn, /* Input changeset */ | ||
| 12081 | int *pnOut, void **ppOut /* OUT: Inverse of input */ | ||
| 12082 | ); | ||
| 12083 | |||
| 12084 | |||
| 12085 | |||
| 12086 | /* | ||
| 11994 | ** CAPI3REF: Changegroup Handle | 12087 | ** CAPI3REF: Changegroup Handle |
| 11995 | ** | 12088 | ** |
| 11996 | ** A changegroup is an object used to combine two or more | 12089 | ** A changegroup is an object used to combine two or more |
| @@ -12037,6 +12130,38 @@ typedef struct sqlite3_changegroup sqlite3_changegroup; | |||
| 12037 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); | 12130 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 12038 | 12131 | ||
| 12039 | /* | 12132 | /* |
| 12133 | ** CAPI3REF: Add a Schema to a Changegroup | ||
| 12134 | ** METHOD: sqlite3_changegroup_schema | ||
| 12135 | ** | ||
| 12136 | ** This method may be used to optionally enforce the rule that the changesets | ||
| 12137 | ** added to the changegroup handle must match the schema of database zDb | ||
| 12138 | ** ("main", "temp", or the name of an attached database). If | ||
| 12139 | ** sqlite3changegroup_add() is called to add a changeset that is not compatible | ||
| 12140 | ** with the configured schema, SQLITE_SCHEMA is returned and the changegroup | ||
| 12141 | ** object is left in an undefined state. | ||
| 12142 | ** | ||
| 12143 | ** A changeset schema is considered compatible with the database schema in | ||
| 12144 | ** the same way as for sqlite3changeset_apply(). Specifically, for each | ||
| 12145 | ** table in the changeset, there exists a database table with: | ||
| 12146 | ** | ||
| 12147 | ** <ul> | ||
| 12148 | ** <li> The name identified by the changeset, and | ||
| 12149 | ** <li> at least as many columns as recorded in the changeset, and | ||
| 12150 | ** <li> the primary key columns in the same position as recorded in | ||
| 12151 | ** the changeset. | ||
| 12152 | ** </ul> | ||
| 12153 | ** | ||
| 12154 | ** The output of the changegroup object always has the same schema as the | ||
| 12155 | ** database nominated using this function. In cases where changesets passed | ||
| 12156 | ** to sqlite3changegroup_add() have fewer columns than the corresponding table | ||
| 12157 | ** in the database schema, these are filled in using the default column | ||
| 12158 | ** values from the database schema. This makes it possible to combined | ||
| 12159 | ** changesets that have different numbers of columns for a single table | ||
| 12160 | ** within a changegroup, provided that they are otherwise compatible. | ||
| 12161 | */ | ||
| 12162 | SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); | ||
| 12163 | |||
| 12164 | /* | ||
| 12040 | ** CAPI3REF: Add A Changeset To A Changegroup | 12165 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 12041 | ** METHOD: sqlite3_changegroup | 12166 | ** METHOD: sqlite3_changegroup |
| 12042 | ** | 12167 | ** |
| @@ -12104,13 +12229,18 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); | |||
| 12104 | ** If the new changeset contains changes to a table that is already present | 12229 | ** If the new changeset contains changes to a table that is already present |
| 12105 | ** in the changegroup, then the number of columns and the position of the | 12230 | ** in the changegroup, then the number of columns and the position of the |
| 12106 | ** primary key columns for the table must be consistent. If this is not the | 12231 | ** primary key columns for the table must be consistent. If this is not the |
| 12107 | ** case, this function fails with SQLITE_SCHEMA. If the input changeset | 12232 | ** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup |
| 12108 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is | 12233 | ** object has been configured with a database schema using the |
| 12109 | ** returned. Or, if an out-of-memory condition occurs during processing, this | 12234 | ** sqlite3changegroup_schema() API, then it is possible to combine changesets |
| 12110 | ** function returns SQLITE_NOMEM. In all cases, if an error occurs the state | 12235 | ** with different numbers of columns for a single table, provided that |
| 12111 | ** of the final contents of the changegroup is undefined. | 12236 | ** they are otherwise compatible. |
| 12112 | ** | 12237 | ** |
| 12113 | ** If no error occurs, SQLITE_OK is returned. | 12238 | ** If the input changeset appears to be corrupt and the corruption is |
| 12239 | ** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition | ||
| 12240 | ** occurs during processing, this function returns SQLITE_NOMEM. | ||
| 12241 | ** | ||
| 12242 | ** In all cases, if an error occurs the state of the final contents of the | ||
| 12243 | ** changegroup is undefined. If no error occurs, SQLITE_OK is returned. | ||
| 12114 | */ | 12244 | */ |
| 12115 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); | 12245 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 12116 | 12246 | ||
| @@ -12375,10 +12505,17 @@ SQLITE_API int sqlite3changeset_apply_v2( | |||
| 12375 | ** <li>an insert change if all fields of the conflicting row match | 12505 | ** <li>an insert change if all fields of the conflicting row match |
| 12376 | ** the row being inserted. | 12506 | ** the row being inserted. |
| 12377 | ** </ul> | 12507 | ** </ul> |
| 12508 | ** | ||
| 12509 | ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd> | ||
| 12510 | ** If this flag it set, then all foreign key constraints in the target | ||
| 12511 | ** database behave as if they were declared with "ON UPDATE NO ACTION ON | ||
| 12512 | ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL | ||
| 12513 | ** or SET DEFAULT. | ||
| 12378 | */ | 12514 | */ |
| 12379 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 | 12515 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12380 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 | 12516 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12381 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 | 12517 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12518 | #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 | ||
| 12382 | 12519 | ||
| 12383 | /* | 12520 | /* |
| 12384 | ** CAPI3REF: Constants Passed To The Conflict Handler | 12521 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| @@ -13770,6 +13907,16 @@ struct fts5_api { | |||
| 13770 | #endif | 13907 | #endif |
| 13771 | 13908 | ||
| 13772 | /* | 13909 | /* |
| 13910 | ** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit | ||
| 13911 | ** SEH support if the -DSQLITE_OMIT_SEH option is given. | ||
| 13912 | */ | ||
| 13913 | #if defined(_MSC_VER) && !defined(SQLITE_OMIT_SEH) | ||
| 13914 | # define SQLITE_USE_SEH 1 | ||
| 13915 | #else | ||
| 13916 | # undef SQLITE_USE_SEH | ||
| 13917 | #endif | ||
| 13918 | |||
| 13919 | /* | ||
| 13773 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. | 13920 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
| 13774 | ** 0 means mutexes are permanently disable and the library is never | 13921 | ** 0 means mutexes are permanently disable and the library is never |
| 13775 | ** threadsafe. 1 means the library is serialized which is the highest | 13922 | ** threadsafe. 1 means the library is serialized which is the highest |
| @@ -14662,16 +14809,33 @@ typedef INT16_TYPE LogEst; | |||
| 14662 | ** using C-preprocessor macros. If that is unsuccessful, or if | 14809 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 14663 | ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined | 14810 | ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined |
| 14664 | ** at run-time. | 14811 | ** at run-time. |
| 14812 | ** | ||
| 14813 | ** If you are building SQLite on some obscure platform for which the | ||
| 14814 | ** following ifdef magic does not work, you can always include either: | ||
| 14815 | ** | ||
| 14816 | ** -DSQLITE_BYTEORDER=1234 | ||
| 14817 | ** | ||
| 14818 | ** or | ||
| 14819 | ** | ||
| 14820 | ** -DSQLITE_BYTEORDER=4321 | ||
| 14821 | ** | ||
| 14822 | ** to cause the build to work for little-endian or big-endian processors, | ||
| 14823 | ** respectively. | ||
| 14665 | */ | 14824 | */ |
| 14666 | #ifndef SQLITE_BYTEORDER | 14825 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 14667 | # if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | 14826 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 14827 | # define SQLITE_BYTEORDER 4321 | ||
| 14828 | # elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ | ||
| 14829 | # define SQLITE_BYTEORDER 1234 | ||
| 14830 | # elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 | ||
| 14831 | # define SQLITE_BYTEORDER 4321 | ||
| 14832 | # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | ||
| 14668 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ | 14833 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 14669 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ | 14834 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 14670 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) | 14835 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 14671 | # define SQLITE_BYTEORDER 1234 | 14836 | # define SQLITE_BYTEORDER 1234 |
| 14672 | # elif defined(sparc) || defined(__ppc__) || \ | 14837 | # elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) |
| 14673 | defined(__ARMEB__) || defined(__AARCH64EB__) | 14838 | # define SQLITE_BYTEORDER 4321 |
| 14674 | # define SQLITE_BYTEORDER 4321 | ||
| 14675 | # else | 14839 | # else |
| 14676 | # define SQLITE_BYTEORDER 0 | 14840 | # define SQLITE_BYTEORDER 0 |
| 14677 | # endif | 14841 | # endif |
| @@ -14995,6 +15159,7 @@ typedef struct Column Column; | |||
| 14995 | typedef struct Cte Cte; | 15159 | typedef struct Cte Cte; |
| 14996 | typedef struct CteUse CteUse; | 15160 | typedef struct CteUse CteUse; |
| 14997 | typedef struct Db Db; | 15161 | typedef struct Db Db; |
| 15162 | typedef struct DbClientData DbClientData; | ||
| 14998 | typedef struct DbFixer DbFixer; | 15163 | typedef struct DbFixer DbFixer; |
| 14999 | typedef struct Schema Schema; | 15164 | typedef struct Schema Schema; |
| 15000 | typedef struct Expr Expr; | 15165 | typedef struct Expr Expr; |
| @@ -16435,19 +16600,20 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 16435 | #define OP_VCreate 171 | 16600 | #define OP_VCreate 171 |
| 16436 | #define OP_VDestroy 172 | 16601 | #define OP_VDestroy 172 |
| 16437 | #define OP_VOpen 173 | 16602 | #define OP_VOpen 173 |
| 16438 | #define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */ | 16603 | #define OP_VCheck 174 |
| 16439 | #define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */ | 16604 | #define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */ |
| 16440 | #define OP_VRename 176 | 16605 | #define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */ |
| 16441 | #define OP_Pagecount 177 | 16606 | #define OP_VRename 177 |
| 16442 | #define OP_MaxPgcnt 178 | 16607 | #define OP_Pagecount 178 |
| 16443 | #define OP_ClrSubtype 179 /* synopsis: r[P1].subtype = 0 */ | 16608 | #define OP_MaxPgcnt 179 |
| 16444 | #define OP_FilterAdd 180 /* synopsis: filter(P1) += key(P3@P4) */ | 16609 | #define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */ |
| 16445 | #define OP_Trace 181 | 16610 | #define OP_FilterAdd 181 /* synopsis: filter(P1) += key(P3@P4) */ |
| 16446 | #define OP_CursorHint 182 | 16611 | #define OP_Trace 182 |
| 16447 | #define OP_ReleaseReg 183 /* synopsis: release r[P1@P2] mask P3 */ | 16612 | #define OP_CursorHint 183 |
| 16448 | #define OP_Noop 184 | 16613 | #define OP_ReleaseReg 184 /* synopsis: release r[P1@P2] mask P3 */ |
| 16449 | #define OP_Explain 185 | 16614 | #define OP_Noop 185 |
| 16450 | #define OP_Abortable 186 | 16615 | #define OP_Explain 186 |
| 16616 | #define OP_Abortable 187 | ||
| 16451 | 16617 | ||
| 16452 | /* Properties such as "out2" or "jump" that are specified in | 16618 | /* Properties such as "out2" or "jump" that are specified in |
| 16453 | ** comments following the "case" for each opcode in the vdbe.c | 16619 | ** comments following the "case" for each opcode in the vdbe.c |
| @@ -16482,9 +16648,9 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 16482 | /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ | 16648 | /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 16483 | /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ | 16649 | /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 16484 | /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 16650 | /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16485 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0x40,\ | 16651 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ |
| 16486 | /* 176 */ 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00,\ | 16652 | /* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00,\ |
| 16487 | /* 184 */ 0x00, 0x00, 0x00,} | 16653 | /* 184 */ 0x00, 0x00, 0x00, 0x00,} |
| 16488 | 16654 | ||
| 16489 | /* The resolve3P2Values() routine is able to run faster if it knows | 16655 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 16490 | ** the value of the largest JUMP opcode. The smaller the maximum | 16656 | ** the value of the largest JUMP opcode. The smaller the maximum |
| @@ -17393,6 +17559,7 @@ struct sqlite3 { | |||
| 17393 | i64 nDeferredCons; /* Net deferred constraints this transaction. */ | 17559 | i64 nDeferredCons; /* Net deferred constraints this transaction. */ |
| 17394 | i64 nDeferredImmCons; /* Net deferred immediate constraints */ | 17560 | i64 nDeferredImmCons; /* Net deferred immediate constraints */ |
| 17395 | int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ | 17561 | int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ |
| 17562 | DbClientData *pDbData; /* sqlite3_set_clientdata() content */ | ||
| 17396 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY | 17563 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 17397 | /* The following variables are all protected by the STATIC_MAIN | 17564 | /* The following variables are all protected by the STATIC_MAIN |
| 17398 | ** mutex, not by sqlite3.mutex. They are used by code in notify.c. | 17565 | ** mutex, not by sqlite3.mutex. They are used by code in notify.c. |
| @@ -17475,6 +17642,7 @@ struct sqlite3 { | |||
| 17475 | /* the count using a callback. */ | 17642 | /* the count using a callback. */ |
| 17476 | #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ | 17643 | #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ |
| 17477 | #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ | 17644 | #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ |
| 17645 | #define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */ | ||
| 17478 | 17646 | ||
| 17479 | /* Flags used only if debugging */ | 17647 | /* Flags used only if debugging */ |
| 17480 | #ifdef SQLITE_DEBUG | 17648 | #ifdef SQLITE_DEBUG |
| @@ -18490,6 +18658,9 @@ struct AggInfo { | |||
| 18490 | FuncDef *pFunc; /* The aggregate function implementation */ | 18658 | FuncDef *pFunc; /* The aggregate function implementation */ |
| 18491 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ | 18659 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ |
| 18492 | int iDistAddr; /* Address of OP_OpenEphemeral */ | 18660 | int iDistAddr; /* Address of OP_OpenEphemeral */ |
| 18661 | int iOBTab; /* Ephemeral table to implement ORDER BY */ | ||
| 18662 | u8 bOBPayload; /* iOBTab has payload columns separate from key */ | ||
| 18663 | u8 bOBUnique; /* Enforce uniqueness on iOBTab keys */ | ||
| 18493 | } *aFunc; | 18664 | } *aFunc; |
| 18494 | int nFunc; /* Number of entries in aFunc[] */ | 18665 | int nFunc; /* Number of entries in aFunc[] */ |
| 18495 | u32 selId; /* Select to which this AggInfo belongs */ | 18666 | u32 selId; /* Select to which this AggInfo belongs */ |
| @@ -18674,7 +18845,7 @@ struct Expr { | |||
| 18674 | #define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ | 18845 | #define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
| 18675 | #define EP_Win 0x008000 /* Contains window functions */ | 18846 | #define EP_Win 0x008000 /* Contains window functions */ |
| 18676 | #define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ | 18847 | #define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| 18677 | /* 0x020000 // Available for reuse */ | 18848 | #define EP_FullSize 0x020000 /* Expr structure must remain full sized */ |
| 18678 | #define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ | 18849 | #define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ |
| 18679 | #define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ | 18850 | #define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ |
| 18680 | #define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ | 18851 | #define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| @@ -18704,6 +18875,7 @@ struct Expr { | |||
| 18704 | #define ExprClearProperty(E,P) (E)->flags&=~(P) | 18875 | #define ExprClearProperty(E,P) (E)->flags&=~(P) |
| 18705 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) | 18876 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) |
| 18706 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) | 18877 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) |
| 18878 | #define ExprIsFullSize(E) (((E)->flags&(EP_Reduced|EP_TokenOnly))==0) | ||
| 18707 | 18879 | ||
| 18708 | /* Macros used to ensure that the correct members of unions are accessed | 18880 | /* Macros used to ensure that the correct members of unions are accessed |
| 18709 | ** in Expr. | 18881 | ** in Expr. |
| @@ -18821,6 +18993,7 @@ struct ExprList { | |||
| 18821 | #define ENAME_NAME 0 /* The AS clause of a result set */ | 18993 | #define ENAME_NAME 0 /* The AS clause of a result set */ |
| 18822 | #define ENAME_SPAN 1 /* Complete text of the result set expression */ | 18994 | #define ENAME_SPAN 1 /* Complete text of the result set expression */ |
| 18823 | #define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ | 18995 | #define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ |
| 18996 | #define ENAME_ROWID 3 /* "DB.TABLE._rowid_" for * expansion of rowid */ | ||
| 18824 | 18997 | ||
| 18825 | /* | 18998 | /* |
| 18826 | ** An instance of this structure can hold a simple list of identifiers, | 18999 | ** An instance of this structure can hold a simple list of identifiers, |
| @@ -19429,6 +19602,7 @@ struct Parse { | |||
| 19429 | int *aLabel; /* Space to hold the labels */ | 19602 | int *aLabel; /* Space to hold the labels */ |
| 19430 | ExprList *pConstExpr;/* Constant expressions */ | 19603 | ExprList *pConstExpr;/* Constant expressions */ |
| 19431 | IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ | 19604 | IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ |
| 19605 | IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */ | ||
| 19432 | Token constraintName;/* Name of the constraint currently being parsed */ | 19606 | Token constraintName;/* Name of the constraint currently being parsed */ |
| 19433 | yDbMask writeMask; /* Start a write transaction on these databases */ | 19607 | yDbMask writeMask; /* Start a write transaction on these databases */ |
| 19434 | yDbMask cookieMask; /* Bitmask of schema verified databases */ | 19608 | yDbMask cookieMask; /* Bitmask of schema verified databases */ |
| @@ -19700,6 +19874,7 @@ struct Returning { | |||
| 19700 | int iRetCur; /* Transient table holding RETURNING results */ | 19874 | int iRetCur; /* Transient table holding RETURNING results */ |
| 19701 | int nRetCol; /* Number of in pReturnEL after expansion */ | 19875 | int nRetCol; /* Number of in pReturnEL after expansion */ |
| 19702 | int iRetReg; /* Register array for holding a row of RETURNING */ | 19876 | int iRetReg; /* Register array for holding a row of RETURNING */ |
| 19877 | char zName[40]; /* Name of trigger: "sqlite_returning_%p" */ | ||
| 19703 | }; | 19878 | }; |
| 19704 | 19879 | ||
| 19705 | /* | 19880 | /* |
| @@ -20000,6 +20175,16 @@ struct CteUse { | |||
| 20000 | }; | 20175 | }; |
| 20001 | 20176 | ||
| 20002 | 20177 | ||
| 20178 | /* Client data associated with sqlite3_set_clientdata() and | ||
| 20179 | ** sqlite3_get_clientdata(). | ||
| 20180 | */ | ||
| 20181 | struct DbClientData { | ||
| 20182 | DbClientData *pNext; /* Next in a linked list */ | ||
| 20183 | void *pData; /* The data */ | ||
| 20184 | void (*xDestructor)(void*); /* Destructor. Might be NULL */ | ||
| 20185 | char zName[1]; /* Name of this client data. MUST BE LAST */ | ||
| 20186 | }; | ||
| 20187 | |||
| 20003 | #ifdef SQLITE_DEBUG | 20188 | #ifdef SQLITE_DEBUG |
| 20004 | /* | 20189 | /* |
| 20005 | ** An instance of the TreeView object is used for printing the content of | 20190 | ** An instance of the TreeView object is used for printing the content of |
| @@ -20404,6 +20589,8 @@ SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); | |||
| 20404 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); | 20589 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 20405 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); | 20590 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 20406 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); | 20591 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); |
| 20592 | SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy(Parse*,Expr*,ExprList*); | ||
| 20593 | SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); | ||
| 20407 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); | 20594 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 20408 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); | 20595 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 20409 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); | 20596 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| @@ -20640,6 +20827,7 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); | |||
| 20640 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); | 20827 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 20641 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); | 20828 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 20642 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); | 20829 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 20830 | SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab); | ||
| 20643 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( | 20831 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( |
| 20644 | Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); | 20832 | Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); |
| 20645 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); | 20833 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); |
| @@ -20911,7 +21099,8 @@ SQLITE_PRIVATE int sqlite3MatchEName( | |||
| 20911 | const struct ExprList_item*, | 21099 | const struct ExprList_item*, |
| 20912 | const char*, | 21100 | const char*, |
| 20913 | const char*, | 21101 | const char*, |
| 20914 | const char* | 21102 | const char*, |
| 21103 | int* | ||
| 20915 | ); | 21104 | ); |
| 20916 | SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); | 21105 | SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); |
| 20917 | SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); | 21106 | SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); |
| @@ -20968,7 +21157,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); | |||
| 20968 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); | 21157 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 20969 | 21158 | ||
| 20970 | SQLITE_PRIVATE char *sqlite3RCStrRef(char*); | 21159 | SQLITE_PRIVATE char *sqlite3RCStrRef(char*); |
| 20971 | SQLITE_PRIVATE void sqlite3RCStrUnref(char*); | 21160 | SQLITE_PRIVATE void sqlite3RCStrUnref(void*); |
| 20972 | SQLITE_PRIVATE char *sqlite3RCStrNew(u64); | 21161 | SQLITE_PRIVATE char *sqlite3RCStrNew(u64); |
| 20973 | SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); | 21162 | SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); |
| 20974 | 21163 | ||
| @@ -21804,6 +21993,9 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 21804 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS | 21993 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS |
| 21805 | "EXPLAIN_ESTIMATED_ROWS", | 21994 | "EXPLAIN_ESTIMATED_ROWS", |
| 21806 | #endif | 21995 | #endif |
| 21996 | #ifdef SQLITE_EXTRA_AUTOEXT | ||
| 21997 | "EXTRA_AUTOEXT=" CTIMEOPT_VAL(SQLITE_EXTRA_AUTOEXT), | ||
| 21998 | #endif | ||
| 21807 | #ifdef SQLITE_EXTRA_IFNULLROW | 21999 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 21808 | "EXTRA_IFNULLROW", | 22000 | "EXTRA_IFNULLROW", |
| 21809 | #endif | 22001 | #endif |
| @@ -22085,6 +22277,9 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 22085 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS | 22277 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS |
| 22086 | "OMIT_SCHEMA_VERSION_PRAGMAS", | 22278 | "OMIT_SCHEMA_VERSION_PRAGMAS", |
| 22087 | #endif | 22279 | #endif |
| 22280 | #ifdef SQLITE_OMIT_SEH | ||
| 22281 | "OMIT_SEH", | ||
| 22282 | #endif | ||
| 22088 | #ifdef SQLITE_OMIT_SHARED_CACHE | 22283 | #ifdef SQLITE_OMIT_SHARED_CACHE |
| 22089 | "OMIT_SHARED_CACHE", | 22284 | "OMIT_SHARED_CACHE", |
| 22090 | #endif | 22285 | #endif |
| @@ -25044,13 +25239,16 @@ static void strftimeFunc( | |||
| 25044 | computeJD(&x); | 25239 | computeJD(&x); |
| 25045 | computeYMD_HMS(&x); | 25240 | computeYMD_HMS(&x); |
| 25046 | for(i=j=0; zFmt[i]; i++){ | 25241 | for(i=j=0; zFmt[i]; i++){ |
| 25242 | char cf; | ||
| 25047 | if( zFmt[i]!='%' ) continue; | 25243 | if( zFmt[i]!='%' ) continue; |
| 25048 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); | 25244 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); |
| 25049 | i++; | 25245 | i++; |
| 25050 | j = i + 1; | 25246 | j = i + 1; |
| 25051 | switch( zFmt[i] ){ | 25247 | cf = zFmt[i]; |
| 25052 | case 'd': { | 25248 | switch( cf ){ |
| 25053 | sqlite3_str_appendf(&sRes, "%02d", x.D); | 25249 | case 'd': /* Fall thru */ |
| 25250 | case 'e': { | ||
| 25251 | sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D); | ||
| 25054 | break; | 25252 | break; |
| 25055 | } | 25253 | } |
| 25056 | case 'f': { | 25254 | case 'f': { |
| @@ -25059,8 +25257,21 @@ static void strftimeFunc( | |||
| 25059 | sqlite3_str_appendf(&sRes, "%06.3f", s); | 25257 | sqlite3_str_appendf(&sRes, "%06.3f", s); |
| 25060 | break; | 25258 | break; |
| 25061 | } | 25259 | } |
| 25062 | case 'H': { | 25260 | case 'F': { |
| 25063 | sqlite3_str_appendf(&sRes, "%02d", x.h); | 25261 | sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D); |
| 25262 | break; | ||
| 25263 | } | ||
| 25264 | case 'H': | ||
| 25265 | case 'k': { | ||
| 25266 | sqlite3_str_appendf(&sRes, cf=='H' ? "%02d" : "%2d", x.h); | ||
| 25267 | break; | ||
| 25268 | } | ||
| 25269 | case 'I': /* Fall thru */ | ||
| 25270 | case 'l': { | ||
| 25271 | int h = x.h; | ||
| 25272 | if( h>12 ) h -= 12; | ||
| 25273 | if( h==0 ) h = 12; | ||
| 25274 | sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h); | ||
| 25064 | break; | 25275 | break; |
| 25065 | } | 25276 | } |
| 25066 | case 'W': /* Fall thru */ | 25277 | case 'W': /* Fall thru */ |
| @@ -25072,7 +25283,7 @@ static void strftimeFunc( | |||
| 25072 | y.D = 1; | 25283 | y.D = 1; |
| 25073 | computeJD(&y); | 25284 | computeJD(&y); |
| 25074 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); | 25285 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); |
| 25075 | if( zFmt[i]=='W' ){ | 25286 | if( cf=='W' ){ |
| 25076 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ | 25287 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ |
| 25077 | wd = (int)(((x.iJD+43200000)/86400000)%7); | 25288 | wd = (int)(((x.iJD+43200000)/86400000)%7); |
| 25078 | sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); | 25289 | sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); |
| @@ -25093,6 +25304,19 @@ static void strftimeFunc( | |||
| 25093 | sqlite3_str_appendf(&sRes,"%02d",x.m); | 25304 | sqlite3_str_appendf(&sRes,"%02d",x.m); |
| 25094 | break; | 25305 | break; |
| 25095 | } | 25306 | } |
| 25307 | case 'p': /* Fall thru */ | ||
| 25308 | case 'P': { | ||
| 25309 | if( x.h>=12 ){ | ||
| 25310 | sqlite3_str_append(&sRes, cf=='p' ? "PM" : "pm", 2); | ||
| 25311 | }else{ | ||
| 25312 | sqlite3_str_append(&sRes, cf=='p' ? "AM" : "am", 2); | ||
| 25313 | } | ||
| 25314 | break; | ||
| 25315 | } | ||
| 25316 | case 'R': { | ||
| 25317 | sqlite3_str_appendf(&sRes, "%02d:%02d", x.h, x.m); | ||
| 25318 | break; | ||
| 25319 | } | ||
| 25096 | case 's': { | 25320 | case 's': { |
| 25097 | if( x.useSubsec ){ | 25321 | if( x.useSubsec ){ |
| 25098 | sqlite3_str_appendf(&sRes,"%.3f", | 25322 | sqlite3_str_appendf(&sRes,"%.3f", |
| @@ -25107,9 +25331,15 @@ static void strftimeFunc( | |||
| 25107 | sqlite3_str_appendf(&sRes,"%02d",(int)x.s); | 25331 | sqlite3_str_appendf(&sRes,"%02d",(int)x.s); |
| 25108 | break; | 25332 | break; |
| 25109 | } | 25333 | } |
| 25334 | case 'T': { | ||
| 25335 | sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s); | ||
| 25336 | break; | ||
| 25337 | } | ||
| 25338 | case 'u': /* Fall thru */ | ||
| 25110 | case 'w': { | 25339 | case 'w': { |
| 25111 | sqlite3_str_appendchar(&sRes, 1, | 25340 | char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; |
| 25112 | (char)(((x.iJD+129600000)/86400000) % 7) + '0'); | 25341 | if( c=='0' && cf=='u' ) c = '7'; |
| 25342 | sqlite3_str_appendchar(&sRes, 1, c); | ||
| 25113 | break; | 25343 | break; |
| 25114 | } | 25344 | } |
| 25115 | case 'Y': { | 25345 | case 'Y': { |
| @@ -28198,7 +28428,7 @@ static void checkMutexFree(sqlite3_mutex *p){ | |||
| 28198 | assert( SQLITE_MUTEX_FAST<2 ); | 28428 | assert( SQLITE_MUTEX_FAST<2 ); |
| 28199 | assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); | 28429 | assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); |
| 28200 | 28430 | ||
| 28201 | #if SQLITE_ENABLE_API_ARMOR | 28431 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 28202 | if( ((CheckMutex*)p)->iType<2 ) | 28432 | if( ((CheckMutex*)p)->iType<2 ) |
| 28203 | #endif | 28433 | #endif |
| 28204 | { | 28434 | { |
| @@ -28870,7 +29100,7 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){ | |||
| 28870 | */ | 29100 | */ |
| 28871 | static void pthreadMutexFree(sqlite3_mutex *p){ | 29101 | static void pthreadMutexFree(sqlite3_mutex *p){ |
| 28872 | assert( p->nRef==0 ); | 29102 | assert( p->nRef==0 ); |
| 28873 | #if SQLITE_ENABLE_API_ARMOR | 29103 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 28874 | if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) | 29104 | if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) |
| 28875 | #endif | 29105 | #endif |
| 28876 | { | 29106 | { |
| @@ -30434,7 +30664,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){ | |||
| 30434 | if( db->mallocFailed || rc ){ | 30664 | if( db->mallocFailed || rc ){ |
| 30435 | return apiHandleError(db, rc); | 30665 | return apiHandleError(db, rc); |
| 30436 | } | 30666 | } |
| 30437 | return rc & db->errMask; | 30667 | return 0; |
| 30438 | } | 30668 | } |
| 30439 | 30669 | ||
| 30440 | /************** End of malloc.c **********************************************/ | 30670 | /************** End of malloc.c **********************************************/ |
| @@ -31830,7 +32060,7 @@ SQLITE_PRIVATE char *sqlite3RCStrRef(char *z){ | |||
| 31830 | ** Decrease the reference count by one. Free the string when the | 32060 | ** Decrease the reference count by one. Free the string when the |
| 31831 | ** reference count reaches zero. | 32061 | ** reference count reaches zero. |
| 31832 | */ | 32062 | */ |
| 31833 | SQLITE_PRIVATE void sqlite3RCStrUnref(char *z){ | 32063 | SQLITE_PRIVATE void sqlite3RCStrUnref(void *z){ |
| 31834 | RCStr *p = (RCStr*)z; | 32064 | RCStr *p = (RCStr*)z; |
| 31835 | assert( p!=0 ); | 32065 | assert( p!=0 ); |
| 31836 | p--; | 32066 | p--; |
| @@ -32293,6 +32523,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u | |||
| 32293 | sqlite3TreeViewItem(pView, "FILTER", 1); | 32523 | sqlite3TreeViewItem(pView, "FILTER", 1); |
| 32294 | sqlite3TreeViewExpr(pView, pWin->pFilter, 0); | 32524 | sqlite3TreeViewExpr(pView, pWin->pFilter, 0); |
| 32295 | sqlite3TreeViewPop(&pView); | 32525 | sqlite3TreeViewPop(&pView); |
| 32526 | if( pWin->eFrmType==TK_FILTER ) return; | ||
| 32296 | } | 32527 | } |
| 32297 | sqlite3TreeViewPush(&pView, more); | 32528 | sqlite3TreeViewPush(&pView, more); |
| 32298 | if( pWin->zName ){ | 32529 | if( pWin->zName ){ |
| @@ -32302,7 +32533,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u | |||
| 32302 | } | 32533 | } |
| 32303 | if( pWin->zBase ) nElement++; | 32534 | if( pWin->zBase ) nElement++; |
| 32304 | if( pWin->pOrderBy ) nElement++; | 32535 | if( pWin->pOrderBy ) nElement++; |
| 32305 | if( pWin->eFrmType ) nElement++; | 32536 | if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ) nElement++; |
| 32306 | if( pWin->eExclude ) nElement++; | 32537 | if( pWin->eExclude ) nElement++; |
| 32307 | if( pWin->zBase ){ | 32538 | if( pWin->zBase ){ |
| 32308 | sqlite3TreeViewPush(&pView, (--nElement)>0); | 32539 | sqlite3TreeViewPush(&pView, (--nElement)>0); |
| @@ -32315,7 +32546,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u | |||
| 32315 | if( pWin->pOrderBy ){ | 32546 | if( pWin->pOrderBy ){ |
| 32316 | sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); | 32547 | sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); |
| 32317 | } | 32548 | } |
| 32318 | if( pWin->eFrmType ){ | 32549 | if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ){ |
| 32319 | char zBuf[30]; | 32550 | char zBuf[30]; |
| 32320 | const char *zFrmType = "ROWS"; | 32551 | const char *zFrmType = "ROWS"; |
| 32321 | if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; | 32552 | if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; |
| @@ -32563,7 +32794,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 32563 | assert( ExprUseXList(pExpr) ); | 32794 | assert( ExprUseXList(pExpr) ); |
| 32564 | pFarg = pExpr->x.pList; | 32795 | pFarg = pExpr->x.pList; |
| 32565 | #ifndef SQLITE_OMIT_WINDOWFUNC | 32796 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32566 | pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; | 32797 | pWin = IsWindowFunc(pExpr) ? pExpr->y.pWin : 0; |
| 32567 | #else | 32798 | #else |
| 32568 | pWin = 0; | 32799 | pWin = 0; |
| 32569 | #endif | 32800 | #endif |
| @@ -32589,7 +32820,13 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 32589 | sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); | 32820 | sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); |
| 32590 | } | 32821 | } |
| 32591 | if( pFarg ){ | 32822 | if( pFarg ){ |
| 32592 | sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0); | 32823 | sqlite3TreeViewExprList(pView, pFarg, pWin!=0 || pExpr->pLeft, 0); |
| 32824 | if( pExpr->pLeft ){ | ||
| 32825 | Expr *pOB = pExpr->pLeft; | ||
| 32826 | assert( pOB->op==TK_ORDER ); | ||
| 32827 | assert( ExprUseXList(pOB) ); | ||
| 32828 | sqlite3TreeViewExprList(pView, pOB->x.pList, pWin!=0, "ORDERBY"); | ||
| 32829 | } | ||
| 32593 | } | 32830 | } |
| 32594 | #ifndef SQLITE_OMIT_WINDOWFUNC | 32831 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32595 | if( pWin ){ | 32832 | if( pWin ){ |
| @@ -32598,6 +32835,10 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 32598 | #endif | 32835 | #endif |
| 32599 | break; | 32836 | break; |
| 32600 | } | 32837 | } |
| 32838 | case TK_ORDER: { | ||
| 32839 | sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, "ORDERBY"); | ||
| 32840 | break; | ||
| 32841 | } | ||
| 32601 | #ifndef SQLITE_OMIT_SUBQUERY | 32842 | #ifndef SQLITE_OMIT_SUBQUERY |
| 32602 | case TK_EXISTS: { | 32843 | case TK_EXISTS: { |
| 32603 | assert( ExprUseXSelect(pExpr) ); | 32844 | assert( ExprUseXSelect(pExpr) ); |
| @@ -34362,12 +34603,16 @@ SQLITE_PRIVATE void sqlite3ProgressCheck(Parse *p){ | |||
| 34362 | p->rc = SQLITE_INTERRUPT; | 34603 | p->rc = SQLITE_INTERRUPT; |
| 34363 | } | 34604 | } |
| 34364 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK | 34605 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 34365 | if( db->xProgress && (++p->nProgressSteps)>=db->nProgressOps ){ | 34606 | if( db->xProgress ){ |
| 34366 | if( db->xProgress(db->pProgressArg) ){ | 34607 | if( p->rc==SQLITE_INTERRUPT ){ |
| 34367 | p->nErr++; | 34608 | p->nProgressSteps = 0; |
| 34368 | p->rc = SQLITE_INTERRUPT; | 34609 | }else if( (++p->nProgressSteps)>=db->nProgressOps ){ |
| 34610 | if( db->xProgress(db->pProgressArg) ){ | ||
| 34611 | p->nErr++; | ||
| 34612 | p->rc = SQLITE_INTERRUPT; | ||
| 34613 | } | ||
| 34614 | p->nProgressSteps = 0; | ||
| 34369 | } | 34615 | } |
| 34370 | p->nProgressSteps = 0; | ||
| 34371 | } | 34616 | } |
| 34372 | #endif | 34617 | #endif |
| 34373 | } | 34618 | } |
| @@ -35185,29 +35430,29 @@ SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRou | |||
| 35185 | double rr[2]; | 35430 | double rr[2]; |
| 35186 | rr[0] = r; | 35431 | rr[0] = r; |
| 35187 | rr[1] = 0.0; | 35432 | rr[1] = 0.0; |
| 35188 | if( rr[0]>1.84e+19 ){ | 35433 | if( rr[0]>9.223372036854774784e+18 ){ |
| 35189 | while( rr[0]>1.84e+119 ){ | 35434 | while( rr[0]>9.223372036854774784e+118 ){ |
| 35190 | exp += 100; | 35435 | exp += 100; |
| 35191 | dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); | 35436 | dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); |
| 35192 | } | 35437 | } |
| 35193 | while( rr[0]>1.84e+29 ){ | 35438 | while( rr[0]>9.223372036854774784e+28 ){ |
| 35194 | exp += 10; | 35439 | exp += 10; |
| 35195 | dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); | 35440 | dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); |
| 35196 | } | 35441 | } |
| 35197 | while( rr[0]>1.84e+19 ){ | 35442 | while( rr[0]>9.223372036854774784e+18 ){ |
| 35198 | exp += 1; | 35443 | exp += 1; |
| 35199 | dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); | 35444 | dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); |
| 35200 | } | 35445 | } |
| 35201 | }else{ | 35446 | }else{ |
| 35202 | while( rr[0]<1.84e-82 ){ | 35447 | while( rr[0]<9.223372036854774784e-83 ){ |
| 35203 | exp -= 100; | 35448 | exp -= 100; |
| 35204 | dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); | 35449 | dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); |
| 35205 | } | 35450 | } |
| 35206 | while( rr[0]<1.84e+08 ){ | 35451 | while( rr[0]<9.223372036854774784e+07 ){ |
| 35207 | exp -= 10; | 35452 | exp -= 10; |
| 35208 | dekkerMul2(rr, 1.0e+10, 0.0); | 35453 | dekkerMul2(rr, 1.0e+10, 0.0); |
| 35209 | } | 35454 | } |
| 35210 | while( rr[0]<1.84e+18 ){ | 35455 | while( rr[0]<9.22337203685477478e+17 ){ |
| 35211 | exp -= 1; | 35456 | exp -= 1; |
| 35212 | dekkerMul2(rr, 1.0e+01, 0.0); | 35457 | dekkerMul2(rr, 1.0e+01, 0.0); |
| 35213 | } | 35458 | } |
| @@ -35523,121 +35768,32 @@ SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){ | |||
| 35523 | ** this function assumes the single-byte case has already been handled. | 35768 | ** this function assumes the single-byte case has already been handled. |
| 35524 | */ | 35769 | */ |
| 35525 | SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ | 35770 | SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ |
| 35526 | u32 a,b; | 35771 | u64 v64; |
| 35772 | u8 n; | ||
| 35527 | 35773 | ||
| 35528 | /* The 1-byte case. Overwhelmingly the most common. Handled inline | 35774 | /* Assume that the single-byte case has already been handled by |
| 35529 | ** by the getVarin32() macro */ | 35775 | ** the getVarint32() macro */ |
| 35530 | a = *p; | 35776 | assert( (p[0] & 0x80)!=0 ); |
| 35531 | /* a: p0 (unmasked) */ | ||
| 35532 | #ifndef getVarint32 | ||
| 35533 | if (!(a&0x80)) | ||
| 35534 | { | ||
| 35535 | /* Values between 0 and 127 */ | ||
| 35536 | *v = a; | ||
| 35537 | return 1; | ||
| 35538 | } | ||
| 35539 | #endif | ||
| 35540 | 35777 | ||
| 35541 | /* The 2-byte case */ | 35778 | if( (p[1] & 0x80)==0 ){ |
| 35542 | p++; | 35779 | /* This is the two-byte case */ |
| 35543 | b = *p; | 35780 | *v = ((p[0]&0x7f)<<7) | p[1]; |
| 35544 | /* b: p1 (unmasked) */ | ||
| 35545 | if (!(b&0x80)) | ||
| 35546 | { | ||
| 35547 | /* Values between 128 and 16383 */ | ||
| 35548 | a &= 0x7f; | ||
| 35549 | a = a<<7; | ||
| 35550 | *v = a | b; | ||
| 35551 | return 2; | 35781 | return 2; |
| 35552 | } | 35782 | } |
| 35553 | 35783 | if( (p[2] & 0x80)==0 ){ | |
| 35554 | /* The 3-byte case */ | 35784 | /* This is the three-byte case */ |
| 35555 | p++; | 35785 | *v = ((p[0]&0x7f)<<14) | ((p[1]&0x7f)<<7) | p[2]; |
| 35556 | a = a<<14; | ||
| 35557 | a |= *p; | ||
| 35558 | /* a: p0<<14 | p2 (unmasked) */ | ||
| 35559 | if (!(a&0x80)) | ||
| 35560 | { | ||
| 35561 | /* Values between 16384 and 2097151 */ | ||
| 35562 | a &= (0x7f<<14)|(0x7f); | ||
| 35563 | b &= 0x7f; | ||
| 35564 | b = b<<7; | ||
| 35565 | *v = a | b; | ||
| 35566 | return 3; | 35786 | return 3; |
| 35567 | } | 35787 | } |
| 35568 | 35788 | /* four or more bytes */ | |
| 35569 | /* A 32-bit varint is used to store size information in btrees. | 35789 | n = sqlite3GetVarint(p, &v64); |
| 35570 | ** Objects are rarely larger than 2MiB limit of a 3-byte varint. | 35790 | assert( n>3 && n<=9 ); |
| 35571 | ** A 3-byte varint is sufficient, for example, to record the size | 35791 | if( (v64 & SQLITE_MAX_U32)!=v64 ){ |
| 35572 | ** of a 1048569-byte BLOB or string. | 35792 | *v = 0xffffffff; |
| 35573 | ** | 35793 | }else{ |
| 35574 | ** We only unroll the first 1-, 2-, and 3- byte cases. The very | ||
| 35575 | ** rare larger cases can be handled by the slower 64-bit varint | ||
| 35576 | ** routine. | ||
| 35577 | */ | ||
| 35578 | #if 1 | ||
| 35579 | { | ||
| 35580 | u64 v64; | ||
| 35581 | u8 n; | ||
| 35582 | |||
| 35583 | n = sqlite3GetVarint(p-2, &v64); | ||
| 35584 | assert( n>3 && n<=9 ); | ||
| 35585 | if( (v64 & SQLITE_MAX_U32)!=v64 ){ | ||
| 35586 | *v = 0xffffffff; | ||
| 35587 | }else{ | ||
| 35588 | *v = (u32)v64; | ||
| 35589 | } | ||
| 35590 | return n; | ||
| 35591 | } | ||
| 35592 | |||
| 35593 | #else | ||
| 35594 | /* For following code (kept for historical record only) shows an | ||
| 35595 | ** unrolling for the 3- and 4-byte varint cases. This code is | ||
| 35596 | ** slightly faster, but it is also larger and much harder to test. | ||
| 35597 | */ | ||
| 35598 | p++; | ||
| 35599 | b = b<<14; | ||
| 35600 | b |= *p; | ||
| 35601 | /* b: p1<<14 | p3 (unmasked) */ | ||
| 35602 | if (!(b&0x80)) | ||
| 35603 | { | ||
| 35604 | /* Values between 2097152 and 268435455 */ | ||
| 35605 | b &= (0x7f<<14)|(0x7f); | ||
| 35606 | a &= (0x7f<<14)|(0x7f); | ||
| 35607 | a = a<<7; | ||
| 35608 | *v = a | b; | ||
| 35609 | return 4; | ||
| 35610 | } | ||
| 35611 | |||
| 35612 | p++; | ||
| 35613 | a = a<<14; | ||
| 35614 | a |= *p; | ||
| 35615 | /* a: p0<<28 | p2<<14 | p4 (unmasked) */ | ||
| 35616 | if (!(a&0x80)) | ||
| 35617 | { | ||
| 35618 | /* Values between 268435456 and 34359738367 */ | ||
| 35619 | a &= SLOT_4_2_0; | ||
| 35620 | b &= SLOT_4_2_0; | ||
| 35621 | b = b<<7; | ||
| 35622 | *v = a | b; | ||
| 35623 | return 5; | ||
| 35624 | } | ||
| 35625 | |||
| 35626 | /* We can only reach this point when reading a corrupt database | ||
| 35627 | ** file. In that case we are not in any hurry. Use the (relatively | ||
| 35628 | ** slow) general-purpose sqlite3GetVarint() routine to extract the | ||
| 35629 | ** value. */ | ||
| 35630 | { | ||
| 35631 | u64 v64; | ||
| 35632 | u8 n; | ||
| 35633 | |||
| 35634 | p -= 4; | ||
| 35635 | n = sqlite3GetVarint(p, &v64); | ||
| 35636 | assert( n>5 && n<=9 ); | ||
| 35637 | *v = (u32)v64; | 35794 | *v = (u32)v64; |
| 35638 | return n; | ||
| 35639 | } | 35795 | } |
| 35640 | #endif | 35796 | return n; |
| 35641 | } | 35797 | } |
| 35642 | 35798 | ||
| 35643 | /* | 35799 | /* |
| @@ -36633,19 +36789,20 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 36633 | /* 171 */ "VCreate" OpHelp(""), | 36789 | /* 171 */ "VCreate" OpHelp(""), |
| 36634 | /* 172 */ "VDestroy" OpHelp(""), | 36790 | /* 172 */ "VDestroy" OpHelp(""), |
| 36635 | /* 173 */ "VOpen" OpHelp(""), | 36791 | /* 173 */ "VOpen" OpHelp(""), |
| 36636 | /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), | 36792 | /* 174 */ "VCheck" OpHelp(""), |
| 36637 | /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | 36793 | /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), |
| 36638 | /* 176 */ "VRename" OpHelp(""), | 36794 | /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 36639 | /* 177 */ "Pagecount" OpHelp(""), | 36795 | /* 177 */ "VRename" OpHelp(""), |
| 36640 | /* 178 */ "MaxPgcnt" OpHelp(""), | 36796 | /* 178 */ "Pagecount" OpHelp(""), |
| 36641 | /* 179 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), | 36797 | /* 179 */ "MaxPgcnt" OpHelp(""), |
| 36642 | /* 180 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), | 36798 | /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), |
| 36643 | /* 181 */ "Trace" OpHelp(""), | 36799 | /* 181 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), |
| 36644 | /* 182 */ "CursorHint" OpHelp(""), | 36800 | /* 182 */ "Trace" OpHelp(""), |
| 36645 | /* 183 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | 36801 | /* 183 */ "CursorHint" OpHelp(""), |
| 36646 | /* 184 */ "Noop" OpHelp(""), | 36802 | /* 184 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 36647 | /* 185 */ "Explain" OpHelp(""), | 36803 | /* 185 */ "Noop" OpHelp(""), |
| 36648 | /* 186 */ "Abortable" OpHelp(""), | 36804 | /* 186 */ "Explain" OpHelp(""), |
| 36805 | /* 187 */ "Abortable" OpHelp(""), | ||
| 36649 | }; | 36806 | }; |
| 36650 | return azName[i]; | 36807 | return azName[i]; |
| 36651 | } | 36808 | } |
| @@ -40787,9 +40944,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { | |||
| 40787 | unixInodeInfo *pInode; | 40944 | unixInodeInfo *pInode; |
| 40788 | afpLockingContext *context = (afpLockingContext *) pFile->lockingContext; | 40945 | afpLockingContext *context = (afpLockingContext *) pFile->lockingContext; |
| 40789 | int skipShared = 0; | 40946 | int skipShared = 0; |
| 40790 | #ifdef SQLITE_TEST | ||
| 40791 | int h = pFile->h; | ||
| 40792 | #endif | ||
| 40793 | 40947 | ||
| 40794 | assert( pFile ); | 40948 | assert( pFile ); |
| 40795 | OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock, | 40949 | OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock, |
| @@ -40805,9 +40959,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { | |||
| 40805 | assert( pInode->nShared!=0 ); | 40959 | assert( pInode->nShared!=0 ); |
| 40806 | if( pFile->eFileLock>SHARED_LOCK ){ | 40960 | if( pFile->eFileLock>SHARED_LOCK ){ |
| 40807 | assert( pInode->eFileLock==pFile->eFileLock ); | 40961 | assert( pInode->eFileLock==pFile->eFileLock ); |
| 40808 | SimulateIOErrorBenign(1); | ||
| 40809 | SimulateIOError( h=(-1) ) | ||
| 40810 | SimulateIOErrorBenign(0); | ||
| 40811 | 40962 | ||
| 40812 | #ifdef SQLITE_DEBUG | 40963 | #ifdef SQLITE_DEBUG |
| 40813 | /* When reducing a lock such that other processes can start | 40964 | /* When reducing a lock such that other processes can start |
| @@ -40856,9 +41007,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { | |||
| 40856 | unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte; | 41007 | unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte; |
| 40857 | pInode->nShared--; | 41008 | pInode->nShared--; |
| 40858 | if( pInode->nShared==0 ){ | 41009 | if( pInode->nShared==0 ){ |
| 40859 | SimulateIOErrorBenign(1); | ||
| 40860 | SimulateIOError( h=(-1) ) | ||
| 40861 | SimulateIOErrorBenign(0); | ||
| 40862 | if( !skipShared ){ | 41010 | if( !skipShared ){ |
| 40863 | rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0); | 41011 | rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0); |
| 40864 | } | 41012 | } |
| @@ -57729,9 +57877,32 @@ static int writeJournalHdr(Pager *pPager){ | |||
| 57729 | memset(zHeader, 0, sizeof(aJournalMagic)+4); | 57877 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 57730 | } | 57878 | } |
| 57731 | 57879 | ||
| 57880 | |||
| 57881 | |||
| 57732 | /* The random check-hash initializer */ | 57882 | /* The random check-hash initializer */ |
| 57733 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); | 57883 | if( pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){ |
| 57884 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); | ||
| 57885 | } | ||
| 57886 | #ifdef SQLITE_DEBUG | ||
| 57887 | else{ | ||
| 57888 | /* The Pager.cksumInit variable is usually randomized above to protect | ||
| 57889 | ** against there being existing records in the journal file. This is | ||
| 57890 | ** dangerous, as following a crash they may be mistaken for records | ||
| 57891 | ** written by the current transaction and rolled back into the database | ||
| 57892 | ** file, causing corruption. The following assert statements verify | ||
| 57893 | ** that this is not required in "journal_mode=memory" mode, as in that | ||
| 57894 | ** case the journal file is always 0 bytes in size at this point. | ||
| 57895 | ** It is advantageous to avoid the sqlite3_randomness() call if possible | ||
| 57896 | ** as it takes the global PRNG mutex. */ | ||
| 57897 | i64 sz = 0; | ||
| 57898 | sqlite3OsFileSize(pPager->jfd, &sz); | ||
| 57899 | assert( sz==0 ); | ||
| 57900 | assert( pPager->journalOff==journalHdrOffset(pPager) ); | ||
| 57901 | assert( sqlite3JournalIsInMemory(pPager->jfd) ); | ||
| 57902 | } | ||
| 57903 | #endif | ||
| 57734 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); | 57904 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 57905 | |||
| 57735 | /* The initial database size */ | 57906 | /* The initial database size */ |
| 57736 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); | 57907 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 57737 | /* The assumed sector size for this process */ | 57908 | /* The assumed sector size for this process */ |
| @@ -58375,6 +58546,9 @@ static int pager_end_transaction(Pager *pPager, int hasSuper, int bCommit){ | |||
| 58375 | return (rc==SQLITE_OK?rc2:rc); | 58546 | return (rc==SQLITE_OK?rc2:rc); |
| 58376 | } | 58547 | } |
| 58377 | 58548 | ||
| 58549 | /* Forward reference */ | ||
| 58550 | static int pager_playback(Pager *pPager, int isHot); | ||
| 58551 | |||
| 58378 | /* | 58552 | /* |
| 58379 | ** Execute a rollback if a transaction is active and unlock the | 58553 | ** Execute a rollback if a transaction is active and unlock the |
| 58380 | ** database file. | 58554 | ** database file. |
| @@ -58403,6 +58577,21 @@ static void pagerUnlockAndRollback(Pager *pPager){ | |||
| 58403 | assert( pPager->eState==PAGER_READER ); | 58577 | assert( pPager->eState==PAGER_READER ); |
| 58404 | pager_end_transaction(pPager, 0, 0); | 58578 | pager_end_transaction(pPager, 0, 0); |
| 58405 | } | 58579 | } |
| 58580 | }else if( pPager->eState==PAGER_ERROR | ||
| 58581 | && pPager->journalMode==PAGER_JOURNALMODE_MEMORY | ||
| 58582 | && isOpen(pPager->jfd) | ||
| 58583 | ){ | ||
| 58584 | /* Special case for a ROLLBACK due to I/O error with an in-memory | ||
| 58585 | ** journal: We have to rollback immediately, before the journal is | ||
| 58586 | ** closed, because once it is closed, all content is forgotten. */ | ||
| 58587 | int errCode = pPager->errCode; | ||
| 58588 | u8 eLock = pPager->eLock; | ||
| 58589 | pPager->eState = PAGER_OPEN; | ||
| 58590 | pPager->errCode = SQLITE_OK; | ||
| 58591 | pPager->eLock = EXCLUSIVE_LOCK; | ||
| 58592 | pager_playback(pPager, 1); | ||
| 58593 | pPager->errCode = errCode; | ||
| 58594 | pPager->eLock = eLock; | ||
| 58406 | } | 58595 | } |
| 58407 | pager_unlock(pPager); | 58596 | pager_unlock(pPager); |
| 58408 | } | 58597 | } |
| @@ -61895,8 +62084,20 @@ SQLITE_PRIVATE int sqlite3PagerGet( | |||
| 61895 | DbPage **ppPage, /* Write a pointer to the page here */ | 62084 | DbPage **ppPage, /* Write a pointer to the page here */ |
| 61896 | int flags /* PAGER_GET_XXX flags */ | 62085 | int flags /* PAGER_GET_XXX flags */ |
| 61897 | ){ | 62086 | ){ |
| 61898 | /* printf("PAGE %u\n", pgno); fflush(stdout); */ | 62087 | #if 0 /* Trace page fetch by setting to 1 */ |
| 62088 | int rc; | ||
| 62089 | printf("PAGE %u\n", pgno); | ||
| 62090 | fflush(stdout); | ||
| 62091 | rc = pPager->xGet(pPager, pgno, ppPage, flags); | ||
| 62092 | if( rc ){ | ||
| 62093 | printf("PAGE %u failed with 0x%02x\n", pgno, rc); | ||
| 62094 | fflush(stdout); | ||
| 62095 | } | ||
| 62096 | return rc; | ||
| 62097 | #else | ||
| 62098 | /* Normal, high-speed version of sqlite3PagerGet() */ | ||
| 61899 | return pPager->xGet(pPager, pgno, ppPage, flags); | 62099 | return pPager->xGet(pPager, pgno, ppPage, flags); |
| 62100 | #endif | ||
| 61900 | } | 62101 | } |
| 61901 | 62102 | ||
| 61902 | /* | 62103 | /* |
| @@ -62772,6 +62973,13 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne( | |||
| 62772 | rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); | 62973 | rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); |
| 62773 | if( rc==SQLITE_OK ){ | 62974 | if( rc==SQLITE_OK ){ |
| 62774 | rc = pager_write_pagelist(pPager, pList); | 62975 | rc = pager_write_pagelist(pPager, pList); |
| 62976 | if( rc==SQLITE_OK && pPager->dbSize>pPager->dbFileSize ){ | ||
| 62977 | char *pTmp = pPager->pTmpSpace; | ||
| 62978 | int szPage = (int)pPager->pageSize; | ||
| 62979 | memset(pTmp, 0, szPage); | ||
| 62980 | rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, | ||
| 62981 | ((i64)pPager->dbSize*pPager->pageSize)-szPage); | ||
| 62982 | } | ||
| 62775 | if( rc==SQLITE_OK ){ | 62983 | if( rc==SQLITE_OK ){ |
| 62776 | rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); | 62984 | rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); |
| 62777 | } | 62985 | } |
| @@ -63583,7 +63791,7 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){ | |||
| 63583 | } | 63791 | } |
| 63584 | assert( state==pPager->eState ); | 63792 | assert( state==pPager->eState ); |
| 63585 | } | 63793 | } |
| 63586 | }else if( eMode==PAGER_JOURNALMODE_OFF ){ | 63794 | }else if( eMode==PAGER_JOURNALMODE_OFF || eMode==PAGER_JOURNALMODE_MEMORY ){ |
| 63587 | sqlite3OsClose(pPager->jfd); | 63795 | sqlite3OsClose(pPager->jfd); |
| 63588 | } | 63796 | } |
| 63589 | } | 63797 | } |
| @@ -69196,7 +69404,7 @@ struct IntegrityCk { | |||
| 69196 | BtShared *pBt; /* The tree being checked out */ | 69404 | BtShared *pBt; /* The tree being checked out */ |
| 69197 | Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ | 69405 | Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ |
| 69198 | u8 *aPgRef; /* 1 bit per page in the db (see above) */ | 69406 | u8 *aPgRef; /* 1 bit per page in the db (see above) */ |
| 69199 | Pgno nPage; /* Number of pages in the database */ | 69407 | Pgno nCkPage; /* Pages in the database. 0 for partial check */ |
| 69200 | int mxErr; /* Stop accumulating errors when this reaches zero */ | 69408 | int mxErr; /* Stop accumulating errors when this reaches zero */ |
| 69201 | int nErr; /* Number of messages written to zErrMsg so far */ | 69409 | int nErr; /* Number of messages written to zErrMsg so far */ |
| 69202 | int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ | 69410 | int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ |
| @@ -69529,7 +69737,6 @@ SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){ | |||
| 69529 | 69737 | ||
| 69530 | /************** End of btmutex.c *********************************************/ | 69738 | /************** End of btmutex.c *********************************************/ |
| 69531 | /************** Begin file btree.c *******************************************/ | 69739 | /************** Begin file btree.c *******************************************/ |
| 69532 | |||
| 69533 | /* | 69740 | /* |
| 69534 | ** 2004 April 6 | 69741 | ** 2004 April 6 |
| 69535 | ** | 69742 | ** |
| @@ -77024,9 +77231,10 @@ static int rebuildPage( | |||
| 77024 | int k; /* Current slot in pCArray->apEnd[] */ | 77231 | int k; /* Current slot in pCArray->apEnd[] */ |
| 77025 | u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ | 77232 | u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ |
| 77026 | 77233 | ||
| 77234 | assert( nCell>0 ); | ||
| 77027 | assert( i<iEnd ); | 77235 | assert( i<iEnd ); |
| 77028 | j = get2byte(&aData[hdr+5]); | 77236 | j = get2byte(&aData[hdr+5]); |
| 77029 | if( NEVER(j>(u32)usableSize) ){ j = 0; } | 77237 | if( j>(u32)usableSize ){ j = 0; } |
| 77030 | memcpy(&pTmp[j], &aData[j], usableSize - j); | 77238 | memcpy(&pTmp[j], &aData[j], usableSize - j); |
| 77031 | 77239 | ||
| 77032 | for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} | 77240 | for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} |
| @@ -77330,6 +77538,7 @@ static int editPage( | |||
| 77330 | return SQLITE_OK; | 77538 | return SQLITE_OK; |
| 77331 | editpage_fail: | 77539 | editpage_fail: |
| 77332 | /* Unable to edit this page. Rebuild it from scratch instead. */ | 77540 | /* Unable to edit this page. Rebuild it from scratch instead. */ |
| 77541 | if( nNew<1 ) return SQLITE_CORRUPT_BKPT; | ||
| 77333 | populateCellCache(pCArray, iNew, nNew); | 77542 | populateCellCache(pCArray, iNew, nNew); |
| 77334 | return rebuildPage(pCArray, iNew, nNew, pPg); | 77543 | return rebuildPage(pCArray, iNew, nNew, pPg); |
| 77335 | } | 77544 | } |
| @@ -79989,7 +80198,8 @@ static void checkAppendMsg( | |||
| 79989 | ** corresponds to page iPg is already set. | 80198 | ** corresponds to page iPg is already set. |
| 79990 | */ | 80199 | */ |
| 79991 | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ | 80200 | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 79992 | assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); | 80201 | assert( pCheck->aPgRef!=0 ); |
| 80202 | assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); | ||
| 79993 | return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); | 80203 | return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); |
| 79994 | } | 80204 | } |
| 79995 | 80205 | ||
| @@ -79997,7 +80207,8 @@ static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ | |||
| 79997 | ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. | 80207 | ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. |
| 79998 | */ | 80208 | */ |
| 79999 | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ | 80209 | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80000 | assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); | 80210 | assert( pCheck->aPgRef!=0 ); |
| 80211 | assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); | ||
| 80001 | pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); | 80212 | pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); |
| 80002 | } | 80213 | } |
| 80003 | 80214 | ||
| @@ -80011,7 +80222,7 @@ static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ | |||
| 80011 | ** Also check that the page number is in bounds. | 80222 | ** Also check that the page number is in bounds. |
| 80012 | */ | 80223 | */ |
| 80013 | static int checkRef(IntegrityCk *pCheck, Pgno iPage){ | 80224 | static int checkRef(IntegrityCk *pCheck, Pgno iPage){ |
| 80014 | if( iPage>pCheck->nPage || iPage==0 ){ | 80225 | if( iPage>pCheck->nCkPage || iPage==0 ){ |
| 80015 | checkAppendMsg(pCheck, "invalid page number %u", iPage); | 80226 | checkAppendMsg(pCheck, "invalid page number %u", iPage); |
| 80016 | return 1; | 80227 | return 1; |
| 80017 | } | 80228 | } |
| @@ -80238,6 +80449,7 @@ static int checkTreePage( | |||
| 80238 | if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ | 80449 | if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ |
| 80239 | checkAppendMsg(pCheck, | 80450 | checkAppendMsg(pCheck, |
| 80240 | "unable to get the page. error code=%d", rc); | 80451 | "unable to get the page. error code=%d", rc); |
| 80452 | if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM; | ||
| 80241 | goto end_of_check; | 80453 | goto end_of_check; |
| 80242 | } | 80454 | } |
| 80243 | 80455 | ||
| @@ -80508,15 +80720,15 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( | |||
| 80508 | sCheck.db = db; | 80720 | sCheck.db = db; |
| 80509 | sCheck.pBt = pBt; | 80721 | sCheck.pBt = pBt; |
| 80510 | sCheck.pPager = pBt->pPager; | 80722 | sCheck.pPager = pBt->pPager; |
| 80511 | sCheck.nPage = btreePagecount(sCheck.pBt); | 80723 | sCheck.nCkPage = btreePagecount(sCheck.pBt); |
| 80512 | sCheck.mxErr = mxErr; | 80724 | sCheck.mxErr = mxErr; |
| 80513 | sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); | 80725 | sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); |
| 80514 | sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; | 80726 | sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; |
| 80515 | if( sCheck.nPage==0 ){ | 80727 | if( sCheck.nCkPage==0 ){ |
| 80516 | goto integrity_ck_cleanup; | 80728 | goto integrity_ck_cleanup; |
| 80517 | } | 80729 | } |
| 80518 | 80730 | ||
| 80519 | sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1); | 80731 | sCheck.aPgRef = sqlite3MallocZero((sCheck.nCkPage / 8)+ 1); |
| 80520 | if( !sCheck.aPgRef ){ | 80732 | if( !sCheck.aPgRef ){ |
| 80521 | checkOom(&sCheck); | 80733 | checkOom(&sCheck); |
| 80522 | goto integrity_ck_cleanup; | 80734 | goto integrity_ck_cleanup; |
| @@ -80528,7 +80740,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( | |||
| 80528 | } | 80740 | } |
| 80529 | 80741 | ||
| 80530 | i = PENDING_BYTE_PAGE(pBt); | 80742 | i = PENDING_BYTE_PAGE(pBt); |
| 80531 | if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i); | 80743 | if( i<=sCheck.nCkPage ) setPageReferenced(&sCheck, i); |
| 80532 | 80744 | ||
| 80533 | /* Check the integrity of the freelist | 80745 | /* Check the integrity of the freelist |
| 80534 | */ | 80746 | */ |
| @@ -80579,7 +80791,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( | |||
| 80579 | /* Make sure every page in the file is referenced | 80791 | /* Make sure every page in the file is referenced |
| 80580 | */ | 80792 | */ |
| 80581 | if( !bPartial ){ | 80793 | if( !bPartial ){ |
| 80582 | for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){ | 80794 | for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){ |
| 80583 | #ifdef SQLITE_OMIT_AUTOVACUUM | 80795 | #ifdef SQLITE_OMIT_AUTOVACUUM |
| 80584 | if( getPageReferenced(&sCheck, i)==0 ){ | 80796 | if( getPageReferenced(&sCheck, i)==0 ){ |
| 80585 | checkAppendMsg(&sCheck, "Page %u: never used", i); | 80797 | checkAppendMsg(&sCheck, "Page %u: never used", i); |
| @@ -82020,7 +82232,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){ | |||
| 82020 | pMem->flags |= MEM_Term; | 82232 | pMem->flags |= MEM_Term; |
| 82021 | return; | 82233 | return; |
| 82022 | } | 82234 | } |
| 82023 | if( pMem->xDel==(void(*)(void*))sqlite3RCStrUnref ){ | 82235 | if( pMem->xDel==sqlite3RCStrUnref ){ |
| 82024 | /* Blindly assume that all RCStr objects are zero-terminated */ | 82236 | /* Blindly assume that all RCStr objects are zero-terminated */ |
| 82025 | pMem->flags |= MEM_Term; | 82237 | pMem->flags |= MEM_Term; |
| 82026 | return; | 82238 | return; |
| @@ -83400,6 +83612,7 @@ static int valueFromExpr( | |||
| 83400 | if( pVal ){ | 83612 | if( pVal ){ |
| 83401 | pVal->flags = MEM_Int; | 83613 | pVal->flags = MEM_Int; |
| 83402 | pVal->u.i = pExpr->u.zToken[4]==0; | 83614 | pVal->u.i = pExpr->u.zToken[4]==0; |
| 83615 | sqlite3ValueApplyAffinity(pVal, affinity, enc); | ||
| 83403 | } | 83616 | } |
| 83404 | } | 83617 | } |
| 83405 | 83618 | ||
| @@ -84713,6 +84926,10 @@ SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn( | |||
| 84713 | int iDest = pOp->p2; /* Jump destination */ | 84926 | int iDest = pOp->p2; /* Jump destination */ |
| 84714 | if( iDest==0 ) continue; | 84927 | if( iDest==0 ) continue; |
| 84715 | if( pOp->opcode==OP_Gosub ) continue; | 84928 | if( pOp->opcode==OP_Gosub ) continue; |
| 84929 | if( pOp->p3==20230325 && pOp->opcode==OP_NotNull ){ | ||
| 84930 | /* This is a deliberately taken illegal branch. tag-20230325-2 */ | ||
| 84931 | continue; | ||
| 84932 | } | ||
| 84716 | if( iDest<0 ){ | 84933 | if( iDest<0 ){ |
| 84717 | int j = ADDR(iDest); | 84934 | int j = ADDR(iDest); |
| 84718 | assert( j>=0 ); | 84935 | assert( j>=0 ); |
| @@ -88172,20 +88389,33 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem | |||
| 88172 | return n1 - n2; | 88389 | return n1 - n2; |
| 88173 | } | 88390 | } |
| 88174 | 88391 | ||
| 88392 | /* The following two functions are used only within testcase() to prove | ||
| 88393 | ** test coverage. These functions do no exist for production builds. | ||
| 88394 | ** We must use separate SQLITE_NOINLINE functions here, since otherwise | ||
| 88395 | ** optimizer code movement causes gcov to become very confused. | ||
| 88396 | */ | ||
| 88397 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) | ||
| 88398 | static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; } | ||
| 88399 | static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; } | ||
| 88400 | #endif | ||
| 88401 | |||
| 88175 | /* | 88402 | /* |
| 88176 | ** Do a comparison between a 64-bit signed integer and a 64-bit floating-point | 88403 | ** Do a comparison between a 64-bit signed integer and a 64-bit floating-point |
| 88177 | ** number. Return negative, zero, or positive if the first (i64) is less than, | 88404 | ** number. Return negative, zero, or positive if the first (i64) is less than, |
| 88178 | ** equal to, or greater than the second (double). | 88405 | ** equal to, or greater than the second (double). |
| 88179 | */ | 88406 | */ |
| 88180 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ | 88407 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ |
| 88181 | if( sizeof(LONGDOUBLE_TYPE)>8 ){ | 88408 | if( sqlite3IsNaN(r) ){ |
| 88409 | /* SQLite considers NaN to be a NULL. And all integer values are greater | ||
| 88410 | ** than NULL */ | ||
| 88411 | return 1; | ||
| 88412 | } | ||
| 88413 | if( sqlite3Config.bUseLongDouble ){ | ||
| 88182 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; | 88414 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; |
| 88183 | testcase( x<r ); | 88415 | testcase( x<r ); |
| 88184 | testcase( x>r ); | 88416 | testcase( x>r ); |
| 88185 | testcase( x==r ); | 88417 | testcase( x==r ); |
| 88186 | if( x<r ) return -1; | 88418 | return (x<r) ? -1 : (x>r); |
| 88187 | if( x>r ) return +1; /*NO_TEST*/ /* work around bugs in gcov */ | ||
| 88188 | return 0; /*NO_TEST*/ /* work around bugs in gcov */ | ||
| 88189 | }else{ | 88419 | }else{ |
| 88190 | i64 y; | 88420 | i64 y; |
| 88191 | double s; | 88421 | double s; |
| @@ -88195,9 +88425,10 @@ SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ | |||
| 88195 | if( i<y ) return -1; | 88425 | if( i<y ) return -1; |
| 88196 | if( i>y ) return +1; | 88426 | if( i>y ) return +1; |
| 88197 | s = (double)i; | 88427 | s = (double)i; |
| 88198 | if( s<r ) return -1; | 88428 | testcase( doubleLt(s,r) ); |
| 88199 | if( s>r ) return +1; | 88429 | testcase( doubleLt(r,s) ); |
| 88200 | return 0; | 88430 | testcase( doubleEq(r,s) ); |
| 88431 | return (s<r) ? -1 : (s>r); | ||
| 88201 | } | 88432 | } |
| 88202 | } | 88433 | } |
| 88203 | 88434 | ||
| @@ -89565,7 +89796,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value *pOld){ | |||
| 89565 | ** is too big or if an OOM occurs. | 89796 | ** is too big or if an OOM occurs. |
| 89566 | ** | 89797 | ** |
| 89567 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() | 89798 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() |
| 89568 | ** on value P is not going to be used and need to be destroyed. | 89799 | ** on value P if P is not going to be used and need to be destroyed. |
| 89569 | */ | 89800 | */ |
| 89570 | static void setResultStrOrError( | 89801 | static void setResultStrOrError( |
| 89571 | sqlite3_context *pCtx, /* Function context */ | 89802 | sqlite3_context *pCtx, /* Function context */ |
| @@ -89595,7 +89826,7 @@ static void setResultStrOrError( | |||
| 89595 | static int invokeValueDestructor( | 89826 | static int invokeValueDestructor( |
| 89596 | const void *p, /* Value to destroy */ | 89827 | const void *p, /* Value to destroy */ |
| 89597 | void (*xDel)(void*), /* The destructor */ | 89828 | void (*xDel)(void*), /* The destructor */ |
| 89598 | sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if no NULL */ | 89829 | sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if not NULL */ |
| 89599 | ){ | 89830 | ){ |
| 89600 | assert( xDel!=SQLITE_DYNAMIC ); | 89831 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89601 | if( xDel==0 ){ | 89832 | if( xDel==0 ){ |
| @@ -89605,7 +89836,14 @@ static int invokeValueDestructor( | |||
| 89605 | }else{ | 89836 | }else{ |
| 89606 | xDel((void*)p); | 89837 | xDel((void*)p); |
| 89607 | } | 89838 | } |
| 89839 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89840 | if( pCtx!=0 ){ | ||
| 89841 | sqlite3_result_error_toobig(pCtx); | ||
| 89842 | } | ||
| 89843 | #else | ||
| 89844 | assert( pCtx!=0 ); | ||
| 89608 | sqlite3_result_error_toobig(pCtx); | 89845 | sqlite3_result_error_toobig(pCtx); |
| 89846 | #endif | ||
| 89609 | return SQLITE_TOOBIG; | 89847 | return SQLITE_TOOBIG; |
| 89610 | } | 89848 | } |
| 89611 | SQLITE_API void sqlite3_result_blob( | 89849 | SQLITE_API void sqlite3_result_blob( |
| @@ -89614,6 +89852,12 @@ SQLITE_API void sqlite3_result_blob( | |||
| 89614 | int n, | 89852 | int n, |
| 89615 | void (*xDel)(void *) | 89853 | void (*xDel)(void *) |
| 89616 | ){ | 89854 | ){ |
| 89855 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89856 | if( pCtx==0 || n<0 ){ | ||
| 89857 | invokeValueDestructor(z, xDel, pCtx); | ||
| 89858 | return; | ||
| 89859 | } | ||
| 89860 | #endif | ||
| 89617 | assert( n>=0 ); | 89861 | assert( n>=0 ); |
| 89618 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89862 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89619 | setResultStrOrError(pCtx, z, n, 0, xDel); | 89863 | setResultStrOrError(pCtx, z, n, 0, xDel); |
| @@ -89624,8 +89868,14 @@ SQLITE_API void sqlite3_result_blob64( | |||
| 89624 | sqlite3_uint64 n, | 89868 | sqlite3_uint64 n, |
| 89625 | void (*xDel)(void *) | 89869 | void (*xDel)(void *) |
| 89626 | ){ | 89870 | ){ |
| 89627 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | ||
| 89628 | assert( xDel!=SQLITE_DYNAMIC ); | 89871 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89872 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89873 | if( pCtx==0 ){ | ||
| 89874 | invokeValueDestructor(z, xDel, 0); | ||
| 89875 | return; | ||
| 89876 | } | ||
| 89877 | #endif | ||
| 89878 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | ||
| 89629 | if( n>0x7fffffff ){ | 89879 | if( n>0x7fffffff ){ |
| 89630 | (void)invokeValueDestructor(z, xDel, pCtx); | 89880 | (void)invokeValueDestructor(z, xDel, pCtx); |
| 89631 | }else{ | 89881 | }else{ |
| @@ -89633,30 +89883,48 @@ SQLITE_API void sqlite3_result_blob64( | |||
| 89633 | } | 89883 | } |
| 89634 | } | 89884 | } |
| 89635 | SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ | 89885 | SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ |
| 89886 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89887 | if( pCtx==0 ) return; | ||
| 89888 | #endif | ||
| 89636 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89889 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89637 | sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); | 89890 | sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); |
| 89638 | } | 89891 | } |
| 89639 | SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ | 89892 | SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ |
| 89893 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89894 | if( pCtx==0 ) return; | ||
| 89895 | #endif | ||
| 89640 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89896 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89641 | pCtx->isError = SQLITE_ERROR; | 89897 | pCtx->isError = SQLITE_ERROR; |
| 89642 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); | 89898 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); |
| 89643 | } | 89899 | } |
| 89644 | #ifndef SQLITE_OMIT_UTF16 | 89900 | #ifndef SQLITE_OMIT_UTF16 |
| 89645 | SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ | 89901 | SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ |
| 89902 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89903 | if( pCtx==0 ) return; | ||
| 89904 | #endif | ||
| 89646 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89905 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89647 | pCtx->isError = SQLITE_ERROR; | 89906 | pCtx->isError = SQLITE_ERROR; |
| 89648 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); | 89907 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); |
| 89649 | } | 89908 | } |
| 89650 | #endif | 89909 | #endif |
| 89651 | SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ | 89910 | SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ |
| 89911 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89912 | if( pCtx==0 ) return; | ||
| 89913 | #endif | ||
| 89652 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89914 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89653 | sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); | 89915 | sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); |
| 89654 | } | 89916 | } |
| 89655 | SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ | 89917 | SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ |
| 89918 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89919 | if( pCtx==0 ) return; | ||
| 89920 | #endif | ||
| 89656 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89921 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89657 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); | 89922 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 89658 | } | 89923 | } |
| 89659 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ | 89924 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 89925 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89926 | if( pCtx==0 ) return; | ||
| 89927 | #endif | ||
| 89660 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89928 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89661 | sqlite3VdbeMemSetNull(pCtx->pOut); | 89929 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89662 | } | 89930 | } |
| @@ -89666,14 +89934,25 @@ SQLITE_API void sqlite3_result_pointer( | |||
| 89666 | const char *zPType, | 89934 | const char *zPType, |
| 89667 | void (*xDestructor)(void*) | 89935 | void (*xDestructor)(void*) |
| 89668 | ){ | 89936 | ){ |
| 89669 | Mem *pOut = pCtx->pOut; | 89937 | Mem *pOut; |
| 89938 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89939 | if( pCtx==0 ){ | ||
| 89940 | invokeValueDestructor(pPtr, xDestructor, 0); | ||
| 89941 | return; | ||
| 89942 | } | ||
| 89943 | #endif | ||
| 89944 | pOut = pCtx->pOut; | ||
| 89670 | assert( sqlite3_mutex_held(pOut->db->mutex) ); | 89945 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89671 | sqlite3VdbeMemRelease(pOut); | 89946 | sqlite3VdbeMemRelease(pOut); |
| 89672 | pOut->flags = MEM_Null; | 89947 | pOut->flags = MEM_Null; |
| 89673 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); | 89948 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); |
| 89674 | } | 89949 | } |
| 89675 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ | 89950 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 89676 | Mem *pOut = pCtx->pOut; | 89951 | Mem *pOut; |
| 89952 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89953 | if( pCtx==0 ) return; | ||
| 89954 | #endif | ||
| 89955 | pOut = pCtx->pOut; | ||
| 89677 | assert( sqlite3_mutex_held(pOut->db->mutex) ); | 89956 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89678 | pOut->eSubtype = eSubtype & 0xff; | 89957 | pOut->eSubtype = eSubtype & 0xff; |
| 89679 | pOut->flags |= MEM_Subtype; | 89958 | pOut->flags |= MEM_Subtype; |
| @@ -89684,6 +89963,12 @@ SQLITE_API void sqlite3_result_text( | |||
| 89684 | int n, | 89963 | int n, |
| 89685 | void (*xDel)(void *) | 89964 | void (*xDel)(void *) |
| 89686 | ){ | 89965 | ){ |
| 89966 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89967 | if( pCtx==0 ){ | ||
| 89968 | invokeValueDestructor(z, xDel, 0); | ||
| 89969 | return; | ||
| 89970 | } | ||
| 89971 | #endif | ||
| 89687 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89972 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89688 | setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); | 89973 | setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); |
| 89689 | } | 89974 | } |
| @@ -89694,6 +89979,12 @@ SQLITE_API void sqlite3_result_text64( | |||
| 89694 | void (*xDel)(void *), | 89979 | void (*xDel)(void *), |
| 89695 | unsigned char enc | 89980 | unsigned char enc |
| 89696 | ){ | 89981 | ){ |
| 89982 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 89983 | if( pCtx==0 ){ | ||
| 89984 | invokeValueDestructor(z, xDel, 0); | ||
| 89985 | return; | ||
| 89986 | } | ||
| 89987 | #endif | ||
| 89697 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 89988 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89698 | assert( xDel!=SQLITE_DYNAMIC ); | 89989 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89699 | if( enc!=SQLITE_UTF8 ){ | 89990 | if( enc!=SQLITE_UTF8 ){ |
| @@ -89737,7 +90028,16 @@ SQLITE_API void sqlite3_result_text16le( | |||
| 89737 | } | 90028 | } |
| 89738 | #endif /* SQLITE_OMIT_UTF16 */ | 90029 | #endif /* SQLITE_OMIT_UTF16 */ |
| 89739 | SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ | 90030 | SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ |
| 89740 | Mem *pOut = pCtx->pOut; | 90031 | Mem *pOut; |
| 90032 | |||
| 90033 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90034 | if( pCtx==0 ) return; | ||
| 90035 | if( pValue==0 ){ | ||
| 90036 | sqlite3_result_null(pCtx); | ||
| 90037 | return; | ||
| 90038 | } | ||
| 90039 | #endif | ||
| 90040 | pOut = pCtx->pOut; | ||
| 89741 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 90041 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89742 | sqlite3VdbeMemCopy(pOut, pValue); | 90042 | sqlite3VdbeMemCopy(pOut, pValue); |
| 89743 | sqlite3VdbeChangeEncoding(pOut, pCtx->enc); | 90043 | sqlite3VdbeChangeEncoding(pOut, pCtx->enc); |
| @@ -89749,7 +90049,12 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ | |||
| 89749 | sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); | 90049 | sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); |
| 89750 | } | 90050 | } |
| 89751 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ | 90051 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ |
| 89752 | Mem *pOut = pCtx->pOut; | 90052 | Mem *pOut; |
| 90053 | |||
| 90054 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90055 | if( pCtx==0 ) return SQLITE_MISUSE_BKPT; | ||
| 90056 | #endif | ||
| 90057 | pOut = pCtx->pOut; | ||
| 89753 | assert( sqlite3_mutex_held(pOut->db->mutex) ); | 90058 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89754 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ | 90059 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 89755 | sqlite3_result_error_toobig(pCtx); | 90060 | sqlite3_result_error_toobig(pCtx); |
| @@ -89763,6 +90068,9 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ | |||
| 89763 | #endif | 90068 | #endif |
| 89764 | } | 90069 | } |
| 89765 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ | 90070 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 90071 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90072 | if( pCtx==0 ) return; | ||
| 90073 | #endif | ||
| 89766 | pCtx->isError = errCode ? errCode : -1; | 90074 | pCtx->isError = errCode ? errCode : -1; |
| 89767 | #ifdef SQLITE_DEBUG | 90075 | #ifdef SQLITE_DEBUG |
| 89768 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; | 90076 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| @@ -89775,6 +90083,9 @@ SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ | |||
| 89775 | 90083 | ||
| 89776 | /* Force an SQLITE_TOOBIG error. */ | 90084 | /* Force an SQLITE_TOOBIG error. */ |
| 89777 | SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ | 90085 | SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ |
| 90086 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90087 | if( pCtx==0 ) return; | ||
| 90088 | #endif | ||
| 89778 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 90089 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89779 | pCtx->isError = SQLITE_TOOBIG; | 90090 | pCtx->isError = SQLITE_TOOBIG; |
| 89780 | sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, | 90091 | sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, |
| @@ -89783,6 +90094,9 @@ SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ | |||
| 89783 | 90094 | ||
| 89784 | /* An SQLITE_NOMEM error. */ | 90095 | /* An SQLITE_NOMEM error. */ |
| 89785 | SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ | 90096 | SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ |
| 90097 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90098 | if( pCtx==0 ) return; | ||
| 90099 | #endif | ||
| 89786 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 90100 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89787 | sqlite3VdbeMemSetNull(pCtx->pOut); | 90101 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89788 | pCtx->isError = SQLITE_NOMEM_BKPT; | 90102 | pCtx->isError = SQLITE_NOMEM_BKPT; |
| @@ -90035,7 +90349,11 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){ | |||
| 90035 | ** pointer to it. | 90349 | ** pointer to it. |
| 90036 | */ | 90350 | */ |
| 90037 | SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ | 90351 | SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ |
| 90352 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90353 | if( p==0 ) return 0; | ||
| 90354 | #else | ||
| 90038 | assert( p && p->pFunc ); | 90355 | assert( p && p->pFunc ); |
| 90356 | #endif | ||
| 90039 | return p->pFunc->pUserData; | 90357 | return p->pFunc->pUserData; |
| 90040 | } | 90358 | } |
| 90041 | 90359 | ||
| @@ -90050,7 +90368,11 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ | |||
| 90050 | ** application defined function. | 90368 | ** application defined function. |
| 90051 | */ | 90369 | */ |
| 90052 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ | 90370 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ |
| 90371 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90372 | if( p==0 ) return 0; | ||
| 90373 | #else | ||
| 90053 | assert( p && p->pOut ); | 90374 | assert( p && p->pOut ); |
| 90375 | #endif | ||
| 90054 | return p->pOut->db; | 90376 | return p->pOut->db; |
| 90055 | } | 90377 | } |
| 90056 | 90378 | ||
| @@ -90069,7 +90391,11 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ | |||
| 90069 | ** value, as a signal to the xUpdate routine that the column is unchanged. | 90391 | ** value, as a signal to the xUpdate routine that the column is unchanged. |
| 90070 | */ | 90392 | */ |
| 90071 | SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ | 90393 | SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ |
| 90394 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90395 | if( p==0 ) return 0; | ||
| 90396 | #else | ||
| 90072 | assert( p ); | 90397 | assert( p ); |
| 90398 | #endif | ||
| 90073 | return sqlite3_value_nochange(p->pOut); | 90399 | return sqlite3_value_nochange(p->pOut); |
| 90074 | } | 90400 | } |
| 90075 | 90401 | ||
| @@ -90097,7 +90423,7 @@ static int valueFromValueList( | |||
| 90097 | ValueList *pRhs; | 90423 | ValueList *pRhs; |
| 90098 | 90424 | ||
| 90099 | *ppOut = 0; | 90425 | *ppOut = 0; |
| 90100 | if( pVal==0 ) return SQLITE_MISUSE; | 90426 | if( pVal==0 ) return SQLITE_MISUSE_BKPT; |
| 90101 | if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ | 90427 | if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ |
| 90102 | return SQLITE_ERROR; | 90428 | return SQLITE_ERROR; |
| 90103 | }else{ | 90429 | }else{ |
| @@ -90228,6 +90554,9 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ | |||
| 90228 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ | 90554 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 90229 | AuxData *pAuxData; | 90555 | AuxData *pAuxData; |
| 90230 | 90556 | ||
| 90557 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90558 | if( pCtx==0 ) return 0; | ||
| 90559 | #endif | ||
| 90231 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 90560 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90232 | #if SQLITE_ENABLE_STAT4 | 90561 | #if SQLITE_ENABLE_STAT4 |
| 90233 | if( pCtx->pVdbe==0 ) return 0; | 90562 | if( pCtx->pVdbe==0 ) return 0; |
| @@ -90260,8 +90589,12 @@ SQLITE_API void sqlite3_set_auxdata( | |||
| 90260 | void (*xDelete)(void*) | 90589 | void (*xDelete)(void*) |
| 90261 | ){ | 90590 | ){ |
| 90262 | AuxData *pAuxData; | 90591 | AuxData *pAuxData; |
| 90263 | Vdbe *pVdbe = pCtx->pVdbe; | 90592 | Vdbe *pVdbe; |
| 90264 | 90593 | ||
| 90594 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 90595 | if( pCtx==0 ) return; | ||
| 90596 | #endif | ||
| 90597 | pVdbe= pCtx->pVdbe; | ||
| 90265 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | 90598 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90266 | #ifdef SQLITE_ENABLE_STAT4 | 90599 | #ifdef SQLITE_ENABLE_STAT4 |
| 90267 | if( pVdbe==0 ) goto failed; | 90600 | if( pVdbe==0 ) goto failed; |
| @@ -90698,7 +91031,7 @@ static int vdbeUnbind(Vdbe *p, unsigned int i){ | |||
| 90698 | } | 91031 | } |
| 90699 | sqlite3_mutex_enter(p->db->mutex); | 91032 | sqlite3_mutex_enter(p->db->mutex); |
| 90700 | if( p->eVdbeState!=VDBE_READY_STATE ){ | 91033 | if( p->eVdbeState!=VDBE_READY_STATE ){ |
| 90701 | sqlite3Error(p->db, SQLITE_MISUSE); | 91034 | sqlite3Error(p->db, SQLITE_MISUSE_BKPT); |
| 90702 | sqlite3_mutex_leave(p->db->mutex); | 91035 | sqlite3_mutex_leave(p->db->mutex); |
| 90703 | sqlite3_log(SQLITE_MISUSE, | 91036 | sqlite3_log(SQLITE_MISUSE, |
| 90704 | "bind on a busy prepared statement: [%s]", p->zSql); | 91037 | "bind on a busy prepared statement: [%s]", p->zSql); |
| @@ -90927,6 +91260,9 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ | |||
| 90927 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ | 91260 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| 90928 | int rc; | 91261 | int rc; |
| 90929 | Vdbe *p = (Vdbe *)pStmt; | 91262 | Vdbe *p = (Vdbe *)pStmt; |
| 91263 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91264 | if( p==0 ) return SQLITE_MISUSE_BKPT; | ||
| 91265 | #endif | ||
| 90930 | sqlite3_mutex_enter(p->db->mutex); | 91266 | sqlite3_mutex_enter(p->db->mutex); |
| 90931 | if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ | 91267 | if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 90932 | rc = SQLITE_TOOBIG; | 91268 | rc = SQLITE_TOOBIG; |
| @@ -91053,6 +91389,9 @@ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt){ | |||
| 91053 | SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ | 91389 | SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ |
| 91054 | Vdbe *v = (Vdbe*)pStmt; | 91390 | Vdbe *v = (Vdbe*)pStmt; |
| 91055 | int rc; | 91391 | int rc; |
| 91392 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91393 | if( pStmt==0 ) return SQLITE_MISUSE_BKPT; | ||
| 91394 | #endif | ||
| 91056 | sqlite3_mutex_enter(v->db->mutex); | 91395 | sqlite3_mutex_enter(v->db->mutex); |
| 91057 | if( ((int)v->explain)==eMode ){ | 91396 | if( ((int)v->explain)==eMode ){ |
| 91058 | rc = SQLITE_OK; | 91397 | rc = SQLITE_OK; |
| @@ -91219,10 +91558,16 @@ static UnpackedRecord *vdbeUnpackRecord( | |||
| 91219 | ** a field of the row currently being updated or deleted. | 91558 | ** a field of the row currently being updated or deleted. |
| 91220 | */ | 91559 | */ |
| 91221 | SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ | 91560 | SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91222 | PreUpdate *p = db->pPreUpdate; | 91561 | PreUpdate *p; |
| 91223 | Mem *pMem; | 91562 | Mem *pMem; |
| 91224 | int rc = SQLITE_OK; | 91563 | int rc = SQLITE_OK; |
| 91225 | 91564 | ||
| 91565 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91566 | if( db==0 || ppValue==0 ){ | ||
| 91567 | return SQLITE_MISUSE_BKPT; | ||
| 91568 | } | ||
| 91569 | #endif | ||
| 91570 | p = db->pPreUpdate; | ||
| 91226 | /* Test that this call is being made from within an SQLITE_DELETE or | 91571 | /* Test that this call is being made from within an SQLITE_DELETE or |
| 91227 | ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ | 91572 | ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ |
| 91228 | if( !p || p->op==SQLITE_INSERT ){ | 91573 | if( !p || p->op==SQLITE_INSERT ){ |
| @@ -91283,7 +91628,12 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa | |||
| 91283 | ** the number of columns in the row being updated, deleted or inserted. | 91628 | ** the number of columns in the row being updated, deleted or inserted. |
| 91284 | */ | 91629 | */ |
| 91285 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ | 91630 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ |
| 91286 | PreUpdate *p = db->pPreUpdate; | 91631 | PreUpdate *p; |
| 91632 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91633 | p = db!=0 ? db->pPreUpdate : 0; | ||
| 91634 | #else | ||
| 91635 | p = db->pPreUpdate; | ||
| 91636 | #endif | ||
| 91287 | return (p ? p->keyinfo.nKeyField : 0); | 91637 | return (p ? p->keyinfo.nKeyField : 0); |
| 91288 | } | 91638 | } |
| 91289 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ | 91639 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| @@ -91301,7 +91651,12 @@ SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ | |||
| 91301 | ** or SET DEFAULT action is considered a trigger. | 91651 | ** or SET DEFAULT action is considered a trigger. |
| 91302 | */ | 91652 | */ |
| 91303 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ | 91653 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ |
| 91304 | PreUpdate *p = db->pPreUpdate; | 91654 | PreUpdate *p; |
| 91655 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91656 | p = db!=0 ? db->pPreUpdate : 0; | ||
| 91657 | #else | ||
| 91658 | p = db->pPreUpdate; | ||
| 91659 | #endif | ||
| 91305 | return (p ? p->v->nFrame : 0); | 91660 | return (p ? p->v->nFrame : 0); |
| 91306 | } | 91661 | } |
| 91307 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ | 91662 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| @@ -91312,7 +91667,12 @@ SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ | |||
| 91312 | ** only. | 91667 | ** only. |
| 91313 | */ | 91668 | */ |
| 91314 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ | 91669 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ |
| 91315 | PreUpdate *p = db->pPreUpdate; | 91670 | PreUpdate *p; |
| 91671 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91672 | p = db!=0 ? db->pPreUpdate : 0; | ||
| 91673 | #else | ||
| 91674 | p = db->pPreUpdate; | ||
| 91675 | #endif | ||
| 91316 | return (p ? p->iBlobWrite : -1); | 91676 | return (p ? p->iBlobWrite : -1); |
| 91317 | } | 91677 | } |
| 91318 | #endif | 91678 | #endif |
| @@ -91323,10 +91683,16 @@ SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ | |||
| 91323 | ** a field of the row currently being updated or inserted. | 91683 | ** a field of the row currently being updated or inserted. |
| 91324 | */ | 91684 | */ |
| 91325 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ | 91685 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91326 | PreUpdate *p = db->pPreUpdate; | 91686 | PreUpdate *p; |
| 91327 | int rc = SQLITE_OK; | 91687 | int rc = SQLITE_OK; |
| 91328 | Mem *pMem; | 91688 | Mem *pMem; |
| 91329 | 91689 | ||
| 91690 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91691 | if( db==0 || ppValue==0 ){ | ||
| 91692 | return SQLITE_MISUSE_BKPT; | ||
| 91693 | } | ||
| 91694 | #endif | ||
| 91695 | p = db->pPreUpdate; | ||
| 91330 | if( !p || p->op==SQLITE_DELETE ){ | 91696 | if( !p || p->op==SQLITE_DELETE ){ |
| 91331 | rc = SQLITE_MISUSE_BKPT; | 91697 | rc = SQLITE_MISUSE_BKPT; |
| 91332 | goto preupdate_new_out; | 91698 | goto preupdate_new_out; |
| @@ -91405,11 +91771,20 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2( | |||
| 91405 | void *pOut /* OUT: Write the answer here */ | 91771 | void *pOut /* OUT: Write the answer here */ |
| 91406 | ){ | 91772 | ){ |
| 91407 | Vdbe *p = (Vdbe*)pStmt; | 91773 | Vdbe *p = (Vdbe*)pStmt; |
| 91408 | VdbeOp *aOp = p->aOp; | 91774 | VdbeOp *aOp; |
| 91409 | int nOp = p->nOp; | 91775 | int nOp; |
| 91410 | ScanStatus *pScan = 0; | 91776 | ScanStatus *pScan = 0; |
| 91411 | int idx; | 91777 | int idx; |
| 91412 | 91778 | ||
| 91779 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 91780 | if( p==0 || pOut==0 | ||
| 91781 | || iScanStatusOp<SQLITE_SCANSTAT_NLOOP | ||
| 91782 | || iScanStatusOp>SQLITE_SCANSTAT_NCYCLE ){ | ||
| 91783 | return 1; | ||
| 91784 | } | ||
| 91785 | #endif | ||
| 91786 | aOp = p->aOp; | ||
| 91787 | nOp = p->nOp; | ||
| 91413 | if( p->pFrame ){ | 91788 | if( p->pFrame ){ |
| 91414 | VdbeFrame *pFrame; | 91789 | VdbeFrame *pFrame; |
| 91415 | for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); | 91790 | for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); |
| @@ -91556,7 +91931,7 @@ SQLITE_API int sqlite3_stmt_scanstatus( | |||
| 91556 | SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ | 91931 | SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ |
| 91557 | Vdbe *p = (Vdbe*)pStmt; | 91932 | Vdbe *p = (Vdbe*)pStmt; |
| 91558 | int ii; | 91933 | int ii; |
| 91559 | for(ii=0; ii<p->nOp; ii++){ | 91934 | for(ii=0; p!=0 && ii<p->nOp; ii++){ |
| 91560 | Op *pOp = &p->aOp[ii]; | 91935 | Op *pOp = &p->aOp[ii]; |
| 91561 | pOp->nExec = 0; | 91936 | pOp->nExec = 0; |
| 91562 | pOp->nCycle = 0; | 91937 | pOp->nCycle = 0; |
| @@ -92525,11 +92900,11 @@ static SQLITE_NOINLINE int vdbeColumnFromOverflow( | |||
| 92525 | sqlite3RCStrRef(pBuf); | 92900 | sqlite3RCStrRef(pBuf); |
| 92526 | if( t&1 ){ | 92901 | if( t&1 ){ |
| 92527 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, | 92902 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, |
| 92528 | (void(*)(void*))sqlite3RCStrUnref); | 92903 | sqlite3RCStrUnref); |
| 92529 | pDest->flags |= MEM_Term; | 92904 | pDest->flags |= MEM_Term; |
| 92530 | }else{ | 92905 | }else{ |
| 92531 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, | 92906 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, |
| 92532 | (void(*)(void*))sqlite3RCStrUnref); | 92907 | sqlite3RCStrUnref); |
| 92533 | } | 92908 | } |
| 92534 | }else{ | 92909 | }else{ |
| 92535 | rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); | 92910 | rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); |
| @@ -95404,7 +95779,6 @@ case OP_MakeRecord: { | |||
| 95404 | /* NULL value. No change in zPayload */ | 95779 | /* NULL value. No change in zPayload */ |
| 95405 | }else{ | 95780 | }else{ |
| 95406 | u64 v; | 95781 | u64 v; |
| 95407 | u32 i; | ||
| 95408 | if( serial_type==7 ){ | 95782 | if( serial_type==7 ){ |
| 95409 | assert( sizeof(v)==sizeof(pRec->u.r) ); | 95783 | assert( sizeof(v)==sizeof(pRec->u.r) ); |
| 95410 | memcpy(&v, &pRec->u.r, sizeof(v)); | 95784 | memcpy(&v, &pRec->u.r, sizeof(v)); |
| @@ -95412,12 +95786,17 @@ case OP_MakeRecord: { | |||
| 95412 | }else{ | 95786 | }else{ |
| 95413 | v = pRec->u.i; | 95787 | v = pRec->u.i; |
| 95414 | } | 95788 | } |
| 95415 | len = i = sqlite3SmallTypeSizes[serial_type]; | 95789 | len = sqlite3SmallTypeSizes[serial_type]; |
| 95416 | assert( i>0 ); | 95790 | assert( len>=1 && len<=8 && len!=5 && len!=7 ); |
| 95417 | while( 1 /*exit-by-break*/ ){ | 95791 | switch( len ){ |
| 95418 | zPayload[--i] = (u8)(v&0xFF); | 95792 | default: zPayload[7] = (u8)(v&0xff); v >>= 8; |
| 95419 | if( i==0 ) break; | 95793 | zPayload[6] = (u8)(v&0xff); v >>= 8; |
| 95420 | v >>= 8; | 95794 | case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; |
| 95795 | zPayload[4] = (u8)(v&0xff); v >>= 8; | ||
| 95796 | case 4: zPayload[3] = (u8)(v&0xff); v >>= 8; | ||
| 95797 | case 3: zPayload[2] = (u8)(v&0xff); v >>= 8; | ||
| 95798 | case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; | ||
| 95799 | case 1: zPayload[0] = (u8)(v&0xff); | ||
| 95421 | } | 95800 | } |
| 95422 | zPayload += len; | 95801 | zPayload += len; |
| 95423 | } | 95802 | } |
| @@ -97534,8 +97913,13 @@ case OP_RowCell: { | |||
| 97534 | ** the "primary" delete. The others are all on OPFLAG_FORDELETE | 97913 | ** the "primary" delete. The others are all on OPFLAG_FORDELETE |
| 97535 | ** cursors or else are marked with the AUXDELETE flag. | 97914 | ** cursors or else are marked with the AUXDELETE flag. |
| 97536 | ** | 97915 | ** |
| 97537 | ** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row | 97916 | ** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then |
| 97538 | ** change count is incremented (otherwise not). | 97917 | ** the row change count is incremented (otherwise not). |
| 97918 | ** | ||
| 97919 | ** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the | ||
| 97920 | ** pre-update-hook for deletes is run, but the btree is otherwise unchanged. | ||
| 97921 | ** This happens when the OP_Delete is to be shortly followed by an OP_Insert | ||
| 97922 | ** with the same key, causing the btree entry to be overwritten. | ||
| 97539 | ** | 97923 | ** |
| 97540 | ** P1 must not be pseudo-table. It has to be a real table with | 97924 | ** P1 must not be pseudo-table. It has to be a real table with |
| 97541 | ** multiple rows. | 97925 | ** multiple rows. |
| @@ -98660,13 +99044,41 @@ case OP_CreateBtree: { /* out2 */ | |||
| 98660 | /* Opcode: SqlExec * * * P4 * | 99044 | /* Opcode: SqlExec * * * P4 * |
| 98661 | ** | 99045 | ** |
| 98662 | ** Run the SQL statement or statements specified in the P4 string. | 99046 | ** Run the SQL statement or statements specified in the P4 string. |
| 99047 | ** Disable Auth and Trace callbacks while those statements are running if | ||
| 99048 | ** P1 is true. | ||
| 98663 | */ | 99049 | */ |
| 98664 | case OP_SqlExec: { | 99050 | case OP_SqlExec: { |
| 99051 | char *zErr; | ||
| 99052 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 99053 | sqlite3_xauth xAuth; | ||
| 99054 | #endif | ||
| 99055 | u8 mTrace; | ||
| 99056 | |||
| 98665 | sqlite3VdbeIncrWriteCounter(p, 0); | 99057 | sqlite3VdbeIncrWriteCounter(p, 0); |
| 98666 | db->nSqlExec++; | 99058 | db->nSqlExec++; |
| 98667 | rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0); | 99059 | zErr = 0; |
| 99060 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 99061 | xAuth = db->xAuth; | ||
| 99062 | #endif | ||
| 99063 | mTrace = db->mTrace; | ||
| 99064 | if( pOp->p1 ){ | ||
| 99065 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 99066 | db->xAuth = 0; | ||
| 99067 | #endif | ||
| 99068 | db->mTrace = 0; | ||
| 99069 | } | ||
| 99070 | rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr); | ||
| 98668 | db->nSqlExec--; | 99071 | db->nSqlExec--; |
| 98669 | if( rc ) goto abort_due_to_error; | 99072 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 99073 | db->xAuth = xAuth; | ||
| 99074 | #endif | ||
| 99075 | db->mTrace = mTrace; | ||
| 99076 | if( zErr || rc ){ | ||
| 99077 | sqlite3VdbeError(p, "%s", zErr); | ||
| 99078 | sqlite3_free(zErr); | ||
| 99079 | if( rc==SQLITE_NOMEM ) goto no_mem; | ||
| 99080 | goto abort_due_to_error; | ||
| 99081 | } | ||
| 98670 | break; | 99082 | break; |
| 98671 | } | 99083 | } |
| 98672 | 99084 | ||
| @@ -99888,6 +100300,53 @@ case OP_VOpen: { /* ncycle */ | |||
| 99888 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ | 100300 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 99889 | 100301 | ||
| 99890 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 100302 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 100303 | /* Opcode: VCheck P1 P2 P3 P4 * | ||
| 100304 | ** | ||
| 100305 | ** P4 is a pointer to a Table object that is a virtual table in schema P1 | ||
| 100306 | ** that supports the xIntegrity() method. This opcode runs the xIntegrity() | ||
| 100307 | ** method for that virtual table, using P3 as the integer argument. If | ||
| 100308 | ** an error is reported back, the table name is prepended to the error | ||
| 100309 | ** message and that message is stored in P2. If no errors are seen, | ||
| 100310 | ** register P2 is set to NULL. | ||
| 100311 | */ | ||
| 100312 | case OP_VCheck: { /* out2 */ | ||
| 100313 | Table *pTab; | ||
| 100314 | sqlite3_vtab *pVtab; | ||
| 100315 | const sqlite3_module *pModule; | ||
| 100316 | char *zErr = 0; | ||
| 100317 | |||
| 100318 | pOut = &aMem[pOp->p2]; | ||
| 100319 | sqlite3VdbeMemSetNull(pOut); /* Innocent until proven guilty */ | ||
| 100320 | assert( pOp->p4type==P4_TABLE ); | ||
| 100321 | pTab = pOp->p4.pTab; | ||
| 100322 | assert( pTab!=0 ); | ||
| 100323 | assert( IsVirtual(pTab) ); | ||
| 100324 | assert( pTab->u.vtab.p!=0 ); | ||
| 100325 | pVtab = pTab->u.vtab.p->pVtab; | ||
| 100326 | assert( pVtab!=0 ); | ||
| 100327 | pModule = pVtab->pModule; | ||
| 100328 | assert( pModule!=0 ); | ||
| 100329 | assert( pModule->iVersion>=4 ); | ||
| 100330 | assert( pModule->xIntegrity!=0 ); | ||
| 100331 | pTab->nTabRef++; | ||
| 100332 | sqlite3VtabLock(pTab->u.vtab.p); | ||
| 100333 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); | ||
| 100334 | rc = pModule->xIntegrity(pVtab, db->aDb[pOp->p1].zDbSName, pTab->zName, | ||
| 100335 | pOp->p3, &zErr); | ||
| 100336 | sqlite3VtabUnlock(pTab->u.vtab.p); | ||
| 100337 | sqlite3DeleteTable(db, pTab); | ||
| 100338 | if( rc ){ | ||
| 100339 | sqlite3_free(zErr); | ||
| 100340 | goto abort_due_to_error; | ||
| 100341 | } | ||
| 100342 | if( zErr ){ | ||
| 100343 | sqlite3VdbeMemSetStr(pOut, zErr, -1, SQLITE_UTF8, sqlite3_free); | ||
| 100344 | } | ||
| 100345 | break; | ||
| 100346 | } | ||
| 100347 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ | ||
| 100348 | |||
| 100349 | #ifndef SQLITE_OMIT_VIRTUALTABLE | ||
| 99891 | /* Opcode: VInitIn P1 P2 P3 * * | 100350 | /* Opcode: VInitIn P1 P2 P3 * * |
| 99892 | ** Synopsis: r[P2]=ValueList(P1,P3) | 100351 | ** Synopsis: r[P2]=ValueList(P1,P3) |
| 99893 | ** | 100352 | ** |
| @@ -100833,8 +101292,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){ | |||
| 100833 | /* Set the value of register r[1] in the SQL statement to integer iRow. | 101292 | /* Set the value of register r[1] in the SQL statement to integer iRow. |
| 100834 | ** This is done directly as a performance optimization | 101293 | ** This is done directly as a performance optimization |
| 100835 | */ | 101294 | */ |
| 100836 | v->aMem[1].flags = MEM_Int; | 101295 | sqlite3VdbeMemSetInt64(&v->aMem[1], iRow); |
| 100837 | v->aMem[1].u.i = iRow; | ||
| 100838 | 101296 | ||
| 100839 | /* If the statement has been run before (and is paused at the OP_ResultRow) | 101297 | /* If the statement has been run before (and is paused at the OP_ResultRow) |
| 100840 | ** then back it up to the point where it does the OP_NotExists. This could | 101298 | ** then back it up to the point where it does the OP_NotExists. This could |
| @@ -100917,7 +101375,7 @@ SQLITE_API int sqlite3_blob_open( | |||
| 100917 | #endif | 101375 | #endif |
| 100918 | *ppBlob = 0; | 101376 | *ppBlob = 0; |
| 100919 | #ifdef SQLITE_ENABLE_API_ARMOR | 101377 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 100920 | if( !sqlite3SafetyCheckOk(db) || zTable==0 ){ | 101378 | if( !sqlite3SafetyCheckOk(db) || zTable==0 || zColumn==0 ){ |
| 100921 | return SQLITE_MISUSE_BKPT; | 101379 | return SQLITE_MISUSE_BKPT; |
| 100922 | } | 101380 | } |
| 100923 | #endif | 101381 | #endif |
| @@ -101479,7 +101937,7 @@ struct SorterFile { | |||
| 101479 | struct SorterList { | 101937 | struct SorterList { |
| 101480 | SorterRecord *pList; /* Linked list of records */ | 101938 | SorterRecord *pList; /* Linked list of records */ |
| 101481 | u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ | 101939 | u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ |
| 101482 | int szPMA; /* Size of pList as PMA in bytes */ | 101940 | i64 szPMA; /* Size of pList as PMA in bytes */ |
| 101483 | }; | 101941 | }; |
| 101484 | 101942 | ||
| 101485 | /* | 101943 | /* |
| @@ -101588,10 +102046,10 @@ typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int); | |||
| 101588 | struct SortSubtask { | 102046 | struct SortSubtask { |
| 101589 | SQLiteThread *pThread; /* Background thread, if any */ | 102047 | SQLiteThread *pThread; /* Background thread, if any */ |
| 101590 | int bDone; /* Set if thread is finished but not joined */ | 102048 | int bDone; /* Set if thread is finished but not joined */ |
| 102049 | int nPMA; /* Number of PMAs currently in file */ | ||
| 101591 | VdbeSorter *pSorter; /* Sorter that owns this sub-task */ | 102050 | VdbeSorter *pSorter; /* Sorter that owns this sub-task */ |
| 101592 | UnpackedRecord *pUnpacked; /* Space to unpack a record */ | 102051 | UnpackedRecord *pUnpacked; /* Space to unpack a record */ |
| 101593 | SorterList list; /* List for thread to write to a PMA */ | 102052 | SorterList list; /* List for thread to write to a PMA */ |
| 101594 | int nPMA; /* Number of PMAs currently in file */ | ||
| 101595 | SorterCompare xCompare; /* Compare function to use */ | 102053 | SorterCompare xCompare; /* Compare function to use */ |
| 101596 | SorterFile file; /* Temp file for level-0 PMAs */ | 102054 | SorterFile file; /* Temp file for level-0 PMAs */ |
| 101597 | SorterFile file2; /* Space for other PMAs */ | 102055 | SorterFile file2; /* Space for other PMAs */ |
| @@ -103065,8 +103523,8 @@ SQLITE_PRIVATE int sqlite3VdbeSorterWrite( | |||
| 103065 | int rc = SQLITE_OK; /* Return Code */ | 103523 | int rc = SQLITE_OK; /* Return Code */ |
| 103066 | SorterRecord *pNew; /* New list element */ | 103524 | SorterRecord *pNew; /* New list element */ |
| 103067 | int bFlush; /* True to flush contents of memory to PMA */ | 103525 | int bFlush; /* True to flush contents of memory to PMA */ |
| 103068 | int nReq; /* Bytes of memory required */ | 103526 | i64 nReq; /* Bytes of memory required */ |
| 103069 | int nPMA; /* Bytes of PMA space required */ | 103527 | i64 nPMA; /* Bytes of PMA space required */ |
| 103070 | int t; /* serial type of first record field */ | 103528 | int t; /* serial type of first record field */ |
| 103071 | 103529 | ||
| 103072 | assert( pCsr->eCurType==CURTYPE_SORTER ); | 103530 | assert( pCsr->eCurType==CURTYPE_SORTER ); |
| @@ -104490,7 +104948,8 @@ static sqlite3_module bytecodevtabModule = { | |||
| 104490 | /* xSavepoint */ 0, | 104948 | /* xSavepoint */ 0, |
| 104491 | /* xRelease */ 0, | 104949 | /* xRelease */ 0, |
| 104492 | /* xRollbackTo */ 0, | 104950 | /* xRollbackTo */ 0, |
| 104493 | /* xShadowName */ 0 | 104951 | /* xShadowName */ 0, |
| 104952 | /* xIntegrity */ 0 | ||
| 104494 | }; | 104953 | }; |
| 104495 | 104954 | ||
| 104496 | 104955 | ||
| @@ -105319,21 +105778,36 @@ static void resolveAlias( | |||
| 105319 | } | 105778 | } |
| 105320 | 105779 | ||
| 105321 | /* | 105780 | /* |
| 105322 | ** Subqueries stores the original database, table and column names for their | 105781 | ** Subqueries store the original database, table and column names for their |
| 105323 | ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN". | 105782 | ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN", |
| 105324 | ** Check to see if the zSpan given to this routine matches the zDb, zTab, | 105783 | ** and mark the expression-list item by setting ExprList.a[].fg.eEName |
| 105325 | ** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will | 105784 | ** to ENAME_TAB. |
| 105326 | ** match anything. | 105785 | ** |
| 105786 | ** Check to see if the zSpan/eEName of the expression-list item passed to this | ||
| 105787 | ** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are | ||
| 105788 | ** NULL then those fields will match anything. Return true if there is a match, | ||
| 105789 | ** or false otherwise. | ||
| 105790 | ** | ||
| 105791 | ** SF_NestedFrom subqueries also store an entry for the implicit rowid (or | ||
| 105792 | ** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID, | ||
| 105793 | ** and setting zSpan to "DATABASE.TABLE.<rowid-alias>". This type of pItem | ||
| 105794 | ** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid) | ||
| 105795 | ** is set to 1 if there is this kind of match. | ||
| 105327 | */ | 105796 | */ |
| 105328 | SQLITE_PRIVATE int sqlite3MatchEName( | 105797 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 105329 | const struct ExprList_item *pItem, | 105798 | const struct ExprList_item *pItem, |
| 105330 | const char *zCol, | 105799 | const char *zCol, |
| 105331 | const char *zTab, | 105800 | const char *zTab, |
| 105332 | const char *zDb | 105801 | const char *zDb, |
| 105802 | int *pbRowid | ||
| 105333 | ){ | 105803 | ){ |
| 105334 | int n; | 105804 | int n; |
| 105335 | const char *zSpan; | 105805 | const char *zSpan; |
| 105336 | if( pItem->fg.eEName!=ENAME_TAB ) return 0; | 105806 | int eEName = pItem->fg.eEName; |
| 105807 | if( eEName!=ENAME_TAB && (eEName!=ENAME_ROWID || NEVER(pbRowid==0)) ){ | ||
| 105808 | return 0; | ||
| 105809 | } | ||
| 105810 | assert( pbRowid==0 || *pbRowid==0 ); | ||
| 105337 | zSpan = pItem->zEName; | 105811 | zSpan = pItem->zEName; |
| 105338 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} | 105812 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105339 | if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ | 105813 | if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ |
| @@ -105345,9 +105819,11 @@ SQLITE_PRIVATE int sqlite3MatchEName( | |||
| 105345 | return 0; | 105819 | return 0; |
| 105346 | } | 105820 | } |
| 105347 | zSpan += n+1; | 105821 | zSpan += n+1; |
| 105348 | if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){ | 105822 | if( zCol ){ |
| 105349 | return 0; | 105823 | if( eEName==ENAME_TAB && sqlite3StrICmp(zSpan, zCol)!=0 ) return 0; |
| 105824 | if( eEName==ENAME_ROWID && sqlite3IsRowid(zCol)==0 ) return 0; | ||
| 105350 | } | 105825 | } |
| 105826 | if( eEName==ENAME_ROWID ) *pbRowid = 1; | ||
| 105351 | return 1; | 105827 | return 1; |
| 105352 | } | 105828 | } |
| 105353 | 105829 | ||
| @@ -105480,7 +105956,7 @@ static int lookupName( | |||
| 105480 | ){ | 105956 | ){ |
| 105481 | int i, j; /* Loop counters */ | 105957 | int i, j; /* Loop counters */ |
| 105482 | int cnt = 0; /* Number of matching column names */ | 105958 | int cnt = 0; /* Number of matching column names */ |
| 105483 | int cntTab = 0; /* Number of matching table names */ | 105959 | int cntTab = 0; /* Number of potential "rowid" matches */ |
| 105484 | int nSubquery = 0; /* How many levels of subquery */ | 105960 | int nSubquery = 0; /* How many levels of subquery */ |
| 105485 | sqlite3 *db = pParse->db; /* The database connection */ | 105961 | sqlite3 *db = pParse->db; /* The database connection */ |
| 105486 | SrcItem *pItem; /* Use for looping over pSrcList items */ | 105962 | SrcItem *pItem; /* Use for looping over pSrcList items */ |
| @@ -105557,39 +106033,49 @@ static int lookupName( | |||
| 105557 | assert( pEList!=0 ); | 106033 | assert( pEList!=0 ); |
| 105558 | assert( pEList->nExpr==pTab->nCol ); | 106034 | assert( pEList->nExpr==pTab->nCol ); |
| 105559 | for(j=0; j<pEList->nExpr; j++){ | 106035 | for(j=0; j<pEList->nExpr; j++){ |
| 105560 | if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ | 106036 | int bRowid = 0; /* True if possible rowid match */ |
| 106037 | if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb, &bRowid) ){ | ||
| 105561 | continue; | 106038 | continue; |
| 105562 | } | 106039 | } |
| 105563 | if( cnt>0 ){ | 106040 | if( bRowid==0 ){ |
| 105564 | if( pItem->fg.isUsing==0 | 106041 | if( cnt>0 ){ |
| 105565 | || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 | 106042 | if( pItem->fg.isUsing==0 |
| 105566 | ){ | 106043 | || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 |
| 105567 | /* Two or more tables have the same column name which is | 106044 | ){ |
| 105568 | ** not joined by USING. This is an error. Signal as much | 106045 | /* Two or more tables have the same column name which is |
| 105569 | ** by clearing pFJMatch and letting cnt go above 1. */ | 106046 | ** not joined by USING. This is an error. Signal as much |
| 105570 | sqlite3ExprListDelete(db, pFJMatch); | 106047 | ** by clearing pFJMatch and letting cnt go above 1. */ |
| 105571 | pFJMatch = 0; | 106048 | sqlite3ExprListDelete(db, pFJMatch); |
| 105572 | }else | 106049 | pFJMatch = 0; |
| 105573 | if( (pItem->fg.jointype & JT_RIGHT)==0 ){ | 106050 | }else |
| 105574 | /* An INNER or LEFT JOIN. Use the left-most table */ | 106051 | if( (pItem->fg.jointype & JT_RIGHT)==0 ){ |
| 105575 | continue; | 106052 | /* An INNER or LEFT JOIN. Use the left-most table */ |
| 105576 | }else | 106053 | continue; |
| 105577 | if( (pItem->fg.jointype & JT_LEFT)==0 ){ | 106054 | }else |
| 105578 | /* A RIGHT JOIN. Use the right-most table */ | 106055 | if( (pItem->fg.jointype & JT_LEFT)==0 ){ |
| 105579 | cnt = 0; | 106056 | /* A RIGHT JOIN. Use the right-most table */ |
| 105580 | sqlite3ExprListDelete(db, pFJMatch); | 106057 | cnt = 0; |
| 105581 | pFJMatch = 0; | 106058 | sqlite3ExprListDelete(db, pFJMatch); |
| 105582 | }else{ | 106059 | pFJMatch = 0; |
| 105583 | /* For a FULL JOIN, we must construct a coalesce() func */ | 106060 | }else{ |
| 105584 | extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); | 106061 | /* For a FULL JOIN, we must construct a coalesce() func */ |
| 106062 | extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); | ||
| 106063 | } | ||
| 105585 | } | 106064 | } |
| 106065 | cnt++; | ||
| 106066 | hit = 1; | ||
| 106067 | }else if( cnt>0 ){ | ||
| 106068 | /* This is a potential rowid match, but there has already been | ||
| 106069 | ** a real match found. So this can be ignored. */ | ||
| 106070 | continue; | ||
| 105586 | } | 106071 | } |
| 105587 | cnt++; | 106072 | cntTab++; |
| 105588 | cntTab = 2; | ||
| 105589 | pMatch = pItem; | 106073 | pMatch = pItem; |
| 105590 | pExpr->iColumn = j; | 106074 | pExpr->iColumn = j; |
| 105591 | pEList->a[j].fg.bUsed = 1; | 106075 | pEList->a[j].fg.bUsed = 1; |
| 105592 | hit = 1; | 106076 | |
| 106077 | /* rowid cannot be part of a USING clause - assert() this. */ | ||
| 106078 | assert( bRowid==0 || pEList->a[j].fg.bUsingTerm==0 ); | ||
| 105593 | if( pEList->a[j].fg.bUsingTerm ) break; | 106079 | if( pEList->a[j].fg.bUsingTerm ) break; |
| 105594 | } | 106080 | } |
| 105595 | if( hit || zTab==0 ) continue; | 106081 | if( hit || zTab==0 ) continue; |
| @@ -105784,10 +106270,10 @@ static int lookupName( | |||
| 105784 | && pMatch | 106270 | && pMatch |
| 105785 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 | 106271 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 |
| 105786 | && sqlite3IsRowid(zCol) | 106272 | && sqlite3IsRowid(zCol) |
| 105787 | && ALWAYS(VisibleRowid(pMatch->pTab)) | 106273 | && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) |
| 105788 | ){ | 106274 | ){ |
| 105789 | cnt = 1; | 106275 | cnt = 1; |
| 105790 | pExpr->iColumn = -1; | 106276 | if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; |
| 105791 | pExpr->affExpr = SQLITE_AFF_INTEGER; | 106277 | pExpr->affExpr = SQLITE_AFF_INTEGER; |
| 105792 | } | 106278 | } |
| 105793 | 106279 | ||
| @@ -106240,6 +106726,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 106240 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); | 106726 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); |
| 106241 | #endif | 106727 | #endif |
| 106242 | assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); | 106728 | assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); |
| 106729 | assert( pExpr->pLeft==0 || pExpr->pLeft->op==TK_ORDER ); | ||
| 106243 | zId = pExpr->u.zToken; | 106730 | zId = pExpr->u.zToken; |
| 106244 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); | 106731 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 106245 | if( pDef==0 ){ | 106732 | if( pDef==0 ){ |
| @@ -106381,6 +106868,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 106381 | pNC->nNcErr++; | 106868 | pNC->nNcErr++; |
| 106382 | } | 106869 | } |
| 106383 | #endif | 106870 | #endif |
| 106871 | else if( is_agg==0 && pExpr->pLeft ){ | ||
| 106872 | sqlite3ExprOrderByAggregateError(pParse, pExpr); | ||
| 106873 | pNC->nNcErr++; | ||
| 106874 | } | ||
| 106384 | if( is_agg ){ | 106875 | if( is_agg ){ |
| 106385 | /* Window functions may not be arguments of aggregate functions. | 106876 | /* Window functions may not be arguments of aggregate functions. |
| 106386 | ** Or arguments of other window functions. But aggregate functions | 106877 | ** Or arguments of other window functions. But aggregate functions |
| @@ -106399,6 +106890,11 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 106399 | #endif | 106890 | #endif |
| 106400 | sqlite3WalkExprList(pWalker, pList); | 106891 | sqlite3WalkExprList(pWalker, pList); |
| 106401 | if( is_agg ){ | 106892 | if( is_agg ){ |
| 106893 | if( pExpr->pLeft ){ | ||
| 106894 | assert( pExpr->pLeft->op==TK_ORDER ); | ||
| 106895 | assert( ExprUseXList(pExpr->pLeft) ); | ||
| 106896 | sqlite3WalkExprList(pWalker, pExpr->pLeft->x.pList); | ||
| 106897 | } | ||
| 106402 | #ifndef SQLITE_OMIT_WINDOWFUNC | 106898 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106403 | if( pWin ){ | 106899 | if( pWin ){ |
| 106404 | Select *pSel = pNC->pWinSelect; | 106900 | Select *pSel = pNC->pWinSelect; |
| @@ -106962,10 +107458,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 106962 | while( p ){ | 107458 | while( p ){ |
| 106963 | assert( (p->selFlags & SF_Expanded)!=0 ); | 107459 | assert( (p->selFlags & SF_Expanded)!=0 ); |
| 106964 | assert( (p->selFlags & SF_Resolved)==0 ); | 107460 | assert( (p->selFlags & SF_Resolved)==0 ); |
| 106965 | assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */ | ||
| 106966 | p->selFlags |= SF_Resolved; | 107461 | p->selFlags |= SF_Resolved; |
| 106967 | 107462 | ||
| 106968 | |||
| 106969 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These | 107463 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These |
| 106970 | ** are not allowed to refer to any names, so pass an empty NameContext. | 107464 | ** are not allowed to refer to any names, so pass an empty NameContext. |
| 106971 | */ | 107465 | */ |
| @@ -107971,6 +108465,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprForVectorField( | |||
| 107971 | */ | 108465 | */ |
| 107972 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); | 108466 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); |
| 107973 | if( pRet ){ | 108467 | if( pRet ){ |
| 108468 | ExprSetProperty(pRet, EP_FullSize); | ||
| 107974 | pRet->iTable = nField; | 108469 | pRet->iTable = nField; |
| 107975 | pRet->iColumn = iField; | 108470 | pRet->iColumn = iField; |
| 107976 | pRet->pLeft = pVector; | 108471 | pRet->pLeft = pVector; |
| @@ -108562,6 +109057,69 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction( | |||
| 108562 | } | 109057 | } |
| 108563 | 109058 | ||
| 108564 | /* | 109059 | /* |
| 109060 | ** Report an error when attempting to use an ORDER BY clause within | ||
| 109061 | ** the arguments of a non-aggregate function. | ||
| 109062 | */ | ||
| 109063 | SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse *pParse, Expr *p){ | ||
| 109064 | sqlite3ErrorMsg(pParse, | ||
| 109065 | "ORDER BY may not be used with non-aggregate %#T()", p | ||
| 109066 | ); | ||
| 109067 | } | ||
| 109068 | |||
| 109069 | /* | ||
| 109070 | ** Attach an ORDER BY clause to a function call. | ||
| 109071 | ** | ||
| 109072 | ** functionname( arguments ORDER BY sortlist ) | ||
| 109073 | ** \_____________________/ \______/ | ||
| 109074 | ** pExpr pOrderBy | ||
| 109075 | ** | ||
| 109076 | ** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER | ||
| 109077 | ** and added to the Expr.pLeft field of the parent TK_FUNCTION node. | ||
| 109078 | */ | ||
| 109079 | SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy( | ||
| 109080 | Parse *pParse, /* Parsing context */ | ||
| 109081 | Expr *pExpr, /* The function call to which ORDER BY is to be added */ | ||
| 109082 | ExprList *pOrderBy /* The ORDER BY clause to add */ | ||
| 109083 | ){ | ||
| 109084 | Expr *pOB; | ||
| 109085 | sqlite3 *db = pParse->db; | ||
| 109086 | if( NEVER(pOrderBy==0) ){ | ||
| 109087 | assert( db->mallocFailed ); | ||
| 109088 | return; | ||
| 109089 | } | ||
| 109090 | if( pExpr==0 ){ | ||
| 109091 | assert( db->mallocFailed ); | ||
| 109092 | sqlite3ExprListDelete(db, pOrderBy); | ||
| 109093 | return; | ||
| 109094 | } | ||
| 109095 | assert( pExpr->op==TK_FUNCTION ); | ||
| 109096 | assert( pExpr->pLeft==0 ); | ||
| 109097 | assert( ExprUseXList(pExpr) ); | ||
| 109098 | if( pExpr->x.pList==0 || NEVER(pExpr->x.pList->nExpr==0) ){ | ||
| 109099 | /* Ignore ORDER BY on zero-argument aggregates */ | ||
| 109100 | sqlite3ParserAddCleanup(pParse, | ||
| 109101 | (void(*)(sqlite3*,void*))sqlite3ExprListDelete, | ||
| 109102 | pOrderBy); | ||
| 109103 | return; | ||
| 109104 | } | ||
| 109105 | if( IsWindowFunc(pExpr) ){ | ||
| 109106 | sqlite3ExprOrderByAggregateError(pParse, pExpr); | ||
| 109107 | sqlite3ExprListDelete(db, pOrderBy); | ||
| 109108 | return; | ||
| 109109 | } | ||
| 109110 | |||
| 109111 | pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0); | ||
| 109112 | if( pOB==0 ){ | ||
| 109113 | sqlite3ExprListDelete(db, pOrderBy); | ||
| 109114 | return; | ||
| 109115 | } | ||
| 109116 | pOB->x.pList = pOrderBy; | ||
| 109117 | assert( ExprUseXList(pOB) ); | ||
| 109118 | pExpr->pLeft = pOB; | ||
| 109119 | ExprSetProperty(pOB, EP_FullSize); | ||
| 109120 | } | ||
| 109121 | |||
| 109122 | /* | ||
| 108565 | ** Check to see if a function is usable according to current access | 109123 | ** Check to see if a function is usable according to current access |
| 108566 | ** rules: | 109124 | ** rules: |
| 108567 | ** | 109125 | ** |
| @@ -108814,11 +109372,7 @@ static int dupedExprStructSize(const Expr *p, int flags){ | |||
| 108814 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ | 109372 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ |
| 108815 | assert( EXPR_FULLSIZE<=0xfff ); | 109373 | assert( EXPR_FULLSIZE<=0xfff ); |
| 108816 | assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); | 109374 | assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); |
| 108817 | if( 0==flags || p->op==TK_SELECT_COLUMN | 109375 | if( 0==flags || ExprHasProperty(p, EP_FullSize) ){ |
| 108818 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 108819 | || ExprHasProperty(p, EP_WinFunc) | ||
| 108820 | #endif | ||
| 108821 | ){ | ||
| 108822 | nSize = EXPR_FULLSIZE; | 109376 | nSize = EXPR_FULLSIZE; |
| 108823 | }else{ | 109377 | }else{ |
| 108824 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); | 109378 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| @@ -108849,56 +109403,93 @@ static int dupedExprNodeSize(const Expr *p, int flags){ | |||
| 108849 | 109403 | ||
| 108850 | /* | 109404 | /* |
| 108851 | ** Return the number of bytes required to create a duplicate of the | 109405 | ** Return the number of bytes required to create a duplicate of the |
| 108852 | ** expression passed as the first argument. The second argument is a | 109406 | ** expression passed as the first argument. |
| 108853 | ** mask containing EXPRDUP_XXX flags. | ||
| 108854 | ** | 109407 | ** |
| 108855 | ** The value returned includes space to create a copy of the Expr struct | 109408 | ** The value returned includes space to create a copy of the Expr struct |
| 108856 | ** itself and the buffer referred to by Expr.u.zToken, if any. | 109409 | ** itself and the buffer referred to by Expr.u.zToken, if any. |
| 108857 | ** | 109410 | ** |
| 108858 | ** If the EXPRDUP_REDUCE flag is set, then the return value includes | 109411 | ** The return value includes space to duplicate all Expr nodes in the |
| 108859 | ** space to duplicate all Expr nodes in the tree formed by Expr.pLeft | 109412 | ** tree formed by Expr.pLeft and Expr.pRight, but not any other |
| 108860 | ** and Expr.pRight variables (but not for any structures pointed to or | 109413 | ** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin. |
| 108861 | ** descended from the Expr.x.pList or Expr.x.pSelect variables). | ||
| 108862 | */ | 109414 | */ |
| 108863 | static int dupedExprSize(const Expr *p, int flags){ | 109415 | static int dupedExprSize(const Expr *p){ |
| 108864 | int nByte = 0; | 109416 | int nByte; |
| 108865 | if( p ){ | 109417 | assert( p!=0 ); |
| 108866 | nByte = dupedExprNodeSize(p, flags); | 109418 | nByte = dupedExprNodeSize(p, EXPRDUP_REDUCE); |
| 108867 | if( flags&EXPRDUP_REDUCE ){ | 109419 | if( p->pLeft ) nByte += dupedExprSize(p->pLeft); |
| 108868 | nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags); | 109420 | if( p->pRight ) nByte += dupedExprSize(p->pRight); |
| 108869 | } | 109421 | assert( nByte==ROUND8(nByte) ); |
| 108870 | } | ||
| 108871 | return nByte; | 109422 | return nByte; |
| 108872 | } | 109423 | } |
| 108873 | 109424 | ||
| 108874 | /* | 109425 | /* |
| 108875 | ** This function is similar to sqlite3ExprDup(), except that if pzBuffer | 109426 | ** An EdupBuf is a memory allocation used to stored multiple Expr objects |
| 108876 | ** is not NULL then *pzBuffer is assumed to point to a buffer large enough | 109427 | ** together with their Expr.zToken content. This is used to help implement |
| 108877 | ** to store the copy of expression p, the copies of p->u.zToken | 109428 | ** compression while doing sqlite3ExprDup(). The top-level Expr does the |
| 108878 | ** (if applicable), and the copies of the p->pLeft and p->pRight expressions, | 109429 | ** allocation for itself and many of its decendents, then passes an instance |
| 108879 | ** if any. Before returning, *pzBuffer is set to the first byte past the | 109430 | ** of the structure down into exprDup() so that they decendents can have |
| 108880 | ** portion of the buffer copied into by this function. | 109431 | ** access to that memory. |
| 108881 | */ | 109432 | */ |
| 108882 | static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ | 109433 | typedef struct EdupBuf EdupBuf; |
| 109434 | struct EdupBuf { | ||
| 109435 | u8 *zAlloc; /* Memory space available for storage */ | ||
| 109436 | #ifdef SQLITE_DEBUG | ||
| 109437 | u8 *zEnd; /* First byte past the end of memory */ | ||
| 109438 | #endif | ||
| 109439 | }; | ||
| 109440 | |||
| 109441 | /* | ||
| 109442 | ** This function is similar to sqlite3ExprDup(), except that if pEdupBuf | ||
| 109443 | ** is not NULL then it points to memory that can be used to store a copy | ||
| 109444 | ** of the input Expr p together with its p->u.zToken (if any). pEdupBuf | ||
| 109445 | ** is updated with the new buffer tail prior to returning. | ||
| 109446 | */ | ||
| 109447 | static Expr *exprDup( | ||
| 109448 | sqlite3 *db, /* Database connection (for memory allocation) */ | ||
| 109449 | const Expr *p, /* Expr tree to be duplicated */ | ||
| 109450 | int dupFlags, /* EXPRDUP_REDUCE for compression. 0 if not */ | ||
| 109451 | EdupBuf *pEdupBuf /* Preallocated storage space, or NULL */ | ||
| 109452 | ){ | ||
| 108883 | Expr *pNew; /* Value to return */ | 109453 | Expr *pNew; /* Value to return */ |
| 108884 | u8 *zAlloc; /* Memory space from which to build Expr object */ | 109454 | EdupBuf sEdupBuf; /* Memory space from which to build Expr object */ |
| 108885 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ | 109455 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ |
| 109456 | int nToken = -1; /* Space needed for p->u.zToken. -1 means unknown */ | ||
| 108886 | 109457 | ||
| 108887 | assert( db!=0 ); | 109458 | assert( db!=0 ); |
| 108888 | assert( p ); | 109459 | assert( p ); |
| 108889 | assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); | 109460 | assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); |
| 108890 | assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE ); | 109461 | assert( pEdupBuf==0 || dupFlags==EXPRDUP_REDUCE ); |
| 108891 | 109462 | ||
| 108892 | /* Figure out where to write the new Expr structure. */ | 109463 | /* Figure out where to write the new Expr structure. */ |
| 108893 | if( pzBuffer ){ | 109464 | if( pEdupBuf ){ |
| 108894 | zAlloc = *pzBuffer; | 109465 | sEdupBuf.zAlloc = pEdupBuf->zAlloc; |
| 109466 | #ifdef SQLITE_DEBUG | ||
| 109467 | sEdupBuf.zEnd = pEdupBuf->zEnd; | ||
| 109468 | #endif | ||
| 108895 | staticFlag = EP_Static; | 109469 | staticFlag = EP_Static; |
| 108896 | assert( zAlloc!=0 ); | 109470 | assert( sEdupBuf.zAlloc!=0 ); |
| 109471 | assert( dupFlags==EXPRDUP_REDUCE ); | ||
| 108897 | }else{ | 109472 | }else{ |
| 108898 | zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); | 109473 | int nAlloc; |
| 109474 | if( dupFlags ){ | ||
| 109475 | nAlloc = dupedExprSize(p); | ||
| 109476 | }else if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ | ||
| 109477 | nToken = sqlite3Strlen30NN(p->u.zToken)+1; | ||
| 109478 | nAlloc = ROUND8(EXPR_FULLSIZE + nToken); | ||
| 109479 | }else{ | ||
| 109480 | nToken = 0; | ||
| 109481 | nAlloc = ROUND8(EXPR_FULLSIZE); | ||
| 109482 | } | ||
| 109483 | assert( nAlloc==ROUND8(nAlloc) ); | ||
| 109484 | sEdupBuf.zAlloc = sqlite3DbMallocRawNN(db, nAlloc); | ||
| 109485 | #ifdef SQLITE_DEBUG | ||
| 109486 | sEdupBuf.zEnd = sEdupBuf.zAlloc ? sEdupBuf.zAlloc+nAlloc : 0; | ||
| 109487 | #endif | ||
| 109488 | |||
| 108899 | staticFlag = 0; | 109489 | staticFlag = 0; |
| 108900 | } | 109490 | } |
| 108901 | pNew = (Expr *)zAlloc; | 109491 | pNew = (Expr *)sEdupBuf.zAlloc; |
| 109492 | assert( EIGHT_BYTE_ALIGNMENT(pNew) ); | ||
| 108902 | 109493 | ||
| 108903 | if( pNew ){ | 109494 | if( pNew ){ |
| 108904 | /* Set nNewSize to the size allocated for the structure pointed to | 109495 | /* Set nNewSize to the size allocated for the structure pointed to |
| @@ -108907,22 +109498,27 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 108907 | ** by the copy of the p->u.zToken string (if any). | 109498 | ** by the copy of the p->u.zToken string (if any). |
| 108908 | */ | 109499 | */ |
| 108909 | const unsigned nStructSize = dupedExprStructSize(p, dupFlags); | 109500 | const unsigned nStructSize = dupedExprStructSize(p, dupFlags); |
| 108910 | const int nNewSize = nStructSize & 0xfff; | 109501 | int nNewSize = nStructSize & 0xfff; |
| 108911 | int nToken; | 109502 | if( nToken<0 ){ |
| 108912 | if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ | 109503 | if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ |
| 108913 | nToken = sqlite3Strlen30(p->u.zToken) + 1; | 109504 | nToken = sqlite3Strlen30(p->u.zToken) + 1; |
| 108914 | }else{ | 109505 | }else{ |
| 108915 | nToken = 0; | 109506 | nToken = 0; |
| 109507 | } | ||
| 108916 | } | 109508 | } |
| 108917 | if( dupFlags ){ | 109509 | if( dupFlags ){ |
| 109510 | assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= nNewSize+nToken ); | ||
| 108918 | assert( ExprHasProperty(p, EP_Reduced)==0 ); | 109511 | assert( ExprHasProperty(p, EP_Reduced)==0 ); |
| 108919 | memcpy(zAlloc, p, nNewSize); | 109512 | memcpy(sEdupBuf.zAlloc, p, nNewSize); |
| 108920 | }else{ | 109513 | }else{ |
| 108921 | u32 nSize = (u32)exprStructSize(p); | 109514 | u32 nSize = (u32)exprStructSize(p); |
| 108922 | memcpy(zAlloc, p, nSize); | 109515 | assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= |
| 109516 | (int)EXPR_FULLSIZE+nToken ); | ||
| 109517 | memcpy(sEdupBuf.zAlloc, p, nSize); | ||
| 108923 | if( nSize<EXPR_FULLSIZE ){ | 109518 | if( nSize<EXPR_FULLSIZE ){ |
| 108924 | memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); | 109519 | memset(&sEdupBuf.zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); |
| 108925 | } | 109520 | } |
| 109521 | nNewSize = EXPR_FULLSIZE; | ||
| 108926 | } | 109522 | } |
| 108927 | 109523 | ||
| 108928 | /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ | 109524 | /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ |
| @@ -108935,44 +109531,50 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 108935 | } | 109531 | } |
| 108936 | 109532 | ||
| 108937 | /* Copy the p->u.zToken string, if any. */ | 109533 | /* Copy the p->u.zToken string, if any. */ |
| 108938 | if( nToken ){ | 109534 | assert( nToken>=0 ); |
| 108939 | char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; | 109535 | if( nToken>0 ){ |
| 109536 | char *zToken = pNew->u.zToken = (char*)&sEdupBuf.zAlloc[nNewSize]; | ||
| 108940 | memcpy(zToken, p->u.zToken, nToken); | 109537 | memcpy(zToken, p->u.zToken, nToken); |
| 109538 | nNewSize += nToken; | ||
| 108941 | } | 109539 | } |
| 109540 | sEdupBuf.zAlloc += ROUND8(nNewSize); | ||
| 109541 | |||
| 109542 | if( ((p->flags|pNew->flags)&(EP_TokenOnly|EP_Leaf))==0 ){ | ||
| 108942 | 109543 | ||
| 108943 | if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){ | ||
| 108944 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ | 109544 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ |
| 108945 | if( ExprUseXSelect(p) ){ | 109545 | if( ExprUseXSelect(p) ){ |
| 108946 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); | 109546 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); |
| 108947 | }else{ | 109547 | }else{ |
| 108948 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); | 109548 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, |
| 109549 | p->op!=TK_ORDER ? dupFlags : 0); | ||
| 108949 | } | 109550 | } |
| 108950 | } | ||
| 108951 | 109551 | ||
| 108952 | /* Fill in pNew->pLeft and pNew->pRight. */ | ||
| 108953 | if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){ | ||
| 108954 | zAlloc += dupedExprNodeSize(p, dupFlags); | ||
| 108955 | if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){ | ||
| 108956 | pNew->pLeft = p->pLeft ? | ||
| 108957 | exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0; | ||
| 108958 | pNew->pRight = p->pRight ? | ||
| 108959 | exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0; | ||
| 108960 | } | ||
| 108961 | #ifndef SQLITE_OMIT_WINDOWFUNC | 109552 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 108962 | if( ExprHasProperty(p, EP_WinFunc) ){ | 109553 | if( ExprHasProperty(p, EP_WinFunc) ){ |
| 108963 | pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); | 109554 | pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); |
| 108964 | assert( ExprHasProperty(pNew, EP_WinFunc) ); | 109555 | assert( ExprHasProperty(pNew, EP_WinFunc) ); |
| 108965 | } | 109556 | } |
| 108966 | #endif /* SQLITE_OMIT_WINDOWFUNC */ | 109557 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 108967 | if( pzBuffer ){ | 109558 | |
| 108968 | *pzBuffer = zAlloc; | 109559 | /* Fill in pNew->pLeft and pNew->pRight. */ |
| 108969 | } | 109560 | if( dupFlags ){ |
| 108970 | }else{ | 109561 | if( p->op==TK_SELECT_COLUMN ){ |
| 108971 | if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ | ||
| 108972 | if( pNew->op==TK_SELECT_COLUMN ){ | ||
| 108973 | pNew->pLeft = p->pLeft; | 109562 | pNew->pLeft = p->pLeft; |
| 108974 | assert( p->pRight==0 || p->pRight==p->pLeft | 109563 | assert( p->pRight==0 |
| 108975 | || ExprHasProperty(p->pLeft, EP_Subquery) ); | 109564 | || p->pRight==p->pLeft |
| 109565 | || ExprHasProperty(p->pLeft, EP_Subquery) ); | ||
| 109566 | }else{ | ||
| 109567 | pNew->pLeft = p->pLeft ? | ||
| 109568 | exprDup(db, p->pLeft, EXPRDUP_REDUCE, &sEdupBuf) : 0; | ||
| 109569 | } | ||
| 109570 | pNew->pRight = p->pRight ? | ||
| 109571 | exprDup(db, p->pRight, EXPRDUP_REDUCE, &sEdupBuf) : 0; | ||
| 109572 | }else{ | ||
| 109573 | if( p->op==TK_SELECT_COLUMN ){ | ||
| 109574 | pNew->pLeft = p->pLeft; | ||
| 109575 | assert( p->pRight==0 | ||
| 109576 | || p->pRight==p->pLeft | ||
| 109577 | || ExprHasProperty(p->pLeft, EP_Subquery) ); | ||
| 108976 | }else{ | 109578 | }else{ |
| 108977 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); | 109579 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 108978 | } | 109580 | } |
| @@ -108980,6 +109582,8 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 108980 | } | 109582 | } |
| 108981 | } | 109583 | } |
| 108982 | } | 109584 | } |
| 109585 | if( pEdupBuf ) memcpy(pEdupBuf, &sEdupBuf, sizeof(sEdupBuf)); | ||
| 109586 | assert( sEdupBuf.zAlloc <= sEdupBuf.zEnd ); | ||
| 108983 | return pNew; | 109587 | return pNew; |
| 108984 | } | 109588 | } |
| 108985 | 109589 | ||
| @@ -109244,11 +109848,7 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *p, int flags) | |||
| 109244 | ** initially NULL, then create a new expression list. | 109848 | ** initially NULL, then create a new expression list. |
| 109245 | ** | 109849 | ** |
| 109246 | ** The pList argument must be either NULL or a pointer to an ExprList | 109850 | ** The pList argument must be either NULL or a pointer to an ExprList |
| 109247 | ** obtained from a prior call to sqlite3ExprListAppend(). This routine | 109851 | ** obtained from a prior call to sqlite3ExprListAppend(). |
| 109248 | ** may not be used with an ExprList obtained from sqlite3ExprListDup(). | ||
| 109249 | ** Reason: This routine assumes that the number of slots in pList->a[] | ||
| 109250 | ** is a power of two. That is true for sqlite3ExprListAppend() returns | ||
| 109251 | ** but is not necessarily true from the return value of sqlite3ExprListDup(). | ||
| 109252 | ** | 109852 | ** |
| 109253 | ** If a memory allocation error occurs, the entire list is freed and | 109853 | ** If a memory allocation error occurs, the entire list is freed and |
| 109254 | ** NULL is returned. If non-NULL is returned, then it is guaranteed | 109854 | ** NULL is returned. If non-NULL is returned, then it is guaranteed |
| @@ -110075,6 +110675,27 @@ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){ | |||
| 110075 | } | 110675 | } |
| 110076 | 110676 | ||
| 110077 | /* | 110677 | /* |
| 110678 | ** Return a pointer to a buffer containing a usable rowid alias for table | ||
| 110679 | ** pTab. An alias is usable if there is not an explicit user-defined column | ||
| 110680 | ** of the same name. | ||
| 110681 | */ | ||
| 110682 | SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){ | ||
| 110683 | const char *azOpt[] = {"_ROWID_", "ROWID", "OID"}; | ||
| 110684 | int ii; | ||
| 110685 | assert( VisibleRowid(pTab) ); | ||
| 110686 | for(ii=0; ii<ArraySize(azOpt); ii++){ | ||
| 110687 | int iCol; | ||
| 110688 | for(iCol=0; iCol<pTab->nCol; iCol++){ | ||
| 110689 | if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break; | ||
| 110690 | } | ||
| 110691 | if( iCol==pTab->nCol ){ | ||
| 110692 | return azOpt[ii]; | ||
| 110693 | } | ||
| 110694 | } | ||
| 110695 | return 0; | ||
| 110696 | } | ||
| 110697 | |||
| 110698 | /* | ||
| 110078 | ** pX is the RHS of an IN operator. If pX is a SELECT statement | 110699 | ** pX is the RHS of an IN operator. If pX is a SELECT statement |
| 110079 | ** that can be simplified to a direct table access, then return | 110700 | ** that can be simplified to a direct table access, then return |
| 110080 | ** a pointer to the SELECT statement. If pX is not a SELECT statement, | 110701 | ** a pointer to the SELECT statement. If pX is not a SELECT statement, |
| @@ -111612,6 +112233,41 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup( | |||
| 111612 | 112233 | ||
| 111613 | 112234 | ||
| 111614 | /* | 112235 | /* |
| 112236 | ** Expresion pExpr is guaranteed to be a TK_COLUMN or equivalent. This | ||
| 112237 | ** function checks the Parse.pIdxPartExpr list to see if this column | ||
| 112238 | ** can be replaced with a constant value. If so, it generates code to | ||
| 112239 | ** put the constant value in a register (ideally, but not necessarily, | ||
| 112240 | ** register iTarget) and returns the register number. | ||
| 112241 | ** | ||
| 112242 | ** Or, if the TK_COLUMN cannot be replaced by a constant, zero is | ||
| 112243 | ** returned. | ||
| 112244 | */ | ||
| 112245 | static int exprPartidxExprLookup(Parse *pParse, Expr *pExpr, int iTarget){ | ||
| 112246 | IndexedExpr *p; | ||
| 112247 | for(p=pParse->pIdxPartExpr; p; p=p->pIENext){ | ||
| 112248 | if( pExpr->iColumn==p->iIdxCol && pExpr->iTable==p->iDataCur ){ | ||
| 112249 | Vdbe *v = pParse->pVdbe; | ||
| 112250 | int addr = 0; | ||
| 112251 | int ret; | ||
| 112252 | |||
| 112253 | if( p->bMaybeNullRow ){ | ||
| 112254 | addr = sqlite3VdbeAddOp1(v, OP_IfNullRow, p->iIdxCur); | ||
| 112255 | } | ||
| 112256 | ret = sqlite3ExprCodeTarget(pParse, p->pExpr, iTarget); | ||
| 112257 | sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, ret, 1, 0, | ||
| 112258 | (const char*)&p->aff, 1); | ||
| 112259 | if( addr ){ | ||
| 112260 | sqlite3VdbeJumpHere(v, addr); | ||
| 112261 | sqlite3VdbeChangeP3(v, addr, ret); | ||
| 112262 | } | ||
| 112263 | return ret; | ||
| 112264 | } | ||
| 112265 | } | ||
| 112266 | return 0; | ||
| 112267 | } | ||
| 112268 | |||
| 112269 | |||
| 112270 | /* | ||
| 111615 | ** Generate code into the current Vdbe to evaluate the given | 112271 | ** Generate code into the current Vdbe to evaluate the given |
| 111616 | ** expression. Attempt to store the results in register "target". | 112272 | ** expression. Attempt to store the results in register "target". |
| 111617 | ** Return the register where results are stored. | 112273 | ** Return the register where results are stored. |
| @@ -111647,6 +112303,7 @@ expr_code_doover: | |||
| 111647 | assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); | 112303 | assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); |
| 111648 | op = pExpr->op; | 112304 | op = pExpr->op; |
| 111649 | } | 112305 | } |
| 112306 | assert( op!=TK_ORDER ); | ||
| 111650 | switch( op ){ | 112307 | switch( op ){ |
| 111651 | case TK_AGG_COLUMN: { | 112308 | case TK_AGG_COLUMN: { |
| 111652 | AggInfo *pAggInfo = pExpr->pAggInfo; | 112309 | AggInfo *pAggInfo = pExpr->pAggInfo; |
| @@ -111660,7 +112317,7 @@ expr_code_doover: | |||
| 111660 | #ifdef SQLITE_VDBE_COVERAGE | 112317 | #ifdef SQLITE_VDBE_COVERAGE |
| 111661 | /* Verify that the OP_Null above is exercised by tests | 112318 | /* Verify that the OP_Null above is exercised by tests |
| 111662 | ** tag-20230325-2 */ | 112319 | ** tag-20230325-2 */ |
| 111663 | sqlite3VdbeAddOp2(v, OP_NotNull, target, 1); | 112320 | sqlite3VdbeAddOp3(v, OP_NotNull, target, 1, 20230325); |
| 111664 | VdbeCoverageNeverTaken(v); | 112321 | VdbeCoverageNeverTaken(v); |
| 111665 | #endif | 112322 | #endif |
| 111666 | break; | 112323 | break; |
| @@ -111768,6 +112425,11 @@ expr_code_doover: | |||
| 111768 | iTab = pParse->iSelfTab - 1; | 112425 | iTab = pParse->iSelfTab - 1; |
| 111769 | } | 112426 | } |
| 111770 | } | 112427 | } |
| 112428 | else if( pParse->pIdxPartExpr | ||
| 112429 | && 0!=(r1 = exprPartidxExprLookup(pParse, pExpr, target)) | ||
| 112430 | ){ | ||
| 112431 | return r1; | ||
| 112432 | } | ||
| 111771 | assert( ExprUseYTab(pExpr) ); | 112433 | assert( ExprUseYTab(pExpr) ); |
| 111772 | assert( pExpr->y.pTab!=0 ); | 112434 | assert( pExpr->y.pTab!=0 ); |
| 111773 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, | 112435 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| @@ -112428,7 +113090,7 @@ expr_code_doover: | |||
| 112428 | ** once. If no functions are involved, then factor the code out and put it at | 113090 | ** once. If no functions are involved, then factor the code out and put it at |
| 112429 | ** the end of the prepared statement in the initialization section. | 113091 | ** the end of the prepared statement in the initialization section. |
| 112430 | ** | 113092 | ** |
| 112431 | ** If regDest>=0 then the result is always stored in that register and the | 113093 | ** If regDest>0 then the result is always stored in that register and the |
| 112432 | ** result is not reusable. If regDest<0 then this routine is free to | 113094 | ** result is not reusable. If regDest<0 then this routine is free to |
| 112433 | ** store the value wherever it wants. The register where the expression | 113095 | ** store the value wherever it wants. The register where the expression |
| 112434 | ** is stored is returned. When regDest<0, two identical expressions might | 113096 | ** is stored is returned. When regDest<0, two identical expressions might |
| @@ -112443,6 +113105,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce( | |||
| 112443 | ){ | 113105 | ){ |
| 112444 | ExprList *p; | 113106 | ExprList *p; |
| 112445 | assert( ConstFactorOk(pParse) ); | 113107 | assert( ConstFactorOk(pParse) ); |
| 113108 | assert( regDest!=0 ); | ||
| 112446 | p = pParse->pConstExpr; | 113109 | p = pParse->pConstExpr; |
| 112447 | if( regDest<0 && p ){ | 113110 | if( regDest<0 && p ){ |
| 112448 | struct ExprList_item *pItem; | 113111 | struct ExprList_item *pItem; |
| @@ -113727,6 +114390,12 @@ SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse *pParse, Expr *pExpr, SrcList | |||
| 113727 | assert( pExpr->op==TK_AGG_FUNCTION ); | 114390 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 113728 | assert( ExprUseXList(pExpr) ); | 114391 | assert( ExprUseXList(pExpr) ); |
| 113729 | sqlite3WalkExprList(&w, pExpr->x.pList); | 114392 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 114393 | if( pExpr->pLeft ){ | ||
| 114394 | assert( pExpr->pLeft->op==TK_ORDER ); | ||
| 114395 | assert( ExprUseXList(pExpr->pLeft) ); | ||
| 114396 | assert( pExpr->pLeft->x.pList!=0 ); | ||
| 114397 | sqlite3WalkExprList(&w, pExpr->pLeft->x.pList); | ||
| 114398 | } | ||
| 113730 | #ifndef SQLITE_OMIT_WINDOWFUNC | 114399 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 113731 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ | 114400 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 113732 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); | 114401 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| @@ -113991,14 +114660,42 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ | |||
| 113991 | u8 enc = ENC(pParse->db); | 114660 | u8 enc = ENC(pParse->db); |
| 113992 | i = addAggInfoFunc(pParse->db, pAggInfo); | 114661 | i = addAggInfoFunc(pParse->db, pAggInfo); |
| 113993 | if( i>=0 ){ | 114662 | if( i>=0 ){ |
| 114663 | int nArg; | ||
| 113994 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 114664 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 113995 | pItem = &pAggInfo->aFunc[i]; | 114665 | pItem = &pAggInfo->aFunc[i]; |
| 113996 | pItem->pFExpr = pExpr; | 114666 | pItem->pFExpr = pExpr; |
| 113997 | assert( ExprUseUToken(pExpr) ); | 114667 | assert( ExprUseUToken(pExpr) ); |
| 114668 | nArg = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; | ||
| 113998 | pItem->pFunc = sqlite3FindFunction(pParse->db, | 114669 | pItem->pFunc = sqlite3FindFunction(pParse->db, |
| 113999 | pExpr->u.zToken, | 114670 | pExpr->u.zToken, nArg, enc, 0); |
| 114000 | pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); | 114671 | assert( pItem->bOBUnique==0 ); |
| 114001 | if( pExpr->flags & EP_Distinct ){ | 114672 | if( pExpr->pLeft |
| 114673 | && (pItem->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)==0 | ||
| 114674 | ){ | ||
| 114675 | /* The NEEDCOLL test above causes any ORDER BY clause on | ||
| 114676 | ** aggregate min() or max() to be ignored. */ | ||
| 114677 | ExprList *pOBList; | ||
| 114678 | assert( nArg>0 ); | ||
| 114679 | assert( pExpr->pLeft->op==TK_ORDER ); | ||
| 114680 | assert( ExprUseXList(pExpr->pLeft) ); | ||
| 114681 | pItem->iOBTab = pParse->nTab++; | ||
| 114682 | pOBList = pExpr->pLeft->x.pList; | ||
| 114683 | assert( pOBList->nExpr>0 ); | ||
| 114684 | assert( pItem->bOBUnique==0 ); | ||
| 114685 | if( pOBList->nExpr==1 | ||
| 114686 | && nArg==1 | ||
| 114687 | && sqlite3ExprCompare(0,pOBList->a[0].pExpr, | ||
| 114688 | pExpr->x.pList->a[0].pExpr,0)==0 | ||
| 114689 | ){ | ||
| 114690 | pItem->bOBPayload = 0; | ||
| 114691 | pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); | ||
| 114692 | }else{ | ||
| 114693 | pItem->bOBPayload = 1; | ||
| 114694 | } | ||
| 114695 | }else{ | ||
| 114696 | pItem->iOBTab = -1; | ||
| 114697 | } | ||
| 114698 | if( ExprHasProperty(pExpr, EP_Distinct) && !pItem->bOBUnique ){ | ||
| 114002 | pItem->iDistinct = pParse->nTab++; | 114699 | pItem->iDistinct = pParse->nTab++; |
| 114003 | }else{ | 114700 | }else{ |
| 114004 | pItem->iDistinct = -1; | 114701 | pItem->iDistinct = -1; |
| @@ -114634,14 +115331,19 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 114634 | /* Verify that constraints are still satisfied */ | 115331 | /* Verify that constraints are still satisfied */ |
| 114635 | if( pNew->pCheck!=0 | 115332 | if( pNew->pCheck!=0 |
| 114636 | || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) | 115333 | || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) |
| 115334 | || (pTab->tabFlags & TF_Strict)!=0 | ||
| 114637 | ){ | 115335 | ){ |
| 114638 | sqlite3NestedParse(pParse, | 115336 | sqlite3NestedParse(pParse, |
| 114639 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" | 115337 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" |
| 114640 | " THEN raise(ABORT,'CHECK constraint failed')" | 115338 | " THEN raise(ABORT,'CHECK constraint failed')" |
| 115339 | " WHEN quick_check GLOB 'non-* value in*'" | ||
| 115340 | " THEN raise(ABORT,'type mismatch on DEFAULT')" | ||
| 114641 | " ELSE raise(ABORT,'NOT NULL constraint failed')" | 115341 | " ELSE raise(ABORT,'NOT NULL constraint failed')" |
| 114642 | " END" | 115342 | " END" |
| 114643 | " FROM pragma_quick_check(%Q,%Q)" | 115343 | " FROM pragma_quick_check(%Q,%Q)" |
| 114644 | " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", | 115344 | " WHERE quick_check GLOB 'CHECK*'" |
| 115345 | " OR quick_check GLOB 'NULL*'" | ||
| 115346 | " OR quick_check GLOB 'non-* value in*'", | ||
| 114645 | zTab, zDb | 115347 | zTab, zDb |
| 114646 | ); | 115348 | ); |
| 114647 | } | 115349 | } |
| @@ -119620,19 +120322,14 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ | |||
| 119620 | */ | 120322 | */ |
| 119621 | if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); | 120323 | if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); |
| 119622 | 120324 | ||
| 119623 | /* Code constant expressions that where factored out of inner loops. | 120325 | /* Code constant expressions that were factored out of inner loops. |
| 119624 | ** | ||
| 119625 | ** The pConstExpr list might also contain expressions that we simply | ||
| 119626 | ** want to keep around until the Parse object is deleted. Such | ||
| 119627 | ** expressions have iConstExprReg==0. Do not generate code for | ||
| 119628 | ** those expressions, of course. | ||
| 119629 | */ | 120326 | */ |
| 119630 | if( pParse->pConstExpr ){ | 120327 | if( pParse->pConstExpr ){ |
| 119631 | ExprList *pEL = pParse->pConstExpr; | 120328 | ExprList *pEL = pParse->pConstExpr; |
| 119632 | pParse->okConstFactor = 0; | 120329 | pParse->okConstFactor = 0; |
| 119633 | for(i=0; i<pEL->nExpr; i++){ | 120330 | for(i=0; i<pEL->nExpr; i++){ |
| 119634 | int iReg = pEL->a[i].u.iConstExprReg; | 120331 | assert( pEL->a[i].u.iConstExprReg>0 ); |
| 119635 | sqlite3ExprCode(pParse, pEL->a[i].pExpr, iReg); | 120332 | sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg); |
| 119636 | } | 120333 | } |
| 119637 | } | 120334 | } |
| 119638 | 120335 | ||
| @@ -120787,19 +121484,12 @@ SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ | |||
| 120787 | #endif | 121484 | #endif |
| 120788 | 121485 | ||
| 120789 | /* | 121486 | /* |
| 120790 | ** Name of the special TEMP trigger used to implement RETURNING. The | ||
| 120791 | ** name begins with "sqlite_" so that it is guaranteed not to collide | ||
| 120792 | ** with any application-generated triggers. | ||
| 120793 | */ | ||
| 120794 | #define RETURNING_TRIGGER_NAME "sqlite_returning" | ||
| 120795 | |||
| 120796 | /* | ||
| 120797 | ** Clean up the data structures associated with the RETURNING clause. | 121487 | ** Clean up the data structures associated with the RETURNING clause. |
| 120798 | */ | 121488 | */ |
| 120799 | static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){ | 121489 | static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){ |
| 120800 | Hash *pHash; | 121490 | Hash *pHash; |
| 120801 | pHash = &(db->aDb[1].pSchema->trigHash); | 121491 | pHash = &(db->aDb[1].pSchema->trigHash); |
| 120802 | sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, 0); | 121492 | sqlite3HashInsert(pHash, pRet->zName, 0); |
| 120803 | sqlite3ExprListDelete(db, pRet->pReturnEL); | 121493 | sqlite3ExprListDelete(db, pRet->pReturnEL); |
| 120804 | sqlite3DbFree(db, pRet); | 121494 | sqlite3DbFree(db, pRet); |
| 120805 | } | 121495 | } |
| @@ -120842,7 +121532,9 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ | |||
| 120842 | (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet); | 121532 | (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet); |
| 120843 | testcase( pParse->earlyCleanup ); | 121533 | testcase( pParse->earlyCleanup ); |
| 120844 | if( db->mallocFailed ) return; | 121534 | if( db->mallocFailed ) return; |
| 120845 | pRet->retTrig.zName = RETURNING_TRIGGER_NAME; | 121535 | sqlite3_snprintf(sizeof(pRet->zName), pRet->zName, |
| 121536 | "sqlite_returning_%p", pParse); | ||
| 121537 | pRet->retTrig.zName = pRet->zName; | ||
| 120846 | pRet->retTrig.op = TK_RETURNING; | 121538 | pRet->retTrig.op = TK_RETURNING; |
| 120847 | pRet->retTrig.tr_tm = TRIGGER_AFTER; | 121539 | pRet->retTrig.tr_tm = TRIGGER_AFTER; |
| 120848 | pRet->retTrig.bReturning = 1; | 121540 | pRet->retTrig.bReturning = 1; |
| @@ -120853,9 +121545,9 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ | |||
| 120853 | pRet->retTStep.pTrig = &pRet->retTrig; | 121545 | pRet->retTStep.pTrig = &pRet->retTrig; |
| 120854 | pRet->retTStep.pExprList = pList; | 121546 | pRet->retTStep.pExprList = pList; |
| 120855 | pHash = &(db->aDb[1].pSchema->trigHash); | 121547 | pHash = &(db->aDb[1].pSchema->trigHash); |
| 120856 | assert( sqlite3HashFind(pHash, RETURNING_TRIGGER_NAME)==0 | 121548 | assert( sqlite3HashFind(pHash, pRet->zName)==0 |
| 120857 | || pParse->nErr || pParse->ifNotExists ); | 121549 | || pParse->nErr || pParse->ifNotExists ); |
| 120858 | if( sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, &pRet->retTrig) | 121550 | if( sqlite3HashInsert(pHash, pRet->zName, &pRet->retTrig) |
| 120859 | ==&pRet->retTrig ){ | 121551 | ==&pRet->retTrig ){ |
| 120860 | sqlite3OomFault(db); | 121552 | sqlite3OomFault(db); |
| 120861 | } | 121553 | } |
| @@ -122299,6 +122991,17 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 122299 | /* Reparse everything to update our internal data structures */ | 122991 | /* Reparse everything to update our internal data structures */ |
| 122300 | sqlite3VdbeAddParseSchemaOp(v, iDb, | 122992 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 122301 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); | 122993 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); |
| 122994 | |||
| 122995 | /* Test for cycles in generated columns and illegal expressions | ||
| 122996 | ** in CHECK constraints and in DEFAULT clauses. */ | ||
| 122997 | if( p->tabFlags & TF_HasGenerated ){ | ||
| 122998 | sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, | ||
| 122999 | sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", | ||
| 123000 | db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); | ||
| 123001 | } | ||
| 123002 | sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, | ||
| 123003 | sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", | ||
| 123004 | db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); | ||
| 122302 | } | 123005 | } |
| 122303 | 123006 | ||
| 122304 | /* Add the table to the in-memory representation of the database. | 123007 | /* Add the table to the in-memory representation of the database. |
| @@ -127901,7 +128604,8 @@ static void hexFunc( | |||
| 127901 | *(z++) = hexdigits[c&0xf]; | 128604 | *(z++) = hexdigits[c&0xf]; |
| 127902 | } | 128605 | } |
| 127903 | *z = 0; | 128606 | *z = 0; |
| 127904 | sqlite3_result_text(context, zHex, n*2, sqlite3_free); | 128607 | sqlite3_result_text64(context, zHex, (u64)(z-zHex), |
| 128608 | sqlite3_free, SQLITE_UTF8); | ||
| 127905 | } | 128609 | } |
| 127906 | } | 128610 | } |
| 127907 | 128611 | ||
| @@ -128195,6 +128899,81 @@ static void trimFunc( | |||
| 128195 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); | 128899 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); |
| 128196 | } | 128900 | } |
| 128197 | 128901 | ||
| 128902 | /* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) | ||
| 128903 | ** functions. | ||
| 128904 | ** | ||
| 128905 | ** Return a string value that is the concatenation of all non-null | ||
| 128906 | ** entries in argv[]. Use zSep as the separator. | ||
| 128907 | */ | ||
| 128908 | static void concatFuncCore( | ||
| 128909 | sqlite3_context *context, | ||
| 128910 | int argc, | ||
| 128911 | sqlite3_value **argv, | ||
| 128912 | int nSep, | ||
| 128913 | const char *zSep | ||
| 128914 | ){ | ||
| 128915 | i64 j, k, n = 0; | ||
| 128916 | int i; | ||
| 128917 | char *z; | ||
| 128918 | for(i=0; i<argc; i++){ | ||
| 128919 | n += sqlite3_value_bytes(argv[i]); | ||
| 128920 | } | ||
| 128921 | n += (argc-1)*nSep; | ||
| 128922 | z = sqlite3_malloc64(n+1); | ||
| 128923 | if( z==0 ){ | ||
| 128924 | sqlite3_result_error_nomem(context); | ||
| 128925 | return; | ||
| 128926 | } | ||
| 128927 | j = 0; | ||
| 128928 | for(i=0; i<argc; i++){ | ||
| 128929 | k = sqlite3_value_bytes(argv[i]); | ||
| 128930 | if( k>0 ){ | ||
| 128931 | const char *v = (const char*)sqlite3_value_text(argv[i]); | ||
| 128932 | if( v!=0 ){ | ||
| 128933 | if( j>0 && nSep>0 ){ | ||
| 128934 | memcpy(&z[j], zSep, nSep); | ||
| 128935 | j += nSep; | ||
| 128936 | } | ||
| 128937 | memcpy(&z[j], v, k); | ||
| 128938 | j += k; | ||
| 128939 | } | ||
| 128940 | } | ||
| 128941 | } | ||
| 128942 | z[j] = 0; | ||
| 128943 | assert( j<=n ); | ||
| 128944 | sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8); | ||
| 128945 | } | ||
| 128946 | |||
| 128947 | /* | ||
| 128948 | ** The CONCAT(...) function. Generate a string result that is the | ||
| 128949 | ** concatentation of all non-null arguments. | ||
| 128950 | */ | ||
| 128951 | static void concatFunc( | ||
| 128952 | sqlite3_context *context, | ||
| 128953 | int argc, | ||
| 128954 | sqlite3_value **argv | ||
| 128955 | ){ | ||
| 128956 | concatFuncCore(context, argc, argv, 0, ""); | ||
| 128957 | } | ||
| 128958 | |||
| 128959 | /* | ||
| 128960 | ** The CONCAT_WS(separator, ...) function. | ||
| 128961 | ** | ||
| 128962 | ** Generate a string that is the concatenation of 2nd through the Nth | ||
| 128963 | ** argument. Use the first argument (which must be non-NULL) as the | ||
| 128964 | ** separator. | ||
| 128965 | */ | ||
| 128966 | static void concatwsFunc( | ||
| 128967 | sqlite3_context *context, | ||
| 128968 | int argc, | ||
| 128969 | sqlite3_value **argv | ||
| 128970 | ){ | ||
| 128971 | int nSep = sqlite3_value_bytes(argv[0]); | ||
| 128972 | const char *zSep = (const char*)sqlite3_value_text(argv[0]); | ||
| 128973 | if( zSep==0 ) return; | ||
| 128974 | concatFuncCore(context, argc-1, argv+1, nSep, zSep); | ||
| 128975 | } | ||
| 128976 | |||
| 128198 | 128977 | ||
| 128199 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION | 128978 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 128200 | /* | 128979 | /* |
| @@ -128616,6 +129395,7 @@ static void minMaxFinalize(sqlite3_context *context){ | |||
| 128616 | 129395 | ||
| 128617 | /* | 129396 | /* |
| 128618 | ** group_concat(EXPR, ?SEPARATOR?) | 129397 | ** group_concat(EXPR, ?SEPARATOR?) |
| 129398 | ** string_agg(EXPR, SEPARATOR) | ||
| 128619 | ** | 129399 | ** |
| 128620 | ** The SEPARATOR goes before the EXPR string. This is tragic. The | 129400 | ** The SEPARATOR goes before the EXPR string. This is tragic. The |
| 128621 | ** groupConcatInverse() implementation would have been easier if the | 129401 | ** groupConcatInverse() implementation would have been easier if the |
| @@ -129206,6 +129986,11 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 129206 | FUNCTION(hex, 1, 0, 0, hexFunc ), | 129986 | FUNCTION(hex, 1, 0, 0, hexFunc ), |
| 129207 | FUNCTION(unhex, 1, 0, 0, unhexFunc ), | 129987 | FUNCTION(unhex, 1, 0, 0, unhexFunc ), |
| 129208 | FUNCTION(unhex, 2, 0, 0, unhexFunc ), | 129988 | FUNCTION(unhex, 2, 0, 0, unhexFunc ), |
| 129989 | FUNCTION(concat, -1, 0, 0, concatFunc ), | ||
| 129990 | FUNCTION(concat, 0, 0, 0, 0 ), | ||
| 129991 | FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), | ||
| 129992 | FUNCTION(concat_ws, 0, 0, 0, 0 ), | ||
| 129993 | FUNCTION(concat_ws, 1, 0, 0, 0 ), | ||
| 129209 | INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), | 129994 | INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), |
| 129210 | VFUNCTION(random, 0, 0, 0, randomFunc ), | 129995 | VFUNCTION(random, 0, 0, 0, randomFunc ), |
| 129211 | VFUNCTION(randomblob, 1, 0, 0, randomBlob ), | 129996 | VFUNCTION(randomblob, 1, 0, 0, randomBlob ), |
| @@ -129235,6 +130020,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 129235 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), | 130020 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 129236 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, | 130021 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, |
| 129237 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), | 130022 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 130023 | WAGGREGATE(string_agg, 2, 0, 0, groupConcatStep, | ||
| 130024 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), | ||
| 129238 | 130025 | ||
| 129239 | LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), | 130026 | LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 129240 | #ifdef SQLITE_CASE_SENSITIVE_LIKE | 130027 | #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| @@ -130177,6 +130964,7 @@ static int isSetNullAction(Parse *pParse, FKey *pFKey){ | |||
| 130177 | if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) | 130964 | if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) |
| 130178 | || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) | 130965 | || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) |
| 130179 | ){ | 130966 | ){ |
| 130967 | assert( (pTop->db->flags & SQLITE_FkNoAction)==0 ); | ||
| 130180 | return 1; | 130968 | return 1; |
| 130181 | } | 130969 | } |
| 130182 | } | 130970 | } |
| @@ -130371,6 +131159,8 @@ SQLITE_PRIVATE void sqlite3FkCheck( | |||
| 130371 | } | 131159 | } |
| 130372 | if( regOld!=0 ){ | 131160 | if( regOld!=0 ){ |
| 130373 | int eAction = pFKey->aAction[aChange!=0]; | 131161 | int eAction = pFKey->aAction[aChange!=0]; |
| 131162 | if( (db->flags & SQLITE_FkNoAction) ) eAction = OE_None; | ||
| 131163 | |||
| 130374 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); | 131164 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); |
| 130375 | /* If this is a deferred FK constraint, or a CASCADE or SET NULL | 131165 | /* If this is a deferred FK constraint, or a CASCADE or SET NULL |
| 130376 | ** action applies, then any foreign key violations caused by | 131166 | ** action applies, then any foreign key violations caused by |
| @@ -130486,7 +131276,11 @@ SQLITE_PRIVATE int sqlite3FkRequired( | |||
| 130486 | /* Check if any parent key columns are being modified. */ | 131276 | /* Check if any parent key columns are being modified. */ |
| 130487 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ | 131277 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 130488 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ | 131278 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 130489 | if( p->aAction[1]!=OE_None ) return 2; | 131279 | if( (pParse->db->flags & SQLITE_FkNoAction)==0 |
| 131280 | && p->aAction[1]!=OE_None | ||
| 131281 | ){ | ||
| 131282 | return 2; | ||
| 131283 | } | ||
| 130490 | bHaveFK = 1; | 131284 | bHaveFK = 1; |
| 130491 | } | 131285 | } |
| 130492 | } | 131286 | } |
| @@ -130536,6 +131330,7 @@ static Trigger *fkActionTrigger( | |||
| 130536 | int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ | 131330 | int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ |
| 130537 | 131331 | ||
| 130538 | action = pFKey->aAction[iAction]; | 131332 | action = pFKey->aAction[iAction]; |
| 131333 | if( (db->flags & SQLITE_FkNoAction) ) action = OE_None; | ||
| 130539 | if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ | 131334 | if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ |
| 130540 | return 0; | 131335 | return 0; |
| 130541 | } | 131336 | } |
| @@ -134491,6 +135286,9 @@ struct sqlite3_api_routines { | |||
| 134491 | int (*is_interrupted)(sqlite3*); | 135286 | int (*is_interrupted)(sqlite3*); |
| 134492 | /* Version 3.43.0 and later */ | 135287 | /* Version 3.43.0 and later */ |
| 134493 | int (*stmt_explain)(sqlite3_stmt*,int); | 135288 | int (*stmt_explain)(sqlite3_stmt*,int); |
| 135289 | /* Version 3.44.0 and later */ | ||
| 135290 | void *(*get_clientdata)(sqlite3*,const char*); | ||
| 135291 | int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*)); | ||
| 134494 | }; | 135292 | }; |
| 134495 | 135293 | ||
| 134496 | /* | 135294 | /* |
| @@ -134821,6 +135619,9 @@ typedef int (*sqlite3_loadext_entry)( | |||
| 134821 | #define sqlite3_is_interrupted sqlite3_api->is_interrupted | 135619 | #define sqlite3_is_interrupted sqlite3_api->is_interrupted |
| 134822 | /* Version 3.43.0 and later */ | 135620 | /* Version 3.43.0 and later */ |
| 134823 | #define sqlite3_stmt_explain sqlite3_api->stmt_explain | 135621 | #define sqlite3_stmt_explain sqlite3_api->stmt_explain |
| 135622 | /* Version 3.44.0 and later */ | ||
| 135623 | #define sqlite3_get_clientdata sqlite3_api->get_clientdata | ||
| 135624 | #define sqlite3_set_clientdata sqlite3_api->set_clientdata | ||
| 134824 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ | 135625 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 134825 | 135626 | ||
| 134826 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) | 135627 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| @@ -135339,7 +136140,10 @@ static const sqlite3_api_routines sqlite3Apis = { | |||
| 135339 | /* Version 3.41.0 and later */ | 136140 | /* Version 3.41.0 and later */ |
| 135340 | sqlite3_is_interrupted, | 136141 | sqlite3_is_interrupted, |
| 135341 | /* Version 3.43.0 and later */ | 136142 | /* Version 3.43.0 and later */ |
| 135342 | sqlite3_stmt_explain | 136143 | sqlite3_stmt_explain, |
| 136144 | /* Version 3.44.0 and later */ | ||
| 136145 | sqlite3_get_clientdata, | ||
| 136146 | sqlite3_set_clientdata | ||
| 135343 | }; | 136147 | }; |
| 135344 | 136148 | ||
| 135345 | /* True if x is the directory separator character | 136149 | /* True if x is the directory separator character |
| @@ -135555,6 +136359,9 @@ SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){ | |||
| 135555 | ** default so as not to open security holes in older applications. | 136359 | ** default so as not to open security holes in older applications. |
| 135556 | */ | 136360 | */ |
| 135557 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ | 136361 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
| 136362 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 136363 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | ||
| 136364 | #endif | ||
| 135558 | sqlite3_mutex_enter(db->mutex); | 136365 | sqlite3_mutex_enter(db->mutex); |
| 135559 | if( onoff ){ | 136366 | if( onoff ){ |
| 135560 | db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; | 136367 | db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; |
| @@ -135604,6 +136411,9 @@ SQLITE_API int sqlite3_auto_extension( | |||
| 135604 | void (*xInit)(void) | 136411 | void (*xInit)(void) |
| 135605 | ){ | 136412 | ){ |
| 135606 | int rc = SQLITE_OK; | 136413 | int rc = SQLITE_OK; |
| 136414 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 136415 | if( xInit==0 ) return SQLITE_MISUSE_BKPT; | ||
| 136416 | #endif | ||
| 135607 | #ifndef SQLITE_OMIT_AUTOINIT | 136417 | #ifndef SQLITE_OMIT_AUTOINIT |
| 135608 | rc = sqlite3_initialize(); | 136418 | rc = sqlite3_initialize(); |
| 135609 | if( rc ){ | 136419 | if( rc ){ |
| @@ -135656,6 +136466,9 @@ SQLITE_API int sqlite3_cancel_auto_extension( | |||
| 135656 | int i; | 136466 | int i; |
| 135657 | int n = 0; | 136467 | int n = 0; |
| 135658 | wsdAutoextInit; | 136468 | wsdAutoextInit; |
| 136469 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 136470 | if( xInit==0 ) return 0; | ||
| 136471 | #endif | ||
| 135659 | sqlite3_mutex_enter(mutex); | 136472 | sqlite3_mutex_enter(mutex); |
| 135660 | for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ | 136473 | for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ |
| 135661 | if( wsdAutoext.aExt[i]==xInit ){ | 136474 | if( wsdAutoext.aExt[i]==xInit ){ |
| @@ -137525,7 +138338,11 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 137525 | #endif | 138338 | #endif |
| 137526 | 138339 | ||
| 137527 | if( sqlite3GetBoolean(zRight, 0) ){ | 138340 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 137528 | db->flags |= mask; | 138341 | if( (mask & SQLITE_WriteSchema)==0 |
| 138342 | || (db->flags & SQLITE_Defensive)==0 | ||
| 138343 | ){ | ||
| 138344 | db->flags |= mask; | ||
| 138345 | } | ||
| 137529 | }else{ | 138346 | }else{ |
| 137530 | db->flags &= ~mask; | 138347 | db->flags &= ~mask; |
| 137531 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; | 138348 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; |
| @@ -138158,8 +138975,31 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 138158 | int r2; /* Previous key for WITHOUT ROWID tables */ | 138975 | int r2; /* Previous key for WITHOUT ROWID tables */ |
| 138159 | int mxCol; /* Maximum non-virtual column number */ | 138976 | int mxCol; /* Maximum non-virtual column number */ |
| 138160 | 138977 | ||
| 138161 | if( !IsOrdinaryTable(pTab) ) continue; | ||
| 138162 | if( pObjTab && pObjTab!=pTab ) continue; | 138978 | if( pObjTab && pObjTab!=pTab ) continue; |
| 138979 | if( !IsOrdinaryTable(pTab) ){ | ||
| 138980 | #ifndef SQLITE_OMIT_VIRTUALTABLE | ||
| 138981 | sqlite3_vtab *pVTab; | ||
| 138982 | int a1; | ||
| 138983 | if( !IsVirtual(pTab) ) continue; | ||
| 138984 | if( pTab->nCol<=0 ){ | ||
| 138985 | const char *zMod = pTab->u.vtab.azArg[0]; | ||
| 138986 | if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue; | ||
| 138987 | } | ||
| 138988 | sqlite3ViewGetColumnNames(pParse, pTab); | ||
| 138989 | if( pTab->u.vtab.p==0 ) continue; | ||
| 138990 | pVTab = pTab->u.vtab.p->pVtab; | ||
| 138991 | if( NEVER(pVTab==0) ) continue; | ||
| 138992 | if( NEVER(pVTab->pModule==0) ) continue; | ||
| 138993 | if( pVTab->pModule->iVersion<4 ) continue; | ||
| 138994 | if( pVTab->pModule->xIntegrity==0 ) continue; | ||
| 138995 | sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick); | ||
| 138996 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); | ||
| 138997 | a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); | ||
| 138998 | integrityCheckResultRow(v); | ||
| 138999 | sqlite3VdbeJumpHere(v, a1); | ||
| 139000 | #endif | ||
| 139001 | continue; | ||
| 139002 | } | ||
| 138163 | if( isQuick || HasRowid(pTab) ){ | 139003 | if( isQuick || HasRowid(pTab) ){ |
| 138164 | pPk = 0; | 139004 | pPk = 0; |
| 138165 | r2 = 0; | 139005 | r2 = 0; |
| @@ -139285,7 +140125,8 @@ static const sqlite3_module pragmaVtabModule = { | |||
| 139285 | 0, /* xSavepoint */ | 140125 | 0, /* xSavepoint */ |
| 139286 | 0, /* xRelease */ | 140126 | 0, /* xRelease */ |
| 139287 | 0, /* xRollbackTo */ | 140127 | 0, /* xRollbackTo */ |
| 139288 | 0 /* xShadowName */ | 140128 | 0, /* xShadowName */ |
| 140129 | 0 /* xIntegrity */ | ||
| 139289 | }; | 140130 | }; |
| 139290 | 140131 | ||
| 139291 | /* | 140132 | /* |
| @@ -139909,8 +140750,6 @@ SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse *pParse){ | |||
| 139909 | db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; | 140750 | db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; |
| 139910 | assert( pParse->db->pParse==pParse ); | 140751 | assert( pParse->db->pParse==pParse ); |
| 139911 | db->pParse = pParse->pOuterParse; | 140752 | db->pParse = pParse->pOuterParse; |
| 139912 | pParse->db = 0; | ||
| 139913 | pParse->disableLookaside = 0; | ||
| 139914 | } | 140753 | } |
| 139915 | 140754 | ||
| 139916 | /* | 140755 | /* |
| @@ -140848,6 +141687,7 @@ static void unsetJoinExpr(Expr *p, int iTable, int nullable){ | |||
| 140848 | } | 141687 | } |
| 140849 | if( p->op==TK_FUNCTION ){ | 141688 | if( p->op==TK_FUNCTION ){ |
| 140850 | assert( ExprUseXList(p) ); | 141689 | assert( ExprUseXList(p) ); |
| 141690 | assert( p->pLeft==0 ); | ||
| 140851 | if( p->x.pList ){ | 141691 | if( p->x.pList ){ |
| 140852 | int i; | 141692 | int i; |
| 140853 | for(i=0; i<p->x.pList->nExpr; i++){ | 141693 | for(i=0; i<p->x.pList->nExpr; i++){ |
| @@ -146508,6 +147348,7 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 146508 | char *zTName = 0; /* text of name of TABLE */ | 147348 | char *zTName = 0; /* text of name of TABLE */ |
| 146509 | int iErrOfst; | 147349 | int iErrOfst; |
| 146510 | if( pE->op==TK_DOT ){ | 147350 | if( pE->op==TK_DOT ){ |
| 147351 | assert( (selFlags & SF_NestedFrom)==0 ); | ||
| 146511 | assert( pE->pLeft!=0 ); | 147352 | assert( pE->pLeft!=0 ); |
| 146512 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); | 147353 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 146513 | zTName = pE->pLeft->u.zToken; | 147354 | zTName = pE->pLeft->u.zToken; |
| @@ -146518,6 +147359,7 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 146518 | iErrOfst = pE->w.iOfst; | 147359 | iErrOfst = pE->w.iOfst; |
| 146519 | } | 147360 | } |
| 146520 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ | 147361 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 147362 | int nAdd; /* Number of cols including rowid */ | ||
| 146521 | Table *pTab = pFrom->pTab; /* Table for this data source */ | 147363 | Table *pTab = pFrom->pTab; /* Table for this data source */ |
| 146522 | ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ | 147364 | ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ |
| 146523 | char *zTabName; /* AS name for this data source */ | 147365 | char *zTabName; /* AS name for this data source */ |
| @@ -146535,6 +147377,7 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 146535 | pNestedFrom = pFrom->pSelect->pEList; | 147377 | pNestedFrom = pFrom->pSelect->pEList; |
| 146536 | assert( pNestedFrom!=0 ); | 147378 | assert( pNestedFrom!=0 ); |
| 146537 | assert( pNestedFrom->nExpr==pTab->nCol ); | 147379 | assert( pNestedFrom->nExpr==pTab->nCol ); |
| 147380 | assert( VisibleRowid(pTab)==0 ); | ||
| 146538 | }else{ | 147381 | }else{ |
| 146539 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ | 147382 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 146540 | continue; | 147383 | continue; |
| @@ -146565,33 +147408,48 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 146565 | }else{ | 147408 | }else{ |
| 146566 | pUsing = 0; | 147409 | pUsing = 0; |
| 146567 | } | 147410 | } |
| 146568 | for(j=0; j<pTab->nCol; j++){ | 147411 | |
| 146569 | char *zName = pTab->aCol[j].zCnName; | 147412 | nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom)); |
| 147413 | for(j=0; j<nAdd; j++){ | ||
| 147414 | const char *zName; | ||
| 146570 | struct ExprList_item *pX; /* Newly added ExprList term */ | 147415 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 146571 | 147416 | ||
| 146572 | assert( zName ); | 147417 | if( j==pTab->nCol ){ |
| 146573 | if( zTName | 147418 | zName = sqlite3RowidAlias(pTab); |
| 146574 | && pNestedFrom | 147419 | if( zName==0 ) continue; |
| 146575 | && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0)==0 | 147420 | }else{ |
| 146576 | ){ | 147421 | zName = pTab->aCol[j].zCnName; |
| 146577 | continue; | ||
| 146578 | } | ||
| 146579 | 147422 | ||
| 146580 | /* If a column is marked as 'hidden', omit it from the expanded | 147423 | /* If pTab is actually an SF_NestedFrom sub-select, do not |
| 146581 | ** result-set list unless the SELECT has the SF_IncludeHidden | 147424 | ** expand any ENAME_ROWID columns. */ |
| 146582 | ** bit set. | 147425 | if( pNestedFrom && pNestedFrom->a[j].fg.eEName==ENAME_ROWID ){ |
| 146583 | */ | 147426 | continue; |
| 146584 | if( (p->selFlags & SF_IncludeHidden)==0 | 147427 | } |
| 146585 | && IsHiddenColumn(&pTab->aCol[j]) | 147428 | |
| 146586 | ){ | 147429 | if( zTName |
| 146587 | continue; | 147430 | && pNestedFrom |
| 146588 | } | 147431 | && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0, 0)==0 |
| 146589 | if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 | 147432 | ){ |
| 146590 | && zTName==0 | 147433 | continue; |
| 146591 | && (selFlags & (SF_NestedFrom))==0 | 147434 | } |
| 146592 | ){ | 147435 | |
| 146593 | continue; | 147436 | /* If a column is marked as 'hidden', omit it from the expanded |
| 147437 | ** result-set list unless the SELECT has the SF_IncludeHidden | ||
| 147438 | ** bit set. | ||
| 147439 | */ | ||
| 147440 | if( (p->selFlags & SF_IncludeHidden)==0 | ||
| 147441 | && IsHiddenColumn(&pTab->aCol[j]) | ||
| 147442 | ){ | ||
| 147443 | continue; | ||
| 147444 | } | ||
| 147445 | if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 | ||
| 147446 | && zTName==0 | ||
| 147447 | && (selFlags & (SF_NestedFrom))==0 | ||
| 147448 | ){ | ||
| 147449 | continue; | ||
| 147450 | } | ||
| 146594 | } | 147451 | } |
| 147452 | assert( zName ); | ||
| 146595 | tableSeen = 1; | 147453 | tableSeen = 1; |
| 146596 | 147454 | ||
| 146597 | if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ | 147455 | if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ |
| @@ -146641,11 +147499,11 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 146641 | zSchemaName, zTabName, zName); | 147499 | zSchemaName, zTabName, zName); |
| 146642 | testcase( pX->zEName==0 ); | 147500 | testcase( pX->zEName==0 ); |
| 146643 | } | 147501 | } |
| 146644 | pX->fg.eEName = ENAME_TAB; | 147502 | pX->fg.eEName = (j==pTab->nCol ? ENAME_ROWID : ENAME_TAB); |
| 146645 | if( (pFrom->fg.isUsing | 147503 | if( (pFrom->fg.isUsing |
| 146646 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) | 147504 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) |
| 146647 | || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) | 147505 | || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) |
| 146648 | || (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 | 147506 | || (j<pTab->nCol && (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)) |
| 146649 | ){ | 147507 | ){ |
| 146650 | pX->fg.bNoExpand = 1; | 147508 | pX->fg.bNoExpand = 1; |
| 146651 | } | 147509 | } |
| @@ -146866,8 +147724,14 @@ static void analyzeAggFuncArgs( | |||
| 146866 | pNC->ncFlags |= NC_InAggFunc; | 147724 | pNC->ncFlags |= NC_InAggFunc; |
| 146867 | for(i=0; i<pAggInfo->nFunc; i++){ | 147725 | for(i=0; i<pAggInfo->nFunc; i++){ |
| 146868 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; | 147726 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; |
| 147727 | assert( pExpr->op==TK_FUNCTION || pExpr->op==TK_AGG_FUNCTION ); | ||
| 146869 | assert( ExprUseXList(pExpr) ); | 147728 | assert( ExprUseXList(pExpr) ); |
| 146870 | sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); | 147729 | sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); |
| 147730 | if( pExpr->pLeft ){ | ||
| 147731 | assert( pExpr->pLeft->op==TK_ORDER ); | ||
| 147732 | assert( ExprUseXList(pExpr->pLeft) ); | ||
| 147733 | sqlite3ExprAnalyzeAggList(pNC, pExpr->pLeft->x.pList); | ||
| 147734 | } | ||
| 146871 | #ifndef SQLITE_OMIT_WINDOWFUNC | 147735 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 146872 | assert( !IsWindowFunc(pExpr) ); | 147736 | assert( !IsWindowFunc(pExpr) ); |
| 146873 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ | 147737 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| @@ -147022,6 +147886,32 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ | |||
| 147022 | pFunc->pFunc->zName)); | 147886 | pFunc->pFunc->zName)); |
| 147023 | } | 147887 | } |
| 147024 | } | 147888 | } |
| 147889 | if( pFunc->iOBTab>=0 ){ | ||
| 147890 | ExprList *pOBList; | ||
| 147891 | KeyInfo *pKeyInfo; | ||
| 147892 | int nExtra = 0; | ||
| 147893 | assert( pFunc->pFExpr->pLeft!=0 ); | ||
| 147894 | assert( pFunc->pFExpr->pLeft->op==TK_ORDER ); | ||
| 147895 | assert( ExprUseXList(pFunc->pFExpr->pLeft) ); | ||
| 147896 | pOBList = pFunc->pFExpr->pLeft->x.pList; | ||
| 147897 | if( !pFunc->bOBUnique ){ | ||
| 147898 | nExtra++; /* One extra column for the OP_Sequence */ | ||
| 147899 | } | ||
| 147900 | if( pFunc->bOBPayload ){ | ||
| 147901 | /* extra columns for the function arguments */ | ||
| 147902 | assert( ExprUseXList(pFunc->pFExpr) ); | ||
| 147903 | nExtra += pFunc->pFExpr->x.pList->nExpr; | ||
| 147904 | } | ||
| 147905 | pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOBList, 0, nExtra); | ||
| 147906 | if( !pFunc->bOBUnique && pParse->nErr==0 ){ | ||
| 147907 | pKeyInfo->nKeyField++; | ||
| 147908 | } | ||
| 147909 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, | ||
| 147910 | pFunc->iOBTab, pOBList->nExpr+nExtra, 0, | ||
| 147911 | (char*)pKeyInfo, P4_KEYINFO); | ||
| 147912 | ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(ORDER BY)", | ||
| 147913 | pFunc->pFunc->zName)); | ||
| 147914 | } | ||
| 147025 | } | 147915 | } |
| 147026 | } | 147916 | } |
| 147027 | 147917 | ||
| @@ -147037,13 +147927,46 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ | |||
| 147037 | ExprList *pList; | 147927 | ExprList *pList; |
| 147038 | assert( ExprUseXList(pF->pFExpr) ); | 147928 | assert( ExprUseXList(pF->pFExpr) ); |
| 147039 | pList = pF->pFExpr->x.pList; | 147929 | pList = pF->pFExpr->x.pList; |
| 147930 | if( pF->iOBTab>=0 ){ | ||
| 147931 | /* For an ORDER BY aggregate, calls to OP_AggStep where deferred and | ||
| 147932 | ** all content was stored in emphermal table pF->iOBTab. Extract that | ||
| 147933 | ** content now (in ORDER BY order) and make all calls to OP_AggStep | ||
| 147934 | ** before doing the OP_AggFinal call. */ | ||
| 147935 | int iTop; /* Start of loop for extracting columns */ | ||
| 147936 | int nArg; /* Number of columns to extract */ | ||
| 147937 | int nKey; /* Key columns to be skipped */ | ||
| 147938 | int regAgg; /* Extract into this array */ | ||
| 147939 | int j; /* Loop counter */ | ||
| 147940 | |||
| 147941 | nArg = pList->nExpr; | ||
| 147942 | regAgg = sqlite3GetTempRange(pParse, nArg); | ||
| 147943 | |||
| 147944 | if( pF->bOBPayload==0 ){ | ||
| 147945 | nKey = 0; | ||
| 147946 | }else{ | ||
| 147947 | assert( pF->pFExpr->pLeft!=0 ); | ||
| 147948 | assert( ExprUseXList(pF->pFExpr->pLeft) ); | ||
| 147949 | assert( pF->pFExpr->pLeft->x.pList!=0 ); | ||
| 147950 | nKey = pF->pFExpr->pLeft->x.pList->nExpr; | ||
| 147951 | if( ALWAYS(!pF->bOBUnique) ) nKey++; | ||
| 147952 | } | ||
| 147953 | iTop = sqlite3VdbeAddOp1(v, OP_Rewind, pF->iOBTab); VdbeCoverage(v); | ||
| 147954 | for(j=nArg-1; j>=0; j--){ | ||
| 147955 | sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, nKey+j, regAgg+j); | ||
| 147956 | } | ||
| 147957 | sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); | ||
| 147958 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); | ||
| 147959 | sqlite3VdbeChangeP5(v, (u8)nArg); | ||
| 147960 | sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v); | ||
| 147961 | sqlite3VdbeJumpHere(v, iTop); | ||
| 147962 | sqlite3ReleaseTempRange(pParse, regAgg, nArg); | ||
| 147963 | } | ||
| 147040 | sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), | 147964 | sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), |
| 147041 | pList ? pList->nExpr : 0); | 147965 | pList ? pList->nExpr : 0); |
| 147042 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); | 147966 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 147043 | } | 147967 | } |
| 147044 | } | 147968 | } |
| 147045 | 147969 | ||
| 147046 | |||
| 147047 | /* | 147970 | /* |
| 147048 | ** Generate code that will update the accumulator memory cells for an | 147971 | ** Generate code that will update the accumulator memory cells for an |
| 147049 | ** aggregate based on the current cursor position. | 147972 | ** aggregate based on the current cursor position. |
| @@ -147052,6 +147975,13 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ | |||
| 147052 | ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator | 147975 | ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator |
| 147053 | ** registers if register regAcc contains 0. The caller will take care | 147976 | ** registers if register regAcc contains 0. The caller will take care |
| 147054 | ** of setting and clearing regAcc. | 147977 | ** of setting and clearing regAcc. |
| 147978 | ** | ||
| 147979 | ** For an ORDER BY aggregate, the actual accumulator memory cell update | ||
| 147980 | ** is deferred until after all input rows have been received, so that they | ||
| 147981 | ** can be run in the requested order. In that case, instead of invoking | ||
| 147982 | ** OP_AggStep to update the accumulator, just add the arguments that would | ||
| 147983 | ** have been passed into OP_AggStep into the sorting ephemeral table | ||
| 147984 | ** (along with the appropriate sort key). | ||
| 147055 | */ | 147985 | */ |
| 147056 | static void updateAccumulator( | 147986 | static void updateAccumulator( |
| 147057 | Parse *pParse, | 147987 | Parse *pParse, |
| @@ -147073,6 +148003,8 @@ static void updateAccumulator( | |||
| 147073 | int nArg; | 148003 | int nArg; |
| 147074 | int addrNext = 0; | 148004 | int addrNext = 0; |
| 147075 | int regAgg; | 148005 | int regAgg; |
| 148006 | int regAggSz = 0; | ||
| 148007 | int regDistinct = 0; | ||
| 147076 | ExprList *pList; | 148008 | ExprList *pList; |
| 147077 | assert( ExprUseXList(pF->pFExpr) ); | 148009 | assert( ExprUseXList(pF->pFExpr) ); |
| 147078 | assert( !IsWindowFunc(pF->pFExpr) ); | 148010 | assert( !IsWindowFunc(pF->pFExpr) ); |
| @@ -147099,9 +148031,44 @@ static void updateAccumulator( | |||
| 147099 | addrNext = sqlite3VdbeMakeLabel(pParse); | 148031 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 147100 | sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); | 148032 | sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); |
| 147101 | } | 148033 | } |
| 147102 | if( pList ){ | 148034 | if( pF->iOBTab>=0 ){ |
| 148035 | /* Instead of invoking AggStep, we must push the arguments that would | ||
| 148036 | ** have been passed to AggStep onto the sorting table. */ | ||
| 148037 | int jj; /* Registered used so far in building the record */ | ||
| 148038 | ExprList *pOBList; /* The ORDER BY clause */ | ||
| 148039 | assert( pList!=0 ); | ||
| 148040 | nArg = pList->nExpr; | ||
| 148041 | assert( nArg>0 ); | ||
| 148042 | assert( pF->pFExpr->pLeft!=0 ); | ||
| 148043 | assert( pF->pFExpr->pLeft->op==TK_ORDER ); | ||
| 148044 | assert( ExprUseXList(pF->pFExpr->pLeft) ); | ||
| 148045 | pOBList = pF->pFExpr->pLeft->x.pList; | ||
| 148046 | assert( pOBList!=0 ); | ||
| 148047 | assert( pOBList->nExpr>0 ); | ||
| 148048 | regAggSz = pOBList->nExpr; | ||
| 148049 | if( !pF->bOBUnique ){ | ||
| 148050 | regAggSz++; /* One register for OP_Sequence */ | ||
| 148051 | } | ||
| 148052 | if( pF->bOBPayload ){ | ||
| 148053 | regAggSz += nArg; | ||
| 148054 | } | ||
| 148055 | regAggSz++; /* One extra register to hold result of MakeRecord */ | ||
| 148056 | regAgg = sqlite3GetTempRange(pParse, regAggSz); | ||
| 148057 | regDistinct = regAgg; | ||
| 148058 | sqlite3ExprCodeExprList(pParse, pOBList, regAgg, 0, SQLITE_ECEL_DUP); | ||
| 148059 | jj = pOBList->nExpr; | ||
| 148060 | if( !pF->bOBUnique ){ | ||
| 148061 | sqlite3VdbeAddOp2(v, OP_Sequence, pF->iOBTab, regAgg+jj); | ||
| 148062 | jj++; | ||
| 148063 | } | ||
| 148064 | if( pF->bOBPayload ){ | ||
| 148065 | regDistinct = regAgg+jj; | ||
| 148066 | sqlite3ExprCodeExprList(pParse, pList, regDistinct, 0, SQLITE_ECEL_DUP); | ||
| 148067 | } | ||
| 148068 | }else if( pList ){ | ||
| 147103 | nArg = pList->nExpr; | 148069 | nArg = pList->nExpr; |
| 147104 | regAgg = sqlite3GetTempRange(pParse, nArg); | 148070 | regAgg = sqlite3GetTempRange(pParse, nArg); |
| 148071 | regDistinct = regAgg; | ||
| 147105 | sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); | 148072 | sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); |
| 147106 | }else{ | 148073 | }else{ |
| 147107 | nArg = 0; | 148074 | nArg = 0; |
| @@ -147112,26 +148079,37 @@ static void updateAccumulator( | |||
| 147112 | addrNext = sqlite3VdbeMakeLabel(pParse); | 148079 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 147113 | } | 148080 | } |
| 147114 | pF->iDistinct = codeDistinct(pParse, eDistinctType, | 148081 | pF->iDistinct = codeDistinct(pParse, eDistinctType, |
| 147115 | pF->iDistinct, addrNext, pList, regAgg); | 148082 | pF->iDistinct, addrNext, pList, regDistinct); |
| 147116 | } | 148083 | } |
| 147117 | if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ | 148084 | if( pF->iOBTab>=0 ){ |
| 147118 | CollSeq *pColl = 0; | 148085 | /* Insert a new record into the ORDER BY table */ |
| 147119 | struct ExprList_item *pItem; | 148086 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regAgg, regAggSz-1, |
| 147120 | int j; | 148087 | regAgg+regAggSz-1); |
| 147121 | assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ | 148088 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pF->iOBTab, regAgg+regAggSz-1, |
| 147122 | for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ | 148089 | regAgg, regAggSz-1); |
| 147123 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); | 148090 | sqlite3ReleaseTempRange(pParse, regAgg, regAggSz); |
| 147124 | } | 148091 | }else{ |
| 147125 | if( !pColl ){ | 148092 | /* Invoke the AggStep function */ |
| 147126 | pColl = pParse->db->pDfltColl; | 148093 | if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 148094 | CollSeq *pColl = 0; | ||
| 148095 | struct ExprList_item *pItem; | ||
| 148096 | int j; | ||
| 148097 | assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ | ||
| 148098 | for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ | ||
| 148099 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); | ||
| 148100 | } | ||
| 148101 | if( !pColl ){ | ||
| 148102 | pColl = pParse->db->pDfltColl; | ||
| 148103 | } | ||
| 148104 | if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; | ||
| 148105 | sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, | ||
| 148106 | (char *)pColl, P4_COLLSEQ); | ||
| 147127 | } | 148107 | } |
| 147128 | if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; | 148108 | sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); |
| 147129 | sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ); | 148109 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 148110 | sqlite3VdbeChangeP5(v, (u8)nArg); | ||
| 148111 | sqlite3ReleaseTempRange(pParse, regAgg, nArg); | ||
| 147130 | } | 148112 | } |
| 147131 | sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); | ||
| 147132 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); | ||
| 147133 | sqlite3VdbeChangeP5(v, (u8)nArg); | ||
| 147134 | sqlite3ReleaseTempRange(pParse, regAgg, nArg); | ||
| 147135 | if( addrNext ){ | 148113 | if( addrNext ){ |
| 147136 | sqlite3VdbeResolveLabel(v, addrNext); | 148114 | sqlite3VdbeResolveLabel(v, addrNext); |
| 147137 | } | 148115 | } |
| @@ -149192,6 +150170,10 @@ SQLITE_PRIVATE void sqlite3BeginTrigger( | |||
| 149192 | sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); | 150170 | sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); |
| 149193 | goto trigger_orphan_error; | 150171 | goto trigger_orphan_error; |
| 149194 | } | 150172 | } |
| 150173 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ | ||
| 150174 | sqlite3ErrorMsg(pParse, "cannot create triggers on shadow tables"); | ||
| 150175 | goto trigger_orphan_error; | ||
| 150176 | } | ||
| 149195 | 150177 | ||
| 149196 | /* Check that the trigger name is not reserved and that no trigger of the | 150178 | /* Check that the trigger name is not reserved and that no trigger of the |
| 149197 | ** specified name exists */ | 150179 | ** specified name exists */ |
| @@ -149975,10 +150957,17 @@ static void codeReturningTrigger( | |||
| 149975 | SrcList sFrom; | 150957 | SrcList sFrom; |
| 149976 | 150958 | ||
| 149977 | assert( v!=0 ); | 150959 | assert( v!=0 ); |
| 149978 | assert( pParse->bReturning ); | 150960 | if( !pParse->bReturning ){ |
| 150961 | /* This RETURNING trigger must be for a different statement as | ||
| 150962 | ** this statement lacks a RETURNING clause. */ | ||
| 150963 | return; | ||
| 150964 | } | ||
| 149979 | assert( db->pParse==pParse ); | 150965 | assert( db->pParse==pParse ); |
| 149980 | pReturning = pParse->u1.pReturning; | 150966 | pReturning = pParse->u1.pReturning; |
| 149981 | assert( pTrigger == &(pReturning->retTrig) ); | 150967 | if( pTrigger != &(pReturning->retTrig) ){ |
| 150968 | /* This RETURNING trigger is for a different statement */ | ||
| 150969 | return; | ||
| 150970 | } | ||
| 149982 | memset(&sSelect, 0, sizeof(sSelect)); | 150971 | memset(&sSelect, 0, sizeof(sSelect)); |
| 149983 | memset(&sFrom, 0, sizeof(sFrom)); | 150972 | memset(&sFrom, 0, sizeof(sFrom)); |
| 149984 | sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); | 150973 | sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); |
| @@ -153415,7 +154404,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ | |||
| 153415 | sqlite3_mutex_enter(db->mutex); | 154404 | sqlite3_mutex_enter(db->mutex); |
| 153416 | pCtx = db->pVtabCtx; | 154405 | pCtx = db->pVtabCtx; |
| 153417 | if( !pCtx || pCtx->bDeclared ){ | 154406 | if( !pCtx || pCtx->bDeclared ){ |
| 153418 | sqlite3Error(db, SQLITE_MISUSE); | 154407 | sqlite3Error(db, SQLITE_MISUSE_BKPT); |
| 153419 | sqlite3_mutex_leave(db->mutex); | 154408 | sqlite3_mutex_leave(db->mutex); |
| 153420 | return SQLITE_MISUSE_BKPT; | 154409 | return SQLITE_MISUSE_BKPT; |
| 153421 | } | 154410 | } |
| @@ -154606,7 +155595,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*); | |||
| 154606 | #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ | 155595 | #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ |
| 154607 | #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ | 155596 | #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ |
| 154608 | #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ | 155597 | #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ |
| 154609 | #define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */ | 155598 | /* 0x02000000 -- available for reuse */ |
| 154610 | #define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ | 155599 | #define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ |
| 154611 | 155600 | ||
| 154612 | #endif /* !defined(SQLITE_WHEREINT_H) */ | 155601 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| @@ -160401,13 +161390,17 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( | |||
| 160401 | WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ | 161390 | WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ |
| 160402 | int iCur; /* Cursor for table getting the filter */ | 161391 | int iCur; /* Cursor for table getting the filter */ |
| 160403 | IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ | 161392 | IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ |
| 161393 | IndexedExpr *saved_pIdxPartExpr; /* saved copy of Parse.pIdxPartExpr */ | ||
| 160404 | 161394 | ||
| 160405 | saved_pIdxEpr = pParse->pIdxEpr; | 161395 | saved_pIdxEpr = pParse->pIdxEpr; |
| 161396 | saved_pIdxPartExpr = pParse->pIdxPartExpr; | ||
| 160406 | pParse->pIdxEpr = 0; | 161397 | pParse->pIdxEpr = 0; |
| 161398 | pParse->pIdxPartExpr = 0; | ||
| 160407 | 161399 | ||
| 160408 | assert( pLoop!=0 ); | 161400 | assert( pLoop!=0 ); |
| 160409 | assert( v!=0 ); | 161401 | assert( v!=0 ); |
| 160410 | assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); | 161402 | assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); |
| 161403 | assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ); | ||
| 160411 | 161404 | ||
| 160412 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); | 161405 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 160413 | do{ | 161406 | do{ |
| @@ -160497,6 +161490,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( | |||
| 160497 | }while( iLevel < pWInfo->nLevel ); | 161490 | }while( iLevel < pWInfo->nLevel ); |
| 160498 | sqlite3VdbeJumpHere(v, addrOnce); | 161491 | sqlite3VdbeJumpHere(v, addrOnce); |
| 160499 | pParse->pIdxEpr = saved_pIdxEpr; | 161492 | pParse->pIdxEpr = saved_pIdxEpr; |
| 161493 | pParse->pIdxPartExpr = saved_pIdxPartExpr; | ||
| 160500 | } | 161494 | } |
| 160501 | 161495 | ||
| 160502 | 161496 | ||
| @@ -162757,6 +163751,100 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex( | |||
| 162757 | } | 163751 | } |
| 162758 | 163752 | ||
| 162759 | /* | 163753 | /* |
| 163754 | ** This is an sqlite3ParserAddCleanup() callback that is invoked to | ||
| 163755 | ** free the Parse->pIdxEpr list when the Parse object is destroyed. | ||
| 163756 | */ | ||
| 163757 | static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){ | ||
| 163758 | IndexedExpr **pp = (IndexedExpr**)pObject; | ||
| 163759 | while( *pp!=0 ){ | ||
| 163760 | IndexedExpr *p = *pp; | ||
| 163761 | *pp = p->pIENext; | ||
| 163762 | sqlite3ExprDelete(db, p->pExpr); | ||
| 163763 | sqlite3DbFreeNN(db, p); | ||
| 163764 | } | ||
| 163765 | } | ||
| 163766 | |||
| 163767 | /* | ||
| 163768 | ** This function is called for a partial index - one with a WHERE clause - in | ||
| 163769 | ** two scenarios. In both cases, it determines whether or not the WHERE | ||
| 163770 | ** clause on the index implies that a column of the table may be safely | ||
| 163771 | ** replaced by a constant expression. For example, in the following | ||
| 163772 | ** SELECT: | ||
| 163773 | ** | ||
| 163774 | ** CREATE INDEX i1 ON t1(b, c) WHERE a=<expr>; | ||
| 163775 | ** SELECT a, b, c FROM t1 WHERE a=<expr> AND b=?; | ||
| 163776 | ** | ||
| 163777 | ** The "a" in the select-list may be replaced by <expr>, iff: | ||
| 163778 | ** | ||
| 163779 | ** (a) <expr> is a constant expression, and | ||
| 163780 | ** (b) The (a=<expr>) comparison uses the BINARY collation sequence, and | ||
| 163781 | ** (c) Column "a" has an affinity other than NONE or BLOB. | ||
| 163782 | ** | ||
| 163783 | ** If argument pItem is NULL, then pMask must not be NULL. In this case this | ||
| 163784 | ** function is being called as part of determining whether or not pIdx | ||
| 163785 | ** is a covering index. This function clears any bits in (*pMask) | ||
| 163786 | ** corresponding to columns that may be replaced by constants as described | ||
| 163787 | ** above. | ||
| 163788 | ** | ||
| 163789 | ** Otherwise, if pItem is not NULL, then this function is being called | ||
| 163790 | ** as part of coding a loop that uses index pIdx. In this case, add entries | ||
| 163791 | ** to the Parse.pIdxPartExpr list for each column that can be replaced | ||
| 163792 | ** by a constant. | ||
| 163793 | */ | ||
| 163794 | static void wherePartIdxExpr( | ||
| 163795 | Parse *pParse, /* Parse context */ | ||
| 163796 | Index *pIdx, /* Partial index being processed */ | ||
| 163797 | Expr *pPart, /* WHERE clause being processed */ | ||
| 163798 | Bitmask *pMask, /* Mask to clear bits in */ | ||
| 163799 | int iIdxCur, /* Cursor number for index */ | ||
| 163800 | SrcItem *pItem /* The FROM clause entry for the table */ | ||
| 163801 | ){ | ||
| 163802 | assert( pItem==0 || (pItem->fg.jointype & JT_RIGHT)==0 ); | ||
| 163803 | assert( (pItem==0 || pMask==0) && (pMask!=0 || pItem!=0) ); | ||
| 163804 | |||
| 163805 | if( pPart->op==TK_AND ){ | ||
| 163806 | wherePartIdxExpr(pParse, pIdx, pPart->pRight, pMask, iIdxCur, pItem); | ||
| 163807 | pPart = pPart->pLeft; | ||
| 163808 | } | ||
| 163809 | |||
| 163810 | if( (pPart->op==TK_EQ || pPart->op==TK_IS) ){ | ||
| 163811 | Expr *pLeft = pPart->pLeft; | ||
| 163812 | Expr *pRight = pPart->pRight; | ||
| 163813 | u8 aff; | ||
| 163814 | |||
| 163815 | if( pLeft->op!=TK_COLUMN ) return; | ||
| 163816 | if( !sqlite3ExprIsConstant(pRight) ) return; | ||
| 163817 | if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return; | ||
| 163818 | if( pLeft->iColumn<0 ) return; | ||
| 163819 | aff = pIdx->pTable->aCol[pLeft->iColumn].affinity; | ||
| 163820 | if( aff>=SQLITE_AFF_TEXT ){ | ||
| 163821 | if( pItem ){ | ||
| 163822 | sqlite3 *db = pParse->db; | ||
| 163823 | IndexedExpr *p = (IndexedExpr*)sqlite3DbMallocRaw(db, sizeof(*p)); | ||
| 163824 | if( p ){ | ||
| 163825 | int bNullRow = (pItem->fg.jointype&(JT_LEFT|JT_LTORJ))!=0; | ||
| 163826 | p->pExpr = sqlite3ExprDup(db, pRight, 0); | ||
| 163827 | p->iDataCur = pItem->iCursor; | ||
| 163828 | p->iIdxCur = iIdxCur; | ||
| 163829 | p->iIdxCol = pLeft->iColumn; | ||
| 163830 | p->bMaybeNullRow = bNullRow; | ||
| 163831 | p->pIENext = pParse->pIdxPartExpr; | ||
| 163832 | p->aff = aff; | ||
| 163833 | pParse->pIdxPartExpr = p; | ||
| 163834 | if( p->pIENext==0 ){ | ||
| 163835 | void *pArg = (void*)&pParse->pIdxPartExpr; | ||
| 163836 | sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); | ||
| 163837 | } | ||
| 163838 | } | ||
| 163839 | }else if( pLeft->iColumn<(BMS-1) ){ | ||
| 163840 | *pMask &= ~((Bitmask)1 << pLeft->iColumn); | ||
| 163841 | } | ||
| 163842 | } | ||
| 163843 | } | ||
| 163844 | } | ||
| 163845 | |||
| 163846 | |||
| 163847 | /* | ||
| 162760 | ** Add all WhereLoop objects for a single table of the join where the table | 163848 | ** Add all WhereLoop objects for a single table of the join where the table |
| 162761 | ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be | 163849 | ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be |
| 162762 | ** a b-tree table, not a virtual table. | 163850 | ** a b-tree table, not a virtual table. |
| @@ -162959,9 +164047,6 @@ static int whereLoopAddBtree( | |||
| 162959 | #else | 164047 | #else |
| 162960 | pNew->rRun = rSize + 16; | 164048 | pNew->rRun = rSize + 16; |
| 162961 | #endif | 164049 | #endif |
| 162962 | if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){ | ||
| 162963 | pNew->wsFlags |= WHERE_VIEWSCAN; | ||
| 162964 | } | ||
| 162965 | ApplyCostMultiplier(pNew->rRun, pTab->costMult); | 164050 | ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 162966 | whereLoopOutputAdjust(pWC, pNew, rSize); | 164051 | whereLoopOutputAdjust(pWC, pNew, rSize); |
| 162967 | rc = whereLoopInsert(pBuilder, pNew); | 164052 | rc = whereLoopInsert(pBuilder, pNew); |
| @@ -162974,6 +164059,11 @@ static int whereLoopAddBtree( | |||
| 162974 | pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; | 164059 | pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; |
| 162975 | }else{ | 164060 | }else{ |
| 162976 | m = pSrc->colUsed & pProbe->colNotIdxed; | 164061 | m = pSrc->colUsed & pProbe->colNotIdxed; |
| 164062 | if( pProbe->pPartIdxWhere ){ | ||
| 164063 | wherePartIdxExpr( | ||
| 164064 | pWInfo->pParse, pProbe, pProbe->pPartIdxWhere, &m, 0, 0 | ||
| 164065 | ); | ||
| 164066 | } | ||
| 162977 | pNew->wsFlags = WHERE_INDEXED; | 164067 | pNew->wsFlags = WHERE_INDEXED; |
| 162978 | if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ | 164068 | if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ |
| 162979 | u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); | 164069 | u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); |
| @@ -163356,7 +164446,7 @@ SQLITE_API int sqlite3_vtab_rhs_value( | |||
| 163356 | sqlite3_value *pVal = 0; | 164446 | sqlite3_value *pVal = 0; |
| 163357 | int rc = SQLITE_OK; | 164447 | int rc = SQLITE_OK; |
| 163358 | if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ | 164448 | if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ |
| 163359 | rc = SQLITE_MISUSE; /* EV: R-30545-25046 */ | 164449 | rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */ |
| 163360 | }else{ | 164450 | }else{ |
| 163361 | if( pH->aRhs[iCons]==0 ){ | 164451 | if( pH->aRhs[iCons]==0 ){ |
| 163362 | WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; | 164452 | WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; |
| @@ -164380,14 +165470,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ | |||
| 164380 | rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ | 165470 | rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ |
| 164381 | } | 165471 | } |
| 164382 | 165472 | ||
| 164383 | /* TUNING: A full-scan of a VIEW or subquery in the outer loop | ||
| 164384 | ** is not so bad. */ | ||
| 164385 | if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 && nLoop>1 ){ | ||
| 164386 | rCost += -10; | ||
| 164387 | nOut += -30; | ||
| 164388 | WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId)); | ||
| 164389 | } | ||
| 164390 | |||
| 164391 | /* Check to see if pWLoop should be added to the set of | 165473 | /* Check to see if pWLoop should be added to the set of |
| 164392 | ** mxChoice best-so-far paths. | 165474 | ** mxChoice best-so-far paths. |
| 164393 | ** | 165475 | ** |
| @@ -164938,20 +166020,6 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( | |||
| 164938 | } | 166020 | } |
| 164939 | 166021 | ||
| 164940 | /* | 166022 | /* |
| 164941 | ** This is an sqlite3ParserAddCleanup() callback that is invoked to | ||
| 164942 | ** free the Parse->pIdxEpr list when the Parse object is destroyed. | ||
| 164943 | */ | ||
| 164944 | static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){ | ||
| 164945 | Parse *pParse = (Parse*)pObject; | ||
| 164946 | while( pParse->pIdxEpr!=0 ){ | ||
| 164947 | IndexedExpr *p = pParse->pIdxEpr; | ||
| 164948 | pParse->pIdxEpr = p->pIENext; | ||
| 164949 | sqlite3ExprDelete(db, p->pExpr); | ||
| 164950 | sqlite3DbFreeNN(db, p); | ||
| 164951 | } | ||
| 164952 | } | ||
| 164953 | |||
| 164954 | /* | ||
| 164955 | ** The index pIdx is used by a query and contains one or more expressions. | 166023 | ** The index pIdx is used by a query and contains one or more expressions. |
| 164956 | ** In other words pIdx is an index on an expression. iIdxCur is the cursor | 166024 | ** In other words pIdx is an index on an expression. iIdxCur is the cursor |
| 164957 | ** number for the index and iDataCur is the cursor number for the corresponding | 166025 | ** number for the index and iDataCur is the cursor number for the corresponding |
| @@ -165012,7 +166080,8 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( | |||
| 165012 | #endif | 166080 | #endif |
| 165013 | pParse->pIdxEpr = p; | 166081 | pParse->pIdxEpr = p; |
| 165014 | if( p->pIENext==0 ){ | 166082 | if( p->pIENext==0 ){ |
| 165015 | sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse); | 166083 | void *pArg = (void*)&pParse->pIdxEpr; |
| 166084 | sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); | ||
| 165016 | } | 166085 | } |
| 165017 | } | 166086 | } |
| 165018 | } | 166087 | } |
| @@ -165402,6 +166471,16 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 165402 | wherePathSolver(pWInfo, pWInfo->nRowOut+1); | 166471 | wherePathSolver(pWInfo, pWInfo->nRowOut+1); |
| 165403 | if( db->mallocFailed ) goto whereBeginError; | 166472 | if( db->mallocFailed ) goto whereBeginError; |
| 165404 | } | 166473 | } |
| 166474 | |||
| 166475 | /* TUNING: Assume that a DISTINCT clause on a subquery reduces | ||
| 166476 | ** the output size by a factor of 8 (LogEst -30). | ||
| 166477 | */ | ||
| 166478 | if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 ){ | ||
| 166479 | WHERETRACE(0x0080,("nRowOut reduced from %d to %d due to DISTINCT\n", | ||
| 166480 | pWInfo->nRowOut, pWInfo->nRowOut-30)); | ||
| 166481 | pWInfo->nRowOut -= 30; | ||
| 166482 | } | ||
| 166483 | |||
| 165405 | } | 166484 | } |
| 165406 | assert( pWInfo->pTabList!=0 ); | 166485 | assert( pWInfo->pTabList!=0 ); |
| 165407 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ | 166486 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ |
| @@ -165614,6 +166693,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 165614 | if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ | 166693 | if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ |
| 165615 | whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); | 166694 | whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); |
| 165616 | } | 166695 | } |
| 166696 | if( pIx->pPartIdxWhere && (pTabItem->fg.jointype & JT_RIGHT)==0 ){ | ||
| 166697 | wherePartIdxExpr( | ||
| 166698 | pParse, pIx, pIx->pPartIdxWhere, 0, iIndexCur, pTabItem | ||
| 166699 | ); | ||
| 166700 | } | ||
| 165617 | } | 166701 | } |
| 165618 | pLevel->iIdxCur = iIndexCur; | 166702 | pLevel->iIdxCur = iIndexCur; |
| 165619 | assert( pIx!=0 ); | 166703 | assert( pIx!=0 ); |
| @@ -167430,8 +168514,9 @@ SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ | |||
| 167430 | if( p ){ | 168514 | if( p ){ |
| 167431 | assert( p->op==TK_FUNCTION ); | 168515 | assert( p->op==TK_FUNCTION ); |
| 167432 | assert( pWin ); | 168516 | assert( pWin ); |
| 168517 | assert( ExprIsFullSize(p) ); | ||
| 167433 | p->y.pWin = pWin; | 168518 | p->y.pWin = pWin; |
| 167434 | ExprSetProperty(p, EP_WinFunc); | 168519 | ExprSetProperty(p, EP_WinFunc|EP_FullSize); |
| 167435 | pWin->pOwner = p; | 168520 | pWin->pOwner = p; |
| 167436 | if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ | 168521 | if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ |
| 167437 | sqlite3ErrorMsg(pParse, | 168522 | sqlite3ErrorMsg(pParse, |
| @@ -169733,18 +170818,18 @@ typedef union { | |||
| 169733 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; | 170818 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 169734 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; | 170819 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 169735 | #define YYFALLBACK 1 | 170820 | #define YYFALLBACK 1 |
| 169736 | #define YYNSTATE 575 | 170821 | #define YYNSTATE 579 |
| 169737 | #define YYNRULE 403 | 170822 | #define YYNRULE 405 |
| 169738 | #define YYNRULE_WITH_ACTION 338 | 170823 | #define YYNRULE_WITH_ACTION 340 |
| 169739 | #define YYNTOKEN 185 | 170824 | #define YYNTOKEN 185 |
| 169740 | #define YY_MAX_SHIFT 574 | 170825 | #define YY_MAX_SHIFT 578 |
| 169741 | #define YY_MIN_SHIFTREDUCE 833 | 170826 | #define YY_MIN_SHIFTREDUCE 838 |
| 169742 | #define YY_MAX_SHIFTREDUCE 1235 | 170827 | #define YY_MAX_SHIFTREDUCE 1242 |
| 169743 | #define YY_ERROR_ACTION 1236 | 170828 | #define YY_ERROR_ACTION 1243 |
| 169744 | #define YY_ACCEPT_ACTION 1237 | 170829 | #define YY_ACCEPT_ACTION 1244 |
| 169745 | #define YY_NO_ACTION 1238 | 170830 | #define YY_NO_ACTION 1245 |
| 169746 | #define YY_MIN_REDUCE 1239 | 170831 | #define YY_MIN_REDUCE 1246 |
| 169747 | #define YY_MAX_REDUCE 1641 | 170832 | #define YY_MAX_REDUCE 1650 |
| 169748 | /************* End control #defines *******************************************/ | 170833 | /************* End control #defines *******************************************/ |
| 169749 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) | 170834 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 169750 | 170835 | ||
| @@ -169811,218 +170896,218 @@ typedef union { | |||
| 169811 | ** yy_default[] Default action for each state. | 170896 | ** yy_default[] Default action for each state. |
| 169812 | ** | 170897 | ** |
| 169813 | *********** Begin parsing tables **********************************************/ | 170898 | *********** Begin parsing tables **********************************************/ |
| 169814 | #define YY_ACTTAB_COUNT (2096) | 170899 | #define YY_ACTTAB_COUNT (2100) |
| 169815 | static const YYACTIONTYPE yy_action[] = { | 170900 | static const YYACTIONTYPE yy_action[] = { |
| 169816 | /* 0 */ 568, 208, 568, 118, 115, 229, 568, 118, 115, 229, | 170901 | /* 0 */ 572, 210, 572, 119, 116, 231, 572, 119, 116, 231, |
| 169817 | /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, | 170902 | /* 10 */ 572, 1317, 379, 1296, 410, 566, 566, 566, 572, 411, |
| 169818 | /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, | 170903 | /* 20 */ 380, 1317, 1279, 42, 42, 42, 42, 210, 1529, 72, |
| 169819 | /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, | 170904 | /* 30 */ 72, 974, 421, 42, 42, 495, 305, 281, 305, 975, |
| 169820 | /* 40 */ 397, 71, 71, 125, 126, 80, 1210, 1210, 1047, 1050, | 170905 | /* 40 */ 399, 72, 72, 126, 127, 81, 1217, 1217, 1054, 1057, |
| 169821 | /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, | 170906 | /* 50 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 480, 411, |
| 169822 | /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, | 170907 | /* 60 */ 1244, 1, 1, 578, 2, 1248, 554, 119, 116, 231, |
| 169823 | /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, | 170908 | /* 70 */ 319, 484, 147, 484, 528, 119, 116, 231, 533, 1330, |
| 169824 | /* 80 */ 417, 523, 142, 125, 126, 80, 1210, 1210, 1047, 1050, | 170909 | /* 80 */ 419, 527, 143, 126, 127, 81, 1217, 1217, 1054, 1057, |
| 169825 | /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, | 170910 | /* 90 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 119, 116, |
| 169826 | /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, | 170911 | /* 100 */ 231, 329, 123, 123, 123, 123, 122, 122, 121, 121, |
| 169827 | /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, | 170912 | /* 110 */ 121, 120, 117, 448, 286, 286, 286, 286, 446, 446, |
| 169828 | /* 120 */ 442, 1559, 376, 1561, 1186, 375, 1157, 565, 1157, 565, | 170913 | /* 120 */ 446, 1568, 378, 1570, 1193, 377, 1164, 569, 1164, 569, |
| 169829 | /* 130 */ 409, 1559, 537, 259, 226, 444, 101, 145, 449, 316, | 170914 | /* 130 */ 411, 1568, 541, 261, 228, 448, 102, 146, 453, 318, |
| 169830 | /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, | 170915 | /* 140 */ 563, 242, 123, 123, 123, 123, 122, 122, 121, 121, |
| 169831 | /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1210, 1210, 1047, | 170916 | /* 150 */ 121, 120, 117, 448, 126, 127, 81, 1217, 1217, 1054, |
| 169832 | /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, | 170917 | /* 160 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 143, |
| 169833 | /* 170 */ 294, 1186, 339, 448, 120, 120, 120, 119, 116, 444, | 170918 | /* 170 */ 296, 1193, 341, 452, 121, 121, 121, 120, 117, 448, |
| 169834 | /* 180 */ 127, 1186, 1187, 1186, 148, 441, 440, 568, 119, 116, | 170919 | /* 180 */ 128, 1193, 1194, 1193, 149, 445, 444, 572, 120, 117, |
| 169835 | /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, | 170920 | /* 190 */ 448, 125, 125, 125, 125, 118, 123, 123, 123, 123, |
| 169836 | /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, | 170921 | /* 200 */ 122, 122, 121, 121, 121, 120, 117, 448, 458, 114, |
| 169837 | /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, | 170922 | /* 210 */ 13, 13, 550, 123, 123, 123, 123, 122, 122, 121, |
| 169838 | /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1186, 1187, | 170923 | /* 220 */ 121, 121, 120, 117, 448, 424, 318, 563, 1193, 1194, |
| 169839 | /* 230 */ 1186, 149, 1218, 409, 1218, 124, 124, 124, 124, 122, | 170924 | /* 230 */ 1193, 150, 1225, 411, 1225, 125, 125, 125, 125, 123, |
| 169840 | /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, | 170925 | /* 240 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, |
| 169841 | /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, | 170926 | /* 250 */ 448, 469, 344, 1041, 1041, 1055, 1058, 126, 127, 81, |
| 169842 | /* 260 */ 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, | 170927 | /* 260 */ 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, |
| 169843 | /* 270 */ 124, 124, 1275, 522, 222, 1186, 568, 409, 224, 514, | 170928 | /* 270 */ 125, 125, 1282, 526, 224, 1193, 572, 411, 226, 519, |
| 169844 | /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, | 170929 | /* 280 */ 177, 83, 84, 123, 123, 123, 123, 122, 122, 121, |
| 169845 | /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1186, 133, | 170930 | /* 290 */ 121, 121, 120, 117, 448, 1010, 16, 16, 1193, 134, |
| 169846 | /* 300 */ 133, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, | 170931 | /* 300 */ 134, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, |
| 169847 | /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, | 170932 | /* 310 */ 124, 124, 125, 125, 125, 125, 123, 123, 123, 123, |
| 169848 | /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, | 170933 | /* 320 */ 122, 122, 121, 121, 121, 120, 117, 448, 1045, 550, |
| 169849 | /* 330 */ 1186, 373, 1186, 1187, 1186, 252, 1429, 399, 504, 501, | 170934 | /* 330 */ 1193, 375, 1193, 1194, 1193, 254, 1438, 401, 508, 505, |
| 169850 | /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, | 170935 | /* 340 */ 504, 112, 564, 570, 4, 929, 929, 435, 503, 342, |
| 169851 | /* 350 */ 460, 328, 360, 394, 1231, 1186, 1187, 1186, 563, 568, | 170936 | /* 350 */ 464, 330, 362, 396, 1238, 1193, 1194, 1193, 567, 572, |
| 169852 | /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, | 170937 | /* 360 */ 123, 123, 123, 123, 122, 122, 121, 121, 121, 120, |
| 169853 | /* 370 */ 116, 444, 284, 284, 369, 1572, 1598, 441, 440, 154, | 170938 | /* 370 */ 117, 448, 286, 286, 371, 1581, 1607, 445, 444, 155, |
| 169854 | /* 380 */ 409, 445, 71, 71, 1282, 565, 1215, 1186, 1187, 1186, | 170939 | /* 380 */ 411, 449, 72, 72, 1289, 569, 1222, 1193, 1194, 1193, |
| 169855 | /* 390 */ 85, 1217, 271, 557, 543, 515, 515, 568, 98, 1216, | 170940 | /* 390 */ 86, 1224, 273, 561, 547, 520, 520, 572, 99, 1223, |
| 169856 | /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1210, 1210, 1047, | 170941 | /* 400 */ 6, 1281, 476, 143, 126, 127, 81, 1217, 1217, 1054, |
| 169857 | /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, | 170942 | /* 410 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 554, |
| 169858 | /* 420 */ 13, 13, 1024, 507, 1218, 1186, 1218, 549, 109, 109, | 170943 | /* 420 */ 13, 13, 1031, 511, 1225, 1193, 1225, 553, 110, 110, |
| 169859 | /* 430 */ 222, 568, 1232, 175, 568, 427, 110, 197, 445, 569, | 170944 | /* 430 */ 224, 572, 1239, 177, 572, 429, 111, 199, 449, 573, |
| 169860 | /* 440 */ 445, 430, 1546, 1014, 325, 551, 1186, 270, 287, 368, | 170945 | /* 440 */ 449, 432, 1555, 1019, 327, 555, 1193, 272, 289, 370, |
| 169861 | /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, | 170946 | /* 450 */ 514, 365, 513, 259, 72, 72, 547, 72, 72, 361, |
| 169862 | /* 460 */ 316, 559, 1604, 122, 122, 122, 122, 121, 121, 120, | 170947 | /* 460 */ 318, 563, 1613, 123, 123, 123, 123, 122, 122, 121, |
| 169863 | /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, | 170948 | /* 470 */ 121, 121, 120, 117, 448, 1019, 1019, 1021, 1022, 28, |
| 169864 | /* 480 */ 284, 284, 1186, 1187, 1186, 1152, 568, 1603, 409, 899, | 170949 | /* 480 */ 286, 286, 1193, 1194, 1193, 1159, 572, 1612, 411, 904, |
| 169865 | /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1152, 516, | 170950 | /* 490 */ 192, 554, 358, 569, 554, 940, 537, 521, 1159, 437, |
| 169866 | /* 500 */ 413, 1152, 552, 1186, 1187, 1186, 568, 544, 544, 51, | 170951 | /* 500 */ 415, 1159, 556, 1193, 1194, 1193, 572, 548, 548, 52, |
| 169867 | /* 510 */ 51, 214, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, | 170952 | /* 510 */ 52, 216, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, |
| 169868 | /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1186, 474, 135, | 170953 | /* 520 */ 1044, 124, 124, 125, 125, 125, 125, 1193, 478, 136, |
| 169869 | /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, | 170954 | /* 530 */ 136, 411, 286, 286, 1493, 509, 122, 122, 121, 121, |
| 169870 | /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 541, | 170955 | /* 540 */ 121, 120, 117, 448, 1010, 569, 522, 219, 545, 545, |
| 169871 | /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1210, 1210, | 170956 | /* 550 */ 318, 563, 143, 6, 536, 126, 127, 81, 1217, 1217, |
| 169872 | /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | 170957 | /* 560 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 169873 | /* 570 */ 1548, 122, 122, 122, 122, 121, 121, 120, 120, 120, | 170958 | /* 570 */ 1557, 123, 123, 123, 123, 122, 122, 121, 121, 121, |
| 169874 | /* 580 */ 119, 116, 444, 485, 1186, 1187, 1186, 482, 281, 1263, | 170959 | /* 580 */ 120, 117, 448, 489, 1193, 1194, 1193, 486, 283, 1270, |
| 169875 | /* 590 */ 955, 252, 1186, 373, 504, 501, 500, 1186, 340, 570, | 170960 | /* 590 */ 960, 254, 1193, 375, 508, 505, 504, 1193, 342, 574, |
| 169876 | /* 600 */ 1186, 570, 409, 292, 499, 955, 874, 191, 480, 316, | 170961 | /* 600 */ 1193, 574, 411, 294, 503, 960, 879, 193, 484, 318, |
| 169877 | /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, | 170962 | /* 610 */ 563, 386, 292, 382, 123, 123, 123, 123, 122, 122, |
| 169878 | /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | 170963 | /* 620 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 169879 | /* 630 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 170964 | /* 630 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169880 | /* 640 */ 124, 409, 394, 1132, 1186, 867, 100, 284, 284, 1186, | 170965 | /* 640 */ 125, 411, 396, 1139, 1193, 872, 101, 286, 286, 1193, |
| 169881 | /* 650 */ 1187, 1186, 373, 1089, 1186, 1187, 1186, 1186, 1187, 1186, | 170966 | /* 650 */ 1194, 1193, 375, 1096, 1193, 1194, 1193, 1193, 1194, 1193, |
| 169882 | /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1210, 1210, | 170967 | /* 660 */ 569, 459, 33, 375, 235, 126, 127, 81, 1217, 1217, |
| 169883 | /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | 170968 | /* 670 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 169884 | /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, | 170969 | /* 680 */ 1437, 962, 572, 230, 961, 123, 123, 123, 123, 122, |
| 169885 | /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1152, 228, 1186, | 170970 | /* 690 */ 122, 121, 121, 121, 120, 117, 448, 1159, 230, 1193, |
| 169886 | /* 700 */ 157, 1186, 1187, 1186, 1547, 13, 13, 301, 955, 1226, | 170971 | /* 700 */ 158, 1193, 1194, 1193, 1556, 13, 13, 303, 960, 1233, |
| 169887 | /* 710 */ 1152, 153, 409, 1152, 373, 1575, 1170, 5, 369, 1572, | 170972 | /* 710 */ 1159, 154, 411, 1159, 375, 1584, 1177, 5, 371, 1581, |
| 169888 | /* 720 */ 429, 1232, 3, 955, 122, 122, 122, 122, 121, 121, | 170973 | /* 720 */ 431, 1239, 3, 960, 123, 123, 123, 123, 122, 122, |
| 169889 | /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | 170974 | /* 730 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 169890 | /* 740 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 170975 | /* 740 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169891 | /* 750 */ 124, 409, 208, 567, 1186, 1025, 1186, 1187, 1186, 1186, | 170976 | /* 750 */ 125, 411, 210, 571, 1193, 1032, 1193, 1194, 1193, 1193, |
| 169892 | /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, | 170977 | /* 760 */ 390, 855, 156, 1555, 376, 404, 1101, 1101, 492, 572, |
| 169893 | /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1210, 1210, | 170978 | /* 770 */ 469, 344, 1322, 1322, 1555, 126, 127, 81, 1217, 1217, |
| 169894 | /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | 170979 | /* 780 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 169895 | /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, | 170980 | /* 790 */ 130, 572, 13, 13, 532, 123, 123, 123, 123, 122, |
| 169896 | /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, | 170981 | /* 800 */ 122, 121, 121, 121, 120, 117, 448, 304, 572, 457, |
| 169897 | /* 810 */ 528, 1186, 1187, 1186, 13, 13, 1186, 1187, 1186, 1293, | 170982 | /* 810 */ 229, 1193, 1194, 1193, 13, 13, 1193, 1194, 1193, 1300, |
| 169898 | /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, | 170983 | /* 820 */ 467, 1270, 411, 1320, 1320, 1555, 1015, 457, 456, 436, |
| 169899 | /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, | 170984 | /* 830 */ 301, 72, 72, 1268, 123, 123, 123, 123, 122, 122, |
| 169900 | /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | 170985 | /* 840 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 169901 | /* 850 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 170986 | /* 850 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169902 | /* 860 */ 124, 409, 227, 1069, 1152, 284, 284, 419, 312, 278, | 170987 | /* 860 */ 125, 411, 384, 1076, 1159, 286, 286, 421, 314, 280, |
| 169903 | /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1152, 565, 568, | 170988 | /* 870 */ 280, 287, 287, 461, 408, 407, 1539, 1159, 569, 572, |
| 169904 | /* 880 */ 1152, 1189, 565, 1592, 565, 125, 126, 80, 1210, 1210, | 170989 | /* 880 */ 1159, 1196, 569, 409, 569, 126, 127, 81, 1217, 1217, |
| 169905 | /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | 170990 | /* 890 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 169906 | /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, | 170991 | /* 900 */ 457, 1485, 13, 13, 1541, 123, 123, 123, 123, 122, |
| 169907 | /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, | 170992 | /* 910 */ 122, 121, 121, 121, 120, 117, 448, 202, 572, 462, |
| 169908 | /* 920 */ 1578, 574, 2, 1241, 838, 839, 840, 1554, 317, 1205, | 170993 | /* 920 */ 1587, 578, 2, 1248, 843, 844, 845, 1563, 319, 409, |
| 169909 | /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1189, | 170994 | /* 930 */ 147, 6, 411, 257, 256, 255, 208, 1330, 9, 1196, |
| 169910 | /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, | 170995 | /* 940 */ 264, 72, 72, 1436, 123, 123, 123, 123, 122, 122, |
| 169911 | /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | 170996 | /* 950 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 169912 | /* 960 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 170997 | /* 960 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169913 | /* 970 */ 124, 568, 284, 284, 568, 1206, 409, 573, 313, 1241, | 170998 | /* 970 */ 125, 572, 286, 286, 572, 1213, 411, 577, 315, 1248, |
| 169914 | /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1635, | 170999 | /* 980 */ 421, 371, 1581, 356, 319, 569, 147, 495, 529, 1644, |
| 169915 | /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, | 171000 | /* 990 */ 397, 935, 495, 1330, 71, 71, 934, 72, 72, 242, |
| 169916 | /* 1000 */ 1321, 104, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, | 171001 | /* 1000 */ 1328, 105, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, |
| 169917 | /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, | 171002 | /* 1010 */ 124, 125, 125, 125, 125, 123, 123, 123, 123, 122, |
| 169918 | /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, | 171003 | /* 1020 */ 122, 121, 121, 121, 120, 117, 448, 1117, 286, 286, |
| 169919 | /* 1030 */ 428, 448, 1519, 1206, 439, 284, 284, 1483, 1348, 311, | 171004 | /* 1030 */ 1422, 452, 1528, 1213, 443, 286, 286, 1492, 1355, 313, |
| 169920 | /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, | 171005 | /* 1040 */ 478, 569, 1118, 454, 351, 495, 354, 1266, 569, 209, |
| 169921 | /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, | 171006 | /* 1050 */ 572, 418, 179, 572, 1031, 242, 385, 1119, 523, 123, |
| 169922 | /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, | 171007 | /* 1060 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, |
| 169923 | /* 1070 */ 444, 1015, 107, 71, 71, 1014, 13, 13, 910, 568, | 171008 | /* 1070 */ 448, 1020, 108, 72, 72, 1019, 13, 13, 915, 572, |
| 169924 | /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, | 171009 | /* 1080 */ 1498, 572, 286, 286, 98, 530, 1537, 452, 916, 1334, |
| 169925 | /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, | 171010 | /* 1090 */ 1329, 203, 411, 286, 286, 569, 152, 211, 1498, 1500, |
| 169926 | /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, | 171011 | /* 1100 */ 426, 569, 56, 56, 57, 57, 569, 1019, 1019, 1021, |
| 169927 | /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1210, | 171012 | /* 1110 */ 447, 572, 411, 531, 12, 297, 126, 127, 81, 1217, |
| 169928 | /* 1120 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 171013 | /* 1120 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169929 | /* 1130 */ 124, 347, 409, 862, 1528, 1206, 125, 126, 80, 1210, | 171014 | /* 1130 */ 125, 572, 411, 867, 15, 15, 126, 127, 81, 1217, |
| 169930 | /* 1140 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 171015 | /* 1140 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169931 | /* 1150 */ 124, 1133, 1633, 474, 1633, 371, 125, 114, 80, 1210, | 171016 | /* 1150 */ 125, 373, 529, 264, 44, 44, 126, 115, 81, 1217, |
| 169932 | /* 1160 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | 171017 | /* 1160 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 169933 | /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, | 171018 | /* 1170 */ 125, 1498, 478, 1271, 417, 123, 123, 123, 123, 122, |
| 169934 | /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, | 171019 | /* 1180 */ 122, 121, 121, 121, 120, 117, 448, 205, 1213, 495, |
| 169935 | /* 1190 */ 1290, 862, 464, 1206, 436, 122, 122, 122, 122, 121, | 171020 | /* 1190 */ 430, 867, 468, 322, 495, 123, 123, 123, 123, 122, |
| 169936 | /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1634, | 171021 | /* 1200 */ 122, 121, 121, 121, 120, 117, 448, 572, 557, 1140, |
| 169937 | /* 1210 */ 539, 1634, 15, 15, 890, 122, 122, 122, 122, 121, | 171022 | /* 1210 */ 1642, 1422, 1642, 543, 572, 123, 123, 123, 123, 122, |
| 169938 | /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, | 171023 | /* 1220 */ 122, 121, 121, 121, 120, 117, 448, 572, 1422, 572, |
| 169939 | /* 1230 */ 1131, 1415, 1552, 1553, 1327, 409, 6, 6, 1163, 1264, | 171024 | /* 1230 */ 13, 13, 542, 323, 1325, 411, 334, 58, 58, 349, |
| 169940 | /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, | 171025 | /* 1240 */ 1422, 1170, 326, 286, 286, 549, 1213, 300, 895, 530, |
| 169941 | /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, | 171026 | /* 1250 */ 45, 45, 59, 59, 1140, 1643, 569, 1643, 565, 417, |
| 169942 | /* 1260 */ 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, | 171027 | /* 1260 */ 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, |
| 169943 | /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1186, 1415, | 171028 | /* 1270 */ 125, 125, 125, 125, 1367, 373, 500, 290, 1193, 512, |
| 169944 | /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1551, 847, | 171029 | /* 1280 */ 1366, 427, 394, 394, 393, 275, 391, 896, 1138, 852, |
| 169945 | /* 1290 */ 1163, 407, 6, 568, 321, 1152, 470, 44, 44, 1550, | 171030 | /* 1290 */ 478, 258, 1422, 1170, 463, 1159, 12, 331, 428, 333, |
| 169946 | /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1152, 431, | 171031 | /* 1300 */ 1117, 460, 236, 258, 325, 460, 544, 1544, 1159, 1098, |
| 169947 | /* 1310 */ 568, 1152, 322, 17, 487, 1111, 58, 58, 122, 122, | 171032 | /* 1310 */ 491, 1159, 324, 1098, 440, 1118, 335, 516, 123, 123, |
| 169948 | /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, | 171033 | /* 1320 */ 123, 123, 122, 122, 121, 121, 121, 120, 117, 448, |
| 169949 | /* 1330 */ 1112, 216, 481, 59, 59, 1186, 1187, 1186, 111, 560, | 171034 | /* 1330 */ 1119, 318, 563, 1138, 572, 1193, 1194, 1193, 112, 564, |
| 169950 | /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, | 171035 | /* 1340 */ 201, 4, 238, 433, 935, 490, 285, 228, 1517, 934, |
| 169951 | /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, | 171036 | /* 1350 */ 170, 560, 572, 142, 1516, 567, 572, 60, 60, 572, |
| 169952 | /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, | 171037 | /* 1360 */ 416, 572, 441, 572, 535, 302, 875, 8, 487, 572, |
| 169953 | /* 1370 */ 235, 61, 61, 568, 414, 568, 414, 568, 445, 62, | 171038 | /* 1370 */ 237, 572, 416, 572, 485, 61, 61, 572, 449, 62, |
| 169954 | /* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49, | 171039 | /* 1380 */ 62, 332, 63, 63, 46, 46, 47, 47, 361, 572, |
| 169955 | /* 1390 */ 557, 568, 359, 568, 100, 486, 50, 50, 63, 63, | 171040 | /* 1390 */ 561, 572, 48, 48, 50, 50, 51, 51, 572, 295, |
| 169956 | /* 1400 */ 64, 64, 561, 415, 535, 410, 568, 1024, 568, 534, | 171041 | /* 1400 */ 64, 64, 482, 295, 539, 412, 471, 1031, 572, 538, |
| 169957 | /* 1410 */ 316, 559, 316, 559, 65, 65, 14, 14, 568, 1024, | 171042 | /* 1410 */ 318, 563, 65, 65, 66, 66, 409, 475, 572, 1031, |
| 169958 | /* 1420 */ 568, 512, 930, 870, 1015, 109, 109, 929, 1014, 66, | 171043 | /* 1420 */ 572, 14, 14, 875, 1020, 110, 110, 409, 1019, 572, |
| 169959 | /* 1430 */ 66, 131, 131, 110, 451, 445, 569, 445, 416, 177, | 171044 | /* 1430 */ 474, 67, 67, 111, 455, 449, 573, 449, 98, 317, |
| 169960 | /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, | 171045 | /* 1440 */ 1019, 132, 132, 133, 133, 572, 1561, 572, 974, 409, |
| 169961 | /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, | 171046 | /* 1450 */ 6, 1562, 68, 68, 1560, 6, 975, 572, 6, 1559, |
| 169962 | /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, | 171047 | /* 1460 */ 1019, 1019, 1021, 6, 346, 218, 101, 531, 53, 53, |
| 169963 | /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1577, 1174, 447, | 171048 | /* 1470 */ 69, 69, 1019, 1019, 1021, 1022, 28, 1586, 1181, 451, |
| 169964 | /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, | 171049 | /* 1480 */ 70, 70, 290, 87, 215, 31, 1363, 394, 394, 393, |
| 169965 | /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, | 171050 | /* 1490 */ 275, 391, 350, 109, 852, 107, 572, 112, 564, 483, |
| 169966 | /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, | 171051 | /* 1500 */ 4, 1212, 572, 239, 153, 572, 39, 236, 1299, 325, |
| 169967 | /* 1510 */ 111, 560, 527, 4, 563, 53, 53, 322, 568, 163, | 171052 | /* 1510 */ 112, 564, 1298, 4, 567, 572, 32, 324, 572, 54, |
| 169968 | /* 1520 */ 163, 568, 337, 468, 164, 164, 333, 563, 76, 76, | 171053 | /* 1520 */ 54, 572, 1135, 353, 398, 165, 165, 567, 166, 166, |
| 169969 | /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, | 171054 | /* 1530 */ 572, 291, 355, 572, 17, 357, 572, 449, 77, 77, |
| 169970 | /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, | 171055 | /* 1540 */ 1313, 55, 55, 1297, 73, 73, 572, 238, 470, 561, |
| 169971 | /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, | 171056 | /* 1550 */ 449, 472, 364, 135, 135, 170, 74, 74, 142, 163, |
| 169972 | /* 1560 */ 161, 1566, 557, 535, 568, 319, 568, 348, 536, 1007, | 171057 | /* 1560 */ 163, 374, 561, 539, 572, 321, 572, 886, 540, 137, |
| 169973 | /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, | 171058 | /* 1570 */ 137, 339, 1353, 422, 298, 237, 539, 572, 1031, 572, |
| 169974 | /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, | 171059 | /* 1580 */ 340, 538, 101, 369, 110, 110, 162, 131, 131, 164, |
| 169975 | /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, | 171060 | /* 1590 */ 164, 1031, 111, 368, 449, 573, 449, 110, 110, 1019, |
| 169976 | /* 1600 */ 162, 162, 156, 156, 568, 110, 1076, 445, 569, 445, | 171061 | /* 1600 */ 157, 157, 141, 141, 572, 111, 572, 449, 573, 449, |
| 169977 | /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, | 171062 | /* 1610 */ 412, 288, 1019, 572, 882, 318, 563, 572, 219, 572, |
| 169978 | /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, | 171063 | /* 1620 */ 241, 1012, 477, 263, 263, 894, 893, 140, 140, 138, |
| 169979 | /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, | 171064 | /* 1630 */ 138, 1019, 1019, 1021, 1022, 28, 139, 139, 525, 455, |
| 169980 | /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1174, | 171065 | /* 1640 */ 76, 76, 78, 78, 1019, 1019, 1021, 1022, 28, 1181, |
| 169981 | /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, | 171066 | /* 1650 */ 451, 572, 1083, 290, 112, 564, 1575, 4, 394, 394, |
| 169982 | /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, | 171067 | /* 1660 */ 393, 275, 391, 572, 1023, 852, 572, 479, 345, 263, |
| 169983 | /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, | 171068 | /* 1670 */ 101, 567, 882, 1376, 75, 75, 1421, 501, 236, 260, |
| 169984 | /* 1680 */ 323, 111, 560, 927, 4, 113, 77, 77, 322, 74, | 171069 | /* 1680 */ 325, 112, 564, 359, 4, 101, 43, 43, 324, 49, |
| 169985 | /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, | 171070 | /* 1690 */ 49, 901, 902, 161, 449, 101, 977, 978, 567, 1079, |
| 169986 | /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, | 171071 | /* 1700 */ 1349, 260, 965, 932, 263, 114, 561, 1095, 517, 1095, |
| 169987 | /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, | 171072 | /* 1710 */ 1083, 1094, 865, 1094, 151, 933, 1144, 114, 238, 1361, |
| 169988 | /* 1720 */ 1251, 445, 1585, 1339, 308, 276, 168, 309, 11, 141, | 171073 | /* 1720 */ 558, 449, 1023, 559, 1426, 1278, 170, 1269, 1257, 142, |
| 169989 | /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, | 171074 | /* 1730 */ 1601, 1256, 1258, 561, 1594, 1031, 496, 278, 213, 1346, |
| 169990 | /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, | 171075 | /* 1740 */ 310, 110, 110, 939, 311, 312, 237, 11, 234, 111, |
| 169991 | /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, | 171076 | /* 1750 */ 221, 449, 573, 449, 293, 395, 1019, 1408, 337, 1403, |
| 169992 | /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, | 171077 | /* 1760 */ 1396, 338, 1031, 299, 343, 1413, 1412, 481, 110, 110, |
| 169993 | /* 1770 */ 204, 1588, 1226, 558, 265, 218, 110, 205, 445, 569, | 171078 | /* 1770 */ 506, 402, 225, 1296, 206, 367, 111, 1358, 449, 573, |
| 169994 | /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, | 171079 | /* 1780 */ 449, 412, 1359, 1019, 1489, 1488, 318, 563, 1019, 1019, |
| 169995 | /* 1790 */ 1016, 1017, 27, 230, 1525, 1223, 79, 560, 85, 4, | 171080 | /* 1790 */ 1021, 1022, 28, 562, 207, 220, 80, 564, 389, 4, |
| 169996 | /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, | 171081 | /* 1800 */ 1597, 1357, 552, 1356, 1233, 181, 267, 232, 1536, 1534, |
| 169997 | /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, | 171082 | /* 1810 */ 455, 1230, 420, 567, 82, 1019, 1019, 1021, 1022, 28, |
| 169998 | /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, | 171083 | /* 1820 */ 86, 217, 85, 1494, 190, 175, 183, 465, 185, 466, |
| 169999 | /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, | 171084 | /* 1830 */ 36, 1409, 186, 187, 188, 499, 449, 244, 37, 99, |
| 170000 | /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, | 171085 | /* 1840 */ 400, 1415, 1414, 488, 1417, 194, 473, 403, 561, 1483, |
| 170001 | /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, | 171086 | /* 1850 */ 248, 92, 1505, 494, 198, 279, 112, 564, 250, 4, |
| 170002 | /* 1860 */ 1307, 1300, 93, 1602, 881, 1601, 224, 404, 434, 520, | 171087 | /* 1860 */ 348, 497, 405, 352, 1259, 251, 252, 515, 1316, 434, |
| 170003 | /* 1870 */ 263, 435, 1571, 563, 1279, 1278, 364, 1024, 306, 1277, | 171088 | /* 1870 */ 1315, 1314, 94, 567, 1307, 886, 1306, 1031, 226, 406, |
| 170004 | /* 1880 */ 264, 1600, 1557, 109, 109, 370, 1299, 307, 1556, 438, | 171089 | /* 1880 */ 1611, 1610, 438, 110, 110, 1580, 1286, 524, 439, 308, |
| 170005 | /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, | 171090 | /* 1890 */ 266, 111, 1285, 449, 573, 449, 449, 309, 1019, 366, |
| 170006 | /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, | 171091 | /* 1900 */ 1284, 1609, 265, 1566, 1565, 442, 372, 1381, 561, 129, |
| 170007 | /* 1910 */ 1180, 530, 272, 274, 379, 210, 1331, 547, 385, 386, | 171092 | /* 1910 */ 550, 1380, 10, 1470, 383, 106, 316, 551, 100, 35, |
| 170008 | /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, | 171093 | /* 1920 */ 534, 575, 212, 1339, 381, 387, 1187, 1338, 274, 276, |
| 170009 | /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, | 171094 | /* 1930 */ 1019, 1019, 1021, 1022, 28, 277, 413, 1031, 576, 1254, |
| 170010 | /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, | 171095 | /* 1940 */ 388, 1521, 1249, 110, 110, 167, 1522, 168, 148, 1520, |
| 170011 | /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, | 171096 | /* 1950 */ 1519, 111, 306, 449, 573, 449, 222, 223, 1019, 839, |
| 170012 | /* 1960 */ 326, 180, 169, 1205, 182, 334, 238, 913, 241, 1100, | 171097 | /* 1960 */ 169, 79, 450, 214, 414, 233, 320, 145, 1093, 1091, |
| 170013 | /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, | 171098 | /* 1970 */ 328, 182, 171, 1212, 918, 184, 240, 336, 243, 1107, |
| 170014 | /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, | 171099 | /* 1980 */ 189, 172, 173, 423, 425, 88, 180, 191, 89, 90, |
| 170015 | /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1220, 489, | 171100 | /* 1990 */ 1019, 1019, 1021, 1022, 28, 91, 174, 1110, 245, 1106, |
| 170016 | /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, | 171101 | /* 2000 */ 246, 159, 18, 247, 347, 1099, 263, 195, 1227, 493, |
| 170017 | /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, | 171102 | /* 2010 */ 249, 196, 38, 854, 498, 368, 253, 360, 897, 197, |
| 170018 | /* 2020 */ 513, 39, 95, 1168, 160, 1053, 964, 1139, 96, 174, | 171103 | /* 2020 */ 502, 93, 19, 20, 507, 884, 363, 510, 95, 307, |
| 170019 | /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1158, 1154, 260, | 171104 | /* 2030 */ 160, 96, 518, 97, 1175, 1060, 1146, 40, 21, 227, |
| 170020 | /* 2040 */ 21, 22, 23, 1156, 1162, 1161, 1143, 24, 33, 25, | 171105 | /* 2040 */ 176, 1145, 282, 284, 969, 200, 963, 114, 262, 1165, |
| 170021 | /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, | 171106 | /* 2050 */ 22, 23, 24, 1161, 1169, 25, 1163, 1150, 34, 26, |
| 170022 | /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, | 171107 | /* 2060 */ 1168, 546, 27, 204, 101, 103, 104, 1074, 7, 1061, |
| 170023 | /* 2070 */ 861, 112, 29, 564, 1176, 1175, 268, 176, 143, 923, | 171108 | /* 2070 */ 1059, 1063, 1116, 1064, 1115, 268, 269, 29, 41, 270, |
| 170024 | /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, | 171109 | /* 2080 */ 1024, 866, 113, 30, 568, 392, 1183, 144, 178, 1182, |
| 170025 | /* 2090 */ 1238, 1238, 1238, 1238, 269, 1593, | 171110 | /* 2090 */ 271, 928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602, |
| 170026 | }; | 171111 | }; |
| 170027 | static const YYCODETYPE yy_lookahead[] = { | 171112 | static const YYCODETYPE yy_lookahead[] = { |
| 170028 | /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, | 171113 | /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, |
| @@ -170101,7 +171186,7 @@ static const YYCODETYPE yy_lookahead[] = { | |||
| 170101 | /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, | 171186 | /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170102 | /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 171187 | /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170103 | /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, | 171188 | /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, |
| 170104 | /* 760 */ 201, 21, 241, 304, 22, 206, 127, 128, 129, 193, | 171189 | /* 760 */ 201, 21, 241, 304, 193, 206, 127, 128, 129, 193, |
| 170105 | /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, | 171190 | /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, |
| 170106 | /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, | 171191 | /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 170107 | /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, | 171192 | /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, |
| @@ -170112,129 +171197,129 @@ static const YYCODETYPE yy_lookahead[] = { | |||
| 170112 | /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, | 171197 | /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170113 | /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 171198 | /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170114 | /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, | 171199 | /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, |
| 170115 | /* 870 */ 240, 239, 240, 193, 106, 107, 193, 89, 252, 193, | 171200 | /* 870 */ 240, 239, 240, 244, 106, 107, 193, 89, 252, 193, |
| 170116 | /* 880 */ 92, 59, 252, 141, 252, 43, 44, 45, 46, 47, | 171201 | /* 880 */ 92, 59, 252, 254, 252, 43, 44, 45, 46, 47, |
| 170117 | /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, | 171202 | /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 170118 | /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, | 171203 | /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, |
| 170119 | /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 16, | 171204 | /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 244, |
| 170120 | /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 25, | 171205 | /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 254, |
| 170121 | /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, | 171206 | /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, |
| 170122 | /* 940 */ 24, 216, 217, 263, 102, 103, 104, 105, 106, 107, | 171207 | /* 940 */ 24, 216, 217, 273, 102, 103, 104, 105, 106, 107, |
| 170123 | /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, | 171208 | /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170124 | /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 171209 | /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170125 | /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, | 171210 | /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, |
| 170126 | /* 980 */ 77, 226, 79, 193, 195, 252, 197, 193, 19, 301, | 171211 | /* 980 */ 193, 311, 312, 16, 195, 252, 197, 193, 19, 301, |
| 170127 | /* 990 */ 302, 193, 193, 204, 216, 217, 226, 216, 217, 266, | 171212 | /* 990 */ 302, 135, 193, 204, 216, 217, 140, 216, 217, 266, |
| 170128 | /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, | 171213 | /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, |
| 170129 | /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, | 171214 | /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, |
| 170130 | /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, | 171215 | /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, |
| 170131 | /* 1030 */ 232, 298, 238, 117, 253, 239, 240, 238, 259, 260, | 171216 | /* 1030 */ 193, 298, 238, 117, 253, 239, 240, 238, 259, 260, |
| 170132 | /* 1040 */ 193, 252, 27, 31, 193, 193, 142, 204, 252, 193, | 171217 | /* 1040 */ 193, 252, 27, 193, 77, 193, 79, 204, 252, 262, |
| 170133 | /* 1050 */ 193, 39, 262, 193, 100, 266, 278, 42, 204, 102, | 171218 | /* 1050 */ 193, 299, 300, 193, 100, 266, 278, 42, 204, 102, |
| 170134 | /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, | 171219 | /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 170135 | /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, | 171220 | /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, |
| 170136 | /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 238, | 171221 | /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 240, |
| 170137 | /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, | 171222 | /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, |
| 170138 | /* 1100 */ 24, 193, 216, 217, 216, 217, 252, 153, 154, 155, | 171223 | /* 1100 */ 263, 252, 216, 217, 216, 217, 252, 153, 154, 155, |
| 170139 | /* 1110 */ 253, 16, 19, 144, 213, 268, 43, 44, 45, 46, | 171224 | /* 1110 */ 253, 193, 19, 144, 213, 268, 43, 44, 45, 46, |
| 170140 | /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 171225 | /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170141 | /* 1130 */ 57, 238, 19, 59, 193, 59, 43, 44, 45, 46, | 171226 | /* 1130 */ 57, 193, 19, 59, 216, 217, 43, 44, 45, 46, |
| 170142 | /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 171227 | /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170143 | /* 1150 */ 57, 22, 23, 193, 25, 193, 43, 44, 45, 46, | 171228 | /* 1150 */ 57, 193, 19, 24, 216, 217, 43, 44, 45, 46, |
| 170144 | /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 171229 | /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170145 | /* 1170 */ 57, 284, 77, 193, 79, 102, 103, 104, 105, 106, | 171230 | /* 1170 */ 57, 284, 193, 208, 209, 102, 103, 104, 105, 106, |
| 170146 | /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 193, 193, | 171231 | /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 59, 193, |
| 170147 | /* 1190 */ 193, 117, 291, 117, 232, 102, 103, 104, 105, 106, | 171232 | /* 1190 */ 232, 117, 291, 193, 193, 102, 103, 104, 105, 106, |
| 170148 | /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 22, 23, | 171233 | /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 193, 204, 22, |
| 170149 | /* 1210 */ 66, 25, 216, 217, 35, 102, 103, 104, 105, 106, | 171234 | /* 1210 */ 23, 193, 25, 66, 193, 102, 103, 104, 105, 106, |
| 170150 | /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 268, 85, | 171235 | /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 193, 193, |
| 170151 | /* 1230 */ 101, 193, 309, 309, 240, 19, 313, 313, 94, 208, | 171236 | /* 1230 */ 216, 217, 85, 193, 238, 19, 16, 216, 217, 238, |
| 170152 | /* 1240 */ 209, 193, 239, 240, 193, 66, 252, 19, 268, 244, | 171237 | /* 1240 */ 193, 94, 193, 239, 240, 231, 117, 268, 35, 116, |
| 170153 | /* 1250 */ 216, 217, 193, 74, 213, 252, 161, 19, 263, 254, | 171238 | /* 1250 */ 216, 217, 216, 217, 22, 23, 252, 25, 208, 209, |
| 170154 | /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 171239 | /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 170155 | /* 1270 */ 54, 55, 56, 57, 193, 216, 217, 5, 59, 193, | 171240 | /* 1270 */ 54, 55, 56, 57, 193, 193, 19, 5, 59, 66, |
| 170156 | /* 1280 */ 19, 244, 10, 11, 12, 13, 14, 101, 309, 17, | 171241 | /* 1280 */ 193, 263, 10, 11, 12, 13, 14, 74, 101, 17, |
| 170157 | /* 1290 */ 146, 254, 313, 193, 193, 76, 115, 216, 217, 309, | 171242 | /* 1290 */ 193, 46, 193, 146, 193, 76, 213, 77, 263, 79, |
| 170158 | /* 1300 */ 12, 263, 30, 313, 32, 46, 87, 46, 89, 130, | 171243 | /* 1300 */ 12, 260, 30, 46, 32, 264, 87, 193, 89, 29, |
| 170159 | /* 1310 */ 193, 92, 40, 22, 263, 27, 216, 217, 102, 103, | 171244 | /* 1310 */ 263, 92, 40, 33, 232, 27, 193, 108, 102, 103, |
| 170160 | /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, | 171245 | /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 170161 | /* 1330 */ 42, 150, 291, 216, 217, 116, 117, 118, 19, 20, | 171246 | /* 1330 */ 42, 138, 139, 101, 193, 116, 117, 118, 19, 20, |
| 170162 | /* 1340 */ 193, 22, 70, 260, 116, 193, 24, 264, 193, 263, | 171247 | /* 1340 */ 255, 22, 70, 130, 135, 65, 256, 257, 193, 140, |
| 170163 | /* 1350 */ 78, 63, 61, 81, 116, 36, 193, 260, 193, 29, | 171248 | /* 1350 */ 78, 63, 193, 81, 193, 36, 193, 216, 217, 193, |
| 170164 | /* 1360 */ 193, 264, 193, 33, 145, 193, 59, 48, 216, 217, | 171249 | /* 1360 */ 115, 193, 263, 193, 145, 268, 59, 48, 193, 193, |
| 170165 | /* 1370 */ 98, 216, 217, 193, 115, 193, 115, 193, 59, 216, | 171250 | /* 1370 */ 98, 193, 115, 193, 291, 216, 217, 193, 59, 216, |
| 170166 | /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 255, 216, 217, | 171251 | /* 1380 */ 217, 161, 216, 217, 216, 217, 216, 217, 131, 193, |
| 170167 | /* 1390 */ 71, 193, 131, 193, 25, 65, 216, 217, 216, 217, | 171252 | /* 1390 */ 71, 193, 216, 217, 216, 217, 216, 217, 193, 260, |
| 170168 | /* 1400 */ 216, 217, 208, 209, 85, 133, 193, 100, 193, 90, | 171253 | /* 1400 */ 216, 217, 19, 264, 85, 133, 244, 100, 193, 90, |
| 170169 | /* 1410 */ 138, 139, 138, 139, 216, 217, 216, 217, 193, 100, | 171254 | /* 1410 */ 138, 139, 216, 217, 216, 217, 254, 244, 193, 100, |
| 170170 | /* 1420 */ 193, 108, 135, 116, 117, 106, 107, 140, 121, 216, | 171255 | /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 254, 121, 193, |
| 170171 | /* 1430 */ 217, 216, 217, 114, 162, 116, 117, 118, 299, 300, | 171256 | /* 1430 */ 115, 216, 217, 114, 162, 116, 117, 118, 115, 244, |
| 170172 | /* 1440 */ 121, 216, 217, 216, 217, 193, 244, 193, 135, 244, | 171257 | /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 193, 31, 254, |
| 170173 | /* 1450 */ 193, 256, 257, 140, 244, 193, 254, 193, 193, 254, | 171258 | /* 1450 */ 313, 309, 216, 217, 309, 313, 39, 193, 313, 309, |
| 170174 | /* 1460 */ 153, 154, 155, 141, 254, 149, 150, 258, 216, 217, | 171259 | /* 1460 */ 153, 154, 155, 313, 193, 150, 25, 144, 216, 217, |
| 170175 | /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, | 171260 | /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, |
| 170176 | /* 1480 */ 216, 217, 5, 115, 158, 193, 160, 10, 11, 12, | 171261 | /* 1480 */ 216, 217, 5, 149, 150, 22, 193, 10, 11, 12, |
| 170177 | /* 1490 */ 13, 14, 193, 59, 17, 126, 193, 19, 20, 129, | 171262 | /* 1490 */ 13, 14, 193, 158, 17, 160, 193, 19, 20, 116, |
| 170178 | /* 1500 */ 22, 193, 22, 22, 24, 193, 23, 30, 25, 32, | 171263 | /* 1500 */ 22, 25, 193, 24, 22, 193, 24, 30, 226, 32, |
| 170179 | /* 1510 */ 19, 20, 144, 22, 36, 216, 217, 40, 193, 216, | 171264 | /* 1510 */ 19, 20, 226, 22, 36, 193, 53, 40, 193, 216, |
| 170180 | /* 1520 */ 217, 193, 152, 129, 216, 217, 193, 36, 216, 217, | 171265 | /* 1520 */ 217, 193, 23, 193, 25, 216, 217, 36, 216, 217, |
| 170181 | /* 1530 */ 193, 99, 193, 193, 53, 193, 193, 59, 23, 193, | 171266 | /* 1530 */ 193, 99, 193, 193, 22, 193, 193, 59, 216, 217, |
| 170182 | /* 1540 */ 25, 216, 217, 193, 216, 217, 152, 70, 59, 71, | 171267 | /* 1540 */ 193, 216, 217, 193, 216, 217, 193, 70, 129, 71, |
| 170183 | /* 1550 */ 59, 117, 193, 216, 217, 78, 216, 217, 81, 216, | 171268 | /* 1550 */ 59, 129, 193, 216, 217, 78, 216, 217, 81, 216, |
| 170184 | /* 1560 */ 217, 318, 71, 85, 193, 133, 193, 193, 90, 23, | 171269 | /* 1560 */ 217, 193, 71, 85, 193, 133, 193, 126, 90, 216, |
| 170185 | /* 1570 */ 23, 25, 25, 120, 121, 98, 85, 193, 100, 193, | 171270 | /* 1570 */ 217, 152, 258, 61, 152, 98, 85, 193, 100, 193, |
| 170186 | /* 1580 */ 23, 90, 25, 121, 106, 107, 19, 216, 217, 216, | 171271 | /* 1580 */ 23, 90, 25, 121, 106, 107, 23, 216, 217, 216, |
| 170187 | /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, | 171272 | /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, |
| 170188 | /* 1600 */ 216, 217, 216, 217, 193, 114, 117, 116, 117, 118, | 171273 | /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118, |
| 170189 | /* 1610 */ 133, 193, 121, 193, 193, 138, 139, 193, 23, 193, | 171274 | /* 1610 */ 133, 22, 121, 193, 59, 138, 139, 193, 142, 193, |
| 170190 | /* 1620 */ 25, 23, 23, 25, 25, 7, 8, 216, 217, 193, | 171275 | /* 1620 */ 141, 23, 23, 25, 25, 120, 121, 216, 217, 216, |
| 170191 | /* 1630 */ 193, 153, 154, 155, 156, 157, 216, 217, 193, 162, | 171276 | /* 1630 */ 217, 153, 154, 155, 156, 157, 216, 217, 19, 162, |
| 170192 | /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, | 171277 | /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, |
| 170193 | /* 1650 */ 2, 193, 193, 5, 19, 20, 59, 22, 10, 11, | 171278 | /* 1650 */ 2, 193, 59, 5, 19, 20, 318, 22, 10, 11, |
| 170194 | /* 1660 */ 12, 13, 14, 193, 97, 17, 193, 23, 193, 25, | 171279 | /* 1660 */ 12, 13, 14, 193, 59, 17, 193, 23, 23, 25, |
| 170195 | /* 1670 */ 288, 36, 193, 242, 216, 217, 236, 23, 30, 25, | 171280 | /* 1670 */ 25, 36, 117, 193, 216, 217, 193, 23, 30, 25, |
| 170196 | /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, | 171281 | /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, |
| 170197 | /* 1690 */ 217, 216, 217, 193, 59, 216, 217, 193, 36, 83, | 171282 | /* 1690 */ 217, 7, 8, 23, 59, 25, 83, 84, 36, 23, |
| 170198 | /* 1700 */ 84, 153, 153, 155, 155, 23, 71, 25, 23, 193, | 171283 | /* 1700 */ 193, 25, 23, 23, 25, 25, 71, 153, 145, 155, |
| 170199 | /* 1710 */ 25, 193, 193, 193, 117, 193, 193, 193, 70, 193, | 171284 | /* 1710 */ 117, 153, 23, 155, 25, 23, 97, 25, 70, 193, |
| 170200 | /* 1720 */ 193, 59, 193, 255, 255, 287, 78, 255, 243, 81, | 171285 | /* 1720 */ 193, 59, 117, 236, 193, 193, 78, 193, 193, 81, |
| 170201 | /* 1730 */ 191, 255, 297, 71, 271, 100, 293, 245, 267, 214, | 171286 | /* 1730 */ 141, 193, 193, 71, 193, 100, 288, 287, 242, 255, |
| 170202 | /* 1740 */ 246, 106, 107, 108, 246, 271, 98, 245, 293, 114, | 171287 | /* 1740 */ 255, 106, 107, 108, 255, 255, 98, 243, 297, 114, |
| 170203 | /* 1750 */ 220, 116, 117, 118, 267, 271, 121, 271, 225, 219, | 171288 | /* 1750 */ 214, 116, 117, 118, 245, 191, 121, 271, 293, 267, |
| 170204 | /* 1760 */ 229, 219, 100, 219, 259, 259, 259, 259, 106, 107, | 171289 | /* 1760 */ 267, 246, 100, 246, 245, 271, 271, 293, 106, 107, |
| 170205 | /* 1770 */ 249, 196, 60, 280, 141, 243, 114, 249, 116, 117, | 171290 | /* 1770 */ 220, 271, 229, 225, 249, 219, 114, 259, 116, 117, |
| 170206 | /* 1780 */ 118, 133, 245, 121, 200, 297, 138, 139, 153, 154, | 171291 | /* 1780 */ 118, 133, 259, 121, 219, 219, 138, 139, 153, 154, |
| 170207 | /* 1790 */ 155, 156, 157, 297, 200, 38, 19, 20, 151, 22, | 171292 | /* 1790 */ 155, 156, 157, 280, 249, 243, 19, 20, 245, 22, |
| 170208 | /* 1800 */ 200, 150, 140, 294, 294, 22, 272, 43, 234, 18, | 171293 | /* 1800 */ 196, 259, 140, 259, 60, 297, 141, 297, 200, 200, |
| 170209 | /* 1810 */ 162, 270, 200, 36, 237, 153, 154, 155, 156, 157, | 171294 | /* 1810 */ 162, 38, 200, 36, 294, 153, 154, 155, 156, 157, |
| 170210 | /* 1820 */ 237, 283, 237, 237, 18, 199, 149, 246, 272, 270, | 171295 | /* 1820 */ 151, 150, 294, 283, 22, 43, 234, 18, 237, 200, |
| 170211 | /* 1830 */ 272, 200, 158, 246, 246, 234, 59, 234, 246, 199, | 171296 | /* 1830 */ 270, 272, 237, 237, 237, 18, 59, 199, 270, 149, |
| 170212 | /* 1840 */ 290, 62, 289, 200, 199, 22, 221, 115, 71, 200, | 171297 | /* 1840 */ 246, 272, 272, 200, 234, 234, 246, 246, 71, 246, |
| 170213 | /* 1850 */ 200, 199, 199, 221, 218, 218, 19, 20, 64, 22, | 171298 | /* 1850 */ 199, 158, 290, 62, 22, 200, 19, 20, 199, 22, |
| 170214 | /* 1860 */ 218, 227, 22, 224, 126, 224, 165, 221, 24, 305, | 171299 | /* 1860 */ 289, 221, 221, 200, 200, 199, 199, 115, 218, 64, |
| 170215 | /* 1870 */ 200, 113, 312, 36, 218, 220, 218, 100, 282, 218, | 171300 | /* 1870 */ 218, 218, 22, 36, 227, 126, 227, 100, 165, 221, |
| 170216 | /* 1880 */ 91, 218, 317, 106, 107, 221, 227, 282, 317, 82, | 171301 | /* 1880 */ 224, 224, 24, 106, 107, 312, 218, 305, 113, 282, |
| 170217 | /* 1890 */ 148, 114, 265, 116, 117, 118, 59, 145, 121, 22, | 171302 | /* 1890 */ 91, 114, 220, 116, 117, 118, 59, 282, 121, 218, |
| 170218 | /* 1900 */ 277, 158, 200, 265, 25, 202, 147, 250, 71, 279, | 171303 | /* 1900 */ 218, 218, 200, 317, 317, 82, 221, 265, 71, 148, |
| 170219 | /* 1910 */ 13, 146, 194, 194, 249, 248, 250, 140, 247, 246, | 171304 | /* 1910 */ 145, 265, 22, 277, 200, 158, 279, 140, 147, 25, |
| 170220 | /* 1920 */ 6, 192, 192, 192, 303, 303, 213, 207, 300, 213, | 171305 | /* 1920 */ 146, 202, 248, 250, 249, 247, 13, 250, 194, 194, |
| 170221 | /* 1930 */ 153, 154, 155, 156, 157, 213, 213, 100, 213, 222, | 171306 | /* 1930 */ 153, 154, 155, 156, 157, 6, 303, 100, 192, 192, |
| 170222 | /* 1940 */ 207, 214, 214, 106, 107, 4, 222, 207, 3, 22, | 171307 | /* 1940 */ 246, 213, 192, 106, 107, 207, 213, 207, 222, 213, |
| 170223 | /* 1950 */ 163, 114, 15, 116, 117, 118, 16, 23, 121, 23, | 171308 | /* 1950 */ 213, 114, 222, 116, 117, 118, 214, 214, 121, 4, |
| 170224 | /* 1960 */ 139, 151, 130, 25, 142, 16, 24, 20, 144, 1, | 171309 | /* 1960 */ 207, 213, 3, 22, 303, 15, 163, 16, 23, 23, |
| 170225 | /* 1970 */ 142, 130, 130, 61, 53, 53, 37, 151, 53, 53, | 171310 | /* 1970 */ 139, 151, 130, 25, 20, 142, 24, 16, 144, 1, |
| 170226 | /* 1980 */ 130, 116, 34, 1, 141, 5, 22, 115, 161, 141, | 171311 | /* 1980 */ 142, 130, 130, 61, 37, 53, 300, 151, 53, 53, |
| 170227 | /* 1990 */ 153, 154, 155, 156, 157, 25, 68, 68, 75, 41, | 171312 | /* 1990 */ 153, 154, 155, 156, 157, 53, 130, 116, 34, 1, |
| 170228 | /* 2000 */ 115, 24, 131, 20, 19, 125, 22, 96, 22, 22, | 171313 | /* 2000 */ 141, 5, 22, 115, 161, 68, 25, 68, 75, 41, |
| 170229 | /* 2010 */ 67, 23, 22, 67, 59, 24, 22, 28, 67, 23, | 171314 | /* 2010 */ 141, 115, 24, 20, 19, 131, 125, 23, 28, 22, |
| 170230 | /* 2020 */ 22, 22, 149, 23, 23, 23, 116, 23, 25, 37, | 171315 | /* 2020 */ 67, 22, 22, 22, 67, 59, 24, 96, 22, 67, |
| 170231 | /* 2030 */ 97, 141, 23, 23, 22, 143, 25, 75, 88, 34, | 171316 | /* 2030 */ 23, 149, 22, 25, 23, 23, 23, 22, 34, 141, |
| 170232 | /* 2040 */ 34, 34, 34, 86, 75, 93, 23, 34, 22, 34, | 171317 | /* 2040 */ 37, 97, 23, 23, 116, 22, 143, 25, 34, 75, |
| 170233 | /* 2050 */ 25, 24, 34, 25, 23, 142, 23, 142, 44, 23, | 171318 | /* 2050 */ 34, 34, 34, 88, 75, 34, 86, 23, 22, 34, |
| 170234 | /* 2060 */ 23, 23, 11, 23, 25, 22, 22, 22, 15, 23, | 171319 | /* 2060 */ 93, 24, 34, 25, 25, 142, 142, 23, 44, 23, |
| 170235 | /* 2070 */ 23, 22, 22, 25, 1, 1, 141, 25, 23, 135, | 171320 | /* 2070 */ 23, 23, 23, 11, 23, 25, 22, 22, 22, 141, |
| 170236 | /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171321 | /* 2080 */ 23, 23, 22, 22, 25, 15, 1, 23, 25, 1, |
| 170237 | /* 2090 */ 319, 319, 319, 319, 141, 141, 319, 319, 319, 319, | 171322 | /* 2090 */ 141, 135, 319, 319, 319, 319, 319, 319, 319, 141, |
| 170238 | /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171323 | /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170239 | /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171324 | /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170240 | /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171325 | /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| @@ -170253,176 +171338,177 @@ static const YYCODETYPE yy_lookahead[] = { | |||
| 170253 | /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171338 | /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170254 | /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171339 | /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170255 | /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | 171340 | /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170256 | /* 2280 */ 319, | 171341 | /* 2280 */ 319, 319, 319, 319, 319, |
| 170257 | }; | 171342 | }; |
| 170258 | #define YY_SHIFT_COUNT (574) | 171343 | #define YY_SHIFT_COUNT (578) |
| 170259 | #define YY_SHIFT_MIN (0) | 171344 | #define YY_SHIFT_MIN (0) |
| 170260 | #define YY_SHIFT_MAX (2074) | 171345 | #define YY_SHIFT_MAX (2088) |
| 170261 | static const unsigned short int yy_shift_ofst[] = { | 171346 | static const unsigned short int yy_shift_ofst[] = { |
| 170262 | /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, | 171347 | /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, |
| 170263 | /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, | 171348 | /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, |
| 170264 | /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | 171349 | /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170265 | /* 30 */ 271, 271, 1219, 1219, 216, 88, 1, 1, 1, 1, | 171350 | /* 30 */ 1837, 271, 271, 1219, 1219, 216, 88, 1, 1, 1, |
| 170266 | /* 40 */ 1, 40, 111, 258, 361, 469, 512, 583, 622, 693, | 171351 | /* 40 */ 1, 1, 40, 111, 258, 361, 469, 512, 583, 622, |
| 170267 | /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, | 171352 | /* 50 */ 693, 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, |
| 170268 | /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, | 171353 | /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, |
| 170269 | /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662, | 171354 | /* 70 */ 1093, 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, |
| 170270 | /* 80 */ 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | 171355 | /* 80 */ 1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170271 | /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | 171356 | /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170272 | /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | 171357 | /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170273 | /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | 171358 | /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170274 | /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | 171359 | /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170275 | /* 130 */ 137, 181, 181, 181, 181, 181, 181, 181, 94, 430, | 171360 | /* 130 */ 1837, 137, 181, 181, 181, 181, 181, 181, 181, 94, |
| 170276 | /* 140 */ 66, 65, 112, 366, 533, 533, 740, 1261, 533, 533, | 171361 | /* 140 */ 430, 66, 65, 112, 366, 533, 533, 740, 1257, 533, |
| 170277 | /* 150 */ 79, 79, 533, 412, 412, 412, 77, 412, 123, 113, | 171362 | /* 150 */ 533, 79, 79, 533, 412, 412, 412, 77, 412, 123, |
| 170278 | /* 160 */ 113, 22, 22, 2096, 2096, 328, 328, 328, 239, 468, | 171363 | /* 160 */ 113, 113, 113, 22, 22, 2100, 2100, 328, 328, 328, |
| 170279 | /* 170 */ 468, 468, 468, 1015, 1015, 409, 366, 1129, 1186, 533, | 171364 | /* 170 */ 239, 468, 468, 468, 468, 1015, 1015, 409, 366, 1187, |
| 170280 | /* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, | 171365 | /* 180 */ 1232, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 170281 | /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 969, | 171366 | /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 170282 | /* 200 */ 621, 621, 533, 642, 788, 788, 1228, 1228, 822, 822, | 171367 | /* 200 */ 533, 969, 621, 621, 533, 642, 788, 788, 1133, 1133, |
| 170283 | /* 210 */ 67, 1274, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 1307, | 171368 | /* 210 */ 822, 822, 67, 1193, 2100, 2100, 2100, 2100, 2100, 2100, |
| 170284 | /* 220 */ 954, 954, 585, 472, 640, 387, 695, 538, 541, 700, | 171369 | /* 220 */ 2100, 1307, 954, 954, 585, 472, 640, 387, 695, 538, |
| 170285 | /* 230 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, | 171370 | /* 230 */ 541, 700, 533, 533, 533, 533, 533, 533, 533, 533, |
| 170286 | /* 240 */ 222, 533, 533, 533, 533, 533, 533, 533, 533, 533, | 171371 | /* 240 */ 533, 533, 222, 533, 533, 533, 533, 533, 533, 533, |
| 170287 | /* 250 */ 533, 533, 533, 1179, 1179, 1179, 533, 533, 533, 565, | 171372 | /* 250 */ 533, 533, 533, 533, 533, 1213, 1213, 1213, 533, 533, |
| 170288 | /* 260 */ 533, 533, 533, 916, 1144, 533, 533, 1288, 533, 533, | 171373 | /* 260 */ 533, 565, 533, 533, 533, 916, 1147, 533, 533, 1288, |
| 170289 | /* 270 */ 533, 533, 533, 533, 533, 533, 639, 1330, 209, 1076, | 171374 | /* 270 */ 533, 533, 533, 533, 533, 533, 533, 533, 639, 1280, |
| 170290 | /* 280 */ 1076, 1076, 1076, 580, 209, 209, 1313, 768, 917, 649, | 171375 | /* 280 */ 209, 1129, 1129, 1129, 1129, 580, 209, 209, 1209, 768, |
| 170291 | /* 290 */ 1181, 1316, 405, 1316, 1238, 249, 1181, 1181, 249, 1181, | 171376 | /* 290 */ 917, 649, 1315, 1334, 405, 1334, 1383, 249, 1315, 1315, |
| 170292 | /* 300 */ 405, 1238, 1369, 464, 1259, 1012, 1012, 1012, 1368, 1368, | 171377 | /* 300 */ 249, 1315, 405, 1383, 1441, 464, 1245, 1417, 1417, 1417, |
| 170293 | /* 310 */ 1368, 1368, 184, 184, 1326, 904, 1287, 1480, 1712, 1712, | 171378 | /* 310 */ 1323, 1323, 1323, 1323, 184, 184, 1335, 1476, 856, 1482, |
| 170294 | /* 320 */ 1633, 1633, 1757, 1757, 1633, 1647, 1651, 1783, 1764, 1791, | 171379 | /* 320 */ 1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802, |
| 170295 | /* 330 */ 1791, 1791, 1791, 1633, 1806, 1677, 1651, 1651, 1677, 1783, | 171380 | /* 330 */ 1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671, |
| 170296 | /* 340 */ 1764, 1677, 1764, 1677, 1633, 1806, 1674, 1779, 1633, 1806, | 171381 | /* 340 */ 1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791, |
| 170297 | /* 350 */ 1823, 1633, 1806, 1633, 1806, 1823, 1732, 1732, 1732, 1794, | 171382 | /* 350 */ 1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752, |
| 170298 | /* 360 */ 1840, 1840, 1823, 1732, 1738, 1732, 1794, 1732, 1732, 1701, | 171383 | /* 360 */ 1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752, |
| 170299 | /* 370 */ 1844, 1758, 1758, 1823, 1633, 1789, 1789, 1807, 1807, 1742, | 171384 | /* 370 */ 1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823, |
| 170300 | /* 380 */ 1752, 1877, 1633, 1743, 1742, 1759, 1765, 1677, 1879, 1897, | 171385 | /* 380 */ 1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690, |
| 170301 | /* 390 */ 1897, 1914, 1914, 1914, 2096, 2096, 2096, 2096, 2096, 2096, | 171386 | /* 390 */ 1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100, |
| 170302 | /* 400 */ 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 207, | 171387 | /* 400 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, |
| 170303 | /* 410 */ 1095, 331, 620, 903, 806, 1074, 1483, 1432, 1481, 1322, | 171388 | /* 410 */ 2100, 207, 1220, 331, 620, 967, 806, 1074, 1499, 1432, |
| 170304 | /* 420 */ 1370, 1394, 1515, 1291, 1546, 1547, 1557, 1595, 1598, 1599, | 171389 | /* 420 */ 1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645, |
| 170305 | /* 430 */ 1434, 1453, 1618, 1462, 1567, 1489, 1644, 1654, 1616, 1660, | 171390 | /* 430 */ 1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593, |
| 170306 | /* 440 */ 1548, 1549, 1682, 1685, 1597, 742, 1941, 1945, 1927, 1787, | 171391 | /* 440 */ 1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589, |
| 170307 | /* 450 */ 1937, 1940, 1934, 1936, 1821, 1810, 1832, 1938, 1938, 1942, | 171392 | /* 450 */ 1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820, |
| 170308 | /* 460 */ 1822, 1947, 1824, 1949, 1968, 1828, 1841, 1938, 1842, 1912, | 171393 | /* 460 */ 1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838, |
| 170309 | /* 470 */ 1939, 1938, 1826, 1921, 1922, 1925, 1926, 1850, 1865, 1948, | 171394 | /* 470 */ 1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936, |
| 170310 | /* 480 */ 1843, 1982, 1980, 1964, 1872, 1827, 1928, 1970, 1929, 1923, | 171395 | /* 480 */ 1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843, |
| 170311 | /* 490 */ 1958, 1848, 1885, 1977, 1983, 1985, 1871, 1880, 1984, 1943, | 171396 | /* 490 */ 1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995, |
| 170312 | /* 500 */ 1986, 1987, 1988, 1990, 1946, 1955, 1991, 1911, 1989, 1994, | 171397 | /* 500 */ 1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966, |
| 170313 | /* 510 */ 1951, 1992, 1996, 1873, 1998, 2000, 2001, 2002, 2003, 2004, | 171398 | /* 510 */ 2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010, |
| 170314 | /* 520 */ 1999, 1933, 1890, 2009, 2010, 1910, 2005, 2012, 1892, 2011, | 171399 | /* 520 */ 2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928, |
| 170315 | /* 530 */ 2006, 2007, 2008, 2013, 1950, 1962, 1957, 2014, 1969, 1952, | 171400 | /* 530 */ 2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974, |
| 170316 | /* 540 */ 2015, 2023, 2026, 2027, 2025, 2028, 2018, 1913, 1915, 2031, | 171401 | /* 540 */ 1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039, |
| 170317 | /* 550 */ 2011, 2033, 2036, 2037, 2038, 2039, 2040, 2043, 2051, 2044, | 171402 | /* 550 */ 2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050, |
| 170318 | /* 560 */ 2045, 2046, 2047, 2049, 2050, 2048, 1944, 1935, 1953, 1954, | 171403 | /* 560 */ 2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059, |
| 170319 | /* 570 */ 2052, 2055, 2053, 2073, 2074, | 171404 | /* 570 */ 1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088, |
| 170320 | }; | 171405 | }; |
| 170321 | #define YY_REDUCE_COUNT (408) | 171406 | #define YY_REDUCE_COUNT (410) |
| 170322 | #define YY_REDUCE_MIN (-271) | 171407 | #define YY_REDUCE_MIN (-271) |
| 170323 | #define YY_REDUCE_MAX (1740) | 171408 | #define YY_REDUCE_MAX (1753) |
| 170324 | static const short yy_reduce_ofst[] = { | 171409 | static const short yy_reduce_ofst[] = { |
| 170325 | /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, | 171410 | /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, |
| 170326 | /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, | 171411 | /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, |
| 170327 | /* 20 */ 576, -175, 598, 686, 615, 725, 860, 778, 781, 857, | 171412 | /* 20 */ 576, 598, -175, 686, 860, 615, 725, 1014, 778, 781, |
| 170328 | /* 30 */ 616, 887, 87, 240, -192, 408, 626, 796, 843, 854, | 171413 | /* 30 */ 857, 616, 887, 87, 240, -192, 408, 626, 796, 843, |
| 170329 | /* 40 */ 1003, -271, -271, -271, -271, -271, -271, -271, -271, -271, | 171414 | /* 40 */ 854, 1004, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170330 | /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, | 171415 | /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170331 | /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, | 171416 | /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170332 | /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, 80, 83, | 171417 | /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, 80, |
| 170333 | /* 80 */ 313, 886, 888, 996, 1034, 1059, 1081, 1100, 1117, 1152, | 171418 | /* 80 */ 83, 313, 886, 888, 918, 938, 1021, 1034, 1036, 1141, |
| 170334 | /* 90 */ 1155, 1163, 1165, 1167, 1169, 1172, 1180, 1182, 1184, 1198, | 171419 | /* 90 */ 1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196, |
| 170335 | /* 100 */ 1200, 1213, 1215, 1225, 1227, 1252, 1254, 1264, 1299, 1303, | 171420 | /* 100 */ 1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303, |
| 170336 | /* 110 */ 1308, 1312, 1325, 1328, 1337, 1340, 1343, 1371, 1373, 1384, | 171421 | /* 110 */ 1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371, |
| 170337 | /* 120 */ 1386, 1411, 1420, 1424, 1426, 1458, 1470, 1473, 1475, 1479, | 171422 | /* 120 */ 1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470, |
| 170338 | /* 130 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, | 171423 | /* 130 */ 1473, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170339 | /* 140 */ -271, 138, 459, 396, -158, 470, 302, -212, 521, 201, | 171424 | /* 140 */ -271, -271, 138, 459, 396, -158, 470, 302, -212, 521, |
| 170340 | /* 150 */ -195, -92, 559, 630, 632, 630, -271, 632, 901, 63, | 171425 | /* 150 */ 201, -195, -92, 559, 630, 632, 630, -271, 632, 901, |
| 170341 | /* 160 */ 407, -271, -271, -271, -271, 161, 161, 161, 251, 335, | 171426 | /* 160 */ 63, 407, 670, -271, -271, -271, -271, 161, 161, 161, |
| 170342 | /* 170 */ 847, 960, 980, 537, 588, 618, 628, 688, 688, -166, | 171427 | /* 170 */ 251, 335, 847, 979, 1097, 537, 588, 618, 628, 688, |
| 170343 | /* 180 */ -161, 674, 790, 794, 799, 851, 852, -122, 680, -120, | 171428 | /* 180 */ 688, -166, -161, 674, 787, 794, 799, 852, 996, -122, |
| 170344 | /* 190 */ 995, 1038, 415, 1051, 893, 798, 962, 400, 1086, 779, | 171429 | /* 190 */ 837, -120, 1018, 1035, 415, 1047, 1001, 958, 1082, 400, |
| 170345 | /* 200 */ 923, 924, 263, 1041, 979, 990, 1083, 1097, 1031, 1194, | 171430 | /* 200 */ 1099, 779, 1137, 1142, 263, 1083, 1145, 1150, 1041, 1139, |
| 170346 | /* 210 */ 362, 994, 1139, 1005, 1037, 1202, 1205, 1195, 1210, -194, | 171431 | /* 210 */ 965, 1050, 362, 849, 752, 629, 675, 1162, 1173, 1090, |
| 170347 | /* 220 */ 56, 185, -135, 232, 522, 560, 601, 617, 669, 683, | 171432 | /* 220 */ 1195, -194, 56, 185, -135, 232, 522, 560, 571, 601, |
| 170348 | /* 230 */ 711, 856, 908, 941, 1048, 1101, 1147, 1257, 1262, 1265, | 171433 | /* 230 */ 617, 669, 683, 711, 850, 893, 1000, 1040, 1049, 1081, |
| 170349 | /* 240 */ 392, 1292, 1333, 1339, 1342, 1346, 1350, 1359, 1374, 1418, | 171434 | /* 240 */ 1087, 1101, 392, 1114, 1123, 1155, 1161, 1175, 1271, 1293, |
| 170350 | /* 250 */ 1421, 1436, 1437, 593, 755, 770, 997, 1445, 1459, 1209, | 171435 | /* 250 */ 1299, 1330, 1339, 1342, 1347, 593, 1282, 1286, 1350, 1359, |
| 170351 | /* 260 */ 1500, 1504, 1516, 1132, 1243, 1518, 1519, 1440, 1520, 560, | 171436 | /* 260 */ 1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487, |
| 170352 | /* 270 */ 1522, 1523, 1524, 1526, 1527, 1529, 1382, 1438, 1431, 1468, | 171437 | /* 270 */ 1531, 560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450, |
| 170353 | /* 280 */ 1469, 1472, 1476, 1209, 1431, 1431, 1485, 1525, 1539, 1435, | 171438 | /* 280 */ 1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536, |
| 170354 | /* 290 */ 1463, 1471, 1492, 1487, 1443, 1494, 1474, 1484, 1498, 1486, | 171439 | /* 290 */ 1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495, |
| 170355 | /* 300 */ 1502, 1455, 1530, 1531, 1533, 1540, 1542, 1544, 1505, 1506, | 171440 | /* 300 */ 1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566, |
| 170356 | /* 310 */ 1507, 1508, 1521, 1528, 1493, 1537, 1532, 1575, 1488, 1496, | 171441 | /* 310 */ 1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604, |
| 170357 | /* 320 */ 1584, 1594, 1509, 1510, 1600, 1538, 1534, 1541, 1574, 1577, | 171442 | /* 320 */ 1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560, |
| 170358 | /* 330 */ 1583, 1585, 1586, 1612, 1626, 1581, 1556, 1558, 1587, 1559, | 171443 | /* 330 */ 1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570, |
| 170359 | /* 340 */ 1601, 1588, 1603, 1592, 1631, 1640, 1550, 1553, 1643, 1645, | 171444 | /* 340 */ 1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571, |
| 170360 | /* 350 */ 1625, 1649, 1652, 1650, 1653, 1632, 1636, 1637, 1642, 1634, | 171445 | /* 350 */ 1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652, |
| 170361 | /* 360 */ 1639, 1641, 1646, 1656, 1655, 1658, 1659, 1661, 1663, 1560, | 171446 | /* 360 */ 1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682, |
| 170362 | /* 370 */ 1564, 1596, 1605, 1664, 1670, 1565, 1571, 1627, 1638, 1657, | 171447 | /* 370 */ 1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642, |
| 170363 | /* 380 */ 1665, 1623, 1702, 1630, 1666, 1667, 1671, 1673, 1703, 1718, | 171448 | /* 380 */ 1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694, |
| 170364 | /* 390 */ 1719, 1729, 1730, 1731, 1621, 1622, 1628, 1720, 1713, 1716, | 171449 | /* 390 */ 1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738, |
| 170365 | /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, | 171450 | /* 400 */ 1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748, |
| 171451 | /* 410 */ 1753, | ||
| 170366 | }; | 171452 | }; |
| 170367 | static const YYACTIONTYPE yy_default[] = { | 171453 | static const YYACTIONTYPE yy_default[] = { |
| 170368 | /* 0 */ 1639, 1639, 1639, 1469, 1236, 1347, 1236, 1236, 1236, 1469, | 171454 | /* 0 */ 1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478, |
| 170369 | /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, | 171455 | /* 10 */ 1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243, |
| 170370 | /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, | 171456 | /* 20 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243, |
| 170371 | /* 30 */ 1236, 1236, 1555, 1555, 1236, 1236, 1236, 1236, 1236, 1236, | 171457 | /* 30 */ 1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243, |
| 170372 | /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, | 171458 | /* 40 */ 1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243, |
| 170373 | /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, | 171459 | /* 50 */ 1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407, |
| 170374 | /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, | 171460 | /* 60 */ 1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475, |
| 170375 | /* 70 */ 1617, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, | 171461 | /* 70 */ 1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243, |
| 170376 | /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171462 | /* 80 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170377 | /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171463 | /* 90 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170378 | /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171464 | /* 100 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170379 | /* 110 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171465 | /* 110 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170380 | /* 120 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171466 | /* 120 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170381 | /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, | 171467 | /* 130 */ 1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443, |
| 170382 | /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, | 171468 | /* 140 */ 1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243, |
| 170383 | /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, | 171469 | /* 150 */ 1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276, |
| 170384 | /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1591, 1590, 1487, 1236, | 171470 | /* 160 */ 1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599, |
| 170385 | /* 170 */ 1236, 1236, 1236, 1236, 1236, 1555, 1236, 1236, 1236, 1236, | 171471 | /* 170 */ 1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243, |
| 170386 | /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171472 | /* 180 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170387 | /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, | 171473 | /* 190 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170388 | /* 200 */ 1555, 1555, 1236, 1269, 1555, 1555, 1368, 1368, 1265, 1265, | 171474 | /* 200 */ 1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375, |
| 170389 | /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, | 171475 | /* 210 */ 1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354, |
| 170390 | /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171476 | /* 220 */ 1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170391 | /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, | 171477 | /* 230 */ 1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243, |
| 170392 | /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171478 | /* 240 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170393 | /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171479 | /* 250 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170394 | /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, | 171480 | /* 260 */ 1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243, |
| 170395 | /* 270 */ 1236, 1236, 1236, 1236, 1236, 1584, 1236, 1499, 1325, 1343, | 171481 | /* 270 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508, |
| 170396 | /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1631, | 171482 | /* 280 */ 1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277, |
| 170397 | /* 290 */ 1403, 1392, 1344, 1392, 1628, 1390, 1403, 1403, 1390, 1403, | 171483 | /* 290 */ 1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410, |
| 170398 | /* 300 */ 1344, 1628, 1286, 1606, 1281, 1377, 1377, 1377, 1367, 1367, | 171484 | /* 300 */ 1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384, |
| 170399 | /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1631, 1631, | 171485 | /* 310 */ 1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243, |
| 170400 | /* 320 */ 1353, 1353, 1630, 1630, 1353, 1487, 1614, 1412, 1314, 1320, | 171486 | /* 320 */ 1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419, |
| 170401 | /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1614, 1614, 1390, 1412, | 171487 | /* 330 */ 1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623, |
| 170402 | /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1625, 1353, 1254, | 171488 | /* 340 */ 1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634, |
| 170403 | /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, | 171489 | /* 350 */ 1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319, |
| 170404 | /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1573, | 171490 | /* 360 */ 1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319, |
| 170405 | /* 370 */ 1236, 1481, 1481, 1477, 1353, 1565, 1565, 1380, 1380, 1385, | 171491 | /* 370 */ 1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387, |
| 170406 | /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1587, | 171492 | /* 380 */ 1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397, |
| 170407 | /* 390 */ 1587, 1583, 1583, 1583, 1636, 1636, 1536, 1599, 1269, 1269, | 171493 | /* 390 */ 1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608, |
| 170408 | /* 400 */ 1269, 1269, 1599, 1288, 1288, 1270, 1270, 1269, 1599, 1236, | 171494 | /* 400 */ 1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276, |
| 170409 | /* 410 */ 1236, 1236, 1236, 1236, 1236, 1594, 1236, 1531, 1488, 1357, | 171495 | /* 410 */ 1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540, |
| 170410 | /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171496 | /* 420 */ 1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170411 | /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, | 171497 | /* 430 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243, |
| 170412 | /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, | 171498 | /* 440 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424, |
| 170413 | /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, | 171499 | /* 450 */ 1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170414 | /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, | 171500 | /* 460 */ 1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170415 | /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171501 | /* 470 */ 1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243, |
| 170416 | /* 480 */ 1627, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, | 171502 | /* 480 */ 1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243, |
| 170417 | /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171503 | /* 490 */ 1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243, |
| 170418 | /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, | 171504 | /* 500 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291, |
| 170419 | /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171505 | /* 510 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170420 | /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, | 171506 | /* 520 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170421 | /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171507 | /* 530 */ 1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243, |
| 170422 | /* 540 */ 1236, 1236, 1236, 1236, 1570, 1372, 1236, 1236, 1236, 1236, | 171508 | /* 540 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379, |
| 170423 | /* 550 */ 1618, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | 171509 | /* 550 */ 1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243, |
| 170424 | /* 560 */ 1236, 1236, 1236, 1236, 1236, 1610, 1328, 1418, 1236, 1421, | 171510 | /* 560 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619, |
| 170425 | /* 570 */ 1258, 1236, 1248, 1236, 1236, | 171511 | /* 570 */ 1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243, |
| 170426 | }; | 171512 | }; |
| 170427 | /********** End of lemon-generated parsing tables *****************************/ | 171513 | /********** End of lemon-generated parsing tables *****************************/ |
| 170428 | 171514 | ||
| @@ -171229,221 +172315,223 @@ static const char *const yyRuleName[] = { | |||
| 171229 | /* 185 */ "expr ::= expr COLLATE ID|STRING", | 172315 | /* 185 */ "expr ::= expr COLLATE ID|STRING", |
| 171230 | /* 186 */ "expr ::= CAST LP expr AS typetoken RP", | 172316 | /* 186 */ "expr ::= CAST LP expr AS typetoken RP", |
| 171231 | /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", | 172317 | /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", |
| 171232 | /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", | 172318 | /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP", |
| 171233 | /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", | 172319 | /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", |
| 171234 | /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", | 172320 | /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", |
| 171235 | /* 191 */ "term ::= CTIME_KW", | 172321 | /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over", |
| 171236 | /* 192 */ "expr ::= LP nexprlist COMMA expr RP", | 172322 | /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", |
| 171237 | /* 193 */ "expr ::= expr AND expr", | 172323 | /* 193 */ "term ::= CTIME_KW", |
| 171238 | /* 194 */ "expr ::= expr OR expr", | 172324 | /* 194 */ "expr ::= LP nexprlist COMMA expr RP", |
| 171239 | /* 195 */ "expr ::= expr LT|GT|GE|LE expr", | 172325 | /* 195 */ "expr ::= expr AND expr", |
| 171240 | /* 196 */ "expr ::= expr EQ|NE expr", | 172326 | /* 196 */ "expr ::= expr OR expr", |
| 171241 | /* 197 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", | 172327 | /* 197 */ "expr ::= expr LT|GT|GE|LE expr", |
| 171242 | /* 198 */ "expr ::= expr PLUS|MINUS expr", | 172328 | /* 198 */ "expr ::= expr EQ|NE expr", |
| 171243 | /* 199 */ "expr ::= expr STAR|SLASH|REM expr", | 172329 | /* 199 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 171244 | /* 200 */ "expr ::= expr CONCAT expr", | 172330 | /* 200 */ "expr ::= expr PLUS|MINUS expr", |
| 171245 | /* 201 */ "likeop ::= NOT LIKE_KW|MATCH", | 172331 | /* 201 */ "expr ::= expr STAR|SLASH|REM expr", |
| 171246 | /* 202 */ "expr ::= expr likeop expr", | 172332 | /* 202 */ "expr ::= expr CONCAT expr", |
| 171247 | /* 203 */ "expr ::= expr likeop expr ESCAPE expr", | 172333 | /* 203 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 171248 | /* 204 */ "expr ::= expr ISNULL|NOTNULL", | 172334 | /* 204 */ "expr ::= expr likeop expr", |
| 171249 | /* 205 */ "expr ::= expr NOT NULL", | 172335 | /* 205 */ "expr ::= expr likeop expr ESCAPE expr", |
| 171250 | /* 206 */ "expr ::= expr IS expr", | 172336 | /* 206 */ "expr ::= expr ISNULL|NOTNULL", |
| 171251 | /* 207 */ "expr ::= expr IS NOT expr", | 172337 | /* 207 */ "expr ::= expr NOT NULL", |
| 171252 | /* 208 */ "expr ::= expr IS NOT DISTINCT FROM expr", | 172338 | /* 208 */ "expr ::= expr IS expr", |
| 171253 | /* 209 */ "expr ::= expr IS DISTINCT FROM expr", | 172339 | /* 209 */ "expr ::= expr IS NOT expr", |
| 171254 | /* 210 */ "expr ::= NOT expr", | 172340 | /* 210 */ "expr ::= expr IS NOT DISTINCT FROM expr", |
| 171255 | /* 211 */ "expr ::= BITNOT expr", | 172341 | /* 211 */ "expr ::= expr IS DISTINCT FROM expr", |
| 171256 | /* 212 */ "expr ::= PLUS|MINUS expr", | 172342 | /* 212 */ "expr ::= NOT expr", |
| 171257 | /* 213 */ "expr ::= expr PTR expr", | 172343 | /* 213 */ "expr ::= BITNOT expr", |
| 171258 | /* 214 */ "between_op ::= BETWEEN", | 172344 | /* 214 */ "expr ::= PLUS|MINUS expr", |
| 171259 | /* 215 */ "between_op ::= NOT BETWEEN", | 172345 | /* 215 */ "expr ::= expr PTR expr", |
| 171260 | /* 216 */ "expr ::= expr between_op expr AND expr", | 172346 | /* 216 */ "between_op ::= BETWEEN", |
| 171261 | /* 217 */ "in_op ::= IN", | 172347 | /* 217 */ "between_op ::= NOT BETWEEN", |
| 171262 | /* 218 */ "in_op ::= NOT IN", | 172348 | /* 218 */ "expr ::= expr between_op expr AND expr", |
| 171263 | /* 219 */ "expr ::= expr in_op LP exprlist RP", | 172349 | /* 219 */ "in_op ::= IN", |
| 171264 | /* 220 */ "expr ::= LP select RP", | 172350 | /* 220 */ "in_op ::= NOT IN", |
| 171265 | /* 221 */ "expr ::= expr in_op LP select RP", | 172351 | /* 221 */ "expr ::= expr in_op LP exprlist RP", |
| 171266 | /* 222 */ "expr ::= expr in_op nm dbnm paren_exprlist", | 172352 | /* 222 */ "expr ::= LP select RP", |
| 171267 | /* 223 */ "expr ::= EXISTS LP select RP", | 172353 | /* 223 */ "expr ::= expr in_op LP select RP", |
| 171268 | /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", | 172354 | /* 224 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 171269 | /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", | 172355 | /* 225 */ "expr ::= EXISTS LP select RP", |
| 171270 | /* 226 */ "case_exprlist ::= WHEN expr THEN expr", | 172356 | /* 226 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 171271 | /* 227 */ "case_else ::= ELSE expr", | 172357 | /* 227 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 171272 | /* 228 */ "case_else ::=", | 172358 | /* 228 */ "case_exprlist ::= WHEN expr THEN expr", |
| 171273 | /* 229 */ "case_operand ::=", | 172359 | /* 229 */ "case_else ::= ELSE expr", |
| 171274 | /* 230 */ "exprlist ::=", | 172360 | /* 230 */ "case_else ::=", |
| 171275 | /* 231 */ "nexprlist ::= nexprlist COMMA expr", | 172361 | /* 231 */ "case_operand ::=", |
| 171276 | /* 232 */ "nexprlist ::= expr", | 172362 | /* 232 */ "exprlist ::=", |
| 171277 | /* 233 */ "paren_exprlist ::=", | 172363 | /* 233 */ "nexprlist ::= nexprlist COMMA expr", |
| 171278 | /* 234 */ "paren_exprlist ::= LP exprlist RP", | 172364 | /* 234 */ "nexprlist ::= expr", |
| 171279 | /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", | 172365 | /* 235 */ "paren_exprlist ::=", |
| 171280 | /* 236 */ "uniqueflag ::= UNIQUE", | 172366 | /* 236 */ "paren_exprlist ::= LP exprlist RP", |
| 171281 | /* 237 */ "uniqueflag ::=", | 172367 | /* 237 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 171282 | /* 238 */ "eidlist_opt ::=", | 172368 | /* 238 */ "uniqueflag ::= UNIQUE", |
| 171283 | /* 239 */ "eidlist_opt ::= LP eidlist RP", | 172369 | /* 239 */ "uniqueflag ::=", |
| 171284 | /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder", | 172370 | /* 240 */ "eidlist_opt ::=", |
| 171285 | /* 241 */ "eidlist ::= nm collate sortorder", | 172371 | /* 241 */ "eidlist_opt ::= LP eidlist RP", |
| 171286 | /* 242 */ "collate ::=", | 172372 | /* 242 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 171287 | /* 243 */ "collate ::= COLLATE ID|STRING", | 172373 | /* 243 */ "eidlist ::= nm collate sortorder", |
| 171288 | /* 244 */ "cmd ::= DROP INDEX ifexists fullname", | 172374 | /* 244 */ "collate ::=", |
| 171289 | /* 245 */ "cmd ::= VACUUM vinto", | 172375 | /* 245 */ "collate ::= COLLATE ID|STRING", |
| 171290 | /* 246 */ "cmd ::= VACUUM nm vinto", | 172376 | /* 246 */ "cmd ::= DROP INDEX ifexists fullname", |
| 171291 | /* 247 */ "vinto ::= INTO expr", | 172377 | /* 247 */ "cmd ::= VACUUM vinto", |
| 171292 | /* 248 */ "vinto ::=", | 172378 | /* 248 */ "cmd ::= VACUUM nm vinto", |
| 171293 | /* 249 */ "cmd ::= PRAGMA nm dbnm", | 172379 | /* 249 */ "vinto ::= INTO expr", |
| 171294 | /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", | 172380 | /* 250 */ "vinto ::=", |
| 171295 | /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", | 172381 | /* 251 */ "cmd ::= PRAGMA nm dbnm", |
| 171296 | /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", | 172382 | /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 171297 | /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", | 172383 | /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 171298 | /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT", | 172384 | /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 171299 | /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT", | 172385 | /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 171300 | /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", | 172386 | /* 256 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 171301 | /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", | 172387 | /* 257 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 171302 | /* 258 */ "trigger_time ::= BEFORE|AFTER", | 172388 | /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 171303 | /* 259 */ "trigger_time ::= INSTEAD OF", | 172389 | /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 171304 | /* 260 */ "trigger_time ::=", | 172390 | /* 260 */ "trigger_time ::= BEFORE|AFTER", |
| 171305 | /* 261 */ "trigger_event ::= DELETE|INSERT", | 172391 | /* 261 */ "trigger_time ::= INSTEAD OF", |
| 171306 | /* 262 */ "trigger_event ::= UPDATE", | 172392 | /* 262 */ "trigger_time ::=", |
| 171307 | /* 263 */ "trigger_event ::= UPDATE OF idlist", | 172393 | /* 263 */ "trigger_event ::= DELETE|INSERT", |
| 171308 | /* 264 */ "when_clause ::=", | 172394 | /* 264 */ "trigger_event ::= UPDATE", |
| 171309 | /* 265 */ "when_clause ::= WHEN expr", | 172395 | /* 265 */ "trigger_event ::= UPDATE OF idlist", |
| 171310 | /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", | 172396 | /* 266 */ "when_clause ::=", |
| 171311 | /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI", | 172397 | /* 267 */ "when_clause ::= WHEN expr", |
| 171312 | /* 268 */ "trnm ::= nm DOT nm", | 172398 | /* 268 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 171313 | /* 269 */ "tridxby ::= INDEXED BY nm", | 172399 | /* 269 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 171314 | /* 270 */ "tridxby ::= NOT INDEXED", | 172400 | /* 270 */ "trnm ::= nm DOT nm", |
| 171315 | /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", | 172401 | /* 271 */ "tridxby ::= INDEXED BY nm", |
| 171316 | /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", | 172402 | /* 272 */ "tridxby ::= NOT INDEXED", |
| 171317 | /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", | 172403 | /* 273 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 171318 | /* 274 */ "trigger_cmd ::= scanpt select scanpt", | 172404 | /* 274 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 171319 | /* 275 */ "expr ::= RAISE LP IGNORE RP", | 172405 | /* 275 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 171320 | /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP", | 172406 | /* 276 */ "trigger_cmd ::= scanpt select scanpt", |
| 171321 | /* 277 */ "raisetype ::= ROLLBACK", | 172407 | /* 277 */ "expr ::= RAISE LP IGNORE RP", |
| 171322 | /* 278 */ "raisetype ::= ABORT", | 172408 | /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 171323 | /* 279 */ "raisetype ::= FAIL", | 172409 | /* 279 */ "raisetype ::= ROLLBACK", |
| 171324 | /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname", | 172410 | /* 280 */ "raisetype ::= ABORT", |
| 171325 | /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", | 172411 | /* 281 */ "raisetype ::= FAIL", |
| 171326 | /* 282 */ "cmd ::= DETACH database_kw_opt expr", | 172412 | /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 171327 | /* 283 */ "key_opt ::=", | 172413 | /* 283 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 171328 | /* 284 */ "key_opt ::= KEY expr", | 172414 | /* 284 */ "cmd ::= DETACH database_kw_opt expr", |
| 171329 | /* 285 */ "cmd ::= REINDEX", | 172415 | /* 285 */ "key_opt ::=", |
| 171330 | /* 286 */ "cmd ::= REINDEX nm dbnm", | 172416 | /* 286 */ "key_opt ::= KEY expr", |
| 171331 | /* 287 */ "cmd ::= ANALYZE", | 172417 | /* 287 */ "cmd ::= REINDEX", |
| 171332 | /* 288 */ "cmd ::= ANALYZE nm dbnm", | 172418 | /* 288 */ "cmd ::= REINDEX nm dbnm", |
| 171333 | /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", | 172419 | /* 289 */ "cmd ::= ANALYZE", |
| 171334 | /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", | 172420 | /* 290 */ "cmd ::= ANALYZE nm dbnm", |
| 171335 | /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", | 172421 | /* 291 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 171336 | /* 292 */ "add_column_fullname ::= fullname", | 172422 | /* 292 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 171337 | /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", | 172423 | /* 293 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 171338 | /* 294 */ "cmd ::= create_vtab", | 172424 | /* 294 */ "add_column_fullname ::= fullname", |
| 171339 | /* 295 */ "cmd ::= create_vtab LP vtabarglist RP", | 172425 | /* 295 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 171340 | /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", | 172426 | /* 296 */ "cmd ::= create_vtab", |
| 171341 | /* 297 */ "vtabarg ::=", | 172427 | /* 297 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 171342 | /* 298 */ "vtabargtoken ::= ANY", | 172428 | /* 298 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 171343 | /* 299 */ "vtabargtoken ::= lp anylist RP", | 172429 | /* 299 */ "vtabarg ::=", |
| 171344 | /* 300 */ "lp ::= LP", | 172430 | /* 300 */ "vtabargtoken ::= ANY", |
| 171345 | /* 301 */ "with ::= WITH wqlist", | 172431 | /* 301 */ "vtabargtoken ::= lp anylist RP", |
| 171346 | /* 302 */ "with ::= WITH RECURSIVE wqlist", | 172432 | /* 302 */ "lp ::= LP", |
| 171347 | /* 303 */ "wqas ::= AS", | 172433 | /* 303 */ "with ::= WITH wqlist", |
| 171348 | /* 304 */ "wqas ::= AS MATERIALIZED", | 172434 | /* 304 */ "with ::= WITH RECURSIVE wqlist", |
| 171349 | /* 305 */ "wqas ::= AS NOT MATERIALIZED", | 172435 | /* 305 */ "wqas ::= AS", |
| 171350 | /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", | 172436 | /* 306 */ "wqas ::= AS MATERIALIZED", |
| 171351 | /* 307 */ "wqlist ::= wqitem", | 172437 | /* 307 */ "wqas ::= AS NOT MATERIALIZED", |
| 171352 | /* 308 */ "wqlist ::= wqlist COMMA wqitem", | 172438 | /* 308 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 171353 | /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", | 172439 | /* 309 */ "wqlist ::= wqitem", |
| 171354 | /* 310 */ "windowdefn ::= nm AS LP window RP", | 172440 | /* 310 */ "wqlist ::= wqlist COMMA wqitem", |
| 171355 | /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", | 172441 | /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 171356 | /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", | 172442 | /* 312 */ "windowdefn ::= nm AS LP window RP", |
| 171357 | /* 313 */ "window ::= ORDER BY sortlist frame_opt", | 172443 | /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 171358 | /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", | 172444 | /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 171359 | /* 315 */ "window ::= nm frame_opt", | 172445 | /* 315 */ "window ::= ORDER BY sortlist frame_opt", |
| 171360 | /* 316 */ "frame_opt ::=", | 172446 | /* 316 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 171361 | /* 317 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", | 172447 | /* 317 */ "window ::= nm frame_opt", |
| 171362 | /* 318 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", | 172448 | /* 318 */ "frame_opt ::=", |
| 171363 | /* 319 */ "range_or_rows ::= RANGE|ROWS|GROUPS", | 172449 | /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 171364 | /* 320 */ "frame_bound_s ::= frame_bound", | 172450 | /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 171365 | /* 321 */ "frame_bound_s ::= UNBOUNDED PRECEDING", | 172451 | /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 171366 | /* 322 */ "frame_bound_e ::= frame_bound", | 172452 | /* 322 */ "frame_bound_s ::= frame_bound", |
| 171367 | /* 323 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", | 172453 | /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 171368 | /* 324 */ "frame_bound ::= expr PRECEDING|FOLLOWING", | 172454 | /* 324 */ "frame_bound_e ::= frame_bound", |
| 171369 | /* 325 */ "frame_bound ::= CURRENT ROW", | 172455 | /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 171370 | /* 326 */ "frame_exclude_opt ::=", | 172456 | /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 171371 | /* 327 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", | 172457 | /* 327 */ "frame_bound ::= CURRENT ROW", |
| 171372 | /* 328 */ "frame_exclude ::= NO OTHERS", | 172458 | /* 328 */ "frame_exclude_opt ::=", |
| 171373 | /* 329 */ "frame_exclude ::= CURRENT ROW", | 172459 | /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 171374 | /* 330 */ "frame_exclude ::= GROUP|TIES", | 172460 | /* 330 */ "frame_exclude ::= NO OTHERS", |
| 171375 | /* 331 */ "window_clause ::= WINDOW windowdefn_list", | 172461 | /* 331 */ "frame_exclude ::= CURRENT ROW", |
| 171376 | /* 332 */ "filter_over ::= filter_clause over_clause", | 172462 | /* 332 */ "frame_exclude ::= GROUP|TIES", |
| 171377 | /* 333 */ "filter_over ::= over_clause", | 172463 | /* 333 */ "window_clause ::= WINDOW windowdefn_list", |
| 171378 | /* 334 */ "filter_over ::= filter_clause", | 172464 | /* 334 */ "filter_over ::= filter_clause over_clause", |
| 171379 | /* 335 */ "over_clause ::= OVER LP window RP", | 172465 | /* 335 */ "filter_over ::= over_clause", |
| 171380 | /* 336 */ "over_clause ::= OVER nm", | 172466 | /* 336 */ "filter_over ::= filter_clause", |
| 171381 | /* 337 */ "filter_clause ::= FILTER LP WHERE expr RP", | 172467 | /* 337 */ "over_clause ::= OVER LP window RP", |
| 171382 | /* 338 */ "input ::= cmdlist", | 172468 | /* 338 */ "over_clause ::= OVER nm", |
| 171383 | /* 339 */ "cmdlist ::= cmdlist ecmd", | 172469 | /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 171384 | /* 340 */ "cmdlist ::= ecmd", | 172470 | /* 340 */ "input ::= cmdlist", |
| 171385 | /* 341 */ "ecmd ::= SEMI", | 172471 | /* 341 */ "cmdlist ::= cmdlist ecmd", |
| 171386 | /* 342 */ "ecmd ::= cmdx SEMI", | 172472 | /* 342 */ "cmdlist ::= ecmd", |
| 171387 | /* 343 */ "ecmd ::= explain cmdx SEMI", | 172473 | /* 343 */ "ecmd ::= SEMI", |
| 171388 | /* 344 */ "trans_opt ::=", | 172474 | /* 344 */ "ecmd ::= cmdx SEMI", |
| 171389 | /* 345 */ "trans_opt ::= TRANSACTION", | 172475 | /* 345 */ "ecmd ::= explain cmdx SEMI", |
| 171390 | /* 346 */ "trans_opt ::= TRANSACTION nm", | 172476 | /* 346 */ "trans_opt ::=", |
| 171391 | /* 347 */ "savepoint_opt ::= SAVEPOINT", | 172477 | /* 347 */ "trans_opt ::= TRANSACTION", |
| 171392 | /* 348 */ "savepoint_opt ::=", | 172478 | /* 348 */ "trans_opt ::= TRANSACTION nm", |
| 171393 | /* 349 */ "cmd ::= create_table create_table_args", | 172479 | /* 349 */ "savepoint_opt ::= SAVEPOINT", |
| 171394 | /* 350 */ "table_option_set ::= table_option", | 172480 | /* 350 */ "savepoint_opt ::=", |
| 171395 | /* 351 */ "columnlist ::= columnlist COMMA columnname carglist", | 172481 | /* 351 */ "cmd ::= create_table create_table_args", |
| 171396 | /* 352 */ "columnlist ::= columnname carglist", | 172482 | /* 352 */ "table_option_set ::= table_option", |
| 171397 | /* 353 */ "nm ::= ID|INDEXED|JOIN_KW", | 172483 | /* 353 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 171398 | /* 354 */ "nm ::= STRING", | 172484 | /* 354 */ "columnlist ::= columnname carglist", |
| 171399 | /* 355 */ "typetoken ::= typename", | 172485 | /* 355 */ "nm ::= ID|INDEXED|JOIN_KW", |
| 171400 | /* 356 */ "typename ::= ID|STRING", | 172486 | /* 356 */ "nm ::= STRING", |
| 171401 | /* 357 */ "signed ::= plus_num", | 172487 | /* 357 */ "typetoken ::= typename", |
| 171402 | /* 358 */ "signed ::= minus_num", | 172488 | /* 358 */ "typename ::= ID|STRING", |
| 171403 | /* 359 */ "carglist ::= carglist ccons", | 172489 | /* 359 */ "signed ::= plus_num", |
| 171404 | /* 360 */ "carglist ::=", | 172490 | /* 360 */ "signed ::= minus_num", |
| 171405 | /* 361 */ "ccons ::= NULL onconf", | 172491 | /* 361 */ "carglist ::= carglist ccons", |
| 171406 | /* 362 */ "ccons ::= GENERATED ALWAYS AS generated", | 172492 | /* 362 */ "carglist ::=", |
| 171407 | /* 363 */ "ccons ::= AS generated", | 172493 | /* 363 */ "ccons ::= NULL onconf", |
| 171408 | /* 364 */ "conslist_opt ::= COMMA conslist", | 172494 | /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 171409 | /* 365 */ "conslist ::= conslist tconscomma tcons", | 172495 | /* 365 */ "ccons ::= AS generated", |
| 171410 | /* 366 */ "conslist ::= tcons", | 172496 | /* 366 */ "conslist_opt ::= COMMA conslist", |
| 171411 | /* 367 */ "tconscomma ::=", | 172497 | /* 367 */ "conslist ::= conslist tconscomma tcons", |
| 171412 | /* 368 */ "defer_subclause_opt ::= defer_subclause", | 172498 | /* 368 */ "conslist ::= tcons", |
| 171413 | /* 369 */ "resolvetype ::= raisetype", | 172499 | /* 369 */ "tconscomma ::=", |
| 171414 | /* 370 */ "selectnowith ::= oneselect", | 172500 | /* 370 */ "defer_subclause_opt ::= defer_subclause", |
| 171415 | /* 371 */ "oneselect ::= values", | 172501 | /* 371 */ "resolvetype ::= raisetype", |
| 171416 | /* 372 */ "sclp ::= selcollist COMMA", | 172502 | /* 372 */ "selectnowith ::= oneselect", |
| 171417 | /* 373 */ "as ::= ID|STRING", | 172503 | /* 373 */ "oneselect ::= values", |
| 171418 | /* 374 */ "indexed_opt ::= indexed_by", | 172504 | /* 374 */ "sclp ::= selcollist COMMA", |
| 171419 | /* 375 */ "returning ::=", | 172505 | /* 375 */ "as ::= ID|STRING", |
| 171420 | /* 376 */ "expr ::= term", | 172506 | /* 376 */ "indexed_opt ::= indexed_by", |
| 171421 | /* 377 */ "likeop ::= LIKE_KW|MATCH", | 172507 | /* 377 */ "returning ::=", |
| 171422 | /* 378 */ "case_operand ::= expr", | 172508 | /* 378 */ "expr ::= term", |
| 171423 | /* 379 */ "exprlist ::= nexprlist", | 172509 | /* 379 */ "likeop ::= LIKE_KW|MATCH", |
| 171424 | /* 380 */ "nmnum ::= plus_num", | 172510 | /* 380 */ "case_operand ::= expr", |
| 171425 | /* 381 */ "nmnum ::= nm", | 172511 | /* 381 */ "exprlist ::= nexprlist", |
| 171426 | /* 382 */ "nmnum ::= ON", | 172512 | /* 382 */ "nmnum ::= plus_num", |
| 171427 | /* 383 */ "nmnum ::= DELETE", | 172513 | /* 383 */ "nmnum ::= nm", |
| 171428 | /* 384 */ "nmnum ::= DEFAULT", | 172514 | /* 384 */ "nmnum ::= ON", |
| 171429 | /* 385 */ "plus_num ::= INTEGER|FLOAT", | 172515 | /* 385 */ "nmnum ::= DELETE", |
| 171430 | /* 386 */ "foreach_clause ::=", | 172516 | /* 386 */ "nmnum ::= DEFAULT", |
| 171431 | /* 387 */ "foreach_clause ::= FOR EACH ROW", | 172517 | /* 387 */ "plus_num ::= INTEGER|FLOAT", |
| 171432 | /* 388 */ "trnm ::= nm", | 172518 | /* 388 */ "foreach_clause ::=", |
| 171433 | /* 389 */ "tridxby ::=", | 172519 | /* 389 */ "foreach_clause ::= FOR EACH ROW", |
| 171434 | /* 390 */ "database_kw_opt ::= DATABASE", | 172520 | /* 390 */ "trnm ::= nm", |
| 171435 | /* 391 */ "database_kw_opt ::=", | 172521 | /* 391 */ "tridxby ::=", |
| 171436 | /* 392 */ "kwcolumn_opt ::=", | 172522 | /* 392 */ "database_kw_opt ::= DATABASE", |
| 171437 | /* 393 */ "kwcolumn_opt ::= COLUMNKW", | 172523 | /* 393 */ "database_kw_opt ::=", |
| 171438 | /* 394 */ "vtabarglist ::= vtabarg", | 172524 | /* 394 */ "kwcolumn_opt ::=", |
| 171439 | /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", | 172525 | /* 395 */ "kwcolumn_opt ::= COLUMNKW", |
| 171440 | /* 396 */ "vtabarg ::= vtabarg vtabargtoken", | 172526 | /* 396 */ "vtabarglist ::= vtabarg", |
| 171441 | /* 397 */ "anylist ::=", | 172527 | /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 171442 | /* 398 */ "anylist ::= anylist LP anylist RP", | 172528 | /* 398 */ "vtabarg ::= vtabarg vtabargtoken", |
| 171443 | /* 399 */ "anylist ::= anylist ANY", | 172529 | /* 399 */ "anylist ::=", |
| 171444 | /* 400 */ "with ::=", | 172530 | /* 400 */ "anylist ::= anylist LP anylist RP", |
| 171445 | /* 401 */ "windowdefn_list ::= windowdefn", | 172531 | /* 401 */ "anylist ::= anylist ANY", |
| 171446 | /* 402 */ "window ::= frame_opt", | 172532 | /* 402 */ "with ::=", |
| 172533 | /* 403 */ "windowdefn_list ::= windowdefn", | ||
| 172534 | /* 404 */ "window ::= frame_opt", | ||
| 171447 | }; | 172535 | }; |
| 171448 | #endif /* NDEBUG */ | 172536 | #endif /* NDEBUG */ |
| 171449 | 172537 | ||
| @@ -172138,221 +173226,223 @@ static const YYCODETYPE yyRuleInfoLhs[] = { | |||
| 172138 | 217, /* (185) expr ::= expr COLLATE ID|STRING */ | 173226 | 217, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 172139 | 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ | 173227 | 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 172140 | 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ | 173228 | 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 172141 | 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | 173229 | 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 172142 | 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | 173230 | 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 172143 | 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | 173231 | 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 172144 | 216, /* (191) term ::= CTIME_KW */ | 173232 | 217, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 172145 | 217, /* (192) expr ::= LP nexprlist COMMA expr RP */ | 173233 | 217, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 172146 | 217, /* (193) expr ::= expr AND expr */ | 173234 | 216, /* (193) term ::= CTIME_KW */ |
| 172147 | 217, /* (194) expr ::= expr OR expr */ | 173235 | 217, /* (194) expr ::= LP nexprlist COMMA expr RP */ |
| 172148 | 217, /* (195) expr ::= expr LT|GT|GE|LE expr */ | 173236 | 217, /* (195) expr ::= expr AND expr */ |
| 172149 | 217, /* (196) expr ::= expr EQ|NE expr */ | 173237 | 217, /* (196) expr ::= expr OR expr */ |
| 172150 | 217, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 173238 | 217, /* (197) expr ::= expr LT|GT|GE|LE expr */ |
| 172151 | 217, /* (198) expr ::= expr PLUS|MINUS expr */ | 173239 | 217, /* (198) expr ::= expr EQ|NE expr */ |
| 172152 | 217, /* (199) expr ::= expr STAR|SLASH|REM expr */ | 173240 | 217, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 172153 | 217, /* (200) expr ::= expr CONCAT expr */ | 173241 | 217, /* (200) expr ::= expr PLUS|MINUS expr */ |
| 172154 | 274, /* (201) likeop ::= NOT LIKE_KW|MATCH */ | 173242 | 217, /* (201) expr ::= expr STAR|SLASH|REM expr */ |
| 172155 | 217, /* (202) expr ::= expr likeop expr */ | 173243 | 217, /* (202) expr ::= expr CONCAT expr */ |
| 172156 | 217, /* (203) expr ::= expr likeop expr ESCAPE expr */ | 173244 | 274, /* (203) likeop ::= NOT LIKE_KW|MATCH */ |
| 172157 | 217, /* (204) expr ::= expr ISNULL|NOTNULL */ | 173245 | 217, /* (204) expr ::= expr likeop expr */ |
| 172158 | 217, /* (205) expr ::= expr NOT NULL */ | 173246 | 217, /* (205) expr ::= expr likeop expr ESCAPE expr */ |
| 172159 | 217, /* (206) expr ::= expr IS expr */ | 173247 | 217, /* (206) expr ::= expr ISNULL|NOTNULL */ |
| 172160 | 217, /* (207) expr ::= expr IS NOT expr */ | 173248 | 217, /* (207) expr ::= expr NOT NULL */ |
| 172161 | 217, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ | 173249 | 217, /* (208) expr ::= expr IS expr */ |
| 172162 | 217, /* (209) expr ::= expr IS DISTINCT FROM expr */ | 173250 | 217, /* (209) expr ::= expr IS NOT expr */ |
| 172163 | 217, /* (210) expr ::= NOT expr */ | 173251 | 217, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ |
| 172164 | 217, /* (211) expr ::= BITNOT expr */ | 173252 | 217, /* (211) expr ::= expr IS DISTINCT FROM expr */ |
| 172165 | 217, /* (212) expr ::= PLUS|MINUS expr */ | 173253 | 217, /* (212) expr ::= NOT expr */ |
| 172166 | 217, /* (213) expr ::= expr PTR expr */ | 173254 | 217, /* (213) expr ::= BITNOT expr */ |
| 172167 | 275, /* (214) between_op ::= BETWEEN */ | 173255 | 217, /* (214) expr ::= PLUS|MINUS expr */ |
| 172168 | 275, /* (215) between_op ::= NOT BETWEEN */ | 173256 | 217, /* (215) expr ::= expr PTR expr */ |
| 172169 | 217, /* (216) expr ::= expr between_op expr AND expr */ | 173257 | 275, /* (216) between_op ::= BETWEEN */ |
| 172170 | 276, /* (217) in_op ::= IN */ | 173258 | 275, /* (217) between_op ::= NOT BETWEEN */ |
| 172171 | 276, /* (218) in_op ::= NOT IN */ | 173259 | 217, /* (218) expr ::= expr between_op expr AND expr */ |
| 172172 | 217, /* (219) expr ::= expr in_op LP exprlist RP */ | 173260 | 276, /* (219) in_op ::= IN */ |
| 172173 | 217, /* (220) expr ::= LP select RP */ | 173261 | 276, /* (220) in_op ::= NOT IN */ |
| 172174 | 217, /* (221) expr ::= expr in_op LP select RP */ | 173262 | 217, /* (221) expr ::= expr in_op LP exprlist RP */ |
| 172175 | 217, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ | 173263 | 217, /* (222) expr ::= LP select RP */ |
| 172176 | 217, /* (223) expr ::= EXISTS LP select RP */ | 173264 | 217, /* (223) expr ::= expr in_op LP select RP */ |
| 172177 | 217, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ | 173265 | 217, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 172178 | 279, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 173266 | 217, /* (225) expr ::= EXISTS LP select RP */ |
| 172179 | 279, /* (226) case_exprlist ::= WHEN expr THEN expr */ | 173267 | 217, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ |
| 172180 | 280, /* (227) case_else ::= ELSE expr */ | 173268 | 279, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 172181 | 280, /* (228) case_else ::= */ | 173269 | 279, /* (228) case_exprlist ::= WHEN expr THEN expr */ |
| 172182 | 278, /* (229) case_operand ::= */ | 173270 | 280, /* (229) case_else ::= ELSE expr */ |
| 172183 | 261, /* (230) exprlist ::= */ | 173271 | 280, /* (230) case_else ::= */ |
| 172184 | 253, /* (231) nexprlist ::= nexprlist COMMA expr */ | 173272 | 278, /* (231) case_operand ::= */ |
| 172185 | 253, /* (232) nexprlist ::= expr */ | 173273 | 261, /* (232) exprlist ::= */ |
| 172186 | 277, /* (233) paren_exprlist ::= */ | 173274 | 253, /* (233) nexprlist ::= nexprlist COMMA expr */ |
| 172187 | 277, /* (234) paren_exprlist ::= LP exprlist RP */ | 173275 | 253, /* (234) nexprlist ::= expr */ |
| 172188 | 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 173276 | 277, /* (235) paren_exprlist ::= */ |
| 172189 | 281, /* (236) uniqueflag ::= UNIQUE */ | 173277 | 277, /* (236) paren_exprlist ::= LP exprlist RP */ |
| 172190 | 281, /* (237) uniqueflag ::= */ | 173278 | 190, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 172191 | 221, /* (238) eidlist_opt ::= */ | 173279 | 281, /* (238) uniqueflag ::= UNIQUE */ |
| 172192 | 221, /* (239) eidlist_opt ::= LP eidlist RP */ | 173280 | 281, /* (239) uniqueflag ::= */ |
| 172193 | 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ | 173281 | 221, /* (240) eidlist_opt ::= */ |
| 172194 | 232, /* (241) eidlist ::= nm collate sortorder */ | 173282 | 221, /* (241) eidlist_opt ::= LP eidlist RP */ |
| 172195 | 282, /* (242) collate ::= */ | 173283 | 232, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 172196 | 282, /* (243) collate ::= COLLATE ID|STRING */ | 173284 | 232, /* (243) eidlist ::= nm collate sortorder */ |
| 172197 | 190, /* (244) cmd ::= DROP INDEX ifexists fullname */ | 173285 | 282, /* (244) collate ::= */ |
| 172198 | 190, /* (245) cmd ::= VACUUM vinto */ | 173286 | 282, /* (245) collate ::= COLLATE ID|STRING */ |
| 172199 | 190, /* (246) cmd ::= VACUUM nm vinto */ | 173287 | 190, /* (246) cmd ::= DROP INDEX ifexists fullname */ |
| 172200 | 283, /* (247) vinto ::= INTO expr */ | 173288 | 190, /* (247) cmd ::= VACUUM vinto */ |
| 172201 | 283, /* (248) vinto ::= */ | 173289 | 190, /* (248) cmd ::= VACUUM nm vinto */ |
| 172202 | 190, /* (249) cmd ::= PRAGMA nm dbnm */ | 173290 | 283, /* (249) vinto ::= INTO expr */ |
| 172203 | 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 173291 | 283, /* (250) vinto ::= */ |
| 172204 | 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 173292 | 190, /* (251) cmd ::= PRAGMA nm dbnm */ |
| 172205 | 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 173293 | 190, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 172206 | 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 173294 | 190, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 172207 | 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ | 173295 | 190, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 172208 | 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ | 173296 | 190, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 172209 | 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 173297 | 211, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ |
| 172210 | 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 173298 | 212, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ |
| 172211 | 287, /* (258) trigger_time ::= BEFORE|AFTER */ | 173299 | 190, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 172212 | 287, /* (259) trigger_time ::= INSTEAD OF */ | 173300 | 285, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 172213 | 287, /* (260) trigger_time ::= */ | 173301 | 287, /* (260) trigger_time ::= BEFORE|AFTER */ |
| 172214 | 288, /* (261) trigger_event ::= DELETE|INSERT */ | 173302 | 287, /* (261) trigger_time ::= INSTEAD OF */ |
| 172215 | 288, /* (262) trigger_event ::= UPDATE */ | 173303 | 287, /* (262) trigger_time ::= */ |
| 172216 | 288, /* (263) trigger_event ::= UPDATE OF idlist */ | 173304 | 288, /* (263) trigger_event ::= DELETE|INSERT */ |
| 172217 | 290, /* (264) when_clause ::= */ | 173305 | 288, /* (264) trigger_event ::= UPDATE */ |
| 172218 | 290, /* (265) when_clause ::= WHEN expr */ | 173306 | 288, /* (265) trigger_event ::= UPDATE OF idlist */ |
| 172219 | 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 173307 | 290, /* (266) when_clause ::= */ |
| 172220 | 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ | 173308 | 290, /* (267) when_clause ::= WHEN expr */ |
| 172221 | 292, /* (268) trnm ::= nm DOT nm */ | 173309 | 286, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 172222 | 293, /* (269) tridxby ::= INDEXED BY nm */ | 173310 | 286, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 172223 | 293, /* (270) tridxby ::= NOT INDEXED */ | 173311 | 292, /* (270) trnm ::= nm DOT nm */ |
| 172224 | 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 173312 | 293, /* (271) tridxby ::= INDEXED BY nm */ |
| 172225 | 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 173313 | 293, /* (272) tridxby ::= NOT INDEXED */ |
| 172226 | 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 173314 | 291, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 172227 | 291, /* (274) trigger_cmd ::= scanpt select scanpt */ | 173315 | 291, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 172228 | 217, /* (275) expr ::= RAISE LP IGNORE RP */ | 173316 | 291, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 172229 | 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ | 173317 | 291, /* (276) trigger_cmd ::= scanpt select scanpt */ |
| 172230 | 236, /* (277) raisetype ::= ROLLBACK */ | 173318 | 217, /* (277) expr ::= RAISE LP IGNORE RP */ |
| 172231 | 236, /* (278) raisetype ::= ABORT */ | 173319 | 217, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 172232 | 236, /* (279) raisetype ::= FAIL */ | 173320 | 236, /* (279) raisetype ::= ROLLBACK */ |
| 172233 | 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ | 173321 | 236, /* (280) raisetype ::= ABORT */ |
| 172234 | 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 173322 | 236, /* (281) raisetype ::= FAIL */ |
| 172235 | 190, /* (282) cmd ::= DETACH database_kw_opt expr */ | 173323 | 190, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ |
| 172236 | 295, /* (283) key_opt ::= */ | 173324 | 190, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 172237 | 295, /* (284) key_opt ::= KEY expr */ | 173325 | 190, /* (284) cmd ::= DETACH database_kw_opt expr */ |
| 172238 | 190, /* (285) cmd ::= REINDEX */ | 173326 | 295, /* (285) key_opt ::= */ |
| 172239 | 190, /* (286) cmd ::= REINDEX nm dbnm */ | 173327 | 295, /* (286) key_opt ::= KEY expr */ |
| 172240 | 190, /* (287) cmd ::= ANALYZE */ | 173328 | 190, /* (287) cmd ::= REINDEX */ |
| 172241 | 190, /* (288) cmd ::= ANALYZE nm dbnm */ | 173329 | 190, /* (288) cmd ::= REINDEX nm dbnm */ |
| 172242 | 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 173330 | 190, /* (289) cmd ::= ANALYZE */ |
| 172243 | 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 173331 | 190, /* (290) cmd ::= ANALYZE nm dbnm */ |
| 172244 | 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 173332 | 190, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 172245 | 296, /* (292) add_column_fullname ::= fullname */ | 173333 | 190, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 172246 | 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 173334 | 190, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 172247 | 190, /* (294) cmd ::= create_vtab */ | 173335 | 296, /* (294) add_column_fullname ::= fullname */ |
| 172248 | 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */ | 173336 | 190, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 172249 | 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 173337 | 190, /* (296) cmd ::= create_vtab */ |
| 172250 | 300, /* (297) vtabarg ::= */ | 173338 | 190, /* (297) cmd ::= create_vtab LP vtabarglist RP */ |
| 172251 | 301, /* (298) vtabargtoken ::= ANY */ | 173339 | 298, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 172252 | 301, /* (299) vtabargtoken ::= lp anylist RP */ | 173340 | 300, /* (299) vtabarg ::= */ |
| 172253 | 302, /* (300) lp ::= LP */ | 173341 | 301, /* (300) vtabargtoken ::= ANY */ |
| 172254 | 266, /* (301) with ::= WITH wqlist */ | 173342 | 301, /* (301) vtabargtoken ::= lp anylist RP */ |
| 172255 | 266, /* (302) with ::= WITH RECURSIVE wqlist */ | 173343 | 302, /* (302) lp ::= LP */ |
| 172256 | 305, /* (303) wqas ::= AS */ | 173344 | 266, /* (303) with ::= WITH wqlist */ |
| 172257 | 305, /* (304) wqas ::= AS MATERIALIZED */ | 173345 | 266, /* (304) with ::= WITH RECURSIVE wqlist */ |
| 172258 | 305, /* (305) wqas ::= AS NOT MATERIALIZED */ | 173346 | 305, /* (305) wqas ::= AS */ |
| 172259 | 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ | 173347 | 305, /* (306) wqas ::= AS MATERIALIZED */ |
| 172260 | 241, /* (307) wqlist ::= wqitem */ | 173348 | 305, /* (307) wqas ::= AS NOT MATERIALIZED */ |
| 172261 | 241, /* (308) wqlist ::= wqlist COMMA wqitem */ | 173349 | 304, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 172262 | 306, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 173350 | 241, /* (309) wqlist ::= wqitem */ |
| 172263 | 307, /* (310) windowdefn ::= nm AS LP window RP */ | 173351 | 241, /* (310) wqlist ::= wqlist COMMA wqitem */ |
| 172264 | 308, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 173352 | 306, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 172265 | 308, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 173353 | 307, /* (312) windowdefn ::= nm AS LP window RP */ |
| 172266 | 308, /* (313) window ::= ORDER BY sortlist frame_opt */ | 173354 | 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172267 | 308, /* (314) window ::= nm ORDER BY sortlist frame_opt */ | 173355 | 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172268 | 308, /* (315) window ::= nm frame_opt */ | 173356 | 308, /* (315) window ::= ORDER BY sortlist frame_opt */ |
| 172269 | 309, /* (316) frame_opt ::= */ | 173357 | 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */ |
| 172270 | 309, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 173358 | 308, /* (317) window ::= nm frame_opt */ |
| 172271 | 309, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 173359 | 309, /* (318) frame_opt ::= */ |
| 172272 | 313, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ | 173360 | 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 172273 | 315, /* (320) frame_bound_s ::= frame_bound */ | 173361 | 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 172274 | 315, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ | 173362 | 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 172275 | 316, /* (322) frame_bound_e ::= frame_bound */ | 173363 | 315, /* (322) frame_bound_s ::= frame_bound */ |
| 172276 | 316, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 173364 | 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 172277 | 314, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ | 173365 | 316, /* (324) frame_bound_e ::= frame_bound */ |
| 172278 | 314, /* (325) frame_bound ::= CURRENT ROW */ | 173366 | 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 172279 | 317, /* (326) frame_exclude_opt ::= */ | 173367 | 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 172280 | 317, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 173368 | 314, /* (327) frame_bound ::= CURRENT ROW */ |
| 172281 | 318, /* (328) frame_exclude ::= NO OTHERS */ | 173369 | 317, /* (328) frame_exclude_opt ::= */ |
| 172282 | 318, /* (329) frame_exclude ::= CURRENT ROW */ | 173370 | 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 172283 | 318, /* (330) frame_exclude ::= GROUP|TIES */ | 173371 | 318, /* (330) frame_exclude ::= NO OTHERS */ |
| 172284 | 251, /* (331) window_clause ::= WINDOW windowdefn_list */ | 173372 | 318, /* (331) frame_exclude ::= CURRENT ROW */ |
| 172285 | 273, /* (332) filter_over ::= filter_clause over_clause */ | 173373 | 318, /* (332) frame_exclude ::= GROUP|TIES */ |
| 172286 | 273, /* (333) filter_over ::= over_clause */ | 173374 | 251, /* (333) window_clause ::= WINDOW windowdefn_list */ |
| 172287 | 273, /* (334) filter_over ::= filter_clause */ | 173375 | 273, /* (334) filter_over ::= filter_clause over_clause */ |
| 172288 | 312, /* (335) over_clause ::= OVER LP window RP */ | 173376 | 273, /* (335) filter_over ::= over_clause */ |
| 172289 | 312, /* (336) over_clause ::= OVER nm */ | 173377 | 273, /* (336) filter_over ::= filter_clause */ |
| 172290 | 311, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ | 173378 | 312, /* (337) over_clause ::= OVER LP window RP */ |
| 172291 | 185, /* (338) input ::= cmdlist */ | 173379 | 312, /* (338) over_clause ::= OVER nm */ |
| 172292 | 186, /* (339) cmdlist ::= cmdlist ecmd */ | 173380 | 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ |
| 172293 | 186, /* (340) cmdlist ::= ecmd */ | 173381 | 185, /* (340) input ::= cmdlist */ |
| 172294 | 187, /* (341) ecmd ::= SEMI */ | 173382 | 186, /* (341) cmdlist ::= cmdlist ecmd */ |
| 172295 | 187, /* (342) ecmd ::= cmdx SEMI */ | 173383 | 186, /* (342) cmdlist ::= ecmd */ |
| 172296 | 187, /* (343) ecmd ::= explain cmdx SEMI */ | 173384 | 187, /* (343) ecmd ::= SEMI */ |
| 172297 | 192, /* (344) trans_opt ::= */ | 173385 | 187, /* (344) ecmd ::= cmdx SEMI */ |
| 172298 | 192, /* (345) trans_opt ::= TRANSACTION */ | 173386 | 187, /* (345) ecmd ::= explain cmdx SEMI */ |
| 172299 | 192, /* (346) trans_opt ::= TRANSACTION nm */ | 173387 | 192, /* (346) trans_opt ::= */ |
| 172300 | 194, /* (347) savepoint_opt ::= SAVEPOINT */ | 173388 | 192, /* (347) trans_opt ::= TRANSACTION */ |
| 172301 | 194, /* (348) savepoint_opt ::= */ | 173389 | 192, /* (348) trans_opt ::= TRANSACTION nm */ |
| 172302 | 190, /* (349) cmd ::= create_table create_table_args */ | 173390 | 194, /* (349) savepoint_opt ::= SAVEPOINT */ |
| 172303 | 203, /* (350) table_option_set ::= table_option */ | 173391 | 194, /* (350) savepoint_opt ::= */ |
| 172304 | 201, /* (351) columnlist ::= columnlist COMMA columnname carglist */ | 173392 | 190, /* (351) cmd ::= create_table create_table_args */ |
| 172305 | 201, /* (352) columnlist ::= columnname carglist */ | 173393 | 203, /* (352) table_option_set ::= table_option */ |
| 172306 | 193, /* (353) nm ::= ID|INDEXED|JOIN_KW */ | 173394 | 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */ |
| 172307 | 193, /* (354) nm ::= STRING */ | 173395 | 201, /* (354) columnlist ::= columnname carglist */ |
| 172308 | 208, /* (355) typetoken ::= typename */ | 173396 | 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */ |
| 172309 | 209, /* (356) typename ::= ID|STRING */ | 173397 | 193, /* (356) nm ::= STRING */ |
| 172310 | 210, /* (357) signed ::= plus_num */ | 173398 | 208, /* (357) typetoken ::= typename */ |
| 172311 | 210, /* (358) signed ::= minus_num */ | 173399 | 209, /* (358) typename ::= ID|STRING */ |
| 172312 | 207, /* (359) carglist ::= carglist ccons */ | 173400 | 210, /* (359) signed ::= plus_num */ |
| 172313 | 207, /* (360) carglist ::= */ | 173401 | 210, /* (360) signed ::= minus_num */ |
| 172314 | 215, /* (361) ccons ::= NULL onconf */ | 173402 | 207, /* (361) carglist ::= carglist ccons */ |
| 172315 | 215, /* (362) ccons ::= GENERATED ALWAYS AS generated */ | 173403 | 207, /* (362) carglist ::= */ |
| 172316 | 215, /* (363) ccons ::= AS generated */ | 173404 | 215, /* (363) ccons ::= NULL onconf */ |
| 172317 | 202, /* (364) conslist_opt ::= COMMA conslist */ | 173405 | 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 172318 | 228, /* (365) conslist ::= conslist tconscomma tcons */ | 173406 | 215, /* (365) ccons ::= AS generated */ |
| 172319 | 228, /* (366) conslist ::= tcons */ | 173407 | 202, /* (366) conslist_opt ::= COMMA conslist */ |
| 172320 | 229, /* (367) tconscomma ::= */ | 173408 | 228, /* (367) conslist ::= conslist tconscomma tcons */ |
| 172321 | 233, /* (368) defer_subclause_opt ::= defer_subclause */ | 173409 | 228, /* (368) conslist ::= tcons */ |
| 172322 | 235, /* (369) resolvetype ::= raisetype */ | 173410 | 229, /* (369) tconscomma ::= */ |
| 172323 | 239, /* (370) selectnowith ::= oneselect */ | 173411 | 233, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 172324 | 240, /* (371) oneselect ::= values */ | 173412 | 235, /* (371) resolvetype ::= raisetype */ |
| 172325 | 254, /* (372) sclp ::= selcollist COMMA */ | 173413 | 239, /* (372) selectnowith ::= oneselect */ |
| 172326 | 255, /* (373) as ::= ID|STRING */ | 173414 | 240, /* (373) oneselect ::= values */ |
| 172327 | 264, /* (374) indexed_opt ::= indexed_by */ | 173415 | 254, /* (374) sclp ::= selcollist COMMA */ |
| 172328 | 272, /* (375) returning ::= */ | 173416 | 255, /* (375) as ::= ID|STRING */ |
| 172329 | 217, /* (376) expr ::= term */ | 173417 | 264, /* (376) indexed_opt ::= indexed_by */ |
| 172330 | 274, /* (377) likeop ::= LIKE_KW|MATCH */ | 173418 | 272, /* (377) returning ::= */ |
| 172331 | 278, /* (378) case_operand ::= expr */ | 173419 | 217, /* (378) expr ::= term */ |
| 172332 | 261, /* (379) exprlist ::= nexprlist */ | 173420 | 274, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 172333 | 284, /* (380) nmnum ::= plus_num */ | 173421 | 278, /* (380) case_operand ::= expr */ |
| 172334 | 284, /* (381) nmnum ::= nm */ | 173422 | 261, /* (381) exprlist ::= nexprlist */ |
| 172335 | 284, /* (382) nmnum ::= ON */ | 173423 | 284, /* (382) nmnum ::= plus_num */ |
| 172336 | 284, /* (383) nmnum ::= DELETE */ | 173424 | 284, /* (383) nmnum ::= nm */ |
| 172337 | 284, /* (384) nmnum ::= DEFAULT */ | 173425 | 284, /* (384) nmnum ::= ON */ |
| 172338 | 211, /* (385) plus_num ::= INTEGER|FLOAT */ | 173426 | 284, /* (385) nmnum ::= DELETE */ |
| 172339 | 289, /* (386) foreach_clause ::= */ | 173427 | 284, /* (386) nmnum ::= DEFAULT */ |
| 172340 | 289, /* (387) foreach_clause ::= FOR EACH ROW */ | 173428 | 211, /* (387) plus_num ::= INTEGER|FLOAT */ |
| 172341 | 292, /* (388) trnm ::= nm */ | 173429 | 289, /* (388) foreach_clause ::= */ |
| 172342 | 293, /* (389) tridxby ::= */ | 173430 | 289, /* (389) foreach_clause ::= FOR EACH ROW */ |
| 172343 | 294, /* (390) database_kw_opt ::= DATABASE */ | 173431 | 292, /* (390) trnm ::= nm */ |
| 172344 | 294, /* (391) database_kw_opt ::= */ | 173432 | 293, /* (391) tridxby ::= */ |
| 172345 | 297, /* (392) kwcolumn_opt ::= */ | 173433 | 294, /* (392) database_kw_opt ::= DATABASE */ |
| 172346 | 297, /* (393) kwcolumn_opt ::= COLUMNKW */ | 173434 | 294, /* (393) database_kw_opt ::= */ |
| 172347 | 299, /* (394) vtabarglist ::= vtabarg */ | 173435 | 297, /* (394) kwcolumn_opt ::= */ |
| 172348 | 299, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ | 173436 | 297, /* (395) kwcolumn_opt ::= COLUMNKW */ |
| 172349 | 300, /* (396) vtabarg ::= vtabarg vtabargtoken */ | 173437 | 299, /* (396) vtabarglist ::= vtabarg */ |
| 172350 | 303, /* (397) anylist ::= */ | 173438 | 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 172351 | 303, /* (398) anylist ::= anylist LP anylist RP */ | 173439 | 300, /* (398) vtabarg ::= vtabarg vtabargtoken */ |
| 172352 | 303, /* (399) anylist ::= anylist ANY */ | 173440 | 303, /* (399) anylist ::= */ |
| 172353 | 266, /* (400) with ::= */ | 173441 | 303, /* (400) anylist ::= anylist LP anylist RP */ |
| 172354 | 306, /* (401) windowdefn_list ::= windowdefn */ | 173442 | 303, /* (401) anylist ::= anylist ANY */ |
| 172355 | 308, /* (402) window ::= frame_opt */ | 173443 | 266, /* (402) with ::= */ |
| 173444 | 306, /* (403) windowdefn_list ::= windowdefn */ | ||
| 173445 | 308, /* (404) window ::= frame_opt */ | ||
| 172356 | }; | 173446 | }; |
| 172357 | 173447 | ||
| 172358 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number | 173448 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| @@ -172546,221 +173636,223 @@ static const signed char yyRuleInfoNRhs[] = { | |||
| 172546 | -3, /* (185) expr ::= expr COLLATE ID|STRING */ | 173636 | -3, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 172547 | -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ | 173637 | -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 172548 | -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ | 173638 | -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 172549 | -4, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | 173639 | -8, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 172550 | -6, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | 173640 | -4, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 172551 | -5, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | 173641 | -6, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 172552 | -1, /* (191) term ::= CTIME_KW */ | 173642 | -9, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 172553 | -5, /* (192) expr ::= LP nexprlist COMMA expr RP */ | 173643 | -5, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 172554 | -3, /* (193) expr ::= expr AND expr */ | 173644 | -1, /* (193) term ::= CTIME_KW */ |
| 172555 | -3, /* (194) expr ::= expr OR expr */ | 173645 | -5, /* (194) expr ::= LP nexprlist COMMA expr RP */ |
| 172556 | -3, /* (195) expr ::= expr LT|GT|GE|LE expr */ | 173646 | -3, /* (195) expr ::= expr AND expr */ |
| 172557 | -3, /* (196) expr ::= expr EQ|NE expr */ | 173647 | -3, /* (196) expr ::= expr OR expr */ |
| 172558 | -3, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 173648 | -3, /* (197) expr ::= expr LT|GT|GE|LE expr */ |
| 172559 | -3, /* (198) expr ::= expr PLUS|MINUS expr */ | 173649 | -3, /* (198) expr ::= expr EQ|NE expr */ |
| 172560 | -3, /* (199) expr ::= expr STAR|SLASH|REM expr */ | 173650 | -3, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 172561 | -3, /* (200) expr ::= expr CONCAT expr */ | 173651 | -3, /* (200) expr ::= expr PLUS|MINUS expr */ |
| 172562 | -2, /* (201) likeop ::= NOT LIKE_KW|MATCH */ | 173652 | -3, /* (201) expr ::= expr STAR|SLASH|REM expr */ |
| 172563 | -3, /* (202) expr ::= expr likeop expr */ | 173653 | -3, /* (202) expr ::= expr CONCAT expr */ |
| 172564 | -5, /* (203) expr ::= expr likeop expr ESCAPE expr */ | 173654 | -2, /* (203) likeop ::= NOT LIKE_KW|MATCH */ |
| 172565 | -2, /* (204) expr ::= expr ISNULL|NOTNULL */ | 173655 | -3, /* (204) expr ::= expr likeop expr */ |
| 172566 | -3, /* (205) expr ::= expr NOT NULL */ | 173656 | -5, /* (205) expr ::= expr likeop expr ESCAPE expr */ |
| 172567 | -3, /* (206) expr ::= expr IS expr */ | 173657 | -2, /* (206) expr ::= expr ISNULL|NOTNULL */ |
| 172568 | -4, /* (207) expr ::= expr IS NOT expr */ | 173658 | -3, /* (207) expr ::= expr NOT NULL */ |
| 172569 | -6, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ | 173659 | -3, /* (208) expr ::= expr IS expr */ |
| 172570 | -5, /* (209) expr ::= expr IS DISTINCT FROM expr */ | 173660 | -4, /* (209) expr ::= expr IS NOT expr */ |
| 172571 | -2, /* (210) expr ::= NOT expr */ | 173661 | -6, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ |
| 172572 | -2, /* (211) expr ::= BITNOT expr */ | 173662 | -5, /* (211) expr ::= expr IS DISTINCT FROM expr */ |
| 172573 | -2, /* (212) expr ::= PLUS|MINUS expr */ | 173663 | -2, /* (212) expr ::= NOT expr */ |
| 172574 | -3, /* (213) expr ::= expr PTR expr */ | 173664 | -2, /* (213) expr ::= BITNOT expr */ |
| 172575 | -1, /* (214) between_op ::= BETWEEN */ | 173665 | -2, /* (214) expr ::= PLUS|MINUS expr */ |
| 172576 | -2, /* (215) between_op ::= NOT BETWEEN */ | 173666 | -3, /* (215) expr ::= expr PTR expr */ |
| 172577 | -5, /* (216) expr ::= expr between_op expr AND expr */ | 173667 | -1, /* (216) between_op ::= BETWEEN */ |
| 172578 | -1, /* (217) in_op ::= IN */ | 173668 | -2, /* (217) between_op ::= NOT BETWEEN */ |
| 172579 | -2, /* (218) in_op ::= NOT IN */ | 173669 | -5, /* (218) expr ::= expr between_op expr AND expr */ |
| 172580 | -5, /* (219) expr ::= expr in_op LP exprlist RP */ | 173670 | -1, /* (219) in_op ::= IN */ |
| 172581 | -3, /* (220) expr ::= LP select RP */ | 173671 | -2, /* (220) in_op ::= NOT IN */ |
| 172582 | -5, /* (221) expr ::= expr in_op LP select RP */ | 173672 | -5, /* (221) expr ::= expr in_op LP exprlist RP */ |
| 172583 | -5, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ | 173673 | -3, /* (222) expr ::= LP select RP */ |
| 172584 | -4, /* (223) expr ::= EXISTS LP select RP */ | 173674 | -5, /* (223) expr ::= expr in_op LP select RP */ |
| 172585 | -5, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ | 173675 | -5, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 172586 | -5, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 173676 | -4, /* (225) expr ::= EXISTS LP select RP */ |
| 172587 | -4, /* (226) case_exprlist ::= WHEN expr THEN expr */ | 173677 | -5, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ |
| 172588 | -2, /* (227) case_else ::= ELSE expr */ | 173678 | -5, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 172589 | 0, /* (228) case_else ::= */ | 173679 | -4, /* (228) case_exprlist ::= WHEN expr THEN expr */ |
| 172590 | 0, /* (229) case_operand ::= */ | 173680 | -2, /* (229) case_else ::= ELSE expr */ |
| 172591 | 0, /* (230) exprlist ::= */ | 173681 | 0, /* (230) case_else ::= */ |
| 172592 | -3, /* (231) nexprlist ::= nexprlist COMMA expr */ | 173682 | 0, /* (231) case_operand ::= */ |
| 172593 | -1, /* (232) nexprlist ::= expr */ | 173683 | 0, /* (232) exprlist ::= */ |
| 172594 | 0, /* (233) paren_exprlist ::= */ | 173684 | -3, /* (233) nexprlist ::= nexprlist COMMA expr */ |
| 172595 | -3, /* (234) paren_exprlist ::= LP exprlist RP */ | 173685 | -1, /* (234) nexprlist ::= expr */ |
| 172596 | -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 173686 | 0, /* (235) paren_exprlist ::= */ |
| 172597 | -1, /* (236) uniqueflag ::= UNIQUE */ | 173687 | -3, /* (236) paren_exprlist ::= LP exprlist RP */ |
| 172598 | 0, /* (237) uniqueflag ::= */ | 173688 | -12, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 172599 | 0, /* (238) eidlist_opt ::= */ | 173689 | -1, /* (238) uniqueflag ::= UNIQUE */ |
| 172600 | -3, /* (239) eidlist_opt ::= LP eidlist RP */ | 173690 | 0, /* (239) uniqueflag ::= */ |
| 172601 | -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ | 173691 | 0, /* (240) eidlist_opt ::= */ |
| 172602 | -3, /* (241) eidlist ::= nm collate sortorder */ | 173692 | -3, /* (241) eidlist_opt ::= LP eidlist RP */ |
| 172603 | 0, /* (242) collate ::= */ | 173693 | -5, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 172604 | -2, /* (243) collate ::= COLLATE ID|STRING */ | 173694 | -3, /* (243) eidlist ::= nm collate sortorder */ |
| 172605 | -4, /* (244) cmd ::= DROP INDEX ifexists fullname */ | 173695 | 0, /* (244) collate ::= */ |
| 172606 | -2, /* (245) cmd ::= VACUUM vinto */ | 173696 | -2, /* (245) collate ::= COLLATE ID|STRING */ |
| 172607 | -3, /* (246) cmd ::= VACUUM nm vinto */ | 173697 | -4, /* (246) cmd ::= DROP INDEX ifexists fullname */ |
| 172608 | -2, /* (247) vinto ::= INTO expr */ | 173698 | -2, /* (247) cmd ::= VACUUM vinto */ |
| 172609 | 0, /* (248) vinto ::= */ | 173699 | -3, /* (248) cmd ::= VACUUM nm vinto */ |
| 172610 | -3, /* (249) cmd ::= PRAGMA nm dbnm */ | 173700 | -2, /* (249) vinto ::= INTO expr */ |
| 172611 | -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 173701 | 0, /* (250) vinto ::= */ |
| 172612 | -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 173702 | -3, /* (251) cmd ::= PRAGMA nm dbnm */ |
| 172613 | -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 173703 | -5, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 172614 | -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 173704 | -6, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 172615 | -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ | 173705 | -5, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 172616 | -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ | 173706 | -6, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 172617 | -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 173707 | -2, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ |
| 172618 | -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 173708 | -2, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ |
| 172619 | -1, /* (258) trigger_time ::= BEFORE|AFTER */ | 173709 | -5, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 172620 | -2, /* (259) trigger_time ::= INSTEAD OF */ | 173710 | -11, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 172621 | 0, /* (260) trigger_time ::= */ | 173711 | -1, /* (260) trigger_time ::= BEFORE|AFTER */ |
| 172622 | -1, /* (261) trigger_event ::= DELETE|INSERT */ | 173712 | -2, /* (261) trigger_time ::= INSTEAD OF */ |
| 172623 | -1, /* (262) trigger_event ::= UPDATE */ | 173713 | 0, /* (262) trigger_time ::= */ |
| 172624 | -3, /* (263) trigger_event ::= UPDATE OF idlist */ | 173714 | -1, /* (263) trigger_event ::= DELETE|INSERT */ |
| 172625 | 0, /* (264) when_clause ::= */ | 173715 | -1, /* (264) trigger_event ::= UPDATE */ |
| 172626 | -2, /* (265) when_clause ::= WHEN expr */ | 173716 | -3, /* (265) trigger_event ::= UPDATE OF idlist */ |
| 172627 | -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 173717 | 0, /* (266) when_clause ::= */ |
| 172628 | -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ | 173718 | -2, /* (267) when_clause ::= WHEN expr */ |
| 172629 | -3, /* (268) trnm ::= nm DOT nm */ | 173719 | -3, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 172630 | -3, /* (269) tridxby ::= INDEXED BY nm */ | 173720 | -2, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 172631 | -2, /* (270) tridxby ::= NOT INDEXED */ | 173721 | -3, /* (270) trnm ::= nm DOT nm */ |
| 172632 | -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 173722 | -3, /* (271) tridxby ::= INDEXED BY nm */ |
| 172633 | -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 173723 | -2, /* (272) tridxby ::= NOT INDEXED */ |
| 172634 | -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 173724 | -9, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 172635 | -3, /* (274) trigger_cmd ::= scanpt select scanpt */ | 173725 | -8, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 172636 | -4, /* (275) expr ::= RAISE LP IGNORE RP */ | 173726 | -6, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 172637 | -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ | 173727 | -3, /* (276) trigger_cmd ::= scanpt select scanpt */ |
| 172638 | -1, /* (277) raisetype ::= ROLLBACK */ | 173728 | -4, /* (277) expr ::= RAISE LP IGNORE RP */ |
| 172639 | -1, /* (278) raisetype ::= ABORT */ | 173729 | -6, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 172640 | -1, /* (279) raisetype ::= FAIL */ | 173730 | -1, /* (279) raisetype ::= ROLLBACK */ |
| 172641 | -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ | 173731 | -1, /* (280) raisetype ::= ABORT */ |
| 172642 | -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 173732 | -1, /* (281) raisetype ::= FAIL */ |
| 172643 | -3, /* (282) cmd ::= DETACH database_kw_opt expr */ | 173733 | -4, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ |
| 172644 | 0, /* (283) key_opt ::= */ | 173734 | -6, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 172645 | -2, /* (284) key_opt ::= KEY expr */ | 173735 | -3, /* (284) cmd ::= DETACH database_kw_opt expr */ |
| 172646 | -1, /* (285) cmd ::= REINDEX */ | 173736 | 0, /* (285) key_opt ::= */ |
| 172647 | -3, /* (286) cmd ::= REINDEX nm dbnm */ | 173737 | -2, /* (286) key_opt ::= KEY expr */ |
| 172648 | -1, /* (287) cmd ::= ANALYZE */ | 173738 | -1, /* (287) cmd ::= REINDEX */ |
| 172649 | -3, /* (288) cmd ::= ANALYZE nm dbnm */ | 173739 | -3, /* (288) cmd ::= REINDEX nm dbnm */ |
| 172650 | -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 173740 | -1, /* (289) cmd ::= ANALYZE */ |
| 172651 | -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 173741 | -3, /* (290) cmd ::= ANALYZE nm dbnm */ |
| 172652 | -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 173742 | -6, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 172653 | -1, /* (292) add_column_fullname ::= fullname */ | 173743 | -7, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 172654 | -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 173744 | -6, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 172655 | -1, /* (294) cmd ::= create_vtab */ | 173745 | -1, /* (294) add_column_fullname ::= fullname */ |
| 172656 | -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */ | 173746 | -8, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 172657 | -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 173747 | -1, /* (296) cmd ::= create_vtab */ |
| 172658 | 0, /* (297) vtabarg ::= */ | 173748 | -4, /* (297) cmd ::= create_vtab LP vtabarglist RP */ |
| 172659 | -1, /* (298) vtabargtoken ::= ANY */ | 173749 | -8, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 172660 | -3, /* (299) vtabargtoken ::= lp anylist RP */ | 173750 | 0, /* (299) vtabarg ::= */ |
| 172661 | -1, /* (300) lp ::= LP */ | 173751 | -1, /* (300) vtabargtoken ::= ANY */ |
| 172662 | -2, /* (301) with ::= WITH wqlist */ | 173752 | -3, /* (301) vtabargtoken ::= lp anylist RP */ |
| 172663 | -3, /* (302) with ::= WITH RECURSIVE wqlist */ | 173753 | -1, /* (302) lp ::= LP */ |
| 172664 | -1, /* (303) wqas ::= AS */ | 173754 | -2, /* (303) with ::= WITH wqlist */ |
| 172665 | -2, /* (304) wqas ::= AS MATERIALIZED */ | 173755 | -3, /* (304) with ::= WITH RECURSIVE wqlist */ |
| 172666 | -3, /* (305) wqas ::= AS NOT MATERIALIZED */ | 173756 | -1, /* (305) wqas ::= AS */ |
| 172667 | -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ | 173757 | -2, /* (306) wqas ::= AS MATERIALIZED */ |
| 172668 | -1, /* (307) wqlist ::= wqitem */ | 173758 | -3, /* (307) wqas ::= AS NOT MATERIALIZED */ |
| 172669 | -3, /* (308) wqlist ::= wqlist COMMA wqitem */ | 173759 | -6, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 172670 | -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 173760 | -1, /* (309) wqlist ::= wqitem */ |
| 172671 | -5, /* (310) windowdefn ::= nm AS LP window RP */ | 173761 | -3, /* (310) wqlist ::= wqlist COMMA wqitem */ |
| 172672 | -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 173762 | -3, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 172673 | -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 173763 | -5, /* (312) windowdefn ::= nm AS LP window RP */ |
| 172674 | -4, /* (313) window ::= ORDER BY sortlist frame_opt */ | 173764 | -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172675 | -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ | 173765 | -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172676 | -2, /* (315) window ::= nm frame_opt */ | 173766 | -4, /* (315) window ::= ORDER BY sortlist frame_opt */ |
| 172677 | 0, /* (316) frame_opt ::= */ | 173767 | -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */ |
| 172678 | -3, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 173768 | -2, /* (317) window ::= nm frame_opt */ |
| 172679 | -6, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 173769 | 0, /* (318) frame_opt ::= */ |
| 172680 | -1, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ | 173770 | -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 172681 | -1, /* (320) frame_bound_s ::= frame_bound */ | 173771 | -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 172682 | -2, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ | 173772 | -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 172683 | -1, /* (322) frame_bound_e ::= frame_bound */ | 173773 | -1, /* (322) frame_bound_s ::= frame_bound */ |
| 172684 | -2, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 173774 | -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 172685 | -2, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ | 173775 | -1, /* (324) frame_bound_e ::= frame_bound */ |
| 172686 | -2, /* (325) frame_bound ::= CURRENT ROW */ | 173776 | -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 172687 | 0, /* (326) frame_exclude_opt ::= */ | 173777 | -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 172688 | -2, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 173778 | -2, /* (327) frame_bound ::= CURRENT ROW */ |
| 172689 | -2, /* (328) frame_exclude ::= NO OTHERS */ | 173779 | 0, /* (328) frame_exclude_opt ::= */ |
| 172690 | -2, /* (329) frame_exclude ::= CURRENT ROW */ | 173780 | -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 172691 | -1, /* (330) frame_exclude ::= GROUP|TIES */ | 173781 | -2, /* (330) frame_exclude ::= NO OTHERS */ |
| 172692 | -2, /* (331) window_clause ::= WINDOW windowdefn_list */ | 173782 | -2, /* (331) frame_exclude ::= CURRENT ROW */ |
| 172693 | -2, /* (332) filter_over ::= filter_clause over_clause */ | 173783 | -1, /* (332) frame_exclude ::= GROUP|TIES */ |
| 172694 | -1, /* (333) filter_over ::= over_clause */ | 173784 | -2, /* (333) window_clause ::= WINDOW windowdefn_list */ |
| 172695 | -1, /* (334) filter_over ::= filter_clause */ | 173785 | -2, /* (334) filter_over ::= filter_clause over_clause */ |
| 172696 | -4, /* (335) over_clause ::= OVER LP window RP */ | 173786 | -1, /* (335) filter_over ::= over_clause */ |
| 172697 | -2, /* (336) over_clause ::= OVER nm */ | 173787 | -1, /* (336) filter_over ::= filter_clause */ |
| 172698 | -5, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ | 173788 | -4, /* (337) over_clause ::= OVER LP window RP */ |
| 172699 | -1, /* (338) input ::= cmdlist */ | 173789 | -2, /* (338) over_clause ::= OVER nm */ |
| 172700 | -2, /* (339) cmdlist ::= cmdlist ecmd */ | 173790 | -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ |
| 172701 | -1, /* (340) cmdlist ::= ecmd */ | 173791 | -1, /* (340) input ::= cmdlist */ |
| 172702 | -1, /* (341) ecmd ::= SEMI */ | 173792 | -2, /* (341) cmdlist ::= cmdlist ecmd */ |
| 172703 | -2, /* (342) ecmd ::= cmdx SEMI */ | 173793 | -1, /* (342) cmdlist ::= ecmd */ |
| 172704 | -3, /* (343) ecmd ::= explain cmdx SEMI */ | 173794 | -1, /* (343) ecmd ::= SEMI */ |
| 172705 | 0, /* (344) trans_opt ::= */ | 173795 | -2, /* (344) ecmd ::= cmdx SEMI */ |
| 172706 | -1, /* (345) trans_opt ::= TRANSACTION */ | 173796 | -3, /* (345) ecmd ::= explain cmdx SEMI */ |
| 172707 | -2, /* (346) trans_opt ::= TRANSACTION nm */ | 173797 | 0, /* (346) trans_opt ::= */ |
| 172708 | -1, /* (347) savepoint_opt ::= SAVEPOINT */ | 173798 | -1, /* (347) trans_opt ::= TRANSACTION */ |
| 172709 | 0, /* (348) savepoint_opt ::= */ | 173799 | -2, /* (348) trans_opt ::= TRANSACTION nm */ |
| 172710 | -2, /* (349) cmd ::= create_table create_table_args */ | 173800 | -1, /* (349) savepoint_opt ::= SAVEPOINT */ |
| 172711 | -1, /* (350) table_option_set ::= table_option */ | 173801 | 0, /* (350) savepoint_opt ::= */ |
| 172712 | -4, /* (351) columnlist ::= columnlist COMMA columnname carglist */ | 173802 | -2, /* (351) cmd ::= create_table create_table_args */ |
| 172713 | -2, /* (352) columnlist ::= columnname carglist */ | 173803 | -1, /* (352) table_option_set ::= table_option */ |
| 172714 | -1, /* (353) nm ::= ID|INDEXED|JOIN_KW */ | 173804 | -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */ |
| 172715 | -1, /* (354) nm ::= STRING */ | 173805 | -2, /* (354) columnlist ::= columnname carglist */ |
| 172716 | -1, /* (355) typetoken ::= typename */ | 173806 | -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */ |
| 172717 | -1, /* (356) typename ::= ID|STRING */ | 173807 | -1, /* (356) nm ::= STRING */ |
| 172718 | -1, /* (357) signed ::= plus_num */ | 173808 | -1, /* (357) typetoken ::= typename */ |
| 172719 | -1, /* (358) signed ::= minus_num */ | 173809 | -1, /* (358) typename ::= ID|STRING */ |
| 172720 | -2, /* (359) carglist ::= carglist ccons */ | 173810 | -1, /* (359) signed ::= plus_num */ |
| 172721 | 0, /* (360) carglist ::= */ | 173811 | -1, /* (360) signed ::= minus_num */ |
| 172722 | -2, /* (361) ccons ::= NULL onconf */ | 173812 | -2, /* (361) carglist ::= carglist ccons */ |
| 172723 | -4, /* (362) ccons ::= GENERATED ALWAYS AS generated */ | 173813 | 0, /* (362) carglist ::= */ |
| 172724 | -2, /* (363) ccons ::= AS generated */ | 173814 | -2, /* (363) ccons ::= NULL onconf */ |
| 172725 | -2, /* (364) conslist_opt ::= COMMA conslist */ | 173815 | -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 172726 | -3, /* (365) conslist ::= conslist tconscomma tcons */ | 173816 | -2, /* (365) ccons ::= AS generated */ |
| 172727 | -1, /* (366) conslist ::= tcons */ | 173817 | -2, /* (366) conslist_opt ::= COMMA conslist */ |
| 172728 | 0, /* (367) tconscomma ::= */ | 173818 | -3, /* (367) conslist ::= conslist tconscomma tcons */ |
| 172729 | -1, /* (368) defer_subclause_opt ::= defer_subclause */ | 173819 | -1, /* (368) conslist ::= tcons */ |
| 172730 | -1, /* (369) resolvetype ::= raisetype */ | 173820 | 0, /* (369) tconscomma ::= */ |
| 172731 | -1, /* (370) selectnowith ::= oneselect */ | 173821 | -1, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 172732 | -1, /* (371) oneselect ::= values */ | 173822 | -1, /* (371) resolvetype ::= raisetype */ |
| 172733 | -2, /* (372) sclp ::= selcollist COMMA */ | 173823 | -1, /* (372) selectnowith ::= oneselect */ |
| 172734 | -1, /* (373) as ::= ID|STRING */ | 173824 | -1, /* (373) oneselect ::= values */ |
| 172735 | -1, /* (374) indexed_opt ::= indexed_by */ | 173825 | -2, /* (374) sclp ::= selcollist COMMA */ |
| 172736 | 0, /* (375) returning ::= */ | 173826 | -1, /* (375) as ::= ID|STRING */ |
| 172737 | -1, /* (376) expr ::= term */ | 173827 | -1, /* (376) indexed_opt ::= indexed_by */ |
| 172738 | -1, /* (377) likeop ::= LIKE_KW|MATCH */ | 173828 | 0, /* (377) returning ::= */ |
| 172739 | -1, /* (378) case_operand ::= expr */ | 173829 | -1, /* (378) expr ::= term */ |
| 172740 | -1, /* (379) exprlist ::= nexprlist */ | 173830 | -1, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 172741 | -1, /* (380) nmnum ::= plus_num */ | 173831 | -1, /* (380) case_operand ::= expr */ |
| 172742 | -1, /* (381) nmnum ::= nm */ | 173832 | -1, /* (381) exprlist ::= nexprlist */ |
| 172743 | -1, /* (382) nmnum ::= ON */ | 173833 | -1, /* (382) nmnum ::= plus_num */ |
| 172744 | -1, /* (383) nmnum ::= DELETE */ | 173834 | -1, /* (383) nmnum ::= nm */ |
| 172745 | -1, /* (384) nmnum ::= DEFAULT */ | 173835 | -1, /* (384) nmnum ::= ON */ |
| 172746 | -1, /* (385) plus_num ::= INTEGER|FLOAT */ | 173836 | -1, /* (385) nmnum ::= DELETE */ |
| 172747 | 0, /* (386) foreach_clause ::= */ | 173837 | -1, /* (386) nmnum ::= DEFAULT */ |
| 172748 | -3, /* (387) foreach_clause ::= FOR EACH ROW */ | 173838 | -1, /* (387) plus_num ::= INTEGER|FLOAT */ |
| 172749 | -1, /* (388) trnm ::= nm */ | 173839 | 0, /* (388) foreach_clause ::= */ |
| 172750 | 0, /* (389) tridxby ::= */ | 173840 | -3, /* (389) foreach_clause ::= FOR EACH ROW */ |
| 172751 | -1, /* (390) database_kw_opt ::= DATABASE */ | 173841 | -1, /* (390) trnm ::= nm */ |
| 172752 | 0, /* (391) database_kw_opt ::= */ | 173842 | 0, /* (391) tridxby ::= */ |
| 172753 | 0, /* (392) kwcolumn_opt ::= */ | 173843 | -1, /* (392) database_kw_opt ::= DATABASE */ |
| 172754 | -1, /* (393) kwcolumn_opt ::= COLUMNKW */ | 173844 | 0, /* (393) database_kw_opt ::= */ |
| 172755 | -1, /* (394) vtabarglist ::= vtabarg */ | 173845 | 0, /* (394) kwcolumn_opt ::= */ |
| 172756 | -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ | 173846 | -1, /* (395) kwcolumn_opt ::= COLUMNKW */ |
| 172757 | -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ | 173847 | -1, /* (396) vtabarglist ::= vtabarg */ |
| 172758 | 0, /* (397) anylist ::= */ | 173848 | -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 172759 | -4, /* (398) anylist ::= anylist LP anylist RP */ | 173849 | -2, /* (398) vtabarg ::= vtabarg vtabargtoken */ |
| 172760 | -2, /* (399) anylist ::= anylist ANY */ | 173850 | 0, /* (399) anylist ::= */ |
| 172761 | 0, /* (400) with ::= */ | 173851 | -4, /* (400) anylist ::= anylist LP anylist RP */ |
| 172762 | -1, /* (401) windowdefn_list ::= windowdefn */ | 173852 | -2, /* (401) anylist ::= anylist ANY */ |
| 172763 | -1, /* (402) window ::= frame_opt */ | 173853 | 0, /* (402) with ::= */ |
| 173854 | -1, /* (403) windowdefn_list ::= windowdefn */ | ||
| 173855 | -1, /* (404) window ::= frame_opt */ | ||
| 172764 | }; | 173856 | }; |
| 172765 | 173857 | ||
| 172766 | static void yy_accept(yyParser*); /* Forward Declaration */ | 173858 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| @@ -172820,7 +173912,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 172820 | case 5: /* transtype ::= DEFERRED */ | 173912 | case 5: /* transtype ::= DEFERRED */ |
| 172821 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); | 173913 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 172822 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); | 173914 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 172823 | case 319: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==319); | 173915 | case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321); |
| 172824 | {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} | 173916 | {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} |
| 172825 | break; | 173917 | break; |
| 172826 | case 8: /* cmd ::= COMMIT|END trans_opt */ | 173918 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| @@ -172857,7 +173949,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 172857 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); | 173949 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 172858 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); | 173950 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 172859 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); | 173951 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); |
| 172860 | case 242: /* collate ::= */ yytestcase(yyruleno==242); | 173952 | case 244: /* collate ::= */ yytestcase(yyruleno==244); |
| 172861 | {yymsp[1].minor.yy394 = 0;} | 173953 | {yymsp[1].minor.yy394 = 0;} |
| 172862 | break; | 173954 | break; |
| 172863 | case 16: /* ifnotexists ::= IF NOT EXISTS */ | 173955 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| @@ -173041,9 +174133,9 @@ static YYACTIONTYPE yy_reduce( | |||
| 173041 | break; | 174133 | break; |
| 173042 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 174134 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 173043 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); | 174135 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 173044 | case 215: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==215); | 174136 | case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217); |
| 173045 | case 218: /* in_op ::= NOT IN */ yytestcase(yyruleno==218); | 174137 | case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220); |
| 173046 | case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243); | 174138 | case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245); |
| 173047 | {yymsp[-1].minor.yy394 = 1;} | 174139 | {yymsp[-1].minor.yy394 = 1;} |
| 173048 | break; | 174140 | break; |
| 173049 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 174141 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| @@ -173192,9 +174284,9 @@ static YYACTIONTYPE yy_reduce( | |||
| 173192 | case 99: /* sclp ::= */ | 174284 | case 99: /* sclp ::= */ |
| 173193 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); | 174285 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); |
| 173194 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); | 174286 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); |
| 173195 | case 230: /* exprlist ::= */ yytestcase(yyruleno==230); | 174287 | case 232: /* exprlist ::= */ yytestcase(yyruleno==232); |
| 173196 | case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233); | 174288 | case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235); |
| 173197 | case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238); | 174289 | case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240); |
| 173198 | {yymsp[1].minor.yy322 = 0;} | 174290 | {yymsp[1].minor.yy322 = 0;} |
| 173199 | break; | 174291 | break; |
| 173200 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ | 174292 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ |
| @@ -173223,8 +174315,8 @@ static YYACTIONTYPE yy_reduce( | |||
| 173223 | break; | 174315 | break; |
| 173224 | case 103: /* as ::= AS nm */ | 174316 | case 103: /* as ::= AS nm */ |
| 173225 | case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); | 174317 | case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); |
| 173226 | case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); | 174318 | case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256); |
| 173227 | case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); | 174319 | case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257); |
| 173228 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} | 174320 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 173229 | break; | 174321 | break; |
| 173230 | case 105: /* from ::= */ | 174322 | case 105: /* from ::= */ |
| @@ -173396,16 +174488,16 @@ static YYACTIONTYPE yy_reduce( | |||
| 173396 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); | 174488 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 173397 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); | 174489 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 173398 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); | 174490 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 173399 | case 228: /* case_else ::= */ yytestcase(yyruleno==228); | 174491 | case 230: /* case_else ::= */ yytestcase(yyruleno==230); |
| 173400 | case 229: /* case_operand ::= */ yytestcase(yyruleno==229); | 174492 | case 231: /* case_operand ::= */ yytestcase(yyruleno==231); |
| 173401 | case 248: /* vinto ::= */ yytestcase(yyruleno==248); | 174493 | case 250: /* vinto ::= */ yytestcase(yyruleno==250); |
| 173402 | {yymsp[1].minor.yy528 = 0;} | 174494 | {yymsp[1].minor.yy528 = 0;} |
| 173403 | break; | 174495 | break; |
| 173404 | case 145: /* having_opt ::= HAVING expr */ | 174496 | case 145: /* having_opt ::= HAVING expr */ |
| 173405 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); | 174497 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 173406 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); | 174498 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 173407 | case 227: /* case_else ::= ELSE expr */ yytestcase(yyruleno==227); | 174499 | case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229); |
| 173408 | case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); | 174500 | case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249); |
| 173409 | {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} | 174501 | {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 173410 | break; | 174502 | break; |
| 173411 | case 147: /* limit_opt ::= LIMIT expr */ | 174503 | case 147: /* limit_opt ::= LIMIT expr */ |
| @@ -173591,33 +174683,48 @@ static YYACTIONTYPE yy_reduce( | |||
| 173591 | } | 174683 | } |
| 173592 | yymsp[-4].minor.yy528 = yylhsminor.yy528; | 174684 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 173593 | break; | 174685 | break; |
| 173594 | case 188: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | 174686 | case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 174687 | { | ||
| 174688 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394); | ||
| 174689 | sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322); | ||
| 174690 | } | ||
| 174691 | yymsp[-7].minor.yy528 = yylhsminor.yy528; | ||
| 174692 | break; | ||
| 174693 | case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | ||
| 173595 | { | 174694 | { |
| 173596 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); | 174695 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 173597 | } | 174696 | } |
| 173598 | yymsp[-3].minor.yy528 = yylhsminor.yy528; | 174697 | yymsp[-3].minor.yy528 = yylhsminor.yy528; |
| 173599 | break; | 174698 | break; |
| 173600 | case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | 174699 | case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 173601 | { | 174700 | { |
| 173602 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394); | 174701 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394); |
| 173603 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); | 174702 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 173604 | } | 174703 | } |
| 173605 | yymsp[-5].minor.yy528 = yylhsminor.yy528; | 174704 | yymsp[-5].minor.yy528 = yylhsminor.yy528; |
| 173606 | break; | 174705 | break; |
| 173607 | case 190: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | 174706 | case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 174707 | { | ||
| 174708 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394); | ||
| 174709 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); | ||
| 174710 | sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322); | ||
| 174711 | } | ||
| 174712 | yymsp[-8].minor.yy528 = yylhsminor.yy528; | ||
| 174713 | break; | ||
| 174714 | case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | ||
| 173608 | { | 174715 | { |
| 173609 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); | 174716 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 173610 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); | 174717 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 173611 | } | 174718 | } |
| 173612 | yymsp[-4].minor.yy528 = yylhsminor.yy528; | 174719 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 173613 | break; | 174720 | break; |
| 173614 | case 191: /* term ::= CTIME_KW */ | 174721 | case 193: /* term ::= CTIME_KW */ |
| 173615 | { | 174722 | { |
| 173616 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); | 174723 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 173617 | } | 174724 | } |
| 173618 | yymsp[0].minor.yy528 = yylhsminor.yy528; | 174725 | yymsp[0].minor.yy528 = yylhsminor.yy528; |
| 173619 | break; | 174726 | break; |
| 173620 | case 192: /* expr ::= LP nexprlist COMMA expr RP */ | 174727 | case 194: /* expr ::= LP nexprlist COMMA expr RP */ |
| 173621 | { | 174728 | { |
| 173622 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); | 174729 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); |
| 173623 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); | 174730 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| @@ -173631,22 +174738,22 @@ static YYACTIONTYPE yy_reduce( | |||
| 173631 | } | 174738 | } |
| 173632 | } | 174739 | } |
| 173633 | break; | 174740 | break; |
| 173634 | case 193: /* expr ::= expr AND expr */ | 174741 | case 195: /* expr ::= expr AND expr */ |
| 173635 | {yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} | 174742 | {yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 173636 | break; | 174743 | break; |
| 173637 | case 194: /* expr ::= expr OR expr */ | 174744 | case 196: /* expr ::= expr OR expr */ |
| 173638 | case 195: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==195); | 174745 | case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197); |
| 173639 | case 196: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==196); | 174746 | case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198); |
| 173640 | case 197: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==197); | 174747 | case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199); |
| 173641 | case 198: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==198); | 174748 | case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200); |
| 173642 | case 199: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==199); | 174749 | case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201); |
| 173643 | case 200: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==200); | 174750 | case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202); |
| 173644 | {yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} | 174751 | {yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 173645 | break; | 174752 | break; |
| 173646 | case 201: /* likeop ::= NOT LIKE_KW|MATCH */ | 174753 | case 203: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 173647 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} | 174754 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 173648 | break; | 174755 | break; |
| 173649 | case 202: /* expr ::= expr likeop expr */ | 174756 | case 204: /* expr ::= expr likeop expr */ |
| 173650 | { | 174757 | { |
| 173651 | ExprList *pList; | 174758 | ExprList *pList; |
| 173652 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; | 174759 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| @@ -173658,7 +174765,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 173658 | if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; | 174765 | if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; |
| 173659 | } | 174766 | } |
| 173660 | break; | 174767 | break; |
| 173661 | case 203: /* expr ::= expr likeop expr ESCAPE expr */ | 174768 | case 205: /* expr ::= expr likeop expr ESCAPE expr */ |
| 173662 | { | 174769 | { |
| 173663 | ExprList *pList; | 174770 | ExprList *pList; |
| 173664 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; | 174771 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| @@ -173671,47 +174778,47 @@ static YYACTIONTYPE yy_reduce( | |||
| 173671 | if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; | 174778 | if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; |
| 173672 | } | 174779 | } |
| 173673 | break; | 174780 | break; |
| 173674 | case 204: /* expr ::= expr ISNULL|NOTNULL */ | 174781 | case 206: /* expr ::= expr ISNULL|NOTNULL */ |
| 173675 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} | 174782 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} |
| 173676 | break; | 174783 | break; |
| 173677 | case 205: /* expr ::= expr NOT NULL */ | 174784 | case 207: /* expr ::= expr NOT NULL */ |
| 173678 | {yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} | 174785 | {yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} |
| 173679 | break; | 174786 | break; |
| 173680 | case 206: /* expr ::= expr IS expr */ | 174787 | case 208: /* expr ::= expr IS expr */ |
| 173681 | { | 174788 | { |
| 173682 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528); | 174789 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528); |
| 173683 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL); | 174790 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL); |
| 173684 | } | 174791 | } |
| 173685 | break; | 174792 | break; |
| 173686 | case 207: /* expr ::= expr IS NOT expr */ | 174793 | case 209: /* expr ::= expr IS NOT expr */ |
| 173687 | { | 174794 | { |
| 173688 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528); | 174795 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528); |
| 173689 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL); | 174796 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL); |
| 173690 | } | 174797 | } |
| 173691 | break; | 174798 | break; |
| 173692 | case 208: /* expr ::= expr IS NOT DISTINCT FROM expr */ | 174799 | case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */ |
| 173693 | { | 174800 | { |
| 173694 | yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528); | 174801 | yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528); |
| 173695 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL); | 174802 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL); |
| 173696 | } | 174803 | } |
| 173697 | break; | 174804 | break; |
| 173698 | case 209: /* expr ::= expr IS DISTINCT FROM expr */ | 174805 | case 211: /* expr ::= expr IS DISTINCT FROM expr */ |
| 173699 | { | 174806 | { |
| 173700 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528); | 174807 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528); |
| 173701 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL); | 174808 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL); |
| 173702 | } | 174809 | } |
| 173703 | break; | 174810 | break; |
| 173704 | case 210: /* expr ::= NOT expr */ | 174811 | case 212: /* expr ::= NOT expr */ |
| 173705 | case 211: /* expr ::= BITNOT expr */ yytestcase(yyruleno==211); | 174812 | case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213); |
| 173706 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} | 174813 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} |
| 173707 | break; | 174814 | break; |
| 173708 | case 212: /* expr ::= PLUS|MINUS expr */ | 174815 | case 214: /* expr ::= PLUS|MINUS expr */ |
| 173709 | { | 174816 | { |
| 173710 | yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); | 174817 | yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); |
| 173711 | /*A-overwrites-B*/ | 174818 | /*A-overwrites-B*/ |
| 173712 | } | 174819 | } |
| 173713 | break; | 174820 | break; |
| 173714 | case 213: /* expr ::= expr PTR expr */ | 174821 | case 215: /* expr ::= expr PTR expr */ |
| 173715 | { | 174822 | { |
| 173716 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); | 174823 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); |
| 173717 | pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); | 174824 | pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); |
| @@ -173719,11 +174826,11 @@ static YYACTIONTYPE yy_reduce( | |||
| 173719 | } | 174826 | } |
| 173720 | yymsp[-2].minor.yy528 = yylhsminor.yy528; | 174827 | yymsp[-2].minor.yy528 = yylhsminor.yy528; |
| 173721 | break; | 174828 | break; |
| 173722 | case 214: /* between_op ::= BETWEEN */ | 174829 | case 216: /* between_op ::= BETWEEN */ |
| 173723 | case 217: /* in_op ::= IN */ yytestcase(yyruleno==217); | 174830 | case 219: /* in_op ::= IN */ yytestcase(yyruleno==219); |
| 173724 | {yymsp[0].minor.yy394 = 0;} | 174831 | {yymsp[0].minor.yy394 = 0;} |
| 173725 | break; | 174832 | break; |
| 173726 | case 216: /* expr ::= expr between_op expr AND expr */ | 174833 | case 218: /* expr ::= expr between_op expr AND expr */ |
| 173727 | { | 174834 | { |
| 173728 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); | 174835 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 173729 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); | 174836 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); |
| @@ -173736,7 +174843,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 173736 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); | 174843 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173737 | } | 174844 | } |
| 173738 | break; | 174845 | break; |
| 173739 | case 219: /* expr ::= expr in_op LP exprlist RP */ | 174846 | case 221: /* expr ::= expr in_op LP exprlist RP */ |
| 173740 | { | 174847 | { |
| 173741 | if( yymsp[-1].minor.yy322==0 ){ | 174848 | if( yymsp[-1].minor.yy322==0 ){ |
| 173742 | /* Expressions of the form | 174849 | /* Expressions of the form |
| @@ -173782,20 +174889,20 @@ static YYACTIONTYPE yy_reduce( | |||
| 173782 | } | 174889 | } |
| 173783 | } | 174890 | } |
| 173784 | break; | 174891 | break; |
| 173785 | case 220: /* expr ::= LP select RP */ | 174892 | case 222: /* expr ::= LP select RP */ |
| 173786 | { | 174893 | { |
| 173787 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); | 174894 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 173788 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); | 174895 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); |
| 173789 | } | 174896 | } |
| 173790 | break; | 174897 | break; |
| 173791 | case 221: /* expr ::= expr in_op LP select RP */ | 174898 | case 223: /* expr ::= expr in_op LP select RP */ |
| 173792 | { | 174899 | { |
| 173793 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); | 174900 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 173794 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47); | 174901 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47); |
| 173795 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); | 174902 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173796 | } | 174903 | } |
| 173797 | break; | 174904 | break; |
| 173798 | case 222: /* expr ::= expr in_op nm dbnm paren_exprlist */ | 174905 | case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 173799 | { | 174906 | { |
| 173800 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); | 174907 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 173801 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); | 174908 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| @@ -173805,14 +174912,14 @@ static YYACTIONTYPE yy_reduce( | |||
| 173805 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); | 174912 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173806 | } | 174913 | } |
| 173807 | break; | 174914 | break; |
| 173808 | case 223: /* expr ::= EXISTS LP select RP */ | 174915 | case 225: /* expr ::= EXISTS LP select RP */ |
| 173809 | { | 174916 | { |
| 173810 | Expr *p; | 174917 | Expr *p; |
| 173811 | p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); | 174918 | p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 173812 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); | 174919 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); |
| 173813 | } | 174920 | } |
| 173814 | break; | 174921 | break; |
| 173815 | case 224: /* expr ::= CASE case_operand case_exprlist case_else END */ | 174922 | case 226: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 173816 | { | 174923 | { |
| 173817 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); | 174924 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); |
| 173818 | if( yymsp[-4].minor.yy528 ){ | 174925 | if( yymsp[-4].minor.yy528 ){ |
| @@ -173824,29 +174931,29 @@ static YYACTIONTYPE yy_reduce( | |||
| 173824 | } | 174931 | } |
| 173825 | } | 174932 | } |
| 173826 | break; | 174933 | break; |
| 173827 | case 225: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 174934 | case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 173828 | { | 174935 | { |
| 173829 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); | 174936 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| 173830 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528); | 174937 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528); |
| 173831 | } | 174938 | } |
| 173832 | break; | 174939 | break; |
| 173833 | case 226: /* case_exprlist ::= WHEN expr THEN expr */ | 174940 | case 228: /* case_exprlist ::= WHEN expr THEN expr */ |
| 173834 | { | 174941 | { |
| 173835 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); | 174942 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 173836 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); | 174943 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); |
| 173837 | } | 174944 | } |
| 173838 | break; | 174945 | break; |
| 173839 | case 231: /* nexprlist ::= nexprlist COMMA expr */ | 174946 | case 233: /* nexprlist ::= nexprlist COMMA expr */ |
| 173840 | {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} | 174947 | {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} |
| 173841 | break; | 174948 | break; |
| 173842 | case 232: /* nexprlist ::= expr */ | 174949 | case 234: /* nexprlist ::= expr */ |
| 173843 | {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} | 174950 | {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} |
| 173844 | break; | 174951 | break; |
| 173845 | case 234: /* paren_exprlist ::= LP exprlist RP */ | 174952 | case 236: /* paren_exprlist ::= LP exprlist RP */ |
| 173846 | case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239); | 174953 | case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241); |
| 173847 | {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} | 174954 | {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} |
| 173848 | break; | 174955 | break; |
| 173849 | case 235: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 174956 | case 237: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 173850 | { | 174957 | { |
| 173851 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, | 174958 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 173852 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, | 174959 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, |
| @@ -173856,48 +174963,48 @@ static YYACTIONTYPE yy_reduce( | |||
| 173856 | } | 174963 | } |
| 173857 | } | 174964 | } |
| 173858 | break; | 174965 | break; |
| 173859 | case 236: /* uniqueflag ::= UNIQUE */ | 174966 | case 238: /* uniqueflag ::= UNIQUE */ |
| 173860 | case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278); | 174967 | case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280); |
| 173861 | {yymsp[0].minor.yy394 = OE_Abort;} | 174968 | {yymsp[0].minor.yy394 = OE_Abort;} |
| 173862 | break; | 174969 | break; |
| 173863 | case 237: /* uniqueflag ::= */ | 174970 | case 239: /* uniqueflag ::= */ |
| 173864 | {yymsp[1].minor.yy394 = OE_None;} | 174971 | {yymsp[1].minor.yy394 = OE_None;} |
| 173865 | break; | 174972 | break; |
| 173866 | case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */ | 174973 | case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 173867 | { | 174974 | { |
| 173868 | yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); | 174975 | yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); |
| 173869 | } | 174976 | } |
| 173870 | break; | 174977 | break; |
| 173871 | case 241: /* eidlist ::= nm collate sortorder */ | 174978 | case 243: /* eidlist ::= nm collate sortorder */ |
| 173872 | { | 174979 | { |
| 173873 | yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ | 174980 | yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ |
| 173874 | } | 174981 | } |
| 173875 | break; | 174982 | break; |
| 173876 | case 244: /* cmd ::= DROP INDEX ifexists fullname */ | 174983 | case 246: /* cmd ::= DROP INDEX ifexists fullname */ |
| 173877 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} | 174984 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} |
| 173878 | break; | 174985 | break; |
| 173879 | case 245: /* cmd ::= VACUUM vinto */ | 174986 | case 247: /* cmd ::= VACUUM vinto */ |
| 173880 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} | 174987 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} |
| 173881 | break; | 174988 | break; |
| 173882 | case 246: /* cmd ::= VACUUM nm vinto */ | 174989 | case 248: /* cmd ::= VACUUM nm vinto */ |
| 173883 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} | 174990 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} |
| 173884 | break; | 174991 | break; |
| 173885 | case 249: /* cmd ::= PRAGMA nm dbnm */ | 174992 | case 251: /* cmd ::= PRAGMA nm dbnm */ |
| 173886 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} | 174993 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 173887 | break; | 174994 | break; |
| 173888 | case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | 174995 | case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 173889 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} | 174996 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 173890 | break; | 174997 | break; |
| 173891 | case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 174998 | case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 173892 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} | 174999 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 173893 | break; | 175000 | break; |
| 173894 | case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | 175001 | case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 173895 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} | 175002 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 173896 | break; | 175003 | break; |
| 173897 | case 253: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 175004 | case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 173898 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} | 175005 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 173899 | break; | 175006 | break; |
| 173900 | case 256: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 175007 | case 258: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 173901 | { | 175008 | { |
| 173902 | Token all; | 175009 | Token all; |
| 173903 | all.z = yymsp[-3].minor.yy0.z; | 175010 | all.z = yymsp[-3].minor.yy0.z; |
| @@ -173905,50 +175012,50 @@ static YYACTIONTYPE yy_reduce( | |||
| 173905 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); | 175012 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); |
| 173906 | } | 175013 | } |
| 173907 | break; | 175014 | break; |
| 173908 | case 257: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 175015 | case 259: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 173909 | { | 175016 | { |
| 173910 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394); | 175017 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394); |
| 173911 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ | 175018 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 173912 | } | 175019 | } |
| 173913 | break; | 175020 | break; |
| 173914 | case 258: /* trigger_time ::= BEFORE|AFTER */ | 175021 | case 260: /* trigger_time ::= BEFORE|AFTER */ |
| 173915 | { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } | 175022 | { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } |
| 173916 | break; | 175023 | break; |
| 173917 | case 259: /* trigger_time ::= INSTEAD OF */ | 175024 | case 261: /* trigger_time ::= INSTEAD OF */ |
| 173918 | { yymsp[-1].minor.yy394 = TK_INSTEAD;} | 175025 | { yymsp[-1].minor.yy394 = TK_INSTEAD;} |
| 173919 | break; | 175026 | break; |
| 173920 | case 260: /* trigger_time ::= */ | 175027 | case 262: /* trigger_time ::= */ |
| 173921 | { yymsp[1].minor.yy394 = TK_BEFORE; } | 175028 | { yymsp[1].minor.yy394 = TK_BEFORE; } |
| 173922 | break; | 175029 | break; |
| 173923 | case 261: /* trigger_event ::= DELETE|INSERT */ | 175030 | case 263: /* trigger_event ::= DELETE|INSERT */ |
| 173924 | case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262); | 175031 | case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264); |
| 173925 | {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} | 175032 | {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} |
| 173926 | break; | 175033 | break; |
| 173927 | case 263: /* trigger_event ::= UPDATE OF idlist */ | 175034 | case 265: /* trigger_event ::= UPDATE OF idlist */ |
| 173928 | {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} | 175035 | {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} |
| 173929 | break; | 175036 | break; |
| 173930 | case 264: /* when_clause ::= */ | 175037 | case 266: /* when_clause ::= */ |
| 173931 | case 283: /* key_opt ::= */ yytestcase(yyruleno==283); | 175038 | case 285: /* key_opt ::= */ yytestcase(yyruleno==285); |
| 173932 | { yymsp[1].minor.yy528 = 0; } | 175039 | { yymsp[1].minor.yy528 = 0; } |
| 173933 | break; | 175040 | break; |
| 173934 | case 265: /* when_clause ::= WHEN expr */ | 175041 | case 267: /* when_clause ::= WHEN expr */ |
| 173935 | case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284); | 175042 | case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286); |
| 173936 | { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } | 175043 | { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } |
| 173937 | break; | 175044 | break; |
| 173938 | case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 175045 | case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 173939 | { | 175046 | { |
| 173940 | assert( yymsp[-2].minor.yy33!=0 ); | 175047 | assert( yymsp[-2].minor.yy33!=0 ); |
| 173941 | yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; | 175048 | yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; |
| 173942 | yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; | 175049 | yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 173943 | } | 175050 | } |
| 173944 | break; | 175051 | break; |
| 173945 | case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */ | 175052 | case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 173946 | { | 175053 | { |
| 173947 | assert( yymsp[-1].minor.yy33!=0 ); | 175054 | assert( yymsp[-1].minor.yy33!=0 ); |
| 173948 | yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; | 175055 | yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 173949 | } | 175056 | } |
| 173950 | break; | 175057 | break; |
| 173951 | case 268: /* trnm ::= nm DOT nm */ | 175058 | case 270: /* trnm ::= nm DOT nm */ |
| 173952 | { | 175059 | { |
| 173953 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; | 175060 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 173954 | sqlite3ErrorMsg(pParse, | 175061 | sqlite3ErrorMsg(pParse, |
| @@ -173956,39 +175063,39 @@ static YYACTIONTYPE yy_reduce( | |||
| 173956 | "statements within triggers"); | 175063 | "statements within triggers"); |
| 173957 | } | 175064 | } |
| 173958 | break; | 175065 | break; |
| 173959 | case 269: /* tridxby ::= INDEXED BY nm */ | 175066 | case 271: /* tridxby ::= INDEXED BY nm */ |
| 173960 | { | 175067 | { |
| 173961 | sqlite3ErrorMsg(pParse, | 175068 | sqlite3ErrorMsg(pParse, |
| 173962 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " | 175069 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 173963 | "within triggers"); | 175070 | "within triggers"); |
| 173964 | } | 175071 | } |
| 173965 | break; | 175072 | break; |
| 173966 | case 270: /* tridxby ::= NOT INDEXED */ | 175073 | case 272: /* tridxby ::= NOT INDEXED */ |
| 173967 | { | 175074 | { |
| 173968 | sqlite3ErrorMsg(pParse, | 175075 | sqlite3ErrorMsg(pParse, |
| 173969 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " | 175076 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 173970 | "within triggers"); | 175077 | "within triggers"); |
| 173971 | } | 175078 | } |
| 173972 | break; | 175079 | break; |
| 173973 | case 271: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 175080 | case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 173974 | {yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);} | 175081 | {yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);} |
| 173975 | yymsp[-8].minor.yy33 = yylhsminor.yy33; | 175082 | yymsp[-8].minor.yy33 = yylhsminor.yy33; |
| 173976 | break; | 175083 | break; |
| 173977 | case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 175084 | case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 173978 | { | 175085 | { |
| 173979 | yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/ | 175086 | yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/ |
| 173980 | } | 175087 | } |
| 173981 | yymsp[-7].minor.yy33 = yylhsminor.yy33; | 175088 | yymsp[-7].minor.yy33 = yylhsminor.yy33; |
| 173982 | break; | 175089 | break; |
| 173983 | case 273: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 175090 | case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 173984 | {yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} | 175091 | {yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} |
| 173985 | yymsp[-5].minor.yy33 = yylhsminor.yy33; | 175092 | yymsp[-5].minor.yy33 = yylhsminor.yy33; |
| 173986 | break; | 175093 | break; |
| 173987 | case 274: /* trigger_cmd ::= scanpt select scanpt */ | 175094 | case 276: /* trigger_cmd ::= scanpt select scanpt */ |
| 173988 | {yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/} | 175095 | {yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/} |
| 173989 | yymsp[-2].minor.yy33 = yylhsminor.yy33; | 175096 | yymsp[-2].minor.yy33 = yylhsminor.yy33; |
| 173990 | break; | 175097 | break; |
| 173991 | case 275: /* expr ::= RAISE LP IGNORE RP */ | 175098 | case 277: /* expr ::= RAISE LP IGNORE RP */ |
| 173992 | { | 175099 | { |
| 173993 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); | 175100 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 173994 | if( yymsp[-3].minor.yy528 ){ | 175101 | if( yymsp[-3].minor.yy528 ){ |
| @@ -173996,7 +175103,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 173996 | } | 175103 | } |
| 173997 | } | 175104 | } |
| 173998 | break; | 175105 | break; |
| 173999 | case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */ | 175106 | case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 174000 | { | 175107 | { |
| 174001 | yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); | 175108 | yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 174002 | if( yymsp[-5].minor.yy528 ) { | 175109 | if( yymsp[-5].minor.yy528 ) { |
| @@ -174004,114 +175111,114 @@ static YYACTIONTYPE yy_reduce( | |||
| 174004 | } | 175111 | } |
| 174005 | } | 175112 | } |
| 174006 | break; | 175113 | break; |
| 174007 | case 277: /* raisetype ::= ROLLBACK */ | 175114 | case 279: /* raisetype ::= ROLLBACK */ |
| 174008 | {yymsp[0].minor.yy394 = OE_Rollback;} | 175115 | {yymsp[0].minor.yy394 = OE_Rollback;} |
| 174009 | break; | 175116 | break; |
| 174010 | case 279: /* raisetype ::= FAIL */ | 175117 | case 281: /* raisetype ::= FAIL */ |
| 174011 | {yymsp[0].minor.yy394 = OE_Fail;} | 175118 | {yymsp[0].minor.yy394 = OE_Fail;} |
| 174012 | break; | 175119 | break; |
| 174013 | case 280: /* cmd ::= DROP TRIGGER ifexists fullname */ | 175120 | case 282: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 174014 | { | 175121 | { |
| 174015 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); | 175122 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); |
| 174016 | } | 175123 | } |
| 174017 | break; | 175124 | break; |
| 174018 | case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 175125 | case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 174019 | { | 175126 | { |
| 174020 | sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); | 175127 | sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); |
| 174021 | } | 175128 | } |
| 174022 | break; | 175129 | break; |
| 174023 | case 282: /* cmd ::= DETACH database_kw_opt expr */ | 175130 | case 284: /* cmd ::= DETACH database_kw_opt expr */ |
| 174024 | { | 175131 | { |
| 174025 | sqlite3Detach(pParse, yymsp[0].minor.yy528); | 175132 | sqlite3Detach(pParse, yymsp[0].minor.yy528); |
| 174026 | } | 175133 | } |
| 174027 | break; | 175134 | break; |
| 174028 | case 285: /* cmd ::= REINDEX */ | 175135 | case 287: /* cmd ::= REINDEX */ |
| 174029 | {sqlite3Reindex(pParse, 0, 0);} | 175136 | {sqlite3Reindex(pParse, 0, 0);} |
| 174030 | break; | 175137 | break; |
| 174031 | case 286: /* cmd ::= REINDEX nm dbnm */ | 175138 | case 288: /* cmd ::= REINDEX nm dbnm */ |
| 174032 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} | 175139 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 174033 | break; | 175140 | break; |
| 174034 | case 287: /* cmd ::= ANALYZE */ | 175141 | case 289: /* cmd ::= ANALYZE */ |
| 174035 | {sqlite3Analyze(pParse, 0, 0);} | 175142 | {sqlite3Analyze(pParse, 0, 0);} |
| 174036 | break; | 175143 | break; |
| 174037 | case 288: /* cmd ::= ANALYZE nm dbnm */ | 175144 | case 290: /* cmd ::= ANALYZE nm dbnm */ |
| 174038 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} | 175145 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 174039 | break; | 175146 | break; |
| 174040 | case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | 175147 | case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 174041 | { | 175148 | { |
| 174042 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); | 175149 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); |
| 174043 | } | 175150 | } |
| 174044 | break; | 175151 | break; |
| 174045 | case 290: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 175152 | case 292: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 174046 | { | 175153 | { |
| 174047 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; | 175154 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 174048 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); | 175155 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 174049 | } | 175156 | } |
| 174050 | break; | 175157 | break; |
| 174051 | case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 175158 | case 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 174052 | { | 175159 | { |
| 174053 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); | 175160 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); |
| 174054 | } | 175161 | } |
| 174055 | break; | 175162 | break; |
| 174056 | case 292: /* add_column_fullname ::= fullname */ | 175163 | case 294: /* add_column_fullname ::= fullname */ |
| 174057 | { | 175164 | { |
| 174058 | disableLookaside(pParse); | 175165 | disableLookaside(pParse); |
| 174059 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); | 175166 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); |
| 174060 | } | 175167 | } |
| 174061 | break; | 175168 | break; |
| 174062 | case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 175169 | case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 174063 | { | 175170 | { |
| 174064 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); | 175171 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 174065 | } | 175172 | } |
| 174066 | break; | 175173 | break; |
| 174067 | case 294: /* cmd ::= create_vtab */ | 175174 | case 296: /* cmd ::= create_vtab */ |
| 174068 | {sqlite3VtabFinishParse(pParse,0);} | 175175 | {sqlite3VtabFinishParse(pParse,0);} |
| 174069 | break; | 175176 | break; |
| 174070 | case 295: /* cmd ::= create_vtab LP vtabarglist RP */ | 175177 | case 297: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 174071 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} | 175178 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 174072 | break; | 175179 | break; |
| 174073 | case 296: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 175180 | case 298: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 174074 | { | 175181 | { |
| 174075 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); | 175182 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); |
| 174076 | } | 175183 | } |
| 174077 | break; | 175184 | break; |
| 174078 | case 297: /* vtabarg ::= */ | 175185 | case 299: /* vtabarg ::= */ |
| 174079 | {sqlite3VtabArgInit(pParse);} | 175186 | {sqlite3VtabArgInit(pParse);} |
| 174080 | break; | 175187 | break; |
| 174081 | case 298: /* vtabargtoken ::= ANY */ | 175188 | case 300: /* vtabargtoken ::= ANY */ |
| 174082 | case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299); | 175189 | case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301); |
| 174083 | case 300: /* lp ::= LP */ yytestcase(yyruleno==300); | 175190 | case 302: /* lp ::= LP */ yytestcase(yyruleno==302); |
| 174084 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} | 175191 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 174085 | break; | 175192 | break; |
| 174086 | case 301: /* with ::= WITH wqlist */ | 175193 | case 303: /* with ::= WITH wqlist */ |
| 174087 | case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302); | 175194 | case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304); |
| 174088 | { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } | 175195 | { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } |
| 174089 | break; | 175196 | break; |
| 174090 | case 303: /* wqas ::= AS */ | 175197 | case 305: /* wqas ::= AS */ |
| 174091 | {yymsp[0].minor.yy516 = M10d_Any;} | 175198 | {yymsp[0].minor.yy516 = M10d_Any;} |
| 174092 | break; | 175199 | break; |
| 174093 | case 304: /* wqas ::= AS MATERIALIZED */ | 175200 | case 306: /* wqas ::= AS MATERIALIZED */ |
| 174094 | {yymsp[-1].minor.yy516 = M10d_Yes;} | 175201 | {yymsp[-1].minor.yy516 = M10d_Yes;} |
| 174095 | break; | 175202 | break; |
| 174096 | case 305: /* wqas ::= AS NOT MATERIALIZED */ | 175203 | case 307: /* wqas ::= AS NOT MATERIALIZED */ |
| 174097 | {yymsp[-2].minor.yy516 = M10d_No;} | 175204 | {yymsp[-2].minor.yy516 = M10d_No;} |
| 174098 | break; | 175205 | break; |
| 174099 | case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */ | 175206 | case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 174100 | { | 175207 | { |
| 174101 | yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/ | 175208 | yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/ |
| 174102 | } | 175209 | } |
| 174103 | break; | 175210 | break; |
| 174104 | case 307: /* wqlist ::= wqitem */ | 175211 | case 309: /* wqlist ::= wqitem */ |
| 174105 | { | 175212 | { |
| 174106 | yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ | 175213 | yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ |
| 174107 | } | 175214 | } |
| 174108 | break; | 175215 | break; |
| 174109 | case 308: /* wqlist ::= wqlist COMMA wqitem */ | 175216 | case 310: /* wqlist ::= wqlist COMMA wqitem */ |
| 174110 | { | 175217 | { |
| 174111 | yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); | 175218 | yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); |
| 174112 | } | 175219 | } |
| 174113 | break; | 175220 | break; |
| 174114 | case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 175221 | case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 174115 | { | 175222 | { |
| 174116 | assert( yymsp[0].minor.yy41!=0 ); | 175223 | assert( yymsp[0].minor.yy41!=0 ); |
| 174117 | sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); | 175224 | sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); |
| @@ -174120,7 +175227,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 174120 | } | 175227 | } |
| 174121 | yymsp[-2].minor.yy41 = yylhsminor.yy41; | 175228 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 174122 | break; | 175229 | break; |
| 174123 | case 310: /* windowdefn ::= nm AS LP window RP */ | 175230 | case 312: /* windowdefn ::= nm AS LP window RP */ |
| 174124 | { | 175231 | { |
| 174125 | if( ALWAYS(yymsp[-1].minor.yy41) ){ | 175232 | if( ALWAYS(yymsp[-1].minor.yy41) ){ |
| 174126 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); | 175233 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| @@ -174129,83 +175236,83 @@ static YYACTIONTYPE yy_reduce( | |||
| 174129 | } | 175236 | } |
| 174130 | yymsp[-4].minor.yy41 = yylhsminor.yy41; | 175237 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 174131 | break; | 175238 | break; |
| 174132 | case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 175239 | case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 174133 | { | 175240 | { |
| 174134 | yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); | 175241 | yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); |
| 174135 | } | 175242 | } |
| 174136 | break; | 175243 | break; |
| 174137 | case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 175244 | case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 174138 | { | 175245 | { |
| 174139 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); | 175246 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); |
| 174140 | } | 175247 | } |
| 174141 | yymsp[-5].minor.yy41 = yylhsminor.yy41; | 175248 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 174142 | break; | 175249 | break; |
| 174143 | case 313: /* window ::= ORDER BY sortlist frame_opt */ | 175250 | case 315: /* window ::= ORDER BY sortlist frame_opt */ |
| 174144 | { | 175251 | { |
| 174145 | yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); | 175252 | yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); |
| 174146 | } | 175253 | } |
| 174147 | break; | 175254 | break; |
| 174148 | case 314: /* window ::= nm ORDER BY sortlist frame_opt */ | 175255 | case 316: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 174149 | { | 175256 | { |
| 174150 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); | 175257 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| 174151 | } | 175258 | } |
| 174152 | yymsp[-4].minor.yy41 = yylhsminor.yy41; | 175259 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 174153 | break; | 175260 | break; |
| 174154 | case 315: /* window ::= nm frame_opt */ | 175261 | case 317: /* window ::= nm frame_opt */ |
| 174155 | { | 175262 | { |
| 174156 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); | 175263 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); |
| 174157 | } | 175264 | } |
| 174158 | yymsp[-1].minor.yy41 = yylhsminor.yy41; | 175265 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 174159 | break; | 175266 | break; |
| 174160 | case 316: /* frame_opt ::= */ | 175267 | case 318: /* frame_opt ::= */ |
| 174161 | { | 175268 | { |
| 174162 | yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); | 175269 | yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 174163 | } | 175270 | } |
| 174164 | break; | 175271 | break; |
| 174165 | case 317: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 175272 | case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 174166 | { | 175273 | { |
| 174167 | yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516); | 175274 | yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516); |
| 174168 | } | 175275 | } |
| 174169 | yymsp[-2].minor.yy41 = yylhsminor.yy41; | 175276 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 174170 | break; | 175277 | break; |
| 174171 | case 318: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 175278 | case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 174172 | { | 175279 | { |
| 174173 | yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516); | 175280 | yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516); |
| 174174 | } | 175281 | } |
| 174175 | yymsp[-5].minor.yy41 = yylhsminor.yy41; | 175282 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 174176 | break; | 175283 | break; |
| 174177 | case 320: /* frame_bound_s ::= frame_bound */ | 175284 | case 322: /* frame_bound_s ::= frame_bound */ |
| 174178 | case 322: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==322); | 175285 | case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324); |
| 174179 | {yylhsminor.yy595 = yymsp[0].minor.yy595;} | 175286 | {yylhsminor.yy595 = yymsp[0].minor.yy595;} |
| 174180 | yymsp[0].minor.yy595 = yylhsminor.yy595; | 175287 | yymsp[0].minor.yy595 = yylhsminor.yy595; |
| 174181 | break; | 175288 | break; |
| 174182 | case 321: /* frame_bound_s ::= UNBOUNDED PRECEDING */ | 175289 | case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 174183 | case 323: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==323); | 175290 | case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325); |
| 174184 | case 325: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==325); | 175291 | case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327); |
| 174185 | {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} | 175292 | {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} |
| 174186 | yymsp[-1].minor.yy595 = yylhsminor.yy595; | 175293 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 174187 | break; | 175294 | break; |
| 174188 | case 324: /* frame_bound ::= expr PRECEDING|FOLLOWING */ | 175295 | case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 174189 | {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} | 175296 | {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} |
| 174190 | yymsp[-1].minor.yy595 = yylhsminor.yy595; | 175297 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 174191 | break; | 175298 | break; |
| 174192 | case 326: /* frame_exclude_opt ::= */ | 175299 | case 328: /* frame_exclude_opt ::= */ |
| 174193 | {yymsp[1].minor.yy516 = 0;} | 175300 | {yymsp[1].minor.yy516 = 0;} |
| 174194 | break; | 175301 | break; |
| 174195 | case 327: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ | 175302 | case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 174196 | {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} | 175303 | {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} |
| 174197 | break; | 175304 | break; |
| 174198 | case 328: /* frame_exclude ::= NO OTHERS */ | 175305 | case 330: /* frame_exclude ::= NO OTHERS */ |
| 174199 | case 329: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==329); | 175306 | case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331); |
| 174200 | {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} | 175307 | {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} |
| 174201 | break; | 175308 | break; |
| 174202 | case 330: /* frame_exclude ::= GROUP|TIES */ | 175309 | case 332: /* frame_exclude ::= GROUP|TIES */ |
| 174203 | {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} | 175310 | {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} |
| 174204 | break; | 175311 | break; |
| 174205 | case 331: /* window_clause ::= WINDOW windowdefn_list */ | 175312 | case 333: /* window_clause ::= WINDOW windowdefn_list */ |
| 174206 | { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } | 175313 | { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } |
| 174207 | break; | 175314 | break; |
| 174208 | case 332: /* filter_over ::= filter_clause over_clause */ | 175315 | case 334: /* filter_over ::= filter_clause over_clause */ |
| 174209 | { | 175316 | { |
| 174210 | if( yymsp[0].minor.yy41 ){ | 175317 | if( yymsp[0].minor.yy41 ){ |
| 174211 | yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; | 175318 | yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; |
| @@ -174216,13 +175323,13 @@ static YYACTIONTYPE yy_reduce( | |||
| 174216 | } | 175323 | } |
| 174217 | yymsp[-1].minor.yy41 = yylhsminor.yy41; | 175324 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 174218 | break; | 175325 | break; |
| 174219 | case 333: /* filter_over ::= over_clause */ | 175326 | case 335: /* filter_over ::= over_clause */ |
| 174220 | { | 175327 | { |
| 174221 | yylhsminor.yy41 = yymsp[0].minor.yy41; | 175328 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174222 | } | 175329 | } |
| 174223 | yymsp[0].minor.yy41 = yylhsminor.yy41; | 175330 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 174224 | break; | 175331 | break; |
| 174225 | case 334: /* filter_over ::= filter_clause */ | 175332 | case 336: /* filter_over ::= filter_clause */ |
| 174226 | { | 175333 | { |
| 174227 | yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 175334 | yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 174228 | if( yylhsminor.yy41 ){ | 175335 | if( yylhsminor.yy41 ){ |
| @@ -174234,13 +175341,13 @@ static YYACTIONTYPE yy_reduce( | |||
| 174234 | } | 175341 | } |
| 174235 | yymsp[0].minor.yy41 = yylhsminor.yy41; | 175342 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 174236 | break; | 175343 | break; |
| 174237 | case 335: /* over_clause ::= OVER LP window RP */ | 175344 | case 337: /* over_clause ::= OVER LP window RP */ |
| 174238 | { | 175345 | { |
| 174239 | yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; | 175346 | yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; |
| 174240 | assert( yymsp[-3].minor.yy41!=0 ); | 175347 | assert( yymsp[-3].minor.yy41!=0 ); |
| 174241 | } | 175348 | } |
| 174242 | break; | 175349 | break; |
| 174243 | case 336: /* over_clause ::= OVER nm */ | 175350 | case 338: /* over_clause ::= OVER nm */ |
| 174244 | { | 175351 | { |
| 174245 | yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 175352 | yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 174246 | if( yymsp[-1].minor.yy41 ){ | 175353 | if( yymsp[-1].minor.yy41 ){ |
| @@ -174248,75 +175355,75 @@ static YYACTIONTYPE yy_reduce( | |||
| 174248 | } | 175355 | } |
| 174249 | } | 175356 | } |
| 174250 | break; | 175357 | break; |
| 174251 | case 337: /* filter_clause ::= FILTER LP WHERE expr RP */ | 175358 | case 339: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 174252 | { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } | 175359 | { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } |
| 174253 | break; | 175360 | break; |
| 174254 | default: | 175361 | default: |
| 174255 | /* (338) input ::= cmdlist */ yytestcase(yyruleno==338); | 175362 | /* (340) input ::= cmdlist */ yytestcase(yyruleno==340); |
| 174256 | /* (339) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==339); | 175363 | /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341); |
| 174257 | /* (340) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=340); | 175364 | /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342); |
| 174258 | /* (341) ecmd ::= SEMI */ yytestcase(yyruleno==341); | 175365 | /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343); |
| 174259 | /* (342) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==342); | 175366 | /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344); |
| 174260 | /* (343) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=343); | 175367 | /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345); |
| 174261 | /* (344) trans_opt ::= */ yytestcase(yyruleno==344); | 175368 | /* (346) trans_opt ::= */ yytestcase(yyruleno==346); |
| 174262 | /* (345) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==345); | 175369 | /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347); |
| 174263 | /* (346) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==346); | 175370 | /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348); |
| 174264 | /* (347) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==347); | 175371 | /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349); |
| 174265 | /* (348) savepoint_opt ::= */ yytestcase(yyruleno==348); | 175372 | /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350); |
| 174266 | /* (349) cmd ::= create_table create_table_args */ yytestcase(yyruleno==349); | 175373 | /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351); |
| 174267 | /* (350) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=350); | 175374 | /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352); |
| 174268 | /* (351) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==351); | 175375 | /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353); |
| 174269 | /* (352) columnlist ::= columnname carglist */ yytestcase(yyruleno==352); | 175376 | /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354); |
| 174270 | /* (353) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==353); | 175377 | /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355); |
| 174271 | /* (354) nm ::= STRING */ yytestcase(yyruleno==354); | 175378 | /* (356) nm ::= STRING */ yytestcase(yyruleno==356); |
| 174272 | /* (355) typetoken ::= typename */ yytestcase(yyruleno==355); | 175379 | /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); |
| 174273 | /* (356) typename ::= ID|STRING */ yytestcase(yyruleno==356); | 175380 | /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); |
| 174274 | /* (357) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); | 175381 | /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); |
| 174275 | /* (358) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=358); | 175382 | /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); |
| 174276 | /* (359) carglist ::= carglist ccons */ yytestcase(yyruleno==359); | 175383 | /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); |
| 174277 | /* (360) carglist ::= */ yytestcase(yyruleno==360); | 175384 | /* (362) carglist ::= */ yytestcase(yyruleno==362); |
| 174278 | /* (361) ccons ::= NULL onconf */ yytestcase(yyruleno==361); | 175385 | /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); |
| 174279 | /* (362) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==362); | 175386 | /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); |
| 174280 | /* (363) ccons ::= AS generated */ yytestcase(yyruleno==363); | 175387 | /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); |
| 174281 | /* (364) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==364); | 175388 | /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); |
| 174282 | /* (365) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==365); | 175389 | /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); |
| 174283 | /* (366) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=366); | 175390 | /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); |
| 174284 | /* (367) tconscomma ::= */ yytestcase(yyruleno==367); | 175391 | /* (369) tconscomma ::= */ yytestcase(yyruleno==369); |
| 174285 | /* (368) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=368); | 175392 | /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); |
| 174286 | /* (369) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=369); | 175393 | /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); |
| 174287 | /* (370) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=370); | 175394 | /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); |
| 174288 | /* (371) oneselect ::= values */ yytestcase(yyruleno==371); | 175395 | /* (373) oneselect ::= values */ yytestcase(yyruleno==373); |
| 174289 | /* (372) sclp ::= selcollist COMMA */ yytestcase(yyruleno==372); | 175396 | /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); |
| 174290 | /* (373) as ::= ID|STRING */ yytestcase(yyruleno==373); | 175397 | /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); |
| 174291 | /* (374) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=374); | 175398 | /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376); |
| 174292 | /* (375) returning ::= */ yytestcase(yyruleno==375); | 175399 | /* (377) returning ::= */ yytestcase(yyruleno==377); |
| 174293 | /* (376) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=376); | 175400 | /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); |
| 174294 | /* (377) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==377); | 175401 | /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); |
| 174295 | /* (378) case_operand ::= expr */ yytestcase(yyruleno==378); | 175402 | /* (380) case_operand ::= expr */ yytestcase(yyruleno==380); |
| 174296 | /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); | 175403 | /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); |
| 174297 | /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); | 175404 | /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); |
| 174298 | /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); | 175405 | /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); |
| 174299 | /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); | 175406 | /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); |
| 174300 | /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); | 175407 | /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); |
| 174301 | /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); | 175408 | /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386); |
| 174302 | /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); | 175409 | /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387); |
| 174303 | /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); | 175410 | /* (388) foreach_clause ::= */ yytestcase(yyruleno==388); |
| 174304 | /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); | 175411 | /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389); |
| 174305 | /* (388) trnm ::= nm */ yytestcase(yyruleno==388); | 175412 | /* (390) trnm ::= nm */ yytestcase(yyruleno==390); |
| 174306 | /* (389) tridxby ::= */ yytestcase(yyruleno==389); | 175413 | /* (391) tridxby ::= */ yytestcase(yyruleno==391); |
| 174307 | /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); | 175414 | /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392); |
| 174308 | /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); | 175415 | /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393); |
| 174309 | /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); | 175416 | /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394); |
| 174310 | /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); | 175417 | /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395); |
| 174311 | /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); | 175418 | /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396); |
| 174312 | /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); | 175419 | /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397); |
| 174313 | /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); | 175420 | /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398); |
| 174314 | /* (397) anylist ::= */ yytestcase(yyruleno==397); | 175421 | /* (399) anylist ::= */ yytestcase(yyruleno==399); |
| 174315 | /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); | 175422 | /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400); |
| 174316 | /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); | 175423 | /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401); |
| 174317 | /* (400) with ::= */ yytestcase(yyruleno==400); | 175424 | /* (402) with ::= */ yytestcase(yyruleno==402); |
| 174318 | /* (401) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=401); | 175425 | /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403); |
| 174319 | /* (402) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=402); | 175426 | /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404); |
| 174320 | break; | 175427 | break; |
| 174321 | /********** End reduce actions ************************************************/ | 175428 | /********** End reduce actions ************************************************/ |
| 174322 | }; | 175429 | }; |
| @@ -176440,7 +177547,9 @@ SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*); | |||
| 176440 | #ifdef SQLITE_ENABLE_STMTVTAB | 177547 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 176441 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); | 177548 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); |
| 176442 | #endif | 177549 | #endif |
| 176443 | 177550 | #ifdef SQLITE_EXTRA_AUTOEXT | |
| 177551 | int SQLITE_EXTRA_AUTOEXT(sqlite3*); | ||
| 177552 | #endif | ||
| 176444 | /* | 177553 | /* |
| 176445 | ** An array of pointers to extension initializer functions for | 177554 | ** An array of pointers to extension initializer functions for |
| 176446 | ** built-in extensions. | 177555 | ** built-in extensions. |
| @@ -176474,6 +177583,9 @@ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = { | |||
| 176474 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB | 177583 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 176475 | sqlite3VdbeBytecodeVtabInit, | 177584 | sqlite3VdbeBytecodeVtabInit, |
| 176476 | #endif | 177585 | #endif |
| 177586 | #ifdef SQLITE_EXTRA_AUTOEXT | ||
| 177587 | SQLITE_EXTRA_AUTOEXT, | ||
| 177588 | #endif | ||
| 176477 | }; | 177589 | }; |
| 176478 | 177590 | ||
| 176479 | #ifndef SQLITE_AMALGAMATION | 177591 | #ifndef SQLITE_AMALGAMATION |
| @@ -176548,6 +177660,32 @@ SQLITE_API char *sqlite3_temp_directory = 0; | |||
| 176548 | SQLITE_API char *sqlite3_data_directory = 0; | 177660 | SQLITE_API char *sqlite3_data_directory = 0; |
| 176549 | 177661 | ||
| 176550 | /* | 177662 | /* |
| 177663 | ** Determine whether or not high-precision (long double) floating point | ||
| 177664 | ** math works correctly on CPU currently running. | ||
| 177665 | */ | ||
| 177666 | static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){ | ||
| 177667 | if( sizeof(LONGDOUBLE_TYPE)<=8 ){ | ||
| 177668 | /* If the size of "long double" is not more than 8, then | ||
| 177669 | ** high-precision math is not possible. */ | ||
| 177670 | return 0; | ||
| 177671 | }else{ | ||
| 177672 | /* Just because sizeof(long double)>8 does not mean that the underlying | ||
| 177673 | ** hardware actually supports high-precision floating point. For example, | ||
| 177674 | ** clearing the 0x100 bit in the floating-point control word on Intel | ||
| 177675 | ** processors will make long double work like double, even though long | ||
| 177676 | ** double takes up more space. The only way to determine if long double | ||
| 177677 | ** actually works is to run an experiment. */ | ||
| 177678 | LONGDOUBLE_TYPE a, b, c; | ||
| 177679 | rc++; | ||
| 177680 | a = 1.0+rc*0.1; | ||
| 177681 | b = 1.0e+18+rc*25.0; | ||
| 177682 | c = a+b; | ||
| 177683 | return b!=c; | ||
| 177684 | } | ||
| 177685 | } | ||
| 177686 | |||
| 177687 | |||
| 177688 | /* | ||
| 176551 | ** Initialize SQLite. | 177689 | ** Initialize SQLite. |
| 176552 | ** | 177690 | ** |
| 176553 | ** This routine must be called to initialize the memory allocation, | 177691 | ** This routine must be called to initialize the memory allocation, |
| @@ -176742,6 +177880,12 @@ SQLITE_API int sqlite3_initialize(void){ | |||
| 176742 | } | 177880 | } |
| 176743 | #endif | 177881 | #endif |
| 176744 | 177882 | ||
| 177883 | /* Experimentally determine if high-precision floating point is | ||
| 177884 | ** available. */ | ||
| 177885 | #ifndef SQLITE_OMIT_WSD | ||
| 177886 | sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc); | ||
| 177887 | #endif | ||
| 177888 | |||
| 176745 | return rc; | 177889 | return rc; |
| 176746 | } | 177890 | } |
| 176747 | 177891 | ||
| @@ -177312,6 +178456,10 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3 *db){ | |||
| 177312 | SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ | 178456 | SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ |
| 177313 | va_list ap; | 178457 | va_list ap; |
| 177314 | int rc; | 178458 | int rc; |
| 178459 | |||
| 178460 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 178461 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | ||
| 178462 | #endif | ||
| 177315 | sqlite3_mutex_enter(db->mutex); | 178463 | sqlite3_mutex_enter(db->mutex); |
| 177316 | va_start(ap, op); | 178464 | va_start(ap, op); |
| 177317 | switch( op ){ | 178465 | switch( op ){ |
| @@ -177641,6 +178789,14 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){ | |||
| 177641 | } | 178789 | } |
| 177642 | #endif | 178790 | #endif |
| 177643 | 178791 | ||
| 178792 | while( db->pDbData ){ | ||
| 178793 | DbClientData *p = db->pDbData; | ||
| 178794 | db->pDbData = p->pNext; | ||
| 178795 | assert( p->pData!=0 ); | ||
| 178796 | if( p->xDestructor ) p->xDestructor(p->pData); | ||
| 178797 | sqlite3_free(p); | ||
| 178798 | } | ||
| 178799 | |||
| 177644 | /* Convert the connection into a zombie and then close it. | 178800 | /* Convert the connection into a zombie and then close it. |
| 177645 | */ | 178801 | */ |
| 177646 | db->eOpenState = SQLITE_STATE_ZOMBIE; | 178802 | db->eOpenState = SQLITE_STATE_ZOMBIE; |
| @@ -178715,6 +179871,12 @@ SQLITE_API void *sqlite3_preupdate_hook( | |||
| 178715 | void *pArg /* First callback argument */ | 179871 | void *pArg /* First callback argument */ |
| 178716 | ){ | 179872 | ){ |
| 178717 | void *pRet; | 179873 | void *pRet; |
| 179874 | |||
| 179875 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 179876 | if( db==0 ){ | ||
| 179877 | return 0; | ||
| 179878 | } | ||
| 179879 | #endif | ||
| 178718 | sqlite3_mutex_enter(db->mutex); | 179880 | sqlite3_mutex_enter(db->mutex); |
| 178719 | pRet = db->pPreUpdateArg; | 179881 | pRet = db->pPreUpdateArg; |
| 178720 | db->xPreUpdateCallback = xCallback; | 179882 | db->xPreUpdateCallback = xCallback; |
| @@ -178861,7 +180023,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( | |||
| 178861 | if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){ | 180023 | if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){ |
| 178862 | /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint | 180024 | /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint |
| 178863 | ** mode: */ | 180025 | ** mode: */ |
| 178864 | return SQLITE_MISUSE; | 180026 | return SQLITE_MISUSE_BKPT; |
| 178865 | } | 180027 | } |
| 178866 | 180028 | ||
| 178867 | sqlite3_mutex_enter(db->mutex); | 180029 | sqlite3_mutex_enter(db->mutex); |
| @@ -180098,6 +181260,69 @@ SQLITE_API int sqlite3_collation_needed16( | |||
| 180098 | } | 181260 | } |
| 180099 | #endif /* SQLITE_OMIT_UTF16 */ | 181261 | #endif /* SQLITE_OMIT_UTF16 */ |
| 180100 | 181262 | ||
| 181263 | /* | ||
| 181264 | ** Find existing client data. | ||
| 181265 | */ | ||
| 181266 | SQLITE_API void *sqlite3_get_clientdata(sqlite3 *db, const char *zName){ | ||
| 181267 | DbClientData *p; | ||
| 181268 | sqlite3_mutex_enter(db->mutex); | ||
| 181269 | for(p=db->pDbData; p; p=p->pNext){ | ||
| 181270 | if( strcmp(p->zName, zName)==0 ){ | ||
| 181271 | void *pResult = p->pData; | ||
| 181272 | sqlite3_mutex_leave(db->mutex); | ||
| 181273 | return pResult; | ||
| 181274 | } | ||
| 181275 | } | ||
| 181276 | sqlite3_mutex_leave(db->mutex); | ||
| 181277 | return 0; | ||
| 181278 | } | ||
| 181279 | |||
| 181280 | /* | ||
| 181281 | ** Add new client data to a database connection. | ||
| 181282 | */ | ||
| 181283 | SQLITE_API int sqlite3_set_clientdata( | ||
| 181284 | sqlite3 *db, /* Attach client data to this connection */ | ||
| 181285 | const char *zName, /* Name of the client data */ | ||
| 181286 | void *pData, /* The client data itself */ | ||
| 181287 | void (*xDestructor)(void*) /* Destructor */ | ||
| 181288 | ){ | ||
| 181289 | DbClientData *p, **pp; | ||
| 181290 | sqlite3_mutex_enter(db->mutex); | ||
| 181291 | pp = &db->pDbData; | ||
| 181292 | for(p=db->pDbData; p && strcmp(p->zName,zName); p=p->pNext){ | ||
| 181293 | pp = &p->pNext; | ||
| 181294 | } | ||
| 181295 | if( p ){ | ||
| 181296 | assert( p->pData!=0 ); | ||
| 181297 | if( p->xDestructor ) p->xDestructor(p->pData); | ||
| 181298 | if( pData==0 ){ | ||
| 181299 | *pp = p->pNext; | ||
| 181300 | sqlite3_free(p); | ||
| 181301 | sqlite3_mutex_leave(db->mutex); | ||
| 181302 | return SQLITE_OK; | ||
| 181303 | } | ||
| 181304 | }else if( pData==0 ){ | ||
| 181305 | sqlite3_mutex_leave(db->mutex); | ||
| 181306 | return SQLITE_OK; | ||
| 181307 | }else{ | ||
| 181308 | size_t n = strlen(zName); | ||
| 181309 | p = sqlite3_malloc64( sizeof(DbClientData)+n+1 ); | ||
| 181310 | if( p==0 ){ | ||
| 181311 | if( xDestructor ) xDestructor(pData); | ||
| 181312 | sqlite3_mutex_leave(db->mutex); | ||
| 181313 | return SQLITE_NOMEM; | ||
| 181314 | } | ||
| 181315 | memcpy(p->zName, zName, n+1); | ||
| 181316 | p->pNext = db->pDbData; | ||
| 181317 | db->pDbData = p; | ||
| 181318 | } | ||
| 181319 | p->pData = pData; | ||
| 181320 | p->xDestructor = xDestructor; | ||
| 181321 | sqlite3_mutex_leave(db->mutex); | ||
| 181322 | return SQLITE_OK; | ||
| 181323 | } | ||
| 181324 | |||
| 181325 | |||
| 180101 | #ifndef SQLITE_OMIT_DEPRECATED | 181326 | #ifndef SQLITE_OMIT_DEPRECATED |
| 180102 | /* | 181327 | /* |
| 180103 | ** This function is now an anachronism. It used to be used to recover from a | 181328 | ** This function is now an anachronism. It used to be used to recover from a |
| @@ -180447,6 +181672,28 @@ SQLITE_API int sqlite3_test_control(int op, ...){ | |||
| 180447 | } | 181672 | } |
| 180448 | #endif | 181673 | #endif |
| 180449 | 181674 | ||
| 181675 | /* sqlite3_test_control(SQLITE_TESTCTRL_FK_NO_ACTION, sqlite3 *db, int b); | ||
| 181676 | ** | ||
| 181677 | ** If b is true, then activate the SQLITE_FkNoAction setting. If b is | ||
| 181678 | ** false then clearn that setting. If the SQLITE_FkNoAction setting is | ||
| 181679 | ** abled, all foreign key ON DELETE and ON UPDATE actions behave as if | ||
| 181680 | ** they were NO ACTION, regardless of how they are defined. | ||
| 181681 | ** | ||
| 181682 | ** NB: One must usually run "PRAGMA writable_schema=RESET" after | ||
| 181683 | ** using this test-control, before it will take full effect. failing | ||
| 181684 | ** to reset the schema can result in some unexpected behavior. | ||
| 181685 | */ | ||
| 181686 | case SQLITE_TESTCTRL_FK_NO_ACTION: { | ||
| 181687 | sqlite3 *db = va_arg(ap, sqlite3*); | ||
| 181688 | int b = va_arg(ap, int); | ||
| 181689 | if( b ){ | ||
| 181690 | db->flags |= SQLITE_FkNoAction; | ||
| 181691 | }else{ | ||
| 181692 | db->flags &= ~SQLITE_FkNoAction; | ||
| 181693 | } | ||
| 181694 | break; | ||
| 181695 | } | ||
| 181696 | |||
| 180450 | /* | 181697 | /* |
| 180451 | ** sqlite3_test_control(BITVEC_TEST, size, program) | 181698 | ** sqlite3_test_control(BITVEC_TEST, size, program) |
| 180452 | ** | 181699 | ** |
| @@ -180871,11 +182118,11 @@ SQLITE_API int sqlite3_test_control(int op, ...){ | |||
| 180871 | ** X<0 Make no changes to the bUseLongDouble. Just report value. | 182118 | ** X<0 Make no changes to the bUseLongDouble. Just report value. |
| 180872 | ** X==0 Disable bUseLongDouble | 182119 | ** X==0 Disable bUseLongDouble |
| 180873 | ** X==1 Enable bUseLongDouble | 182120 | ** X==1 Enable bUseLongDouble |
| 180874 | ** X==2 Set bUseLongDouble to its default value for this platform | 182121 | ** X>=2 Set bUseLongDouble to its default value for this platform |
| 180875 | */ | 182122 | */ |
| 180876 | case SQLITE_TESTCTRL_USELONGDOUBLE: { | 182123 | case SQLITE_TESTCTRL_USELONGDOUBLE: { |
| 180877 | int b = va_arg(ap, int); | 182124 | int b = va_arg(ap, int); |
| 180878 | if( b==2 ) b = sizeof(LONGDOUBLE_TYPE)>8; | 182125 | if( b>=2 ) b = hasHighPrecisionDouble(b); |
| 180879 | if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; | 182126 | if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; |
| 180880 | rc = sqlite3Config.bUseLongDouble!=0; | 182127 | rc = sqlite3Config.bUseLongDouble!=0; |
| 180881 | break; | 182128 | break; |
| @@ -181289,7 +182536,7 @@ SQLITE_API int sqlite3_compileoption_used(const char *zOptName){ | |||
| 181289 | int nOpt; | 182536 | int nOpt; |
| 181290 | const char **azCompileOpt; | 182537 | const char **azCompileOpt; |
| 181291 | 182538 | ||
| 181292 | #if SQLITE_ENABLE_API_ARMOR | 182539 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 181293 | if( zOptName==0 ){ | 182540 | if( zOptName==0 ){ |
| 181294 | (void)SQLITE_MISUSE_BKPT; | 182541 | (void)SQLITE_MISUSE_BKPT; |
| 181295 | return 0; | 182542 | return 0; |
| @@ -181484,6 +182731,9 @@ SQLITE_API int sqlite3_unlock_notify( | |||
| 181484 | ){ | 182731 | ){ |
| 181485 | int rc = SQLITE_OK; | 182732 | int rc = SQLITE_OK; |
| 181486 | 182733 | ||
| 182734 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 182735 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | ||
| 182736 | #endif | ||
| 181487 | sqlite3_mutex_enter(db->mutex); | 182737 | sqlite3_mutex_enter(db->mutex); |
| 181488 | enterMutex(); | 182738 | enterMutex(); |
| 181489 | 182739 | ||
| @@ -182505,6 +183755,7 @@ struct Fts3Table { | |||
| 182505 | int nPgsz; /* Page size for host database */ | 183755 | int nPgsz; /* Page size for host database */ |
| 182506 | char *zSegmentsTbl; /* Name of %_segments table */ | 183756 | char *zSegmentsTbl; /* Name of %_segments table */ |
| 182507 | sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ | 183757 | sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ |
| 183758 | int iSavepoint; | ||
| 182508 | 183759 | ||
| 182509 | /* | 183760 | /* |
| 182510 | ** The following array of hash tables is used to buffer pending index | 183761 | ** The following array of hash tables is used to buffer pending index |
| @@ -183248,6 +184499,7 @@ static void fts3DeclareVtab(int *pRc, Fts3Table *p){ | |||
| 183248 | 184499 | ||
| 183249 | zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); | 184500 | zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); |
| 183250 | sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); | 184501 | sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 184502 | sqlite3_vtab_config(p->db, SQLITE_VTAB_INNOCUOUS); | ||
| 183251 | 184503 | ||
| 183252 | /* Create a list of user columns for the virtual table */ | 184504 | /* Create a list of user columns for the virtual table */ |
| 183253 | zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); | 184505 | zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); |
| @@ -186497,6 +187749,8 @@ static int fts3RenameMethod( | |||
| 186497 | rc = sqlite3Fts3PendingTermsFlush(p); | 187749 | rc = sqlite3Fts3PendingTermsFlush(p); |
| 186498 | } | 187750 | } |
| 186499 | 187751 | ||
| 187752 | p->bIgnoreSavepoint = 1; | ||
| 187753 | |||
| 186500 | if( p->zContentTbl==0 ){ | 187754 | if( p->zContentTbl==0 ){ |
| 186501 | fts3DbExec(&rc, db, | 187755 | fts3DbExec(&rc, db, |
| 186502 | "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", | 187756 | "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", |
| @@ -186524,6 +187778,8 @@ static int fts3RenameMethod( | |||
| 186524 | "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", | 187778 | "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", |
| 186525 | p->zDb, p->zName, zName | 187779 | p->zDb, p->zName, zName |
| 186526 | ); | 187780 | ); |
| 187781 | |||
| 187782 | p->bIgnoreSavepoint = 0; | ||
| 186527 | return rc; | 187783 | return rc; |
| 186528 | } | 187784 | } |
| 186529 | 187785 | ||
| @@ -186534,12 +187790,28 @@ static int fts3RenameMethod( | |||
| 186534 | */ | 187790 | */ |
| 186535 | static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ | 187791 | static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186536 | int rc = SQLITE_OK; | 187792 | int rc = SQLITE_OK; |
| 186537 | UNUSED_PARAMETER(iSavepoint); | 187793 | Fts3Table *pTab = (Fts3Table*)pVtab; |
| 186538 | assert( ((Fts3Table *)pVtab)->inTransaction ); | 187794 | assert( pTab->inTransaction ); |
| 186539 | assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint ); | 187795 | assert( pTab->mxSavepoint<=iSavepoint ); |
| 186540 | TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint ); | 187796 | TESTONLY( pTab->mxSavepoint = iSavepoint ); |
| 186541 | if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){ | 187797 | |
| 186542 | rc = fts3SyncMethod(pVtab); | 187798 | if( pTab->bIgnoreSavepoint==0 ){ |
| 187799 | if( fts3HashCount(&pTab->aIndex[0].hPending)>0 ){ | ||
| 187800 | char *zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", | ||
| 187801 | pTab->zDb, pTab->zName, pTab->zName | ||
| 187802 | ); | ||
| 187803 | if( zSql ){ | ||
| 187804 | pTab->bIgnoreSavepoint = 1; | ||
| 187805 | rc = sqlite3_exec(pTab->db, zSql, 0, 0, 0); | ||
| 187806 | pTab->bIgnoreSavepoint = 0; | ||
| 187807 | sqlite3_free(zSql); | ||
| 187808 | }else{ | ||
| 187809 | rc = SQLITE_NOMEM; | ||
| 187810 | } | ||
| 187811 | } | ||
| 187812 | if( rc==SQLITE_OK ){ | ||
| 187813 | pTab->iSavepoint = iSavepoint+1; | ||
| 187814 | } | ||
| 186543 | } | 187815 | } |
| 186544 | return rc; | 187816 | return rc; |
| 186545 | } | 187817 | } |
| @@ -186550,12 +187822,11 @@ static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ | |||
| 186550 | ** This is a no-op. | 187822 | ** This is a no-op. |
| 186551 | */ | 187823 | */ |
| 186552 | static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ | 187824 | static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186553 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); | 187825 | Fts3Table *pTab = (Fts3Table*)pVtab; |
| 186554 | UNUSED_PARAMETER(iSavepoint); | 187826 | assert( pTab->inTransaction ); |
| 186555 | UNUSED_PARAMETER(pVtab); | 187827 | assert( pTab->mxSavepoint >= iSavepoint ); |
| 186556 | assert( p->inTransaction ); | 187828 | TESTONLY( pTab->mxSavepoint = iSavepoint-1 ); |
| 186557 | assert( p->mxSavepoint >= iSavepoint ); | 187829 | pTab->iSavepoint = iSavepoint; |
| 186558 | TESTONLY( p->mxSavepoint = iSavepoint-1 ); | ||
| 186559 | return SQLITE_OK; | 187830 | return SQLITE_OK; |
| 186560 | } | 187831 | } |
| 186561 | 187832 | ||
| @@ -186565,11 +187836,13 @@ static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ | |||
| 186565 | ** Discard the contents of the pending terms table. | 187836 | ** Discard the contents of the pending terms table. |
| 186566 | */ | 187837 | */ |
| 186567 | static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ | 187838 | static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186568 | Fts3Table *p = (Fts3Table*)pVtab; | 187839 | Fts3Table *pTab = (Fts3Table*)pVtab; |
| 186569 | UNUSED_PARAMETER(iSavepoint); | 187840 | UNUSED_PARAMETER(iSavepoint); |
| 186570 | assert( p->inTransaction ); | 187841 | assert( pTab->inTransaction ); |
| 186571 | TESTONLY( p->mxSavepoint = iSavepoint ); | 187842 | TESTONLY( pTab->mxSavepoint = iSavepoint ); |
| 186572 | sqlite3Fts3PendingTermsClear(p); | 187843 | if( (iSavepoint+1)<=pTab->iSavepoint ){ |
| 187844 | sqlite3Fts3PendingTermsClear(pTab); | ||
| 187845 | } | ||
| 186573 | return SQLITE_OK; | 187846 | return SQLITE_OK; |
| 186574 | } | 187847 | } |
| 186575 | 187848 | ||
| @@ -186588,8 +187861,49 @@ static int fts3ShadowName(const char *zName){ | |||
| 186588 | return 0; | 187861 | return 0; |
| 186589 | } | 187862 | } |
| 186590 | 187863 | ||
| 187864 | /* | ||
| 187865 | ** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual | ||
| 187866 | ** table. | ||
| 187867 | */ | ||
| 187868 | static int fts3Integrity( | ||
| 187869 | sqlite3_vtab *pVtab, /* The virtual table to be checked */ | ||
| 187870 | const char *zSchema, /* Name of schema in which pVtab lives */ | ||
| 187871 | const char *zTabname, /* Name of the pVTab table */ | ||
| 187872 | int isQuick, /* True if this is a quick_check */ | ||
| 187873 | char **pzErr /* Write error message here */ | ||
| 187874 | ){ | ||
| 187875 | Fts3Table *p = (Fts3Table*)pVtab; | ||
| 187876 | char *zSql; | ||
| 187877 | int rc; | ||
| 187878 | char *zErr = 0; | ||
| 187879 | |||
| 187880 | assert( pzErr!=0 ); | ||
| 187881 | assert( *pzErr==0 ); | ||
| 187882 | UNUSED_PARAMETER(isQuick); | ||
| 187883 | zSql = sqlite3_mprintf( | ||
| 187884 | "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", | ||
| 187885 | zSchema, zTabname, zTabname); | ||
| 187886 | if( zSql==0 ){ | ||
| 187887 | return SQLITE_NOMEM; | ||
| 187888 | } | ||
| 187889 | rc = sqlite3_exec(p->db, zSql, 0, 0, &zErr); | ||
| 187890 | sqlite3_free(zSql); | ||
| 187891 | if( (rc&0xff)==SQLITE_CORRUPT ){ | ||
| 187892 | *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", | ||
| 187893 | p->bFts4 ? 4 : 3, zSchema, zTabname); | ||
| 187894 | }else if( rc!=SQLITE_OK ){ | ||
| 187895 | *pzErr = sqlite3_mprintf("unable to validate the inverted index for" | ||
| 187896 | " FTS%d table %s.%s: %s", | ||
| 187897 | p->bFts4 ? 4 : 3, zSchema, zTabname, zErr); | ||
| 187898 | } | ||
| 187899 | sqlite3_free(zErr); | ||
| 187900 | return SQLITE_OK; | ||
| 187901 | } | ||
| 187902 | |||
| 187903 | |||
| 187904 | |||
| 186591 | static const sqlite3_module fts3Module = { | 187905 | static const sqlite3_module fts3Module = { |
| 186592 | /* iVersion */ 3, | 187906 | /* iVersion */ 4, |
| 186593 | /* xCreate */ fts3CreateMethod, | 187907 | /* xCreate */ fts3CreateMethod, |
| 186594 | /* xConnect */ fts3ConnectMethod, | 187908 | /* xConnect */ fts3ConnectMethod, |
| 186595 | /* xBestIndex */ fts3BestIndexMethod, | 187909 | /* xBestIndex */ fts3BestIndexMethod, |
| @@ -186613,6 +187927,7 @@ static const sqlite3_module fts3Module = { | |||
| 186613 | /* xRelease */ fts3ReleaseMethod, | 187927 | /* xRelease */ fts3ReleaseMethod, |
| 186614 | /* xRollbackTo */ fts3RollbackToMethod, | 187928 | /* xRollbackTo */ fts3RollbackToMethod, |
| 186615 | /* xShadowName */ fts3ShadowName, | 187929 | /* xShadowName */ fts3ShadowName, |
| 187930 | /* xIntegrity */ fts3Integrity, | ||
| 186616 | }; | 187931 | }; |
| 186617 | 187932 | ||
| 186618 | /* | 187933 | /* |
| @@ -189288,7 +190603,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db){ | |||
| 189288 | 0, /* xSavepoint */ | 190603 | 0, /* xSavepoint */ |
| 189289 | 0, /* xRelease */ | 190604 | 0, /* xRelease */ |
| 189290 | 0, /* xRollbackTo */ | 190605 | 0, /* xRollbackTo */ |
| 189291 | 0 /* xShadowName */ | 190606 | 0, /* xShadowName */ |
| 190607 | 0 /* xIntegrity */ | ||
| 189292 | }; | 190608 | }; |
| 189293 | int rc; /* Return code */ | 190609 | int rc; /* Return code */ |
| 189294 | 190610 | ||
| @@ -192854,7 +194170,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash, void(*xDestr | |||
| 192854 | 0, /* xSavepoint */ | 194170 | 0, /* xSavepoint */ |
| 192855 | 0, /* xRelease */ | 194171 | 0, /* xRelease */ |
| 192856 | 0, /* xRollbackTo */ | 194172 | 0, /* xRollbackTo */ |
| 192857 | 0 /* xShadowName */ | 194173 | 0, /* xShadowName */ |
| 194174 | 0 /* xIntegrity */ | ||
| 192858 | }; | 194175 | }; |
| 192859 | int rc; /* Return code */ | 194176 | int rc; /* Return code */ |
| 192860 | 194177 | ||
| @@ -196195,7 +197512,6 @@ SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){ | |||
| 196195 | rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); | 197512 | rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); |
| 196196 | if( rc==SQLITE_DONE ) rc = SQLITE_OK; | 197513 | if( rc==SQLITE_DONE ) rc = SQLITE_OK; |
| 196197 | } | 197514 | } |
| 196198 | sqlite3Fts3PendingTermsClear(p); | ||
| 196199 | 197515 | ||
| 196200 | /* Determine the auto-incr-merge setting if unknown. If enabled, | 197516 | /* Determine the auto-incr-merge setting if unknown. If enabled, |
| 196201 | ** estimate the number of leaf blocks of content to be written | 197517 | ** estimate the number of leaf blocks of content to be written |
| @@ -196217,6 +197533,10 @@ SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){ | |||
| 196217 | rc = sqlite3_reset(pStmt); | 197533 | rc = sqlite3_reset(pStmt); |
| 196218 | } | 197534 | } |
| 196219 | } | 197535 | } |
| 197536 | |||
| 197537 | if( rc==SQLITE_OK ){ | ||
| 197538 | sqlite3Fts3PendingTermsClear(p); | ||
| 197539 | } | ||
| 196220 | return rc; | 197540 | return rc; |
| 196221 | } | 197541 | } |
| 196222 | 197542 | ||
| @@ -196848,6 +198168,8 @@ static int fts3AppendToNode( | |||
| 196848 | 198168 | ||
| 196849 | blobGrowBuffer(pPrev, nTerm, &rc); | 198169 | blobGrowBuffer(pPrev, nTerm, &rc); |
| 196850 | if( rc!=SQLITE_OK ) return rc; | 198170 | if( rc!=SQLITE_OK ) return rc; |
| 198171 | assert( pPrev!=0 ); | ||
| 198172 | assert( pPrev->a!=0 ); | ||
| 196851 | 198173 | ||
| 196852 | nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm); | 198174 | nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm); |
| 196853 | nSuffix = nTerm - nPrefix; | 198175 | nSuffix = nTerm - nPrefix; |
| @@ -196904,9 +198226,13 @@ static int fts3IncrmergeAppend( | |||
| 196904 | nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; | 198226 | nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 196905 | 198227 | ||
| 196906 | /* If the current block is not empty, and if adding this term/doclist | 198228 | /* If the current block is not empty, and if adding this term/doclist |
| 196907 | ** to the current block would make it larger than Fts3Table.nNodeSize | 198229 | ** to the current block would make it larger than Fts3Table.nNodeSize bytes, |
| 196908 | ** bytes, write this block out to the database. */ | 198230 | ** and if there is still room for another leaf page, write this block out to |
| 196909 | if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){ | 198231 | ** the database. */ |
| 198232 | if( pLeaf->block.n>0 | ||
| 198233 | && (pLeaf->block.n + nSpace)>p->nNodeSize | ||
| 198234 | && pLeaf->iBlock < (pWriter->iStart + pWriter->nLeafEst) | ||
| 198235 | ){ | ||
| 196910 | rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); | 198236 | rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); |
| 196911 | pWriter->nWork++; | 198237 | pWriter->nWork++; |
| 196912 | 198238 | ||
| @@ -197238,7 +198564,7 @@ static int fts3IncrmergeLoad( | |||
| 197238 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); | 198564 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); |
| 197239 | blobGrowBuffer(&pNode->block, | 198565 | blobGrowBuffer(&pNode->block, |
| 197240 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc | 198566 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc |
| 197241 | ); | 198567 | ); |
| 197242 | if( rc==SQLITE_OK ){ | 198568 | if( rc==SQLITE_OK ){ |
| 197243 | memcpy(pNode->block.a, aBlock, nBlock); | 198569 | memcpy(pNode->block.a, aBlock, nBlock); |
| 197244 | pNode->block.n = nBlock; | 198570 | pNode->block.n = nBlock; |
| @@ -198303,8 +199629,11 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ | |||
| 198303 | rc = fts3DoIncrmerge(p, &zVal[6]); | 199629 | rc = fts3DoIncrmerge(p, &zVal[6]); |
| 198304 | }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ | 199630 | }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ |
| 198305 | rc = fts3DoAutoincrmerge(p, &zVal[10]); | 199631 | rc = fts3DoAutoincrmerge(p, &zVal[10]); |
| 199632 | }else if( nVal==5 && 0==sqlite3_strnicmp(zVal, "flush", 5) ){ | ||
| 199633 | rc = sqlite3Fts3PendingTermsFlush(p); | ||
| 199634 | } | ||
| 198306 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) | 199635 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| 198307 | }else{ | 199636 | else{ |
| 198308 | int v; | 199637 | int v; |
| 198309 | if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ | 199638 | if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ |
| 198310 | v = atoi(&zVal[9]); | 199639 | v = atoi(&zVal[9]); |
| @@ -198322,8 +199651,8 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ | |||
| 198322 | if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; | 199651 | if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; |
| 198323 | rc = SQLITE_OK; | 199652 | rc = SQLITE_OK; |
| 198324 | } | 199653 | } |
| 198325 | #endif | ||
| 198326 | } | 199654 | } |
| 199655 | #endif | ||
| 198327 | return rc; | 199656 | return rc; |
| 198328 | } | 199657 | } |
| 198329 | 199658 | ||
| @@ -201836,7 +203165,7 @@ static void jsonResult(JsonString *p){ | |||
| 201836 | }else if( jsonForceRCStr(p) ){ | 203165 | }else if( jsonForceRCStr(p) ){ |
| 201837 | sqlite3RCStrRef(p->zBuf); | 203166 | sqlite3RCStrRef(p->zBuf); |
| 201838 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, | 203167 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 201839 | (void(*)(void*))sqlite3RCStrUnref, | 203168 | sqlite3RCStrUnref, |
| 201840 | SQLITE_UTF8); | 203169 | SQLITE_UTF8); |
| 201841 | } | 203170 | } |
| 201842 | } | 203171 | } |
| @@ -203176,7 +204505,7 @@ static JsonParse *jsonParseCached( | |||
| 203176 | /* The input JSON was not found anywhere in the cache. We will need | 204505 | /* The input JSON was not found anywhere in the cache. We will need |
| 203177 | ** to parse it ourselves and generate a new JsonParse object. | 204506 | ** to parse it ourselves and generate a new JsonParse object. |
| 203178 | */ | 204507 | */ |
| 203179 | bJsonRCStr = sqlite3ValueIsOfClass(pJson,(void(*)(void*))sqlite3RCStrUnref); | 204508 | bJsonRCStr = sqlite3ValueIsOfClass(pJson,sqlite3RCStrUnref); |
| 203180 | p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); | 204509 | p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); |
| 203181 | if( p==0 ){ | 204510 | if( p==0 ){ |
| 203182 | sqlite3_result_error_nomem(pCtx); | 204511 | sqlite3_result_error_nomem(pCtx); |
| @@ -203390,6 +204719,7 @@ static JsonNode *jsonLookupStep( | |||
| 203390 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; | 204719 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; |
| 203391 | j += jsonNodeSize(&pRoot[j]); | 204720 | j += jsonNodeSize(&pRoot[j]); |
| 203392 | } | 204721 | } |
| 204722 | if( i==0 && j<=pRoot->n ) break; | ||
| 203393 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; | 204723 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
| 203394 | if( pParse->useMod==0 ) break; | 204724 | if( pParse->useMod==0 ) break; |
| 203395 | assert( pRoot->eU==2 ); | 204725 | assert( pRoot->eU==2 ); |
| @@ -204077,11 +205407,13 @@ static void jsonReplaceNode( | |||
| 204077 | break; | 205407 | break; |
| 204078 | } | 205408 | } |
| 204079 | if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ | 205409 | if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ |
| 204080 | char *zCopy = sqlite3DbStrDup(0, z); | 205410 | char *zCopy = sqlite3_malloc64( n+1 ); |
| 204081 | int k; | 205411 | int k; |
| 204082 | if( zCopy ){ | 205412 | if( zCopy ){ |
| 205413 | memcpy(zCopy, z, n); | ||
| 205414 | zCopy[n] = 0; | ||
| 204083 | jsonParseAddCleanup(p, sqlite3_free, zCopy); | 205415 | jsonParseAddCleanup(p, sqlite3_free, zCopy); |
| 204084 | }else{ | 205416 | }else{ |
| 204085 | p->oom = 1; | 205417 | p->oom = 1; |
| 204086 | sqlite3_result_error_nomem(pCtx); | 205418 | sqlite3_result_error_nomem(pCtx); |
| 204087 | } | 205419 | } |
| @@ -204136,6 +205468,7 @@ static void jsonReplaceFunc( | |||
| 204136 | } | 205468 | } |
| 204137 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); | 205469 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 204138 | if( pParse==0 ) return; | 205470 | if( pParse==0 ) return; |
| 205471 | pParse->nJPRef++; | ||
| 204139 | for(i=1; i<(u32)argc; i+=2){ | 205472 | for(i=1; i<(u32)argc; i+=2){ |
| 204140 | zPath = (const char*)sqlite3_value_text(argv[i]); | 205473 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 204141 | pParse->useMod = 1; | 205474 | pParse->useMod = 1; |
| @@ -204148,6 +205481,7 @@ static void jsonReplaceFunc( | |||
| 204148 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); | 205481 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 204149 | replace_err: | 205482 | replace_err: |
| 204150 | jsonDebugPrintParse(pParse); | 205483 | jsonDebugPrintParse(pParse); |
| 205484 | jsonParseFree(pParse); | ||
| 204151 | } | 205485 | } |
| 204152 | 205486 | ||
| 204153 | 205487 | ||
| @@ -204182,6 +205516,7 @@ static void jsonSetFunc( | |||
| 204182 | } | 205516 | } |
| 204183 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); | 205517 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 204184 | if( pParse==0 ) return; | 205518 | if( pParse==0 ) return; |
| 205519 | pParse->nJPRef++; | ||
| 204185 | for(i=1; i<(u32)argc; i+=2){ | 205520 | for(i=1; i<(u32)argc; i+=2){ |
| 204186 | zPath = (const char*)sqlite3_value_text(argv[i]); | 205521 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 204187 | bApnd = 0; | 205522 | bApnd = 0; |
| @@ -204198,9 +205533,8 @@ static void jsonSetFunc( | |||
| 204198 | } | 205533 | } |
| 204199 | jsonDebugPrintParse(pParse); | 205534 | jsonDebugPrintParse(pParse); |
| 204200 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); | 205535 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 204201 | |||
| 204202 | jsonSetDone: | 205536 | jsonSetDone: |
| 204203 | /* no cleanup required */; | 205537 | jsonParseFree(pParse); |
| 204204 | } | 205538 | } |
| 204205 | 205539 | ||
| 204206 | /* | 205540 | /* |
| @@ -204356,7 +205690,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ | |||
| 204356 | }else if( isFinal ){ | 205690 | }else if( isFinal ){ |
| 204357 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, | 205691 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 204358 | pStr->bStatic ? SQLITE_TRANSIENT : | 205692 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 204359 | (void(*)(void*))sqlite3RCStrUnref); | 205693 | sqlite3RCStrUnref); |
| 204360 | pStr->bStatic = 1; | 205694 | pStr->bStatic = 1; |
| 204361 | }else{ | 205695 | }else{ |
| 204362 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); | 205696 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| @@ -204465,7 +205799,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ | |||
| 204465 | }else if( isFinal ){ | 205799 | }else if( isFinal ){ |
| 204466 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, | 205800 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 204467 | pStr->bStatic ? SQLITE_TRANSIENT : | 205801 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 204468 | (void(*)(void*))sqlite3RCStrUnref); | 205802 | sqlite3RCStrUnref); |
| 204469 | pStr->bStatic = 1; | 205803 | pStr->bStatic = 1; |
| 204470 | }else{ | 205804 | }else{ |
| 204471 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); | 205805 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| @@ -204897,7 +206231,7 @@ static int jsonEachFilter( | |||
| 204897 | if( z==0 ) return SQLITE_OK; | 206231 | if( z==0 ) return SQLITE_OK; |
| 204898 | memset(&p->sParse, 0, sizeof(p->sParse)); | 206232 | memset(&p->sParse, 0, sizeof(p->sParse)); |
| 204899 | p->sParse.nJPRef = 1; | 206233 | p->sParse.nJPRef = 1; |
| 204900 | if( sqlite3ValueIsOfClass(argv[0], (void(*)(void*))sqlite3RCStrUnref) ){ | 206234 | if( sqlite3ValueIsOfClass(argv[0], sqlite3RCStrUnref) ){ |
| 204901 | p->sParse.zJson = sqlite3RCStrRef((char*)z); | 206235 | p->sParse.zJson = sqlite3RCStrRef((char*)z); |
| 204902 | }else{ | 206236 | }else{ |
| 204903 | n = sqlite3_value_bytes(argv[0]); | 206237 | n = sqlite3_value_bytes(argv[0]); |
| @@ -204992,7 +206326,8 @@ static sqlite3_module jsonEachModule = { | |||
| 204992 | 0, /* xSavepoint */ | 206326 | 0, /* xSavepoint */ |
| 204993 | 0, /* xRelease */ | 206327 | 0, /* xRelease */ |
| 204994 | 0, /* xRollbackTo */ | 206328 | 0, /* xRollbackTo */ |
| 204995 | 0 /* xShadowName */ | 206329 | 0, /* xShadowName */ |
| 206330 | 0 /* xIntegrity */ | ||
| 204996 | }; | 206331 | }; |
| 204997 | 206332 | ||
| 204998 | /* The methods of the json_tree virtual table. */ | 206333 | /* The methods of the json_tree virtual table. */ |
| @@ -205020,7 +206355,8 @@ static sqlite3_module jsonTreeModule = { | |||
| 205020 | 0, /* xSavepoint */ | 206355 | 0, /* xSavepoint */ |
| 205021 | 0, /* xRelease */ | 206356 | 0, /* xRelease */ |
| 205022 | 0, /* xRollbackTo */ | 206357 | 0, /* xRollbackTo */ |
| 205023 | 0 /* xShadowName */ | 206358 | 0, /* xShadowName */ |
| 206359 | 0 /* xIntegrity */ | ||
| 205024 | }; | 206360 | }; |
| 205025 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ | 206361 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 205026 | #endif /* !defined(SQLITE_OMIT_JSON) */ | 206362 | #endif /* !defined(SQLITE_OMIT_JSON) */ |
| @@ -205255,6 +206591,7 @@ struct Rtree { | |||
| 205255 | int iDepth; /* Current depth of the r-tree structure */ | 206591 | int iDepth; /* Current depth of the r-tree structure */ |
| 205256 | char *zDb; /* Name of database containing r-tree table */ | 206592 | char *zDb; /* Name of database containing r-tree table */ |
| 205257 | char *zName; /* Name of r-tree table */ | 206593 | char *zName; /* Name of r-tree table */ |
| 206594 | char *zNodeName; /* Name of the %_node table */ | ||
| 205258 | u32 nBusy; /* Current number of users of this structure */ | 206595 | u32 nBusy; /* Current number of users of this structure */ |
| 205259 | i64 nRowEst; /* Estimated number of rows in this table */ | 206596 | i64 nRowEst; /* Estimated number of rows in this table */ |
| 205260 | u32 nCursor; /* Number of open cursors */ | 206597 | u32 nCursor; /* Number of open cursors */ |
| @@ -205267,7 +206604,6 @@ struct Rtree { | |||
| 205267 | ** headed by the node (leaf nodes have RtreeNode.iNode==0). | 206604 | ** headed by the node (leaf nodes have RtreeNode.iNode==0). |
| 205268 | */ | 206605 | */ |
| 205269 | RtreeNode *pDeleted; | 206606 | RtreeNode *pDeleted; |
| 205270 | int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */ | ||
| 205271 | 206607 | ||
| 205272 | /* Blob I/O on xxx_node */ | 206608 | /* Blob I/O on xxx_node */ |
| 205273 | sqlite3_blob *pNodeBlob; | 206609 | sqlite3_blob *pNodeBlob; |
| @@ -205564,15 +206900,20 @@ struct RtreeMatchArg { | |||
| 205564 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined | 206900 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 205565 | ** at run-time. | 206901 | ** at run-time. |
| 205566 | */ | 206902 | */ |
| 205567 | #ifndef SQLITE_BYTEORDER | 206903 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 205568 | # if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | 206904 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 206905 | # define SQLITE_BYTEORDER 4321 | ||
| 206906 | # elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ | ||
| 206907 | # define SQLITE_BYTEORDER 1234 | ||
| 206908 | # elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 | ||
| 206909 | # define SQLITE_BYTEORDER 4321 | ||
| 206910 | # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | ||
| 205569 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ | 206911 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 205570 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ | 206912 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 205571 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) | 206913 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 205572 | # define SQLITE_BYTEORDER 1234 | 206914 | # define SQLITE_BYTEORDER 1234 |
| 205573 | # elif defined(sparc) || defined(__ppc__) || \ | 206915 | # elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) |
| 205574 | defined(__ARMEB__) || defined(__AARCH64EB__) | 206916 | # define SQLITE_BYTEORDER 4321 |
| 205575 | # define SQLITE_BYTEORDER 4321 | ||
| 205576 | # else | 206917 | # else |
| 205577 | # define SQLITE_BYTEORDER 0 | 206918 | # define SQLITE_BYTEORDER 0 |
| 205578 | # endif | 206919 | # endif |
| @@ -205821,11 +207162,9 @@ static int nodeAcquire( | |||
| 205821 | } | 207162 | } |
| 205822 | } | 207163 | } |
| 205823 | if( pRtree->pNodeBlob==0 ){ | 207164 | if( pRtree->pNodeBlob==0 ){ |
| 205824 | char *zTab = sqlite3_mprintf("%s_node", pRtree->zName); | 207165 | rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, pRtree->zNodeName, |
| 205825 | if( zTab==0 ) return SQLITE_NOMEM; | 207166 | "data", iNode, 0, |
| 205826 | rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0, | ||
| 205827 | &pRtree->pNodeBlob); | 207167 | &pRtree->pNodeBlob); |
| 205828 | sqlite3_free(zTab); | ||
| 205829 | } | 207168 | } |
| 205830 | if( rc ){ | 207169 | if( rc ){ |
| 205831 | nodeBlobReset(pRtree); | 207170 | nodeBlobReset(pRtree); |
| @@ -207166,8 +208505,12 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ | |||
| 207166 | 208505 | ||
| 207167 | pIdxInfo->idxNum = 2; | 208506 | pIdxInfo->idxNum = 2; |
| 207168 | pIdxInfo->needToFreeIdxStr = 1; | 208507 | pIdxInfo->needToFreeIdxStr = 1; |
| 207169 | if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ | 208508 | if( iIdx>0 ){ |
| 207170 | return SQLITE_NOMEM; | 208509 | pIdxInfo->idxStr = sqlite3_malloc( iIdx+1 ); |
| 208510 | if( pIdxInfo->idxStr==0 ){ | ||
| 208511 | return SQLITE_NOMEM; | ||
| 208512 | } | ||
| 208513 | memcpy(pIdxInfo->idxStr, zIdxStr, iIdx+1); | ||
| 207171 | } | 208514 | } |
| 207172 | 208515 | ||
| 207173 | nRow = pRtree->nRowEst >> (iIdx/2); | 208516 | nRow = pRtree->nRowEst >> (iIdx/2); |
| @@ -207246,31 +208589,22 @@ static void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ | |||
| 207246 | */ | 208589 | */ |
| 207247 | static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ | 208590 | static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ |
| 207248 | int ii; | 208591 | int ii; |
| 207249 | int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); | 208592 | if( pRtree->eCoordType==RTREE_COORD_INT32 ){ |
| 207250 | for(ii=0; ii<pRtree->nDim2; ii+=2){ | 208593 | for(ii=0; ii<pRtree->nDim2; ii+=2){ |
| 207251 | RtreeCoord *a1 = &p1->aCoord[ii]; | 208594 | RtreeCoord *a1 = &p1->aCoord[ii]; |
| 207252 | RtreeCoord *a2 = &p2->aCoord[ii]; | 208595 | RtreeCoord *a2 = &p2->aCoord[ii]; |
| 207253 | if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) | 208596 | if( a2[0].i<a1[0].i || a2[1].i>a1[1].i ) return 0; |
| 207254 | || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) | 208597 | } |
| 207255 | ){ | 208598 | }else{ |
| 207256 | return 0; | 208599 | for(ii=0; ii<pRtree->nDim2; ii+=2){ |
| 208600 | RtreeCoord *a1 = &p1->aCoord[ii]; | ||
| 208601 | RtreeCoord *a2 = &p2->aCoord[ii]; | ||
| 208602 | if( a2[0].f<a1[0].f || a2[1].f>a1[1].f ) return 0; | ||
| 207257 | } | 208603 | } |
| 207258 | } | 208604 | } |
| 207259 | return 1; | 208605 | return 1; |
| 207260 | } | 208606 | } |
| 207261 | 208607 | ||
| 207262 | /* | ||
| 207263 | ** Return the amount cell p would grow by if it were unioned with pCell. | ||
| 207264 | */ | ||
| 207265 | static RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){ | ||
| 207266 | RtreeDValue area; | ||
| 207267 | RtreeCell cell; | ||
| 207268 | memcpy(&cell, p, sizeof(RtreeCell)); | ||
| 207269 | area = cellArea(pRtree, &cell); | ||
| 207270 | cellUnion(pRtree, &cell, pCell); | ||
| 207271 | return (cellArea(pRtree, &cell)-area); | ||
| 207272 | } | ||
| 207273 | |||
| 207274 | static RtreeDValue cellOverlap( | 208608 | static RtreeDValue cellOverlap( |
| 207275 | Rtree *pRtree, | 208609 | Rtree *pRtree, |
| 207276 | RtreeCell *p, | 208610 | RtreeCell *p, |
| @@ -207317,38 +208651,52 @@ static int ChooseLeaf( | |||
| 207317 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ | 208651 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 207318 | int iCell; | 208652 | int iCell; |
| 207319 | sqlite3_int64 iBest = 0; | 208653 | sqlite3_int64 iBest = 0; |
| 207320 | 208654 | int bFound = 0; | |
| 207321 | RtreeDValue fMinGrowth = RTREE_ZERO; | 208655 | RtreeDValue fMinGrowth = RTREE_ZERO; |
| 207322 | RtreeDValue fMinArea = RTREE_ZERO; | 208656 | RtreeDValue fMinArea = RTREE_ZERO; |
| 207323 | |||
| 207324 | int nCell = NCELL(pNode); | 208657 | int nCell = NCELL(pNode); |
| 207325 | RtreeCell cell; | ||
| 207326 | RtreeNode *pChild = 0; | 208658 | RtreeNode *pChild = 0; |
| 207327 | 208659 | ||
| 207328 | RtreeCell *aCell = 0; | 208660 | /* First check to see if there is are any cells in pNode that completely |
| 207329 | 208661 | ** contains pCell. If two or more cells in pNode completely contain pCell | |
| 207330 | /* Select the child node which will be enlarged the least if pCell | 208662 | ** then pick the smallest. |
| 207331 | ** is inserted into it. Resolve ties by choosing the entry with | ||
| 207332 | ** the smallest area. | ||
| 207333 | */ | 208663 | */ |
| 207334 | for(iCell=0; iCell<nCell; iCell++){ | 208664 | for(iCell=0; iCell<nCell; iCell++){ |
| 207335 | int bBest = 0; | 208665 | RtreeCell cell; |
| 207336 | RtreeDValue growth; | ||
| 207337 | RtreeDValue area; | ||
| 207338 | nodeGetCell(pRtree, pNode, iCell, &cell); | 208666 | nodeGetCell(pRtree, pNode, iCell, &cell); |
| 207339 | growth = cellGrowth(pRtree, &cell, pCell); | 208667 | if( cellContains(pRtree, &cell, pCell) ){ |
| 207340 | area = cellArea(pRtree, &cell); | 208668 | RtreeDValue area = cellArea(pRtree, &cell); |
| 207341 | if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){ | 208669 | if( bFound==0 || area<fMinArea ){ |
| 207342 | bBest = 1; | 208670 | iBest = cell.iRowid; |
| 208671 | fMinArea = area; | ||
| 208672 | bFound = 1; | ||
| 208673 | } | ||
| 207343 | } | 208674 | } |
| 207344 | if( bBest ){ | 208675 | } |
| 207345 | fMinGrowth = growth; | 208676 | if( !bFound ){ |
| 207346 | fMinArea = area; | 208677 | /* No cells of pNode will completely contain pCell. So pick the |
| 207347 | iBest = cell.iRowid; | 208678 | ** cell of pNode that grows by the least amount when pCell is added. |
| 208679 | ** Break ties by selecting the smaller cell. | ||
| 208680 | */ | ||
| 208681 | for(iCell=0; iCell<nCell; iCell++){ | ||
| 208682 | RtreeCell cell; | ||
| 208683 | RtreeDValue growth; | ||
| 208684 | RtreeDValue area; | ||
| 208685 | nodeGetCell(pRtree, pNode, iCell, &cell); | ||
| 208686 | area = cellArea(pRtree, &cell); | ||
| 208687 | cellUnion(pRtree, &cell, pCell); | ||
| 208688 | growth = cellArea(pRtree, &cell)-area; | ||
| 208689 | if( iCell==0 | ||
| 208690 | || growth<fMinGrowth | ||
| 208691 | || (growth==fMinGrowth && area<fMinArea) | ||
| 208692 | ){ | ||
| 208693 | fMinGrowth = growth; | ||
| 208694 | fMinArea = area; | ||
| 208695 | iBest = cell.iRowid; | ||
| 208696 | } | ||
| 207348 | } | 208697 | } |
| 207349 | } | 208698 | } |
| 207350 | 208699 | ||
| 207351 | sqlite3_free(aCell); | ||
| 207352 | rc = nodeAcquire(pRtree, iBest, pNode, &pChild); | 208700 | rc = nodeAcquire(pRtree, iBest, pNode, &pChild); |
| 207353 | nodeRelease(pRtree, pNode); | 208701 | nodeRelease(pRtree, pNode); |
| 207354 | pNode = pChild; | 208702 | pNode = pChild; |
| @@ -207421,77 +208769,6 @@ static int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){ | |||
| 207421 | static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); | 208769 | static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); |
| 207422 | 208770 | ||
| 207423 | 208771 | ||
| 207424 | /* | ||
| 207425 | ** Arguments aIdx, aDistance and aSpare all point to arrays of size | ||
| 207426 | ** nIdx. The aIdx array contains the set of integers from 0 to | ||
| 207427 | ** (nIdx-1) in no particular order. This function sorts the values | ||
| 207428 | ** in aIdx according to the indexed values in aDistance. For | ||
| 207429 | ** example, assuming the inputs: | ||
| 207430 | ** | ||
| 207431 | ** aIdx = { 0, 1, 2, 3 } | ||
| 207432 | ** aDistance = { 5.0, 2.0, 7.0, 6.0 } | ||
| 207433 | ** | ||
| 207434 | ** this function sets the aIdx array to contain: | ||
| 207435 | ** | ||
| 207436 | ** aIdx = { 0, 1, 2, 3 } | ||
| 207437 | ** | ||
| 207438 | ** The aSpare array is used as temporary working space by the | ||
| 207439 | ** sorting algorithm. | ||
| 207440 | */ | ||
| 207441 | static void SortByDistance( | ||
| 207442 | int *aIdx, | ||
| 207443 | int nIdx, | ||
| 207444 | RtreeDValue *aDistance, | ||
| 207445 | int *aSpare | ||
| 207446 | ){ | ||
| 207447 | if( nIdx>1 ){ | ||
| 207448 | int iLeft = 0; | ||
| 207449 | int iRight = 0; | ||
| 207450 | |||
| 207451 | int nLeft = nIdx/2; | ||
| 207452 | int nRight = nIdx-nLeft; | ||
| 207453 | int *aLeft = aIdx; | ||
| 207454 | int *aRight = &aIdx[nLeft]; | ||
| 207455 | |||
| 207456 | SortByDistance(aLeft, nLeft, aDistance, aSpare); | ||
| 207457 | SortByDistance(aRight, nRight, aDistance, aSpare); | ||
| 207458 | |||
| 207459 | memcpy(aSpare, aLeft, sizeof(int)*nLeft); | ||
| 207460 | aLeft = aSpare; | ||
| 207461 | |||
| 207462 | while( iLeft<nLeft || iRight<nRight ){ | ||
| 207463 | if( iLeft==nLeft ){ | ||
| 207464 | aIdx[iLeft+iRight] = aRight[iRight]; | ||
| 207465 | iRight++; | ||
| 207466 | }else if( iRight==nRight ){ | ||
| 207467 | aIdx[iLeft+iRight] = aLeft[iLeft]; | ||
| 207468 | iLeft++; | ||
| 207469 | }else{ | ||
| 207470 | RtreeDValue fLeft = aDistance[aLeft[iLeft]]; | ||
| 207471 | RtreeDValue fRight = aDistance[aRight[iRight]]; | ||
| 207472 | if( fLeft<fRight ){ | ||
| 207473 | aIdx[iLeft+iRight] = aLeft[iLeft]; | ||
| 207474 | iLeft++; | ||
| 207475 | }else{ | ||
| 207476 | aIdx[iLeft+iRight] = aRight[iRight]; | ||
| 207477 | iRight++; | ||
| 207478 | } | ||
| 207479 | } | ||
| 207480 | } | ||
| 207481 | |||
| 207482 | #if 0 | ||
| 207483 | /* Check that the sort worked */ | ||
| 207484 | { | ||
| 207485 | int jj; | ||
| 207486 | for(jj=1; jj<nIdx; jj++){ | ||
| 207487 | RtreeDValue left = aDistance[aIdx[jj-1]]; | ||
| 207488 | RtreeDValue right = aDistance[aIdx[jj]]; | ||
| 207489 | assert( left<=right ); | ||
| 207490 | } | ||
| 207491 | } | ||
| 207492 | #endif | ||
| 207493 | } | ||
| 207494 | } | ||
| 207495 | 208772 | ||
| 207496 | /* | 208773 | /* |
| 207497 | ** Arguments aIdx, aCell and aSpare all point to arrays of size | 208774 | ** Arguments aIdx, aCell and aSpare all point to arrays of size |
| @@ -207976,107 +209253,6 @@ static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){ | |||
| 207976 | return rc; | 209253 | return rc; |
| 207977 | } | 209254 | } |
| 207978 | 209255 | ||
| 207979 | static int Reinsert( | ||
| 207980 | Rtree *pRtree, | ||
| 207981 | RtreeNode *pNode, | ||
| 207982 | RtreeCell *pCell, | ||
| 207983 | int iHeight | ||
| 207984 | ){ | ||
| 207985 | int *aOrder; | ||
| 207986 | int *aSpare; | ||
| 207987 | RtreeCell *aCell; | ||
| 207988 | RtreeDValue *aDistance; | ||
| 207989 | int nCell; | ||
| 207990 | RtreeDValue aCenterCoord[RTREE_MAX_DIMENSIONS]; | ||
| 207991 | int iDim; | ||
| 207992 | int ii; | ||
| 207993 | int rc = SQLITE_OK; | ||
| 207994 | int n; | ||
| 207995 | |||
| 207996 | memset(aCenterCoord, 0, sizeof(RtreeDValue)*RTREE_MAX_DIMENSIONS); | ||
| 207997 | |||
| 207998 | nCell = NCELL(pNode)+1; | ||
| 207999 | n = (nCell+1)&(~1); | ||
| 208000 | |||
| 208001 | /* Allocate the buffers used by this operation. The allocation is | ||
| 208002 | ** relinquished before this function returns. | ||
| 208003 | */ | ||
| 208004 | aCell = (RtreeCell *)sqlite3_malloc64(n * ( | ||
| 208005 | sizeof(RtreeCell) + /* aCell array */ | ||
| 208006 | sizeof(int) + /* aOrder array */ | ||
| 208007 | sizeof(int) + /* aSpare array */ | ||
| 208008 | sizeof(RtreeDValue) /* aDistance array */ | ||
| 208009 | )); | ||
| 208010 | if( !aCell ){ | ||
| 208011 | return SQLITE_NOMEM; | ||
| 208012 | } | ||
| 208013 | aOrder = (int *)&aCell[n]; | ||
| 208014 | aSpare = (int *)&aOrder[n]; | ||
| 208015 | aDistance = (RtreeDValue *)&aSpare[n]; | ||
| 208016 | |||
| 208017 | for(ii=0; ii<nCell; ii++){ | ||
| 208018 | if( ii==(nCell-1) ){ | ||
| 208019 | memcpy(&aCell[ii], pCell, sizeof(RtreeCell)); | ||
| 208020 | }else{ | ||
| 208021 | nodeGetCell(pRtree, pNode, ii, &aCell[ii]); | ||
| 208022 | } | ||
| 208023 | aOrder[ii] = ii; | ||
| 208024 | for(iDim=0; iDim<pRtree->nDim; iDim++){ | ||
| 208025 | aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]); | ||
| 208026 | aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]); | ||
| 208027 | } | ||
| 208028 | } | ||
| 208029 | for(iDim=0; iDim<pRtree->nDim; iDim++){ | ||
| 208030 | aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2)); | ||
| 208031 | } | ||
| 208032 | |||
| 208033 | for(ii=0; ii<nCell; ii++){ | ||
| 208034 | aDistance[ii] = RTREE_ZERO; | ||
| 208035 | for(iDim=0; iDim<pRtree->nDim; iDim++){ | ||
| 208036 | RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) - | ||
| 208037 | DCOORD(aCell[ii].aCoord[iDim*2])); | ||
| 208038 | aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]); | ||
| 208039 | } | ||
| 208040 | } | ||
| 208041 | |||
| 208042 | SortByDistance(aOrder, nCell, aDistance, aSpare); | ||
| 208043 | nodeZero(pRtree, pNode); | ||
| 208044 | |||
| 208045 | for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){ | ||
| 208046 | RtreeCell *p = &aCell[aOrder[ii]]; | ||
| 208047 | nodeInsertCell(pRtree, pNode, p); | ||
| 208048 | if( p->iRowid==pCell->iRowid ){ | ||
| 208049 | if( iHeight==0 ){ | ||
| 208050 | rc = rowidWrite(pRtree, p->iRowid, pNode->iNode); | ||
| 208051 | }else{ | ||
| 208052 | rc = parentWrite(pRtree, p->iRowid, pNode->iNode); | ||
| 208053 | } | ||
| 208054 | } | ||
| 208055 | } | ||
| 208056 | if( rc==SQLITE_OK ){ | ||
| 208057 | rc = fixBoundingBox(pRtree, pNode); | ||
| 208058 | } | ||
| 208059 | for(; rc==SQLITE_OK && ii<nCell; ii++){ | ||
| 208060 | /* Find a node to store this cell in. pNode->iNode currently contains | ||
| 208061 | ** the height of the sub-tree headed by the cell. | ||
| 208062 | */ | ||
| 208063 | RtreeNode *pInsert; | ||
| 208064 | RtreeCell *p = &aCell[aOrder[ii]]; | ||
| 208065 | rc = ChooseLeaf(pRtree, p, iHeight, &pInsert); | ||
| 208066 | if( rc==SQLITE_OK ){ | ||
| 208067 | int rc2; | ||
| 208068 | rc = rtreeInsertCell(pRtree, pInsert, p, iHeight); | ||
| 208069 | rc2 = nodeRelease(pRtree, pInsert); | ||
| 208070 | if( rc==SQLITE_OK ){ | ||
| 208071 | rc = rc2; | ||
| 208072 | } | ||
| 208073 | } | ||
| 208074 | } | ||
| 208075 | |||
| 208076 | sqlite3_free(aCell); | ||
| 208077 | return rc; | ||
| 208078 | } | ||
| 208079 | |||
| 208080 | /* | 209256 | /* |
| 208081 | ** Insert cell pCell into node pNode. Node pNode is the head of a | 209257 | ** Insert cell pCell into node pNode. Node pNode is the head of a |
| 208082 | ** subtree iHeight high (leaf nodes have iHeight==0). | 209258 | ** subtree iHeight high (leaf nodes have iHeight==0). |
| @@ -208097,12 +209273,7 @@ static int rtreeInsertCell( | |||
| 208097 | } | 209273 | } |
| 208098 | } | 209274 | } |
| 208099 | if( nodeInsertCell(pRtree, pNode, pCell) ){ | 209275 | if( nodeInsertCell(pRtree, pNode, pCell) ){ |
| 208100 | if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){ | 209276 | rc = SplitNode(pRtree, pNode, pCell, iHeight); |
| 208101 | rc = SplitNode(pRtree, pNode, pCell, iHeight); | ||
| 208102 | }else{ | ||
| 208103 | pRtree->iReinsertHeight = iHeight; | ||
| 208104 | rc = Reinsert(pRtree, pNode, pCell, iHeight); | ||
| 208105 | } | ||
| 208106 | }else{ | 209277 | }else{ |
| 208107 | rc = AdjustTree(pRtree, pNode, pCell); | 209278 | rc = AdjustTree(pRtree, pNode, pCell); |
| 208108 | if( ALWAYS(rc==SQLITE_OK) ){ | 209279 | if( ALWAYS(rc==SQLITE_OK) ){ |
| @@ -208445,7 +209616,6 @@ static int rtreeUpdate( | |||
| 208445 | } | 209616 | } |
| 208446 | if( rc==SQLITE_OK ){ | 209617 | if( rc==SQLITE_OK ){ |
| 208447 | int rc2; | 209618 | int rc2; |
| 208448 | pRtree->iReinsertHeight = -1; | ||
| 208449 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); | 209619 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 208450 | rc2 = nodeRelease(pRtree, pLeaf); | 209620 | rc2 = nodeRelease(pRtree, pLeaf); |
| 208451 | if( rc==SQLITE_OK ){ | 209621 | if( rc==SQLITE_OK ){ |
| @@ -208586,8 +209756,11 @@ static int rtreeShadowName(const char *zName){ | |||
| 208586 | return 0; | 209756 | return 0; |
| 208587 | } | 209757 | } |
| 208588 | 209758 | ||
| 209759 | /* Forward declaration */ | ||
| 209760 | static int rtreeIntegrity(sqlite3_vtab*, const char*, const char*, int, char**); | ||
| 209761 | |||
| 208589 | static sqlite3_module rtreeModule = { | 209762 | static sqlite3_module rtreeModule = { |
| 208590 | 3, /* iVersion */ | 209763 | 4, /* iVersion */ |
| 208591 | rtreeCreate, /* xCreate - create a table */ | 209764 | rtreeCreate, /* xCreate - create a table */ |
| 208592 | rtreeConnect, /* xConnect - connect to an existing table */ | 209765 | rtreeConnect, /* xConnect - connect to an existing table */ |
| 208593 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ | 209766 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ |
| @@ -208610,7 +209783,8 @@ static sqlite3_module rtreeModule = { | |||
| 208610 | rtreeSavepoint, /* xSavepoint */ | 209783 | rtreeSavepoint, /* xSavepoint */ |
| 208611 | 0, /* xRelease */ | 209784 | 0, /* xRelease */ |
| 208612 | 0, /* xRollbackTo */ | 209785 | 0, /* xRollbackTo */ |
| 208613 | rtreeShadowName /* xShadowName */ | 209786 | rtreeShadowName, /* xShadowName */ |
| 209787 | rtreeIntegrity /* xIntegrity */ | ||
| 208614 | }; | 209788 | }; |
| 208615 | 209789 | ||
| 208616 | static int rtreeSqlInit( | 209790 | static int rtreeSqlInit( |
| @@ -208866,22 +210040,27 @@ static int rtreeInit( | |||
| 208866 | } | 210040 | } |
| 208867 | 210041 | ||
| 208868 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); | 210042 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 210043 | sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); | ||
| 210044 | |||
| 208869 | 210045 | ||
| 208870 | /* Allocate the sqlite3_vtab structure */ | 210046 | /* Allocate the sqlite3_vtab structure */ |
| 208871 | nDb = (int)strlen(argv[1]); | 210047 | nDb = (int)strlen(argv[1]); |
| 208872 | nName = (int)strlen(argv[2]); | 210048 | nName = (int)strlen(argv[2]); |
| 208873 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); | 210049 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); |
| 208874 | if( !pRtree ){ | 210050 | if( !pRtree ){ |
| 208875 | return SQLITE_NOMEM; | 210051 | return SQLITE_NOMEM; |
| 208876 | } | 210052 | } |
| 208877 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); | 210053 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); |
| 208878 | pRtree->nBusy = 1; | 210054 | pRtree->nBusy = 1; |
| 208879 | pRtree->base.pModule = &rtreeModule; | 210055 | pRtree->base.pModule = &rtreeModule; |
| 208880 | pRtree->zDb = (char *)&pRtree[1]; | 210056 | pRtree->zDb = (char *)&pRtree[1]; |
| 208881 | pRtree->zName = &pRtree->zDb[nDb+1]; | 210057 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 210058 | pRtree->zNodeName = &pRtree->zName[nName+1]; | ||
| 208882 | pRtree->eCoordType = (u8)eCoordType; | 210059 | pRtree->eCoordType = (u8)eCoordType; |
| 208883 | memcpy(pRtree->zDb, argv[1], nDb); | 210060 | memcpy(pRtree->zDb, argv[1], nDb); |
| 208884 | memcpy(pRtree->zName, argv[2], nName); | 210061 | memcpy(pRtree->zName, argv[2], nName); |
| 210062 | memcpy(pRtree->zNodeName, argv[2], nName); | ||
| 210063 | memcpy(&pRtree->zNodeName[nName], "_node", 6); | ||
| 208885 | 210064 | ||
| 208886 | 210065 | ||
| 208887 | /* Create/Connect to the underlying relational database schema. If | 210066 | /* Create/Connect to the underlying relational database schema. If |
| @@ -209378,7 +210557,6 @@ static int rtreeCheckTable( | |||
| 209378 | ){ | 210557 | ){ |
| 209379 | RtreeCheck check; /* Common context for various routines */ | 210558 | RtreeCheck check; /* Common context for various routines */ |
| 209380 | sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ | 210559 | sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ |
| 209381 | int bEnd = 0; /* True if transaction should be closed */ | ||
| 209382 | int nAux = 0; /* Number of extra columns. */ | 210560 | int nAux = 0; /* Number of extra columns. */ |
| 209383 | 210561 | ||
| 209384 | /* Initialize the context object */ | 210562 | /* Initialize the context object */ |
| @@ -209387,14 +210565,6 @@ static int rtreeCheckTable( | |||
| 209387 | check.zDb = zDb; | 210565 | check.zDb = zDb; |
| 209388 | check.zTab = zTab; | 210566 | check.zTab = zTab; |
| 209389 | 210567 | ||
| 209390 | /* If there is not already an open transaction, open one now. This is | ||
| 209391 | ** to ensure that the queries run as part of this integrity-check operate | ||
| 209392 | ** on a consistent snapshot. */ | ||
| 209393 | if( sqlite3_get_autocommit(db) ){ | ||
| 209394 | check.rc = sqlite3_exec(db, "BEGIN", 0, 0, 0); | ||
| 209395 | bEnd = 1; | ||
| 209396 | } | ||
| 209397 | |||
| 209398 | /* Find the number of auxiliary columns */ | 210568 | /* Find the number of auxiliary columns */ |
| 209399 | if( check.rc==SQLITE_OK ){ | 210569 | if( check.rc==SQLITE_OK ){ |
| 209400 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); | 210570 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); |
| @@ -209435,16 +210605,35 @@ static int rtreeCheckTable( | |||
| 209435 | sqlite3_finalize(check.aCheckMapping[0]); | 210605 | sqlite3_finalize(check.aCheckMapping[0]); |
| 209436 | sqlite3_finalize(check.aCheckMapping[1]); | 210606 | sqlite3_finalize(check.aCheckMapping[1]); |
| 209437 | 210607 | ||
| 209438 | /* If one was opened, close the transaction */ | ||
| 209439 | if( bEnd ){ | ||
| 209440 | int rc = sqlite3_exec(db, "END", 0, 0, 0); | ||
| 209441 | if( check.rc==SQLITE_OK ) check.rc = rc; | ||
| 209442 | } | ||
| 209443 | *pzReport = check.zReport; | 210608 | *pzReport = check.zReport; |
| 209444 | return check.rc; | 210609 | return check.rc; |
| 209445 | } | 210610 | } |
| 209446 | 210611 | ||
| 209447 | /* | 210612 | /* |
| 210613 | ** Implementation of the xIntegrity method for Rtree. | ||
| 210614 | */ | ||
| 210615 | static int rtreeIntegrity( | ||
| 210616 | sqlite3_vtab *pVtab, /* The virtual table to check */ | ||
| 210617 | const char *zSchema, /* Schema in which the virtual table lives */ | ||
| 210618 | const char *zName, /* Name of the virtual table */ | ||
| 210619 | int isQuick, /* True for a quick_check */ | ||
| 210620 | char **pzErr /* Write results here */ | ||
| 210621 | ){ | ||
| 210622 | Rtree *pRtree = (Rtree*)pVtab; | ||
| 210623 | int rc; | ||
| 210624 | assert( pzErr!=0 && *pzErr==0 ); | ||
| 210625 | UNUSED_PARAMETER(zSchema); | ||
| 210626 | UNUSED_PARAMETER(zName); | ||
| 210627 | UNUSED_PARAMETER(isQuick); | ||
| 210628 | rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr); | ||
| 210629 | if( rc==SQLITE_OK && *pzErr ){ | ||
| 210630 | *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z", | ||
| 210631 | pRtree->zDb, pRtree->zName, *pzErr); | ||
| 210632 | } | ||
| 210633 | return rc; | ||
| 210634 | } | ||
| 210635 | |||
| 210636 | /* | ||
| 209448 | ** Usage: | 210637 | ** Usage: |
| 209449 | ** | 210638 | ** |
| 209450 | ** rtreecheck(<rtree-table>); | 210639 | ** rtreecheck(<rtree-table>); |
| @@ -210765,24 +211954,28 @@ static int geopolyInit( | |||
| 210765 | (void)pAux; | 211954 | (void)pAux; |
| 210766 | 211955 | ||
| 210767 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); | 211956 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 211957 | sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); | ||
| 210768 | 211958 | ||
| 210769 | /* Allocate the sqlite3_vtab structure */ | 211959 | /* Allocate the sqlite3_vtab structure */ |
| 210770 | nDb = strlen(argv[1]); | 211960 | nDb = strlen(argv[1]); |
| 210771 | nName = strlen(argv[2]); | 211961 | nName = strlen(argv[2]); |
| 210772 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); | 211962 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); |
| 210773 | if( !pRtree ){ | 211963 | if( !pRtree ){ |
| 210774 | return SQLITE_NOMEM; | 211964 | return SQLITE_NOMEM; |
| 210775 | } | 211965 | } |
| 210776 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); | 211966 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); |
| 210777 | pRtree->nBusy = 1; | 211967 | pRtree->nBusy = 1; |
| 210778 | pRtree->base.pModule = &rtreeModule; | 211968 | pRtree->base.pModule = &rtreeModule; |
| 210779 | pRtree->zDb = (char *)&pRtree[1]; | 211969 | pRtree->zDb = (char *)&pRtree[1]; |
| 210780 | pRtree->zName = &pRtree->zDb[nDb+1]; | 211970 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 211971 | pRtree->zNodeName = &pRtree->zName[nName+1]; | ||
| 210781 | pRtree->eCoordType = RTREE_COORD_REAL32; | 211972 | pRtree->eCoordType = RTREE_COORD_REAL32; |
| 210782 | pRtree->nDim = 2; | 211973 | pRtree->nDim = 2; |
| 210783 | pRtree->nDim2 = 4; | 211974 | pRtree->nDim2 = 4; |
| 210784 | memcpy(pRtree->zDb, argv[1], nDb); | 211975 | memcpy(pRtree->zDb, argv[1], nDb); |
| 210785 | memcpy(pRtree->zName, argv[2], nName); | 211976 | memcpy(pRtree->zName, argv[2], nName); |
| 211977 | memcpy(pRtree->zNodeName, argv[2], nName); | ||
| 211978 | memcpy(&pRtree->zNodeName[nName], "_node", 6); | ||
| 210786 | 211979 | ||
| 210787 | 211980 | ||
| 210788 | /* Create/Connect to the underlying relational database schema. If | 211981 | /* Create/Connect to the underlying relational database schema. If |
| @@ -211196,7 +212389,6 @@ static int geopolyUpdate( | |||
| 211196 | } | 212389 | } |
| 211197 | if( rc==SQLITE_OK ){ | 212390 | if( rc==SQLITE_OK ){ |
| 211198 | int rc2; | 212391 | int rc2; |
| 211199 | pRtree->iReinsertHeight = -1; | ||
| 211200 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); | 212392 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 211201 | rc2 = nodeRelease(pRtree, pLeaf); | 212393 | rc2 = nodeRelease(pRtree, pLeaf); |
| 211202 | if( rc==SQLITE_OK ){ | 212394 | if( rc==SQLITE_OK ){ |
| @@ -211293,7 +212485,8 @@ static sqlite3_module geopolyModule = { | |||
| 211293 | rtreeSavepoint, /* xSavepoint */ | 212485 | rtreeSavepoint, /* xSavepoint */ |
| 211294 | 0, /* xRelease */ | 212486 | 0, /* xRelease */ |
| 211295 | 0, /* xRollbackTo */ | 212487 | 0, /* xRollbackTo */ |
| 211296 | rtreeShadowName /* xShadowName */ | 212488 | rtreeShadowName, /* xShadowName */ |
| 212489 | rtreeIntegrity /* xIntegrity */ | ||
| 211297 | }; | 212490 | }; |
| 211298 | 212491 | ||
| 211299 | static int sqlite3_geopoly_init(sqlite3 *db){ | 212492 | static int sqlite3_geopoly_init(sqlite3 *db){ |
| @@ -219307,7 +220500,8 @@ SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ | |||
| 219307 | 0, /* xSavepoint */ | 220500 | 0, /* xSavepoint */ |
| 219308 | 0, /* xRelease */ | 220501 | 0, /* xRelease */ |
| 219309 | 0, /* xRollbackTo */ | 220502 | 0, /* xRollbackTo */ |
| 219310 | 0 /* xShadowName */ | 220503 | 0, /* xShadowName */ |
| 220504 | 0 /* xIntegrity */ | ||
| 219311 | }; | 220505 | }; |
| 219312 | return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); | 220506 | return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); |
| 219313 | } | 220507 | } |
| @@ -219744,7 +220938,8 @@ SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ | |||
| 219744 | 0, /* xSavepoint */ | 220938 | 0, /* xSavepoint */ |
| 219745 | 0, /* xRelease */ | 220939 | 0, /* xRelease */ |
| 219746 | 0, /* xRollbackTo */ | 220940 | 0, /* xRollbackTo */ |
| 219747 | 0 /* xShadowName */ | 220941 | 0, /* xShadowName */ |
| 220942 | 0 /* xIntegrity */ | ||
| 219748 | }; | 220943 | }; |
| 219749 | return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); | 220944 | return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); |
| 219750 | } | 220945 | } |
| @@ -219875,6 +221070,18 @@ struct sqlite3_changeset_iter { | |||
| 219875 | ** The data associated with each hash-table entry is a structure containing | 221070 | ** The data associated with each hash-table entry is a structure containing |
| 219876 | ** a subset of the initial values that the modified row contained at the | 221071 | ** a subset of the initial values that the modified row contained at the |
| 219877 | ** start of the session. Or no initial values if the row was inserted. | 221072 | ** start of the session. Or no initial values if the row was inserted. |
| 221073 | ** | ||
| 221074 | ** pDfltStmt: | ||
| 221075 | ** This is only used by the sqlite3changegroup_xxx() APIs, not by | ||
| 221076 | ** regular sqlite3_session objects. It is a SELECT statement that | ||
| 221077 | ** selects the default value for each table column. For example, | ||
| 221078 | ** if the table is | ||
| 221079 | ** | ||
| 221080 | ** CREATE TABLE xx(a DEFAULT 1, b, c DEFAULT 'abc') | ||
| 221081 | ** | ||
| 221082 | ** then this variable is the compiled version of: | ||
| 221083 | ** | ||
| 221084 | ** SELECT 1, NULL, 'abc' | ||
| 219878 | */ | 221085 | */ |
| 219879 | struct SessionTable { | 221086 | struct SessionTable { |
| 219880 | SessionTable *pNext; | 221087 | SessionTable *pNext; |
| @@ -219883,10 +221090,12 @@ struct SessionTable { | |||
| 219883 | int bStat1; /* True if this is sqlite_stat1 */ | 221090 | int bStat1; /* True if this is sqlite_stat1 */ |
| 219884 | int bRowid; /* True if this table uses rowid for PK */ | 221091 | int bRowid; /* True if this table uses rowid for PK */ |
| 219885 | const char **azCol; /* Column names */ | 221092 | const char **azCol; /* Column names */ |
| 221093 | const char **azDflt; /* Default value expressions */ | ||
| 219886 | u8 *abPK; /* Array of primary key flags */ | 221094 | u8 *abPK; /* Array of primary key flags */ |
| 219887 | int nEntry; /* Total number of entries in hash table */ | 221095 | int nEntry; /* Total number of entries in hash table */ |
| 219888 | int nChange; /* Size of apChange[] array */ | 221096 | int nChange; /* Size of apChange[] array */ |
| 219889 | SessionChange **apChange; /* Hash table buckets */ | 221097 | SessionChange **apChange; /* Hash table buckets */ |
| 221098 | sqlite3_stmt *pDfltStmt; | ||
| 219890 | }; | 221099 | }; |
| 219891 | 221100 | ||
| 219892 | /* | 221101 | /* |
| @@ -220055,6 +221264,7 @@ struct SessionTable { | |||
| 220055 | struct SessionChange { | 221264 | struct SessionChange { |
| 220056 | u8 op; /* One of UPDATE, DELETE, INSERT */ | 221265 | u8 op; /* One of UPDATE, DELETE, INSERT */ |
| 220057 | u8 bIndirect; /* True if this change is "indirect" */ | 221266 | u8 bIndirect; /* True if this change is "indirect" */ |
| 221267 | u16 nRecordField; /* Number of fields in aRecord[] */ | ||
| 220058 | int nMaxSize; /* Max size of eventual changeset record */ | 221268 | int nMaxSize; /* Max size of eventual changeset record */ |
| 220059 | int nRecord; /* Number of bytes in buffer aRecord[] */ | 221269 | int nRecord; /* Number of bytes in buffer aRecord[] */ |
| 220060 | u8 *aRecord; /* Buffer containing old.* record */ | 221270 | u8 *aRecord; /* Buffer containing old.* record */ |
| @@ -220080,7 +221290,7 @@ static int sessionVarintLen(int iVal){ | |||
| 220080 | ** Read a varint value from aBuf[] into *piVal. Return the number of | 221290 | ** Read a varint value from aBuf[] into *piVal. Return the number of |
| 220081 | ** bytes read. | 221291 | ** bytes read. |
| 220082 | */ | 221292 | */ |
| 220083 | static int sessionVarintGet(u8 *aBuf, int *piVal){ | 221293 | static int sessionVarintGet(const u8 *aBuf, int *piVal){ |
| 220084 | return getVarint32(aBuf, *piVal); | 221294 | return getVarint32(aBuf, *piVal); |
| 220085 | } | 221295 | } |
| 220086 | 221296 | ||
| @@ -220343,9 +221553,11 @@ static int sessionPreupdateHash( | |||
| 220343 | ** Return the number of bytes of space occupied by the value (including | 221553 | ** Return the number of bytes of space occupied by the value (including |
| 220344 | ** the type byte). | 221554 | ** the type byte). |
| 220345 | */ | 221555 | */ |
| 220346 | static int sessionSerialLen(u8 *a){ | 221556 | static int sessionSerialLen(const u8 *a){ |
| 220347 | int e = *a; | 221557 | int e; |
| 220348 | int n; | 221558 | int n; |
| 221559 | assert( a!=0 ); | ||
| 221560 | e = *a; | ||
| 220349 | if( e==0 || e==0xFF ) return 1; | 221561 | if( e==0 || e==0xFF ) return 1; |
| 220350 | if( e==SQLITE_NULL ) return 1; | 221562 | if( e==SQLITE_NULL ) return 1; |
| 220351 | if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; | 221563 | if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; |
| @@ -220750,13 +221962,14 @@ static int sessionGrowHash( | |||
| 220750 | ** | 221962 | ** |
| 220751 | ** For example, if the table is declared as: | 221963 | ** For example, if the table is declared as: |
| 220752 | ** | 221964 | ** |
| 220753 | ** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z)); | 221965 | ** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z)); |
| 220754 | ** | 221966 | ** |
| 220755 | ** Then the four output variables are populated as follows: | 221967 | ** Then the five output variables are populated as follows: |
| 220756 | ** | 221968 | ** |
| 220757 | ** *pnCol = 4 | 221969 | ** *pnCol = 4 |
| 220758 | ** *pzTab = "tbl1" | 221970 | ** *pzTab = "tbl1" |
| 220759 | ** *pazCol = {"w", "x", "y", "z"} | 221971 | ** *pazCol = {"w", "x", "y", "z"} |
| 221972 | ** *pazDflt = {NULL, 'abc', NULL, NULL} | ||
| 220760 | ** *pabPK = {1, 0, 0, 1} | 221973 | ** *pabPK = {1, 0, 0, 1} |
| 220761 | ** | 221974 | ** |
| 220762 | ** All returned buffers are part of the same single allocation, which must | 221975 | ** All returned buffers are part of the same single allocation, which must |
| @@ -220770,6 +221983,7 @@ static int sessionTableInfo( | |||
| 220770 | int *pnCol, /* OUT: number of columns */ | 221983 | int *pnCol, /* OUT: number of columns */ |
| 220771 | const char **pzTab, /* OUT: Copy of zThis */ | 221984 | const char **pzTab, /* OUT: Copy of zThis */ |
| 220772 | const char ***pazCol, /* OUT: Array of column names for table */ | 221985 | const char ***pazCol, /* OUT: Array of column names for table */ |
| 221986 | const char ***pazDflt, /* OUT: Array of default value expressions */ | ||
| 220773 | u8 **pabPK, /* OUT: Array of booleans - true for PK col */ | 221987 | u8 **pabPK, /* OUT: Array of booleans - true for PK col */ |
| 220774 | int *pbRowid /* OUT: True if only PK is a rowid */ | 221988 | int *pbRowid /* OUT: True if only PK is a rowid */ |
| 220775 | ){ | 221989 | ){ |
| @@ -220782,11 +221996,18 @@ static int sessionTableInfo( | |||
| 220782 | int i; | 221996 | int i; |
| 220783 | u8 *pAlloc = 0; | 221997 | u8 *pAlloc = 0; |
| 220784 | char **azCol = 0; | 221998 | char **azCol = 0; |
| 221999 | char **azDflt = 0; | ||
| 220785 | u8 *abPK = 0; | 222000 | u8 *abPK = 0; |
| 220786 | int bRowid = 0; /* Set to true to use rowid as PK */ | 222001 | int bRowid = 0; /* Set to true to use rowid as PK */ |
| 220787 | 222002 | ||
| 220788 | assert( pazCol && pabPK ); | 222003 | assert( pazCol && pabPK ); |
| 220789 | 222004 | ||
| 222005 | *pazCol = 0; | ||
| 222006 | *pabPK = 0; | ||
| 222007 | *pnCol = 0; | ||
| 222008 | if( pzTab ) *pzTab = 0; | ||
| 222009 | if( pazDflt ) *pazDflt = 0; | ||
| 222010 | |||
| 220790 | nThis = sqlite3Strlen30(zThis); | 222011 | nThis = sqlite3Strlen30(zThis); |
| 220791 | if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ | 222012 | if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ |
| 220792 | rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); | 222013 | rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); |
| @@ -220800,39 +222021,28 @@ static int sessionTableInfo( | |||
| 220800 | }else if( rc==SQLITE_ERROR ){ | 222021 | }else if( rc==SQLITE_ERROR ){ |
| 220801 | zPragma = sqlite3_mprintf(""); | 222022 | zPragma = sqlite3_mprintf(""); |
| 220802 | }else{ | 222023 | }else{ |
| 220803 | *pazCol = 0; | ||
| 220804 | *pabPK = 0; | ||
| 220805 | *pnCol = 0; | ||
| 220806 | if( pzTab ) *pzTab = 0; | ||
| 220807 | return rc; | 222024 | return rc; |
| 220808 | } | 222025 | } |
| 220809 | }else{ | 222026 | }else{ |
| 220810 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); | 222027 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); |
| 220811 | } | 222028 | } |
| 220812 | if( !zPragma ){ | 222029 | if( !zPragma ){ |
| 220813 | *pazCol = 0; | ||
| 220814 | *pabPK = 0; | ||
| 220815 | *pnCol = 0; | ||
| 220816 | if( pzTab ) *pzTab = 0; | ||
| 220817 | return SQLITE_NOMEM; | 222030 | return SQLITE_NOMEM; |
| 220818 | } | 222031 | } |
| 220819 | 222032 | ||
| 220820 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); | 222033 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); |
| 220821 | sqlite3_free(zPragma); | 222034 | sqlite3_free(zPragma); |
| 220822 | if( rc!=SQLITE_OK ){ | 222035 | if( rc!=SQLITE_OK ){ |
| 220823 | *pazCol = 0; | ||
| 220824 | *pabPK = 0; | ||
| 220825 | *pnCol = 0; | ||
| 220826 | if( pzTab ) *pzTab = 0; | ||
| 220827 | return rc; | 222036 | return rc; |
| 220828 | } | 222037 | } |
| 220829 | 222038 | ||
| 220830 | nByte = nThis + 1; | 222039 | nByte = nThis + 1; |
| 220831 | bRowid = (pbRowid!=0); | 222040 | bRowid = (pbRowid!=0); |
| 220832 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ | 222041 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 220833 | nByte += sqlite3_column_bytes(pStmt, 1); | 222042 | nByte += sqlite3_column_bytes(pStmt, 1); /* name */ |
| 222043 | nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */ | ||
| 220834 | nDbCol++; | 222044 | nDbCol++; |
| 220835 | if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; | 222045 | if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */ |
| 220836 | } | 222046 | } |
| 220837 | if( nDbCol==0 ) bRowid = 0; | 222047 | if( nDbCol==0 ) bRowid = 0; |
| 220838 | nDbCol += bRowid; | 222048 | nDbCol += bRowid; |
| @@ -220840,15 +222050,18 @@ static int sessionTableInfo( | |||
| 220840 | rc = sqlite3_reset(pStmt); | 222050 | rc = sqlite3_reset(pStmt); |
| 220841 | 222051 | ||
| 220842 | if( rc==SQLITE_OK ){ | 222052 | if( rc==SQLITE_OK ){ |
| 220843 | nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); | 222053 | nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1); |
| 220844 | pAlloc = sessionMalloc64(pSession, nByte); | 222054 | pAlloc = sessionMalloc64(pSession, nByte); |
| 220845 | if( pAlloc==0 ){ | 222055 | if( pAlloc==0 ){ |
| 220846 | rc = SQLITE_NOMEM; | 222056 | rc = SQLITE_NOMEM; |
| 222057 | }else{ | ||
| 222058 | memset(pAlloc, 0, nByte); | ||
| 220847 | } | 222059 | } |
| 220848 | } | 222060 | } |
| 220849 | if( rc==SQLITE_OK ){ | 222061 | if( rc==SQLITE_OK ){ |
| 220850 | azCol = (char **)pAlloc; | 222062 | azCol = (char **)pAlloc; |
| 220851 | pAlloc = (u8 *)&azCol[nDbCol]; | 222063 | azDflt = (char**)&azCol[nDbCol]; |
| 222064 | pAlloc = (u8 *)&azDflt[nDbCol]; | ||
| 220852 | abPK = (u8 *)pAlloc; | 222065 | abPK = (u8 *)pAlloc; |
| 220853 | pAlloc = &abPK[nDbCol]; | 222066 | pAlloc = &abPK[nDbCol]; |
| 220854 | if( pzTab ){ | 222067 | if( pzTab ){ |
| @@ -220868,11 +222081,21 @@ static int sessionTableInfo( | |||
| 220868 | } | 222081 | } |
| 220869 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ | 222082 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 220870 | int nName = sqlite3_column_bytes(pStmt, 1); | 222083 | int nName = sqlite3_column_bytes(pStmt, 1); |
| 222084 | int nDflt = sqlite3_column_bytes(pStmt, 4); | ||
| 220871 | const unsigned char *zName = sqlite3_column_text(pStmt, 1); | 222085 | const unsigned char *zName = sqlite3_column_text(pStmt, 1); |
| 222086 | const unsigned char *zDflt = sqlite3_column_text(pStmt, 4); | ||
| 222087 | |||
| 220872 | if( zName==0 ) break; | 222088 | if( zName==0 ) break; |
| 220873 | memcpy(pAlloc, zName, nName+1); | 222089 | memcpy(pAlloc, zName, nName+1); |
| 220874 | azCol[i] = (char *)pAlloc; | 222090 | azCol[i] = (char *)pAlloc; |
| 220875 | pAlloc += nName+1; | 222091 | pAlloc += nName+1; |
| 222092 | if( zDflt ){ | ||
| 222093 | memcpy(pAlloc, zDflt, nDflt+1); | ||
| 222094 | azDflt[i] = (char *)pAlloc; | ||
| 222095 | pAlloc += nDflt+1; | ||
| 222096 | }else{ | ||
| 222097 | azDflt[i] = 0; | ||
| 222098 | } | ||
| 220876 | abPK[i] = sqlite3_column_int(pStmt, 5); | 222099 | abPK[i] = sqlite3_column_int(pStmt, 5); |
| 220877 | i++; | 222100 | i++; |
| 220878 | } | 222101 | } |
| @@ -220883,14 +222106,11 @@ static int sessionTableInfo( | |||
| 220883 | ** free any allocation made. An error code will be returned in this case. | 222106 | ** free any allocation made. An error code will be returned in this case. |
| 220884 | */ | 222107 | */ |
| 220885 | if( rc==SQLITE_OK ){ | 222108 | if( rc==SQLITE_OK ){ |
| 220886 | *pazCol = (const char **)azCol; | 222109 | *pazCol = (const char**)azCol; |
| 222110 | if( pazDflt ) *pazDflt = (const char**)azDflt; | ||
| 220887 | *pabPK = abPK; | 222111 | *pabPK = abPK; |
| 220888 | *pnCol = nDbCol; | 222112 | *pnCol = nDbCol; |
| 220889 | }else{ | 222113 | }else{ |
| 220890 | *pazCol = 0; | ||
| 220891 | *pabPK = 0; | ||
| 220892 | *pnCol = 0; | ||
| 220893 | if( pzTab ) *pzTab = 0; | ||
| 220894 | sessionFree(pSession, azCol); | 222114 | sessionFree(pSession, azCol); |
| 220895 | } | 222115 | } |
| 220896 | if( pbRowid ) *pbRowid = bRowid; | 222116 | if( pbRowid ) *pbRowid = bRowid; |
| @@ -220899,10 +222119,9 @@ static int sessionTableInfo( | |||
| 220899 | } | 222119 | } |
| 220900 | 222120 | ||
| 220901 | /* | 222121 | /* |
| 220902 | ** This function is only called from within a pre-update handler for a | 222122 | ** This function is called to initialize the SessionTable.nCol, azCol[] |
| 220903 | ** write to table pTab, part of session pSession. If this is the first | 222123 | ** abPK[] and azDflt[] members of SessionTable object pTab. If these |
| 220904 | ** write to this table, initalize the SessionTable.nCol, azCol[] and | 222124 | ** fields are already initilialized, this function is a no-op. |
| 220905 | ** abPK[] arrays accordingly. | ||
| 220906 | ** | 222125 | ** |
| 220907 | ** If an error occurs, an error code is stored in sqlite3_session.rc and | 222126 | ** If an error occurs, an error code is stored in sqlite3_session.rc and |
| 220908 | ** non-zero returned. Or, if no error occurs but the table has no primary | 222127 | ** non-zero returned. Or, if no error occurs but the table has no primary |
| @@ -220910,15 +222129,22 @@ static int sessionTableInfo( | |||
| 220910 | ** indicate that updates on this table should be ignored. SessionTable.abPK | 222129 | ** indicate that updates on this table should be ignored. SessionTable.abPK |
| 220911 | ** is set to NULL in this case. | 222130 | ** is set to NULL in this case. |
| 220912 | */ | 222131 | */ |
| 220913 | static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ | 222132 | static int sessionInitTable( |
| 222133 | sqlite3_session *pSession, /* Optional session handle */ | ||
| 222134 | SessionTable *pTab, /* Table object to initialize */ | ||
| 222135 | sqlite3 *db, /* Database handle to read schema from */ | ||
| 222136 | const char *zDb /* Name of db - "main", "temp" etc. */ | ||
| 222137 | ){ | ||
| 222138 | int rc = SQLITE_OK; | ||
| 222139 | |||
| 220914 | if( pTab->nCol==0 ){ | 222140 | if( pTab->nCol==0 ){ |
| 220915 | u8 *abPK; | 222141 | u8 *abPK; |
| 220916 | assert( pTab->azCol==0 || pTab->abPK==0 ); | 222142 | assert( pTab->azCol==0 || pTab->abPK==0 ); |
| 220917 | pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, | 222143 | rc = sessionTableInfo(pSession, db, zDb, |
| 220918 | pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK, | 222144 | pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK, |
| 220919 | (pSession->bImplicitPK ? &pTab->bRowid : 0) | 222145 | ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0) |
| 220920 | ); | 222146 | ); |
| 220921 | if( pSession->rc==SQLITE_OK ){ | 222147 | if( rc==SQLITE_OK ){ |
| 220922 | int i; | 222148 | int i; |
| 220923 | for(i=0; i<pTab->nCol; i++){ | 222149 | for(i=0; i<pTab->nCol; i++){ |
| 220924 | if( abPK[i] ){ | 222150 | if( abPK[i] ){ |
| @@ -220930,14 +222156,321 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ | |||
| 220930 | pTab->bStat1 = 1; | 222156 | pTab->bStat1 = 1; |
| 220931 | } | 222157 | } |
| 220932 | 222158 | ||
| 220933 | if( pSession->bEnableSize ){ | 222159 | if( pSession && pSession->bEnableSize ){ |
| 220934 | pSession->nMaxChangesetSize += ( | 222160 | pSession->nMaxChangesetSize += ( |
| 220935 | 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 | 222161 | 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 |
| 220936 | ); | 222162 | ); |
| 220937 | } | 222163 | } |
| 220938 | } | 222164 | } |
| 220939 | } | 222165 | } |
| 220940 | return (pSession->rc || pTab->abPK==0); | 222166 | |
| 222167 | if( pSession ){ | ||
| 222168 | pSession->rc = rc; | ||
| 222169 | return (rc || pTab->abPK==0); | ||
| 222170 | } | ||
| 222171 | return rc; | ||
| 222172 | } | ||
| 222173 | |||
| 222174 | /* | ||
| 222175 | ** Re-initialize table object pTab. | ||
| 222176 | */ | ||
| 222177 | static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){ | ||
| 222178 | int nCol = 0; | ||
| 222179 | const char **azCol = 0; | ||
| 222180 | const char **azDflt = 0; | ||
| 222181 | u8 *abPK = 0; | ||
| 222182 | int bRowid = 0; | ||
| 222183 | |||
| 222184 | assert( pSession->rc==SQLITE_OK ); | ||
| 222185 | |||
| 222186 | pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, | ||
| 222187 | pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK, | ||
| 222188 | (pSession->bImplicitPK ? &bRowid : 0) | ||
| 222189 | ); | ||
| 222190 | if( pSession->rc==SQLITE_OK ){ | ||
| 222191 | if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){ | ||
| 222192 | pSession->rc = SQLITE_SCHEMA; | ||
| 222193 | }else{ | ||
| 222194 | int ii; | ||
| 222195 | int nOldCol = pTab->nCol; | ||
| 222196 | for(ii=0; ii<nCol; ii++){ | ||
| 222197 | if( ii<pTab->nCol ){ | ||
| 222198 | if( pTab->abPK[ii]!=abPK[ii] ){ | ||
| 222199 | pSession->rc = SQLITE_SCHEMA; | ||
| 222200 | } | ||
| 222201 | }else if( abPK[ii] ){ | ||
| 222202 | pSession->rc = SQLITE_SCHEMA; | ||
| 222203 | } | ||
| 222204 | } | ||
| 222205 | |||
| 222206 | if( pSession->rc==SQLITE_OK ){ | ||
| 222207 | const char **a = pTab->azCol; | ||
| 222208 | pTab->azCol = azCol; | ||
| 222209 | pTab->nCol = nCol; | ||
| 222210 | pTab->azDflt = azDflt; | ||
| 222211 | pTab->abPK = abPK; | ||
| 222212 | azCol = a; | ||
| 222213 | } | ||
| 222214 | if( pSession->bEnableSize ){ | ||
| 222215 | pSession->nMaxChangesetSize += (nCol - nOldCol); | ||
| 222216 | pSession->nMaxChangesetSize += sessionVarintLen(nCol); | ||
| 222217 | pSession->nMaxChangesetSize -= sessionVarintLen(nOldCol); | ||
| 222218 | } | ||
| 222219 | } | ||
| 222220 | } | ||
| 222221 | |||
| 222222 | sqlite3_free((char*)azCol); | ||
| 222223 | return pSession->rc; | ||
| 222224 | } | ||
| 222225 | |||
| 222226 | /* | ||
| 222227 | ** Session-change object (*pp) contains an old.* record with fewer than | ||
| 222228 | ** nCol fields. This function updates it with the default values for | ||
| 222229 | ** the missing fields. | ||
| 222230 | */ | ||
| 222231 | static void sessionUpdateOneChange( | ||
| 222232 | sqlite3_session *pSession, /* For memory accounting */ | ||
| 222233 | int *pRc, /* IN/OUT: Error code */ | ||
| 222234 | SessionChange **pp, /* IN/OUT: Change object to update */ | ||
| 222235 | int nCol, /* Number of columns now in table */ | ||
| 222236 | sqlite3_stmt *pDflt /* SELECT <default-values...> */ | ||
| 222237 | ){ | ||
| 222238 | SessionChange *pOld = *pp; | ||
| 222239 | |||
| 222240 | while( pOld->nRecordField<nCol ){ | ||
| 222241 | SessionChange *pNew = 0; | ||
| 222242 | int nByte = 0; | ||
| 222243 | int nIncr = 0; | ||
| 222244 | int iField = pOld->nRecordField; | ||
| 222245 | int eType = sqlite3_column_type(pDflt, iField); | ||
| 222246 | switch( eType ){ | ||
| 222247 | case SQLITE_NULL: | ||
| 222248 | nIncr = 1; | ||
| 222249 | break; | ||
| 222250 | case SQLITE_INTEGER: | ||
| 222251 | case SQLITE_FLOAT: | ||
| 222252 | nIncr = 9; | ||
| 222253 | break; | ||
| 222254 | default: { | ||
| 222255 | int n = sqlite3_column_bytes(pDflt, iField); | ||
| 222256 | nIncr = 1 + sessionVarintLen(n) + n; | ||
| 222257 | assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); | ||
| 222258 | break; | ||
| 222259 | } | ||
| 222260 | } | ||
| 222261 | |||
| 222262 | nByte = nIncr + (sizeof(SessionChange) + pOld->nRecord); | ||
| 222263 | pNew = sessionMalloc64(pSession, nByte); | ||
| 222264 | if( pNew==0 ){ | ||
| 222265 | *pRc = SQLITE_NOMEM; | ||
| 222266 | return; | ||
| 222267 | }else{ | ||
| 222268 | memcpy(pNew, pOld, sizeof(SessionChange)); | ||
| 222269 | pNew->aRecord = (u8*)&pNew[1]; | ||
| 222270 | memcpy(pNew->aRecord, pOld->aRecord, pOld->nRecord); | ||
| 222271 | pNew->aRecord[pNew->nRecord++] = (u8)eType; | ||
| 222272 | switch( eType ){ | ||
| 222273 | case SQLITE_INTEGER: { | ||
| 222274 | i64 iVal = sqlite3_column_int64(pDflt, iField); | ||
| 222275 | sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); | ||
| 222276 | pNew->nRecord += 8; | ||
| 222277 | break; | ||
| 222278 | } | ||
| 222279 | |||
| 222280 | case SQLITE_FLOAT: { | ||
| 222281 | double rVal = sqlite3_column_double(pDflt, iField); | ||
| 222282 | i64 iVal = 0; | ||
| 222283 | memcpy(&iVal, &rVal, sizeof(rVal)); | ||
| 222284 | sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); | ||
| 222285 | pNew->nRecord += 8; | ||
| 222286 | break; | ||
| 222287 | } | ||
| 222288 | |||
| 222289 | case SQLITE_TEXT: { | ||
| 222290 | int n = sqlite3_column_bytes(pDflt, iField); | ||
| 222291 | const char *z = (const char*)sqlite3_column_text(pDflt, iField); | ||
| 222292 | pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); | ||
| 222293 | memcpy(&pNew->aRecord[pNew->nRecord], z, n); | ||
| 222294 | pNew->nRecord += n; | ||
| 222295 | break; | ||
| 222296 | } | ||
| 222297 | |||
| 222298 | case SQLITE_BLOB: { | ||
| 222299 | int n = sqlite3_column_bytes(pDflt, iField); | ||
| 222300 | const u8 *z = (const u8*)sqlite3_column_blob(pDflt, iField); | ||
| 222301 | pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); | ||
| 222302 | memcpy(&pNew->aRecord[pNew->nRecord], z, n); | ||
| 222303 | pNew->nRecord += n; | ||
| 222304 | break; | ||
| 222305 | } | ||
| 222306 | |||
| 222307 | default: | ||
| 222308 | assert( eType==SQLITE_NULL ); | ||
| 222309 | break; | ||
| 222310 | } | ||
| 222311 | |||
| 222312 | sessionFree(pSession, pOld); | ||
| 222313 | *pp = pOld = pNew; | ||
| 222314 | pNew->nRecordField++; | ||
| 222315 | pNew->nMaxSize += nIncr; | ||
| 222316 | if( pSession ){ | ||
| 222317 | pSession->nMaxChangesetSize += nIncr; | ||
| 222318 | } | ||
| 222319 | } | ||
| 222320 | } | ||
| 222321 | } | ||
| 222322 | |||
| 222323 | /* | ||
| 222324 | ** Ensure that there is room in the buffer to append nByte bytes of data. | ||
| 222325 | ** If not, use sqlite3_realloc() to grow the buffer so that there is. | ||
| 222326 | ** | ||
| 222327 | ** If successful, return zero. Otherwise, if an OOM condition is encountered, | ||
| 222328 | ** set *pRc to SQLITE_NOMEM and return non-zero. | ||
| 222329 | */ | ||
| 222330 | static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ | ||
| 222331 | #define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) | ||
| 222332 | i64 nReq = p->nBuf + nByte; | ||
| 222333 | if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ | ||
| 222334 | u8 *aNew; | ||
| 222335 | i64 nNew = p->nAlloc ? p->nAlloc : 128; | ||
| 222336 | |||
| 222337 | do { | ||
| 222338 | nNew = nNew*2; | ||
| 222339 | }while( nNew<nReq ); | ||
| 222340 | |||
| 222341 | /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation | ||
| 222342 | ** of sqlite3_realloc64(). Allocations greater than this size in bytes | ||
| 222343 | ** always fail. It is used here to ensure that this routine can always | ||
| 222344 | ** allocate up to this limit - instead of up to the largest power of | ||
| 222345 | ** two smaller than the limit. */ | ||
| 222346 | if( nNew>SESSION_MAX_BUFFER_SZ ){ | ||
| 222347 | nNew = SESSION_MAX_BUFFER_SZ; | ||
| 222348 | if( nNew<nReq ){ | ||
| 222349 | *pRc = SQLITE_NOMEM; | ||
| 222350 | return 1; | ||
| 222351 | } | ||
| 222352 | } | ||
| 222353 | |||
| 222354 | aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); | ||
| 222355 | if( 0==aNew ){ | ||
| 222356 | *pRc = SQLITE_NOMEM; | ||
| 222357 | }else{ | ||
| 222358 | p->aBuf = aNew; | ||
| 222359 | p->nAlloc = nNew; | ||
| 222360 | } | ||
| 222361 | } | ||
| 222362 | return (*pRc!=SQLITE_OK); | ||
| 222363 | } | ||
| 222364 | |||
| 222365 | |||
| 222366 | /* | ||
| 222367 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is | ||
| 222368 | ** called. Otherwise, append a string to the buffer. All bytes in the string | ||
| 222369 | ** up to (but not including) the nul-terminator are written to the buffer. | ||
| 222370 | ** | ||
| 222371 | ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before | ||
| 222372 | ** returning. | ||
| 222373 | */ | ||
| 222374 | static void sessionAppendStr( | ||
| 222375 | SessionBuffer *p, | ||
| 222376 | const char *zStr, | ||
| 222377 | int *pRc | ||
| 222378 | ){ | ||
| 222379 | int nStr = sqlite3Strlen30(zStr); | ||
| 222380 | if( 0==sessionBufferGrow(p, nStr+1, pRc) ){ | ||
| 222381 | memcpy(&p->aBuf[p->nBuf], zStr, nStr); | ||
| 222382 | p->nBuf += nStr; | ||
| 222383 | p->aBuf[p->nBuf] = 0x00; | ||
| 222384 | } | ||
| 222385 | } | ||
| 222386 | |||
| 222387 | /* | ||
| 222388 | ** Format a string using printf() style formatting and then append it to the | ||
| 222389 | ** buffer using sessionAppendString(). | ||
| 222390 | */ | ||
| 222391 | static void sessionAppendPrintf( | ||
| 222392 | SessionBuffer *p, /* Buffer to append to */ | ||
| 222393 | int *pRc, | ||
| 222394 | const char *zFmt, | ||
| 222395 | ... | ||
| 222396 | ){ | ||
| 222397 | if( *pRc==SQLITE_OK ){ | ||
| 222398 | char *zApp = 0; | ||
| 222399 | va_list ap; | ||
| 222400 | va_start(ap, zFmt); | ||
| 222401 | zApp = sqlite3_vmprintf(zFmt, ap); | ||
| 222402 | if( zApp==0 ){ | ||
| 222403 | *pRc = SQLITE_NOMEM; | ||
| 222404 | }else{ | ||
| 222405 | sessionAppendStr(p, zApp, pRc); | ||
| 222406 | } | ||
| 222407 | va_end(ap); | ||
| 222408 | sqlite3_free(zApp); | ||
| 222409 | } | ||
| 222410 | } | ||
| 222411 | |||
| 222412 | /* | ||
| 222413 | ** Prepare a statement against database handle db that SELECTs a single | ||
| 222414 | ** row containing the default values for each column in table pTab. For | ||
| 222415 | ** example, if pTab is declared as: | ||
| 222416 | ** | ||
| 222417 | ** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd'); | ||
| 222418 | ** | ||
| 222419 | ** Then this function prepares and returns the SQL statement: | ||
| 222420 | ** | ||
| 222421 | ** SELECT NULL, 123, 'abcd'; | ||
| 222422 | */ | ||
| 222423 | static int sessionPrepareDfltStmt( | ||
| 222424 | sqlite3 *db, /* Database handle */ | ||
| 222425 | SessionTable *pTab, /* Table to prepare statement for */ | ||
| 222426 | sqlite3_stmt **ppStmt /* OUT: Statement handle */ | ||
| 222427 | ){ | ||
| 222428 | SessionBuffer sql = {0,0,0}; | ||
| 222429 | int rc = SQLITE_OK; | ||
| 222430 | const char *zSep = " "; | ||
| 222431 | int ii = 0; | ||
| 222432 | |||
| 222433 | *ppStmt = 0; | ||
| 222434 | sessionAppendPrintf(&sql, &rc, "SELECT"); | ||
| 222435 | for(ii=0; ii<pTab->nCol; ii++){ | ||
| 222436 | const char *zDflt = pTab->azDflt[ii] ? pTab->azDflt[ii] : "NULL"; | ||
| 222437 | sessionAppendPrintf(&sql, &rc, "%s%s", zSep, zDflt); | ||
| 222438 | zSep = ", "; | ||
| 222439 | } | ||
| 222440 | if( rc==SQLITE_OK ){ | ||
| 222441 | rc = sqlite3_prepare_v2(db, (const char*)sql.aBuf, -1, ppStmt, 0); | ||
| 222442 | } | ||
| 222443 | sqlite3_free(sql.aBuf); | ||
| 222444 | |||
| 222445 | return rc; | ||
| 222446 | } | ||
| 222447 | |||
| 222448 | /* | ||
| 222449 | ** Table pTab has one or more existing change-records with old.* records | ||
| 222450 | ** with fewer than pTab->nCol columns. This function updates all such | ||
| 222451 | ** change-records with the default values for the missing columns. | ||
| 222452 | */ | ||
| 222453 | static int sessionUpdateChanges(sqlite3_session *pSession, SessionTable *pTab){ | ||
| 222454 | sqlite3_stmt *pStmt = 0; | ||
| 222455 | int rc = pSession->rc; | ||
| 222456 | |||
| 222457 | rc = sessionPrepareDfltStmt(pSession->db, pTab, &pStmt); | ||
| 222458 | if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ | ||
| 222459 | int ii = 0; | ||
| 222460 | SessionChange **pp = 0; | ||
| 222461 | for(ii=0; ii<pTab->nChange; ii++){ | ||
| 222462 | for(pp=&pTab->apChange[ii]; *pp; pp=&((*pp)->pNext)){ | ||
| 222463 | if( (*pp)->nRecordField!=pTab->nCol ){ | ||
| 222464 | sessionUpdateOneChange(pSession, &rc, pp, pTab->nCol, pStmt); | ||
| 222465 | } | ||
| 222466 | } | ||
| 222467 | } | ||
| 222468 | } | ||
| 222469 | |||
| 222470 | pSession->rc = rc; | ||
| 222471 | rc = sqlite3_finalize(pStmt); | ||
| 222472 | if( pSession->rc==SQLITE_OK ) pSession->rc = rc; | ||
| 222473 | return pSession->rc; | ||
| 220941 | } | 222474 | } |
| 220942 | 222475 | ||
| 220943 | /* | 222476 | /* |
| @@ -221100,16 +222633,22 @@ static void sessionPreupdateOneChange( | |||
| 221100 | int iHash; | 222633 | int iHash; |
| 221101 | int bNull = 0; | 222634 | int bNull = 0; |
| 221102 | int rc = SQLITE_OK; | 222635 | int rc = SQLITE_OK; |
| 222636 | int nExpect = 0; | ||
| 221103 | SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; | 222637 | SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; |
| 221104 | 222638 | ||
| 221105 | if( pSession->rc ) return; | 222639 | if( pSession->rc ) return; |
| 221106 | 222640 | ||
| 221107 | /* Load table details if required */ | 222641 | /* Load table details if required */ |
| 221108 | if( sessionInitTable(pSession, pTab) ) return; | 222642 | if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return; |
| 221109 | 222643 | ||
| 221110 | /* Check the number of columns in this xPreUpdate call matches the | 222644 | /* Check the number of columns in this xPreUpdate call matches the |
| 221111 | ** number of columns in the table. */ | 222645 | ** number of columns in the table. */ |
| 221112 | if( (pTab->nCol-pTab->bRowid)!=pSession->hook.xCount(pSession->hook.pCtx) ){ | 222646 | nExpect = pSession->hook.xCount(pSession->hook.pCtx); |
| 222647 | if( (pTab->nCol-pTab->bRowid)<nExpect ){ | ||
| 222648 | if( sessionReinitTable(pSession, pTab) ) return; | ||
| 222649 | if( sessionUpdateChanges(pSession, pTab) ) return; | ||
| 222650 | } | ||
| 222651 | if( (pTab->nCol-pTab->bRowid)!=nExpect ){ | ||
| 221113 | pSession->rc = SQLITE_SCHEMA; | 222652 | pSession->rc = SQLITE_SCHEMA; |
| 221114 | return; | 222653 | return; |
| 221115 | } | 222654 | } |
| @@ -221186,7 +222725,7 @@ static void sessionPreupdateOneChange( | |||
| 221186 | } | 222725 | } |
| 221187 | 222726 | ||
| 221188 | /* Allocate the change object */ | 222727 | /* Allocate the change object */ |
| 221189 | pC = (SessionChange *)sessionMalloc64(pSession, nByte); | 222728 | pC = (SessionChange*)sessionMalloc64(pSession, nByte); |
| 221190 | if( !pC ){ | 222729 | if( !pC ){ |
| 221191 | rc = SQLITE_NOMEM; | 222730 | rc = SQLITE_NOMEM; |
| 221192 | goto error_out; | 222731 | goto error_out; |
| @@ -221219,6 +222758,7 @@ static void sessionPreupdateOneChange( | |||
| 221219 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ | 222758 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ |
| 221220 | pC->bIndirect = 1; | 222759 | pC->bIndirect = 1; |
| 221221 | } | 222760 | } |
| 222761 | pC->nRecordField = pTab->nCol; | ||
| 221222 | pC->nRecord = nByte; | 222762 | pC->nRecord = nByte; |
| 221223 | pC->op = op; | 222763 | pC->op = op; |
| 221224 | pC->pNext = pTab->apChange[iHash]; | 222764 | pC->pNext = pTab->apChange[iHash]; |
| @@ -221598,7 +223138,7 @@ SQLITE_API int sqlite3session_diff( | |||
| 221598 | /* Locate and if necessary initialize the target table object */ | 223138 | /* Locate and if necessary initialize the target table object */ |
| 221599 | rc = sessionFindTable(pSession, zTbl, &pTo); | 223139 | rc = sessionFindTable(pSession, zTbl, &pTo); |
| 221600 | if( pTo==0 ) goto diff_out; | 223140 | if( pTo==0 ) goto diff_out; |
| 221601 | if( sessionInitTable(pSession, pTo) ){ | 223141 | if( sessionInitTable(pSession, pTo, pSession->db, pSession->zDb) ){ |
| 221602 | rc = pSession->rc; | 223142 | rc = pSession->rc; |
| 221603 | goto diff_out; | 223143 | goto diff_out; |
| 221604 | } | 223144 | } |
| @@ -221611,7 +223151,7 @@ SQLITE_API int sqlite3session_diff( | |||
| 221611 | int bRowid = 0; | 223151 | int bRowid = 0; |
| 221612 | u8 *abPK; | 223152 | u8 *abPK; |
| 221613 | const char **azCol = 0; | 223153 | const char **azCol = 0; |
| 221614 | rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK, | 223154 | rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK, |
| 221615 | pSession->bImplicitPK ? &bRowid : 0 | 223155 | pSession->bImplicitPK ? &bRowid : 0 |
| 221616 | ); | 223156 | ); |
| 221617 | if( rc==SQLITE_OK ){ | 223157 | if( rc==SQLITE_OK ){ |
| @@ -221726,6 +223266,7 @@ static void sessionDeleteTable(sqlite3_session *pSession, SessionTable *pList){ | |||
| 221726 | sessionFree(pSession, p); | 223266 | sessionFree(pSession, p); |
| 221727 | } | 223267 | } |
| 221728 | } | 223268 | } |
| 223269 | sqlite3_finalize(pTab->pDfltStmt); | ||
| 221729 | sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ | 223270 | sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ |
| 221730 | sessionFree(pSession, pTab->apChange); | 223271 | sessionFree(pSession, pTab->apChange); |
| 221731 | sessionFree(pSession, pTab); | 223272 | sessionFree(pSession, pTab); |
| @@ -221760,7 +223301,7 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession){ | |||
| 221760 | 223301 | ||
| 221761 | /* Assert that all allocations have been freed and then free the | 223302 | /* Assert that all allocations have been freed and then free the |
| 221762 | ** session object itself. */ | 223303 | ** session object itself. */ |
| 221763 | assert( pSession->nMalloc==0 ); | 223304 | // assert( pSession->nMalloc==0 ); |
| 221764 | sqlite3_free(pSession); | 223305 | sqlite3_free(pSession); |
| 221765 | } | 223306 | } |
| 221766 | 223307 | ||
| @@ -221832,48 +223373,6 @@ SQLITE_API int sqlite3session_attach( | |||
| 221832 | } | 223373 | } |
| 221833 | 223374 | ||
| 221834 | /* | 223375 | /* |
| 221835 | ** Ensure that there is room in the buffer to append nByte bytes of data. | ||
| 221836 | ** If not, use sqlite3_realloc() to grow the buffer so that there is. | ||
| 221837 | ** | ||
| 221838 | ** If successful, return zero. Otherwise, if an OOM condition is encountered, | ||
| 221839 | ** set *pRc to SQLITE_NOMEM and return non-zero. | ||
| 221840 | */ | ||
| 221841 | static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ | ||
| 221842 | #define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) | ||
| 221843 | i64 nReq = p->nBuf + nByte; | ||
| 221844 | if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ | ||
| 221845 | u8 *aNew; | ||
| 221846 | i64 nNew = p->nAlloc ? p->nAlloc : 128; | ||
| 221847 | |||
| 221848 | do { | ||
| 221849 | nNew = nNew*2; | ||
| 221850 | }while( nNew<nReq ); | ||
| 221851 | |||
| 221852 | /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation | ||
| 221853 | ** of sqlite3_realloc64(). Allocations greater than this size in bytes | ||
| 221854 | ** always fail. It is used here to ensure that this routine can always | ||
| 221855 | ** allocate up to this limit - instead of up to the largest power of | ||
| 221856 | ** two smaller than the limit. */ | ||
| 221857 | if( nNew>SESSION_MAX_BUFFER_SZ ){ | ||
| 221858 | nNew = SESSION_MAX_BUFFER_SZ; | ||
| 221859 | if( nNew<nReq ){ | ||
| 221860 | *pRc = SQLITE_NOMEM; | ||
| 221861 | return 1; | ||
| 221862 | } | ||
| 221863 | } | ||
| 221864 | |||
| 221865 | aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); | ||
| 221866 | if( 0==aNew ){ | ||
| 221867 | *pRc = SQLITE_NOMEM; | ||
| 221868 | }else{ | ||
| 221869 | p->aBuf = aNew; | ||
| 221870 | p->nAlloc = nNew; | ||
| 221871 | } | ||
| 221872 | } | ||
| 221873 | return (*pRc!=SQLITE_OK); | ||
| 221874 | } | ||
| 221875 | |||
| 221876 | /* | ||
| 221877 | ** Append the value passed as the second argument to the buffer passed | 223376 | ** Append the value passed as the second argument to the buffer passed |
| 221878 | ** as the first. | 223377 | ** as the first. |
| 221879 | ** | 223378 | ** |
| @@ -221943,27 +223442,6 @@ static void sessionAppendBlob( | |||
| 221943 | 223442 | ||
| 221944 | /* | 223443 | /* |
| 221945 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is | 223444 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 221946 | ** called. Otherwise, append a string to the buffer. All bytes in the string | ||
| 221947 | ** up to (but not including) the nul-terminator are written to the buffer. | ||
| 221948 | ** | ||
| 221949 | ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before | ||
| 221950 | ** returning. | ||
| 221951 | */ | ||
| 221952 | static void sessionAppendStr( | ||
| 221953 | SessionBuffer *p, | ||
| 221954 | const char *zStr, | ||
| 221955 | int *pRc | ||
| 221956 | ){ | ||
| 221957 | int nStr = sqlite3Strlen30(zStr); | ||
| 221958 | if( 0==sessionBufferGrow(p, nStr+1, pRc) ){ | ||
| 221959 | memcpy(&p->aBuf[p->nBuf], zStr, nStr); | ||
| 221960 | p->nBuf += nStr; | ||
| 221961 | p->aBuf[p->nBuf] = 0x00; | ||
| 221962 | } | ||
| 221963 | } | ||
| 221964 | |||
| 221965 | /* | ||
| 221966 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is | ||
| 221967 | ** called. Otherwise, append the string representation of integer iVal | 223445 | ** called. Otherwise, append the string representation of integer iVal |
| 221968 | ** to the buffer. No nul-terminator is written. | 223446 | ** to the buffer. No nul-terminator is written. |
| 221969 | ** | 223447 | ** |
| @@ -221980,27 +223458,6 @@ static void sessionAppendInteger( | |||
| 221980 | sessionAppendStr(p, aBuf, pRc); | 223458 | sessionAppendStr(p, aBuf, pRc); |
| 221981 | } | 223459 | } |
| 221982 | 223460 | ||
| 221983 | static void sessionAppendPrintf( | ||
| 221984 | SessionBuffer *p, /* Buffer to append to */ | ||
| 221985 | int *pRc, | ||
| 221986 | const char *zFmt, | ||
| 221987 | ... | ||
| 221988 | ){ | ||
| 221989 | if( *pRc==SQLITE_OK ){ | ||
| 221990 | char *zApp = 0; | ||
| 221991 | va_list ap; | ||
| 221992 | va_start(ap, zFmt); | ||
| 221993 | zApp = sqlite3_vmprintf(zFmt, ap); | ||
| 221994 | if( zApp==0 ){ | ||
| 221995 | *pRc = SQLITE_NOMEM; | ||
| 221996 | }else{ | ||
| 221997 | sessionAppendStr(p, zApp, pRc); | ||
| 221998 | } | ||
| 221999 | va_end(ap); | ||
| 222000 | sqlite3_free(zApp); | ||
| 222001 | } | ||
| 222002 | } | ||
| 222003 | |||
| 222004 | /* | 223461 | /* |
| 222005 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is | 223462 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 222006 | ** called. Otherwise, append the string zStr enclosed in quotes (") and | 223463 | ** called. Otherwise, append the string zStr enclosed in quotes (") and |
| @@ -222491,26 +223948,16 @@ static int sessionGenerateChangeset( | |||
| 222491 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ | 223948 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ |
| 222492 | if( pTab->nEntry ){ | 223949 | if( pTab->nEntry ){ |
| 222493 | const char *zName = pTab->zName; | 223950 | const char *zName = pTab->zName; |
| 222494 | int nCol = 0; /* Number of columns in table */ | ||
| 222495 | u8 *abPK = 0; /* Primary key array */ | ||
| 222496 | const char **azCol = 0; /* Table columns */ | ||
| 222497 | int i; /* Used to iterate through hash buckets */ | 223951 | int i; /* Used to iterate through hash buckets */ |
| 222498 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ | 223952 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ |
| 222499 | int nRewind = buf.nBuf; /* Initial size of write buffer */ | 223953 | int nRewind = buf.nBuf; /* Initial size of write buffer */ |
| 222500 | int nNoop; /* Size of buffer after writing tbl header */ | 223954 | int nNoop; /* Size of buffer after writing tbl header */ |
| 222501 | int bRowid = 0; | 223955 | int nOldCol = pTab->nCol; |
| 222502 | 223956 | ||
| 222503 | /* Check the table schema is still Ok. */ | 223957 | /* Check the table schema is still Ok. */ |
| 222504 | rc = sessionTableInfo( | 223958 | rc = sessionReinitTable(pSession, pTab); |
| 222505 | 0, db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK, | 223959 | if( rc==SQLITE_OK && pTab->nCol!=nOldCol ){ |
| 222506 | (pSession->bImplicitPK ? &bRowid : 0) | 223960 | rc = sessionUpdateChanges(pSession, pTab); |
| 222507 | ); | ||
| 222508 | if( rc==SQLITE_OK && ( | ||
| 222509 | pTab->nCol!=nCol | ||
| 222510 | || pTab->bRowid!=bRowid | ||
| 222511 | || memcmp(abPK, pTab->abPK, nCol) | ||
| 222512 | )){ | ||
| 222513 | rc = SQLITE_SCHEMA; | ||
| 222514 | } | 223961 | } |
| 222515 | 223962 | ||
| 222516 | /* Write a table header */ | 223963 | /* Write a table header */ |
| @@ -222518,8 +223965,8 @@ static int sessionGenerateChangeset( | |||
| 222518 | 223965 | ||
| 222519 | /* Build and compile a statement to execute: */ | 223966 | /* Build and compile a statement to execute: */ |
| 222520 | if( rc==SQLITE_OK ){ | 223967 | if( rc==SQLITE_OK ){ |
| 222521 | rc = sessionSelectStmt( | 223968 | rc = sessionSelectStmt(db, 0, pSession->zDb, |
| 222522 | db, 0, pSession->zDb, zName, bRowid, nCol, azCol, abPK, &pSel | 223969 | zName, pTab->bRowid, pTab->nCol, pTab->azCol, pTab->abPK, &pSel |
| 222523 | ); | 223970 | ); |
| 222524 | } | 223971 | } |
| 222525 | 223972 | ||
| @@ -222528,22 +223975,22 @@ static int sessionGenerateChangeset( | |||
| 222528 | SessionChange *p; /* Used to iterate through changes */ | 223975 | SessionChange *p; /* Used to iterate through changes */ |
| 222529 | 223976 | ||
| 222530 | for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ | 223977 | for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ |
| 222531 | rc = sessionSelectBind(pSel, nCol, abPK, p); | 223978 | rc = sessionSelectBind(pSel, pTab->nCol, pTab->abPK, p); |
| 222532 | if( rc!=SQLITE_OK ) continue; | 223979 | if( rc!=SQLITE_OK ) continue; |
| 222533 | if( sqlite3_step(pSel)==SQLITE_ROW ){ | 223980 | if( sqlite3_step(pSel)==SQLITE_ROW ){ |
| 222534 | if( p->op==SQLITE_INSERT ){ | 223981 | if( p->op==SQLITE_INSERT ){ |
| 222535 | int iCol; | 223982 | int iCol; |
| 222536 | sessionAppendByte(&buf, SQLITE_INSERT, &rc); | 223983 | sessionAppendByte(&buf, SQLITE_INSERT, &rc); |
| 222537 | sessionAppendByte(&buf, p->bIndirect, &rc); | 223984 | sessionAppendByte(&buf, p->bIndirect, &rc); |
| 222538 | for(iCol=0; iCol<nCol; iCol++){ | 223985 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 222539 | sessionAppendCol(&buf, pSel, iCol, &rc); | 223986 | sessionAppendCol(&buf, pSel, iCol, &rc); |
| 222540 | } | 223987 | } |
| 222541 | }else{ | 223988 | }else{ |
| 222542 | assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */ | 223989 | assert( pTab->abPK!=0 ); |
| 222543 | rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); | 223990 | rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, pTab->abPK); |
| 222544 | } | 223991 | } |
| 222545 | }else if( p->op!=SQLITE_INSERT ){ | 223992 | }else if( p->op!=SQLITE_INSERT ){ |
| 222546 | rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK); | 223993 | rc = sessionAppendDelete(&buf, bPatchset, p, pTab->nCol,pTab->abPK); |
| 222547 | } | 223994 | } |
| 222548 | if( rc==SQLITE_OK ){ | 223995 | if( rc==SQLITE_OK ){ |
| 222549 | rc = sqlite3_reset(pSel); | 223996 | rc = sqlite3_reset(pSel); |
| @@ -222568,7 +224015,6 @@ static int sessionGenerateChangeset( | |||
| 222568 | if( buf.nBuf==nNoop ){ | 224015 | if( buf.nBuf==nNoop ){ |
| 222569 | buf.nBuf = nRewind; | 224016 | buf.nBuf = nRewind; |
| 222570 | } | 224017 | } |
| 222571 | sqlite3_free((char*)azCol); /* cast works around VC++ bug */ | ||
| 222572 | } | 224018 | } |
| 222573 | } | 224019 | } |
| 222574 | 224020 | ||
| @@ -224697,7 +226143,7 @@ static int sessionChangesetApply( | |||
| 224697 | 226143 | ||
| 224698 | sqlite3changeset_pk(pIter, &abPK, 0); | 226144 | sqlite3changeset_pk(pIter, &abPK, 0); |
| 224699 | rc = sessionTableInfo(0, db, "main", zNew, | 226145 | rc = sessionTableInfo(0, db, "main", zNew, |
| 224700 | &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK, &sApply.bRowid | 226146 | &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid |
| 224701 | ); | 226147 | ); |
| 224702 | if( rc!=SQLITE_OK ) break; | 226148 | if( rc!=SQLITE_OK ) break; |
| 224703 | for(i=0; i<sApply.nCol; i++){ | 226149 | for(i=0; i<sApply.nCol; i++){ |
| @@ -224829,11 +226275,24 @@ SQLITE_API int sqlite3changeset_apply_v2( | |||
| 224829 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ | 226275 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ |
| 224830 | int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); | 226276 | int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); |
| 224831 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); | 226277 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); |
| 226278 | u64 savedFlag = db->flags & SQLITE_FkNoAction; | ||
| 226279 | |||
| 226280 | if( flags & SQLITE_CHANGESETAPPLY_FKNOACTION ){ | ||
| 226281 | db->flags |= ((u64)SQLITE_FkNoAction); | ||
| 226282 | db->aDb[0].pSchema->schema_cookie -= 32; | ||
| 226283 | } | ||
| 226284 | |||
| 224832 | if( rc==SQLITE_OK ){ | 226285 | if( rc==SQLITE_OK ){ |
| 224833 | rc = sessionChangesetApply( | 226286 | rc = sessionChangesetApply( |
| 224834 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags | 226287 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags |
| 224835 | ); | 226288 | ); |
| 224836 | } | 226289 | } |
| 226290 | |||
| 226291 | if( (flags & SQLITE_CHANGESETAPPLY_FKNOACTION) && savedFlag==0 ){ | ||
| 226292 | assert( db->flags & SQLITE_FkNoAction ); | ||
| 226293 | db->flags &= ~((u64)SQLITE_FkNoAction); | ||
| 226294 | db->aDb[0].pSchema->schema_cookie -= 32; | ||
| 226295 | } | ||
| 224837 | return rc; | 226296 | return rc; |
| 224838 | } | 226297 | } |
| 224839 | 226298 | ||
| @@ -224921,6 +226380,9 @@ struct sqlite3_changegroup { | |||
| 224921 | int rc; /* Error code */ | 226380 | int rc; /* Error code */ |
| 224922 | int bPatch; /* True to accumulate patchsets */ | 226381 | int bPatch; /* True to accumulate patchsets */ |
| 224923 | SessionTable *pList; /* List of tables in current patch */ | 226382 | SessionTable *pList; /* List of tables in current patch */ |
| 226383 | |||
| 226384 | sqlite3 *db; /* Configured by changegroup_schema() */ | ||
| 226385 | char *zDb; /* Configured by changegroup_schema() */ | ||
| 224924 | }; | 226386 | }; |
| 224925 | 226387 | ||
| 224926 | /* | 226388 | /* |
| @@ -224941,6 +226403,7 @@ static int sessionChangeMerge( | |||
| 224941 | ){ | 226403 | ){ |
| 224942 | SessionChange *pNew = 0; | 226404 | SessionChange *pNew = 0; |
| 224943 | int rc = SQLITE_OK; | 226405 | int rc = SQLITE_OK; |
| 226406 | assert( aRec!=0 ); | ||
| 224944 | 226407 | ||
| 224945 | if( !pExist ){ | 226408 | if( !pExist ){ |
| 224946 | pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec); | 226409 | pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec); |
| @@ -225107,6 +226570,114 @@ static int sessionChangeMerge( | |||
| 225107 | } | 226570 | } |
| 225108 | 226571 | ||
| 225109 | /* | 226572 | /* |
| 226573 | ** Check if a changeset entry with nCol columns and the PK array passed | ||
| 226574 | ** as the final argument to this function is compatible with SessionTable | ||
| 226575 | ** pTab. If so, return 1. Otherwise, if they are incompatible in some way, | ||
| 226576 | ** return 0. | ||
| 226577 | */ | ||
| 226578 | static int sessionChangesetCheckCompat( | ||
| 226579 | SessionTable *pTab, | ||
| 226580 | int nCol, | ||
| 226581 | u8 *abPK | ||
| 226582 | ){ | ||
| 226583 | if( pTab->azCol && nCol<pTab->nCol ){ | ||
| 226584 | int ii; | ||
| 226585 | for(ii=0; ii<pTab->nCol; ii++){ | ||
| 226586 | u8 bPK = (ii < nCol) ? abPK[ii] : 0; | ||
| 226587 | if( pTab->abPK[ii]!=bPK ) return 0; | ||
| 226588 | } | ||
| 226589 | return 1; | ||
| 226590 | } | ||
| 226591 | return (pTab->nCol==nCol && 0==memcmp(abPK, pTab->abPK, nCol)); | ||
| 226592 | } | ||
| 226593 | |||
| 226594 | static int sessionChangesetExtendRecord( | ||
| 226595 | sqlite3_changegroup *pGrp, | ||
| 226596 | SessionTable *pTab, | ||
| 226597 | int nCol, | ||
| 226598 | int op, | ||
| 226599 | const u8 *aRec, | ||
| 226600 | int nRec, | ||
| 226601 | SessionBuffer *pOut | ||
| 226602 | ){ | ||
| 226603 | int rc = SQLITE_OK; | ||
| 226604 | int ii = 0; | ||
| 226605 | |||
| 226606 | assert( pTab->azCol ); | ||
| 226607 | assert( nCol<pTab->nCol ); | ||
| 226608 | |||
| 226609 | pOut->nBuf = 0; | ||
| 226610 | if( op==SQLITE_INSERT || (op==SQLITE_DELETE && pGrp->bPatch==0) ){ | ||
| 226611 | /* Append the missing default column values to the record. */ | ||
| 226612 | sessionAppendBlob(pOut, aRec, nRec, &rc); | ||
| 226613 | if( rc==SQLITE_OK && pTab->pDfltStmt==0 ){ | ||
| 226614 | rc = sessionPrepareDfltStmt(pGrp->db, pTab, &pTab->pDfltStmt); | ||
| 226615 | } | ||
| 226616 | for(ii=nCol; rc==SQLITE_OK && ii<pTab->nCol; ii++){ | ||
| 226617 | int eType = sqlite3_column_type(pTab->pDfltStmt, ii); | ||
| 226618 | sessionAppendByte(pOut, eType, &rc); | ||
| 226619 | switch( eType ){ | ||
| 226620 | case SQLITE_FLOAT: | ||
| 226621 | case SQLITE_INTEGER: { | ||
| 226622 | i64 iVal; | ||
| 226623 | if( eType==SQLITE_INTEGER ){ | ||
| 226624 | iVal = sqlite3_column_int64(pTab->pDfltStmt, ii); | ||
| 226625 | }else{ | ||
| 226626 | double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii); | ||
| 226627 | memcpy(&iVal, &rVal, sizeof(i64)); | ||
| 226628 | } | ||
| 226629 | if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){ | ||
| 226630 | sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal); | ||
| 226631 | } | ||
| 226632 | break; | ||
| 226633 | } | ||
| 226634 | |||
| 226635 | case SQLITE_BLOB: | ||
| 226636 | case SQLITE_TEXT: { | ||
| 226637 | int n = sqlite3_column_bytes(pTab->pDfltStmt, ii); | ||
| 226638 | sessionAppendVarint(pOut, n, &rc); | ||
| 226639 | if( eType==SQLITE_TEXT ){ | ||
| 226640 | const u8 *z = (const u8*)sqlite3_column_text(pTab->pDfltStmt, ii); | ||
| 226641 | sessionAppendBlob(pOut, z, n, &rc); | ||
| 226642 | }else{ | ||
| 226643 | const u8 *z = (const u8*)sqlite3_column_blob(pTab->pDfltStmt, ii); | ||
| 226644 | sessionAppendBlob(pOut, z, n, &rc); | ||
| 226645 | } | ||
| 226646 | break; | ||
| 226647 | } | ||
| 226648 | |||
| 226649 | default: | ||
| 226650 | assert( eType==SQLITE_NULL ); | ||
| 226651 | break; | ||
| 226652 | } | ||
| 226653 | } | ||
| 226654 | }else if( op==SQLITE_UPDATE ){ | ||
| 226655 | /* Append missing "undefined" entries to the old.* record. And, if this | ||
| 226656 | ** is an UPDATE, to the new.* record as well. */ | ||
| 226657 | int iOff = 0; | ||
| 226658 | if( pGrp->bPatch==0 ){ | ||
| 226659 | for(ii=0; ii<nCol; ii++){ | ||
| 226660 | iOff += sessionSerialLen(&aRec[iOff]); | ||
| 226661 | } | ||
| 226662 | sessionAppendBlob(pOut, aRec, iOff, &rc); | ||
| 226663 | for(ii=0; ii<(pTab->nCol-nCol); ii++){ | ||
| 226664 | sessionAppendByte(pOut, 0x00, &rc); | ||
| 226665 | } | ||
| 226666 | } | ||
| 226667 | |||
| 226668 | sessionAppendBlob(pOut, &aRec[iOff], nRec-iOff, &rc); | ||
| 226669 | for(ii=0; ii<(pTab->nCol-nCol); ii++){ | ||
| 226670 | sessionAppendByte(pOut, 0x00, &rc); | ||
| 226671 | } | ||
| 226672 | }else{ | ||
| 226673 | assert( op==SQLITE_DELETE && pGrp->bPatch ); | ||
| 226674 | sessionAppendBlob(pOut, aRec, nRec, &rc); | ||
| 226675 | } | ||
| 226676 | |||
| 226677 | return rc; | ||
| 226678 | } | ||
| 226679 | |||
| 226680 | /* | ||
| 225110 | ** Add all changes in the changeset traversed by the iterator passed as | 226681 | ** Add all changes in the changeset traversed by the iterator passed as |
| 225111 | ** the first argument to the changegroup hash tables. | 226682 | ** the first argument to the changegroup hash tables. |
| 225112 | */ | 226683 | */ |
| @@ -225119,6 +226690,7 @@ static int sessionChangesetToHash( | |||
| 225119 | int nRec; | 226690 | int nRec; |
| 225120 | int rc = SQLITE_OK; | 226691 | int rc = SQLITE_OK; |
| 225121 | SessionTable *pTab = 0; | 226692 | SessionTable *pTab = 0; |
| 226693 | SessionBuffer rec = {0, 0, 0}; | ||
| 225122 | 226694 | ||
| 225123 | while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ | 226695 | while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ |
| 225124 | const char *zNew; | 226696 | const char *zNew; |
| @@ -225130,6 +226702,9 @@ static int sessionChangesetToHash( | |||
| 225130 | SessionChange *pExist = 0; | 226702 | SessionChange *pExist = 0; |
| 225131 | SessionChange **pp; | 226703 | SessionChange **pp; |
| 225132 | 226704 | ||
| 226705 | /* Ensure that only changesets, or only patchsets, but not a mixture | ||
| 226706 | ** of both, are being combined. It is an error to try to combine a | ||
| 226707 | ** changeset and a patchset. */ | ||
| 225133 | if( pGrp->pList==0 ){ | 226708 | if( pGrp->pList==0 ){ |
| 225134 | pGrp->bPatch = pIter->bPatchset; | 226709 | pGrp->bPatch = pIter->bPatchset; |
| 225135 | }else if( pIter->bPatchset!=pGrp->bPatch ){ | 226710 | }else if( pIter->bPatchset!=pGrp->bPatch ){ |
| @@ -225162,18 +226737,38 @@ static int sessionChangesetToHash( | |||
| 225162 | pTab->zName = (char*)&pTab->abPK[nCol]; | 226737 | pTab->zName = (char*)&pTab->abPK[nCol]; |
| 225163 | memcpy(pTab->zName, zNew, nNew+1); | 226738 | memcpy(pTab->zName, zNew, nNew+1); |
| 225164 | 226739 | ||
| 226740 | if( pGrp->db ){ | ||
| 226741 | pTab->nCol = 0; | ||
| 226742 | rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); | ||
| 226743 | if( rc ){ | ||
| 226744 | assert( pTab->azCol==0 ); | ||
| 226745 | sqlite3_free(pTab); | ||
| 226746 | break; | ||
| 226747 | } | ||
| 226748 | } | ||
| 226749 | |||
| 225165 | /* The new object must be linked on to the end of the list, not | 226750 | /* The new object must be linked on to the end of the list, not |
| 225166 | ** simply added to the start of it. This is to ensure that the | 226751 | ** simply added to the start of it. This is to ensure that the |
| 225167 | ** tables within the output of sqlite3changegroup_output() are in | 226752 | ** tables within the output of sqlite3changegroup_output() are in |
| 225168 | ** the right order. */ | 226753 | ** the right order. */ |
| 225169 | for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); | 226754 | for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); |
| 225170 | *ppTab = pTab; | 226755 | *ppTab = pTab; |
| 225171 | }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){ | 226756 | } |
| 226757 | |||
| 226758 | if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ | ||
| 225172 | rc = SQLITE_SCHEMA; | 226759 | rc = SQLITE_SCHEMA; |
| 225173 | break; | 226760 | break; |
| 225174 | } | 226761 | } |
| 225175 | } | 226762 | } |
| 225176 | 226763 | ||
| 226764 | if( nCol<pTab->nCol ){ | ||
| 226765 | assert( pGrp->db ); | ||
| 226766 | rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec); | ||
| 226767 | if( rc ) break; | ||
| 226768 | aRec = rec.aBuf; | ||
| 226769 | nRec = rec.nBuf; | ||
| 226770 | } | ||
| 226771 | |||
| 225177 | if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ | 226772 | if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 225178 | rc = SQLITE_NOMEM; | 226773 | rc = SQLITE_NOMEM; |
| 225179 | break; | 226774 | break; |
| @@ -225211,6 +226806,7 @@ static int sessionChangesetToHash( | |||
| 225211 | } | 226806 | } |
| 225212 | } | 226807 | } |
| 225213 | 226808 | ||
| 226809 | sqlite3_free(rec.aBuf); | ||
| 225214 | if( rc==SQLITE_OK ) rc = pIter->rc; | 226810 | if( rc==SQLITE_OK ) rc = pIter->rc; |
| 225215 | return rc; | 226811 | return rc; |
| 225216 | } | 226812 | } |
| @@ -225298,6 +226894,31 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp){ | |||
| 225298 | } | 226894 | } |
| 225299 | 226895 | ||
| 225300 | /* | 226896 | /* |
| 226897 | ** Provide a database schema to the changegroup object. | ||
| 226898 | */ | ||
| 226899 | SQLITE_API int sqlite3changegroup_schema( | ||
| 226900 | sqlite3_changegroup *pGrp, | ||
| 226901 | sqlite3 *db, | ||
| 226902 | const char *zDb | ||
| 226903 | ){ | ||
| 226904 | int rc = SQLITE_OK; | ||
| 226905 | |||
| 226906 | if( pGrp->pList || pGrp->db ){ | ||
| 226907 | /* Cannot add a schema after one or more calls to sqlite3changegroup_add(), | ||
| 226908 | ** or after sqlite3changegroup_schema() has already been called. */ | ||
| 226909 | rc = SQLITE_MISUSE; | ||
| 226910 | }else{ | ||
| 226911 | pGrp->zDb = sqlite3_mprintf("%s", zDb); | ||
| 226912 | if( pGrp->zDb==0 ){ | ||
| 226913 | rc = SQLITE_NOMEM; | ||
| 226914 | }else{ | ||
| 226915 | pGrp->db = db; | ||
| 226916 | } | ||
| 226917 | } | ||
| 226918 | return rc; | ||
| 226919 | } | ||
| 226920 | |||
| 226921 | /* | ||
| 225301 | ** Add the changeset currently stored in buffer pData, size nData bytes, | 226922 | ** Add the changeset currently stored in buffer pData, size nData bytes, |
| 225302 | ** to changeset-group p. | 226923 | ** to changeset-group p. |
| 225303 | */ | 226924 | */ |
| @@ -225360,6 +226981,7 @@ SQLITE_API int sqlite3changegroup_output_strm( | |||
| 225360 | */ | 226981 | */ |
| 225361 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ | 226982 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ |
| 225362 | if( pGrp ){ | 226983 | if( pGrp ){ |
| 226984 | sqlite3_free(pGrp->zDb); | ||
| 225363 | sessionDeleteTable(0, pGrp->pList); | 226985 | sessionDeleteTable(0, pGrp->pList); |
| 225364 | sqlite3_free(pGrp); | 226986 | sqlite3_free(pGrp); |
| 225365 | } | 226987 | } |
| @@ -228865,15 +230487,19 @@ static int fts5CInstIterInit( | |||
| 228865 | */ | 230487 | */ |
| 228866 | typedef struct HighlightContext HighlightContext; | 230488 | typedef struct HighlightContext HighlightContext; |
| 228867 | struct HighlightContext { | 230489 | struct HighlightContext { |
| 228868 | CInstIter iter; /* Coalesced Instance Iterator */ | 230490 | /* Constant parameters to fts5HighlightCb() */ |
| 228869 | int iPos; /* Current token offset in zIn[] */ | ||
| 228870 | int iRangeStart; /* First token to include */ | 230491 | int iRangeStart; /* First token to include */ |
| 228871 | int iRangeEnd; /* If non-zero, last token to include */ | 230492 | int iRangeEnd; /* If non-zero, last token to include */ |
| 228872 | const char *zOpen; /* Opening highlight */ | 230493 | const char *zOpen; /* Opening highlight */ |
| 228873 | const char *zClose; /* Closing highlight */ | 230494 | const char *zClose; /* Closing highlight */ |
| 228874 | const char *zIn; /* Input text */ | 230495 | const char *zIn; /* Input text */ |
| 228875 | int nIn; /* Size of input text in bytes */ | 230496 | int nIn; /* Size of input text in bytes */ |
| 228876 | int iOff; /* Current offset within zIn[] */ | 230497 | |
| 230498 | /* Variables modified by fts5HighlightCb() */ | ||
| 230499 | CInstIter iter; /* Coalesced Instance Iterator */ | ||
| 230500 | int iPos; /* Current token offset in zIn[] */ | ||
| 230501 | int iOff; /* Have copied up to this offset in zIn[] */ | ||
| 230502 | int bOpen; /* True if highlight is open */ | ||
| 228877 | char *zOut; /* Output value */ | 230503 | char *zOut; /* Output value */ |
| 228878 | }; | 230504 | }; |
| 228879 | 230505 | ||
| @@ -228906,8 +230532,8 @@ static int fts5HighlightCb( | |||
| 228906 | int tflags, /* Mask of FTS5_TOKEN_* flags */ | 230532 | int tflags, /* Mask of FTS5_TOKEN_* flags */ |
| 228907 | const char *pToken, /* Buffer containing token */ | 230533 | const char *pToken, /* Buffer containing token */ |
| 228908 | int nToken, /* Size of token in bytes */ | 230534 | int nToken, /* Size of token in bytes */ |
| 228909 | int iStartOff, /* Start offset of token */ | 230535 | int iStartOff, /* Start byte offset of token */ |
| 228910 | int iEndOff /* End offset of token */ | 230536 | int iEndOff /* End byte offset of token */ |
| 228911 | ){ | 230537 | ){ |
| 228912 | HighlightContext *p = (HighlightContext*)pContext; | 230538 | HighlightContext *p = (HighlightContext*)pContext; |
| 228913 | int rc = SQLITE_OK; | 230539 | int rc = SQLITE_OK; |
| @@ -228923,30 +230549,47 @@ static int fts5HighlightCb( | |||
| 228923 | if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff; | 230549 | if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff; |
| 228924 | } | 230550 | } |
| 228925 | 230551 | ||
| 228926 | if( iPos==p->iter.iStart ){ | 230552 | /* If the parenthesis is open, and this token is not part of the current |
| 230553 | ** phrase, and the starting byte offset of this token is past the point | ||
| 230554 | ** that has currently been copied into the output buffer, close the | ||
| 230555 | ** parenthesis. */ | ||
| 230556 | if( p->bOpen | ||
| 230557 | && (iPos<=p->iter.iStart || p->iter.iStart<0) | ||
| 230558 | && iStartOff>p->iOff | ||
| 230559 | ){ | ||
| 230560 | fts5HighlightAppend(&rc, p, p->zClose, -1); | ||
| 230561 | p->bOpen = 0; | ||
| 230562 | } | ||
| 230563 | |||
| 230564 | /* If this is the start of a new phrase, and the highlight is not open: | ||
| 230565 | ** | ||
| 230566 | ** * copy text from the input up to the start of the phrase, and | ||
| 230567 | ** * open the highlight. | ||
| 230568 | */ | ||
| 230569 | if( iPos==p->iter.iStart && p->bOpen==0 ){ | ||
| 228927 | fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff); | 230570 | fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff); |
| 228928 | fts5HighlightAppend(&rc, p, p->zOpen, -1); | 230571 | fts5HighlightAppend(&rc, p, p->zOpen, -1); |
| 228929 | p->iOff = iStartOff; | 230572 | p->iOff = iStartOff; |
| 230573 | p->bOpen = 1; | ||
| 228930 | } | 230574 | } |
| 228931 | 230575 | ||
| 228932 | if( iPos==p->iter.iEnd ){ | 230576 | if( iPos==p->iter.iEnd ){ |
| 228933 | if( p->iRangeEnd>=0 && p->iter.iStart<p->iRangeStart ){ | 230577 | if( p->bOpen==0 ){ |
| 230578 | assert( p->iRangeEnd>=0 ); | ||
| 228934 | fts5HighlightAppend(&rc, p, p->zOpen, -1); | 230579 | fts5HighlightAppend(&rc, p, p->zOpen, -1); |
| 230580 | p->bOpen = 1; | ||
| 228935 | } | 230581 | } |
| 228936 | fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); | 230582 | fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); |
| 228937 | fts5HighlightAppend(&rc, p, p->zClose, -1); | ||
| 228938 | p->iOff = iEndOff; | 230583 | p->iOff = iEndOff; |
| 230584 | |||
| 228939 | if( rc==SQLITE_OK ){ | 230585 | if( rc==SQLITE_OK ){ |
| 228940 | rc = fts5CInstIterNext(&p->iter); | 230586 | rc = fts5CInstIterNext(&p->iter); |
| 228941 | } | 230587 | } |
| 228942 | } | 230588 | } |
| 228943 | 230589 | ||
| 228944 | if( p->iRangeEnd>=0 && iPos==p->iRangeEnd ){ | 230590 | if( iPos==p->iRangeEnd ){ |
| 228945 | fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); | 230591 | fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); |
| 228946 | p->iOff = iEndOff; | 230592 | p->iOff = iEndOff; |
| 228947 | if( iPos>=p->iter.iStart && iPos<p->iter.iEnd ){ | ||
| 228948 | fts5HighlightAppend(&rc, p, p->zClose, -1); | ||
| 228949 | } | ||
| 228950 | } | 230593 | } |
| 228951 | 230594 | ||
| 228952 | return rc; | 230595 | return rc; |
| @@ -228987,6 +230630,9 @@ static void fts5HighlightFunction( | |||
| 228987 | if( rc==SQLITE_OK ){ | 230630 | if( rc==SQLITE_OK ){ |
| 228988 | rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); | 230631 | rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); |
| 228989 | } | 230632 | } |
| 230633 | if( ctx.bOpen ){ | ||
| 230634 | fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1); | ||
| 230635 | } | ||
| 228990 | fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); | 230636 | fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); |
| 228991 | 230637 | ||
| 228992 | if( rc==SQLITE_OK ){ | 230638 | if( rc==SQLITE_OK ){ |
| @@ -229265,6 +230911,9 @@ static void fts5SnippetFunction( | |||
| 229265 | if( rc==SQLITE_OK ){ | 230911 | if( rc==SQLITE_OK ){ |
| 229266 | rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); | 230912 | rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); |
| 229267 | } | 230913 | } |
| 230914 | if( ctx.bOpen ){ | ||
| 230915 | fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1); | ||
| 230916 | } | ||
| 229268 | if( ctx.iRangeEnd>=(nColSize-1) ){ | 230917 | if( ctx.iRangeEnd>=(nColSize-1) ){ |
| 229269 | fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); | 230918 | fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); |
| 229270 | }else{ | 230919 | }else{ |
| @@ -237536,7 +239185,6 @@ static int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){ | |||
| 237536 | assert_nc( i2!=0 ); | 239185 | assert_nc( i2!=0 ); |
| 237537 | pRes->bTermEq = 1; | 239186 | pRes->bTermEq = 1; |
| 237538 | if( p1->iRowid==p2->iRowid ){ | 239187 | if( p1->iRowid==p2->iRowid ){ |
| 237539 | p1->bDel = p2->bDel; | ||
| 237540 | return i2; | 239188 | return i2; |
| 237541 | } | 239189 | } |
| 237542 | res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; | 239190 | res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; |
| @@ -237904,7 +239552,7 @@ static Fts5Iter *fts5MultiIterAlloc( | |||
| 237904 | int nSeg | 239552 | int nSeg |
| 237905 | ){ | 239553 | ){ |
| 237906 | Fts5Iter *pNew; | 239554 | Fts5Iter *pNew; |
| 237907 | int nSlot; /* Power of two >= nSeg */ | 239555 | i64 nSlot; /* Power of two >= nSeg */ |
| 237908 | 239556 | ||
| 237909 | for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2); | 239557 | for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2); |
| 237910 | pNew = fts5IdxMalloc(p, | 239558 | pNew = fts5IdxMalloc(p, |
| @@ -239680,7 +241328,6 @@ static void fts5DoSecureDelete( | |||
| 239680 | int iPgIdx = pSeg->pLeaf->szLeaf; | 241328 | int iPgIdx = pSeg->pLeaf->szLeaf; |
| 239681 | 241329 | ||
| 239682 | u64 iDelta = 0; | 241330 | u64 iDelta = 0; |
| 239683 | u64 iNextDelta = 0; | ||
| 239684 | int iNextOff = 0; | 241331 | int iNextOff = 0; |
| 239685 | int iOff = 0; | 241332 | int iOff = 0; |
| 239686 | int nIdx = 0; | 241333 | int nIdx = 0; |
| @@ -239688,8 +241335,6 @@ static void fts5DoSecureDelete( | |||
| 239688 | int bLastInDoclist = 0; | 241335 | int bLastInDoclist = 0; |
| 239689 | int iIdx = 0; | 241336 | int iIdx = 0; |
| 239690 | int iStart = 0; | 241337 | int iStart = 0; |
| 239691 | int iKeyOff = 0; | ||
| 239692 | int iPrevKeyOff = 0; | ||
| 239693 | int iDelKeyOff = 0; /* Offset of deleted key, if any */ | 241338 | int iDelKeyOff = 0; /* Offset of deleted key, if any */ |
| 239694 | 241339 | ||
| 239695 | nIdx = nPg-iPgIdx; | 241340 | nIdx = nPg-iPgIdx; |
| @@ -239714,10 +241359,21 @@ static void fts5DoSecureDelete( | |||
| 239714 | ** This block sets the following variables: | 241359 | ** This block sets the following variables: |
| 239715 | ** | 241360 | ** |
| 239716 | ** iStart: | 241361 | ** iStart: |
| 241362 | ** The offset of the first byte of the rowid or delta-rowid | ||
| 241363 | ** value for the doclist entry being removed. | ||
| 241364 | ** | ||
| 239717 | ** iDelta: | 241365 | ** iDelta: |
| 241366 | ** The value of the rowid or delta-rowid value for the doclist | ||
| 241367 | ** entry being removed. | ||
| 241368 | ** | ||
| 241369 | ** iNextOff: | ||
| 241370 | ** The offset of the next entry following the position list | ||
| 241371 | ** for the one being removed. If the position list for this | ||
| 241372 | ** entry overflows onto the next leaf page, this value will be | ||
| 241373 | ** greater than pLeaf->szLeaf. | ||
| 239718 | */ | 241374 | */ |
| 239719 | { | 241375 | { |
| 239720 | int iSOP; | 241376 | int iSOP; /* Start-Of-Position-list */ |
| 239721 | if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ | 241377 | if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ |
| 239722 | iStart = pSeg->iTermLeafOffset; | 241378 | iStart = pSeg->iTermLeafOffset; |
| 239723 | }else{ | 241379 | }else{ |
| @@ -239753,47 +241409,75 @@ static void fts5DoSecureDelete( | |||
| 239753 | } | 241409 | } |
| 239754 | 241410 | ||
| 239755 | iOff = iStart; | 241411 | iOff = iStart; |
| 239756 | if( iNextOff>=iPgIdx ){ | 241412 | |
| 239757 | int pgno = pSeg->iLeafPgno+1; | 241413 | /* Set variable bLastInDoclist to true if this entry happens to be |
| 239758 | fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); | 241414 | ** the last rowid in the doclist for its term. */ |
| 239759 | iNextOff = iPgIdx; | 241415 | if( pSeg->bDel==0 ){ |
| 239760 | }else{ | 241416 | if( iNextOff>=iPgIdx ){ |
| 239761 | /* Set bLastInDoclist to true if the entry being removed is the last | 241417 | int pgno = pSeg->iLeafPgno+1; |
| 239762 | ** in its doclist. */ | 241418 | fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); |
| 239763 | for(iIdx=0, iKeyOff=0; iIdx<nIdx; /* no-op */){ | 241419 | iNextOff = iPgIdx; |
| 239764 | u32 iVal = 0; | 241420 | }else{ |
| 239765 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | 241421 | /* Loop through the page-footer. If iNextOff (offset of the |
| 239766 | iKeyOff += iVal; | 241422 | ** entry following the one we are removing) is equal to the |
| 239767 | if( iKeyOff==iNextOff ){ | 241423 | ** offset of a key on this page, then the entry is the last |
| 239768 | bLastInDoclist = 1; | 241424 | ** in its doclist. */ |
| 241425 | int iKeyOff = 0; | ||
| 241426 | for(iIdx=0; iIdx<nIdx; /* no-op */){ | ||
| 241427 | u32 iVal = 0; | ||
| 241428 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | ||
| 241429 | iKeyOff += iVal; | ||
| 241430 | if( iKeyOff==iNextOff ){ | ||
| 241431 | bLastInDoclist = 1; | ||
| 241432 | } | ||
| 239769 | } | 241433 | } |
| 239770 | } | 241434 | } |
| 239771 | } | ||
| 239772 | 241435 | ||
| 239773 | if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist||iNextOff==iPgIdx) ){ | 241436 | /* If this is (a) the first rowid on a page and (b) is not followed by |
| 239774 | fts5PutU16(&aPg[0], 0); | 241437 | ** another position list on the same page, set the "first-rowid" field |
| 241438 | ** of the header to 0. */ | ||
| 241439 | if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist || iNextOff==iPgIdx) ){ | ||
| 241440 | fts5PutU16(&aPg[0], 0); | ||
| 241441 | } | ||
| 239775 | } | 241442 | } |
| 239776 | 241443 | ||
| 239777 | if( bLastInDoclist==0 ){ | 241444 | if( pSeg->bDel ){ |
| 241445 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta); | ||
| 241446 | aPg[iOff++] = 0x01; | ||
| 241447 | }else if( bLastInDoclist==0 ){ | ||
| 239778 | if( iNextOff!=iPgIdx ){ | 241448 | if( iNextOff!=iPgIdx ){ |
| 241449 | u64 iNextDelta = 0; | ||
| 239779 | iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); | 241450 | iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); |
| 239780 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); | 241451 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); |
| 239781 | } | 241452 | } |
| 239782 | }else if( | 241453 | }else if( |
| 239783 | iStart==pSeg->iTermLeafOffset && pSeg->iLeafPgno==pSeg->iTermLeafPgno | 241454 | pSeg->iLeafPgno==pSeg->iTermLeafPgno |
| 241455 | && iStart==pSeg->iTermLeafOffset | ||
| 239784 | ){ | 241456 | ){ |
| 239785 | /* The entry being removed was the only position list in its | 241457 | /* The entry being removed was the only position list in its |
| 239786 | ** doclist. Therefore the term needs to be removed as well. */ | 241458 | ** doclist. Therefore the term needs to be removed as well. */ |
| 239787 | int iKey = 0; | 241459 | int iKey = 0; |
| 239788 | for(iIdx=0, iKeyOff=0; iIdx<nIdx; iKey++){ | 241460 | int iKeyOff = 0; |
| 241461 | |||
| 241462 | /* Set iKeyOff to the offset of the term that will be removed - the | ||
| 241463 | ** last offset in the footer that is not greater than iStart. */ | ||
| 241464 | for(iIdx=0; iIdx<nIdx; iKey++){ | ||
| 239789 | u32 iVal = 0; | 241465 | u32 iVal = 0; |
| 239790 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | 241466 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 239791 | if( (iKeyOff+iVal)>(u32)iStart ) break; | 241467 | if( (iKeyOff+iVal)>(u32)iStart ) break; |
| 239792 | iKeyOff += iVal; | 241468 | iKeyOff += iVal; |
| 239793 | } | 241469 | } |
| 241470 | assert_nc( iKey>=1 ); | ||
| 239794 | 241471 | ||
| 241472 | /* Set iDelKeyOff to the value of the footer entry to remove from | ||
| 241473 | ** the page. */ | ||
| 239795 | iDelKeyOff = iOff = iKeyOff; | 241474 | iDelKeyOff = iOff = iKeyOff; |
| 241475 | |||
| 239796 | if( iNextOff!=iPgIdx ){ | 241476 | if( iNextOff!=iPgIdx ){ |
| 241477 | /* This is the only position-list associated with the term, and there | ||
| 241478 | ** is another term following it on this page. So the subsequent term | ||
| 241479 | ** needs to be moved to replace the term associated with the entry | ||
| 241480 | ** being removed. */ | ||
| 239797 | int nPrefix = 0; | 241481 | int nPrefix = 0; |
| 239798 | int nSuffix = 0; | 241482 | int nSuffix = 0; |
| 239799 | int nPrefix2 = 0; | 241483 | int nPrefix2 = 0; |
| @@ -239872,6 +241556,15 @@ static void fts5DoSecureDelete( | |||
| 239872 | } | 241556 | } |
| 239873 | } | 241557 | } |
| 239874 | 241558 | ||
| 241559 | /* Assuming no error has occurred, this block does final edits to the | ||
| 241560 | ** leaf page before writing it back to disk. Input variables are: | ||
| 241561 | ** | ||
| 241562 | ** nPg: Total initial size of leaf page. | ||
| 241563 | ** iPgIdx: Initial offset of page footer. | ||
| 241564 | ** | ||
| 241565 | ** iOff: Offset to move data to | ||
| 241566 | ** iNextOff: Offset to move data from | ||
| 241567 | */ | ||
| 239875 | if( p->rc==SQLITE_OK ){ | 241568 | if( p->rc==SQLITE_OK ){ |
| 239876 | const int nMove = nPg - iNextOff; /* Number of bytes to move */ | 241569 | const int nMove = nPg - iNextOff; /* Number of bytes to move */ |
| 239877 | int nShift = iNextOff - iOff; /* Distance to move them */ | 241570 | int nShift = iNextOff - iOff; /* Distance to move them */ |
| @@ -240072,10 +241765,16 @@ static void fts5FlushOneHash(Fts5Index *p){ | |||
| 240072 | fts5WriteFlushLeaf(p, &writer); | 241765 | fts5WriteFlushLeaf(p, &writer); |
| 240073 | } | 241766 | } |
| 240074 | }else{ | 241767 | }else{ |
| 240075 | int bDummy; | 241768 | int bDel = 0; |
| 240076 | int nPos; | 241769 | int nPos = 0; |
| 240077 | int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); | 241770 | int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDel); |
| 240078 | nCopy += nPos; | 241771 | if( bDel && bSecureDelete ){ |
| 241772 | fts5BufferAppendVarint(&p->rc, pBuf, nPos*2); | ||
| 241773 | iOff += nCopy; | ||
| 241774 | nCopy = nPos; | ||
| 241775 | }else{ | ||
| 241776 | nCopy += nPos; | ||
| 241777 | } | ||
| 240079 | if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ | 241778 | if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ |
| 240080 | /* The entire poslist will fit on the current leaf. So copy | 241779 | /* The entire poslist will fit on the current leaf. So copy |
| 240081 | ** it in one go. */ | 241780 | ** it in one go. */ |
| @@ -240113,7 +241812,6 @@ static void fts5FlushOneHash(Fts5Index *p){ | |||
| 240113 | assert( pBuf->n<=pBuf->nSpace ); | 241812 | assert( pBuf->n<=pBuf->nSpace ); |
| 240114 | if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); | 241813 | if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); |
| 240115 | } | 241814 | } |
| 240116 | sqlite3Fts5HashClear(pHash); | ||
| 240117 | fts5WriteFinish(p, &writer, &pgnoLast); | 241815 | fts5WriteFinish(p, &writer, &pgnoLast); |
| 240118 | 241816 | ||
| 240119 | assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); | 241817 | assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); |
| @@ -240146,7 +241844,6 @@ static void fts5FlushOneHash(Fts5Index *p){ | |||
| 240146 | fts5IndexCrisismerge(p, &pStruct); | 241844 | fts5IndexCrisismerge(p, &pStruct); |
| 240147 | fts5StructureWrite(p, pStruct); | 241845 | fts5StructureWrite(p, pStruct); |
| 240148 | fts5StructureRelease(pStruct); | 241846 | fts5StructureRelease(pStruct); |
| 240149 | p->nContentlessDelete = 0; | ||
| 240150 | } | 241847 | } |
| 240151 | 241848 | ||
| 240152 | /* | 241849 | /* |
| @@ -240157,8 +241854,12 @@ static void fts5IndexFlush(Fts5Index *p){ | |||
| 240157 | if( p->nPendingData || p->nContentlessDelete ){ | 241854 | if( p->nPendingData || p->nContentlessDelete ){ |
| 240158 | assert( p->pHash ); | 241855 | assert( p->pHash ); |
| 240159 | fts5FlushOneHash(p); | 241856 | fts5FlushOneHash(p); |
| 240160 | p->nPendingData = 0; | 241857 | if( p->rc==SQLITE_OK ){ |
| 240161 | p->nPendingRow = 0; | 241858 | sqlite3Fts5HashClear(p->pHash); |
| 241859 | p->nPendingData = 0; | ||
| 241860 | p->nPendingRow = 0; | ||
| 241861 | p->nContentlessDelete = 0; | ||
| 241862 | } | ||
| 240162 | } | 241863 | } |
| 240163 | } | 241864 | } |
| 240164 | 241865 | ||
| @@ -242900,7 +244601,8 @@ static int sqlite3Fts5IndexInit(sqlite3 *db){ | |||
| 242900 | 0, /* xSavepoint */ | 244601 | 0, /* xSavepoint */ |
| 242901 | 0, /* xRelease */ | 244602 | 0, /* xRelease */ |
| 242902 | 0, /* xRollbackTo */ | 244603 | 0, /* xRollbackTo */ |
| 242903 | 0 /* xShadowName */ | 244604 | 0, /* xShadowName */ |
| 244605 | 0 /* xIntegrity */ | ||
| 242904 | }; | 244606 | }; |
| 242905 | rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); | 244607 | rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); |
| 242906 | } | 244608 | } |
| @@ -243039,6 +244741,8 @@ struct Fts5FullTable { | |||
| 243039 | Fts5Storage *pStorage; /* Document store */ | 244741 | Fts5Storage *pStorage; /* Document store */ |
| 243040 | Fts5Global *pGlobal; /* Global (connection wide) data */ | 244742 | Fts5Global *pGlobal; /* Global (connection wide) data */ |
| 243041 | Fts5Cursor *pSortCsr; /* Sort data from this cursor */ | 244743 | Fts5Cursor *pSortCsr; /* Sort data from this cursor */ |
| 244744 | int iSavepoint; /* Successful xSavepoint()+1 */ | ||
| 244745 | int bInSavepoint; | ||
| 243042 | #ifdef SQLITE_DEBUG | 244746 | #ifdef SQLITE_DEBUG |
| 243043 | struct Fts5TransactionState ts; | 244747 | struct Fts5TransactionState ts; |
| 243044 | #endif | 244748 | #endif |
| @@ -243327,6 +245031,13 @@ static int fts5InitVtab( | |||
| 243327 | pConfig->pzErrmsg = 0; | 245031 | pConfig->pzErrmsg = 0; |
| 243328 | } | 245032 | } |
| 243329 | 245033 | ||
| 245034 | if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ | ||
| 245035 | rc = sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, (int)1); | ||
| 245036 | } | ||
| 245037 | if( rc==SQLITE_OK ){ | ||
| 245038 | rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); | ||
| 245039 | } | ||
| 245040 | |||
| 243330 | if( rc!=SQLITE_OK ){ | 245041 | if( rc!=SQLITE_OK ){ |
| 243331 | fts5FreeVtab(pTab); | 245042 | fts5FreeVtab(pTab); |
| 243332 | pTab = 0; | 245043 | pTab = 0; |
| @@ -244251,6 +245962,9 @@ static int fts5FilterMethod( | |||
| 244251 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); | 245962 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); |
| 244252 | } | 245963 | } |
| 244253 | 245964 | ||
| 245965 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); | ||
| 245966 | if( rc!=SQLITE_OK ) goto filter_out; | ||
| 245967 | |||
| 244254 | if( pTab->pSortCsr ){ | 245968 | if( pTab->pSortCsr ){ |
| 244255 | /* If pSortCsr is non-NULL, then this call is being made as part of | 245969 | /* If pSortCsr is non-NULL, then this call is being made as part of |
| 244256 | ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is | 245970 | ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is |
| @@ -244273,6 +245987,7 @@ static int fts5FilterMethod( | |||
| 244273 | pCsr->pExpr = pTab->pSortCsr->pExpr; | 245987 | pCsr->pExpr = pTab->pSortCsr->pExpr; |
| 244274 | rc = fts5CursorFirst(pTab, pCsr, bDesc); | 245988 | rc = fts5CursorFirst(pTab, pCsr, bDesc); |
| 244275 | }else if( pCsr->pExpr ){ | 245989 | }else if( pCsr->pExpr ){ |
| 245990 | assert( rc==SQLITE_OK ); | ||
| 244276 | rc = fts5CursorParseRank(pConfig, pCsr, pRank); | 245991 | rc = fts5CursorParseRank(pConfig, pCsr, pRank); |
| 244277 | if( rc==SQLITE_OK ){ | 245992 | if( rc==SQLITE_OK ){ |
| 244278 | if( bOrderByRank ){ | 245993 | if( bOrderByRank ){ |
| @@ -244444,6 +246159,7 @@ static int fts5SpecialInsert( | |||
| 244444 | Fts5Config *pConfig = pTab->p.pConfig; | 246159 | Fts5Config *pConfig = pTab->p.pConfig; |
| 244445 | int rc = SQLITE_OK; | 246160 | int rc = SQLITE_OK; |
| 244446 | int bError = 0; | 246161 | int bError = 0; |
| 246162 | int bLoadConfig = 0; | ||
| 244447 | 246163 | ||
| 244448 | if( 0==sqlite3_stricmp("delete-all", zCmd) ){ | 246164 | if( 0==sqlite3_stricmp("delete-all", zCmd) ){ |
| 244449 | if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ | 246165 | if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
| @@ -244455,6 +246171,7 @@ static int fts5SpecialInsert( | |||
| 244455 | }else{ | 246171 | }else{ |
| 244456 | rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); | 246172 | rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); |
| 244457 | } | 246173 | } |
| 246174 | bLoadConfig = 1; | ||
| 244458 | }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ | 246175 | }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ |
| 244459 | if( pConfig->eContent==FTS5_CONTENT_NONE ){ | 246176 | if( pConfig->eContent==FTS5_CONTENT_NONE ){ |
| 244460 | fts5SetVtabError(pTab, | 246177 | fts5SetVtabError(pTab, |
| @@ -244464,6 +246181,7 @@ static int fts5SpecialInsert( | |||
| 244464 | }else{ | 246181 | }else{ |
| 244465 | rc = sqlite3Fts5StorageRebuild(pTab->pStorage); | 246182 | rc = sqlite3Fts5StorageRebuild(pTab->pStorage); |
| 244466 | } | 246183 | } |
| 246184 | bLoadConfig = 1; | ||
| 244467 | }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ | 246185 | }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ |
| 244468 | rc = sqlite3Fts5StorageOptimize(pTab->pStorage); | 246186 | rc = sqlite3Fts5StorageOptimize(pTab->pStorage); |
| 244469 | }else if( 0==sqlite3_stricmp("merge", zCmd) ){ | 246187 | }else if( 0==sqlite3_stricmp("merge", zCmd) ){ |
| @@ -244476,6 +246194,8 @@ static int fts5SpecialInsert( | |||
| 244476 | }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ | 246194 | }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ |
| 244477 | pConfig->bPrefixIndex = sqlite3_value_int(pVal); | 246195 | pConfig->bPrefixIndex = sqlite3_value_int(pVal); |
| 244478 | #endif | 246196 | #endif |
| 246197 | }else if( 0==sqlite3_stricmp("flush", zCmd) ){ | ||
| 246198 | rc = sqlite3Fts5FlushToDisk(&pTab->p); | ||
| 244479 | }else{ | 246199 | }else{ |
| 244480 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); | 246200 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 244481 | if( rc==SQLITE_OK ){ | 246201 | if( rc==SQLITE_OK ){ |
| @@ -244489,6 +246209,12 @@ static int fts5SpecialInsert( | |||
| 244489 | } | 246209 | } |
| 244490 | } | 246210 | } |
| 244491 | } | 246211 | } |
| 246212 | |||
| 246213 | if( rc==SQLITE_OK && bLoadConfig ){ | ||
| 246214 | pTab->p.pConfig->iCookie--; | ||
| 246215 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); | ||
| 246216 | } | ||
| 246217 | |||
| 244492 | return rc; | 246218 | return rc; |
| 244493 | } | 246219 | } |
| 244494 | 246220 | ||
| @@ -244607,7 +246333,7 @@ static int fts5UpdateMethod( | |||
| 244607 | assert( nArg!=1 || eType0==SQLITE_INTEGER ); | 246333 | assert( nArg!=1 || eType0==SQLITE_INTEGER ); |
| 244608 | 246334 | ||
| 244609 | /* Filter out attempts to run UPDATE or DELETE on contentless tables. | 246335 | /* Filter out attempts to run UPDATE or DELETE on contentless tables. |
| 244610 | ** This is not suported. Except - DELETE is supported if the CREATE | 246336 | ** This is not suported. Except - they are both supported if the CREATE |
| 244611 | ** VIRTUAL TABLE statement contained "contentless_delete=1". */ | 246337 | ** VIRTUAL TABLE statement contained "contentless_delete=1". */ |
| 244612 | if( eType0==SQLITE_INTEGER | 246338 | if( eType0==SQLITE_INTEGER |
| 244613 | && pConfig->eContent==FTS5_CONTENT_NONE | 246339 | && pConfig->eContent==FTS5_CONTENT_NONE |
| @@ -244636,7 +246362,8 @@ static int fts5UpdateMethod( | |||
| 244636 | } | 246362 | } |
| 244637 | 246363 | ||
| 244638 | else if( eType0!=SQLITE_INTEGER ){ | 246364 | else if( eType0!=SQLITE_INTEGER ){ |
| 244639 | /* If this is a REPLACE, first remove the current entry (if any) */ | 246365 | /* An INSERT statement. If the conflict-mode is REPLACE, first remove |
| 246366 | ** the current entry (if any). */ | ||
| 244640 | if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ | 246367 | if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ |
| 244641 | i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ | 246368 | i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ |
| 244642 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); | 246369 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); |
| @@ -245510,8 +247237,12 @@ static int fts5RenameMethod( | |||
| 245510 | sqlite3_vtab *pVtab, /* Virtual table handle */ | 247237 | sqlite3_vtab *pVtab, /* Virtual table handle */ |
| 245511 | const char *zName /* New name of table */ | 247238 | const char *zName /* New name of table */ |
| 245512 | ){ | 247239 | ){ |
| 247240 | int rc; | ||
| 245513 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; | 247241 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245514 | return sqlite3Fts5StorageRename(pTab->pStorage, zName); | 247242 | pTab->bInSavepoint = 1; |
| 247243 | rc = sqlite3Fts5StorageRename(pTab->pStorage, zName); | ||
| 247244 | pTab->bInSavepoint = 0; | ||
| 247245 | return rc; | ||
| 245515 | } | 247246 | } |
| 245516 | 247247 | ||
| 245517 | static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ | 247248 | static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ |
| @@ -245525,9 +247256,29 @@ static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ | |||
| 245525 | ** Flush the contents of the pending-terms table to disk. | 247256 | ** Flush the contents of the pending-terms table to disk. |
| 245526 | */ | 247257 | */ |
| 245527 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ | 247258 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245528 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ | 247259 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245529 | fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint); | 247260 | int rc = SQLITE_OK; |
| 245530 | return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); | 247261 | char *zSql = 0; |
| 247262 | fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); | ||
| 247263 | |||
| 247264 | if( pTab->bInSavepoint==0 ){ | ||
| 247265 | zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", | ||
| 247266 | pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName | ||
| 247267 | ); | ||
| 247268 | if( zSql ){ | ||
| 247269 | pTab->bInSavepoint = 1; | ||
| 247270 | rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0); | ||
| 247271 | pTab->bInSavepoint = 0; | ||
| 247272 | sqlite3_free(zSql); | ||
| 247273 | }else{ | ||
| 247274 | rc = SQLITE_NOMEM; | ||
| 247275 | } | ||
| 247276 | if( rc==SQLITE_OK ){ | ||
| 247277 | pTab->iSavepoint = iSavepoint+1; | ||
| 247278 | } | ||
| 247279 | } | ||
| 247280 | |||
| 247281 | return rc; | ||
| 245531 | } | 247282 | } |
| 245532 | 247283 | ||
| 245533 | /* | 247284 | /* |
| @@ -245536,9 +247287,16 @@ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ | |||
| 245536 | ** This is a no-op. | 247287 | ** This is a no-op. |
| 245537 | */ | 247288 | */ |
| 245538 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ | 247289 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245539 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ | 247290 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245540 | fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint); | 247291 | int rc = SQLITE_OK; |
| 245541 | return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); | 247292 | fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); |
| 247293 | if( (iSavepoint+1)<pTab->iSavepoint ){ | ||
| 247294 | rc = sqlite3Fts5FlushToDisk(&pTab->p); | ||
| 247295 | if( rc==SQLITE_OK ){ | ||
| 247296 | pTab->iSavepoint = iSavepoint; | ||
| 247297 | } | ||
| 247298 | } | ||
| 247299 | return rc; | ||
| 245542 | } | 247300 | } |
| 245543 | 247301 | ||
| 245544 | /* | 247302 | /* |
| @@ -245548,11 +247306,14 @@ static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ | |||
| 245548 | */ | 247306 | */ |
| 245549 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ | 247307 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245550 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; | 247308 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245551 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ | 247309 | int rc = SQLITE_OK; |
| 245552 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); | 247310 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); |
| 245553 | fts5TripCursors(pTab); | 247311 | fts5TripCursors(pTab); |
| 245554 | pTab->p.pConfig->pgsz = 0; | 247312 | pTab->p.pConfig->pgsz = 0; |
| 245555 | return sqlite3Fts5StorageRollback(pTab->pStorage); | 247313 | if( (iSavepoint+1)<=pTab->iSavepoint ){ |
| 247314 | rc = sqlite3Fts5StorageRollback(pTab->pStorage); | ||
| 247315 | } | ||
| 247316 | return rc; | ||
| 245556 | } | 247317 | } |
| 245557 | 247318 | ||
| 245558 | /* | 247319 | /* |
| @@ -245754,7 +247515,7 @@ static void fts5SourceIdFunc( | |||
| 245754 | ){ | 247515 | ){ |
| 245755 | assert( nArg==0 ); | 247516 | assert( nArg==0 ); |
| 245756 | UNUSED_PARAM2(nArg, apUnused); | 247517 | UNUSED_PARAM2(nArg, apUnused); |
| 245757 | sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); | 247518 | sqlite3_result_text(pCtx, "fts5: 2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301", -1, SQLITE_TRANSIENT); |
| 245758 | } | 247519 | } |
| 245759 | 247520 | ||
| 245760 | /* | 247521 | /* |
| @@ -245772,9 +247533,46 @@ static int fts5ShadowName(const char *zName){ | |||
| 245772 | return 0; | 247533 | return 0; |
| 245773 | } | 247534 | } |
| 245774 | 247535 | ||
| 247536 | /* | ||
| 247537 | ** Run an integrity check on the FTS5 data structures. Return a string | ||
| 247538 | ** if anything is found amiss. Return a NULL pointer if everything is | ||
| 247539 | ** OK. | ||
| 247540 | */ | ||
| 247541 | static int fts5Integrity( | ||
| 247542 | sqlite3_vtab *pVtab, /* the FTS5 virtual table to check */ | ||
| 247543 | const char *zSchema, /* Name of schema in which this table lives */ | ||
| 247544 | const char *zTabname, /* Name of the table itself */ | ||
| 247545 | int isQuick, /* True if this is a quick-check */ | ||
| 247546 | char **pzErr /* Write error message here */ | ||
| 247547 | ){ | ||
| 247548 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; | ||
| 247549 | Fts5Config *pConfig = pTab->p.pConfig; | ||
| 247550 | char *zSql; | ||
| 247551 | char *zErr = 0; | ||
| 247552 | int rc; | ||
| 247553 | assert( pzErr!=0 && *pzErr==0 ); | ||
| 247554 | UNUSED_PARAM(isQuick); | ||
| 247555 | zSql = sqlite3_mprintf( | ||
| 247556 | "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", | ||
| 247557 | zSchema, zTabname, pConfig->zName); | ||
| 247558 | if( zSql==0 ) return SQLITE_NOMEM; | ||
| 247559 | rc = sqlite3_exec(pConfig->db, zSql, 0, 0, &zErr); | ||
| 247560 | sqlite3_free(zSql); | ||
| 247561 | if( (rc&0xff)==SQLITE_CORRUPT ){ | ||
| 247562 | *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", | ||
| 247563 | zSchema, zTabname); | ||
| 247564 | }else if( rc!=SQLITE_OK ){ | ||
| 247565 | *pzErr = sqlite3_mprintf("unable to validate the inverted index for" | ||
| 247566 | " FTS5 table %s.%s: %s", | ||
| 247567 | zSchema, zTabname, zErr); | ||
| 247568 | } | ||
| 247569 | sqlite3_free(zErr); | ||
| 247570 | return SQLITE_OK; | ||
| 247571 | } | ||
| 247572 | |||
| 245775 | static int fts5Init(sqlite3 *db){ | 247573 | static int fts5Init(sqlite3 *db){ |
| 245776 | static const sqlite3_module fts5Mod = { | 247574 | static const sqlite3_module fts5Mod = { |
| 245777 | /* iVersion */ 3, | 247575 | /* iVersion */ 4, |
| 245778 | /* xCreate */ fts5CreateMethod, | 247576 | /* xCreate */ fts5CreateMethod, |
| 245779 | /* xConnect */ fts5ConnectMethod, | 247577 | /* xConnect */ fts5ConnectMethod, |
| 245780 | /* xBestIndex */ fts5BestIndexMethod, | 247578 | /* xBestIndex */ fts5BestIndexMethod, |
| @@ -245797,7 +247595,8 @@ static int fts5Init(sqlite3 *db){ | |||
| 245797 | /* xSavepoint */ fts5SavepointMethod, | 247595 | /* xSavepoint */ fts5SavepointMethod, |
| 245798 | /* xRelease */ fts5ReleaseMethod, | 247596 | /* xRelease */ fts5ReleaseMethod, |
| 245799 | /* xRollbackTo */ fts5RollbackToMethod, | 247597 | /* xRollbackTo */ fts5RollbackToMethod, |
| 245800 | /* xShadowName */ fts5ShadowName | 247598 | /* xShadowName */ fts5ShadowName, |
| 247599 | /* xIntegrity */ fts5Integrity | ||
| 245801 | }; | 247600 | }; |
| 245802 | 247601 | ||
| 245803 | int rc; | 247602 | int rc; |
| @@ -247074,7 +248873,9 @@ static int sqlite3Fts5StorageSync(Fts5Storage *p){ | |||
| 247074 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); | 248873 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 247075 | if( p->bTotalsValid ){ | 248874 | if( p->bTotalsValid ){ |
| 247076 | rc = fts5StorageSaveTotals(p); | 248875 | rc = fts5StorageSaveTotals(p); |
| 247077 | p->bTotalsValid = 0; | 248876 | if( rc==SQLITE_OK ){ |
| 248877 | p->bTotalsValid = 0; | ||
| 248878 | } | ||
| 247078 | } | 248879 | } |
| 247079 | if( rc==SQLITE_OK ){ | 248880 | if( rc==SQLITE_OK ){ |
| 247080 | rc = sqlite3Fts5IndexSync(p->pIndex); | 248881 | rc = sqlite3Fts5IndexSync(p->pIndex); |
| @@ -250442,7 +252243,8 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){ | |||
| 250442 | /* xSavepoint */ 0, | 252243 | /* xSavepoint */ 0, |
| 250443 | /* xRelease */ 0, | 252244 | /* xRelease */ 0, |
| 250444 | /* xRollbackTo */ 0, | 252245 | /* xRollbackTo */ 0, |
| 250445 | /* xShadowName */ 0 | 252246 | /* xShadowName */ 0, |
| 252247 | /* xIntegrity */ 0 | ||
| 250446 | }; | 252248 | }; |
| 250447 | void *p = (void*)pGlobal; | 252249 | void *p = (void*)pGlobal; |
| 250448 | 252250 | ||
| @@ -250771,6 +252573,7 @@ static sqlite3_module stmtModule = { | |||
| 250771 | 0, /* xRelease */ | 252573 | 0, /* xRelease */ |
| 250772 | 0, /* xRollbackTo */ | 252574 | 0, /* xRollbackTo */ |
| 250773 | 0, /* xShadowName */ | 252575 | 0, /* xShadowName */ |
| 252576 | 0 /* xIntegrity */ | ||
| 250774 | }; | 252577 | }; |
| 250775 | 252578 | ||
| 250776 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ | 252579 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |