Fossil SCM
Update the built-in SQLite to the first 3.44.0 alpha, for testing.
Commit
b0db6ddb5e7735a6c5bb6dc637557384ea027f67fe64a18b4799ad29f4c66733
Parent
7e63c86e6b48044…
2 files changed
+4011
-2316
+159
-24
+4011
-2316
| --- extsrc/sqlite3.c | ||
| +++ extsrc/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 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 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | -** d3a40c05c49e1a49264912b1a05bc2143ac. | |
| 21 | +** 23a9dbe83c0042e9d500e3ae6c0592a4689. | |
| 22 | 22 | */ |
| 23 | 23 | #define SQLITE_CORE 1 |
| 24 | 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | 25 | #ifndef SQLITE_PRIVATE |
| 26 | 26 | # define SQLITE_PRIVATE static |
| @@ -457,13 +457,13 @@ | ||
| 457 | 457 | ** |
| 458 | 458 | ** See also: [sqlite3_libversion()], |
| 459 | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | 461 | */ |
| 462 | -#define SQLITE_VERSION "3.43.1" | |
| 463 | -#define SQLITE_VERSION_NUMBER 3043001 | |
| 464 | -#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" | |
| 462 | +#define SQLITE_VERSION "3.44.0" | |
| 463 | +#define SQLITE_VERSION_NUMBER 3044000 | |
| 464 | +#define SQLITE_SOURCE_ID "2023-10-21 20:34:57 023a9dbe83c0042e9d500e3ae6c0592a468982e4ac278d08c9201967506c7555" | |
| 465 | 465 | |
| 466 | 466 | /* |
| 467 | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | 469 | ** |
| @@ -5635,10 +5635,11 @@ | ||
| 5635 | 5635 | ** |
| 5636 | 5636 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 5637 | 5637 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 5638 | 5638 | */ |
| 5639 | 5639 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5640 | + | |
| 5640 | 5641 | |
| 5641 | 5642 | /* |
| 5642 | 5643 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5643 | 5644 | ** KEYWORDS: {function creation routines} |
| 5644 | 5645 | ** METHOD: sqlite3 |
| @@ -6190,36 +6191,36 @@ | ||
| 6190 | 6191 | /* |
| 6191 | 6192 | ** CAPI3REF: Function Auxiliary Data |
| 6192 | 6193 | ** METHOD: sqlite3_context |
| 6193 | 6194 | ** |
| 6194 | 6195 | ** These functions may be used by (non-aggregate) SQL functions to |
| 6195 | -** associate metadata with argument values. If the same value is passed to | |
| 6196 | -** multiple invocations of the same SQL function during query execution, under | |
| 6197 | -** some circumstances the associated metadata may be preserved. An example | |
| 6198 | -** of where this might be useful is in a regular-expression matching | |
| 6199 | -** function. The compiled version of the regular expression can be stored as | |
| 6200 | -** metadata associated with the pattern string. | |
| 6196 | +** associate auxiliary data with argument values. If the same argument | |
| 6197 | +** value is passed to multiple invocations of the same SQL function during | |
| 6198 | +** query execution, under some circumstances the associated auxiliary data | |
| 6199 | +** might be preserved. An example of where this might be useful is in a | |
| 6200 | +** regular-expression matching function. The compiled version of the regular | |
| 6201 | +** expression can be stored as auxiliary data associated with the pattern string. | |
| 6201 | 6202 | ** Then as long as the pattern string remains the same, |
| 6202 | 6203 | ** the compiled regular expression can be reused on multiple |
| 6203 | 6204 | ** invocations of the same function. |
| 6204 | 6205 | ** |
| 6205 | -** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata | |
| 6206 | +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data | |
| 6206 | 6207 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 6207 | 6208 | ** value to the application-defined function. ^N is zero for the left-most |
| 6208 | -** function argument. ^If there is no metadata | |
| 6209 | +** function argument. ^If there is no auxiliary data | |
| 6209 | 6210 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 6210 | 6211 | ** returns a NULL pointer. |
| 6211 | 6212 | ** |
| 6212 | -** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th | |
| 6213 | -** argument of the application-defined function. ^Subsequent | |
| 6213 | +** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the | |
| 6214 | +** N-th argument of the application-defined function. ^Subsequent | |
| 6214 | 6215 | ** 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 | |
| 6216 | -** NULL if the metadata has been discarded. | |
| 6216 | +** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or | |
| 6217 | +** NULL if the auxiliary data has been discarded. | |
| 6217 | 6218 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 6218 | 6219 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 6219 | -** once, when the metadata is discarded. | |
| 6220 | -** SQLite is free to discard the metadata at any time, including: <ul> | |
| 6220 | +** once, when the auxiliary data is discarded. | |
| 6221 | +** SQLite is free to discard the auxiliary data at any time, including: <ul> | |
| 6221 | 6222 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 6222 | 6223 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 6223 | 6224 | ** SQL statement)^, or |
| 6224 | 6225 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 6225 | 6226 | ** parameter)^, or |
| @@ -6231,24 +6232,81 @@ | ||
| 6231 | 6232 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 6232 | 6233 | ** should be called near the end of the function implementation and the |
| 6233 | 6234 | ** function implementation should not make any use of P after |
| 6234 | 6235 | ** sqlite3_set_auxdata() has been called. |
| 6235 | 6236 | ** |
| 6236 | -** ^(In practice, metadata is preserved between function calls for | |
| 6237 | +** ^(In practice, auxiliary data is preserved between function calls for | |
| 6237 | 6238 | ** function parameters that are compile-time constants, including literal |
| 6238 | 6239 | ** values and [parameters] and expressions composed from the same.)^ |
| 6239 | 6240 | ** |
| 6240 | 6241 | ** The value of the N parameter to these interfaces should be non-negative. |
| 6241 | 6242 | ** Future enhancements may make use of negative N values to define new |
| 6242 | 6243 | ** kinds of function caching behavior. |
| 6243 | 6244 | ** |
| 6244 | 6245 | ** These routines must be called from the same thread in which |
| 6245 | 6246 | ** the SQL function is running. |
| 6247 | +** | |
| 6248 | +** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. | |
| 6246 | 6249 | */ |
| 6247 | 6250 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 6248 | 6251 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 6249 | 6252 | |
| 6253 | +/* | |
| 6254 | +** CAPI3REF: Database Connection Client Data | |
| 6255 | +** METHOD: sqlite3 | |
| 6256 | +** | |
| 6257 | +** These functions are used to associate one or more named pointers | |
| 6258 | +** with a [database connection]. | |
| 6259 | +** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P | |
| 6260 | +** to be attached to [database connection] D using name N. Subsequent | |
| 6261 | +** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P | |
| 6262 | +** or a NULL pointer if there were no prior calls to | |
| 6263 | +** sqlite3_set_clientdata() with the same values of D and N. | |
| 6264 | +** Names are compared using strcmp() and are thus case sensitive. | |
| 6265 | +** | |
| 6266 | +** If P and X are both non-NULL, then the destructor X is invoked with | |
| 6267 | +** argument P on the first of the following occurrences: | |
| 6268 | +** <ul> | |
| 6269 | +** <li> An out-of-memory error occurs during the call to | |
| 6270 | +** sqlite3_set_clientdata() which attempts to register pointer P. | |
| 6271 | +** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made | |
| 6272 | +** with the same D and N parameters. | |
| 6273 | +** <li> The database connection closes. SQLite does not make any guarantees | |
| 6274 | +** about the order in which destructors are called, only that all | |
| 6275 | +** destructors will be called exactly once at some point during the | |
| 6276 | +** database connection closingi process. | |
| 6277 | +** </ul> | |
| 6278 | +** | |
| 6279 | +** SQLite does not do anything with client data other than invoke | |
| 6280 | +** destructors on the client data at the appropriate time. The intended | |
| 6281 | +** use for client data is to provide a mechanism for wrapper libraries | |
| 6282 | +** to store additional information about an SQLite database connection. | |
| 6283 | +** | |
| 6284 | +** There is no limit (other than available memory) on the number of different | |
| 6285 | +** client data pointers (with different names) that can be attached to a | |
| 6286 | +** single database connection. However, the implementation is optimized | |
| 6287 | +** for the case of having only one or two different client data names. | |
| 6288 | +** Applications and wrapper libraries are discouraged from using more than | |
| 6289 | +** one client data name each. | |
| 6290 | +** | |
| 6291 | +** There is no way to enumerate the client data pointers | |
| 6292 | +** associated with a database connection. The N parameter can be thought | |
| 6293 | +** of as a secret key such that only code that knows the secret key is able | |
| 6294 | +** to access the associated data. | |
| 6295 | +** | |
| 6296 | +** Security Warning: These interfaces should not be exposed in scripting | |
| 6297 | +** languages or in other circumstances where it might be possible for an | |
| 6298 | +** an attacker to invoke them. Any agent that can invoke these interfaces | |
| 6299 | +** can probably also take control of the process. | |
| 6300 | +** | |
| 6301 | +** Database connection client data is only available for SQLite | |
| 6302 | +** version 3.44.0 ([dateof:3.44.0]) and later. | |
| 6303 | +** | |
| 6304 | +** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. | |
| 6305 | +*/ | |
| 6306 | +SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); | |
| 6307 | +SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); | |
| 6250 | 6308 | |
| 6251 | 6309 | /* |
| 6252 | 6310 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 6253 | 6311 | ** |
| 6254 | 6312 | ** These are special values for the destructor that is passed in as the |
| @@ -7528,10 +7586,13 @@ | ||
| 7528 | 7586 | int (*xRelease)(sqlite3_vtab *pVTab, int); |
| 7529 | 7587 | int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
| 7530 | 7588 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7531 | 7589 | ** Those below are for version 3 and greater. */ |
| 7532 | 7590 | int (*xShadowName)(const char*); |
| 7591 | + /* The methods above are in versions 1 through 3 of the sqlite_module object. | |
| 7592 | + ** Those below are for version 4 and greater. */ | |
| 7593 | + int (*xIntegrity)(sqlite3_vtab *pVTab, char**); | |
| 7533 | 7594 | }; |
| 7534 | 7595 | |
| 7535 | 7596 | /* |
| 7536 | 7597 | ** CAPI3REF: Virtual Table Indexing Information |
| 7537 | 7598 | ** KEYWORDS: sqlite3_index_info |
| @@ -8495,10 +8556,11 @@ | ||
| 8495 | 8556 | */ |
| 8496 | 8557 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8497 | 8558 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8498 | 8559 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8499 | 8560 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8561 | +#define SQLITE_TESTCTRL_FK_NO_ACTION 7 | |
| 8500 | 8562 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8501 | 8563 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8502 | 8564 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8503 | 8565 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8504 | 8566 | #define SQLITE_TESTCTRL_ASSERT 12 |
| @@ -10859,10 +10921,17 @@ | ||
| 10859 | 10921 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 10860 | 10922 | ** values of D and S. |
| 10861 | 10923 | ** The size of the database is written into *P even if the |
| 10862 | 10924 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10863 | 10925 | ** of the database exists. |
| 10926 | +** | |
| 10927 | +** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, | |
| 10928 | +** the returned buffer content will remain accessible and unchanged | |
| 10929 | +** until either the next write operation on the connection or when | |
| 10930 | +** the connection is closed, and applications must not modify the | |
| 10931 | +** buffer. If the bit had been clear, the returned buffer will not | |
| 10932 | +** be accessed by SQLite after the call. | |
| 10864 | 10933 | ** |
| 10865 | 10934 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10866 | 10935 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10867 | 10936 | ** allocation error occurs. |
| 10868 | 10937 | ** |
| @@ -10907,18 +10976,28 @@ | ||
| 10907 | 10976 | ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will |
| 10908 | 10977 | ** invoke sqlite3_free() on the serialization buffer when the database |
| 10909 | 10978 | ** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then |
| 10910 | 10979 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() |
| 10911 | 10980 | ** if writes on the database cause it to grow larger than M bytes. |
| 10981 | +** | |
| 10982 | +** Applications must not modify the buffer P or invalidate it before | |
| 10983 | +** the database connection D is closed. | |
| 10912 | 10984 | ** |
| 10913 | 10985 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 10914 | 10986 | ** database is currently in a read transaction or is involved in a backup |
| 10915 | 10987 | ** operation. |
| 10916 | 10988 | ** |
| 10917 | 10989 | ** It is not possible to deserialized into the TEMP database. If the |
| 10918 | 10990 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10919 | 10991 | ** function returns SQLITE_ERROR. |
| 10992 | +** | |
| 10993 | +** The deserialized database should not be in [WAL mode]. If the database | |
| 10994 | +** is in WAL mode, then any attempt to use the database file will result | |
| 10995 | +** in an [SQLITE_CANTOPEN] error. The application can set the | |
| 10996 | +** [file format version numbers] (bytes 18 and 19) of the input database P | |
| 10997 | +** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the | |
| 10998 | +** database file into rollback mode and work around this limitation. | |
| 10920 | 10999 | ** |
| 10921 | 11000 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10922 | 11001 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10923 | 11002 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10924 | 11003 | ** |
| @@ -11987,10 +12066,22 @@ | ||
| 11987 | 12066 | void *pB, /* Pointer to buffer containing changeset B */ |
| 11988 | 12067 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| 11989 | 12068 | void **ppOut /* OUT: Buffer containing output changeset */ |
| 11990 | 12069 | ); |
| 11991 | 12070 | |
| 12071 | + | |
| 12072 | +/* | |
| 12073 | +** CAPI3REF: Upgrade the Schema of a Changeset/Patchset | |
| 12074 | +*/ | |
| 12075 | +SQLITE_API int sqlite3changeset_upgrade( | |
| 12076 | + sqlite3 *db, | |
| 12077 | + const char *zDb, | |
| 12078 | + int nIn, const void *pIn, /* Input changeset */ | |
| 12079 | + int *pnOut, void **ppOut /* OUT: Inverse of input */ | |
| 12080 | +); | |
| 12081 | + | |
| 12082 | + | |
| 11992 | 12083 | |
| 11993 | 12084 | /* |
| 11994 | 12085 | ** CAPI3REF: Changegroup Handle |
| 11995 | 12086 | ** |
| 11996 | 12087 | ** A changegroup is an object used to combine two or more |
| @@ -12034,10 +12125,42 @@ | ||
| 12034 | 12125 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 12035 | 12126 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 12036 | 12127 | */ |
| 12037 | 12128 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 12038 | 12129 | |
| 12130 | +/* | |
| 12131 | +** CAPI3REF: Add a Schema to a Changegroup | |
| 12132 | +** METHOD: sqlite3_changegroup_schema | |
| 12133 | +** | |
| 12134 | +** This method may be used to optionally enforce the rule that the changesets | |
| 12135 | +** added to the changegroup handle must match the schema of database zDb | |
| 12136 | +** ("main", "temp", or the name of an attached database). If | |
| 12137 | +** sqlite3changegroup_add() is called to add a changeset that is not compatible | |
| 12138 | +** with the configured schema, SQLITE_SCHEMA is returned and the changegroup | |
| 12139 | +** object is left in an undefined state. | |
| 12140 | +** | |
| 12141 | +** A changeset schema is considered compatible with the database schema in | |
| 12142 | +** the same way as for sqlite3changeset_apply(). Specifically, for each | |
| 12143 | +** table in the changeset, there exists a database table with: | |
| 12144 | +** | |
| 12145 | +** <ul> | |
| 12146 | +** <li> The name identified by the changeset, and | |
| 12147 | +** <li> at least as many columns as recorded in the changeset, and | |
| 12148 | +** <li> the primary key columns in the same position as recorded in | |
| 12149 | +** the changeset. | |
| 12150 | +** </ul> | |
| 12151 | +** | |
| 12152 | +** The output of the changegroup object always has the same schema as the | |
| 12153 | +** database nominated using this function. In cases where changesets passed | |
| 12154 | +** to sqlite3changegroup_add() have fewer columns than the corresponding table | |
| 12155 | +** in the database schema, these are filled in using the default column | |
| 12156 | +** values from the database schema. This makes it possible to combined | |
| 12157 | +** changesets that have different numbers of columns for a single table | |
| 12158 | +** within a changegroup, provided that they are otherwise compatible. | |
| 12159 | +*/ | |
| 12160 | +SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); | |
| 12161 | + | |
| 12039 | 12162 | /* |
| 12040 | 12163 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 12041 | 12164 | ** METHOD: sqlite3_changegroup |
| 12042 | 12165 | ** |
| 12043 | 12166 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| @@ -12102,17 +12225,22 @@ | ||
| 12102 | 12225 | ** </table> |
| 12103 | 12226 | ** |
| 12104 | 12227 | ** If the new changeset contains changes to a table that is already present |
| 12105 | 12228 | ** in the changegroup, then the number of columns and the position of the |
| 12106 | 12229 | ** 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 | |
| 12108 | -** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is | |
| 12109 | -** returned. Or, if an out-of-memory condition occurs during processing, this | |
| 12110 | -** function returns SQLITE_NOMEM. In all cases, if an error occurs the state | |
| 12111 | -** of the final contents of the changegroup is undefined. | |
| 12230 | +** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup | |
| 12231 | +** object has been configured with a database schema using the | |
| 12232 | +** sqlite3changegroup_schema() API, then it is possible to combine changesets | |
| 12233 | +** with different numbers of columns for a single table, provided that | |
| 12234 | +** they are otherwise compatible. | |
| 12112 | 12235 | ** |
| 12113 | -** If no error occurs, SQLITE_OK is returned. | |
| 12236 | +** If the input changeset appears to be corrupt and the corruption is | |
| 12237 | +** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition | |
| 12238 | +** occurs during processing, this function returns SQLITE_NOMEM. | |
| 12239 | +** | |
| 12240 | +** In all cases, if an error occurs the state of the final contents of the | |
| 12241 | +** changegroup is undefined. If no error occurs, SQLITE_OK is returned. | |
| 12114 | 12242 | */ |
| 12115 | 12243 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 12116 | 12244 | |
| 12117 | 12245 | /* |
| 12118 | 12246 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| @@ -12373,14 +12501,21 @@ | ||
| 12373 | 12501 | ** <li>an update change if the modified fields are already set to |
| 12374 | 12502 | ** their new values in the conflicting row, or |
| 12375 | 12503 | ** <li>an insert change if all fields of the conflicting row match |
| 12376 | 12504 | ** the row being inserted. |
| 12377 | 12505 | ** </ul> |
| 12506 | +** | |
| 12507 | +** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd> | |
| 12508 | +** If this flag it set, then all foreign key constraints in the target | |
| 12509 | +** database behave as if they were declared with "ON UPDATE NO ACTION ON | |
| 12510 | +** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL | |
| 12511 | +** or SET DEFAULT. | |
| 12378 | 12512 | */ |
| 12379 | 12513 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12380 | 12514 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12381 | 12515 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12516 | +#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 | |
| 12382 | 12517 | |
| 12383 | 12518 | /* |
| 12384 | 12519 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| 12385 | 12520 | ** |
| 12386 | 12521 | ** Values that may be passed as the second argument to a conflict-handler. |
| @@ -13767,10 +13902,20 @@ | ||
| 13767 | 13902 | # include <cmnintrin.h> |
| 13768 | 13903 | # endif |
| 13769 | 13904 | # endif |
| 13770 | 13905 | #endif |
| 13771 | 13906 | |
| 13907 | +/* | |
| 13908 | +** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit | |
| 13909 | +** SEH support if the -DSQLITE_OMIT_SEH option is given. | |
| 13910 | +*/ | |
| 13911 | +#if defined(_MSC_VER) && !defined(SQLITE_OMIT_SEH) | |
| 13912 | +# define SQLITE_USE_SEH 1 | |
| 13913 | +#else | |
| 13914 | +# undef SQLITE_USE_SEH | |
| 13915 | +#endif | |
| 13916 | + | |
| 13772 | 13917 | /* |
| 13773 | 13918 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
| 13774 | 13919 | ** 0 means mutexes are permanently disable and the library is never |
| 13775 | 13920 | ** threadsafe. 1 means the library is serialized which is the highest |
| 13776 | 13921 | ** level of threadsafety. 2 means the library is multithreaded - multiple |
| @@ -14660,20 +14805,37 @@ | ||
| 14660 | 14805 | ** |
| 14661 | 14806 | ** For best performance, an attempt is made to guess at the byte-order |
| 14662 | 14807 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 14663 | 14808 | ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined |
| 14664 | 14809 | ** at run-time. |
| 14810 | +** | |
| 14811 | +** If you are building SQLite on some obscure platform for which the | |
| 14812 | +** following ifdef magic does not work, you can always include either: | |
| 14813 | +** | |
| 14814 | +** -DSQLITE_BYTEORDER=1234 | |
| 14815 | +** | |
| 14816 | +** or | |
| 14817 | +** | |
| 14818 | +** -DSQLITE_BYTEORDER=4321 | |
| 14819 | +** | |
| 14820 | +** to cause the build to work for little-endian or big-endian processors, | |
| 14821 | +** respectively. | |
| 14665 | 14822 | */ |
| 14666 | -#ifndef SQLITE_BYTEORDER | |
| 14667 | -# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | |
| 14823 | +#ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ | |
| 14824 | +# if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
| 14825 | +# define SQLITE_BYTEORDER 4321 | |
| 14826 | +# elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ | |
| 14827 | +# define SQLITE_BYTEORDER 1234 | |
| 14828 | +# elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 | |
| 14829 | +# define SQLITE_BYTEORDER 4321 | |
| 14830 | +# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | |
| 14668 | 14831 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 14669 | 14832 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 14670 | 14833 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 14671 | -# define SQLITE_BYTEORDER 1234 | |
| 14672 | -# elif defined(sparc) || defined(__ppc__) || \ | |
| 14673 | - defined(__ARMEB__) || defined(__AARCH64EB__) | |
| 14674 | -# define SQLITE_BYTEORDER 4321 | |
| 14834 | +# define SQLITE_BYTEORDER 1234 | |
| 14835 | +# elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) | |
| 14836 | +# define SQLITE_BYTEORDER 4321 | |
| 14675 | 14837 | # else |
| 14676 | 14838 | # define SQLITE_BYTEORDER 0 |
| 14677 | 14839 | # endif |
| 14678 | 14840 | #endif |
| 14679 | 14841 | #if SQLITE_BYTEORDER==4321 |
| @@ -14993,10 +15155,11 @@ | ||
| 14993 | 15155 | typedef struct CollSeq CollSeq; |
| 14994 | 15156 | typedef struct Column Column; |
| 14995 | 15157 | typedef struct Cte Cte; |
| 14996 | 15158 | typedef struct CteUse CteUse; |
| 14997 | 15159 | typedef struct Db Db; |
| 15160 | +typedef struct DbClientData DbClientData; | |
| 14998 | 15161 | typedef struct DbFixer DbFixer; |
| 14999 | 15162 | typedef struct Schema Schema; |
| 15000 | 15163 | typedef struct Expr Expr; |
| 15001 | 15164 | typedef struct ExprList ExprList; |
| 15002 | 15165 | typedef struct FKey FKey; |
| @@ -16433,23 +16596,24 @@ | ||
| 16433 | 16596 | #define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 16434 | 16597 | #define OP_VBegin 170 |
| 16435 | 16598 | #define OP_VCreate 171 |
| 16436 | 16599 | #define OP_VDestroy 172 |
| 16437 | 16600 | #define OP_VOpen 173 |
| 16438 | -#define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */ | |
| 16439 | -#define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */ | |
| 16440 | -#define OP_VRename 176 | |
| 16441 | -#define OP_Pagecount 177 | |
| 16442 | -#define OP_MaxPgcnt 178 | |
| 16443 | -#define OP_ClrSubtype 179 /* synopsis: r[P1].subtype = 0 */ | |
| 16444 | -#define OP_FilterAdd 180 /* synopsis: filter(P1) += key(P3@P4) */ | |
| 16445 | -#define OP_Trace 181 | |
| 16446 | -#define OP_CursorHint 182 | |
| 16447 | -#define OP_ReleaseReg 183 /* synopsis: release r[P1@P2] mask P3 */ | |
| 16448 | -#define OP_Noop 184 | |
| 16449 | -#define OP_Explain 185 | |
| 16450 | -#define OP_Abortable 186 | |
| 16601 | +#define OP_VCheck 174 | |
| 16602 | +#define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */ | |
| 16603 | +#define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */ | |
| 16604 | +#define OP_VRename 177 | |
| 16605 | +#define OP_Pagecount 178 | |
| 16606 | +#define OP_MaxPgcnt 179 | |
| 16607 | +#define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */ | |
| 16608 | +#define OP_FilterAdd 181 /* synopsis: filter(P1) += key(P3@P4) */ | |
| 16609 | +#define OP_Trace 182 | |
| 16610 | +#define OP_CursorHint 183 | |
| 16611 | +#define OP_ReleaseReg 184 /* synopsis: release r[P1@P2] mask P3 */ | |
| 16612 | +#define OP_Noop 185 | |
| 16613 | +#define OP_Explain 186 | |
| 16614 | +#define OP_Abortable 187 | |
| 16451 | 16615 | |
| 16452 | 16616 | /* Properties such as "out2" or "jump" that are specified in |
| 16453 | 16617 | ** comments following the "case" for each opcode in the vdbe.c |
| 16454 | 16618 | ** are encoded into bitvectors as follows: |
| 16455 | 16619 | */ |
| @@ -16480,13 +16644,13 @@ | ||
| 16480 | 16644 | /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\ |
| 16481 | 16645 | /* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\ |
| 16482 | 16646 | /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 16483 | 16647 | /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 16484 | 16648 | /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16485 | -/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0x40,\ | |
| 16486 | -/* 176 */ 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00,\ | |
| 16487 | -/* 184 */ 0x00, 0x00, 0x00,} | |
| 16649 | +/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ | |
| 16650 | +/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00,\ | |
| 16651 | +/* 184 */ 0x00, 0x00, 0x00, 0x00,} | |
| 16488 | 16652 | |
| 16489 | 16653 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 16490 | 16654 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 16491 | 16655 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 16492 | 16656 | ** generated this include file strives to group all JUMP opcodes |
| @@ -17391,10 +17555,11 @@ | ||
| 17391 | 17555 | int nSavepoint; /* Number of non-transaction savepoints */ |
| 17392 | 17556 | int nStatement; /* Number of nested statement-transactions */ |
| 17393 | 17557 | i64 nDeferredCons; /* Net deferred constraints this transaction. */ |
| 17394 | 17558 | i64 nDeferredImmCons; /* Net deferred immediate constraints */ |
| 17395 | 17559 | int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ |
| 17560 | + DbClientData *pDbData; /* sqlite3_set_clientdata() content */ | |
| 17396 | 17561 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 17397 | 17562 | /* The following variables are all protected by the STATIC_MAIN |
| 17398 | 17563 | ** mutex, not by sqlite3.mutex. They are used by code in notify.c. |
| 17399 | 17564 | ** |
| 17400 | 17565 | ** When X.pUnlockConnection==Y, that means that X is waiting for Y to |
| @@ -17473,10 +17638,11 @@ | ||
| 17473 | 17638 | #define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ |
| 17474 | 17639 | /* DELETE, or UPDATE and return */ |
| 17475 | 17640 | /* the count using a callback. */ |
| 17476 | 17641 | #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ |
| 17477 | 17642 | #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ |
| 17643 | +#define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */ | |
| 17478 | 17644 | |
| 17479 | 17645 | /* Flags used only if debugging */ |
| 17480 | 17646 | #ifdef SQLITE_DEBUG |
| 17481 | 17647 | #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */ |
| 17482 | 17648 | #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */ |
| @@ -18488,10 +18654,13 @@ | ||
| 18488 | 18654 | struct AggInfo_func { /* For each aggregate function */ |
| 18489 | 18655 | Expr *pFExpr; /* Expression encoding the function */ |
| 18490 | 18656 | FuncDef *pFunc; /* The aggregate function implementation */ |
| 18491 | 18657 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ |
| 18492 | 18658 | int iDistAddr; /* Address of OP_OpenEphemeral */ |
| 18659 | + int iOBTab; /* Ephemeral table to implement ORDER BY */ | |
| 18660 | + u8 bOBPayload; /* iOBTab has payload columns separate from key */ | |
| 18661 | + u8 bOBUnique; /* Enforce uniqueness on iOBTab keys */ | |
| 18493 | 18662 | } *aFunc; |
| 18494 | 18663 | int nFunc; /* Number of entries in aFunc[] */ |
| 18495 | 18664 | u32 selId; /* Select to which this AggInfo belongs */ |
| 18496 | 18665 | #ifdef SQLITE_DEBUG |
| 18497 | 18666 | Select *pSelect; /* SELECT statement that this AggInfo supports */ |
| @@ -18672,11 +18841,11 @@ | ||
| 18672 | 18841 | #define EP_xIsSelect 0x001000 /* x.pSelect is valid (otherwise x.pList is) */ |
| 18673 | 18842 | #define EP_Skip 0x002000 /* Operator does not contribute to affinity */ |
| 18674 | 18843 | #define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
| 18675 | 18844 | #define EP_Win 0x008000 /* Contains window functions */ |
| 18676 | 18845 | #define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| 18677 | - /* 0x020000 // Available for reuse */ | |
| 18846 | +#define EP_FullSize 0x020000 /* Expr structure must remain full sized */ | |
| 18678 | 18847 | #define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ |
| 18679 | 18848 | #define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ |
| 18680 | 18849 | #define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| 18681 | 18850 | #define EP_CanBeNull 0x200000 /* Can be null despite NOT NULL constraint */ |
| 18682 | 18851 | #define EP_Subquery 0x400000 /* Tree contains a TK_SELECT operator */ |
| @@ -18702,10 +18871,11 @@ | ||
| 18702 | 18871 | #define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P)) |
| 18703 | 18872 | #define ExprSetProperty(E,P) (E)->flags|=(P) |
| 18704 | 18873 | #define ExprClearProperty(E,P) (E)->flags&=~(P) |
| 18705 | 18874 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) |
| 18706 | 18875 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) |
| 18876 | +#define ExprIsFullSize(E) (((E)->flags&(EP_Reduced|EP_TokenOnly))==0) | |
| 18707 | 18877 | |
| 18708 | 18878 | /* Macros used to ensure that the correct members of unions are accessed |
| 18709 | 18879 | ** in Expr. |
| 18710 | 18880 | */ |
| 18711 | 18881 | #define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0) |
| @@ -18819,10 +18989,11 @@ | ||
| 18819 | 18989 | ** Allowed values for Expr.a.eEName |
| 18820 | 18990 | */ |
| 18821 | 18991 | #define ENAME_NAME 0 /* The AS clause of a result set */ |
| 18822 | 18992 | #define ENAME_SPAN 1 /* Complete text of the result set expression */ |
| 18823 | 18993 | #define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ |
| 18994 | +#define ENAME_ROWID 3 /* "DB.TABLE._rowid_" for * expansion of rowid */ | |
| 18824 | 18995 | |
| 18825 | 18996 | /* |
| 18826 | 18997 | ** An instance of this structure can hold a simple list of identifiers, |
| 18827 | 18998 | ** such as the list "a,b,c" in the following statements: |
| 18828 | 18999 | ** |
| @@ -19427,10 +19598,11 @@ | ||
| 19427 | 19598 | int nLabel; /* The *negative* of the number of labels used */ |
| 19428 | 19599 | int nLabelAlloc; /* Number of slots in aLabel */ |
| 19429 | 19600 | int *aLabel; /* Space to hold the labels */ |
| 19430 | 19601 | ExprList *pConstExpr;/* Constant expressions */ |
| 19431 | 19602 | IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ |
| 19603 | + IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */ | |
| 19432 | 19604 | Token constraintName;/* Name of the constraint currently being parsed */ |
| 19433 | 19605 | yDbMask writeMask; /* Start a write transaction on these databases */ |
| 19434 | 19606 | yDbMask cookieMask; /* Bitmask of schema verified databases */ |
| 19435 | 19607 | int regRowid; /* Register holding rowid of CREATE TABLE entry */ |
| 19436 | 19608 | int regRoot; /* Register holding root page number for new objects */ |
| @@ -19997,10 +20169,20 @@ | ||
| 19997 | 20169 | int iCur; /* Ephemeral table holding the materialization */ |
| 19998 | 20170 | LogEst nRowEst; /* Estimated number of rows in the table */ |
| 19999 | 20171 | u8 eM10d; /* The MATERIALIZED flag */ |
| 20000 | 20172 | }; |
| 20001 | 20173 | |
| 20174 | + | |
| 20175 | +/* Client data associated with sqlite3_set_clientdata() and | |
| 20176 | +** sqlite3_get_clientdata(). | |
| 20177 | +*/ | |
| 20178 | +struct DbClientData { | |
| 20179 | + DbClientData *pNext; /* Next in a linked list */ | |
| 20180 | + void *pData; /* The data */ | |
| 20181 | + void (*xDestructor)(void*); /* Destructor. Might be NULL */ | |
| 20182 | + char zName[1]; /* Name of this client data. MUST BE LAST */ | |
| 20183 | +}; | |
| 20002 | 20184 | |
| 20003 | 20185 | #ifdef SQLITE_DEBUG |
| 20004 | 20186 | /* |
| 20005 | 20187 | ** An instance of the TreeView object is used for printing the content of |
| 20006 | 20188 | ** data structures on sqlite3DebugPrintf() using a tree-like view. |
| @@ -20402,10 +20584,12 @@ | ||
| 20402 | 20584 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*); |
| 20403 | 20585 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 20404 | 20586 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 20405 | 20587 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 20406 | 20588 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); |
| 20589 | +SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy(Parse*,Expr*,ExprList*); | |
| 20590 | +SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); | |
| 20407 | 20591 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 20408 | 20592 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 20409 | 20593 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 20410 | 20594 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20411 | 20595 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| @@ -20638,10 +20822,11 @@ | ||
| 20638 | 20822 | #endif |
| 20639 | 20823 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20640 | 20824 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 20641 | 20825 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 20642 | 20826 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 20827 | +SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab); | |
| 20643 | 20828 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( |
| 20644 | 20829 | Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); |
| 20645 | 20830 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); |
| 20646 | 20831 | SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); |
| 20647 | 20832 | SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int); |
| @@ -20909,11 +21094,12 @@ | ||
| 20909 | 21094 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| 20910 | 21095 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 20911 | 21096 | const struct ExprList_item*, |
| 20912 | 21097 | const char*, |
| 20913 | 21098 | const char*, |
| 20914 | - const char* | |
| 21099 | + const char*, | |
| 21100 | + int* | |
| 20915 | 21101 | ); |
| 20916 | 21102 | SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); |
| 20917 | 21103 | SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); |
| 20918 | 21104 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 20919 | 21105 | SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*); |
| @@ -20966,11 +21152,11 @@ | ||
| 20966 | 21152 | SQLITE_PRIVATE void sqlite3OomClear(sqlite3*); |
| 20967 | 21153 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 20968 | 21154 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 20969 | 21155 | |
| 20970 | 21156 | SQLITE_PRIVATE char *sqlite3RCStrRef(char*); |
| 20971 | -SQLITE_PRIVATE void sqlite3RCStrUnref(char*); | |
| 21157 | +SQLITE_PRIVATE void sqlite3RCStrUnref(void*); | |
| 20972 | 21158 | SQLITE_PRIVATE char *sqlite3RCStrNew(u64); |
| 20973 | 21159 | SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); |
| 20974 | 21160 | |
| 20975 | 21161 | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); |
| 20976 | 21162 | SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64); |
| @@ -21802,10 +21988,13 @@ | ||
| 21802 | 21988 | "ENABLE_ZIPVFS", |
| 21803 | 21989 | #endif |
| 21804 | 21990 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS |
| 21805 | 21991 | "EXPLAIN_ESTIMATED_ROWS", |
| 21806 | 21992 | #endif |
| 21993 | +#ifdef SQLITE_EXTRA_AUTOEXT | |
| 21994 | + "EXTRA_AUTOEXT=" CTIMEOPT_VAL(SQLITE_EXTRA_AUTOEXT), | |
| 21995 | +#endif | |
| 21807 | 21996 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 21808 | 21997 | "EXTRA_IFNULLROW", |
| 21809 | 21998 | #endif |
| 21810 | 21999 | #ifdef SQLITE_EXTRA_INIT |
| 21811 | 22000 | "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT), |
| @@ -22082,10 +22271,13 @@ | ||
| 22082 | 22271 | #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS |
| 22083 | 22272 | "OMIT_SCHEMA_PRAGMAS", |
| 22084 | 22273 | #endif |
| 22085 | 22274 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS |
| 22086 | 22275 | "OMIT_SCHEMA_VERSION_PRAGMAS", |
| 22276 | +#endif | |
| 22277 | +#ifdef SQLITE_OMIT_SEH | |
| 22278 | + "OMIT_SEH", | |
| 22087 | 22279 | #endif |
| 22088 | 22280 | #ifdef SQLITE_OMIT_SHARED_CACHE |
| 22089 | 22281 | "OMIT_SHARED_CACHE", |
| 22090 | 22282 | #endif |
| 22091 | 22283 | #ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES |
| @@ -25042,27 +25234,43 @@ | ||
| 25042 | 25234 | sqlite3StrAccumInit(&sRes, 0, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]); |
| 25043 | 25235 | |
| 25044 | 25236 | computeJD(&x); |
| 25045 | 25237 | computeYMD_HMS(&x); |
| 25046 | 25238 | for(i=j=0; zFmt[i]; i++){ |
| 25239 | + char cf; | |
| 25047 | 25240 | if( zFmt[i]!='%' ) continue; |
| 25048 | 25241 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); |
| 25049 | 25242 | i++; |
| 25050 | 25243 | j = i + 1; |
| 25051 | - switch( zFmt[i] ){ | |
| 25052 | - case 'd': { | |
| 25053 | - sqlite3_str_appendf(&sRes, "%02d", x.D); | |
| 25244 | + cf = zFmt[i]; | |
| 25245 | + switch( cf ){ | |
| 25246 | + case 'd': /* Fall thru */ | |
| 25247 | + case 'e': { | |
| 25248 | + sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D); | |
| 25054 | 25249 | break; |
| 25055 | 25250 | } |
| 25056 | 25251 | case 'f': { |
| 25057 | 25252 | double s = x.s; |
| 25058 | 25253 | if( s>59.999 ) s = 59.999; |
| 25059 | 25254 | sqlite3_str_appendf(&sRes, "%06.3f", s); |
| 25060 | 25255 | break; |
| 25061 | 25256 | } |
| 25062 | - case 'H': { | |
| 25063 | - sqlite3_str_appendf(&sRes, "%02d", x.h); | |
| 25257 | + case 'F': { | |
| 25258 | + sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D); | |
| 25259 | + break; | |
| 25260 | + } | |
| 25261 | + case 'H': | |
| 25262 | + case 'k': { | |
| 25263 | + sqlite3_str_appendf(&sRes, cf=='H' ? "%02d" : "%2d", x.h); | |
| 25264 | + break; | |
| 25265 | + } | |
| 25266 | + case 'I': /* Fall thru */ | |
| 25267 | + case 'l': { | |
| 25268 | + int h = x.h; | |
| 25269 | + if( h>12 ) h -= 12; | |
| 25270 | + if( h==0 ) h = 12; | |
| 25271 | + sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h); | |
| 25064 | 25272 | break; |
| 25065 | 25273 | } |
| 25066 | 25274 | case 'W': /* Fall thru */ |
| 25067 | 25275 | case 'j': { |
| 25068 | 25276 | int nDay; /* Number of days since 1st day of year */ |
| @@ -25070,11 +25278,11 @@ | ||
| 25070 | 25278 | y.validJD = 0; |
| 25071 | 25279 | y.M = 1; |
| 25072 | 25280 | y.D = 1; |
| 25073 | 25281 | computeJD(&y); |
| 25074 | 25282 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); |
| 25075 | - if( zFmt[i]=='W' ){ | |
| 25283 | + if( cf=='W' ){ | |
| 25076 | 25284 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ |
| 25077 | 25285 | wd = (int)(((x.iJD+43200000)/86400000)%7); |
| 25078 | 25286 | sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); |
| 25079 | 25287 | }else{ |
| 25080 | 25288 | sqlite3_str_appendf(&sRes,"%03d",nDay+1); |
| @@ -25090,10 +25298,23 @@ | ||
| 25090 | 25298 | break; |
| 25091 | 25299 | } |
| 25092 | 25300 | case 'M': { |
| 25093 | 25301 | sqlite3_str_appendf(&sRes,"%02d",x.m); |
| 25094 | 25302 | break; |
| 25303 | + } | |
| 25304 | + case 'p': /* Fall thru */ | |
| 25305 | + case 'P': { | |
| 25306 | + if( x.h>=12 ){ | |
| 25307 | + sqlite3_str_append(&sRes, cf=='p' ? "PM" : "pm", 2); | |
| 25308 | + }else{ | |
| 25309 | + sqlite3_str_append(&sRes, cf=='p' ? "AM" : "am", 2); | |
| 25310 | + } | |
| 25311 | + break; | |
| 25312 | + } | |
| 25313 | + case 'R': { | |
| 25314 | + sqlite3_str_appendf(&sRes, "%02d:%02d", x.h, x.m); | |
| 25315 | + break; | |
| 25095 | 25316 | } |
| 25096 | 25317 | case 's': { |
| 25097 | 25318 | if( x.useSubsec ){ |
| 25098 | 25319 | sqlite3_str_appendf(&sRes,"%.3f", |
| 25099 | 25320 | (x.iJD - 21086676*(i64)10000000)/1000.0); |
| @@ -25105,13 +25326,19 @@ | ||
| 25105 | 25326 | } |
| 25106 | 25327 | case 'S': { |
| 25107 | 25328 | sqlite3_str_appendf(&sRes,"%02d",(int)x.s); |
| 25108 | 25329 | break; |
| 25109 | 25330 | } |
| 25331 | + case 'T': { | |
| 25332 | + sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s); | |
| 25333 | + break; | |
| 25334 | + } | |
| 25335 | + case 'u': /* Fall thru */ | |
| 25110 | 25336 | case 'w': { |
| 25111 | - sqlite3_str_appendchar(&sRes, 1, | |
| 25112 | - (char)(((x.iJD+129600000)/86400000) % 7) + '0'); | |
| 25337 | + char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; | |
| 25338 | + if( c=='0' && cf=='u' ) c = '7'; | |
| 25339 | + sqlite3_str_appendchar(&sRes, 1, c); | |
| 25113 | 25340 | break; |
| 25114 | 25341 | } |
| 25115 | 25342 | case 'Y': { |
| 25116 | 25343 | sqlite3_str_appendf(&sRes,"%04d",x.Y); |
| 25117 | 25344 | break; |
| @@ -28196,11 +28423,11 @@ | ||
| 28196 | 28423 | static void checkMutexFree(sqlite3_mutex *p){ |
| 28197 | 28424 | assert( SQLITE_MUTEX_RECURSIVE<2 ); |
| 28198 | 28425 | assert( SQLITE_MUTEX_FAST<2 ); |
| 28199 | 28426 | assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); |
| 28200 | 28427 | |
| 28201 | -#if SQLITE_ENABLE_API_ARMOR | |
| 28428 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 28202 | 28429 | if( ((CheckMutex*)p)->iType<2 ) |
| 28203 | 28430 | #endif |
| 28204 | 28431 | { |
| 28205 | 28432 | CheckMutex *pCheck = (CheckMutex*)p; |
| 28206 | 28433 | pGlobalMutexMethods->xMutexFree(pCheck->mutex); |
| @@ -28868,11 +29095,11 @@ | ||
| 28868 | 29095 | ** allocated mutex. SQLite is careful to deallocate every |
| 28869 | 29096 | ** mutex that it allocates. |
| 28870 | 29097 | */ |
| 28871 | 29098 | static void pthreadMutexFree(sqlite3_mutex *p){ |
| 28872 | 29099 | assert( p->nRef==0 ); |
| 28873 | -#if SQLITE_ENABLE_API_ARMOR | |
| 29100 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 28874 | 29101 | if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) |
| 28875 | 29102 | #endif |
| 28876 | 29103 | { |
| 28877 | 29104 | pthread_mutex_destroy(&p->mutex); |
| 28878 | 29105 | sqlite3_free(p); |
| @@ -30432,11 +30659,11 @@ | ||
| 30432 | 30659 | assert( db!=0 ); |
| 30433 | 30660 | assert( sqlite3_mutex_held(db->mutex) ); |
| 30434 | 30661 | if( db->mallocFailed || rc ){ |
| 30435 | 30662 | return apiHandleError(db, rc); |
| 30436 | 30663 | } |
| 30437 | - return rc & db->errMask; | |
| 30664 | + return 0; | |
| 30438 | 30665 | } |
| 30439 | 30666 | |
| 30440 | 30667 | /************** End of malloc.c **********************************************/ |
| 30441 | 30668 | /************** Begin file printf.c ******************************************/ |
| 30442 | 30669 | /* |
| @@ -31828,11 +32055,11 @@ | ||
| 31828 | 32055 | |
| 31829 | 32056 | /* |
| 31830 | 32057 | ** Decrease the reference count by one. Free the string when the |
| 31831 | 32058 | ** reference count reaches zero. |
| 31832 | 32059 | */ |
| 31833 | -SQLITE_PRIVATE void sqlite3RCStrUnref(char *z){ | |
| 32060 | +SQLITE_PRIVATE void sqlite3RCStrUnref(void *z){ | |
| 31834 | 32061 | RCStr *p = (RCStr*)z; |
| 31835 | 32062 | assert( p!=0 ); |
| 31836 | 32063 | p--; |
| 31837 | 32064 | assert( p->nRCRef>0 ); |
| 31838 | 32065 | if( p->nRCRef>=2 ){ |
| @@ -32291,20 +32518,21 @@ | ||
| 32291 | 32518 | if( pWin==0 ) return; |
| 32292 | 32519 | if( pWin->pFilter ){ |
| 32293 | 32520 | sqlite3TreeViewItem(pView, "FILTER", 1); |
| 32294 | 32521 | sqlite3TreeViewExpr(pView, pWin->pFilter, 0); |
| 32295 | 32522 | sqlite3TreeViewPop(&pView); |
| 32523 | + if( pWin->eFrmType==TK_FILTER ) return; | |
| 32296 | 32524 | } |
| 32297 | 32525 | sqlite3TreeViewPush(&pView, more); |
| 32298 | 32526 | if( pWin->zName ){ |
| 32299 | 32527 | sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin); |
| 32300 | 32528 | }else{ |
| 32301 | 32529 | sqlite3TreeViewLine(pView, "OVER (%p)", pWin); |
| 32302 | 32530 | } |
| 32303 | 32531 | if( pWin->zBase ) nElement++; |
| 32304 | 32532 | if( pWin->pOrderBy ) nElement++; |
| 32305 | - if( pWin->eFrmType ) nElement++; | |
| 32533 | + if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ) nElement++; | |
| 32306 | 32534 | if( pWin->eExclude ) nElement++; |
| 32307 | 32535 | if( pWin->zBase ){ |
| 32308 | 32536 | sqlite3TreeViewPush(&pView, (--nElement)>0); |
| 32309 | 32537 | sqlite3TreeViewLine(pView, "window: %s", pWin->zBase); |
| 32310 | 32538 | sqlite3TreeViewPop(&pView); |
| @@ -32313,11 +32541,11 @@ | ||
| 32313 | 32541 | sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY"); |
| 32314 | 32542 | } |
| 32315 | 32543 | if( pWin->pOrderBy ){ |
| 32316 | 32544 | sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); |
| 32317 | 32545 | } |
| 32318 | - if( pWin->eFrmType ){ | |
| 32546 | + if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ){ | |
| 32319 | 32547 | char zBuf[30]; |
| 32320 | 32548 | const char *zFrmType = "ROWS"; |
| 32321 | 32549 | if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; |
| 32322 | 32550 | if( pWin->eFrmType==TK_GROUPS ) zFrmType = "GROUPS"; |
| 32323 | 32551 | sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType, |
| @@ -32561,11 +32789,11 @@ | ||
| 32561 | 32789 | pWin = 0; |
| 32562 | 32790 | }else{ |
| 32563 | 32791 | assert( ExprUseXList(pExpr) ); |
| 32564 | 32792 | pFarg = pExpr->x.pList; |
| 32565 | 32793 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32566 | - pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; | |
| 32794 | + pWin = IsWindowFunc(pExpr) ? pExpr->y.pWin : 0; | |
| 32567 | 32795 | #else |
| 32568 | 32796 | pWin = 0; |
| 32569 | 32797 | #endif |
| 32570 | 32798 | } |
| 32571 | 32799 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| @@ -32587,18 +32815,28 @@ | ||
| 32587 | 32815 | pExpr->u.zToken, zFlgs, zOp2); |
| 32588 | 32816 | }else{ |
| 32589 | 32817 | sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); |
| 32590 | 32818 | } |
| 32591 | 32819 | if( pFarg ){ |
| 32592 | - sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0); | |
| 32820 | + sqlite3TreeViewExprList(pView, pFarg, pWin!=0 || pExpr->pLeft, 0); | |
| 32821 | + if( pExpr->pLeft ){ | |
| 32822 | + Expr *pOB = pExpr->pLeft; | |
| 32823 | + assert( pOB->op==TK_ORDER ); | |
| 32824 | + assert( ExprUseXList(pOB) ); | |
| 32825 | + sqlite3TreeViewExprList(pView, pOB->x.pList, pWin!=0, "ORDERBY"); | |
| 32826 | + } | |
| 32593 | 32827 | } |
| 32594 | 32828 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32595 | 32829 | if( pWin ){ |
| 32596 | 32830 | sqlite3TreeViewWindow(pView, pWin, 0); |
| 32597 | 32831 | } |
| 32598 | 32832 | #endif |
| 32599 | 32833 | break; |
| 32834 | + } | |
| 32835 | + case TK_ORDER: { | |
| 32836 | + sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, "ORDERBY"); | |
| 32837 | + break; | |
| 32600 | 32838 | } |
| 32601 | 32839 | #ifndef SQLITE_OMIT_SUBQUERY |
| 32602 | 32840 | case TK_EXISTS: { |
| 32603 | 32841 | assert( ExprUseXSelect(pExpr) ); |
| 32604 | 32842 | sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags); |
| @@ -34360,16 +34598,20 @@ | ||
| 34360 | 34598 | if( AtomicLoad(&db->u1.isInterrupted) ){ |
| 34361 | 34599 | p->nErr++; |
| 34362 | 34600 | p->rc = SQLITE_INTERRUPT; |
| 34363 | 34601 | } |
| 34364 | 34602 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 34365 | - if( db->xProgress && (++p->nProgressSteps)>=db->nProgressOps ){ | |
| 34366 | - if( db->xProgress(db->pProgressArg) ){ | |
| 34367 | - p->nErr++; | |
| 34368 | - p->rc = SQLITE_INTERRUPT; | |
| 34603 | + if( db->xProgress ){ | |
| 34604 | + if( p->rc==SQLITE_INTERRUPT ){ | |
| 34605 | + p->nProgressSteps = 0; | |
| 34606 | + }else if( (++p->nProgressSteps)>=db->nProgressOps ){ | |
| 34607 | + if( db->xProgress(db->pProgressArg) ){ | |
| 34608 | + p->nErr++; | |
| 34609 | + p->rc = SQLITE_INTERRUPT; | |
| 34610 | + } | |
| 34611 | + p->nProgressSteps = 0; | |
| 34369 | 34612 | } |
| 34370 | - p->nProgressSteps = 0; | |
| 34371 | 34613 | } |
| 34372 | 34614 | #endif |
| 34373 | 34615 | } |
| 34374 | 34616 | |
| 34375 | 34617 | /* |
| @@ -35183,33 +35425,33 @@ | ||
| 35183 | 35425 | ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); |
| 35184 | 35426 | */ |
| 35185 | 35427 | double rr[2]; |
| 35186 | 35428 | rr[0] = r; |
| 35187 | 35429 | rr[1] = 0.0; |
| 35188 | - if( rr[0]>1.84e+19 ){ | |
| 35189 | - while( rr[0]>1.84e+119 ){ | |
| 35430 | + if( rr[0]>9.223372036854774784e+18 ){ | |
| 35431 | + while( rr[0]>9.223372036854774784e+118 ){ | |
| 35190 | 35432 | exp += 100; |
| 35191 | 35433 | dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); |
| 35192 | 35434 | } |
| 35193 | - while( rr[0]>1.84e+29 ){ | |
| 35435 | + while( rr[0]>9.223372036854774784e+28 ){ | |
| 35194 | 35436 | exp += 10; |
| 35195 | 35437 | dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); |
| 35196 | 35438 | } |
| 35197 | - while( rr[0]>1.84e+19 ){ | |
| 35439 | + while( rr[0]>9.223372036854774784e+18 ){ | |
| 35198 | 35440 | exp += 1; |
| 35199 | 35441 | dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); |
| 35200 | 35442 | } |
| 35201 | 35443 | }else{ |
| 35202 | - while( rr[0]<1.84e-82 ){ | |
| 35444 | + while( rr[0]<9.223372036854774784e-83 ){ | |
| 35203 | 35445 | exp -= 100; |
| 35204 | 35446 | dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); |
| 35205 | 35447 | } |
| 35206 | - while( rr[0]<1.84e+08 ){ | |
| 35448 | + while( rr[0]<9.223372036854774784e+07 ){ | |
| 35207 | 35449 | exp -= 10; |
| 35208 | 35450 | dekkerMul2(rr, 1.0e+10, 0.0); |
| 35209 | 35451 | } |
| 35210 | - while( rr[0]<1.84e+18 ){ | |
| 35452 | + while( rr[0]<9.22337203685477478e+17 ){ | |
| 35211 | 35453 | exp -= 1; |
| 35212 | 35454 | dekkerMul2(rr, 1.0e+01, 0.0); |
| 35213 | 35455 | } |
| 35214 | 35456 | } |
| 35215 | 35457 | v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1]; |
| @@ -35521,125 +35763,36 @@ | ||
| 35521 | 35763 | ** A MACRO version, getVarint32, is provided which inlines the |
| 35522 | 35764 | ** single-byte case. All code should use the MACRO version as |
| 35523 | 35765 | ** this function assumes the single-byte case has already been handled. |
| 35524 | 35766 | */ |
| 35525 | 35767 | SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ |
| 35526 | - u32 a,b; | |
| 35527 | - | |
| 35528 | - /* The 1-byte case. Overwhelmingly the most common. Handled inline | |
| 35529 | - ** by the getVarin32() macro */ | |
| 35530 | - a = *p; | |
| 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 | - | |
| 35541 | - /* The 2-byte case */ | |
| 35542 | - p++; | |
| 35543 | - b = *p; | |
| 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; | |
| 35768 | + u64 v64; | |
| 35769 | + u8 n; | |
| 35770 | + | |
| 35771 | + /* Assume that the single-byte case has already been handled by | |
| 35772 | + ** the getVarint32() macro */ | |
| 35773 | + assert( (p[0] & 0x80)!=0 ); | |
| 35774 | + | |
| 35775 | + if( (p[1] & 0x80)==0 ){ | |
| 35776 | + /* This is the two-byte case */ | |
| 35777 | + *v = ((p[0]&0x7f)<<7) | p[1]; | |
| 35551 | 35778 | return 2; |
| 35552 | 35779 | } |
| 35553 | - | |
| 35554 | - /* The 3-byte case */ | |
| 35555 | - p++; | |
| 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; | |
| 35780 | + if( (p[2] & 0x80)==0 ){ | |
| 35781 | + /* This is the three-byte case */ | |
| 35782 | + *v = ((p[0]&0x7f)<<14) | ((p[1]&0x7f)<<7) | p[2]; | |
| 35566 | 35783 | return 3; |
| 35567 | 35784 | } |
| 35568 | - | |
| 35569 | - /* A 32-bit varint is used to store size information in btrees. | |
| 35570 | - ** Objects are rarely larger than 2MiB limit of a 3-byte varint. | |
| 35571 | - ** A 3-byte varint is sufficient, for example, to record the size | |
| 35572 | - ** of a 1048569-byte BLOB or string. | |
| 35573 | - ** | |
| 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; | |
| 35638 | - return n; | |
| 35639 | - } | |
| 35640 | -#endif | |
| 35785 | + /* four or more bytes */ | |
| 35786 | + n = sqlite3GetVarint(p, &v64); | |
| 35787 | + assert( n>3 && n<=9 ); | |
| 35788 | + if( (v64 & SQLITE_MAX_U32)!=v64 ){ | |
| 35789 | + *v = 0xffffffff; | |
| 35790 | + }else{ | |
| 35791 | + *v = (u32)v64; | |
| 35792 | + } | |
| 35793 | + return n; | |
| 35641 | 35794 | } |
| 35642 | 35795 | |
| 35643 | 35796 | /* |
| 35644 | 35797 | ** Return the number of bytes that will be needed to store the given |
| 35645 | 35798 | ** 64-bit integer. |
| @@ -36631,23 +36784,24 @@ | ||
| 36631 | 36784 | /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 36632 | 36785 | /* 170 */ "VBegin" OpHelp(""), |
| 36633 | 36786 | /* 171 */ "VCreate" OpHelp(""), |
| 36634 | 36787 | /* 172 */ "VDestroy" OpHelp(""), |
| 36635 | 36788 | /* 173 */ "VOpen" OpHelp(""), |
| 36636 | - /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), | |
| 36637 | - /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | |
| 36638 | - /* 176 */ "VRename" OpHelp(""), | |
| 36639 | - /* 177 */ "Pagecount" OpHelp(""), | |
| 36640 | - /* 178 */ "MaxPgcnt" OpHelp(""), | |
| 36641 | - /* 179 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), | |
| 36642 | - /* 180 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), | |
| 36643 | - /* 181 */ "Trace" OpHelp(""), | |
| 36644 | - /* 182 */ "CursorHint" OpHelp(""), | |
| 36645 | - /* 183 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | |
| 36646 | - /* 184 */ "Noop" OpHelp(""), | |
| 36647 | - /* 185 */ "Explain" OpHelp(""), | |
| 36648 | - /* 186 */ "Abortable" OpHelp(""), | |
| 36789 | + /* 174 */ "VCheck" OpHelp(""), | |
| 36790 | + /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), | |
| 36791 | + /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | |
| 36792 | + /* 177 */ "VRename" OpHelp(""), | |
| 36793 | + /* 178 */ "Pagecount" OpHelp(""), | |
| 36794 | + /* 179 */ "MaxPgcnt" OpHelp(""), | |
| 36795 | + /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), | |
| 36796 | + /* 181 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), | |
| 36797 | + /* 182 */ "Trace" OpHelp(""), | |
| 36798 | + /* 183 */ "CursorHint" OpHelp(""), | |
| 36799 | + /* 184 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | |
| 36800 | + /* 185 */ "Noop" OpHelp(""), | |
| 36801 | + /* 186 */ "Explain" OpHelp(""), | |
| 36802 | + /* 187 */ "Abortable" OpHelp(""), | |
| 36649 | 36803 | }; |
| 36650 | 36804 | return azName[i]; |
| 36651 | 36805 | } |
| 36652 | 36806 | #endif |
| 36653 | 36807 | |
| @@ -57726,14 +57880,37 @@ | ||
| 57726 | 57880 | memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); |
| 57727 | 57881 | put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff); |
| 57728 | 57882 | }else{ |
| 57729 | 57883 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 57730 | 57884 | } |
| 57885 | + | |
| 57886 | + | |
| 57731 | 57887 | |
| 57732 | 57888 | /* The random check-hash initializer */ |
| 57733 | - sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); | |
| 57889 | + if( pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){ | |
| 57890 | + sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); | |
| 57891 | + } | |
| 57892 | +#ifdef SQLITE_DEBUG | |
| 57893 | + else{ | |
| 57894 | + /* The Pager.cksumInit variable is usually randomized above to protect | |
| 57895 | + ** against there being existing records in the journal file. This is | |
| 57896 | + ** dangerous, as following a crash they may be mistaken for records | |
| 57897 | + ** written by the current transaction and rolled back into the database | |
| 57898 | + ** file, causing corruption. The following assert statements verify | |
| 57899 | + ** that this is not required in "journal_mode=memory" mode, as in that | |
| 57900 | + ** case the journal file is always 0 bytes in size at this point. | |
| 57901 | + ** It is advantageous to avoid the sqlite3_randomness() call if possible | |
| 57902 | + ** as it takes the global PRNG mutex. */ | |
| 57903 | + i64 sz = 0; | |
| 57904 | + sqlite3OsFileSize(pPager->jfd, &sz); | |
| 57905 | + assert( sz==0 ); | |
| 57906 | + assert( pPager->journalOff==journalHdrOffset(pPager) ); | |
| 57907 | + assert( sqlite3JournalIsInMemory(pPager->jfd) ); | |
| 57908 | + } | |
| 57909 | +#endif | |
| 57734 | 57910 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 57911 | + | |
| 57735 | 57912 | /* The initial database size */ |
| 57736 | 57913 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 57737 | 57914 | /* The assumed sector size for this process */ |
| 57738 | 57915 | put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize); |
| 57739 | 57916 | |
| @@ -58373,10 +58550,13 @@ | ||
| 58373 | 58550 | pPager->setSuper = 0; |
| 58374 | 58551 | |
| 58375 | 58552 | return (rc==SQLITE_OK?rc2:rc); |
| 58376 | 58553 | } |
| 58377 | 58554 | |
| 58555 | +/* Forward reference */ | |
| 58556 | +static int pager_playback(Pager *pPager, int isHot); | |
| 58557 | + | |
| 58378 | 58558 | /* |
| 58379 | 58559 | ** Execute a rollback if a transaction is active and unlock the |
| 58380 | 58560 | ** database file. |
| 58381 | 58561 | ** |
| 58382 | 58562 | ** If the pager has already entered the ERROR state, do not attempt |
| @@ -58401,10 +58581,25 @@ | ||
| 58401 | 58581 | sqlite3EndBenignMalloc(); |
| 58402 | 58582 | }else if( !pPager->exclusiveMode ){ |
| 58403 | 58583 | assert( pPager->eState==PAGER_READER ); |
| 58404 | 58584 | pager_end_transaction(pPager, 0, 0); |
| 58405 | 58585 | } |
| 58586 | + }else if( pPager->eState==PAGER_ERROR | |
| 58587 | + && pPager->journalMode==PAGER_JOURNALMODE_MEMORY | |
| 58588 | + && isOpen(pPager->jfd) | |
| 58589 | + ){ | |
| 58590 | + /* Special case for a ROLLBACK due to I/O error with an in-memory | |
| 58591 | + ** journal: We have to rollback immediately, before the journal is | |
| 58592 | + ** closed, because once it is closed, all content is forgotten. */ | |
| 58593 | + int errCode = pPager->errCode; | |
| 58594 | + u8 eLock = pPager->eLock; | |
| 58595 | + pPager->eState = PAGER_OPEN; | |
| 58596 | + pPager->errCode = SQLITE_OK; | |
| 58597 | + pPager->eLock = EXCLUSIVE_LOCK; | |
| 58598 | + pager_playback(pPager, 1); | |
| 58599 | + pPager->errCode = errCode; | |
| 58600 | + pPager->eLock = eLock; | |
| 58406 | 58601 | } |
| 58407 | 58602 | pager_unlock(pPager); |
| 58408 | 58603 | } |
| 58409 | 58604 | |
| 58410 | 58605 | /* |
| @@ -61893,12 +62088,24 @@ | ||
| 61893 | 62088 | Pager *pPager, /* The pager open on the database file */ |
| 61894 | 62089 | Pgno pgno, /* Page number to fetch */ |
| 61895 | 62090 | DbPage **ppPage, /* Write a pointer to the page here */ |
| 61896 | 62091 | int flags /* PAGER_GET_XXX flags */ |
| 61897 | 62092 | ){ |
| 61898 | - /* printf("PAGE %u\n", pgno); fflush(stdout); */ | |
| 62093 | +#if 0 /* Trace page fetch by setting to 1 */ | |
| 62094 | + int rc; | |
| 62095 | + printf("PAGE %u\n", pgno); | |
| 62096 | + fflush(stdout); | |
| 62097 | + rc = pPager->xGet(pPager, pgno, ppPage, flags); | |
| 62098 | + if( rc ){ | |
| 62099 | + printf("PAGE %u failed with 0x%02x\n", pgno, rc); | |
| 62100 | + fflush(stdout); | |
| 62101 | + } | |
| 62102 | + return rc; | |
| 62103 | +#else | |
| 62104 | + /* Normal, high-speed version of sqlite3PagerGet() */ | |
| 61899 | 62105 | return pPager->xGet(pPager, pgno, ppPage, flags); |
| 62106 | +#endif | |
| 61900 | 62107 | } |
| 61901 | 62108 | |
| 61902 | 62109 | /* |
| 61903 | 62110 | ** Acquire a page if it is already in the in-memory cache. Do |
| 61904 | 62111 | ** not read the page from disk. Return a pointer to the page, |
| @@ -63581,11 +63788,11 @@ | ||
| 63581 | 63788 | }else if( state==PAGER_OPEN ){ |
| 63582 | 63789 | pager_unlock(pPager); |
| 63583 | 63790 | } |
| 63584 | 63791 | assert( state==pPager->eState ); |
| 63585 | 63792 | } |
| 63586 | - }else if( eMode==PAGER_JOURNALMODE_OFF ){ | |
| 63793 | + }else if( eMode==PAGER_JOURNALMODE_OFF || eMode==PAGER_JOURNALMODE_MEMORY ){ | |
| 63587 | 63794 | sqlite3OsClose(pPager->jfd); |
| 63588 | 63795 | } |
| 63589 | 63796 | } |
| 63590 | 63797 | |
| 63591 | 63798 | /* Return the new journal mode */ |
| @@ -69194,11 +69401,11 @@ | ||
| 69194 | 69401 | typedef struct IntegrityCk IntegrityCk; |
| 69195 | 69402 | struct IntegrityCk { |
| 69196 | 69403 | BtShared *pBt; /* The tree being checked out */ |
| 69197 | 69404 | Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ |
| 69198 | 69405 | u8 *aPgRef; /* 1 bit per page in the db (see above) */ |
| 69199 | - Pgno nPage; /* Number of pages in the database */ | |
| 69406 | + Pgno nCkPage; /* Pages in the database. 0 for partial check */ | |
| 69200 | 69407 | int mxErr; /* Stop accumulating errors when this reaches zero */ |
| 69201 | 69408 | int nErr; /* Number of messages written to zErrMsg so far */ |
| 69202 | 69409 | int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ |
| 69203 | 69410 | u32 nStep; /* Number of steps into the integrity_check process */ |
| 69204 | 69411 | const char *zPfx; /* Error message prefix */ |
| @@ -69527,11 +69734,10 @@ | ||
| 69527 | 69734 | |
| 69528 | 69735 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 69529 | 69736 | |
| 69530 | 69737 | /************** End of btmutex.c *********************************************/ |
| 69531 | 69738 | /************** Begin file btree.c *******************************************/ |
| 69532 | - | |
| 69533 | 69739 | /* |
| 69534 | 69740 | ** 2004 April 6 |
| 69535 | 69741 | ** |
| 69536 | 69742 | ** The author disclaims copyright to this source code. In place of |
| 69537 | 69743 | ** a legal notice, here is a blessing: |
| @@ -77022,13 +77228,14 @@ | ||
| 77022 | 77228 | u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager); |
| 77023 | 77229 | u8 *pData; |
| 77024 | 77230 | int k; /* Current slot in pCArray->apEnd[] */ |
| 77025 | 77231 | u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ |
| 77026 | 77232 | |
| 77233 | + assert( nCell>0 ); | |
| 77027 | 77234 | assert( i<iEnd ); |
| 77028 | 77235 | j = get2byte(&aData[hdr+5]); |
| 77029 | - if( NEVER(j>(u32)usableSize) ){ j = 0; } | |
| 77236 | + if( j>(u32)usableSize ){ j = 0; } | |
| 77030 | 77237 | memcpy(&pTmp[j], &aData[j], usableSize - j); |
| 77031 | 77238 | |
| 77032 | 77239 | for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} |
| 77033 | 77240 | pSrcEnd = pCArray->apEnd[k]; |
| 77034 | 77241 | |
| @@ -77328,10 +77535,11 @@ | ||
| 77328 | 77535 | #endif |
| 77329 | 77536 | |
| 77330 | 77537 | return SQLITE_OK; |
| 77331 | 77538 | editpage_fail: |
| 77332 | 77539 | /* Unable to edit this page. Rebuild it from scratch instead. */ |
| 77540 | + if( nNew<1 ) return SQLITE_CORRUPT_BKPT; | |
| 77333 | 77541 | populateCellCache(pCArray, iNew, nNew); |
| 77334 | 77542 | return rebuildPage(pCArray, iNew, nNew, pPg); |
| 77335 | 77543 | } |
| 77336 | 77544 | |
| 77337 | 77545 | |
| @@ -79987,19 +80195,19 @@ | ||
| 79987 | 80195 | /* |
| 79988 | 80196 | ** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that |
| 79989 | 80197 | ** corresponds to page iPg is already set. |
| 79990 | 80198 | */ |
| 79991 | 80199 | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 79992 | - assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); | |
| 80200 | + assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); | |
| 79993 | 80201 | return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); |
| 79994 | 80202 | } |
| 79995 | 80203 | |
| 79996 | 80204 | /* |
| 79997 | 80205 | ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. |
| 79998 | 80206 | */ |
| 79999 | 80207 | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80000 | - assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); | |
| 80208 | + assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); | |
| 80001 | 80209 | pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); |
| 80002 | 80210 | } |
| 80003 | 80211 | |
| 80004 | 80212 | |
| 80005 | 80213 | /* |
| @@ -80009,11 +80217,12 @@ | ||
| 80009 | 80217 | ** if this is the first reference to the page. |
| 80010 | 80218 | ** |
| 80011 | 80219 | ** Also check that the page number is in bounds. |
| 80012 | 80220 | */ |
| 80013 | 80221 | static int checkRef(IntegrityCk *pCheck, Pgno iPage){ |
| 80014 | - if( iPage>pCheck->nPage || iPage==0 ){ | |
| 80222 | + if( iPage>pCheck->nCkPage || iPage==0 ){ | |
| 80223 | + if( pCheck->nCkPage==0 ) return 0; /* omit reference counting */ | |
| 80015 | 80224 | checkAppendMsg(pCheck, "invalid page number %u", iPage); |
| 80016 | 80225 | return 1; |
| 80017 | 80226 | } |
| 80018 | 80227 | if( getPageReferenced(pCheck, iPage) ){ |
| 80019 | 80228 | checkAppendMsg(pCheck, "2nd reference to page %u", iPage); |
| @@ -80236,10 +80445,11 @@ | ||
| 80236 | 80445 | pCheck->zPfx = "Tree %u page %u: "; |
| 80237 | 80446 | pCheck->v1 = iPage; |
| 80238 | 80447 | if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ |
| 80239 | 80448 | checkAppendMsg(pCheck, |
| 80240 | 80449 | "unable to get the page. error code=%d", rc); |
| 80450 | + if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM; | |
| 80241 | 80451 | goto end_of_check; |
| 80242 | 80452 | } |
| 80243 | 80453 | |
| 80244 | 80454 | /* Clear MemPage.isInit to make sure the corruption detection code in |
| 80245 | 80455 | ** btreeInitPage() is executed. */ |
| @@ -80506,31 +80716,36 @@ | ||
| 80506 | 80716 | assert( nRef>=0 ); |
| 80507 | 80717 | memset(&sCheck, 0, sizeof(sCheck)); |
| 80508 | 80718 | sCheck.db = db; |
| 80509 | 80719 | sCheck.pBt = pBt; |
| 80510 | 80720 | sCheck.pPager = pBt->pPager; |
| 80511 | - sCheck.nPage = btreePagecount(sCheck.pBt); | |
| 80721 | + sCheck.nCkPage = btreePagecount(sCheck.pBt); | |
| 80512 | 80722 | sCheck.mxErr = mxErr; |
| 80513 | 80723 | sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); |
| 80514 | 80724 | sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; |
| 80515 | - if( sCheck.nPage==0 ){ | |
| 80725 | + if( sCheck.nCkPage==0 ){ | |
| 80516 | 80726 | goto integrity_ck_cleanup; |
| 80517 | 80727 | } |
| 80518 | 80728 | |
| 80519 | - sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1); | |
| 80520 | - if( !sCheck.aPgRef ){ | |
| 80521 | - checkOom(&sCheck); | |
| 80522 | - goto integrity_ck_cleanup; | |
| 80729 | + if( bPartial ){ | |
| 80730 | + sCheck.nCkPage = 0; | |
| 80731 | + sCheck.aPgRef = 0; | |
| 80732 | + }else{ | |
| 80733 | + sCheck.aPgRef = sqlite3MallocZero((sCheck.nCkPage / 8)+ 1); | |
| 80734 | + if( !sCheck.aPgRef ){ | |
| 80735 | + checkOom(&sCheck); | |
| 80736 | + goto integrity_ck_cleanup; | |
| 80737 | + } | |
| 80523 | 80738 | } |
| 80524 | 80739 | sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize ); |
| 80525 | 80740 | if( sCheck.heap==0 ){ |
| 80526 | 80741 | checkOom(&sCheck); |
| 80527 | 80742 | goto integrity_ck_cleanup; |
| 80528 | 80743 | } |
| 80529 | 80744 | |
| 80530 | 80745 | i = PENDING_BYTE_PAGE(pBt); |
| 80531 | - if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i); | |
| 80746 | + if( i<=sCheck.nCkPage ) setPageReferenced(&sCheck, i); | |
| 80532 | 80747 | |
| 80533 | 80748 | /* Check the integrity of the freelist |
| 80534 | 80749 | */ |
| 80535 | 80750 | if( bCkFreelist ){ |
| 80536 | 80751 | sCheck.zPfx = "Freelist: "; |
| @@ -80577,11 +80792,11 @@ | ||
| 80577 | 80792 | pBt->db->flags = savedDbFlags; |
| 80578 | 80793 | |
| 80579 | 80794 | /* Make sure every page in the file is referenced |
| 80580 | 80795 | */ |
| 80581 | 80796 | if( !bPartial ){ |
| 80582 | - for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){ | |
| 80797 | + for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){ | |
| 80583 | 80798 | #ifdef SQLITE_OMIT_AUTOVACUUM |
| 80584 | 80799 | if( getPageReferenced(&sCheck, i)==0 ){ |
| 80585 | 80800 | checkAppendMsg(&sCheck, "Page %u: never used", i); |
| 80586 | 80801 | } |
| 80587 | 80802 | #else |
| @@ -82018,11 +82233,11 @@ | ||
| 82018 | 82233 | ){ |
| 82019 | 82234 | pMem->z[pMem->n] = 0; |
| 82020 | 82235 | pMem->flags |= MEM_Term; |
| 82021 | 82236 | return; |
| 82022 | 82237 | } |
| 82023 | - if( pMem->xDel==(void(*)(void*))sqlite3RCStrUnref ){ | |
| 82238 | + if( pMem->xDel==sqlite3RCStrUnref ){ | |
| 82024 | 82239 | /* Blindly assume that all RCStr objects are zero-terminated */ |
| 82025 | 82240 | pMem->flags |= MEM_Term; |
| 82026 | 82241 | return; |
| 82027 | 82242 | } |
| 82028 | 82243 | }else if( pMem->szMalloc >= pMem->n+1 ){ |
| @@ -83398,10 +83613,11 @@ | ||
| 83398 | 83613 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 83399 | 83614 | pVal = valueNew(db, pCtx); |
| 83400 | 83615 | if( pVal ){ |
| 83401 | 83616 | pVal->flags = MEM_Int; |
| 83402 | 83617 | pVal->u.i = pExpr->u.zToken[4]==0; |
| 83618 | + sqlite3ValueApplyAffinity(pVal, affinity, enc); | |
| 83403 | 83619 | } |
| 83404 | 83620 | } |
| 83405 | 83621 | |
| 83406 | 83622 | *ppVal = pVal; |
| 83407 | 83623 | return rc; |
| @@ -84711,10 +84927,14 @@ | ||
| 84711 | 84927 | for(i=iFirst; i<=iLast; i++, pOp++){ |
| 84712 | 84928 | if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ){ |
| 84713 | 84929 | int iDest = pOp->p2; /* Jump destination */ |
| 84714 | 84930 | if( iDest==0 ) continue; |
| 84715 | 84931 | if( pOp->opcode==OP_Gosub ) continue; |
| 84932 | + if( pOp->p3==20230325 && pOp->opcode==OP_NotNull ){ | |
| 84933 | + /* This is a deliberately taken illegal branch. tag-20230325-2 */ | |
| 84934 | + continue; | |
| 84935 | + } | |
| 84716 | 84936 | if( iDest<0 ){ |
| 84717 | 84937 | int j = ADDR(iDest); |
| 84718 | 84938 | assert( j>=0 ); |
| 84719 | 84939 | if( j>=-pParse->nLabel || pParse->aLabel[j]<0 ){ |
| 84720 | 84940 | continue; |
| @@ -88170,36 +88390,45 @@ | ||
| 88170 | 88390 | c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1); |
| 88171 | 88391 | if( c ) return c; |
| 88172 | 88392 | return n1 - n2; |
| 88173 | 88393 | } |
| 88174 | 88394 | |
| 88395 | +/* The following two functions are used only within testcase() to prove | |
| 88396 | +** test coverage. These functions do no exist for production builds. | |
| 88397 | +** We must use separate SQLITE_NOINLINE functions here, since otherwise | |
| 88398 | +** optimizer code movement causes gcov to become very confused. | |
| 88399 | +*/ | |
| 88400 | +#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) | |
| 88401 | +static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; } | |
| 88402 | +static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; } | |
| 88403 | +#endif | |
| 88404 | + | |
| 88175 | 88405 | /* |
| 88176 | 88406 | ** Do a comparison between a 64-bit signed integer and a 64-bit floating-point |
| 88177 | 88407 | ** number. Return negative, zero, or positive if the first (i64) is less than, |
| 88178 | 88408 | ** equal to, or greater than the second (double). |
| 88179 | 88409 | */ |
| 88180 | 88410 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ |
| 88181 | - if( sizeof(LONGDOUBLE_TYPE)>8 ){ | |
| 88411 | + if( sqlite3Config.bUseLongDouble ){ | |
| 88182 | 88412 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; |
| 88183 | 88413 | testcase( x<r ); |
| 88184 | 88414 | testcase( x>r ); |
| 88185 | 88415 | testcase( x==r ); |
| 88186 | - if( x<r ) return -1; | |
| 88187 | - if( x>r ) return +1; /*NO_TEST*/ /* work around bugs in gcov */ | |
| 88188 | - return 0; /*NO_TEST*/ /* work around bugs in gcov */ | |
| 88416 | + return (x<r) ? -1 : (x>r); | |
| 88189 | 88417 | }else{ |
| 88190 | 88418 | i64 y; |
| 88191 | 88419 | double s; |
| 88192 | 88420 | if( r<-9223372036854775808.0 ) return +1; |
| 88193 | 88421 | if( r>=9223372036854775808.0 ) return -1; |
| 88194 | 88422 | y = (i64)r; |
| 88195 | 88423 | if( i<y ) return -1; |
| 88196 | 88424 | if( i>y ) return +1; |
| 88197 | 88425 | s = (double)i; |
| 88198 | - if( s<r ) return -1; | |
| 88199 | - if( s>r ) return +1; | |
| 88200 | - return 0; | |
| 88426 | + testcase( doubleLt(s,r) ); | |
| 88427 | + testcase( doubleLt(r,s) ); | |
| 88428 | + testcase( doubleEq(r,s) ); | |
| 88429 | + return (s<r) ? -1 : (s>r); | |
| 88201 | 88430 | } |
| 88202 | 88431 | } |
| 88203 | 88432 | |
| 88204 | 88433 | /* |
| 88205 | 88434 | ** Compare the values contained by the two memory cells, returning |
| @@ -89563,11 +89792,11 @@ | ||
| 89563 | 89792 | ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the |
| 89564 | 89793 | ** result as a string or blob. Appropriate errors are set if the string/blob |
| 89565 | 89794 | ** is too big or if an OOM occurs. |
| 89566 | 89795 | ** |
| 89567 | 89796 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() |
| 89568 | -** on value P is not going to be used and need to be destroyed. | |
| 89797 | +** on value P if P is not going to be used and need to be destroyed. | |
| 89569 | 89798 | */ |
| 89570 | 89799 | static void setResultStrOrError( |
| 89571 | 89800 | sqlite3_context *pCtx, /* Function context */ |
| 89572 | 89801 | const char *z, /* String pointer */ |
| 89573 | 89802 | int n, /* Bytes in string, or negative */ |
| @@ -89593,29 +89822,42 @@ | ||
| 89593 | 89822 | } |
| 89594 | 89823 | } |
| 89595 | 89824 | static int invokeValueDestructor( |
| 89596 | 89825 | const void *p, /* Value to destroy */ |
| 89597 | 89826 | void (*xDel)(void*), /* The destructor */ |
| 89598 | - sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if no NULL */ | |
| 89827 | + sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if not NULL */ | |
| 89599 | 89828 | ){ |
| 89600 | 89829 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89601 | 89830 | if( xDel==0 ){ |
| 89602 | 89831 | /* noop */ |
| 89603 | 89832 | }else if( xDel==SQLITE_TRANSIENT ){ |
| 89604 | 89833 | /* noop */ |
| 89605 | 89834 | }else{ |
| 89606 | 89835 | xDel((void*)p); |
| 89607 | 89836 | } |
| 89837 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89838 | + if( pCtx!=0 ){ | |
| 89839 | + sqlite3_result_error_toobig(pCtx); | |
| 89840 | + } | |
| 89841 | +#else | |
| 89842 | + assert( pCtx!=0 ); | |
| 89608 | 89843 | sqlite3_result_error_toobig(pCtx); |
| 89844 | +#endif | |
| 89609 | 89845 | return SQLITE_TOOBIG; |
| 89610 | 89846 | } |
| 89611 | 89847 | SQLITE_API void sqlite3_result_blob( |
| 89612 | 89848 | sqlite3_context *pCtx, |
| 89613 | 89849 | const void *z, |
| 89614 | 89850 | int n, |
| 89615 | 89851 | void (*xDel)(void *) |
| 89616 | 89852 | ){ |
| 89853 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89854 | + if( pCtx==0 || n<0 ){ | |
| 89855 | + invokeValueDestructor(z, xDel, pCtx); | |
| 89856 | + return; | |
| 89857 | + } | |
| 89858 | +#endif | |
| 89617 | 89859 | assert( n>=0 ); |
| 89618 | 89860 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89619 | 89861 | setResultStrOrError(pCtx, z, n, 0, xDel); |
| 89620 | 89862 | } |
| 89621 | 89863 | SQLITE_API void sqlite3_result_blob64( |
| @@ -89622,60 +89864,95 @@ | ||
| 89622 | 89864 | sqlite3_context *pCtx, |
| 89623 | 89865 | const void *z, |
| 89624 | 89866 | sqlite3_uint64 n, |
| 89625 | 89867 | void (*xDel)(void *) |
| 89626 | 89868 | ){ |
| 89627 | - assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | |
| 89628 | 89869 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89870 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89871 | + if( pCtx==0 ){ | |
| 89872 | + invokeValueDestructor(z, xDel, 0); | |
| 89873 | + return; | |
| 89874 | + } | |
| 89875 | +#endif | |
| 89876 | + assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); | |
| 89629 | 89877 | if( n>0x7fffffff ){ |
| 89630 | 89878 | (void)invokeValueDestructor(z, xDel, pCtx); |
| 89631 | 89879 | }else{ |
| 89632 | 89880 | setResultStrOrError(pCtx, z, (int)n, 0, xDel); |
| 89633 | 89881 | } |
| 89634 | 89882 | } |
| 89635 | 89883 | SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ |
| 89884 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89885 | + if( pCtx==0 ) return; | |
| 89886 | +#endif | |
| 89636 | 89887 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89637 | 89888 | sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); |
| 89638 | 89889 | } |
| 89639 | 89890 | SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ |
| 89891 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89892 | + if( pCtx==0 ) return; | |
| 89893 | +#endif | |
| 89640 | 89894 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89641 | 89895 | pCtx->isError = SQLITE_ERROR; |
| 89642 | 89896 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); |
| 89643 | 89897 | } |
| 89644 | 89898 | #ifndef SQLITE_OMIT_UTF16 |
| 89645 | 89899 | SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ |
| 89900 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89901 | + if( pCtx==0 ) return; | |
| 89902 | +#endif | |
| 89646 | 89903 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89647 | 89904 | pCtx->isError = SQLITE_ERROR; |
| 89648 | 89905 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); |
| 89649 | 89906 | } |
| 89650 | 89907 | #endif |
| 89651 | 89908 | SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ |
| 89909 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89910 | + if( pCtx==0 ) return; | |
| 89911 | +#endif | |
| 89652 | 89912 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89653 | 89913 | sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); |
| 89654 | 89914 | } |
| 89655 | 89915 | SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ |
| 89916 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89917 | + if( pCtx==0 ) return; | |
| 89918 | +#endif | |
| 89656 | 89919 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89657 | 89920 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 89658 | 89921 | } |
| 89659 | 89922 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 89923 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89924 | + if( pCtx==0 ) return; | |
| 89925 | +#endif | |
| 89660 | 89926 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89661 | 89927 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89662 | 89928 | } |
| 89663 | 89929 | SQLITE_API void sqlite3_result_pointer( |
| 89664 | 89930 | sqlite3_context *pCtx, |
| 89665 | 89931 | void *pPtr, |
| 89666 | 89932 | const char *zPType, |
| 89667 | 89933 | void (*xDestructor)(void*) |
| 89668 | 89934 | ){ |
| 89669 | - Mem *pOut = pCtx->pOut; | |
| 89935 | + Mem *pOut; | |
| 89936 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89937 | + if( pCtx==0 ){ | |
| 89938 | + invokeValueDestructor(pPtr, xDestructor, 0); | |
| 89939 | + return; | |
| 89940 | + } | |
| 89941 | +#endif | |
| 89942 | + pOut = pCtx->pOut; | |
| 89670 | 89943 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89671 | 89944 | sqlite3VdbeMemRelease(pOut); |
| 89672 | 89945 | pOut->flags = MEM_Null; |
| 89673 | 89946 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); |
| 89674 | 89947 | } |
| 89675 | 89948 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 89676 | - Mem *pOut = pCtx->pOut; | |
| 89949 | + Mem *pOut; | |
| 89950 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89951 | + if( pCtx==0 ) return; | |
| 89952 | +#endif | |
| 89953 | + pOut = pCtx->pOut; | |
| 89677 | 89954 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89678 | 89955 | pOut->eSubtype = eSubtype & 0xff; |
| 89679 | 89956 | pOut->flags |= MEM_Subtype; |
| 89680 | 89957 | } |
| 89681 | 89958 | SQLITE_API void sqlite3_result_text( |
| @@ -89682,10 +89959,16 @@ | ||
| 89682 | 89959 | sqlite3_context *pCtx, |
| 89683 | 89960 | const char *z, |
| 89684 | 89961 | int n, |
| 89685 | 89962 | void (*xDel)(void *) |
| 89686 | 89963 | ){ |
| 89964 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89965 | + if( pCtx==0 ){ | |
| 89966 | + invokeValueDestructor(z, xDel, 0); | |
| 89967 | + return; | |
| 89968 | + } | |
| 89969 | +#endif | |
| 89687 | 89970 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89688 | 89971 | setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); |
| 89689 | 89972 | } |
| 89690 | 89973 | SQLITE_API void sqlite3_result_text64( |
| 89691 | 89974 | sqlite3_context *pCtx, |
| @@ -89692,10 +89975,16 @@ | ||
| 89692 | 89975 | const char *z, |
| 89693 | 89976 | sqlite3_uint64 n, |
| 89694 | 89977 | void (*xDel)(void *), |
| 89695 | 89978 | unsigned char enc |
| 89696 | 89979 | ){ |
| 89980 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 89981 | + if( pCtx==0 ){ | |
| 89982 | + invokeValueDestructor(z, xDel, 0); | |
| 89983 | + return; | |
| 89984 | + } | |
| 89985 | +#endif | |
| 89697 | 89986 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89698 | 89987 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89699 | 89988 | if( enc!=SQLITE_UTF8 ){ |
| 89700 | 89989 | if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 89701 | 89990 | n &= ~(u64)1; |
| @@ -89735,11 +90024,20 @@ | ||
| 89735 | 90024 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89736 | 90025 | setResultStrOrError(pCtx, z, n & ~(u64)1, SQLITE_UTF16LE, xDel); |
| 89737 | 90026 | } |
| 89738 | 90027 | #endif /* SQLITE_OMIT_UTF16 */ |
| 89739 | 90028 | SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ |
| 89740 | - Mem *pOut = pCtx->pOut; | |
| 90029 | + Mem *pOut; | |
| 90030 | + | |
| 90031 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90032 | + if( pCtx==0 ) return; | |
| 90033 | + if( pValue==0 ){ | |
| 90034 | + sqlite3_result_null(pCtx); | |
| 90035 | + return; | |
| 90036 | + } | |
| 90037 | +#endif | |
| 90038 | + pOut = pCtx->pOut; | |
| 89741 | 90039 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89742 | 90040 | sqlite3VdbeMemCopy(pOut, pValue); |
| 89743 | 90041 | sqlite3VdbeChangeEncoding(pOut, pCtx->enc); |
| 89744 | 90042 | if( sqlite3VdbeMemTooBig(pOut) ){ |
| 89745 | 90043 | sqlite3_result_error_toobig(pCtx); |
| @@ -89747,11 +90045,16 @@ | ||
| 89747 | 90045 | } |
| 89748 | 90046 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ |
| 89749 | 90047 | sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); |
| 89750 | 90048 | } |
| 89751 | 90049 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ |
| 89752 | - Mem *pOut = pCtx->pOut; | |
| 90050 | + Mem *pOut; | |
| 90051 | + | |
| 90052 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90053 | + if( pCtx==0 ) return SQLITE_MISUSE_BKPT; | |
| 90054 | +#endif | |
| 90055 | + pOut = pCtx->pOut; | |
| 89753 | 90056 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89754 | 90057 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 89755 | 90058 | sqlite3_result_error_toobig(pCtx); |
| 89756 | 90059 | return SQLITE_TOOBIG; |
| 89757 | 90060 | } |
| @@ -89761,10 +90064,13 @@ | ||
| 89761 | 90064 | #else |
| 89762 | 90065 | return sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 89763 | 90066 | #endif |
| 89764 | 90067 | } |
| 89765 | 90068 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 90069 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90070 | + if( pCtx==0 ) return; | |
| 90071 | +#endif | |
| 89766 | 90072 | pCtx->isError = errCode ? errCode : -1; |
| 89767 | 90073 | #ifdef SQLITE_DEBUG |
| 89768 | 90074 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| 89769 | 90075 | #endif |
| 89770 | 90076 | if( pCtx->pOut->flags & MEM_Null ){ |
| @@ -89773,18 +90079,24 @@ | ||
| 89773 | 90079 | } |
| 89774 | 90080 | } |
| 89775 | 90081 | |
| 89776 | 90082 | /* Force an SQLITE_TOOBIG error. */ |
| 89777 | 90083 | SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ |
| 90084 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90085 | + if( pCtx==0 ) return; | |
| 90086 | +#endif | |
| 89778 | 90087 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89779 | 90088 | pCtx->isError = SQLITE_TOOBIG; |
| 89780 | 90089 | sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, |
| 89781 | 90090 | SQLITE_UTF8, SQLITE_STATIC); |
| 89782 | 90091 | } |
| 89783 | 90092 | |
| 89784 | 90093 | /* An SQLITE_NOMEM error. */ |
| 89785 | 90094 | SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ |
| 90095 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90096 | + if( pCtx==0 ) return; | |
| 90097 | +#endif | |
| 89786 | 90098 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89787 | 90099 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89788 | 90100 | pCtx->isError = SQLITE_NOMEM_BKPT; |
| 89789 | 90101 | sqlite3OomFault(pCtx->pOut->db); |
| 89790 | 90102 | } |
| @@ -90033,11 +90345,15 @@ | ||
| 90033 | 90345 | /* |
| 90034 | 90346 | ** Extract the user data from a sqlite3_context structure and return a |
| 90035 | 90347 | ** pointer to it. |
| 90036 | 90348 | */ |
| 90037 | 90349 | SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ |
| 90350 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90351 | + if( p==0 ) return 0; | |
| 90352 | +#else | |
| 90038 | 90353 | assert( p && p->pFunc ); |
| 90354 | +#endif | |
| 90039 | 90355 | return p->pFunc->pUserData; |
| 90040 | 90356 | } |
| 90041 | 90357 | |
| 90042 | 90358 | /* |
| 90043 | 90359 | ** Extract the user data from a sqlite3_context structure and return a |
| @@ -90048,11 +90364,15 @@ | ||
| 90048 | 90364 | ** parameter) of the sqlite3_create_function() and |
| 90049 | 90365 | ** sqlite3_create_function16() routines that originally registered the |
| 90050 | 90366 | ** application defined function. |
| 90051 | 90367 | */ |
| 90052 | 90368 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ |
| 90369 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90370 | + if( p==0 ) return 0; | |
| 90371 | +#else | |
| 90053 | 90372 | assert( p && p->pOut ); |
| 90373 | +#endif | |
| 90054 | 90374 | return p->pOut->db; |
| 90055 | 90375 | } |
| 90056 | 90376 | |
| 90057 | 90377 | /* |
| 90058 | 90378 | ** If this routine is invoked from within an xColumn method of a virtual |
| @@ -90067,11 +90387,15 @@ | ||
| 90067 | 90387 | ** Virtual table implements might use this routine to optimize their |
| 90068 | 90388 | ** performance by substituting a NULL result, or some other light-weight |
| 90069 | 90389 | ** value, as a signal to the xUpdate routine that the column is unchanged. |
| 90070 | 90390 | */ |
| 90071 | 90391 | SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ |
| 90392 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90393 | + if( p==0 ) return 0; | |
| 90394 | +#else | |
| 90072 | 90395 | assert( p ); |
| 90396 | +#endif | |
| 90073 | 90397 | return sqlite3_value_nochange(p->pOut); |
| 90074 | 90398 | } |
| 90075 | 90399 | |
| 90076 | 90400 | /* |
| 90077 | 90401 | ** The destructor function for a ValueList object. This needs to be |
| @@ -90095,11 +90419,11 @@ | ||
| 90095 | 90419 | ){ |
| 90096 | 90420 | int rc; |
| 90097 | 90421 | ValueList *pRhs; |
| 90098 | 90422 | |
| 90099 | 90423 | *ppOut = 0; |
| 90100 | - if( pVal==0 ) return SQLITE_MISUSE; | |
| 90424 | + if( pVal==0 ) return SQLITE_MISUSE_BKPT; | |
| 90101 | 90425 | if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ |
| 90102 | 90426 | return SQLITE_ERROR; |
| 90103 | 90427 | }else{ |
| 90104 | 90428 | assert( (pVal->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) == |
| 90105 | 90429 | (MEM_Null|MEM_Term|MEM_Subtype) ); |
| @@ -90226,10 +90550,13 @@ | ||
| 90226 | 90550 | ** single prepared statement. The iArg values must match. |
| 90227 | 90551 | */ |
| 90228 | 90552 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 90229 | 90553 | AuxData *pAuxData; |
| 90230 | 90554 | |
| 90555 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90556 | + if( pCtx==0 ) return 0; | |
| 90557 | +#endif | |
| 90231 | 90558 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90232 | 90559 | #if SQLITE_ENABLE_STAT4 |
| 90233 | 90560 | if( pCtx->pVdbe==0 ) return 0; |
| 90234 | 90561 | #else |
| 90235 | 90562 | assert( pCtx->pVdbe!=0 ); |
| @@ -90258,12 +90585,16 @@ | ||
| 90258 | 90585 | int iArg, |
| 90259 | 90586 | void *pAux, |
| 90260 | 90587 | void (*xDelete)(void*) |
| 90261 | 90588 | ){ |
| 90262 | 90589 | AuxData *pAuxData; |
| 90263 | - Vdbe *pVdbe = pCtx->pVdbe; | |
| 90590 | + Vdbe *pVdbe; | |
| 90264 | 90591 | |
| 90592 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 90593 | + if( pCtx==0 ) return; | |
| 90594 | +#endif | |
| 90595 | + pVdbe= pCtx->pVdbe; | |
| 90265 | 90596 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90266 | 90597 | #ifdef SQLITE_ENABLE_STAT4 |
| 90267 | 90598 | if( pVdbe==0 ) goto failed; |
| 90268 | 90599 | #else |
| 90269 | 90600 | assert( pVdbe!=0 ); |
| @@ -90696,11 +91027,11 @@ | ||
| 90696 | 91027 | if( vdbeSafetyNotNull(p) ){ |
| 90697 | 91028 | return SQLITE_MISUSE_BKPT; |
| 90698 | 91029 | } |
| 90699 | 91030 | sqlite3_mutex_enter(p->db->mutex); |
| 90700 | 91031 | if( p->eVdbeState!=VDBE_READY_STATE ){ |
| 90701 | - sqlite3Error(p->db, SQLITE_MISUSE); | |
| 91032 | + sqlite3Error(p->db, SQLITE_MISUSE_BKPT); | |
| 90702 | 91033 | sqlite3_mutex_leave(p->db->mutex); |
| 90703 | 91034 | sqlite3_log(SQLITE_MISUSE, |
| 90704 | 91035 | "bind on a busy prepared statement: [%s]", p->zSql); |
| 90705 | 91036 | return SQLITE_MISUSE_BKPT; |
| 90706 | 91037 | } |
| @@ -90925,10 +91256,13 @@ | ||
| 90925 | 91256 | return rc; |
| 90926 | 91257 | } |
| 90927 | 91258 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| 90928 | 91259 | int rc; |
| 90929 | 91260 | Vdbe *p = (Vdbe *)pStmt; |
| 91261 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91262 | + if( p==0 ) return SQLITE_MISUSE_BKPT; | |
| 91263 | +#endif | |
| 90930 | 91264 | sqlite3_mutex_enter(p->db->mutex); |
| 90931 | 91265 | if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 90932 | 91266 | rc = SQLITE_TOOBIG; |
| 90933 | 91267 | }else{ |
| 90934 | 91268 | assert( (n & 0x7FFFFFFF)==n ); |
| @@ -91051,10 +91385,13 @@ | ||
| 91051 | 91385 | ** Set the explain mode for a statement. |
| 91052 | 91386 | */ |
| 91053 | 91387 | SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ |
| 91054 | 91388 | Vdbe *v = (Vdbe*)pStmt; |
| 91055 | 91389 | int rc; |
| 91390 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91391 | + if( pStmt==0 ) return SQLITE_MISUSE_BKPT; | |
| 91392 | +#endif | |
| 91056 | 91393 | sqlite3_mutex_enter(v->db->mutex); |
| 91057 | 91394 | if( ((int)v->explain)==eMode ){ |
| 91058 | 91395 | rc = SQLITE_OK; |
| 91059 | 91396 | }else if( eMode<0 || eMode>2 ){ |
| 91060 | 91397 | rc = SQLITE_ERROR; |
| @@ -91217,14 +91554,20 @@ | ||
| 91217 | 91554 | /* |
| 91218 | 91555 | ** This function is called from within a pre-update callback to retrieve |
| 91219 | 91556 | ** a field of the row currently being updated or deleted. |
| 91220 | 91557 | */ |
| 91221 | 91558 | SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91222 | - PreUpdate *p = db->pPreUpdate; | |
| 91559 | + PreUpdate *p; | |
| 91223 | 91560 | Mem *pMem; |
| 91224 | 91561 | int rc = SQLITE_OK; |
| 91225 | 91562 | |
| 91563 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91564 | + if( db==0 || ppValue==0 ){ | |
| 91565 | + return SQLITE_MISUSE_BKPT; | |
| 91566 | + } | |
| 91567 | +#endif | |
| 91568 | + p = db->pPreUpdate; | |
| 91226 | 91569 | /* Test that this call is being made from within an SQLITE_DELETE or |
| 91227 | 91570 | ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ |
| 91228 | 91571 | if( !p || p->op==SQLITE_INSERT ){ |
| 91229 | 91572 | rc = SQLITE_MISUSE_BKPT; |
| 91230 | 91573 | goto preupdate_old_out; |
| @@ -91281,11 +91624,16 @@ | ||
| 91281 | 91624 | /* |
| 91282 | 91625 | ** This function is called from within a pre-update callback to retrieve |
| 91283 | 91626 | ** the number of columns in the row being updated, deleted or inserted. |
| 91284 | 91627 | */ |
| 91285 | 91628 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ |
| 91286 | - PreUpdate *p = db->pPreUpdate; | |
| 91629 | + PreUpdate *p; | |
| 91630 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91631 | + p = db!=0 ? db->pPreUpdate : 0; | |
| 91632 | +#else | |
| 91633 | + p = db->pPreUpdate; | |
| 91634 | +#endif | |
| 91287 | 91635 | return (p ? p->keyinfo.nKeyField : 0); |
| 91288 | 91636 | } |
| 91289 | 91637 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 91290 | 91638 | |
| 91291 | 91639 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91299,11 +91647,16 @@ | ||
| 91299 | 91647 | ** |
| 91300 | 91648 | ** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL |
| 91301 | 91649 | ** or SET DEFAULT action is considered a trigger. |
| 91302 | 91650 | */ |
| 91303 | 91651 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ |
| 91304 | - PreUpdate *p = db->pPreUpdate; | |
| 91652 | + PreUpdate *p; | |
| 91653 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91654 | + p = db!=0 ? db->pPreUpdate : 0; | |
| 91655 | +#else | |
| 91656 | + p = db->pPreUpdate; | |
| 91657 | +#endif | |
| 91305 | 91658 | return (p ? p->v->nFrame : 0); |
| 91306 | 91659 | } |
| 91307 | 91660 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 91308 | 91661 | |
| 91309 | 91662 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91310,11 +91663,16 @@ | ||
| 91310 | 91663 | /* |
| 91311 | 91664 | ** This function is designed to be called from within a pre-update callback |
| 91312 | 91665 | ** only. |
| 91313 | 91666 | */ |
| 91314 | 91667 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ |
| 91315 | - PreUpdate *p = db->pPreUpdate; | |
| 91668 | + PreUpdate *p; | |
| 91669 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91670 | + p = db!=0 ? db->pPreUpdate : 0; | |
| 91671 | +#else | |
| 91672 | + p = db->pPreUpdate; | |
| 91673 | +#endif | |
| 91316 | 91674 | return (p ? p->iBlobWrite : -1); |
| 91317 | 91675 | } |
| 91318 | 91676 | #endif |
| 91319 | 91677 | |
| 91320 | 91678 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91321,14 +91679,20 @@ | ||
| 91321 | 91679 | /* |
| 91322 | 91680 | ** This function is called from within a pre-update callback to retrieve |
| 91323 | 91681 | ** a field of the row currently being updated or inserted. |
| 91324 | 91682 | */ |
| 91325 | 91683 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91326 | - PreUpdate *p = db->pPreUpdate; | |
| 91684 | + PreUpdate *p; | |
| 91327 | 91685 | int rc = SQLITE_OK; |
| 91328 | 91686 | Mem *pMem; |
| 91329 | 91687 | |
| 91688 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91689 | + if( db==0 || ppValue==0 ){ | |
| 91690 | + return SQLITE_MISUSE_BKPT; | |
| 91691 | + } | |
| 91692 | +#endif | |
| 91693 | + p = db->pPreUpdate; | |
| 91330 | 91694 | if( !p || p->op==SQLITE_DELETE ){ |
| 91331 | 91695 | rc = SQLITE_MISUSE_BKPT; |
| 91332 | 91696 | goto preupdate_new_out; |
| 91333 | 91697 | } |
| 91334 | 91698 | if( p->pPk && p->op!=SQLITE_UPDATE ){ |
| @@ -91403,15 +91767,24 @@ | ||
| 91403 | 91767 | int iScanStatusOp, /* Which metric to return */ |
| 91404 | 91768 | int flags, |
| 91405 | 91769 | void *pOut /* OUT: Write the answer here */ |
| 91406 | 91770 | ){ |
| 91407 | 91771 | Vdbe *p = (Vdbe*)pStmt; |
| 91408 | - VdbeOp *aOp = p->aOp; | |
| 91409 | - int nOp = p->nOp; | |
| 91772 | + VdbeOp *aOp; | |
| 91773 | + int nOp; | |
| 91410 | 91774 | ScanStatus *pScan = 0; |
| 91411 | 91775 | int idx; |
| 91412 | 91776 | |
| 91777 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 91778 | + if( p==0 || pOut==0 | |
| 91779 | + || iScanStatusOp<SQLITE_SCANSTAT_NLOOP | |
| 91780 | + || iScanStatusOp>SQLITE_SCANSTAT_NCYCLE ){ | |
| 91781 | + return 1; | |
| 91782 | + } | |
| 91783 | +#endif | |
| 91784 | + aOp = p->aOp; | |
| 91785 | + nOp = p->nOp; | |
| 91413 | 91786 | if( p->pFrame ){ |
| 91414 | 91787 | VdbeFrame *pFrame; |
| 91415 | 91788 | for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); |
| 91416 | 91789 | aOp = pFrame->aOp; |
| 91417 | 91790 | nOp = pFrame->nOp; |
| @@ -91554,11 +91927,11 @@ | ||
| 91554 | 91927 | ** Zero all counters associated with the sqlite3_stmt_scanstatus() data. |
| 91555 | 91928 | */ |
| 91556 | 91929 | SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ |
| 91557 | 91930 | Vdbe *p = (Vdbe*)pStmt; |
| 91558 | 91931 | int ii; |
| 91559 | - for(ii=0; ii<p->nOp; ii++){ | |
| 91932 | + for(ii=0; p!=0 && ii<p->nOp; ii++){ | |
| 91560 | 91933 | Op *pOp = &p->aOp[ii]; |
| 91561 | 91934 | pOp->nExec = 0; |
| 91562 | 91935 | pOp->nCycle = 0; |
| 91563 | 91936 | } |
| 91564 | 91937 | } |
| @@ -92523,15 +92896,15 @@ | ||
| 92523 | 92896 | } |
| 92524 | 92897 | assert( t>=12 ); |
| 92525 | 92898 | sqlite3RCStrRef(pBuf); |
| 92526 | 92899 | if( t&1 ){ |
| 92527 | 92900 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, |
| 92528 | - (void(*)(void*))sqlite3RCStrUnref); | |
| 92901 | + sqlite3RCStrUnref); | |
| 92529 | 92902 | pDest->flags |= MEM_Term; |
| 92530 | 92903 | }else{ |
| 92531 | 92904 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, |
| 92532 | - (void(*)(void*))sqlite3RCStrUnref); | |
| 92905 | + sqlite3RCStrUnref); | |
| 92533 | 92906 | } |
| 92534 | 92907 | }else{ |
| 92535 | 92908 | rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); |
| 92536 | 92909 | if( rc ) return rc; |
| 92537 | 92910 | sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); |
| @@ -95402,24 +95775,28 @@ | ||
| 95402 | 95775 | *(zHdr++) = serial_type; |
| 95403 | 95776 | if( serial_type==0 ){ |
| 95404 | 95777 | /* NULL value. No change in zPayload */ |
| 95405 | 95778 | }else{ |
| 95406 | 95779 | u64 v; |
| 95407 | - u32 i; | |
| 95408 | 95780 | if( serial_type==7 ){ |
| 95409 | 95781 | assert( sizeof(v)==sizeof(pRec->u.r) ); |
| 95410 | 95782 | memcpy(&v, &pRec->u.r, sizeof(v)); |
| 95411 | 95783 | swapMixedEndianFloat(v); |
| 95412 | 95784 | }else{ |
| 95413 | 95785 | v = pRec->u.i; |
| 95414 | 95786 | } |
| 95415 | - len = i = sqlite3SmallTypeSizes[serial_type]; | |
| 95416 | - assert( i>0 ); | |
| 95417 | - while( 1 /*exit-by-break*/ ){ | |
| 95418 | - zPayload[--i] = (u8)(v&0xFF); | |
| 95419 | - if( i==0 ) break; | |
| 95420 | - v >>= 8; | |
| 95787 | + len = sqlite3SmallTypeSizes[serial_type]; | |
| 95788 | + assert( len>=1 && len<=8 && len!=5 && len!=7 ); | |
| 95789 | + switch( len ){ | |
| 95790 | + default: zPayload[7] = (u8)(v&0xff); v >>= 8; | |
| 95791 | + zPayload[6] = (u8)(v&0xff); v >>= 8; | |
| 95792 | + case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; | |
| 95793 | + zPayload[4] = (u8)(v&0xff); v >>= 8; | |
| 95794 | + case 4: zPayload[3] = (u8)(v&0xff); v >>= 8; | |
| 95795 | + case 3: zPayload[2] = (u8)(v&0xff); v >>= 8; | |
| 95796 | + case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; | |
| 95797 | + case 1: zPayload[0] = (u8)(v&0xff); | |
| 95421 | 95798 | } |
| 95422 | 95799 | zPayload += len; |
| 95423 | 95800 | } |
| 95424 | 95801 | }else if( serial_type<0x80 ){ |
| 95425 | 95802 | *(zHdr++) = serial_type; |
| @@ -97532,12 +97909,17 @@ | ||
| 97532 | 97909 | ** delete is one of several associated with deleting a table row and |
| 97533 | 97910 | ** all its associated index entries. Exactly one of those deletes is |
| 97534 | 97911 | ** the "primary" delete. The others are all on OPFLAG_FORDELETE |
| 97535 | 97912 | ** cursors or else are marked with the AUXDELETE flag. |
| 97536 | 97913 | ** |
| 97537 | -** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row | |
| 97538 | -** change count is incremented (otherwise not). | |
| 97914 | +** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then | |
| 97915 | +** the row change count is incremented (otherwise not). | |
| 97916 | +** | |
| 97917 | +** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the | |
| 97918 | +** pre-update-hook for deletes is run, but the btree is otherwise unchanged. | |
| 97919 | +** This happens when the OP_Delete is to be shortly followed by an OP_Insert | |
| 97920 | +** with the same key, causing the btree entry to be overwritten. | |
| 97539 | 97921 | ** |
| 97540 | 97922 | ** P1 must not be pseudo-table. It has to be a real table with |
| 97541 | 97923 | ** multiple rows. |
| 97542 | 97924 | ** |
| 97543 | 97925 | ** If P4 is not NULL then it points to a Table object. In this case either |
| @@ -98658,17 +99040,37 @@ | ||
| 98658 | 99040 | } |
| 98659 | 99041 | |
| 98660 | 99042 | /* Opcode: SqlExec * * * P4 * |
| 98661 | 99043 | ** |
| 98662 | 99044 | ** Run the SQL statement or statements specified in the P4 string. |
| 99045 | +** Disable Auth and Trace callbacks while those statements are running if | |
| 99046 | +** P1 is true. | |
| 98663 | 99047 | */ |
| 98664 | 99048 | case OP_SqlExec: { |
| 99049 | + char *zErr; | |
| 99050 | + sqlite3_xauth xAuth; | |
| 99051 | + u8 mTrace; | |
| 99052 | + | |
| 98665 | 99053 | sqlite3VdbeIncrWriteCounter(p, 0); |
| 98666 | 99054 | db->nSqlExec++; |
| 98667 | - rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0); | |
| 99055 | + zErr = 0; | |
| 99056 | + xAuth = db->xAuth; | |
| 99057 | + mTrace = db->mTrace; | |
| 99058 | + if( pOp->p1 ){ | |
| 99059 | + db->xAuth = 0; | |
| 99060 | + db->mTrace = 0; | |
| 99061 | + } | |
| 99062 | + rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr); | |
| 98668 | 99063 | db->nSqlExec--; |
| 98669 | - if( rc ) goto abort_due_to_error; | |
| 99064 | + db->xAuth = xAuth; | |
| 99065 | + db->mTrace = mTrace; | |
| 99066 | + if( zErr || rc ){ | |
| 99067 | + sqlite3VdbeError(p, "%s", zErr); | |
| 99068 | + sqlite3_free(zErr); | |
| 99069 | + if( rc==SQLITE_NOMEM ) goto no_mem; | |
| 99070 | + goto abort_due_to_error; | |
| 99071 | + } | |
| 98670 | 99072 | break; |
| 98671 | 99073 | } |
| 98672 | 99074 | |
| 98673 | 99075 | /* Opcode: ParseSchema P1 * * P4 * |
| 98674 | 99076 | ** |
| @@ -99885,10 +100287,54 @@ | ||
| 99885 | 100287 | } |
| 99886 | 100288 | break; |
| 99887 | 100289 | } |
| 99888 | 100290 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 99889 | 100291 | |
| 100292 | +#ifndef SQLITE_OMIT_VIRTUALTABLE | |
| 100293 | +/* Opcode: VCheck * P2 * P4 * | |
| 100294 | +** | |
| 100295 | +** P4 is a pointer to a Table object that is a virtual table that | |
| 100296 | +** supports the xIntegrity() method. This opcode runs the xIntegrity() | |
| 100297 | +** method for that virtual table. If an error is reported back, the error | |
| 100298 | +** message is stored in register P2. If no errors are seen, register P2 | |
| 100299 | +** is set to NULL. | |
| 100300 | +*/ | |
| 100301 | +case OP_VCheck: { /* out2 */ | |
| 100302 | + Table *pTab; | |
| 100303 | + sqlite3_vtab *pVtab; | |
| 100304 | + const sqlite3_module *pModule; | |
| 100305 | + char *zErr = 0; | |
| 100306 | + | |
| 100307 | + pOut = &aMem[pOp->p2]; | |
| 100308 | + sqlite3VdbeMemSetNull(pOut); /* Innocent until proven guilty */ | |
| 100309 | + assert( pOp->p4type==P4_TABLE ); | |
| 100310 | + pTab = pOp->p4.pTab; | |
| 100311 | + assert( pTab!=0 ); | |
| 100312 | + assert( IsVirtual(pTab) ); | |
| 100313 | + assert( pTab->u.vtab.p!=0 ); | |
| 100314 | + pVtab = pTab->u.vtab.p->pVtab; | |
| 100315 | + assert( pVtab!=0 ); | |
| 100316 | + pModule = pVtab->pModule; | |
| 100317 | + assert( pModule!=0 ); | |
| 100318 | + assert( pModule->iVersion>=4 ); | |
| 100319 | + assert( pModule->xIntegrity!=0 ); | |
| 100320 | + pTab->nTabRef++; | |
| 100321 | + sqlite3VtabLock(pTab->u.vtab.p); | |
| 100322 | + rc = pModule->xIntegrity(pVtab, &zErr); | |
| 100323 | + sqlite3VtabUnlock(pTab->u.vtab.p); | |
| 100324 | + sqlite3DeleteTable(db, pTab); | |
| 100325 | + if( rc ){ | |
| 100326 | + sqlite3_free(zErr); | |
| 100327 | + goto abort_due_to_error; | |
| 100328 | + } | |
| 100329 | + if( zErr ){ | |
| 100330 | + sqlite3VdbeMemSetStr(pOut, zErr, -1, SQLITE_UTF8, sqlite3_free); | |
| 100331 | + } | |
| 100332 | + break; | |
| 100333 | +} | |
| 100334 | +#endif /* SQLITE_OMIT_VIRTUALTABLE */ | |
| 100335 | + | |
| 99890 | 100336 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 99891 | 100337 | /* Opcode: VInitIn P1 P2 P3 * * |
| 99892 | 100338 | ** Synopsis: r[P2]=ValueList(P1,P3) |
| 99893 | 100339 | ** |
| 99894 | 100340 | ** Set register P2 to be a pointer to a ValueList object for cursor P1 |
| @@ -100831,12 +101277,11 @@ | ||
| 100831 | 101277 | Vdbe *v = (Vdbe *)p->pStmt; |
| 100832 | 101278 | |
| 100833 | 101279 | /* Set the value of register r[1] in the SQL statement to integer iRow. |
| 100834 | 101280 | ** This is done directly as a performance optimization |
| 100835 | 101281 | */ |
| 100836 | - v->aMem[1].flags = MEM_Int; | |
| 100837 | - v->aMem[1].u.i = iRow; | |
| 101282 | + sqlite3VdbeMemSetInt64(&v->aMem[1], iRow); | |
| 100838 | 101283 | |
| 100839 | 101284 | /* If the statement has been run before (and is paused at the OP_ResultRow) |
| 100840 | 101285 | ** then back it up to the point where it does the OP_NotExists. This could |
| 100841 | 101286 | ** have been down with an extra OP_Goto, but simply setting the program |
| 100842 | 101287 | ** counter is faster. */ |
| @@ -100915,11 +101360,11 @@ | ||
| 100915 | 101360 | return SQLITE_MISUSE_BKPT; |
| 100916 | 101361 | } |
| 100917 | 101362 | #endif |
| 100918 | 101363 | *ppBlob = 0; |
| 100919 | 101364 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 100920 | - if( !sqlite3SafetyCheckOk(db) || zTable==0 ){ | |
| 101365 | + if( !sqlite3SafetyCheckOk(db) || zTable==0 || zColumn==0 ){ | |
| 100921 | 101366 | return SQLITE_MISUSE_BKPT; |
| 100922 | 101367 | } |
| 100923 | 101368 | #endif |
| 100924 | 101369 | wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */ |
| 100925 | 101370 | |
| @@ -101477,11 +101922,11 @@ | ||
| 101477 | 101922 | ** are connected using SorterRecord.u.iNext. |
| 101478 | 101923 | */ |
| 101479 | 101924 | struct SorterList { |
| 101480 | 101925 | SorterRecord *pList; /* Linked list of records */ |
| 101481 | 101926 | u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ |
| 101482 | - int szPMA; /* Size of pList as PMA in bytes */ | |
| 101927 | + i64 szPMA; /* Size of pList as PMA in bytes */ | |
| 101483 | 101928 | }; |
| 101484 | 101929 | |
| 101485 | 101930 | /* |
| 101486 | 101931 | ** The MergeEngine object is used to combine two or more smaller PMAs into |
| 101487 | 101932 | ** one big PMA using a merge operation. Separate PMAs all need to be |
| @@ -101586,14 +102031,14 @@ | ||
| 101586 | 102031 | */ |
| 101587 | 102032 | typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int); |
| 101588 | 102033 | struct SortSubtask { |
| 101589 | 102034 | SQLiteThread *pThread; /* Background thread, if any */ |
| 101590 | 102035 | int bDone; /* Set if thread is finished but not joined */ |
| 102036 | + int nPMA; /* Number of PMAs currently in file */ | |
| 101591 | 102037 | VdbeSorter *pSorter; /* Sorter that owns this sub-task */ |
| 101592 | 102038 | UnpackedRecord *pUnpacked; /* Space to unpack a record */ |
| 101593 | 102039 | SorterList list; /* List for thread to write to a PMA */ |
| 101594 | - int nPMA; /* Number of PMAs currently in file */ | |
| 101595 | 102040 | SorterCompare xCompare; /* Compare function to use */ |
| 101596 | 102041 | SorterFile file; /* Temp file for level-0 PMAs */ |
| 101597 | 102042 | SorterFile file2; /* Space for other PMAs */ |
| 101598 | 102043 | }; |
| 101599 | 102044 | |
| @@ -103063,12 +103508,12 @@ | ||
| 103063 | 103508 | ){ |
| 103064 | 103509 | VdbeSorter *pSorter; |
| 103065 | 103510 | int rc = SQLITE_OK; /* Return Code */ |
| 103066 | 103511 | SorterRecord *pNew; /* New list element */ |
| 103067 | 103512 | int bFlush; /* True to flush contents of memory to PMA */ |
| 103068 | - int nReq; /* Bytes of memory required */ | |
| 103069 | - int nPMA; /* Bytes of PMA space required */ | |
| 103513 | + i64 nReq; /* Bytes of memory required */ | |
| 103514 | + i64 nPMA; /* Bytes of PMA space required */ | |
| 103070 | 103515 | int t; /* serial type of first record field */ |
| 103071 | 103516 | |
| 103072 | 103517 | assert( pCsr->eCurType==CURTYPE_SORTER ); |
| 103073 | 103518 | pSorter = pCsr->uc.pSorter; |
| 103074 | 103519 | getVarint32NR((const u8*)&pVal->z[1], t); |
| @@ -104488,11 +104933,12 @@ | ||
| 104488 | 104933 | /* xFindMethod */ 0, |
| 104489 | 104934 | /* xRename */ 0, |
| 104490 | 104935 | /* xSavepoint */ 0, |
| 104491 | 104936 | /* xRelease */ 0, |
| 104492 | 104937 | /* xRollbackTo */ 0, |
| 104493 | - /* xShadowName */ 0 | |
| 104938 | + /* xShadowName */ 0, | |
| 104939 | + /* xIntegrity */ 0 | |
| 104494 | 104940 | }; |
| 104495 | 104941 | |
| 104496 | 104942 | |
| 104497 | 104943 | SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3 *db){ |
| 104498 | 104944 | int rc; |
| @@ -105317,25 +105763,40 @@ | ||
| 105317 | 105763 | sqlite3ExprDeferredDelete(pParse, pDup); |
| 105318 | 105764 | } |
| 105319 | 105765 | } |
| 105320 | 105766 | |
| 105321 | 105767 | /* |
| 105322 | -** Subqueries stores the original database, table and column names for their | |
| 105323 | -** 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, | |
| 105325 | -** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will | |
| 105326 | -** match anything. | |
| 105768 | +** Subqueries store the original database, table and column names for their | |
| 105769 | +** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN", | |
| 105770 | +** and mark the expression-list item by setting ExprList.a[].fg.eEName | |
| 105771 | +** to ENAME_TAB. | |
| 105772 | +** | |
| 105773 | +** Check to see if the zSpan/eEName of the expression-list item passed to this | |
| 105774 | +** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are | |
| 105775 | +** NULL then those fields will match anything. Return true if there is a match, | |
| 105776 | +** or false otherwise. | |
| 105777 | +** | |
| 105778 | +** SF_NestedFrom subqueries also store an entry for the implicit rowid (or | |
| 105779 | +** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID, | |
| 105780 | +** and setting zSpan to "DATABASE.TABLE.<rowid-alias>". This type of pItem | |
| 105781 | +** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid) | |
| 105782 | +** is set to 1 if there is this kind of match. | |
| 105327 | 105783 | */ |
| 105328 | 105784 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 105329 | 105785 | const struct ExprList_item *pItem, |
| 105330 | 105786 | const char *zCol, |
| 105331 | 105787 | const char *zTab, |
| 105332 | - const char *zDb | |
| 105788 | + const char *zDb, | |
| 105789 | + int *pbRowid | |
| 105333 | 105790 | ){ |
| 105334 | 105791 | int n; |
| 105335 | 105792 | const char *zSpan; |
| 105336 | - if( pItem->fg.eEName!=ENAME_TAB ) return 0; | |
| 105793 | + int eEName = pItem->fg.eEName; | |
| 105794 | + if( eEName!=ENAME_TAB && (eEName!=ENAME_ROWID || NEVER(pbRowid==0)) ){ | |
| 105795 | + return 0; | |
| 105796 | + } | |
| 105797 | + assert( pbRowid==0 || *pbRowid==0 ); | |
| 105337 | 105798 | zSpan = pItem->zEName; |
| 105338 | 105799 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105339 | 105800 | if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ |
| 105340 | 105801 | return 0; |
| 105341 | 105802 | } |
| @@ -105343,13 +105804,15 @@ | ||
| 105343 | 105804 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105344 | 105805 | if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){ |
| 105345 | 105806 | return 0; |
| 105346 | 105807 | } |
| 105347 | 105808 | zSpan += n+1; |
| 105348 | - if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){ | |
| 105349 | - return 0; | |
| 105809 | + if( zCol ){ | |
| 105810 | + if( eEName==ENAME_TAB && sqlite3StrICmp(zSpan, zCol)!=0 ) return 0; | |
| 105811 | + if( eEName==ENAME_ROWID && sqlite3IsRowid(zCol)==0 ) return 0; | |
| 105350 | 105812 | } |
| 105813 | + if( eEName==ENAME_ROWID ) *pbRowid = 1; | |
| 105351 | 105814 | return 1; |
| 105352 | 105815 | } |
| 105353 | 105816 | |
| 105354 | 105817 | /* |
| 105355 | 105818 | ** Return TRUE if the double-quoted string mis-feature should be supported. |
| @@ -105478,11 +105941,11 @@ | ||
| 105478 | 105941 | NameContext *pNC, /* The name context used to resolve the name */ |
| 105479 | 105942 | Expr *pExpr /* Make this EXPR node point to the selected column */ |
| 105480 | 105943 | ){ |
| 105481 | 105944 | int i, j; /* Loop counters */ |
| 105482 | 105945 | int cnt = 0; /* Number of matching column names */ |
| 105483 | - int cntTab = 0; /* Number of matching table names */ | |
| 105946 | + int cntTab = 0; /* Number of potential "rowid" matches */ | |
| 105484 | 105947 | int nSubquery = 0; /* How many levels of subquery */ |
| 105485 | 105948 | sqlite3 *db = pParse->db; /* The database connection */ |
| 105486 | 105949 | SrcItem *pItem; /* Use for looping over pSrcList items */ |
| 105487 | 105950 | SrcItem *pMatch = 0; /* The matching pSrcList item */ |
| 105488 | 105951 | NameContext *pTopNC = pNC; /* First namecontext in the list */ |
| @@ -105555,43 +106018,53 @@ | ||
| 105555 | 106018 | assert( pItem->pSelect!=0 ); |
| 105556 | 106019 | pEList = pItem->pSelect->pEList; |
| 105557 | 106020 | assert( pEList!=0 ); |
| 105558 | 106021 | assert( pEList->nExpr==pTab->nCol ); |
| 105559 | 106022 | for(j=0; j<pEList->nExpr; j++){ |
| 105560 | - if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ | |
| 105561 | - continue; | |
| 105562 | - } | |
| 105563 | - if( cnt>0 ){ | |
| 105564 | - if( pItem->fg.isUsing==0 | |
| 105565 | - || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 | |
| 105566 | - ){ | |
| 105567 | - /* Two or more tables have the same column name which is | |
| 105568 | - ** not joined by USING. This is an error. Signal as much | |
| 105569 | - ** by clearing pFJMatch and letting cnt go above 1. */ | |
| 105570 | - sqlite3ExprListDelete(db, pFJMatch); | |
| 105571 | - pFJMatch = 0; | |
| 105572 | - }else | |
| 105573 | - if( (pItem->fg.jointype & JT_RIGHT)==0 ){ | |
| 105574 | - /* An INNER or LEFT JOIN. Use the left-most table */ | |
| 105575 | - continue; | |
| 105576 | - }else | |
| 105577 | - if( (pItem->fg.jointype & JT_LEFT)==0 ){ | |
| 105578 | - /* A RIGHT JOIN. Use the right-most table */ | |
| 105579 | - cnt = 0; | |
| 105580 | - sqlite3ExprListDelete(db, pFJMatch); | |
| 105581 | - pFJMatch = 0; | |
| 105582 | - }else{ | |
| 105583 | - /* For a FULL JOIN, we must construct a coalesce() func */ | |
| 105584 | - extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); | |
| 105585 | - } | |
| 105586 | - } | |
| 105587 | - cnt++; | |
| 105588 | - cntTab = 2; | |
| 106023 | + int bRowid = 0; /* True if possible rowid match */ | |
| 106024 | + if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb, &bRowid) ){ | |
| 106025 | + continue; | |
| 106026 | + } | |
| 106027 | + if( bRowid==0 ){ | |
| 106028 | + if( cnt>0 ){ | |
| 106029 | + if( pItem->fg.isUsing==0 | |
| 106030 | + || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 | |
| 106031 | + ){ | |
| 106032 | + /* Two or more tables have the same column name which is | |
| 106033 | + ** not joined by USING. This is an error. Signal as much | |
| 106034 | + ** by clearing pFJMatch and letting cnt go above 1. */ | |
| 106035 | + sqlite3ExprListDelete(db, pFJMatch); | |
| 106036 | + pFJMatch = 0; | |
| 106037 | + }else | |
| 106038 | + if( (pItem->fg.jointype & JT_RIGHT)==0 ){ | |
| 106039 | + /* An INNER or LEFT JOIN. Use the left-most table */ | |
| 106040 | + continue; | |
| 106041 | + }else | |
| 106042 | + if( (pItem->fg.jointype & JT_LEFT)==0 ){ | |
| 106043 | + /* A RIGHT JOIN. Use the right-most table */ | |
| 106044 | + cnt = 0; | |
| 106045 | + sqlite3ExprListDelete(db, pFJMatch); | |
| 106046 | + pFJMatch = 0; | |
| 106047 | + }else{ | |
| 106048 | + /* For a FULL JOIN, we must construct a coalesce() func */ | |
| 106049 | + extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); | |
| 106050 | + } | |
| 106051 | + } | |
| 106052 | + cnt++; | |
| 106053 | + hit = 1; | |
| 106054 | + }else if( cnt>0 ){ | |
| 106055 | + /* This is a potential rowid match, but there has already been | |
| 106056 | + ** a real match found. So this can be ignored. */ | |
| 106057 | + continue; | |
| 106058 | + } | |
| 106059 | + cntTab++; | |
| 105589 | 106060 | pMatch = pItem; |
| 105590 | 106061 | pExpr->iColumn = j; |
| 105591 | 106062 | pEList->a[j].fg.bUsed = 1; |
| 105592 | - hit = 1; | |
| 106063 | + | |
| 106064 | + /* rowid cannot be part of a USING clause - assert() this. */ | |
| 106065 | + assert( bRowid==0 || pEList->a[j].fg.bUsingTerm==0 ); | |
| 105593 | 106066 | if( pEList->a[j].fg.bUsingTerm ) break; |
| 105594 | 106067 | } |
| 105595 | 106068 | if( hit || zTab==0 ) continue; |
| 105596 | 106069 | } |
| 105597 | 106070 | assert( zDb==0 || zTab!=0 ); |
| @@ -105782,14 +106255,14 @@ | ||
| 105782 | 106255 | if( cnt==0 |
| 105783 | 106256 | && cntTab==1 |
| 105784 | 106257 | && pMatch |
| 105785 | 106258 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 |
| 105786 | 106259 | && sqlite3IsRowid(zCol) |
| 105787 | - && ALWAYS(VisibleRowid(pMatch->pTab)) | |
| 106260 | + && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) | |
| 105788 | 106261 | ){ |
| 105789 | 106262 | cnt = 1; |
| 105790 | - pExpr->iColumn = -1; | |
| 106263 | + if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; | |
| 105791 | 106264 | pExpr->affExpr = SQLITE_AFF_INTEGER; |
| 105792 | 106265 | } |
| 105793 | 106266 | |
| 105794 | 106267 | /* |
| 105795 | 106268 | ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z |
| @@ -106238,10 +106711,11 @@ | ||
| 106238 | 106711 | int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin)); |
| 106239 | 106712 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106240 | 106713 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); |
| 106241 | 106714 | #endif |
| 106242 | 106715 | assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); |
| 106716 | + assert( pExpr->pLeft==0 || pExpr->pLeft->op==TK_ORDER ); | |
| 106243 | 106717 | zId = pExpr->u.zToken; |
| 106244 | 106718 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 106245 | 106719 | if( pDef==0 ){ |
| 106246 | 106720 | pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| 106247 | 106721 | if( pDef==0 ){ |
| @@ -106379,10 +106853,14 @@ | ||
| 106379 | 106853 | pExpr |
| 106380 | 106854 | ); |
| 106381 | 106855 | pNC->nNcErr++; |
| 106382 | 106856 | } |
| 106383 | 106857 | #endif |
| 106858 | + else if( is_agg==0 && pExpr->pLeft ){ | |
| 106859 | + sqlite3ExprOrderByAggregateError(pParse, pExpr); | |
| 106860 | + pNC->nNcErr++; | |
| 106861 | + } | |
| 106384 | 106862 | if( is_agg ){ |
| 106385 | 106863 | /* Window functions may not be arguments of aggregate functions. |
| 106386 | 106864 | ** Or arguments of other window functions. But aggregate functions |
| 106387 | 106865 | ** may be arguments for window functions. */ |
| 106388 | 106866 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -106397,10 +106875,15 @@ | ||
| 106397 | 106875 | is_agg = 1; |
| 106398 | 106876 | } |
| 106399 | 106877 | #endif |
| 106400 | 106878 | sqlite3WalkExprList(pWalker, pList); |
| 106401 | 106879 | if( is_agg ){ |
| 106880 | + if( pExpr->pLeft ){ | |
| 106881 | + assert( pExpr->pLeft->op==TK_ORDER ); | |
| 106882 | + assert( ExprUseXList(pExpr->pLeft) ); | |
| 106883 | + sqlite3WalkExprList(pWalker, pExpr->pLeft->x.pList); | |
| 106884 | + } | |
| 106402 | 106885 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106403 | 106886 | if( pWin ){ |
| 106404 | 106887 | Select *pSel = pNC->pWinSelect; |
| 106405 | 106888 | assert( pWin==0 || (ExprUseYWin(pExpr) && pWin==pExpr->y.pWin) ); |
| 106406 | 106889 | if( IN_RENAME_OBJECT==0 ){ |
| @@ -106960,13 +107443,11 @@ | ||
| 106960 | 107443 | nCompound = 0; |
| 106961 | 107444 | pLeftmost = p; |
| 106962 | 107445 | while( p ){ |
| 106963 | 107446 | assert( (p->selFlags & SF_Expanded)!=0 ); |
| 106964 | 107447 | assert( (p->selFlags & SF_Resolved)==0 ); |
| 106965 | - assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */ | |
| 106966 | 107448 | p->selFlags |= SF_Resolved; |
| 106967 | - | |
| 106968 | 107449 | |
| 106969 | 107450 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These |
| 106970 | 107451 | ** are not allowed to refer to any names, so pass an empty NameContext. |
| 106971 | 107452 | */ |
| 106972 | 107453 | memset(&sNC, 0, sizeof(sNC)); |
| @@ -107969,10 +108450,11 @@ | ||
| 107969 | 108450 | ** with the same pLeft pointer to the pVector, but only one of them |
| 107970 | 108451 | ** will own the pVector. |
| 107971 | 108452 | */ |
| 107972 | 108453 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); |
| 107973 | 108454 | if( pRet ){ |
| 108455 | + ExprSetProperty(pRet, EP_FullSize); | |
| 107974 | 108456 | pRet->iTable = nField; |
| 107975 | 108457 | pRet->iColumn = iField; |
| 107976 | 108458 | pRet->pLeft = pVector; |
| 107977 | 108459 | } |
| 107978 | 108460 | }else{ |
| @@ -108558,10 +109040,73 @@ | ||
| 108558 | 109040 | assert( ExprUseXList(pNew) ); |
| 108559 | 109041 | sqlite3ExprSetHeightAndFlags(pParse, pNew); |
| 108560 | 109042 | if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct); |
| 108561 | 109043 | return pNew; |
| 108562 | 109044 | } |
| 109045 | + | |
| 109046 | +/* | |
| 109047 | +** Report an error when attempting to use an ORDER BY clause within | |
| 109048 | +** the arguments of a non-aggregate function. | |
| 109049 | +*/ | |
| 109050 | +SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse *pParse, Expr *p){ | |
| 109051 | + sqlite3ErrorMsg(pParse, | |
| 109052 | + "ORDER BY may not be used with non-aggregate %#T()", p | |
| 109053 | + ); | |
| 109054 | +} | |
| 109055 | + | |
| 109056 | +/* | |
| 109057 | +** Attach an ORDER BY clause to a function call. | |
| 109058 | +** | |
| 109059 | +** functionname( arguments ORDER BY sortlist ) | |
| 109060 | +** \_____________________/ \______/ | |
| 109061 | +** pExpr pOrderBy | |
| 109062 | +** | |
| 109063 | +** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER | |
| 109064 | +** and added to the Expr.pLeft field of the parent TK_FUNCTION node. | |
| 109065 | +*/ | |
| 109066 | +SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy( | |
| 109067 | + Parse *pParse, /* Parsing context */ | |
| 109068 | + Expr *pExpr, /* The function call to which ORDER BY is to be added */ | |
| 109069 | + ExprList *pOrderBy /* The ORDER BY clause to add */ | |
| 109070 | +){ | |
| 109071 | + Expr *pOB; | |
| 109072 | + sqlite3 *db = pParse->db; | |
| 109073 | + if( NEVER(pOrderBy==0) ){ | |
| 109074 | + assert( db->mallocFailed ); | |
| 109075 | + return; | |
| 109076 | + } | |
| 109077 | + if( pExpr==0 ){ | |
| 109078 | + assert( db->mallocFailed ); | |
| 109079 | + sqlite3ExprListDelete(db, pOrderBy); | |
| 109080 | + return; | |
| 109081 | + } | |
| 109082 | + assert( pExpr->op==TK_FUNCTION ); | |
| 109083 | + assert( pExpr->pLeft==0 ); | |
| 109084 | + assert( ExprUseXList(pExpr) ); | |
| 109085 | + if( pExpr->x.pList==0 || NEVER(pExpr->x.pList->nExpr==0) ){ | |
| 109086 | + /* Ignore ORDER BY on zero-argument aggregates */ | |
| 109087 | + sqlite3ParserAddCleanup(pParse, | |
| 109088 | + (void(*)(sqlite3*,void*))sqlite3ExprListDelete, | |
| 109089 | + pOrderBy); | |
| 109090 | + return; | |
| 109091 | + } | |
| 109092 | + if( IsWindowFunc(pExpr) ){ | |
| 109093 | + sqlite3ExprOrderByAggregateError(pParse, pExpr); | |
| 109094 | + sqlite3ExprListDelete(db, pOrderBy); | |
| 109095 | + return; | |
| 109096 | + } | |
| 109097 | + | |
| 109098 | + pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0); | |
| 109099 | + if( pOB==0 ){ | |
| 109100 | + sqlite3ExprListDelete(db, pOrderBy); | |
| 109101 | + return; | |
| 109102 | + } | |
| 109103 | + pOB->x.pList = pOrderBy; | |
| 109104 | + assert( ExprUseXList(pOB) ); | |
| 109105 | + pExpr->pLeft = pOB; | |
| 109106 | + ExprSetProperty(pOB, EP_FullSize); | |
| 109107 | +} | |
| 108563 | 109108 | |
| 108564 | 109109 | /* |
| 108565 | 109110 | ** Check to see if a function is usable according to current access |
| 108566 | 109111 | ** rules: |
| 108567 | 109112 | ** |
| @@ -108812,15 +109357,11 @@ | ||
| 108812 | 109357 | static int dupedExprStructSize(const Expr *p, int flags){ |
| 108813 | 109358 | int nSize; |
| 108814 | 109359 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ |
| 108815 | 109360 | assert( EXPR_FULLSIZE<=0xfff ); |
| 108816 | 109361 | assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); |
| 108817 | - if( 0==flags || p->op==TK_SELECT_COLUMN | |
| 108818 | -#ifndef SQLITE_OMIT_WINDOWFUNC | |
| 108819 | - || ExprHasProperty(p, EP_WinFunc) | |
| 108820 | -#endif | |
| 108821 | - ){ | |
| 109362 | + if( 0==flags || ExprHasProperty(p, EP_FullSize) ){ | |
| 108822 | 109363 | nSize = EXPR_FULLSIZE; |
| 108823 | 109364 | }else{ |
| 108824 | 109365 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| 108825 | 109366 | assert( !ExprHasProperty(p, EP_OuterON) ); |
| 108826 | 109367 | assert( !ExprHasVVAProperty(p, EP_NoReduce) ); |
| @@ -108847,84 +109388,123 @@ | ||
| 108847 | 109388 | return ROUND8(nByte); |
| 108848 | 109389 | } |
| 108849 | 109390 | |
| 108850 | 109391 | /* |
| 108851 | 109392 | ** Return the number of bytes required to create a duplicate of the |
| 108852 | -** expression passed as the first argument. The second argument is a | |
| 108853 | -** mask containing EXPRDUP_XXX flags. | |
| 109393 | +** expression passed as the first argument. | |
| 108854 | 109394 | ** |
| 108855 | 109395 | ** The value returned includes space to create a copy of the Expr struct |
| 108856 | 109396 | ** itself and the buffer referred to by Expr.u.zToken, if any. |
| 108857 | 109397 | ** |
| 108858 | -** If the EXPRDUP_REDUCE flag is set, then the return value includes | |
| 108859 | -** space to duplicate all Expr nodes in the tree formed by Expr.pLeft | |
| 108860 | -** and Expr.pRight variables (but not for any structures pointed to or | |
| 108861 | -** descended from the Expr.x.pList or Expr.x.pSelect variables). | |
| 109398 | +** The return value includes space to duplicate all Expr nodes in the | |
| 109399 | +** tree formed by Expr.pLeft and Expr.pRight, but not any other | |
| 109400 | +** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin. | |
| 108862 | 109401 | */ |
| 108863 | -static int dupedExprSize(const Expr *p, int flags){ | |
| 108864 | - int nByte = 0; | |
| 108865 | - if( p ){ | |
| 108866 | - nByte = dupedExprNodeSize(p, flags); | |
| 108867 | - if( flags&EXPRDUP_REDUCE ){ | |
| 108868 | - nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags); | |
| 108869 | - } | |
| 108870 | - } | |
| 109402 | +static int dupedExprSize(const Expr *p){ | |
| 109403 | + int nByte; | |
| 109404 | + assert( p!=0 ); | |
| 109405 | + nByte = dupedExprNodeSize(p, EXPRDUP_REDUCE); | |
| 109406 | + if( p->pLeft ) nByte += dupedExprSize(p->pLeft); | |
| 109407 | + if( p->pRight ) nByte += dupedExprSize(p->pRight); | |
| 108871 | 109408 | return nByte; |
| 108872 | 109409 | } |
| 108873 | 109410 | |
| 108874 | 109411 | /* |
| 108875 | -** This function is similar to sqlite3ExprDup(), except that if pzBuffer | |
| 108876 | -** is not NULL then *pzBuffer is assumed to point to a buffer large enough | |
| 108877 | -** to store the copy of expression p, the copies of p->u.zToken | |
| 108878 | -** (if applicable), and the copies of the p->pLeft and p->pRight expressions, | |
| 108879 | -** if any. Before returning, *pzBuffer is set to the first byte past the | |
| 108880 | -** portion of the buffer copied into by this function. | |
| 109412 | +** An EdupBuf is a memory allocation used to stored multiple Expr objects | |
| 109413 | +** together with their Expr.zToken content. This is used to help implement | |
| 109414 | +** compression while doing sqlite3ExprDup(). The top-level Expr does the | |
| 109415 | +** allocation for itself and many of its decendents, then passes an instance | |
| 109416 | +** of the structure down into exprDup() so that they decendents can have | |
| 109417 | +** access to that memory. | |
| 108881 | 109418 | */ |
| 108882 | -static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ | |
| 109419 | +typedef struct EdupBuf EdupBuf; | |
| 109420 | +struct EdupBuf { | |
| 109421 | + u8 *zAlloc; /* Memory space available for storage */ | |
| 109422 | +#ifdef SQLITE_DEBUG | |
| 109423 | + u8 *zEnd; /* First byte past the end of memory */ | |
| 109424 | +#endif | |
| 109425 | +}; | |
| 109426 | + | |
| 109427 | +/* | |
| 109428 | +** This function is similar to sqlite3ExprDup(), except that if pEdupBuf | |
| 109429 | +** is not NULL then it points to memory that can be used to store a copy | |
| 109430 | +** of the input Expr p together with its p->u.zToken (if any). pEdupBuf | |
| 109431 | +** is updated with the new buffer tail prior to returning. | |
| 109432 | +*/ | |
| 109433 | +static Expr *exprDup( | |
| 109434 | + sqlite3 *db, /* Database connection (for memory allocation) */ | |
| 109435 | + const Expr *p, /* Expr tree to be duplicated */ | |
| 109436 | + int dupFlags, /* EXPRDUP_REDUCE for compression. 0 if not */ | |
| 109437 | + EdupBuf *pEdupBuf /* Preallocated storage space, or NULL */ | |
| 109438 | +){ | |
| 108883 | 109439 | Expr *pNew; /* Value to return */ |
| 108884 | - u8 *zAlloc; /* Memory space from which to build Expr object */ | |
| 109440 | + EdupBuf sEdupBuf; /* Memory space from which to build Expr object */ | |
| 108885 | 109441 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ |
| 109442 | + int nToken = -1; /* Space needed for p->u.zToken. -1 means unknown */ | |
| 108886 | 109443 | |
| 108887 | 109444 | assert( db!=0 ); |
| 108888 | 109445 | assert( p ); |
| 108889 | 109446 | assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); |
| 108890 | - assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE ); | |
| 109447 | + assert( pEdupBuf==0 || dupFlags==EXPRDUP_REDUCE ); | |
| 108891 | 109448 | |
| 108892 | 109449 | /* Figure out where to write the new Expr structure. */ |
| 108893 | - if( pzBuffer ){ | |
| 108894 | - zAlloc = *pzBuffer; | |
| 109450 | + if( pEdupBuf ){ | |
| 109451 | + sEdupBuf.zAlloc = pEdupBuf->zAlloc; | |
| 109452 | +#ifdef SQLITE_DEBUG | |
| 109453 | + sEdupBuf.zEnd = pEdupBuf->zEnd; | |
| 109454 | +#endif | |
| 108895 | 109455 | staticFlag = EP_Static; |
| 108896 | - assert( zAlloc!=0 ); | |
| 109456 | + assert( sEdupBuf.zAlloc!=0 ); | |
| 109457 | + assert( dupFlags==EXPRDUP_REDUCE ); | |
| 108897 | 109458 | }else{ |
| 108898 | - zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); | |
| 109459 | + int nAlloc; | |
| 109460 | + if( dupFlags ){ | |
| 109461 | + nAlloc = dupedExprSize(p); | |
| 109462 | + }else if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ | |
| 109463 | + nToken = sqlite3Strlen30NN(p->u.zToken)+1; | |
| 109464 | + nAlloc = EXPR_FULLSIZE + nToken; | |
| 109465 | + }else{ | |
| 109466 | + nToken = 0; | |
| 109467 | + nAlloc = EXPR_FULLSIZE; | |
| 109468 | + } | |
| 109469 | + sEdupBuf.zAlloc = sqlite3DbMallocRawNN(db, nAlloc); | |
| 109470 | +#ifdef SQLITE_DEBUG | |
| 109471 | + sEdupBuf.zEnd = sEdupBuf.zAlloc ? sEdupBuf.zAlloc+nAlloc : 0; | |
| 109472 | +#endif | |
| 109473 | + | |
| 108899 | 109474 | staticFlag = 0; |
| 108900 | 109475 | } |
| 108901 | - pNew = (Expr *)zAlloc; | |
| 109476 | + pNew = (Expr *)sEdupBuf.zAlloc; | |
| 108902 | 109477 | |
| 108903 | 109478 | if( pNew ){ |
| 108904 | 109479 | /* Set nNewSize to the size allocated for the structure pointed to |
| 108905 | 109480 | ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or |
| 108906 | 109481 | ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed |
| 108907 | 109482 | ** by the copy of the p->u.zToken string (if any). |
| 108908 | 109483 | */ |
| 108909 | 109484 | const unsigned nStructSize = dupedExprStructSize(p, dupFlags); |
| 108910 | 109485 | const int nNewSize = nStructSize & 0xfff; |
| 108911 | - int nToken; | |
| 108912 | - if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ | |
| 108913 | - nToken = sqlite3Strlen30(p->u.zToken) + 1; | |
| 108914 | - }else{ | |
| 108915 | - nToken = 0; | |
| 109486 | + if( nToken<0 ){ | |
| 109487 | + if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ | |
| 109488 | + nToken = sqlite3Strlen30(p->u.zToken) + 1; | |
| 109489 | + }else{ | |
| 109490 | + nToken = 0; | |
| 109491 | + } | |
| 108916 | 109492 | } |
| 108917 | 109493 | if( dupFlags ){ |
| 109494 | + assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= nNewSize+nToken ); | |
| 108918 | 109495 | assert( ExprHasProperty(p, EP_Reduced)==0 ); |
| 108919 | - memcpy(zAlloc, p, nNewSize); | |
| 109496 | + memcpy(sEdupBuf.zAlloc, p, nNewSize); | |
| 109497 | + sEdupBuf.zAlloc += nNewSize; | |
| 108920 | 109498 | }else{ |
| 108921 | 109499 | u32 nSize = (u32)exprStructSize(p); |
| 108922 | - memcpy(zAlloc, p, nSize); | |
| 109500 | + assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= EXPR_FULLSIZE+nToken ); | |
| 109501 | + memcpy(sEdupBuf.zAlloc, p, nSize); | |
| 108923 | 109502 | if( nSize<EXPR_FULLSIZE ){ |
| 108924 | - memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); | |
| 109503 | + memset(&sEdupBuf.zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); | |
| 108925 | 109504 | } |
| 109505 | + sEdupBuf.zAlloc += EXPR_FULLSIZE; | |
| 108926 | 109506 | } |
| 108927 | 109507 | |
| 108928 | 109508 | /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ |
| 108929 | 109509 | pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static); |
| 108930 | 109510 | pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly); |
| @@ -108933,55 +109513,62 @@ | ||
| 108933 | 109513 | if( dupFlags ){ |
| 108934 | 109514 | ExprSetVVAProperty(pNew, EP_Immutable); |
| 108935 | 109515 | } |
| 108936 | 109516 | |
| 108937 | 109517 | /* Copy the p->u.zToken string, if any. */ |
| 108938 | - if( nToken ){ | |
| 108939 | - char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; | |
| 109518 | + assert( nToken>=0 ); | |
| 109519 | + if( nToken>0 ){ | |
| 109520 | + char *zToken = pNew->u.zToken = (char*)sEdupBuf.zAlloc; | |
| 108940 | 109521 | memcpy(zToken, p->u.zToken, nToken); |
| 109522 | + sEdupBuf.zAlloc += nToken; | |
| 108941 | 109523 | } |
| 108942 | 109524 | |
| 108943 | - if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){ | |
| 109525 | + if( ((p->flags|pNew->flags)&(EP_TokenOnly|EP_Leaf))==0 ){ | |
| 109526 | + | |
| 108944 | 109527 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ |
| 108945 | 109528 | if( ExprUseXSelect(p) ){ |
| 108946 | 109529 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); |
| 108947 | 109530 | }else{ |
| 108948 | - pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); | |
| 108949 | - } | |
| 108950 | - } | |
| 108951 | - | |
| 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 | - } | |
| 109531 | + pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, | |
| 109532 | + p->op!=TK_ORDER ? dupFlags : 0); | |
| 109533 | + } | |
| 109534 | + | |
| 108961 | 109535 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 108962 | 109536 | if( ExprHasProperty(p, EP_WinFunc) ){ |
| 108963 | 109537 | pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); |
| 108964 | 109538 | assert( ExprHasProperty(pNew, EP_WinFunc) ); |
| 108965 | 109539 | } |
| 108966 | 109540 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 108967 | - if( pzBuffer ){ | |
| 108968 | - *pzBuffer = zAlloc; | |
| 108969 | - } | |
| 108970 | - }else{ | |
| 108971 | - if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ | |
| 108972 | - if( pNew->op==TK_SELECT_COLUMN ){ | |
| 109541 | + | |
| 109542 | + /* Fill in pNew->pLeft and pNew->pRight. */ | |
| 109543 | + if( dupFlags ){ | |
| 109544 | + if( p->op==TK_SELECT_COLUMN ){ | |
| 109545 | + pNew->pLeft = p->pLeft; | |
| 109546 | + assert( p->pRight==0 | |
| 109547 | + || p->pRight==p->pLeft | |
| 109548 | + || ExprHasProperty(p->pLeft, EP_Subquery) ); | |
| 109549 | + }else{ | |
| 109550 | + pNew->pLeft = p->pLeft ? | |
| 109551 | + exprDup(db, p->pLeft, EXPRDUP_REDUCE, &sEdupBuf) : 0; | |
| 109552 | + } | |
| 109553 | + pNew->pRight = p->pRight ? | |
| 109554 | + exprDup(db, p->pRight, EXPRDUP_REDUCE, &sEdupBuf) : 0; | |
| 109555 | + }else{ | |
| 109556 | + if( p->op==TK_SELECT_COLUMN ){ | |
| 108973 | 109557 | pNew->pLeft = p->pLeft; |
| 108974 | - assert( p->pRight==0 || p->pRight==p->pLeft | |
| 108975 | - || ExprHasProperty(p->pLeft, EP_Subquery) ); | |
| 109558 | + assert( p->pRight==0 | |
| 109559 | + || p->pRight==p->pLeft | |
| 109560 | + || ExprHasProperty(p->pLeft, EP_Subquery) ); | |
| 108976 | 109561 | }else{ |
| 108977 | 109562 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 108978 | 109563 | } |
| 108979 | 109564 | pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); |
| 108980 | 109565 | } |
| 108981 | 109566 | } |
| 108982 | 109567 | } |
| 109568 | + if( pEdupBuf ) memcpy(pEdupBuf, &sEdupBuf, sizeof(sEdupBuf)); | |
| 109569 | + assert( sEdupBuf.zAlloc <= sEdupBuf.zEnd ); | |
| 108983 | 109570 | return pNew; |
| 108984 | 109571 | } |
| 108985 | 109572 | |
| 108986 | 109573 | /* |
| 108987 | 109574 | ** Create and return a deep copy of the object passed as the second |
| @@ -109242,15 +109829,11 @@ | ||
| 109242 | 109829 | /* |
| 109243 | 109830 | ** Add a new element to the end of an expression list. If pList is |
| 109244 | 109831 | ** initially NULL, then create a new expression list. |
| 109245 | 109832 | ** |
| 109246 | 109833 | ** The pList argument must be either NULL or a pointer to an ExprList |
| 109247 | -** obtained from a prior call to sqlite3ExprListAppend(). This routine | |
| 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(). | |
| 109834 | +** obtained from a prior call to sqlite3ExprListAppend(). | |
| 109252 | 109835 | ** |
| 109253 | 109836 | ** If a memory allocation error occurs, the entire list is freed and |
| 109254 | 109837 | ** NULL is returned. If non-NULL is returned, then it is guaranteed |
| 109255 | 109838 | ** that the new entry was successfully appended. |
| 109256 | 109839 | */ |
| @@ -110071,10 +110654,31 @@ | ||
| 110071 | 110654 | if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1; |
| 110072 | 110655 | if( sqlite3StrICmp(z, "ROWID")==0 ) return 1; |
| 110073 | 110656 | if( sqlite3StrICmp(z, "OID")==0 ) return 1; |
| 110074 | 110657 | return 0; |
| 110075 | 110658 | } |
| 110659 | + | |
| 110660 | +/* | |
| 110661 | +** Return a pointer to a buffer containing a usable rowid alias for table | |
| 110662 | +** pTab. An alias is usable if there is not an explicit user-defined column | |
| 110663 | +** of the same name. | |
| 110664 | +*/ | |
| 110665 | +SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){ | |
| 110666 | + const char *azOpt[] = {"_ROWID_", "ROWID", "OID"}; | |
| 110667 | + int ii; | |
| 110668 | + assert( VisibleRowid(pTab) ); | |
| 110669 | + for(ii=0; ii<ArraySize(azOpt); ii++){ | |
| 110670 | + int iCol; | |
| 110671 | + for(iCol=0; iCol<pTab->nCol; iCol++){ | |
| 110672 | + if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break; | |
| 110673 | + } | |
| 110674 | + if( iCol==pTab->nCol ){ | |
| 110675 | + return azOpt[ii]; | |
| 110676 | + } | |
| 110677 | + } | |
| 110678 | + return 0; | |
| 110679 | +} | |
| 110076 | 110680 | |
| 110077 | 110681 | /* |
| 110078 | 110682 | ** pX is the RHS of an IN operator. If pX is a SELECT statement |
| 110079 | 110683 | ** that can be simplified to a direct table access, then return |
| 110080 | 110684 | ** a pointer to the SELECT statement. If pX is not a SELECT statement, |
| @@ -111608,10 +112212,45 @@ | ||
| 111608 | 112212 | return target; |
| 111609 | 112213 | } |
| 111610 | 112214 | return -1; /* Not found */ |
| 111611 | 112215 | } |
| 111612 | 112216 | |
| 112217 | + | |
| 112218 | +/* | |
| 112219 | +** Expresion pExpr is guaranteed to be a TK_COLUMN or equivalent. This | |
| 112220 | +** function checks the Parse.pIdxPartExpr list to see if this column | |
| 112221 | +** can be replaced with a constant value. If so, it generates code to | |
| 112222 | +** put the constant value in a register (ideally, but not necessarily, | |
| 112223 | +** register iTarget) and returns the register number. | |
| 112224 | +** | |
| 112225 | +** Or, if the TK_COLUMN cannot be replaced by a constant, zero is | |
| 112226 | +** returned. | |
| 112227 | +*/ | |
| 112228 | +static int exprPartidxExprLookup(Parse *pParse, Expr *pExpr, int iTarget){ | |
| 112229 | + IndexedExpr *p; | |
| 112230 | + for(p=pParse->pIdxPartExpr; p; p=p->pIENext){ | |
| 112231 | + if( pExpr->iColumn==p->iIdxCol && pExpr->iTable==p->iDataCur ){ | |
| 112232 | + Vdbe *v = pParse->pVdbe; | |
| 112233 | + int addr = 0; | |
| 112234 | + int ret; | |
| 112235 | + | |
| 112236 | + if( p->bMaybeNullRow ){ | |
| 112237 | + addr = sqlite3VdbeAddOp1(v, OP_IfNullRow, p->iIdxCur); | |
| 112238 | + } | |
| 112239 | + ret = sqlite3ExprCodeTarget(pParse, p->pExpr, iTarget); | |
| 112240 | + sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, ret, 1, 0, | |
| 112241 | + (const char*)&p->aff, 1); | |
| 112242 | + if( addr ){ | |
| 112243 | + sqlite3VdbeJumpHere(v, addr); | |
| 112244 | + sqlite3VdbeChangeP3(v, addr, ret); | |
| 112245 | + } | |
| 112246 | + return ret; | |
| 112247 | + } | |
| 112248 | + } | |
| 112249 | + return 0; | |
| 112250 | +} | |
| 112251 | + | |
| 111613 | 112252 | |
| 111614 | 112253 | /* |
| 111615 | 112254 | ** Generate code into the current Vdbe to evaluate the given |
| 111616 | 112255 | ** expression. Attempt to store the results in register "target". |
| 111617 | 112256 | ** Return the register where results are stored. |
| @@ -111645,10 +112284,11 @@ | ||
| 111645 | 112284 | return r1; |
| 111646 | 112285 | }else{ |
| 111647 | 112286 | assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); |
| 111648 | 112287 | op = pExpr->op; |
| 111649 | 112288 | } |
| 112289 | + assert( op!=TK_ORDER ); | |
| 111650 | 112290 | switch( op ){ |
| 111651 | 112291 | case TK_AGG_COLUMN: { |
| 111652 | 112292 | AggInfo *pAggInfo = pExpr->pAggInfo; |
| 111653 | 112293 | struct AggInfo_col *pCol; |
| 111654 | 112294 | assert( pAggInfo!=0 ); |
| @@ -111658,11 +112298,11 @@ | ||
| 111658 | 112298 | ** is using an expression index */ |
| 111659 | 112299 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 111660 | 112300 | #ifdef SQLITE_VDBE_COVERAGE |
| 111661 | 112301 | /* Verify that the OP_Null above is exercised by tests |
| 111662 | 112302 | ** tag-20230325-2 */ |
| 111663 | - sqlite3VdbeAddOp2(v, OP_NotNull, target, 1); | |
| 112303 | + sqlite3VdbeAddOp3(v, OP_NotNull, target, 1, 20230325); | |
| 111664 | 112304 | VdbeCoverageNeverTaken(v); |
| 111665 | 112305 | #endif |
| 111666 | 112306 | break; |
| 111667 | 112307 | } |
| 111668 | 112308 | pCol = &pAggInfo->aCol[pExpr->iAgg]; |
| @@ -111765,10 +112405,15 @@ | ||
| 111765 | 112405 | }else{ |
| 111766 | 112406 | /* Coding an expression that is part of an index where column names |
| 111767 | 112407 | ** in the index refer to the table to which the index belongs */ |
| 111768 | 112408 | iTab = pParse->iSelfTab - 1; |
| 111769 | 112409 | } |
| 112410 | + } | |
| 112411 | + else if( pParse->pIdxPartExpr | |
| 112412 | + && 0!=(r1 = exprPartidxExprLookup(pParse, pExpr, target)) | |
| 112413 | + ){ | |
| 112414 | + return r1; | |
| 111770 | 112415 | } |
| 111771 | 112416 | assert( ExprUseYTab(pExpr) ); |
| 111772 | 112417 | assert( pExpr->y.pTab!=0 ); |
| 111773 | 112418 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 111774 | 112419 | pExpr->iColumn, iTab, target, |
| @@ -112426,11 +113071,11 @@ | ||
| 112426 | 113071 | ** If the expression uses functions (that might throw an exception) then |
| 112427 | 113072 | ** guard them with an OP_Once opcode to ensure that the code is only executed |
| 112428 | 113073 | ** once. If no functions are involved, then factor the code out and put it at |
| 112429 | 113074 | ** the end of the prepared statement in the initialization section. |
| 112430 | 113075 | ** |
| 112431 | -** If regDest>=0 then the result is always stored in that register and the | |
| 113076 | +** If regDest>0 then the result is always stored in that register and the | |
| 112432 | 113077 | ** result is not reusable. If regDest<0 then this routine is free to |
| 112433 | 113078 | ** store the value wherever it wants. The register where the expression |
| 112434 | 113079 | ** is stored is returned. When regDest<0, two identical expressions might |
| 112435 | 113080 | ** code to the same register, if they do not contain function calls and hence |
| 112436 | 113081 | ** are factored out into the initialization section at the end of the |
| @@ -112441,10 +113086,11 @@ | ||
| 112441 | 113086 | Expr *pExpr, /* The expression to code when the VDBE initializes */ |
| 112442 | 113087 | int regDest /* Store the value in this register */ |
| 112443 | 113088 | ){ |
| 112444 | 113089 | ExprList *p; |
| 112445 | 113090 | assert( ConstFactorOk(pParse) ); |
| 113091 | + assert( regDest!=0 ); | |
| 112446 | 113092 | p = pParse->pConstExpr; |
| 112447 | 113093 | if( regDest<0 && p ){ |
| 112448 | 113094 | struct ExprList_item *pItem; |
| 112449 | 113095 | int i; |
| 112450 | 113096 | for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){ |
| @@ -113725,10 +114371,16 @@ | ||
| 113725 | 114371 | x.db = pParse->db; |
| 113726 | 114372 | x.pRef = pSrcList; |
| 113727 | 114373 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 113728 | 114374 | assert( ExprUseXList(pExpr) ); |
| 113729 | 114375 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 114376 | + if( pExpr->pLeft ){ | |
| 114377 | + assert( pExpr->pLeft->op==TK_ORDER ); | |
| 114378 | + assert( ExprUseXList(pExpr->pLeft) ); | |
| 114379 | + assert( pExpr->pLeft->x.pList!=0 ); | |
| 114380 | + sqlite3WalkExprList(&w, pExpr->pLeft->x.pList); | |
| 114381 | + } | |
| 113730 | 114382 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 113731 | 114383 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 113732 | 114384 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 113733 | 114385 | } |
| 113734 | 114386 | #endif |
| @@ -113989,18 +114641,45 @@ | ||
| 113989 | 114641 | /* pExpr is original. Make a new entry in pAggInfo->aFunc[] |
| 113990 | 114642 | */ |
| 113991 | 114643 | u8 enc = ENC(pParse->db); |
| 113992 | 114644 | i = addAggInfoFunc(pParse->db, pAggInfo); |
| 113993 | 114645 | if( i>=0 ){ |
| 114646 | + int nArg; | |
| 113994 | 114647 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 113995 | 114648 | pItem = &pAggInfo->aFunc[i]; |
| 113996 | 114649 | pItem->pFExpr = pExpr; |
| 113997 | 114650 | assert( ExprUseUToken(pExpr) ); |
| 114651 | + nArg = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; | |
| 113998 | 114652 | pItem->pFunc = sqlite3FindFunction(pParse->db, |
| 113999 | - pExpr->u.zToken, | |
| 114000 | - pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); | |
| 114001 | - if( pExpr->flags & EP_Distinct ){ | |
| 114653 | + pExpr->u.zToken, nArg, enc, 0); | |
| 114654 | + assert( pItem->bOBUnique==0 ); | |
| 114655 | + if( pExpr->pLeft | |
| 114656 | + && (pItem->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)==0 | |
| 114657 | + ){ | |
| 114658 | + /* The NEEDCOLL test above causes any ORDER BY clause on | |
| 114659 | + ** aggregate min() or max() to be ignored. */ | |
| 114660 | + ExprList *pOBList; | |
| 114661 | + assert( nArg>0 ); | |
| 114662 | + assert( pExpr->pLeft->op==TK_ORDER ); | |
| 114663 | + assert( ExprUseXList(pExpr->pLeft) ); | |
| 114664 | + pItem->iOBTab = pParse->nTab++; | |
| 114665 | + pOBList = pExpr->pLeft->x.pList; | |
| 114666 | + assert( pOBList->nExpr>0 ); | |
| 114667 | + if( pOBList->nExpr==1 | |
| 114668 | + && nArg==1 | |
| 114669 | + && sqlite3ExprCompare(0,pOBList->a[0].pExpr, | |
| 114670 | + pExpr->x.pList->a[0].pExpr,0)==0 | |
| 114671 | + ){ | |
| 114672 | + pItem->bOBPayload = 0; | |
| 114673 | + }else{ | |
| 114674 | + pItem->bOBPayload = 1; | |
| 114675 | + } | |
| 114676 | + pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); | |
| 114677 | + }else{ | |
| 114678 | + pItem->iOBTab = -1; | |
| 114679 | + } | |
| 114680 | + if( ExprHasProperty(pExpr, EP_Distinct) && !pItem->bOBUnique ){ | |
| 114002 | 114681 | pItem->iDistinct = pParse->nTab++; |
| 114003 | 114682 | }else{ |
| 114004 | 114683 | pItem->iDistinct = -1; |
| 114005 | 114684 | } |
| 114006 | 114685 | } |
| @@ -114632,18 +115311,23 @@ | ||
| 114632 | 115311 | renameReloadSchema(pParse, iDb, INITFLAG_AlterAdd); |
| 114633 | 115312 | |
| 114634 | 115313 | /* Verify that constraints are still satisfied */ |
| 114635 | 115314 | if( pNew->pCheck!=0 |
| 114636 | 115315 | || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) |
| 115316 | + || (pTab->tabFlags & TF_Strict)!=0 | |
| 114637 | 115317 | ){ |
| 114638 | 115318 | sqlite3NestedParse(pParse, |
| 114639 | 115319 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" |
| 114640 | 115320 | " THEN raise(ABORT,'CHECK constraint failed')" |
| 115321 | + " WHEN quick_check GLOB 'non-* value in*'" | |
| 115322 | + " THEN raise(ABORT,'type mismatch on DEFAULT')" | |
| 114641 | 115323 | " ELSE raise(ABORT,'NOT NULL constraint failed')" |
| 114642 | 115324 | " END" |
| 114643 | 115325 | " FROM pragma_quick_check(%Q,%Q)" |
| 114644 | - " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", | |
| 115326 | + " WHERE quick_check GLOB 'CHECK*'" | |
| 115327 | + " OR quick_check GLOB 'NULL*'" | |
| 115328 | + " OR quick_check GLOB 'non-* value in*'", | |
| 114645 | 115329 | zTab, zDb |
| 114646 | 115330 | ); |
| 114647 | 115331 | } |
| 114648 | 115332 | } |
| 114649 | 115333 | } |
| @@ -119618,23 +120302,18 @@ | ||
| 119618 | 120302 | |
| 119619 | 120303 | /* Initialize any AUTOINCREMENT data structures required. |
| 119620 | 120304 | */ |
| 119621 | 120305 | if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); |
| 119622 | 120306 | |
| 119623 | - /* Code constant expressions that where 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. | |
| 120307 | + /* Code constant expressions that were factored out of inner loops. | |
| 119629 | 120308 | */ |
| 119630 | 120309 | if( pParse->pConstExpr ){ |
| 119631 | 120310 | ExprList *pEL = pParse->pConstExpr; |
| 119632 | 120311 | pParse->okConstFactor = 0; |
| 119633 | 120312 | for(i=0; i<pEL->nExpr; i++){ |
| 119634 | - int iReg = pEL->a[i].u.iConstExprReg; | |
| 119635 | - sqlite3ExprCode(pParse, pEL->a[i].pExpr, iReg); | |
| 120313 | + assert( pEL->a[i].u.iConstExprReg>0 ); | |
| 120314 | + sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg); | |
| 119636 | 120315 | } |
| 119637 | 120316 | } |
| 119638 | 120317 | |
| 119639 | 120318 | if( pParse->bReturning ){ |
| 119640 | 120319 | Returning *pRet = pParse->u1.pReturning; |
| @@ -122297,10 +122976,21 @@ | ||
| 122297 | 122976 | #endif |
| 122298 | 122977 | |
| 122299 | 122978 | /* Reparse everything to update our internal data structures */ |
| 122300 | 122979 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 122301 | 122980 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); |
| 122981 | + | |
| 122982 | + /* Test for cycles in generated columns and illegal expressions | |
| 122983 | + ** in CHECK constraints and in DEFAULT clauses. */ | |
| 122984 | + if( p->tabFlags & TF_HasGenerated ){ | |
| 122985 | + sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, | |
| 122986 | + sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", | |
| 122987 | + db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); | |
| 122988 | + } | |
| 122989 | + sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, | |
| 122990 | + sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", | |
| 122991 | + db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); | |
| 122302 | 122992 | } |
| 122303 | 122993 | |
| 122304 | 122994 | /* Add the table to the in-memory representation of the database. |
| 122305 | 122995 | */ |
| 122306 | 122996 | if( db->init.busy ){ |
| @@ -127899,11 +128589,12 @@ | ||
| 127899 | 128589 | unsigned char c = *pBlob; |
| 127900 | 128590 | *(z++) = hexdigits[(c>>4)&0xf]; |
| 127901 | 128591 | *(z++) = hexdigits[c&0xf]; |
| 127902 | 128592 | } |
| 127903 | 128593 | *z = 0; |
| 127904 | - sqlite3_result_text(context, zHex, n*2, sqlite3_free); | |
| 128594 | + sqlite3_result_text64(context, zHex, (u64)(z-zHex), | |
| 128595 | + sqlite3_free, SQLITE_UTF8); | |
| 127905 | 128596 | } |
| 127906 | 128597 | } |
| 127907 | 128598 | |
| 127908 | 128599 | /* |
| 127909 | 128600 | ** Buffer zStr contains nStr bytes of utf-8 encoded text. Return 1 if zStr |
| @@ -128192,10 +128883,85 @@ | ||
| 128192 | 128883 | sqlite3_free(azChar); |
| 128193 | 128884 | } |
| 128194 | 128885 | } |
| 128195 | 128886 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); |
| 128196 | 128887 | } |
| 128888 | + | |
| 128889 | +/* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) | |
| 128890 | +** functions. | |
| 128891 | +** | |
| 128892 | +** Return a string value that is the concatenation of all non-null | |
| 128893 | +** entries in argv[]. Use zSep as the separator. | |
| 128894 | +*/ | |
| 128895 | +static void concatFuncCore( | |
| 128896 | + sqlite3_context *context, | |
| 128897 | + int argc, | |
| 128898 | + sqlite3_value **argv, | |
| 128899 | + int nSep, | |
| 128900 | + const char *zSep | |
| 128901 | +){ | |
| 128902 | + i64 j, k, n = 0; | |
| 128903 | + int i; | |
| 128904 | + char *z; | |
| 128905 | + for(i=0; i<argc; i++){ | |
| 128906 | + n += sqlite3_value_bytes(argv[i]); | |
| 128907 | + } | |
| 128908 | + n += (argc-1)*nSep; | |
| 128909 | + z = sqlite3_malloc64(n+1); | |
| 128910 | + if( z==0 ){ | |
| 128911 | + sqlite3_result_error_nomem(context); | |
| 128912 | + return; | |
| 128913 | + } | |
| 128914 | + j = 0; | |
| 128915 | + for(i=0; i<argc; i++){ | |
| 128916 | + k = sqlite3_value_bytes(argv[i]); | |
| 128917 | + if( k>0 ){ | |
| 128918 | + const char *v = (const char*)sqlite3_value_text(argv[i]); | |
| 128919 | + if( v!=0 ){ | |
| 128920 | + if( j>0 && nSep>0 ){ | |
| 128921 | + memcpy(&z[j], zSep, nSep); | |
| 128922 | + j += nSep; | |
| 128923 | + } | |
| 128924 | + memcpy(&z[j], v, k); | |
| 128925 | + j += k; | |
| 128926 | + } | |
| 128927 | + } | |
| 128928 | + } | |
| 128929 | + z[j] = 0; | |
| 128930 | + assert( j<=n ); | |
| 128931 | + sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8); | |
| 128932 | +} | |
| 128933 | + | |
| 128934 | +/* | |
| 128935 | +** The CONCAT(...) function. Generate a string result that is the | |
| 128936 | +** concatentation of all non-null arguments. | |
| 128937 | +*/ | |
| 128938 | +static void concatFunc( | |
| 128939 | + sqlite3_context *context, | |
| 128940 | + int argc, | |
| 128941 | + sqlite3_value **argv | |
| 128942 | +){ | |
| 128943 | + concatFuncCore(context, argc, argv, 0, ""); | |
| 128944 | +} | |
| 128945 | + | |
| 128946 | +/* | |
| 128947 | +** The CONCAT_WS(separator, ...) function. | |
| 128948 | +** | |
| 128949 | +** Generate a string that is the concatenation of 2nd through the Nth | |
| 128950 | +** argument. Use the first argument (which must be non-NULL) as the | |
| 128951 | +** separator. | |
| 128952 | +*/ | |
| 128953 | +static void concatwsFunc( | |
| 128954 | + sqlite3_context *context, | |
| 128955 | + int argc, | |
| 128956 | + sqlite3_value **argv | |
| 128957 | +){ | |
| 128958 | + int nSep = sqlite3_value_bytes(argv[0]); | |
| 128959 | + const char *zSep = (const char*)sqlite3_value_text(argv[0]); | |
| 128960 | + if( zSep==0 ) return; | |
| 128961 | + concatFuncCore(context, argc-1, argv+1, nSep, zSep); | |
| 128962 | +} | |
| 128197 | 128963 | |
| 128198 | 128964 | |
| 128199 | 128965 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 128200 | 128966 | /* |
| 128201 | 128967 | ** The "unknown" function is automatically substituted in place of |
| @@ -128614,10 +129380,11 @@ | ||
| 128614 | 129380 | minMaxValueFinalize(context, 0); |
| 128615 | 129381 | } |
| 128616 | 129382 | |
| 128617 | 129383 | /* |
| 128618 | 129384 | ** group_concat(EXPR, ?SEPARATOR?) |
| 129385 | +** string_agg(EXPR, SEPARATOR) | |
| 128619 | 129386 | ** |
| 128620 | 129387 | ** The SEPARATOR goes before the EXPR string. This is tragic. The |
| 128621 | 129388 | ** groupConcatInverse() implementation would have been easier if the |
| 128622 | 129389 | ** SEPARATOR were appended after EXPR. And the order is undocumented, |
| 128623 | 129390 | ** so we could change it, in theory. But the old behavior has been |
| @@ -129204,10 +129971,15 @@ | ||
| 129204 | 129971 | FUNCTION(upper, 1, 0, 0, upperFunc ), |
| 129205 | 129972 | FUNCTION(lower, 1, 0, 0, lowerFunc ), |
| 129206 | 129973 | FUNCTION(hex, 1, 0, 0, hexFunc ), |
| 129207 | 129974 | FUNCTION(unhex, 1, 0, 0, unhexFunc ), |
| 129208 | 129975 | FUNCTION(unhex, 2, 0, 0, unhexFunc ), |
| 129976 | + FUNCTION(concat, -1, 0, 0, concatFunc ), | |
| 129977 | + FUNCTION(concat, 0, 0, 0, 0 ), | |
| 129978 | + FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), | |
| 129979 | + FUNCTION(concat_ws, 0, 0, 0, 0 ), | |
| 129980 | + FUNCTION(concat_ws, 1, 0, 0, 0 ), | |
| 129209 | 129981 | INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), |
| 129210 | 129982 | VFUNCTION(random, 0, 0, 0, randomFunc ), |
| 129211 | 129983 | VFUNCTION(randomblob, 1, 0, 0, randomBlob ), |
| 129212 | 129984 | FUNCTION(nullif, 2, 0, 1, nullifFunc ), |
| 129213 | 129985 | DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ), |
| @@ -129232,10 +130004,12 @@ | ||
| 129232 | 130004 | WAGGREGATE(count, 1,0,0, countStep, |
| 129233 | 130005 | countFinalize, countFinalize, countInverse, SQLITE_FUNC_ANYORDER ), |
| 129234 | 130006 | WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep, |
| 129235 | 130007 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 129236 | 130008 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, |
| 130009 | + groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), | |
| 130010 | + WAGGREGATE(string_agg, 2, 0, 0, groupConcatStep, | |
| 129237 | 130011 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 129238 | 130012 | |
| 129239 | 130013 | LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 129240 | 130014 | #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 129241 | 130015 | LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| @@ -130175,10 +130949,11 @@ | ||
| 130175 | 130949 | if( pTop->pTriggerPrg ){ |
| 130176 | 130950 | Trigger *p = pTop->pTriggerPrg->pTrigger; |
| 130177 | 130951 | if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) |
| 130178 | 130952 | || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) |
| 130179 | 130953 | ){ |
| 130954 | + assert( (pTop->db->flags & SQLITE_FkNoAction)==0 ); | |
| 130180 | 130955 | return 1; |
| 130181 | 130956 | } |
| 130182 | 130957 | } |
| 130183 | 130958 | return 0; |
| 130184 | 130959 | } |
| @@ -130369,10 +131144,12 @@ | ||
| 130369 | 131144 | if( regNew!=0 ){ |
| 130370 | 131145 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1); |
| 130371 | 131146 | } |
| 130372 | 131147 | if( regOld!=0 ){ |
| 130373 | 131148 | int eAction = pFKey->aAction[aChange!=0]; |
| 131149 | + if( (db->flags & SQLITE_FkNoAction) ) eAction = OE_None; | |
| 131150 | + | |
| 130374 | 131151 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); |
| 130375 | 131152 | /* If this is a deferred FK constraint, or a CASCADE or SET NULL |
| 130376 | 131153 | ** action applies, then any foreign key violations caused by |
| 130377 | 131154 | ** removing the parent key will be rectified by the action trigger. |
| 130378 | 131155 | ** So do not set the "may-abort" flag in this case. |
| @@ -130484,11 +131261,15 @@ | ||
| 130484 | 131261 | } |
| 130485 | 131262 | |
| 130486 | 131263 | /* Check if any parent key columns are being modified. */ |
| 130487 | 131264 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 130488 | 131265 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 130489 | - if( p->aAction[1]!=OE_None ) return 2; | |
| 131266 | + if( (pParse->db->flags & SQLITE_FkNoAction)==0 | |
| 131267 | + && p->aAction[1]!=OE_None | |
| 131268 | + ){ | |
| 131269 | + return 2; | |
| 131270 | + } | |
| 130490 | 131271 | bHaveFK = 1; |
| 130491 | 131272 | } |
| 130492 | 131273 | } |
| 130493 | 131274 | } |
| 130494 | 131275 | } |
| @@ -130534,10 +131315,11 @@ | ||
| 130534 | 131315 | int action; /* One of OE_None, OE_Cascade etc. */ |
| 130535 | 131316 | Trigger *pTrigger; /* Trigger definition to return */ |
| 130536 | 131317 | int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ |
| 130537 | 131318 | |
| 130538 | 131319 | action = pFKey->aAction[iAction]; |
| 131320 | + if( (db->flags & SQLITE_FkNoAction) ) action = OE_None; | |
| 130539 | 131321 | if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ |
| 130540 | 131322 | return 0; |
| 130541 | 131323 | } |
| 130542 | 131324 | pTrigger = pFKey->apTrigger[iAction]; |
| 130543 | 131325 | |
| @@ -135553,10 +136335,13 @@ | ||
| 135553 | 136335 | /* |
| 135554 | 136336 | ** Enable or disable extension loading. Extension loading is disabled by |
| 135555 | 136337 | ** default so as not to open security holes in older applications. |
| 135556 | 136338 | */ |
| 135557 | 136339 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
| 136340 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 136341 | + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | |
| 136342 | +#endif | |
| 135558 | 136343 | sqlite3_mutex_enter(db->mutex); |
| 135559 | 136344 | if( onoff ){ |
| 135560 | 136345 | db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; |
| 135561 | 136346 | }else{ |
| 135562 | 136347 | db->flags &= ~(u64)(SQLITE_LoadExtension|SQLITE_LoadExtFunc); |
| @@ -135602,10 +136387,13 @@ | ||
| 135602 | 136387 | */ |
| 135603 | 136388 | SQLITE_API int sqlite3_auto_extension( |
| 135604 | 136389 | void (*xInit)(void) |
| 135605 | 136390 | ){ |
| 135606 | 136391 | int rc = SQLITE_OK; |
| 136392 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 136393 | + if( xInit==0 ) return SQLITE_MISUSE_BKPT; | |
| 136394 | +#endif | |
| 135607 | 136395 | #ifndef SQLITE_OMIT_AUTOINIT |
| 135608 | 136396 | rc = sqlite3_initialize(); |
| 135609 | 136397 | if( rc ){ |
| 135610 | 136398 | return rc; |
| 135611 | 136399 | }else |
| @@ -135654,10 +136442,13 @@ | ||
| 135654 | 136442 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MAIN); |
| 135655 | 136443 | #endif |
| 135656 | 136444 | int i; |
| 135657 | 136445 | int n = 0; |
| 135658 | 136446 | wsdAutoextInit; |
| 136447 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 136448 | + if( xInit==0 ) return 0; | |
| 136449 | +#endif | |
| 135659 | 136450 | sqlite3_mutex_enter(mutex); |
| 135660 | 136451 | for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ |
| 135661 | 136452 | if( wsdAutoext.aExt[i]==xInit ){ |
| 135662 | 136453 | wsdAutoext.nExt--; |
| 135663 | 136454 | wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt]; |
| @@ -137523,11 +138314,15 @@ | ||
| 137523 | 138314 | mask &= ~(SQLITE_WriteSchema); |
| 137524 | 138315 | } |
| 137525 | 138316 | #endif |
| 137526 | 138317 | |
| 137527 | 138318 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 137528 | - db->flags |= mask; | |
| 138319 | + if( (mask & SQLITE_WriteSchema)==0 | |
| 138320 | + || (db->flags & SQLITE_Defensive)==0 | |
| 138321 | + ){ | |
| 138322 | + db->flags |= mask; | |
| 138323 | + } | |
| 137529 | 138324 | }else{ |
| 137530 | 138325 | db->flags &= ~mask; |
| 137531 | 138326 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; |
| 137532 | 138327 | if( (mask & SQLITE_WriteSchema)!=0 |
| 137533 | 138328 | && sqlite3_stricmp(zRight, "reset")==0 |
| @@ -138156,12 +138951,33 @@ | ||
| 138156 | 138951 | int r1 = -1; |
| 138157 | 138952 | int bStrict; /* True for a STRICT table */ |
| 138158 | 138953 | int r2; /* Previous key for WITHOUT ROWID tables */ |
| 138159 | 138954 | int mxCol; /* Maximum non-virtual column number */ |
| 138160 | 138955 | |
| 138161 | - if( !IsOrdinaryTable(pTab) ) continue; | |
| 138162 | 138956 | if( pObjTab && pObjTab!=pTab ) continue; |
| 138957 | + if( !IsOrdinaryTable(pTab) ){ | |
| 138958 | + sqlite3_vtab *pVTab; | |
| 138959 | + int a1; | |
| 138960 | + if( !IsVirtual(pTab) ) continue; | |
| 138961 | + if( pTab->nCol<=0 ){ | |
| 138962 | + const char *zMod = pTab->u.vtab.azArg[0]; | |
| 138963 | + if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue; | |
| 138964 | + } | |
| 138965 | + sqlite3ViewGetColumnNames(pParse, pTab); | |
| 138966 | + if( pTab->u.vtab.p==0 ) continue; | |
| 138967 | + pVTab = pTab->u.vtab.p->pVtab; | |
| 138968 | + if( NEVER(pVTab==0) ) continue; | |
| 138969 | + if( NEVER(pVTab->pModule==0) ) continue; | |
| 138970 | + if( pVTab->pModule->iVersion<4 ) continue; | |
| 138971 | + if( pVTab->pModule->xIntegrity==0 ) continue; | |
| 138972 | + sqlite3VdbeAddOp2(v, OP_VCheck, 0, 3); | |
| 138973 | + sqlite3VdbeAppendP4(v, pTab, P4_TABLE); | |
| 138974 | + a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); | |
| 138975 | + integrityCheckResultRow(v); | |
| 138976 | + sqlite3VdbeJumpHere(v, a1); | |
| 138977 | + continue; | |
| 138978 | + } | |
| 138163 | 138979 | if( isQuick || HasRowid(pTab) ){ |
| 138164 | 138980 | pPk = 0; |
| 138165 | 138981 | r2 = 0; |
| 138166 | 138982 | }else{ |
| 138167 | 138983 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| @@ -139283,11 +140099,12 @@ | ||
| 139283 | 140099 | 0, /* xFindFunction - function overloading */ |
| 139284 | 140100 | 0, /* xRename - rename the table */ |
| 139285 | 140101 | 0, /* xSavepoint */ |
| 139286 | 140102 | 0, /* xRelease */ |
| 139287 | 140103 | 0, /* xRollbackTo */ |
| 139288 | - 0 /* xShadowName */ | |
| 140104 | + 0, /* xShadowName */ | |
| 140105 | + 0 /* xIntegrity */ | |
| 139289 | 140106 | }; |
| 139290 | 140107 | |
| 139291 | 140108 | /* |
| 139292 | 140109 | ** Check to see if zTabName is really the name of a pragma. If it is, |
| 139293 | 140110 | ** then register an eponymous virtual table for that pragma and return |
| @@ -139907,12 +140724,10 @@ | ||
| 139907 | 140724 | assert( db->lookaside.bDisable >= pParse->disableLookaside ); |
| 139908 | 140725 | db->lookaside.bDisable -= pParse->disableLookaside; |
| 139909 | 140726 | db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; |
| 139910 | 140727 | assert( pParse->db->pParse==pParse ); |
| 139911 | 140728 | db->pParse = pParse->pOuterParse; |
| 139912 | - pParse->db = 0; | |
| 139913 | - pParse->disableLookaside = 0; | |
| 139914 | 140729 | } |
| 139915 | 140730 | |
| 139916 | 140731 | /* |
| 139917 | 140732 | ** Add a new cleanup operation to a Parser. The cleanup should happen when |
| 139918 | 140733 | ** the parser object is destroyed. But, beware: the cleanup might happen |
| @@ -140846,10 +141661,11 @@ | ||
| 140846 | 141661 | if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){ |
| 140847 | 141662 | ExprClearProperty(p, EP_CanBeNull); |
| 140848 | 141663 | } |
| 140849 | 141664 | if( p->op==TK_FUNCTION ){ |
| 140850 | 141665 | assert( ExprUseXList(p) ); |
| 141666 | + assert( p->pLeft==0 ); | |
| 140851 | 141667 | if( p->x.pList ){ |
| 140852 | 141668 | int i; |
| 140853 | 141669 | for(i=0; i<p->x.pList->nExpr; i++){ |
| 140854 | 141670 | unsetJoinExpr(p->x.pList->a[i].pExpr, iTable, nullable); |
| 140855 | 141671 | } |
| @@ -146506,10 +147322,11 @@ | ||
| 146506 | 147322 | ** expanded. */ |
| 146507 | 147323 | int tableSeen = 0; /* Set to 1 when TABLE matches */ |
| 146508 | 147324 | char *zTName = 0; /* text of name of TABLE */ |
| 146509 | 147325 | int iErrOfst; |
| 146510 | 147326 | if( pE->op==TK_DOT ){ |
| 147327 | + assert( (selFlags & SF_NestedFrom)==0 ); | |
| 146511 | 147328 | assert( pE->pLeft!=0 ); |
| 146512 | 147329 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 146513 | 147330 | zTName = pE->pLeft->u.zToken; |
| 146514 | 147331 | assert( ExprUseWOfst(pE->pLeft) ); |
| 146515 | 147332 | iErrOfst = pE->pRight->w.iOfst; |
| @@ -146516,10 +147333,11 @@ | ||
| 146516 | 147333 | }else{ |
| 146517 | 147334 | assert( ExprUseWOfst(pE) ); |
| 146518 | 147335 | iErrOfst = pE->w.iOfst; |
| 146519 | 147336 | } |
| 146520 | 147337 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 147338 | + int nAdd; /* Number of cols including rowid */ | |
| 146521 | 147339 | Table *pTab = pFrom->pTab; /* Table for this data source */ |
| 146522 | 147340 | ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ |
| 146523 | 147341 | char *zTabName; /* AS name for this data source */ |
| 146524 | 147342 | const char *zSchemaName = 0; /* Schema name for this data source */ |
| 146525 | 147343 | int iDb; /* Schema index for this data src */ |
| @@ -146533,10 +147351,11 @@ | ||
| 146533 | 147351 | if( pFrom->fg.isNestedFrom ){ |
| 146534 | 147352 | assert( pFrom->pSelect!=0 ); |
| 146535 | 147353 | pNestedFrom = pFrom->pSelect->pEList; |
| 146536 | 147354 | assert( pNestedFrom!=0 ); |
| 146537 | 147355 | assert( pNestedFrom->nExpr==pTab->nCol ); |
| 147356 | + assert( VisibleRowid(pTab)==0 ); | |
| 146538 | 147357 | }else{ |
| 146539 | 147358 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 146540 | 147359 | continue; |
| 146541 | 147360 | } |
| 146542 | 147361 | pNestedFrom = 0; |
| @@ -146563,37 +147382,52 @@ | ||
| 146563 | 147382 | } |
| 146564 | 147383 | } |
| 146565 | 147384 | }else{ |
| 146566 | 147385 | pUsing = 0; |
| 146567 | 147386 | } |
| 146568 | - for(j=0; j<pTab->nCol; j++){ | |
| 146569 | - char *zName = pTab->aCol[j].zCnName; | |
| 147387 | + | |
| 147388 | + nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom)); | |
| 147389 | + for(j=0; j<nAdd; j++){ | |
| 147390 | + const char *zName; | |
| 146570 | 147391 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 146571 | 147392 | |
| 147393 | + if( j==pTab->nCol ){ | |
| 147394 | + zName = sqlite3RowidAlias(pTab); | |
| 147395 | + if( zName==0 ) continue; | |
| 147396 | + }else{ | |
| 147397 | + zName = pTab->aCol[j].zCnName; | |
| 147398 | + | |
| 147399 | + /* If pTab is actually an SF_NestedFrom sub-select, do not | |
| 147400 | + ** expand any ENAME_ROWID columns. */ | |
| 147401 | + if( pNestedFrom && pNestedFrom->a[j].fg.eEName==ENAME_ROWID ){ | |
| 147402 | + continue; | |
| 147403 | + } | |
| 147404 | + | |
| 147405 | + if( zTName | |
| 147406 | + && pNestedFrom | |
| 147407 | + && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0, 0)==0 | |
| 147408 | + ){ | |
| 147409 | + continue; | |
| 147410 | + } | |
| 147411 | + | |
| 147412 | + /* If a column is marked as 'hidden', omit it from the expanded | |
| 147413 | + ** result-set list unless the SELECT has the SF_IncludeHidden | |
| 147414 | + ** bit set. | |
| 147415 | + */ | |
| 147416 | + if( (p->selFlags & SF_IncludeHidden)==0 | |
| 147417 | + && IsHiddenColumn(&pTab->aCol[j]) | |
| 147418 | + ){ | |
| 147419 | + continue; | |
| 147420 | + } | |
| 147421 | + if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 | |
| 147422 | + && zTName==0 | |
| 147423 | + && (selFlags & (SF_NestedFrom))==0 | |
| 147424 | + ){ | |
| 147425 | + continue; | |
| 147426 | + } | |
| 147427 | + } | |
| 146572 | 147428 | assert( zName ); |
| 146573 | - if( zTName | |
| 146574 | - && pNestedFrom | |
| 146575 | - && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0)==0 | |
| 146576 | - ){ | |
| 146577 | - continue; | |
| 146578 | - } | |
| 146579 | - | |
| 146580 | - /* If a column is marked as 'hidden', omit it from the expanded | |
| 146581 | - ** result-set list unless the SELECT has the SF_IncludeHidden | |
| 146582 | - ** bit set. | |
| 146583 | - */ | |
| 146584 | - if( (p->selFlags & SF_IncludeHidden)==0 | |
| 146585 | - && IsHiddenColumn(&pTab->aCol[j]) | |
| 146586 | - ){ | |
| 146587 | - continue; | |
| 146588 | - } | |
| 146589 | - if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 | |
| 146590 | - && zTName==0 | |
| 146591 | - && (selFlags & (SF_NestedFrom))==0 | |
| 146592 | - ){ | |
| 146593 | - continue; | |
| 146594 | - } | |
| 146595 | 147429 | tableSeen = 1; |
| 146596 | 147430 | |
| 146597 | 147431 | if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ |
| 146598 | 147432 | if( pFrom->fg.isUsing |
| 146599 | 147433 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0 |
| @@ -146639,15 +147473,15 @@ | ||
| 146639 | 147473 | }else{ |
| 146640 | 147474 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 146641 | 147475 | zSchemaName, zTabName, zName); |
| 146642 | 147476 | testcase( pX->zEName==0 ); |
| 146643 | 147477 | } |
| 146644 | - pX->fg.eEName = ENAME_TAB; | |
| 147478 | + pX->fg.eEName = (j==pTab->nCol ? ENAME_ROWID : ENAME_TAB); | |
| 146645 | 147479 | if( (pFrom->fg.isUsing |
| 146646 | 147480 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) |
| 146647 | 147481 | || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) |
| 146648 | - || (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 | |
| 147482 | + || (j<pTab->nCol && (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)) | |
| 146649 | 147483 | ){ |
| 146650 | 147484 | pX->fg.bNoExpand = 1; |
| 146651 | 147485 | } |
| 146652 | 147486 | }else if( longNames ){ |
| 146653 | 147487 | pX->zEName = sqlite3MPrintf(db, "%s.%s", zTabName, zName); |
| @@ -146864,12 +147698,18 @@ | ||
| 146864 | 147698 | assert( pAggInfo!=0 ); |
| 146865 | 147699 | assert( pAggInfo->iFirstReg==0 ); |
| 146866 | 147700 | pNC->ncFlags |= NC_InAggFunc; |
| 146867 | 147701 | for(i=0; i<pAggInfo->nFunc; i++){ |
| 146868 | 147702 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; |
| 147703 | + assert( pExpr->op==TK_FUNCTION || pExpr->op==TK_AGG_FUNCTION ); | |
| 146869 | 147704 | assert( ExprUseXList(pExpr) ); |
| 146870 | 147705 | sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); |
| 147706 | + if( pExpr->pLeft ){ | |
| 147707 | + assert( pExpr->pLeft->op==TK_ORDER ); | |
| 147708 | + assert( ExprUseXList(pExpr->pLeft) ); | |
| 147709 | + sqlite3ExprAnalyzeAggList(pNC, pExpr->pLeft->x.pList); | |
| 147710 | + } | |
| 146871 | 147711 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 146872 | 147712 | assert( !IsWindowFunc(pExpr) ); |
| 146873 | 147713 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 146874 | 147714 | sqlite3ExprAnalyzeAggregates(pNC, pExpr->y.pWin->pFilter); |
| 146875 | 147715 | } |
| @@ -147020,10 +147860,36 @@ | ||
| 147020 | 147860 | pFunc->iDistinct, 0, 0, (char*)pKeyInfo, P4_KEYINFO); |
| 147021 | 147861 | ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(DISTINCT)", |
| 147022 | 147862 | pFunc->pFunc->zName)); |
| 147023 | 147863 | } |
| 147024 | 147864 | } |
| 147865 | + if( pFunc->iOBTab>=0 ){ | |
| 147866 | + ExprList *pOBList; | |
| 147867 | + KeyInfo *pKeyInfo; | |
| 147868 | + int nExtra = 0; | |
| 147869 | + assert( pFunc->pFExpr->pLeft!=0 ); | |
| 147870 | + assert( pFunc->pFExpr->pLeft->op==TK_ORDER ); | |
| 147871 | + assert( ExprUseXList(pFunc->pFExpr->pLeft) ); | |
| 147872 | + pOBList = pFunc->pFExpr->pLeft->x.pList; | |
| 147873 | + if( !pFunc->bOBUnique ){ | |
| 147874 | + nExtra++; /* One extra column for the OP_Sequence */ | |
| 147875 | + } | |
| 147876 | + if( pFunc->bOBPayload ){ | |
| 147877 | + /* extra columns for the function arguments */ | |
| 147878 | + assert( ExprUseXList(pFunc->pFExpr) ); | |
| 147879 | + nExtra += pFunc->pFExpr->x.pList->nExpr; | |
| 147880 | + } | |
| 147881 | + pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOBList, 0, nExtra); | |
| 147882 | + if( !pFunc->bOBUnique && pParse->nErr==0 ){ | |
| 147883 | + pKeyInfo->nKeyField++; | |
| 147884 | + } | |
| 147885 | + sqlite3VdbeAddOp4(v, OP_OpenEphemeral, | |
| 147886 | + pFunc->iOBTab, pOBList->nExpr+nExtra, 0, | |
| 147887 | + (char*)pKeyInfo, P4_KEYINFO); | |
| 147888 | + ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(ORDER BY)", | |
| 147889 | + pFunc->pFunc->zName)); | |
| 147890 | + } | |
| 147025 | 147891 | } |
| 147026 | 147892 | } |
| 147027 | 147893 | |
| 147028 | 147894 | /* |
| 147029 | 147895 | ** Invoke the OP_AggFinalize opcode for every aggregate function |
| @@ -147035,25 +147901,65 @@ | ||
| 147035 | 147901 | struct AggInfo_func *pF; |
| 147036 | 147902 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 147037 | 147903 | ExprList *pList; |
| 147038 | 147904 | assert( ExprUseXList(pF->pFExpr) ); |
| 147039 | 147905 | pList = pF->pFExpr->x.pList; |
| 147906 | + if( pF->iOBTab>=0 ){ | |
| 147907 | + /* For an ORDER BY aggregate, calls to OP_AggStep where deferred and | |
| 147908 | + ** all content was stored in emphermal table pF->iOBTab. Extract that | |
| 147909 | + ** content now (in ORDER BY order) and make all calls to OP_AggStep | |
| 147910 | + ** before doing the OP_AggFinal call. */ | |
| 147911 | + int iTop; /* Start of loop for extracting columns */ | |
| 147912 | + int nArg; /* Number of columns to extract */ | |
| 147913 | + int nKey; /* Key columns to be skipped */ | |
| 147914 | + int regAgg; /* Extract into this array */ | |
| 147915 | + int j; /* Loop counter */ | |
| 147916 | + | |
| 147917 | + nArg = pList->nExpr; | |
| 147918 | + regAgg = sqlite3GetTempRange(pParse, nArg); | |
| 147919 | + | |
| 147920 | + if( pF->bOBPayload==0 ){ | |
| 147921 | + nKey = 0; | |
| 147922 | + }else{ | |
| 147923 | + assert( pF->pFExpr->pLeft!=0 ); | |
| 147924 | + assert( ExprUseXList(pF->pFExpr->pLeft) ); | |
| 147925 | + assert( pF->pFExpr->pLeft->x.pList!=0 ); | |
| 147926 | + nKey = pF->pFExpr->pLeft->x.pList->nExpr; | |
| 147927 | + if( !pF->bOBUnique ) nKey++; | |
| 147928 | + } | |
| 147929 | + iTop = sqlite3VdbeAddOp1(v, OP_Rewind, pF->iOBTab); VdbeCoverage(v); | |
| 147930 | + for(j=nArg-1; j>=0; j--){ | |
| 147931 | + sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, nKey+j, regAgg+j); | |
| 147932 | + } | |
| 147933 | + sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); | |
| 147934 | + sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); | |
| 147935 | + sqlite3VdbeChangeP5(v, (u8)nArg); | |
| 147936 | + sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v); | |
| 147937 | + sqlite3VdbeJumpHere(v, iTop); | |
| 147938 | + sqlite3ReleaseTempRange(pParse, regAgg, nArg); | |
| 147939 | + } | |
| 147040 | 147940 | sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), |
| 147041 | 147941 | pList ? pList->nExpr : 0); |
| 147042 | 147942 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 147043 | 147943 | } |
| 147044 | 147944 | } |
| 147045 | - | |
| 147046 | 147945 | |
| 147047 | 147946 | /* |
| 147048 | 147947 | ** Generate code that will update the accumulator memory cells for an |
| 147049 | 147948 | ** aggregate based on the current cursor position. |
| 147050 | 147949 | ** |
| 147051 | 147950 | ** If regAcc is non-zero and there are no min() or max() aggregates |
| 147052 | 147951 | ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator |
| 147053 | 147952 | ** registers if register regAcc contains 0. The caller will take care |
| 147054 | 147953 | ** of setting and clearing regAcc. |
| 147954 | +** | |
| 147955 | +** For an ORDER BY aggregate, the actually accumulator memory cell update | |
| 147956 | +** is deferred until after all input rows have been received, so that they | |
| 147957 | +** can be run in the requested order. In that case, instead of invoking | |
| 147958 | +** OP_AggStep to update accumulator, just add the arguments that would | |
| 147959 | +** have been passed into OP_AggStep into the sorting ephemeral table | |
| 147960 | +** (along with the appropriate sort key). | |
| 147055 | 147961 | */ |
| 147056 | 147962 | static void updateAccumulator( |
| 147057 | 147963 | Parse *pParse, |
| 147058 | 147964 | int regAcc, |
| 147059 | 147965 | AggInfo *pAggInfo, |
| @@ -147071,10 +147977,11 @@ | ||
| 147071 | 147977 | pAggInfo->directMode = 1; |
| 147072 | 147978 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 147073 | 147979 | int nArg; |
| 147074 | 147980 | int addrNext = 0; |
| 147075 | 147981 | int regAgg; |
| 147982 | + int regAggSz = 0; | |
| 147076 | 147983 | ExprList *pList; |
| 147077 | 147984 | assert( ExprUseXList(pF->pFExpr) ); |
| 147078 | 147985 | assert( !IsWindowFunc(pF->pFExpr) ); |
| 147079 | 147986 | pList = pF->pFExpr->x.pList; |
| 147080 | 147987 | if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){ |
| @@ -147097,11 +148004,43 @@ | ||
| 147097 | 148004 | sqlite3VdbeAddOp2(v, OP_Copy, regAcc, regHit); |
| 147098 | 148005 | } |
| 147099 | 148006 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 147100 | 148007 | sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); |
| 147101 | 148008 | } |
| 147102 | - if( pList ){ | |
| 148009 | + if( pF->iOBTab>=0 ){ | |
| 148010 | + /* Instead of invoking AggStep, we must push the arguments that would | |
| 148011 | + ** have been passed to AggStep onto the sorting table. */ | |
| 148012 | + int jj; /* Registered used so far in building the record */ | |
| 148013 | + ExprList *pOBList; /* The ORDER BY clause */ | |
| 148014 | + assert( pList!=0 ); | |
| 148015 | + nArg = pList->nExpr; | |
| 148016 | + assert( nArg>0 ); | |
| 148017 | + assert( pF->pFExpr->pLeft!=0 ); | |
| 148018 | + assert( pF->pFExpr->pLeft->op==TK_ORDER ); | |
| 148019 | + assert( ExprUseXList(pF->pFExpr->pLeft) ); | |
| 148020 | + pOBList = pF->pFExpr->pLeft->x.pList; | |
| 148021 | + assert( pOBList!=0 ); | |
| 148022 | + assert( pOBList->nExpr>0 ); | |
| 148023 | + regAggSz = pOBList->nExpr; | |
| 148024 | + if( !pF->bOBUnique ){ | |
| 148025 | + regAggSz++; /* One register for OP_Sequence */ | |
| 148026 | + } | |
| 148027 | + if( pF->bOBPayload ){ | |
| 148028 | + regAggSz += nArg; | |
| 148029 | + } | |
| 148030 | + regAggSz++; /* One extra register to hold result of MakeRecord */ | |
| 148031 | + regAgg = sqlite3GetTempRange(pParse, regAggSz); | |
| 148032 | + sqlite3ExprCodeExprList(pParse, pOBList, regAgg, 0, SQLITE_ECEL_DUP); | |
| 148033 | + jj = pOBList->nExpr; | |
| 148034 | + if( !pF->bOBUnique ){ | |
| 148035 | + sqlite3VdbeAddOp2(v, OP_Sequence, pF->iOBTab, regAgg+jj); | |
| 148036 | + jj++; | |
| 148037 | + } | |
| 148038 | + if( pF->bOBPayload ){ | |
| 148039 | + sqlite3ExprCodeExprList(pParse, pList, regAgg+jj, 0, SQLITE_ECEL_DUP); | |
| 148040 | + } | |
| 148041 | + }else if( pList ){ | |
| 147103 | 148042 | nArg = pList->nExpr; |
| 147104 | 148043 | regAgg = sqlite3GetTempRange(pParse, nArg); |
| 147105 | 148044 | sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); |
| 147106 | 148045 | }else{ |
| 147107 | 148046 | nArg = 0; |
| @@ -147112,28 +148051,39 @@ | ||
| 147112 | 148051 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 147113 | 148052 | } |
| 147114 | 148053 | pF->iDistinct = codeDistinct(pParse, eDistinctType, |
| 147115 | 148054 | pF->iDistinct, addrNext, pList, regAgg); |
| 147116 | 148055 | } |
| 147117 | - if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ | |
| 147118 | - CollSeq *pColl = 0; | |
| 147119 | - struct ExprList_item *pItem; | |
| 147120 | - int j; | |
| 147121 | - assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ | |
| 147122 | - for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ | |
| 147123 | - pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); | |
| 147124 | - } | |
| 147125 | - if( !pColl ){ | |
| 147126 | - pColl = pParse->db->pDfltColl; | |
| 147127 | - } | |
| 147128 | - if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; | |
| 147129 | - sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ); | |
| 147130 | - } | |
| 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); | |
| 148056 | + if( pF->iOBTab>=0 ){ | |
| 148057 | + /* Insert a new record into the ORDER BY table */ | |
| 148058 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regAgg, regAggSz-1, | |
| 148059 | + regAgg+regAggSz-1); | |
| 148060 | + sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pF->iOBTab, regAgg+regAggSz-1, | |
| 148061 | + regAgg, regAggSz-1); | |
| 148062 | + sqlite3ReleaseTempRange(pParse, regAgg, regAggSz); | |
| 148063 | + }else{ | |
| 148064 | + /* Invoke the AggStep function */ | |
| 148065 | + if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ | |
| 148066 | + CollSeq *pColl = 0; | |
| 148067 | + struct ExprList_item *pItem; | |
| 148068 | + int j; | |
| 148069 | + assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ | |
| 148070 | + for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ | |
| 148071 | + pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); | |
| 148072 | + } | |
| 148073 | + if( !pColl ){ | |
| 148074 | + pColl = pParse->db->pDfltColl; | |
| 148075 | + } | |
| 148076 | + if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; | |
| 148077 | + sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, | |
| 148078 | + (char *)pColl, P4_COLLSEQ); | |
| 148079 | + } | |
| 148080 | + sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); | |
| 148081 | + sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); | |
| 148082 | + sqlite3VdbeChangeP5(v, (u8)nArg); | |
| 148083 | + sqlite3ReleaseTempRange(pParse, regAgg, nArg); | |
| 148084 | + } | |
| 147135 | 148085 | if( addrNext ){ |
| 147136 | 148086 | sqlite3VdbeResolveLabel(v, addrNext); |
| 147137 | 148087 | } |
| 147138 | 148088 | } |
| 147139 | 148089 | if( regHit==0 && pAggInfo->nAccumulator ){ |
| @@ -149189,10 +150139,14 @@ | ||
| 149189 | 150139 | goto trigger_orphan_error; |
| 149190 | 150140 | } |
| 149191 | 150141 | if( IsVirtual(pTab) ){ |
| 149192 | 150142 | sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); |
| 149193 | 150143 | goto trigger_orphan_error; |
| 150144 | + } | |
| 150145 | + if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ | |
| 150146 | + sqlite3ErrorMsg(pParse, "cannot create triggers on shadow tables"); | |
| 150147 | + goto trigger_orphan_error; | |
| 149194 | 150148 | } |
| 149195 | 150149 | |
| 149196 | 150150 | /* Check that the trigger name is not reserved and that no trigger of the |
| 149197 | 150151 | ** specified name exists */ |
| 149198 | 150152 | zName = sqlite3NameFromToken(db, pName); |
| @@ -153413,11 +154367,11 @@ | ||
| 153413 | 154367 | } |
| 153414 | 154368 | #endif |
| 153415 | 154369 | sqlite3_mutex_enter(db->mutex); |
| 153416 | 154370 | pCtx = db->pVtabCtx; |
| 153417 | 154371 | if( !pCtx || pCtx->bDeclared ){ |
| 153418 | - sqlite3Error(db, SQLITE_MISUSE); | |
| 154372 | + sqlite3Error(db, SQLITE_MISUSE_BKPT); | |
| 153419 | 154373 | sqlite3_mutex_leave(db->mutex); |
| 153420 | 154374 | return SQLITE_MISUSE_BKPT; |
| 153421 | 154375 | } |
| 153422 | 154376 | pTab = pCtx->pTab; |
| 153423 | 154377 | assert( IsVirtual(pTab) ); |
| @@ -154604,11 +155558,11 @@ | ||
| 154604 | 155558 | #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ |
| 154605 | 155559 | #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ |
| 154606 | 155560 | #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ |
| 154607 | 155561 | #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ |
| 154608 | 155562 | #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ |
| 154609 | -#define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */ | |
| 155563 | + /* 0x02000000 -- available for reuse */ | |
| 154610 | 155564 | #define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ |
| 154611 | 155565 | |
| 154612 | 155566 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| 154613 | 155567 | |
| 154614 | 155568 | /************** End of whereInt.h ********************************************/ |
| @@ -160399,17 +161353,21 @@ | ||
| 160399 | 161353 | Parse *pParse = pWInfo->pParse; /* Parsing context */ |
| 160400 | 161354 | Vdbe *v = pParse->pVdbe; /* VDBE under construction */ |
| 160401 | 161355 | WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ |
| 160402 | 161356 | int iCur; /* Cursor for table getting the filter */ |
| 160403 | 161357 | IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ |
| 161358 | + IndexedExpr *saved_pIdxPartExpr; /* saved copy of Parse.pIdxPartExpr */ | |
| 160404 | 161359 | |
| 160405 | 161360 | saved_pIdxEpr = pParse->pIdxEpr; |
| 161361 | + saved_pIdxPartExpr = pParse->pIdxPartExpr; | |
| 160406 | 161362 | pParse->pIdxEpr = 0; |
| 161363 | + pParse->pIdxPartExpr = 0; | |
| 160407 | 161364 | |
| 160408 | 161365 | assert( pLoop!=0 ); |
| 160409 | 161366 | assert( v!=0 ); |
| 160410 | 161367 | assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); |
| 161368 | + assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ); | |
| 160411 | 161369 | |
| 160412 | 161370 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 160413 | 161371 | do{ |
| 160414 | 161372 | const SrcList *pTabList; |
| 160415 | 161373 | const SrcItem *pItem; |
| @@ -160495,10 +161453,11 @@ | ||
| 160495 | 161453 | } |
| 160496 | 161454 | } |
| 160497 | 161455 | }while( iLevel < pWInfo->nLevel ); |
| 160498 | 161456 | sqlite3VdbeJumpHere(v, addrOnce); |
| 160499 | 161457 | pParse->pIdxEpr = saved_pIdxEpr; |
| 161458 | + pParse->pIdxPartExpr = saved_pIdxPartExpr; | |
| 160500 | 161459 | } |
| 160501 | 161460 | |
| 160502 | 161461 | |
| 160503 | 161462 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 160504 | 161463 | /* |
| @@ -162753,10 +163712,104 @@ | ||
| 162753 | 163712 | }else{ |
| 162754 | 163713 | rc = WHERE_IDX_ONLY; |
| 162755 | 163714 | } |
| 162756 | 163715 | return rc; |
| 162757 | 163716 | } |
| 163717 | + | |
| 163718 | +/* | |
| 163719 | +** This is an sqlite3ParserAddCleanup() callback that is invoked to | |
| 163720 | +** free the Parse->pIdxEpr list when the Parse object is destroyed. | |
| 163721 | +*/ | |
| 163722 | +static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){ | |
| 163723 | + IndexedExpr **pp = (IndexedExpr**)pObject; | |
| 163724 | + while( *pp!=0 ){ | |
| 163725 | + IndexedExpr *p = *pp; | |
| 163726 | + *pp = p->pIENext; | |
| 163727 | + sqlite3ExprDelete(db, p->pExpr); | |
| 163728 | + sqlite3DbFreeNN(db, p); | |
| 163729 | + } | |
| 163730 | +} | |
| 163731 | + | |
| 163732 | +/* | |
| 163733 | +** This function is called for a partial index - one with a WHERE clause - in | |
| 163734 | +** two scenarios. In both cases, it determines whether or not the WHERE | |
| 163735 | +** clause on the index implies that a column of the table may be safely | |
| 163736 | +** replaced by a constant expression. For example, in the following | |
| 163737 | +** SELECT: | |
| 163738 | +** | |
| 163739 | +** CREATE INDEX i1 ON t1(b, c) WHERE a=<expr>; | |
| 163740 | +** SELECT a, b, c FROM t1 WHERE a=<expr> AND b=?; | |
| 163741 | +** | |
| 163742 | +** The "a" in the select-list may be replaced by <expr>, iff: | |
| 163743 | +** | |
| 163744 | +** (a) <expr> is a constant expression, and | |
| 163745 | +** (b) The (a=<expr>) comparison uses the BINARY collation sequence, and | |
| 163746 | +** (c) Column "a" has an affinity other than NONE or BLOB. | |
| 163747 | +** | |
| 163748 | +** If argument pItem is NULL, then pMask must not be NULL. In this case this | |
| 163749 | +** function is being called as part of determining whether or not pIdx | |
| 163750 | +** is a covering index. This function clears any bits in (*pMask) | |
| 163751 | +** corresponding to columns that may be replaced by constants as described | |
| 163752 | +** above. | |
| 163753 | +** | |
| 163754 | +** Otherwise, if pItem is not NULL, then this function is being called | |
| 163755 | +** as part of coding a loop that uses index pIdx. In this case, add entries | |
| 163756 | +** to the Parse.pIdxPartExpr list for each column that can be replaced | |
| 163757 | +** by a constant. | |
| 163758 | +*/ | |
| 163759 | +static void wherePartIdxExpr( | |
| 163760 | + Parse *pParse, /* Parse context */ | |
| 163761 | + Index *pIdx, /* Partial index being processed */ | |
| 163762 | + Expr *pPart, /* WHERE clause being processed */ | |
| 163763 | + Bitmask *pMask, /* Mask to clear bits in */ | |
| 163764 | + int iIdxCur, /* Cursor number for index */ | |
| 163765 | + SrcItem *pItem /* The FROM clause entry for the table */ | |
| 163766 | +){ | |
| 163767 | + assert( pItem==0 || (pItem->fg.jointype & JT_RIGHT)==0 ); | |
| 163768 | + assert( (pItem==0 || pMask==0) && (pMask!=0 || pItem!=0) ); | |
| 163769 | + | |
| 163770 | + if( pPart->op==TK_AND ){ | |
| 163771 | + wherePartIdxExpr(pParse, pIdx, pPart->pRight, pMask, iIdxCur, pItem); | |
| 163772 | + pPart = pPart->pLeft; | |
| 163773 | + } | |
| 163774 | + | |
| 163775 | + if( (pPart->op==TK_EQ || pPart->op==TK_IS) ){ | |
| 163776 | + Expr *pLeft = pPart->pLeft; | |
| 163777 | + Expr *pRight = pPart->pRight; | |
| 163778 | + u8 aff; | |
| 163779 | + | |
| 163780 | + if( pLeft->op!=TK_COLUMN ) return; | |
| 163781 | + if( !sqlite3ExprIsConstant(pRight) ) return; | |
| 163782 | + if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return; | |
| 163783 | + if( pLeft->iColumn<0 ) return; | |
| 163784 | + aff = pIdx->pTable->aCol[pLeft->iColumn].affinity; | |
| 163785 | + if( aff>=SQLITE_AFF_TEXT ){ | |
| 163786 | + if( pItem ){ | |
| 163787 | + sqlite3 *db = pParse->db; | |
| 163788 | + IndexedExpr *p = (IndexedExpr*)sqlite3DbMallocRaw(db, sizeof(*p)); | |
| 163789 | + if( p ){ | |
| 163790 | + int bNullRow = (pItem->fg.jointype&(JT_LEFT|JT_LTORJ))!=0; | |
| 163791 | + p->pExpr = sqlite3ExprDup(db, pRight, 0); | |
| 163792 | + p->iDataCur = pItem->iCursor; | |
| 163793 | + p->iIdxCur = iIdxCur; | |
| 163794 | + p->iIdxCol = pLeft->iColumn; | |
| 163795 | + p->bMaybeNullRow = bNullRow; | |
| 163796 | + p->pIENext = pParse->pIdxPartExpr; | |
| 163797 | + p->aff = aff; | |
| 163798 | + pParse->pIdxPartExpr = p; | |
| 163799 | + if( p->pIENext==0 ){ | |
| 163800 | + void *pArg = (void*)&pParse->pIdxPartExpr; | |
| 163801 | + sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); | |
| 163802 | + } | |
| 163803 | + } | |
| 163804 | + }else if( pLeft->iColumn<(BMS-1) ){ | |
| 163805 | + *pMask &= ~((Bitmask)1 << pLeft->iColumn); | |
| 163806 | + } | |
| 163807 | + } | |
| 163808 | + } | |
| 163809 | +} | |
| 163810 | + | |
| 162758 | 163811 | |
| 162759 | 163812 | /* |
| 162760 | 163813 | ** Add all WhereLoop objects for a single table of the join where the table |
| 162761 | 163814 | ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be |
| 162762 | 163815 | ** a b-tree table, not a virtual table. |
| @@ -162957,13 +164010,10 @@ | ||
| 162957 | 164010 | #ifdef SQLITE_ENABLE_STAT4 |
| 162958 | 164011 | pNew->rRun = rSize + 16 - 2*((pTab->tabFlags & TF_HasStat4)!=0); |
| 162959 | 164012 | #else |
| 162960 | 164013 | pNew->rRun = rSize + 16; |
| 162961 | 164014 | #endif |
| 162962 | - if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){ | |
| 162963 | - pNew->wsFlags |= WHERE_VIEWSCAN; | |
| 162964 | - } | |
| 162965 | 164015 | ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 162966 | 164016 | whereLoopOutputAdjust(pWC, pNew, rSize); |
| 162967 | 164017 | rc = whereLoopInsert(pBuilder, pNew); |
| 162968 | 164018 | pNew->nOut = rSize; |
| 162969 | 164019 | if( rc ) break; |
| @@ -162972,10 +164022,15 @@ | ||
| 162972 | 164022 | if( pProbe->isCovering ){ |
| 162973 | 164023 | m = 0; |
| 162974 | 164024 | pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; |
| 162975 | 164025 | }else{ |
| 162976 | 164026 | m = pSrc->colUsed & pProbe->colNotIdxed; |
| 164027 | + if( pProbe->pPartIdxWhere ){ | |
| 164028 | + wherePartIdxExpr( | |
| 164029 | + pWInfo->pParse, pProbe, pProbe->pPartIdxWhere, &m, 0, 0 | |
| 164030 | + ); | |
| 164031 | + } | |
| 162977 | 164032 | pNew->wsFlags = WHERE_INDEXED; |
| 162978 | 164033 | if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ |
| 162979 | 164034 | u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); |
| 162980 | 164035 | if( isCov==0 ){ |
| 162981 | 164036 | WHERETRACE(0x200, |
| @@ -163354,11 +164409,11 @@ | ||
| 163354 | 164409 | ){ |
| 163355 | 164410 | HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 163356 | 164411 | sqlite3_value *pVal = 0; |
| 163357 | 164412 | int rc = SQLITE_OK; |
| 163358 | 164413 | if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ |
| 163359 | - rc = SQLITE_MISUSE; /* EV: R-30545-25046 */ | |
| 164414 | + rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */ | |
| 163360 | 164415 | }else{ |
| 163361 | 164416 | if( pH->aRhs[iCons]==0 ){ |
| 163362 | 164417 | WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; |
| 163363 | 164418 | rc = sqlite3ValueFromExpr( |
| 163364 | 164419 | pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db), |
| @@ -164378,18 +165433,10 @@ | ||
| 164378 | 165433 | }else{ |
| 164379 | 165434 | rCost = rUnsorted; |
| 164380 | 165435 | rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ |
| 164381 | 165436 | } |
| 164382 | 165437 | |
| 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 | 165438 | /* Check to see if pWLoop should be added to the set of |
| 164392 | 165439 | ** mxChoice best-so-far paths. |
| 164393 | 165440 | ** |
| 164394 | 165441 | ** First look for an existing path among best-so-far paths |
| 164395 | 165442 | ** that covers the same set of loops and has the same isOrdered |
| @@ -164935,24 +165982,10 @@ | ||
| 164935 | 165982 | } |
| 164936 | 165983 | nSearch += pLoop->nOut; |
| 164937 | 165984 | } |
| 164938 | 165985 | } |
| 164939 | 165986 | |
| 164940 | -/* | |
| 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 | 165987 | /* |
| 164955 | 165988 | ** The index pIdx is used by a query and contains one or more expressions. |
| 164956 | 165989 | ** In other words pIdx is an index on an expression. iIdxCur is the cursor |
| 164957 | 165990 | ** number for the index and iDataCur is the cursor number for the corresponding |
| 164958 | 165991 | ** table. |
| @@ -165010,11 +166043,12 @@ | ||
| 165010 | 166043 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 165011 | 166044 | p->zIdxName = pIdx->zName; |
| 165012 | 166045 | #endif |
| 165013 | 166046 | pParse->pIdxEpr = p; |
| 165014 | 166047 | if( p->pIENext==0 ){ |
| 165015 | - sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse); | |
| 166048 | + void *pArg = (void*)&pParse->pIdxEpr; | |
| 166049 | + sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); | |
| 165016 | 166050 | } |
| 165017 | 166051 | } |
| 165018 | 166052 | } |
| 165019 | 166053 | |
| 165020 | 166054 | /* |
| @@ -165400,10 +166434,20 @@ | ||
| 165400 | 166434 | if( db->mallocFailed ) goto whereBeginError; |
| 165401 | 166435 | if( pWInfo->pOrderBy ){ |
| 165402 | 166436 | wherePathSolver(pWInfo, pWInfo->nRowOut+1); |
| 165403 | 166437 | if( db->mallocFailed ) goto whereBeginError; |
| 165404 | 166438 | } |
| 166439 | + | |
| 166440 | + /* TUNING: Assume that a DISTINCT clause on a subquery reduces | |
| 166441 | + ** the output size by a factor of 8 (LogEst -30). | |
| 166442 | + */ | |
| 166443 | + if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 ){ | |
| 166444 | + WHERETRACE(0x0080,("nRowOut reduced from %d to %d due to DISTINCT\n", | |
| 166445 | + pWInfo->nRowOut, pWInfo->nRowOut-30)); | |
| 166446 | + pWInfo->nRowOut -= 30; | |
| 166447 | + } | |
| 166448 | + | |
| 165405 | 166449 | } |
| 165406 | 166450 | assert( pWInfo->pTabList!=0 ); |
| 165407 | 166451 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ |
| 165408 | 166452 | whereReverseScanOrder(pWInfo); |
| 165409 | 166453 | } |
| @@ -165611,10 +166655,15 @@ | ||
| 165611 | 166655 | op = OP_ReopenIdx; |
| 165612 | 166656 | }else{ |
| 165613 | 166657 | iIndexCur = pParse->nTab++; |
| 165614 | 166658 | if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ |
| 165615 | 166659 | whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); |
| 166660 | + } | |
| 166661 | + if( pIx->pPartIdxWhere && (pTabItem->fg.jointype & JT_RIGHT)==0 ){ | |
| 166662 | + wherePartIdxExpr( | |
| 166663 | + pParse, pIx, pIx->pPartIdxWhere, 0, iIndexCur, pTabItem | |
| 166664 | + ); | |
| 165616 | 166665 | } |
| 165617 | 166666 | } |
| 165618 | 166667 | pLevel->iIdxCur = iIndexCur; |
| 165619 | 166668 | assert( pIx!=0 ); |
| 165620 | 166669 | assert( pIx->pSchema==pTab->pSchema ); |
| @@ -167428,12 +168477,13 @@ | ||
| 167428 | 168477 | */ |
| 167429 | 168478 | SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ |
| 167430 | 168479 | if( p ){ |
| 167431 | 168480 | assert( p->op==TK_FUNCTION ); |
| 167432 | 168481 | assert( pWin ); |
| 168482 | + assert( ExprIsFullSize(p) ); | |
| 167433 | 168483 | p->y.pWin = pWin; |
| 167434 | - ExprSetProperty(p, EP_WinFunc); | |
| 168484 | + ExprSetProperty(p, EP_WinFunc|EP_FullSize); | |
| 167435 | 168485 | pWin->pOwner = p; |
| 167436 | 168486 | if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ |
| 167437 | 168487 | sqlite3ErrorMsg(pParse, |
| 167438 | 168488 | "DISTINCT is not supported for window functions" |
| 167439 | 168489 | ); |
| @@ -169731,22 +170781,22 @@ | ||
| 169731 | 170781 | #define sqlite3ParserCTX_PDECL ,Parse *pParse |
| 169732 | 170782 | #define sqlite3ParserCTX_PARAM ,pParse |
| 169733 | 170783 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 169734 | 170784 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 169735 | 170785 | #define YYFALLBACK 1 |
| 169736 | -#define YYNSTATE 575 | |
| 169737 | -#define YYNRULE 403 | |
| 169738 | -#define YYNRULE_WITH_ACTION 338 | |
| 170786 | +#define YYNSTATE 579 | |
| 170787 | +#define YYNRULE 405 | |
| 170788 | +#define YYNRULE_WITH_ACTION 340 | |
| 169739 | 170789 | #define YYNTOKEN 185 |
| 169740 | -#define YY_MAX_SHIFT 574 | |
| 169741 | -#define YY_MIN_SHIFTREDUCE 833 | |
| 169742 | -#define YY_MAX_SHIFTREDUCE 1235 | |
| 169743 | -#define YY_ERROR_ACTION 1236 | |
| 169744 | -#define YY_ACCEPT_ACTION 1237 | |
| 169745 | -#define YY_NO_ACTION 1238 | |
| 169746 | -#define YY_MIN_REDUCE 1239 | |
| 169747 | -#define YY_MAX_REDUCE 1641 | |
| 170790 | +#define YY_MAX_SHIFT 578 | |
| 170791 | +#define YY_MIN_SHIFTREDUCE 838 | |
| 170792 | +#define YY_MAX_SHIFTREDUCE 1242 | |
| 170793 | +#define YY_ERROR_ACTION 1243 | |
| 170794 | +#define YY_ACCEPT_ACTION 1244 | |
| 170795 | +#define YY_NO_ACTION 1245 | |
| 170796 | +#define YY_MIN_REDUCE 1246 | |
| 170797 | +#define YY_MAX_REDUCE 1650 | |
| 169748 | 170798 | /************* End control #defines *******************************************/ |
| 169749 | 170799 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 169750 | 170800 | |
| 169751 | 170801 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 169752 | 170802 | ** otherwise. |
| @@ -169809,222 +170859,222 @@ | ||
| 169809 | 170859 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 169810 | 170860 | ** shifting non-terminals after a reduce. |
| 169811 | 170861 | ** yy_default[] Default action for each state. |
| 169812 | 170862 | ** |
| 169813 | 170863 | *********** Begin parsing tables **********************************************/ |
| 169814 | -#define YY_ACTTAB_COUNT (2096) | |
| 170864 | +#define YY_ACTTAB_COUNT (2100) | |
| 169815 | 170865 | static const YYACTIONTYPE yy_action[] = { |
| 169816 | - /* 0 */ 568, 208, 568, 118, 115, 229, 568, 118, 115, 229, | |
| 169817 | - /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, | |
| 169818 | - /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, | |
| 169819 | - /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, | |
| 169820 | - /* 40 */ 397, 71, 71, 125, 126, 80, 1210, 1210, 1047, 1050, | |
| 169821 | - /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, | |
| 169822 | - /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, | |
| 169823 | - /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, | |
| 169824 | - /* 80 */ 417, 523, 142, 125, 126, 80, 1210, 1210, 1047, 1050, | |
| 169825 | - /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, | |
| 169826 | - /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, | |
| 169827 | - /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, | |
| 169828 | - /* 120 */ 442, 1559, 376, 1561, 1186, 375, 1157, 565, 1157, 565, | |
| 169829 | - /* 130 */ 409, 1559, 537, 259, 226, 444, 101, 145, 449, 316, | |
| 169830 | - /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, | |
| 169831 | - /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1210, 1210, 1047, | |
| 169832 | - /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, | |
| 169833 | - /* 170 */ 294, 1186, 339, 448, 120, 120, 120, 119, 116, 444, | |
| 169834 | - /* 180 */ 127, 1186, 1187, 1186, 148, 441, 440, 568, 119, 116, | |
| 169835 | - /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, | |
| 169836 | - /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, | |
| 169837 | - /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, | |
| 169838 | - /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1186, 1187, | |
| 169839 | - /* 230 */ 1186, 149, 1218, 409, 1218, 124, 124, 124, 124, 122, | |
| 169840 | - /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, | |
| 169841 | - /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, | |
| 169842 | - /* 260 */ 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, | |
| 169843 | - /* 270 */ 124, 124, 1275, 522, 222, 1186, 568, 409, 224, 514, | |
| 169844 | - /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, | |
| 169845 | - /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1186, 133, | |
| 169846 | - /* 300 */ 133, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, | |
| 169847 | - /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, | |
| 169848 | - /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, | |
| 169849 | - /* 330 */ 1186, 373, 1186, 1187, 1186, 252, 1429, 399, 504, 501, | |
| 169850 | - /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, | |
| 169851 | - /* 350 */ 460, 328, 360, 394, 1231, 1186, 1187, 1186, 563, 568, | |
| 169852 | - /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, | |
| 169853 | - /* 370 */ 116, 444, 284, 284, 369, 1572, 1598, 441, 440, 154, | |
| 169854 | - /* 380 */ 409, 445, 71, 71, 1282, 565, 1215, 1186, 1187, 1186, | |
| 169855 | - /* 390 */ 85, 1217, 271, 557, 543, 515, 515, 568, 98, 1216, | |
| 169856 | - /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1210, 1210, 1047, | |
| 169857 | - /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, | |
| 169858 | - /* 420 */ 13, 13, 1024, 507, 1218, 1186, 1218, 549, 109, 109, | |
| 169859 | - /* 430 */ 222, 568, 1232, 175, 568, 427, 110, 197, 445, 569, | |
| 169860 | - /* 440 */ 445, 430, 1546, 1014, 325, 551, 1186, 270, 287, 368, | |
| 169861 | - /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, | |
| 169862 | - /* 460 */ 316, 559, 1604, 122, 122, 122, 122, 121, 121, 120, | |
| 169863 | - /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, | |
| 169864 | - /* 480 */ 284, 284, 1186, 1187, 1186, 1152, 568, 1603, 409, 899, | |
| 169865 | - /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1152, 516, | |
| 169866 | - /* 500 */ 413, 1152, 552, 1186, 1187, 1186, 568, 544, 544, 51, | |
| 169867 | - /* 510 */ 51, 214, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, | |
| 169868 | - /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1186, 474, 135, | |
| 169869 | - /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, | |
| 169870 | - /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 541, | |
| 169871 | - /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1210, 1210, | |
| 169872 | - /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | |
| 169873 | - /* 570 */ 1548, 122, 122, 122, 122, 121, 121, 120, 120, 120, | |
| 169874 | - /* 580 */ 119, 116, 444, 485, 1186, 1187, 1186, 482, 281, 1263, | |
| 169875 | - /* 590 */ 955, 252, 1186, 373, 504, 501, 500, 1186, 340, 570, | |
| 169876 | - /* 600 */ 1186, 570, 409, 292, 499, 955, 874, 191, 480, 316, | |
| 169877 | - /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, | |
| 169878 | - /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | |
| 169879 | - /* 630 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169880 | - /* 640 */ 124, 409, 394, 1132, 1186, 867, 100, 284, 284, 1186, | |
| 169881 | - /* 650 */ 1187, 1186, 373, 1089, 1186, 1187, 1186, 1186, 1187, 1186, | |
| 169882 | - /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1210, 1210, | |
| 169883 | - /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | |
| 169884 | - /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, | |
| 169885 | - /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1152, 228, 1186, | |
| 169886 | - /* 700 */ 157, 1186, 1187, 1186, 1547, 13, 13, 301, 955, 1226, | |
| 169887 | - /* 710 */ 1152, 153, 409, 1152, 373, 1575, 1170, 5, 369, 1572, | |
| 169888 | - /* 720 */ 429, 1232, 3, 955, 122, 122, 122, 122, 121, 121, | |
| 169889 | - /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | |
| 169890 | - /* 740 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169891 | - /* 750 */ 124, 409, 208, 567, 1186, 1025, 1186, 1187, 1186, 1186, | |
| 169892 | - /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, | |
| 169893 | - /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1210, 1210, | |
| 169894 | - /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | |
| 169895 | - /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, | |
| 169896 | - /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, | |
| 169897 | - /* 810 */ 528, 1186, 1187, 1186, 13, 13, 1186, 1187, 1186, 1293, | |
| 169898 | - /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, | |
| 169899 | - /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, | |
| 169900 | - /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | |
| 169901 | - /* 850 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169902 | - /* 860 */ 124, 409, 227, 1069, 1152, 284, 284, 419, 312, 278, | |
| 169903 | - /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1152, 565, 568, | |
| 169904 | - /* 880 */ 1152, 1189, 565, 1592, 565, 125, 126, 80, 1210, 1210, | |
| 169905 | - /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, | |
| 169906 | - /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, | |
| 169907 | - /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, | |
| 169908 | - /* 920 */ 1578, 574, 2, 1241, 838, 839, 840, 1554, 317, 1205, | |
| 169909 | - /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1189, | |
| 169910 | - /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, | |
| 169911 | - /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, | |
| 169912 | - /* 960 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169913 | - /* 970 */ 124, 568, 284, 284, 568, 1206, 409, 573, 313, 1241, | |
| 169914 | - /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1635, | |
| 169915 | - /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, | |
| 169916 | - /* 1000 */ 1321, 104, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, | |
| 169917 | - /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, | |
| 169918 | - /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, | |
| 169919 | - /* 1030 */ 428, 448, 1519, 1206, 439, 284, 284, 1483, 1348, 311, | |
| 169920 | - /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, | |
| 169921 | - /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, | |
| 169922 | - /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, | |
| 169923 | - /* 1070 */ 444, 1015, 107, 71, 71, 1014, 13, 13, 910, 568, | |
| 169924 | - /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, | |
| 169925 | - /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, | |
| 169926 | - /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, | |
| 169927 | - /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1210, | |
| 169928 | - /* 1120 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169929 | - /* 1130 */ 124, 347, 409, 862, 1528, 1206, 125, 126, 80, 1210, | |
| 169930 | - /* 1140 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169931 | - /* 1150 */ 124, 1133, 1633, 474, 1633, 371, 125, 114, 80, 1210, | |
| 169932 | - /* 1160 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, | |
| 169933 | - /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, | |
| 169934 | - /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, | |
| 169935 | - /* 1190 */ 1290, 862, 464, 1206, 436, 122, 122, 122, 122, 121, | |
| 169936 | - /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1634, | |
| 169937 | - /* 1210 */ 539, 1634, 15, 15, 890, 122, 122, 122, 122, 121, | |
| 169938 | - /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, | |
| 169939 | - /* 1230 */ 1131, 1415, 1552, 1553, 1327, 409, 6, 6, 1163, 1264, | |
| 169940 | - /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, | |
| 169941 | - /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, | |
| 169942 | - /* 1260 */ 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, | |
| 169943 | - /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1186, 1415, | |
| 169944 | - /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1551, 847, | |
| 169945 | - /* 1290 */ 1163, 407, 6, 568, 321, 1152, 470, 44, 44, 1550, | |
| 169946 | - /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1152, 431, | |
| 169947 | - /* 1310 */ 568, 1152, 322, 17, 487, 1111, 58, 58, 122, 122, | |
| 169948 | - /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, | |
| 169949 | - /* 1330 */ 1112, 216, 481, 59, 59, 1186, 1187, 1186, 111, 560, | |
| 169950 | - /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, | |
| 169951 | - /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, | |
| 169952 | - /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, | |
| 169953 | - /* 1370 */ 235, 61, 61, 568, 414, 568, 414, 568, 445, 62, | |
| 169954 | - /* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49, | |
| 169955 | - /* 1390 */ 557, 568, 359, 568, 100, 486, 50, 50, 63, 63, | |
| 169956 | - /* 1400 */ 64, 64, 561, 415, 535, 410, 568, 1024, 568, 534, | |
| 169957 | - /* 1410 */ 316, 559, 316, 559, 65, 65, 14, 14, 568, 1024, | |
| 169958 | - /* 1420 */ 568, 512, 930, 870, 1015, 109, 109, 929, 1014, 66, | |
| 169959 | - /* 1430 */ 66, 131, 131, 110, 451, 445, 569, 445, 416, 177, | |
| 169960 | - /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, | |
| 169961 | - /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, | |
| 169962 | - /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, | |
| 169963 | - /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1577, 1174, 447, | |
| 169964 | - /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, | |
| 169965 | - /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, | |
| 169966 | - /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, | |
| 169967 | - /* 1510 */ 111, 560, 527, 4, 563, 53, 53, 322, 568, 163, | |
| 169968 | - /* 1520 */ 163, 568, 337, 468, 164, 164, 333, 563, 76, 76, | |
| 169969 | - /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, | |
| 169970 | - /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, | |
| 169971 | - /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, | |
| 169972 | - /* 1560 */ 161, 1566, 557, 535, 568, 319, 568, 348, 536, 1007, | |
| 169973 | - /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, | |
| 169974 | - /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, | |
| 169975 | - /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, | |
| 169976 | - /* 1600 */ 162, 162, 156, 156, 568, 110, 1076, 445, 569, 445, | |
| 169977 | - /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, | |
| 169978 | - /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, | |
| 169979 | - /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, | |
| 169980 | - /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1174, | |
| 169981 | - /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, | |
| 169982 | - /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, | |
| 169983 | - /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, | |
| 169984 | - /* 1680 */ 323, 111, 560, 927, 4, 113, 77, 77, 322, 74, | |
| 169985 | - /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, | |
| 169986 | - /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, | |
| 169987 | - /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, | |
| 169988 | - /* 1720 */ 1251, 445, 1585, 1339, 308, 276, 168, 309, 11, 141, | |
| 169989 | - /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, | |
| 169990 | - /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, | |
| 169991 | - /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, | |
| 169992 | - /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, | |
| 169993 | - /* 1770 */ 204, 1588, 1226, 558, 265, 218, 110, 205, 445, 569, | |
| 169994 | - /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, | |
| 169995 | - /* 1790 */ 1016, 1017, 27, 230, 1525, 1223, 79, 560, 85, 4, | |
| 169996 | - /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, | |
| 169997 | - /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, | |
| 169998 | - /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, | |
| 169999 | - /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, | |
| 170000 | - /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, | |
| 170001 | - /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, | |
| 170002 | - /* 1860 */ 1307, 1300, 93, 1602, 881, 1601, 224, 404, 434, 520, | |
| 170003 | - /* 1870 */ 263, 435, 1571, 563, 1279, 1278, 364, 1024, 306, 1277, | |
| 170004 | - /* 1880 */ 264, 1600, 1557, 109, 109, 370, 1299, 307, 1556, 438, | |
| 170005 | - /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, | |
| 170006 | - /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, | |
| 170007 | - /* 1910 */ 1180, 530, 272, 274, 379, 210, 1331, 547, 385, 386, | |
| 170008 | - /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, | |
| 170009 | - /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, | |
| 170010 | - /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, | |
| 170011 | - /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, | |
| 170012 | - /* 1960 */ 326, 180, 169, 1205, 182, 334, 238, 913, 241, 1100, | |
| 170013 | - /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, | |
| 170014 | - /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, | |
| 170015 | - /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1220, 489, | |
| 170016 | - /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, | |
| 170017 | - /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, | |
| 170018 | - /* 2020 */ 513, 39, 95, 1168, 160, 1053, 964, 1139, 96, 174, | |
| 170019 | - /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1158, 1154, 260, | |
| 170020 | - /* 2040 */ 21, 22, 23, 1156, 1162, 1161, 1143, 24, 33, 25, | |
| 170021 | - /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, | |
| 170022 | - /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, | |
| 170023 | - /* 2070 */ 861, 112, 29, 564, 1176, 1175, 268, 176, 143, 923, | |
| 170024 | - /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, | |
| 170025 | - /* 2090 */ 1238, 1238, 1238, 1238, 269, 1593, | |
| 170866 | + /* 0 */ 572, 210, 572, 119, 116, 231, 572, 119, 116, 231, | |
| 170867 | + /* 10 */ 572, 1317, 379, 1296, 410, 566, 566, 566, 572, 411, | |
| 170868 | + /* 20 */ 380, 1317, 1279, 42, 42, 42, 42, 210, 1529, 72, | |
| 170869 | + /* 30 */ 72, 974, 421, 42, 42, 495, 305, 281, 305, 975, | |
| 170870 | + /* 40 */ 399, 72, 72, 126, 127, 81, 1217, 1217, 1054, 1057, | |
| 170871 | + /* 50 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 480, 411, | |
| 170872 | + /* 60 */ 1244, 1, 1, 578, 2, 1248, 554, 119, 116, 231, | |
| 170873 | + /* 70 */ 319, 484, 147, 484, 528, 119, 116, 231, 533, 1330, | |
| 170874 | + /* 80 */ 419, 527, 143, 126, 127, 81, 1217, 1217, 1054, 1057, | |
| 170875 | + /* 90 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 119, 116, | |
| 170876 | + /* 100 */ 231, 329, 123, 123, 123, 123, 122, 122, 121, 121, | |
| 170877 | + /* 110 */ 121, 120, 117, 448, 286, 286, 286, 286, 446, 446, | |
| 170878 | + /* 120 */ 446, 1568, 378, 1570, 1193, 377, 1164, 569, 1164, 569, | |
| 170879 | + /* 130 */ 411, 1568, 541, 261, 228, 448, 102, 146, 453, 318, | |
| 170880 | + /* 140 */ 563, 242, 123, 123, 123, 123, 122, 122, 121, 121, | |
| 170881 | + /* 150 */ 121, 120, 117, 448, 126, 127, 81, 1217, 1217, 1054, | |
| 170882 | + /* 160 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 143, | |
| 170883 | + /* 170 */ 296, 1193, 341, 452, 121, 121, 121, 120, 117, 448, | |
| 170884 | + /* 180 */ 128, 1193, 1194, 1193, 149, 445, 444, 572, 120, 117, | |
| 170885 | + /* 190 */ 448, 125, 125, 125, 125, 118, 123, 123, 123, 123, | |
| 170886 | + /* 200 */ 122, 122, 121, 121, 121, 120, 117, 448, 458, 114, | |
| 170887 | + /* 210 */ 13, 13, 550, 123, 123, 123, 123, 122, 122, 121, | |
| 170888 | + /* 220 */ 121, 121, 120, 117, 448, 424, 318, 563, 1193, 1194, | |
| 170889 | + /* 230 */ 1193, 150, 1225, 411, 1225, 125, 125, 125, 125, 123, | |
| 170890 | + /* 240 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, | |
| 170891 | + /* 250 */ 448, 469, 344, 1041, 1041, 1055, 1058, 126, 127, 81, | |
| 170892 | + /* 260 */ 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, | |
| 170893 | + /* 270 */ 125, 125, 1282, 526, 224, 1193, 572, 411, 226, 519, | |
| 170894 | + /* 280 */ 177, 83, 84, 123, 123, 123, 123, 122, 122, 121, | |
| 170895 | + /* 290 */ 121, 121, 120, 117, 448, 1010, 16, 16, 1193, 134, | |
| 170896 | + /* 300 */ 134, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, | |
| 170897 | + /* 310 */ 124, 124, 125, 125, 125, 125, 123, 123, 123, 123, | |
| 170898 | + /* 320 */ 122, 122, 121, 121, 121, 120, 117, 448, 1045, 550, | |
| 170899 | + /* 330 */ 1193, 375, 1193, 1194, 1193, 254, 1438, 401, 508, 505, | |
| 170900 | + /* 340 */ 504, 112, 564, 570, 4, 929, 929, 435, 503, 342, | |
| 170901 | + /* 350 */ 464, 330, 362, 396, 1238, 1193, 1194, 1193, 567, 572, | |
| 170902 | + /* 360 */ 123, 123, 123, 123, 122, 122, 121, 121, 121, 120, | |
| 170903 | + /* 370 */ 117, 448, 286, 286, 371, 1581, 1607, 445, 444, 155, | |
| 170904 | + /* 380 */ 411, 449, 72, 72, 1289, 569, 1222, 1193, 1194, 1193, | |
| 170905 | + /* 390 */ 86, 1224, 273, 561, 547, 520, 520, 572, 99, 1223, | |
| 170906 | + /* 400 */ 6, 1281, 476, 143, 126, 127, 81, 1217, 1217, 1054, | |
| 170907 | + /* 410 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 554, | |
| 170908 | + /* 420 */ 13, 13, 1031, 511, 1225, 1193, 1225, 553, 110, 110, | |
| 170909 | + /* 430 */ 224, 572, 1239, 177, 572, 429, 111, 199, 449, 573, | |
| 170910 | + /* 440 */ 449, 432, 1555, 1019, 327, 555, 1193, 272, 289, 370, | |
| 170911 | + /* 450 */ 514, 365, 513, 259, 72, 72, 547, 72, 72, 361, | |
| 170912 | + /* 460 */ 318, 563, 1613, 123, 123, 123, 123, 122, 122, 121, | |
| 170913 | + /* 470 */ 121, 121, 120, 117, 448, 1019, 1019, 1021, 1022, 28, | |
| 170914 | + /* 480 */ 286, 286, 1193, 1194, 1193, 1159, 572, 1612, 411, 904, | |
| 170915 | + /* 490 */ 192, 554, 358, 569, 554, 940, 537, 521, 1159, 437, | |
| 170916 | + /* 500 */ 415, 1159, 556, 1193, 1194, 1193, 572, 548, 548, 52, | |
| 170917 | + /* 510 */ 52, 216, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, | |
| 170918 | + /* 520 */ 1044, 124, 124, 125, 125, 125, 125, 1193, 478, 136, | |
| 170919 | + /* 530 */ 136, 411, 286, 286, 1493, 509, 122, 122, 121, 121, | |
| 170920 | + /* 540 */ 121, 120, 117, 448, 1010, 569, 522, 219, 545, 545, | |
| 170921 | + /* 550 */ 318, 563, 143, 6, 536, 126, 127, 81, 1217, 1217, | |
| 170922 | + /* 560 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, | |
| 170923 | + /* 570 */ 1557, 123, 123, 123, 123, 122, 122, 121, 121, 121, | |
| 170924 | + /* 580 */ 120, 117, 448, 489, 1193, 1194, 1193, 486, 283, 1270, | |
| 170925 | + /* 590 */ 960, 254, 1193, 375, 508, 505, 504, 1193, 342, 574, | |
| 170926 | + /* 600 */ 1193, 574, 411, 294, 503, 960, 879, 193, 484, 318, | |
| 170927 | + /* 610 */ 563, 386, 292, 382, 123, 123, 123, 123, 122, 122, | |
| 170928 | + /* 620 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, | |
| 170929 | + /* 630 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170930 | + /* 640 */ 125, 411, 396, 1139, 1193, 872, 101, 286, 286, 1193, | |
| 170931 | + /* 650 */ 1194, 1193, 375, 1096, 1193, 1194, 1193, 1193, 1194, 1193, | |
| 170932 | + /* 660 */ 569, 459, 33, 375, 235, 126, 127, 81, 1217, 1217, | |
| 170933 | + /* 670 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, | |
| 170934 | + /* 680 */ 1437, 962, 572, 230, 961, 123, 123, 123, 123, 122, | |
| 170935 | + /* 690 */ 122, 121, 121, 121, 120, 117, 448, 1159, 230, 1193, | |
| 170936 | + /* 700 */ 158, 1193, 1194, 1193, 1556, 13, 13, 303, 960, 1233, | |
| 170937 | + /* 710 */ 1159, 154, 411, 1159, 375, 1584, 1177, 5, 371, 1581, | |
| 170938 | + /* 720 */ 431, 1239, 3, 960, 123, 123, 123, 123, 122, 122, | |
| 170939 | + /* 730 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, | |
| 170940 | + /* 740 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170941 | + /* 750 */ 125, 411, 210, 571, 1193, 1032, 1193, 1194, 1193, 1193, | |
| 170942 | + /* 760 */ 390, 855, 156, 1555, 376, 404, 1101, 1101, 492, 572, | |
| 170943 | + /* 770 */ 469, 344, 1322, 1322, 1555, 126, 127, 81, 1217, 1217, | |
| 170944 | + /* 780 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, | |
| 170945 | + /* 790 */ 130, 572, 13, 13, 532, 123, 123, 123, 123, 122, | |
| 170946 | + /* 800 */ 122, 121, 121, 121, 120, 117, 448, 304, 572, 457, | |
| 170947 | + /* 810 */ 229, 1193, 1194, 1193, 13, 13, 1193, 1194, 1193, 1300, | |
| 170948 | + /* 820 */ 467, 1270, 411, 1320, 1320, 1555, 1015, 457, 456, 436, | |
| 170949 | + /* 830 */ 301, 72, 72, 1268, 123, 123, 123, 123, 122, 122, | |
| 170950 | + /* 840 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, | |
| 170951 | + /* 850 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170952 | + /* 860 */ 125, 411, 384, 1076, 1159, 286, 286, 421, 314, 280, | |
| 170953 | + /* 870 */ 280, 287, 287, 461, 408, 407, 1539, 1159, 569, 572, | |
| 170954 | + /* 880 */ 1159, 1196, 569, 409, 569, 126, 127, 81, 1217, 1217, | |
| 170955 | + /* 890 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, | |
| 170956 | + /* 900 */ 457, 1485, 13, 13, 1541, 123, 123, 123, 123, 122, | |
| 170957 | + /* 910 */ 122, 121, 121, 121, 120, 117, 448, 202, 572, 462, | |
| 170958 | + /* 920 */ 1587, 578, 2, 1248, 843, 844, 845, 1563, 319, 409, | |
| 170959 | + /* 930 */ 147, 6, 411, 257, 256, 255, 208, 1330, 9, 1196, | |
| 170960 | + /* 940 */ 264, 72, 72, 1436, 123, 123, 123, 123, 122, 122, | |
| 170961 | + /* 950 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, | |
| 170962 | + /* 960 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170963 | + /* 970 */ 125, 572, 286, 286, 572, 1213, 411, 577, 315, 1248, | |
| 170964 | + /* 980 */ 421, 371, 1581, 356, 319, 569, 147, 495, 529, 1644, | |
| 170965 | + /* 990 */ 397, 935, 495, 1330, 71, 71, 934, 72, 72, 242, | |
| 170966 | + /* 1000 */ 1328, 105, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, | |
| 170967 | + /* 1010 */ 124, 125, 125, 125, 125, 123, 123, 123, 123, 122, | |
| 170968 | + /* 1020 */ 122, 121, 121, 121, 120, 117, 448, 1117, 286, 286, | |
| 170969 | + /* 1030 */ 1422, 452, 1528, 1213, 443, 286, 286, 1492, 1355, 313, | |
| 170970 | + /* 1040 */ 478, 569, 1118, 454, 351, 495, 354, 1266, 569, 209, | |
| 170971 | + /* 1050 */ 572, 418, 179, 572, 1031, 242, 385, 1119, 523, 123, | |
| 170972 | + /* 1060 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, | |
| 170973 | + /* 1070 */ 448, 1020, 108, 72, 72, 1019, 13, 13, 915, 572, | |
| 170974 | + /* 1080 */ 1498, 572, 286, 286, 98, 530, 1537, 452, 916, 1334, | |
| 170975 | + /* 1090 */ 1329, 203, 411, 286, 286, 569, 152, 211, 1498, 1500, | |
| 170976 | + /* 1100 */ 426, 569, 56, 56, 57, 57, 569, 1019, 1019, 1021, | |
| 170977 | + /* 1110 */ 447, 572, 411, 531, 12, 297, 126, 127, 81, 1217, | |
| 170978 | + /* 1120 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170979 | + /* 1130 */ 125, 572, 411, 867, 15, 15, 126, 127, 81, 1217, | |
| 170980 | + /* 1140 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170981 | + /* 1150 */ 125, 373, 529, 264, 44, 44, 126, 115, 81, 1217, | |
| 170982 | + /* 1160 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, | |
| 170983 | + /* 1170 */ 125, 1498, 478, 1271, 417, 123, 123, 123, 123, 122, | |
| 170984 | + /* 1180 */ 122, 121, 121, 121, 120, 117, 448, 205, 1213, 495, | |
| 170985 | + /* 1190 */ 430, 867, 468, 322, 495, 123, 123, 123, 123, 122, | |
| 170986 | + /* 1200 */ 122, 121, 121, 121, 120, 117, 448, 572, 557, 1140, | |
| 170987 | + /* 1210 */ 1642, 1422, 1642, 543, 572, 123, 123, 123, 123, 122, | |
| 170988 | + /* 1220 */ 122, 121, 121, 121, 120, 117, 448, 572, 1422, 572, | |
| 170989 | + /* 1230 */ 13, 13, 542, 323, 1325, 411, 334, 58, 58, 349, | |
| 170990 | + /* 1240 */ 1422, 1170, 326, 286, 286, 549, 1213, 300, 895, 530, | |
| 170991 | + /* 1250 */ 45, 45, 59, 59, 1140, 1643, 569, 1643, 565, 417, | |
| 170992 | + /* 1260 */ 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, | |
| 170993 | + /* 1270 */ 125, 125, 125, 125, 1367, 373, 500, 290, 1193, 512, | |
| 170994 | + /* 1280 */ 1366, 427, 394, 394, 393, 275, 391, 896, 1138, 852, | |
| 170995 | + /* 1290 */ 478, 258, 1422, 1170, 463, 1159, 12, 331, 428, 333, | |
| 170996 | + /* 1300 */ 1117, 460, 236, 258, 325, 460, 544, 1544, 1159, 1098, | |
| 170997 | + /* 1310 */ 491, 1159, 324, 1098, 440, 1118, 335, 516, 123, 123, | |
| 170998 | + /* 1320 */ 123, 123, 122, 122, 121, 121, 121, 120, 117, 448, | |
| 170999 | + /* 1330 */ 1119, 318, 563, 1138, 572, 1193, 1194, 1193, 112, 564, | |
| 171000 | + /* 1340 */ 201, 4, 238, 433, 935, 490, 285, 228, 1517, 934, | |
| 171001 | + /* 1350 */ 170, 560, 572, 142, 1516, 567, 572, 60, 60, 572, | |
| 171002 | + /* 1360 */ 416, 572, 441, 572, 535, 302, 875, 8, 487, 572, | |
| 171003 | + /* 1370 */ 237, 572, 416, 572, 485, 61, 61, 572, 449, 62, | |
| 171004 | + /* 1380 */ 62, 332, 63, 63, 46, 46, 47, 47, 361, 572, | |
| 171005 | + /* 1390 */ 561, 572, 48, 48, 50, 50, 51, 51, 572, 295, | |
| 171006 | + /* 1400 */ 64, 64, 482, 295, 539, 412, 471, 1031, 572, 538, | |
| 171007 | + /* 1410 */ 318, 563, 65, 65, 66, 66, 409, 475, 572, 1031, | |
| 171008 | + /* 1420 */ 572, 14, 14, 875, 1020, 110, 110, 409, 1019, 572, | |
| 171009 | + /* 1430 */ 474, 67, 67, 111, 455, 449, 573, 449, 98, 317, | |
| 171010 | + /* 1440 */ 1019, 132, 132, 133, 133, 572, 1561, 572, 974, 409, | |
| 171011 | + /* 1450 */ 6, 1562, 68, 68, 1560, 6, 975, 572, 6, 1559, | |
| 171012 | + /* 1460 */ 1019, 1019, 1021, 6, 346, 218, 101, 531, 53, 53, | |
| 171013 | + /* 1470 */ 69, 69, 1019, 1019, 1021, 1022, 28, 1586, 1181, 451, | |
| 171014 | + /* 1480 */ 70, 70, 290, 87, 215, 31, 1363, 394, 394, 393, | |
| 171015 | + /* 1490 */ 275, 391, 350, 109, 852, 107, 572, 112, 564, 483, | |
| 171016 | + /* 1500 */ 4, 1212, 572, 239, 153, 572, 39, 236, 1299, 325, | |
| 171017 | + /* 1510 */ 112, 564, 1298, 4, 567, 572, 32, 324, 572, 54, | |
| 171018 | + /* 1520 */ 54, 572, 1135, 353, 398, 165, 165, 567, 166, 166, | |
| 171019 | + /* 1530 */ 572, 291, 355, 572, 17, 357, 572, 449, 77, 77, | |
| 171020 | + /* 1540 */ 1313, 55, 55, 1297, 73, 73, 572, 238, 470, 561, | |
| 171021 | + /* 1550 */ 449, 472, 364, 135, 135, 170, 74, 74, 142, 163, | |
| 171022 | + /* 1560 */ 163, 374, 561, 539, 572, 321, 572, 886, 540, 137, | |
| 171023 | + /* 1570 */ 137, 339, 1353, 422, 298, 237, 539, 572, 1031, 572, | |
| 171024 | + /* 1580 */ 340, 538, 101, 369, 110, 110, 162, 131, 131, 164, | |
| 171025 | + /* 1590 */ 164, 1031, 111, 368, 449, 573, 449, 110, 110, 1019, | |
| 171026 | + /* 1600 */ 157, 157, 141, 141, 572, 111, 572, 449, 573, 449, | |
| 171027 | + /* 1610 */ 412, 288, 1019, 572, 882, 318, 563, 572, 219, 572, | |
| 171028 | + /* 1620 */ 241, 1012, 477, 263, 263, 894, 893, 140, 140, 138, | |
| 171029 | + /* 1630 */ 138, 1019, 1019, 1021, 1022, 28, 139, 139, 525, 455, | |
| 171030 | + /* 1640 */ 76, 76, 78, 78, 1019, 1019, 1021, 1022, 28, 1181, | |
| 171031 | + /* 1650 */ 451, 572, 1083, 290, 112, 564, 1575, 4, 394, 394, | |
| 171032 | + /* 1660 */ 393, 275, 391, 572, 1023, 852, 572, 479, 345, 263, | |
| 171033 | + /* 1670 */ 101, 567, 882, 1376, 75, 75, 1421, 501, 236, 260, | |
| 171034 | + /* 1680 */ 325, 112, 564, 359, 4, 101, 43, 43, 324, 49, | |
| 171035 | + /* 1690 */ 49, 901, 902, 161, 449, 101, 977, 978, 567, 1079, | |
| 171036 | + /* 1700 */ 1349, 260, 965, 932, 263, 114, 561, 1095, 517, 1095, | |
| 171037 | + /* 1710 */ 1083, 1094, 865, 1094, 151, 933, 1144, 114, 238, 1361, | |
| 171038 | + /* 1720 */ 558, 449, 1023, 559, 1426, 1278, 170, 1269, 1257, 142, | |
| 171039 | + /* 1730 */ 1601, 1256, 1258, 561, 1594, 1031, 496, 278, 213, 1346, | |
| 171040 | + /* 1740 */ 310, 110, 110, 939, 311, 312, 237, 11, 234, 111, | |
| 171041 | + /* 1750 */ 221, 449, 573, 449, 293, 395, 1019, 1408, 337, 1403, | |
| 171042 | + /* 1760 */ 1396, 338, 1031, 299, 343, 1413, 1412, 481, 110, 110, | |
| 171043 | + /* 1770 */ 506, 402, 225, 1296, 206, 367, 111, 1358, 449, 573, | |
| 171044 | + /* 1780 */ 449, 412, 1359, 1019, 1489, 1488, 318, 563, 1019, 1019, | |
| 171045 | + /* 1790 */ 1021, 1022, 28, 562, 207, 220, 80, 564, 389, 4, | |
| 171046 | + /* 1800 */ 1597, 1357, 552, 1356, 1233, 181, 267, 232, 1536, 1534, | |
| 171047 | + /* 1810 */ 455, 1230, 420, 567, 82, 1019, 1019, 1021, 1022, 28, | |
| 171048 | + /* 1820 */ 86, 217, 85, 1494, 190, 175, 183, 465, 185, 466, | |
| 171049 | + /* 1830 */ 36, 1409, 186, 187, 188, 499, 449, 244, 37, 99, | |
| 171050 | + /* 1840 */ 400, 1415, 1414, 488, 1417, 194, 473, 403, 561, 1483, | |
| 171051 | + /* 1850 */ 248, 92, 1505, 494, 198, 279, 112, 564, 250, 4, | |
| 171052 | + /* 1860 */ 348, 497, 405, 352, 1259, 251, 252, 515, 1316, 434, | |
| 171053 | + /* 1870 */ 1315, 1314, 94, 567, 1307, 886, 1306, 1031, 226, 406, | |
| 171054 | + /* 1880 */ 1611, 1610, 438, 110, 110, 1580, 1286, 524, 439, 308, | |
| 171055 | + /* 1890 */ 266, 111, 1285, 449, 573, 449, 449, 309, 1019, 366, | |
| 171056 | + /* 1900 */ 1284, 1609, 265, 1566, 1565, 442, 372, 1381, 561, 129, | |
| 171057 | + /* 1910 */ 550, 1380, 10, 1470, 383, 106, 316, 551, 100, 35, | |
| 171058 | + /* 1920 */ 534, 575, 212, 1339, 381, 387, 1187, 1338, 274, 276, | |
| 171059 | + /* 1930 */ 1019, 1019, 1021, 1022, 28, 277, 413, 1031, 576, 1254, | |
| 171060 | + /* 1940 */ 388, 1521, 1249, 110, 110, 167, 1522, 168, 148, 1520, | |
| 171061 | + /* 1950 */ 1519, 111, 306, 449, 573, 449, 222, 223, 1019, 839, | |
| 171062 | + /* 1960 */ 169, 79, 450, 214, 414, 233, 320, 145, 1093, 1091, | |
| 171063 | + /* 1970 */ 328, 182, 171, 1212, 918, 184, 240, 336, 243, 1107, | |
| 171064 | + /* 1980 */ 189, 172, 173, 423, 425, 88, 180, 191, 89, 90, | |
| 171065 | + /* 1990 */ 1019, 1019, 1021, 1022, 28, 91, 174, 1110, 245, 1106, | |
| 171066 | + /* 2000 */ 246, 159, 18, 247, 347, 1099, 263, 195, 1227, 493, | |
| 171067 | + /* 2010 */ 249, 196, 38, 854, 498, 368, 253, 360, 897, 197, | |
| 171068 | + /* 2020 */ 502, 93, 19, 20, 507, 884, 363, 510, 95, 307, | |
| 171069 | + /* 2030 */ 160, 96, 518, 97, 1175, 1060, 1146, 40, 21, 227, | |
| 171070 | + /* 2040 */ 176, 1145, 282, 284, 969, 200, 963, 114, 262, 1165, | |
| 171071 | + /* 2050 */ 22, 23, 24, 1161, 1169, 25, 1163, 1150, 34, 26, | |
| 171072 | + /* 2060 */ 1168, 546, 27, 204, 101, 103, 104, 1074, 7, 1061, | |
| 171073 | + /* 2070 */ 1059, 1063, 1116, 1064, 1115, 268, 269, 29, 41, 270, | |
| 171074 | + /* 2080 */ 1024, 866, 113, 30, 568, 392, 1183, 144, 178, 1182, | |
| 171075 | + /* 2090 */ 271, 928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602, | |
| 170026 | 171076 | }; |
| 170027 | 171077 | static const YYCODETYPE yy_lookahead[] = { |
| 170028 | 171078 | /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, |
| 170029 | 171079 | /* 10 */ 193, 223, 219, 225, 206, 210, 211, 212, 193, 19, |
| 170030 | 171080 | /* 20 */ 219, 233, 216, 216, 217, 216, 217, 193, 295, 216, |
| @@ -170099,11 +171149,11 @@ | ||
| 170099 | 171149 | /* 710 */ 89, 241, 19, 92, 193, 193, 23, 22, 311, 312, |
| 170100 | 171150 | /* 720 */ 231, 101, 22, 143, 102, 103, 104, 105, 106, 107, |
| 170101 | 171151 | /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170102 | 171152 | /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170103 | 171153 | /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, |
| 170104 | - /* 760 */ 201, 21, 241, 304, 22, 206, 127, 128, 129, 193, | |
| 171154 | + /* 760 */ 201, 21, 241, 304, 193, 206, 127, 128, 129, 193, | |
| 170105 | 171155 | /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, |
| 170106 | 171156 | /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 170107 | 171157 | /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, |
| 170108 | 171158 | /* 800 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 193, |
| 170109 | 171159 | /* 810 */ 193, 116, 117, 118, 216, 217, 116, 117, 118, 226, |
| @@ -170110,133 +171160,133 @@ | ||
| 170110 | 171160 | /* 820 */ 80, 193, 19, 235, 236, 304, 23, 211, 212, 231, |
| 170111 | 171161 | /* 830 */ 204, 216, 217, 205, 102, 103, 104, 105, 106, 107, |
| 170112 | 171162 | /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170113 | 171163 | /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170114 | 171164 | /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, |
| 170115 | - /* 870 */ 240, 239, 240, 193, 106, 107, 193, 89, 252, 193, | |
| 170116 | - /* 880 */ 92, 59, 252, 141, 252, 43, 44, 45, 46, 47, | |
| 171165 | + /* 870 */ 240, 239, 240, 244, 106, 107, 193, 89, 252, 193, | |
| 171166 | + /* 880 */ 92, 59, 252, 254, 252, 43, 44, 45, 46, 47, | |
| 170117 | 171167 | /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 170118 | 171168 | /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, |
| 170119 | - /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 16, | |
| 170120 | - /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 25, | |
| 171169 | + /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 244, | |
| 171170 | + /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 254, | |
| 170121 | 171171 | /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, |
| 170122 | - /* 940 */ 24, 216, 217, 263, 102, 103, 104, 105, 106, 107, | |
| 171172 | + /* 940 */ 24, 216, 217, 273, 102, 103, 104, 105, 106, 107, | |
| 170123 | 171173 | /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170124 | 171174 | /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170125 | 171175 | /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, |
| 170126 | - /* 980 */ 77, 226, 79, 193, 195, 252, 197, 193, 19, 301, | |
| 170127 | - /* 990 */ 302, 193, 193, 204, 216, 217, 226, 216, 217, 266, | |
| 171176 | + /* 980 */ 193, 311, 312, 16, 195, 252, 197, 193, 19, 301, | |
| 171177 | + /* 990 */ 302, 135, 193, 204, 216, 217, 140, 216, 217, 266, | |
| 170128 | 171178 | /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, |
| 170129 | 171179 | /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, |
| 170130 | 171180 | /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, |
| 170131 | - /* 1030 */ 232, 298, 238, 117, 253, 239, 240, 238, 259, 260, | |
| 170132 | - /* 1040 */ 193, 252, 27, 31, 193, 193, 142, 204, 252, 193, | |
| 170133 | - /* 1050 */ 193, 39, 262, 193, 100, 266, 278, 42, 204, 102, | |
| 171181 | + /* 1030 */ 193, 298, 238, 117, 253, 239, 240, 238, 259, 260, | |
| 171182 | + /* 1040 */ 193, 252, 27, 193, 77, 193, 79, 204, 252, 262, | |
| 171183 | + /* 1050 */ 193, 299, 300, 193, 100, 266, 278, 42, 204, 102, | |
| 170134 | 171184 | /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 170135 | 171185 | /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, |
| 170136 | - /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 238, | |
| 171186 | + /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 240, | |
| 170137 | 171187 | /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, |
| 170138 | - /* 1100 */ 24, 193, 216, 217, 216, 217, 252, 153, 154, 155, | |
| 170139 | - /* 1110 */ 253, 16, 19, 144, 213, 268, 43, 44, 45, 46, | |
| 171188 | + /* 1100 */ 263, 252, 216, 217, 216, 217, 252, 153, 154, 155, | |
| 171189 | + /* 1110 */ 253, 193, 19, 144, 213, 268, 43, 44, 45, 46, | |
| 170140 | 171190 | /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170141 | - /* 1130 */ 57, 238, 19, 59, 193, 59, 43, 44, 45, 46, | |
| 171191 | + /* 1130 */ 57, 193, 19, 59, 216, 217, 43, 44, 45, 46, | |
| 170142 | 171192 | /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170143 | - /* 1150 */ 57, 22, 23, 193, 25, 193, 43, 44, 45, 46, | |
| 171193 | + /* 1150 */ 57, 193, 19, 24, 216, 217, 43, 44, 45, 46, | |
| 170144 | 171194 | /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170145 | - /* 1170 */ 57, 284, 77, 193, 79, 102, 103, 104, 105, 106, | |
| 170146 | - /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 193, 193, | |
| 170147 | - /* 1190 */ 193, 117, 291, 117, 232, 102, 103, 104, 105, 106, | |
| 170148 | - /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 22, 23, | |
| 170149 | - /* 1210 */ 66, 25, 216, 217, 35, 102, 103, 104, 105, 106, | |
| 170150 | - /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 268, 85, | |
| 170151 | - /* 1230 */ 101, 193, 309, 309, 240, 19, 313, 313, 94, 208, | |
| 170152 | - /* 1240 */ 209, 193, 239, 240, 193, 66, 252, 19, 268, 244, | |
| 170153 | - /* 1250 */ 216, 217, 193, 74, 213, 252, 161, 19, 263, 254, | |
| 171195 | + /* 1170 */ 57, 284, 193, 208, 209, 102, 103, 104, 105, 106, | |
| 171196 | + /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 59, 193, | |
| 171197 | + /* 1190 */ 232, 117, 291, 193, 193, 102, 103, 104, 105, 106, | |
| 171198 | + /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 193, 204, 22, | |
| 171199 | + /* 1210 */ 23, 193, 25, 66, 193, 102, 103, 104, 105, 106, | |
| 171200 | + /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 193, 193, | |
| 171201 | + /* 1230 */ 216, 217, 85, 193, 238, 19, 16, 216, 217, 238, | |
| 171202 | + /* 1240 */ 193, 94, 193, 239, 240, 231, 117, 268, 35, 116, | |
| 171203 | + /* 1250 */ 216, 217, 216, 217, 22, 23, 252, 25, 208, 209, | |
| 170154 | 171204 | /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 170155 | - /* 1270 */ 54, 55, 56, 57, 193, 216, 217, 5, 59, 193, | |
| 170156 | - /* 1280 */ 19, 244, 10, 11, 12, 13, 14, 101, 309, 17, | |
| 170157 | - /* 1290 */ 146, 254, 313, 193, 193, 76, 115, 216, 217, 309, | |
| 170158 | - /* 1300 */ 12, 263, 30, 313, 32, 46, 87, 46, 89, 130, | |
| 170159 | - /* 1310 */ 193, 92, 40, 22, 263, 27, 216, 217, 102, 103, | |
| 171205 | + /* 1270 */ 54, 55, 56, 57, 193, 193, 19, 5, 59, 66, | |
| 171206 | + /* 1280 */ 193, 263, 10, 11, 12, 13, 14, 74, 101, 17, | |
| 171207 | + /* 1290 */ 193, 46, 193, 146, 193, 76, 213, 77, 263, 79, | |
| 171208 | + /* 1300 */ 12, 260, 30, 46, 32, 264, 87, 193, 89, 29, | |
| 171209 | + /* 1310 */ 263, 92, 40, 33, 232, 27, 193, 108, 102, 103, | |
| 170160 | 171210 | /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 170161 | - /* 1330 */ 42, 150, 291, 216, 217, 116, 117, 118, 19, 20, | |
| 170162 | - /* 1340 */ 193, 22, 70, 260, 116, 193, 24, 264, 193, 263, | |
| 170163 | - /* 1350 */ 78, 63, 61, 81, 116, 36, 193, 260, 193, 29, | |
| 170164 | - /* 1360 */ 193, 264, 193, 33, 145, 193, 59, 48, 216, 217, | |
| 170165 | - /* 1370 */ 98, 216, 217, 193, 115, 193, 115, 193, 59, 216, | |
| 170166 | - /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 255, 216, 217, | |
| 170167 | - /* 1390 */ 71, 193, 131, 193, 25, 65, 216, 217, 216, 217, | |
| 170168 | - /* 1400 */ 216, 217, 208, 209, 85, 133, 193, 100, 193, 90, | |
| 170169 | - /* 1410 */ 138, 139, 138, 139, 216, 217, 216, 217, 193, 100, | |
| 170170 | - /* 1420 */ 193, 108, 135, 116, 117, 106, 107, 140, 121, 216, | |
| 170171 | - /* 1430 */ 217, 216, 217, 114, 162, 116, 117, 118, 299, 300, | |
| 170172 | - /* 1440 */ 121, 216, 217, 216, 217, 193, 244, 193, 135, 244, | |
| 170173 | - /* 1450 */ 193, 256, 257, 140, 244, 193, 254, 193, 193, 254, | |
| 170174 | - /* 1460 */ 153, 154, 155, 141, 254, 149, 150, 258, 216, 217, | |
| 171211 | + /* 1330 */ 42, 138, 139, 101, 193, 116, 117, 118, 19, 20, | |
| 171212 | + /* 1340 */ 255, 22, 70, 130, 135, 65, 256, 257, 193, 140, | |
| 171213 | + /* 1350 */ 78, 63, 193, 81, 193, 36, 193, 216, 217, 193, | |
| 171214 | + /* 1360 */ 115, 193, 263, 193, 145, 268, 59, 48, 193, 193, | |
| 171215 | + /* 1370 */ 98, 193, 115, 193, 291, 216, 217, 193, 59, 216, | |
| 171216 | + /* 1380 */ 217, 161, 216, 217, 216, 217, 216, 217, 131, 193, | |
| 171217 | + /* 1390 */ 71, 193, 216, 217, 216, 217, 216, 217, 193, 260, | |
| 171218 | + /* 1400 */ 216, 217, 19, 264, 85, 133, 244, 100, 193, 90, | |
| 171219 | + /* 1410 */ 138, 139, 216, 217, 216, 217, 254, 244, 193, 100, | |
| 171220 | + /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 254, 121, 193, | |
| 171221 | + /* 1430 */ 115, 216, 217, 114, 162, 116, 117, 118, 115, 244, | |
| 171222 | + /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 193, 31, 254, | |
| 171223 | + /* 1450 */ 313, 309, 216, 217, 309, 313, 39, 193, 313, 309, | |
| 171224 | + /* 1460 */ 153, 154, 155, 313, 193, 150, 25, 144, 216, 217, | |
| 170175 | 171225 | /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, |
| 170176 | - /* 1480 */ 216, 217, 5, 115, 158, 193, 160, 10, 11, 12, | |
| 170177 | - /* 1490 */ 13, 14, 193, 59, 17, 126, 193, 19, 20, 129, | |
| 170178 | - /* 1500 */ 22, 193, 22, 22, 24, 193, 23, 30, 25, 32, | |
| 170179 | - /* 1510 */ 19, 20, 144, 22, 36, 216, 217, 40, 193, 216, | |
| 170180 | - /* 1520 */ 217, 193, 152, 129, 216, 217, 193, 36, 216, 217, | |
| 170181 | - /* 1530 */ 193, 99, 193, 193, 53, 193, 193, 59, 23, 193, | |
| 170182 | - /* 1540 */ 25, 216, 217, 193, 216, 217, 152, 70, 59, 71, | |
| 170183 | - /* 1550 */ 59, 117, 193, 216, 217, 78, 216, 217, 81, 216, | |
| 170184 | - /* 1560 */ 217, 318, 71, 85, 193, 133, 193, 193, 90, 23, | |
| 170185 | - /* 1570 */ 23, 25, 25, 120, 121, 98, 85, 193, 100, 193, | |
| 170186 | - /* 1580 */ 23, 90, 25, 121, 106, 107, 19, 216, 217, 216, | |
| 171226 | + /* 1480 */ 216, 217, 5, 149, 150, 22, 193, 10, 11, 12, | |
| 171227 | + /* 1490 */ 13, 14, 193, 158, 17, 160, 193, 19, 20, 116, | |
| 171228 | + /* 1500 */ 22, 25, 193, 24, 22, 193, 24, 30, 226, 32, | |
| 171229 | + /* 1510 */ 19, 20, 226, 22, 36, 193, 53, 40, 193, 216, | |
| 171230 | + /* 1520 */ 217, 193, 23, 193, 25, 216, 217, 36, 216, 217, | |
| 171231 | + /* 1530 */ 193, 99, 193, 193, 22, 193, 193, 59, 216, 217, | |
| 171232 | + /* 1540 */ 193, 216, 217, 193, 216, 217, 193, 70, 129, 71, | |
| 171233 | + /* 1550 */ 59, 129, 193, 216, 217, 78, 216, 217, 81, 216, | |
| 171234 | + /* 1560 */ 217, 193, 71, 85, 193, 133, 193, 126, 90, 216, | |
| 171235 | + /* 1570 */ 217, 152, 258, 61, 152, 98, 85, 193, 100, 193, | |
| 171236 | + /* 1580 */ 23, 90, 25, 121, 106, 107, 23, 216, 217, 216, | |
| 170187 | 171237 | /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, |
| 170188 | - /* 1600 */ 216, 217, 216, 217, 193, 114, 117, 116, 117, 118, | |
| 170189 | - /* 1610 */ 133, 193, 121, 193, 193, 138, 139, 193, 23, 193, | |
| 170190 | - /* 1620 */ 25, 23, 23, 25, 25, 7, 8, 216, 217, 193, | |
| 170191 | - /* 1630 */ 193, 153, 154, 155, 156, 157, 216, 217, 193, 162, | |
| 171238 | + /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118, | |
| 171239 | + /* 1610 */ 133, 22, 121, 193, 59, 138, 139, 193, 142, 193, | |
| 171240 | + /* 1620 */ 141, 23, 23, 25, 25, 120, 121, 216, 217, 216, | |
| 171241 | + /* 1630 */ 217, 153, 154, 155, 156, 157, 216, 217, 19, 162, | |
| 170192 | 171242 | /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, |
| 170193 | - /* 1650 */ 2, 193, 193, 5, 19, 20, 59, 22, 10, 11, | |
| 170194 | - /* 1660 */ 12, 13, 14, 193, 97, 17, 193, 23, 193, 25, | |
| 170195 | - /* 1670 */ 288, 36, 193, 242, 216, 217, 236, 23, 30, 25, | |
| 171243 | + /* 1650 */ 2, 193, 59, 5, 19, 20, 318, 22, 10, 11, | |
| 171244 | + /* 1660 */ 12, 13, 14, 193, 59, 17, 193, 23, 23, 25, | |
| 171245 | + /* 1670 */ 25, 36, 117, 193, 216, 217, 193, 23, 30, 25, | |
| 170196 | 171246 | /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, |
| 170197 | - /* 1690 */ 217, 216, 217, 193, 59, 216, 217, 193, 36, 83, | |
| 170198 | - /* 1700 */ 84, 153, 153, 155, 155, 23, 71, 25, 23, 193, | |
| 170199 | - /* 1710 */ 25, 193, 193, 193, 117, 193, 193, 193, 70, 193, | |
| 170200 | - /* 1720 */ 193, 59, 193, 255, 255, 287, 78, 255, 243, 81, | |
| 170201 | - /* 1730 */ 191, 255, 297, 71, 271, 100, 293, 245, 267, 214, | |
| 170202 | - /* 1740 */ 246, 106, 107, 108, 246, 271, 98, 245, 293, 114, | |
| 170203 | - /* 1750 */ 220, 116, 117, 118, 267, 271, 121, 271, 225, 219, | |
| 170204 | - /* 1760 */ 229, 219, 100, 219, 259, 259, 259, 259, 106, 107, | |
| 170205 | - /* 1770 */ 249, 196, 60, 280, 141, 243, 114, 249, 116, 117, | |
| 170206 | - /* 1780 */ 118, 133, 245, 121, 200, 297, 138, 139, 153, 154, | |
| 170207 | - /* 1790 */ 155, 156, 157, 297, 200, 38, 19, 20, 151, 22, | |
| 170208 | - /* 1800 */ 200, 150, 140, 294, 294, 22, 272, 43, 234, 18, | |
| 170209 | - /* 1810 */ 162, 270, 200, 36, 237, 153, 154, 155, 156, 157, | |
| 170210 | - /* 1820 */ 237, 283, 237, 237, 18, 199, 149, 246, 272, 270, | |
| 170211 | - /* 1830 */ 272, 200, 158, 246, 246, 234, 59, 234, 246, 199, | |
| 170212 | - /* 1840 */ 290, 62, 289, 200, 199, 22, 221, 115, 71, 200, | |
| 170213 | - /* 1850 */ 200, 199, 199, 221, 218, 218, 19, 20, 64, 22, | |
| 170214 | - /* 1860 */ 218, 227, 22, 224, 126, 224, 165, 221, 24, 305, | |
| 170215 | - /* 1870 */ 200, 113, 312, 36, 218, 220, 218, 100, 282, 218, | |
| 170216 | - /* 1880 */ 91, 218, 317, 106, 107, 221, 227, 282, 317, 82, | |
| 170217 | - /* 1890 */ 148, 114, 265, 116, 117, 118, 59, 145, 121, 22, | |
| 170218 | - /* 1900 */ 277, 158, 200, 265, 25, 202, 147, 250, 71, 279, | |
| 170219 | - /* 1910 */ 13, 146, 194, 194, 249, 248, 250, 140, 247, 246, | |
| 170220 | - /* 1920 */ 6, 192, 192, 192, 303, 303, 213, 207, 300, 213, | |
| 170221 | - /* 1930 */ 153, 154, 155, 156, 157, 213, 213, 100, 213, 222, | |
| 170222 | - /* 1940 */ 207, 214, 214, 106, 107, 4, 222, 207, 3, 22, | |
| 170223 | - /* 1950 */ 163, 114, 15, 116, 117, 118, 16, 23, 121, 23, | |
| 170224 | - /* 1960 */ 139, 151, 130, 25, 142, 16, 24, 20, 144, 1, | |
| 170225 | - /* 1970 */ 142, 130, 130, 61, 53, 53, 37, 151, 53, 53, | |
| 170226 | - /* 1980 */ 130, 116, 34, 1, 141, 5, 22, 115, 161, 141, | |
| 170227 | - /* 1990 */ 153, 154, 155, 156, 157, 25, 68, 68, 75, 41, | |
| 170228 | - /* 2000 */ 115, 24, 131, 20, 19, 125, 22, 96, 22, 22, | |
| 170229 | - /* 2010 */ 67, 23, 22, 67, 59, 24, 22, 28, 67, 23, | |
| 170230 | - /* 2020 */ 22, 22, 149, 23, 23, 23, 116, 23, 25, 37, | |
| 170231 | - /* 2030 */ 97, 141, 23, 23, 22, 143, 25, 75, 88, 34, | |
| 170232 | - /* 2040 */ 34, 34, 34, 86, 75, 93, 23, 34, 22, 34, | |
| 170233 | - /* 2050 */ 25, 24, 34, 25, 23, 142, 23, 142, 44, 23, | |
| 170234 | - /* 2060 */ 23, 23, 11, 23, 25, 22, 22, 22, 15, 23, | |
| 170235 | - /* 2070 */ 23, 22, 22, 25, 1, 1, 141, 25, 23, 135, | |
| 170236 | - /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, | |
| 170237 | - /* 2090 */ 319, 319, 319, 319, 141, 141, 319, 319, 319, 319, | |
| 171247 | + /* 1690 */ 217, 7, 8, 23, 59, 25, 83, 84, 36, 23, | |
| 171248 | + /* 1700 */ 193, 25, 23, 23, 25, 25, 71, 153, 145, 155, | |
| 171249 | + /* 1710 */ 117, 153, 23, 155, 25, 23, 97, 25, 70, 193, | |
| 171250 | + /* 1720 */ 193, 59, 117, 236, 193, 193, 78, 193, 193, 81, | |
| 171251 | + /* 1730 */ 141, 193, 193, 71, 193, 100, 288, 287, 242, 255, | |
| 171252 | + /* 1740 */ 255, 106, 107, 108, 255, 255, 98, 243, 297, 114, | |
| 171253 | + /* 1750 */ 214, 116, 117, 118, 245, 191, 121, 271, 293, 267, | |
| 171254 | + /* 1760 */ 267, 246, 100, 246, 245, 271, 271, 293, 106, 107, | |
| 171255 | + /* 1770 */ 220, 271, 229, 225, 249, 219, 114, 259, 116, 117, | |
| 171256 | + /* 1780 */ 118, 133, 259, 121, 219, 219, 138, 139, 153, 154, | |
| 171257 | + /* 1790 */ 155, 156, 157, 280, 249, 243, 19, 20, 245, 22, | |
| 171258 | + /* 1800 */ 196, 259, 140, 259, 60, 297, 141, 297, 200, 200, | |
| 171259 | + /* 1810 */ 162, 38, 200, 36, 294, 153, 154, 155, 156, 157, | |
| 171260 | + /* 1820 */ 151, 150, 294, 283, 22, 43, 234, 18, 237, 200, | |
| 171261 | + /* 1830 */ 270, 272, 237, 237, 237, 18, 59, 199, 270, 149, | |
| 171262 | + /* 1840 */ 246, 272, 272, 200, 234, 234, 246, 246, 71, 246, | |
| 171263 | + /* 1850 */ 199, 158, 290, 62, 22, 200, 19, 20, 199, 22, | |
| 171264 | + /* 1860 */ 289, 221, 221, 200, 200, 199, 199, 115, 218, 64, | |
| 171265 | + /* 1870 */ 218, 218, 22, 36, 227, 126, 227, 100, 165, 221, | |
| 171266 | + /* 1880 */ 224, 224, 24, 106, 107, 312, 218, 305, 113, 282, | |
| 171267 | + /* 1890 */ 91, 114, 220, 116, 117, 118, 59, 282, 121, 218, | |
| 171268 | + /* 1900 */ 218, 218, 200, 317, 317, 82, 221, 265, 71, 148, | |
| 171269 | + /* 1910 */ 145, 265, 22, 277, 200, 158, 279, 140, 147, 25, | |
| 171270 | + /* 1920 */ 146, 202, 248, 250, 249, 247, 13, 250, 194, 194, | |
| 171271 | + /* 1930 */ 153, 154, 155, 156, 157, 6, 303, 100, 192, 192, | |
| 171272 | + /* 1940 */ 246, 213, 192, 106, 107, 207, 213, 207, 222, 213, | |
| 171273 | + /* 1950 */ 213, 114, 222, 116, 117, 118, 214, 214, 121, 4, | |
| 171274 | + /* 1960 */ 207, 213, 3, 22, 303, 15, 163, 16, 23, 23, | |
| 171275 | + /* 1970 */ 139, 151, 130, 25, 20, 142, 24, 16, 144, 1, | |
| 171276 | + /* 1980 */ 142, 130, 130, 61, 37, 53, 300, 151, 53, 53, | |
| 171277 | + /* 1990 */ 153, 154, 155, 156, 157, 53, 130, 116, 34, 1, | |
| 171278 | + /* 2000 */ 141, 5, 22, 115, 161, 68, 25, 68, 75, 41, | |
| 171279 | + /* 2010 */ 141, 115, 24, 20, 19, 131, 125, 23, 28, 22, | |
| 171280 | + /* 2020 */ 67, 22, 22, 22, 67, 59, 24, 96, 22, 67, | |
| 171281 | + /* 2030 */ 23, 149, 22, 25, 23, 23, 23, 22, 34, 141, | |
| 171282 | + /* 2040 */ 37, 97, 23, 23, 116, 22, 143, 25, 34, 75, | |
| 171283 | + /* 2050 */ 34, 34, 34, 88, 75, 34, 86, 23, 22, 34, | |
| 171284 | + /* 2060 */ 93, 24, 34, 25, 25, 142, 142, 23, 44, 23, | |
| 171285 | + /* 2070 */ 23, 23, 23, 11, 23, 25, 22, 22, 22, 141, | |
| 171286 | + /* 2080 */ 23, 23, 22, 22, 25, 15, 1, 23, 25, 1, | |
| 171287 | + /* 2090 */ 141, 135, 319, 319, 319, 319, 319, 319, 319, 141, | |
| 170238 | 171288 | /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170239 | 171289 | /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170240 | 171290 | /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170241 | 171291 | /* 2130 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170242 | 171292 | /* 2140 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| @@ -170251,180 +171301,181 @@ | ||
| 170251 | 171301 | /* 2230 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170252 | 171302 | /* 2240 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170253 | 171303 | /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170254 | 171304 | /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170255 | 171305 | /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170256 | - /* 2280 */ 319, | |
| 171306 | + /* 2280 */ 319, 319, 319, 319, 319, | |
| 170257 | 171307 | }; |
| 170258 | -#define YY_SHIFT_COUNT (574) | |
| 171308 | +#define YY_SHIFT_COUNT (578) | |
| 170259 | 171309 | #define YY_SHIFT_MIN (0) |
| 170260 | -#define YY_SHIFT_MAX (2074) | |
| 171310 | +#define YY_SHIFT_MAX (2088) | |
| 170261 | 171311 | static const unsigned short int yy_shift_ofst[] = { |
| 170262 | 171312 | /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, |
| 170263 | 171313 | /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, |
| 170264 | 171314 | /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170265 | - /* 30 */ 271, 271, 1219, 1219, 216, 88, 1, 1, 1, 1, | |
| 170266 | - /* 40 */ 1, 40, 111, 258, 361, 469, 512, 583, 622, 693, | |
| 170267 | - /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, | |
| 171315 | + /* 30 */ 1837, 271, 271, 1219, 1219, 216, 88, 1, 1, 1, | |
| 171316 | + /* 40 */ 1, 1, 40, 111, 258, 361, 469, 512, 583, 622, | |
| 171317 | + /* 50 */ 693, 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, | |
| 170268 | 171318 | /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, |
| 170269 | - /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662, | |
| 170270 | - /* 80 */ 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | |
| 171319 | + /* 70 */ 1093, 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, | |
| 171320 | + /* 80 */ 1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, | |
| 170271 | 171321 | /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170272 | 171322 | /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170273 | 171323 | /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170274 | 171324 | /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170275 | - /* 130 */ 137, 181, 181, 181, 181, 181, 181, 181, 94, 430, | |
| 170276 | - /* 140 */ 66, 65, 112, 366, 533, 533, 740, 1261, 533, 533, | |
| 170277 | - /* 150 */ 79, 79, 533, 412, 412, 412, 77, 412, 123, 113, | |
| 170278 | - /* 160 */ 113, 22, 22, 2096, 2096, 328, 328, 328, 239, 468, | |
| 170279 | - /* 170 */ 468, 468, 468, 1015, 1015, 409, 366, 1129, 1186, 533, | |
| 170280 | - /* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, | |
| 170281 | - /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 969, | |
| 170282 | - /* 200 */ 621, 621, 533, 642, 788, 788, 1228, 1228, 822, 822, | |
| 170283 | - /* 210 */ 67, 1274, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 1307, | |
| 170284 | - /* 220 */ 954, 954, 585, 472, 640, 387, 695, 538, 541, 700, | |
| 170285 | - /* 230 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, | |
| 170286 | - /* 240 */ 222, 533, 533, 533, 533, 533, 533, 533, 533, 533, | |
| 170287 | - /* 250 */ 533, 533, 533, 1179, 1179, 1179, 533, 533, 533, 565, | |
| 170288 | - /* 260 */ 533, 533, 533, 916, 1144, 533, 533, 1288, 533, 533, | |
| 170289 | - /* 270 */ 533, 533, 533, 533, 533, 533, 639, 1330, 209, 1076, | |
| 170290 | - /* 280 */ 1076, 1076, 1076, 580, 209, 209, 1313, 768, 917, 649, | |
| 170291 | - /* 290 */ 1181, 1316, 405, 1316, 1238, 249, 1181, 1181, 249, 1181, | |
| 170292 | - /* 300 */ 405, 1238, 1369, 464, 1259, 1012, 1012, 1012, 1368, 1368, | |
| 170293 | - /* 310 */ 1368, 1368, 184, 184, 1326, 904, 1287, 1480, 1712, 1712, | |
| 170294 | - /* 320 */ 1633, 1633, 1757, 1757, 1633, 1647, 1651, 1783, 1764, 1791, | |
| 170295 | - /* 330 */ 1791, 1791, 1791, 1633, 1806, 1677, 1651, 1651, 1677, 1783, | |
| 170296 | - /* 340 */ 1764, 1677, 1764, 1677, 1633, 1806, 1674, 1779, 1633, 1806, | |
| 170297 | - /* 350 */ 1823, 1633, 1806, 1633, 1806, 1823, 1732, 1732, 1732, 1794, | |
| 170298 | - /* 360 */ 1840, 1840, 1823, 1732, 1738, 1732, 1794, 1732, 1732, 1701, | |
| 170299 | - /* 370 */ 1844, 1758, 1758, 1823, 1633, 1789, 1789, 1807, 1807, 1742, | |
| 170300 | - /* 380 */ 1752, 1877, 1633, 1743, 1742, 1759, 1765, 1677, 1879, 1897, | |
| 170301 | - /* 390 */ 1897, 1914, 1914, 1914, 2096, 2096, 2096, 2096, 2096, 2096, | |
| 170302 | - /* 400 */ 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 207, | |
| 170303 | - /* 410 */ 1095, 331, 620, 903, 806, 1074, 1483, 1432, 1481, 1322, | |
| 170304 | - /* 420 */ 1370, 1394, 1515, 1291, 1546, 1547, 1557, 1595, 1598, 1599, | |
| 170305 | - /* 430 */ 1434, 1453, 1618, 1462, 1567, 1489, 1644, 1654, 1616, 1660, | |
| 170306 | - /* 440 */ 1548, 1549, 1682, 1685, 1597, 742, 1941, 1945, 1927, 1787, | |
| 170307 | - /* 450 */ 1937, 1940, 1934, 1936, 1821, 1810, 1832, 1938, 1938, 1942, | |
| 170308 | - /* 460 */ 1822, 1947, 1824, 1949, 1968, 1828, 1841, 1938, 1842, 1912, | |
| 170309 | - /* 470 */ 1939, 1938, 1826, 1921, 1922, 1925, 1926, 1850, 1865, 1948, | |
| 170310 | - /* 480 */ 1843, 1982, 1980, 1964, 1872, 1827, 1928, 1970, 1929, 1923, | |
| 170311 | - /* 490 */ 1958, 1848, 1885, 1977, 1983, 1985, 1871, 1880, 1984, 1943, | |
| 170312 | - /* 500 */ 1986, 1987, 1988, 1990, 1946, 1955, 1991, 1911, 1989, 1994, | |
| 170313 | - /* 510 */ 1951, 1992, 1996, 1873, 1998, 2000, 2001, 2002, 2003, 2004, | |
| 170314 | - /* 520 */ 1999, 1933, 1890, 2009, 2010, 1910, 2005, 2012, 1892, 2011, | |
| 170315 | - /* 530 */ 2006, 2007, 2008, 2013, 1950, 1962, 1957, 2014, 1969, 1952, | |
| 170316 | - /* 540 */ 2015, 2023, 2026, 2027, 2025, 2028, 2018, 1913, 1915, 2031, | |
| 170317 | - /* 550 */ 2011, 2033, 2036, 2037, 2038, 2039, 2040, 2043, 2051, 2044, | |
| 170318 | - /* 560 */ 2045, 2046, 2047, 2049, 2050, 2048, 1944, 1935, 1953, 1954, | |
| 170319 | - /* 570 */ 2052, 2055, 2053, 2073, 2074, | |
| 171325 | + /* 130 */ 1837, 137, 181, 181, 181, 181, 181, 181, 181, 94, | |
| 171326 | + /* 140 */ 430, 66, 65, 112, 366, 533, 533, 740, 1257, 533, | |
| 171327 | + /* 150 */ 533, 79, 79, 533, 412, 412, 412, 77, 412, 123, | |
| 171328 | + /* 160 */ 113, 113, 113, 22, 22, 2100, 2100, 328, 328, 328, | |
| 171329 | + /* 170 */ 239, 468, 468, 468, 468, 1015, 1015, 409, 366, 1187, | |
| 171330 | + /* 180 */ 1232, 533, 533, 533, 533, 533, 533, 533, 533, 533, | |
| 171331 | + /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, | |
| 171332 | + /* 200 */ 533, 969, 621, 621, 533, 642, 788, 788, 1133, 1133, | |
| 171333 | + /* 210 */ 822, 822, 67, 1193, 2100, 2100, 2100, 2100, 2100, 2100, | |
| 171334 | + /* 220 */ 2100, 1307, 954, 954, 585, 472, 640, 387, 695, 538, | |
| 171335 | + /* 230 */ 541, 700, 533, 533, 533, 533, 533, 533, 533, 533, | |
| 171336 | + /* 240 */ 533, 533, 222, 533, 533, 533, 533, 533, 533, 533, | |
| 171337 | + /* 250 */ 533, 533, 533, 533, 533, 1213, 1213, 1213, 533, 533, | |
| 171338 | + /* 260 */ 533, 565, 533, 533, 533, 916, 1147, 533, 533, 1288, | |
| 171339 | + /* 270 */ 533, 533, 533, 533, 533, 533, 533, 533, 639, 1280, | |
| 171340 | + /* 280 */ 209, 1129, 1129, 1129, 1129, 580, 209, 209, 1209, 768, | |
| 171341 | + /* 290 */ 917, 649, 1315, 1334, 405, 1334, 1383, 249, 1315, 1315, | |
| 171342 | + /* 300 */ 249, 1315, 405, 1383, 1441, 464, 1245, 1417, 1417, 1417, | |
| 171343 | + /* 310 */ 1323, 1323, 1323, 1323, 184, 184, 1335, 1476, 856, 1482, | |
| 171344 | + /* 320 */ 1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802, | |
| 171345 | + /* 330 */ 1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671, | |
| 171346 | + /* 340 */ 1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791, | |
| 171347 | + /* 350 */ 1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752, | |
| 171348 | + /* 360 */ 1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752, | |
| 171349 | + /* 370 */ 1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823, | |
| 171350 | + /* 380 */ 1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690, | |
| 171351 | + /* 390 */ 1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100, | |
| 171352 | + /* 400 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, | |
| 171353 | + /* 410 */ 2100, 207, 1220, 331, 620, 967, 806, 1074, 1499, 1432, | |
| 171354 | + /* 420 */ 1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645, | |
| 171355 | + /* 430 */ 1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593, | |
| 171356 | + /* 440 */ 1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589, | |
| 171357 | + /* 450 */ 1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820, | |
| 171358 | + /* 460 */ 1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838, | |
| 171359 | + /* 470 */ 1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936, | |
| 171360 | + /* 480 */ 1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843, | |
| 171361 | + /* 490 */ 1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995, | |
| 171362 | + /* 500 */ 1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966, | |
| 171363 | + /* 510 */ 2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010, | |
| 171364 | + /* 520 */ 2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928, | |
| 171365 | + /* 530 */ 2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974, | |
| 171366 | + /* 540 */ 1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039, | |
| 171367 | + /* 550 */ 2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050, | |
| 171368 | + /* 560 */ 2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059, | |
| 171369 | + /* 570 */ 1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088, | |
| 170320 | 171370 | }; |
| 170321 | -#define YY_REDUCE_COUNT (408) | |
| 171371 | +#define YY_REDUCE_COUNT (410) | |
| 170322 | 171372 | #define YY_REDUCE_MIN (-271) |
| 170323 | -#define YY_REDUCE_MAX (1740) | |
| 171373 | +#define YY_REDUCE_MAX (1753) | |
| 170324 | 171374 | static const short yy_reduce_ofst[] = { |
| 170325 | 171375 | /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, |
| 170326 | 171376 | /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, |
| 170327 | - /* 20 */ 576, -175, 598, 686, 615, 725, 860, 778, 781, 857, | |
| 170328 | - /* 30 */ 616, 887, 87, 240, -192, 408, 626, 796, 843, 854, | |
| 170329 | - /* 40 */ 1003, -271, -271, -271, -271, -271, -271, -271, -271, -271, | |
| 171377 | + /* 20 */ 576, 598, -175, 686, 860, 615, 725, 1014, 778, 781, | |
| 171378 | + /* 30 */ 857, 616, 887, 87, 240, -192, 408, 626, 796, 843, | |
| 171379 | + /* 40 */ 854, 1004, -271, -271, -271, -271, -271, -271, -271, -271, | |
| 170330 | 171380 | /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170331 | 171381 | /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170332 | - /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, 80, 83, | |
| 170333 | - /* 80 */ 313, 886, 888, 996, 1034, 1059, 1081, 1100, 1117, 1152, | |
| 170334 | - /* 90 */ 1155, 1163, 1165, 1167, 1169, 1172, 1180, 1182, 1184, 1198, | |
| 170335 | - /* 100 */ 1200, 1213, 1215, 1225, 1227, 1252, 1254, 1264, 1299, 1303, | |
| 170336 | - /* 110 */ 1308, 1312, 1325, 1328, 1337, 1340, 1343, 1371, 1373, 1384, | |
| 170337 | - /* 120 */ 1386, 1411, 1420, 1424, 1426, 1458, 1470, 1473, 1475, 1479, | |
| 170338 | - /* 130 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, | |
| 170339 | - /* 140 */ -271, 138, 459, 396, -158, 470, 302, -212, 521, 201, | |
| 170340 | - /* 150 */ -195, -92, 559, 630, 632, 630, -271, 632, 901, 63, | |
| 170341 | - /* 160 */ 407, -271, -271, -271, -271, 161, 161, 161, 251, 335, | |
| 170342 | - /* 170 */ 847, 960, 980, 537, 588, 618, 628, 688, 688, -166, | |
| 170343 | - /* 180 */ -161, 674, 790, 794, 799, 851, 852, -122, 680, -120, | |
| 170344 | - /* 190 */ 995, 1038, 415, 1051, 893, 798, 962, 400, 1086, 779, | |
| 170345 | - /* 200 */ 923, 924, 263, 1041, 979, 990, 1083, 1097, 1031, 1194, | |
| 170346 | - /* 210 */ 362, 994, 1139, 1005, 1037, 1202, 1205, 1195, 1210, -194, | |
| 170347 | - /* 220 */ 56, 185, -135, 232, 522, 560, 601, 617, 669, 683, | |
| 170348 | - /* 230 */ 711, 856, 908, 941, 1048, 1101, 1147, 1257, 1262, 1265, | |
| 170349 | - /* 240 */ 392, 1292, 1333, 1339, 1342, 1346, 1350, 1359, 1374, 1418, | |
| 170350 | - /* 250 */ 1421, 1436, 1437, 593, 755, 770, 997, 1445, 1459, 1209, | |
| 170351 | - /* 260 */ 1500, 1504, 1516, 1132, 1243, 1518, 1519, 1440, 1520, 560, | |
| 170352 | - /* 270 */ 1522, 1523, 1524, 1526, 1527, 1529, 1382, 1438, 1431, 1468, | |
| 170353 | - /* 280 */ 1469, 1472, 1476, 1209, 1431, 1431, 1485, 1525, 1539, 1435, | |
| 170354 | - /* 290 */ 1463, 1471, 1492, 1487, 1443, 1494, 1474, 1484, 1498, 1486, | |
| 170355 | - /* 300 */ 1502, 1455, 1530, 1531, 1533, 1540, 1542, 1544, 1505, 1506, | |
| 170356 | - /* 310 */ 1507, 1508, 1521, 1528, 1493, 1537, 1532, 1575, 1488, 1496, | |
| 170357 | - /* 320 */ 1584, 1594, 1509, 1510, 1600, 1538, 1534, 1541, 1574, 1577, | |
| 170358 | - /* 330 */ 1583, 1585, 1586, 1612, 1626, 1581, 1556, 1558, 1587, 1559, | |
| 170359 | - /* 340 */ 1601, 1588, 1603, 1592, 1631, 1640, 1550, 1553, 1643, 1645, | |
| 170360 | - /* 350 */ 1625, 1649, 1652, 1650, 1653, 1632, 1636, 1637, 1642, 1634, | |
| 170361 | - /* 360 */ 1639, 1641, 1646, 1656, 1655, 1658, 1659, 1661, 1663, 1560, | |
| 170362 | - /* 370 */ 1564, 1596, 1605, 1664, 1670, 1565, 1571, 1627, 1638, 1657, | |
| 170363 | - /* 380 */ 1665, 1623, 1702, 1630, 1666, 1667, 1671, 1673, 1703, 1718, | |
| 170364 | - /* 390 */ 1719, 1729, 1730, 1731, 1621, 1622, 1628, 1720, 1713, 1716, | |
| 170365 | - /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, | |
| 171382 | + /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, 80, | |
| 171383 | + /* 80 */ 83, 313, 886, 888, 918, 938, 1021, 1034, 1036, 1141, | |
| 171384 | + /* 90 */ 1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196, | |
| 171385 | + /* 100 */ 1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303, | |
| 171386 | + /* 110 */ 1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371, | |
| 171387 | + /* 120 */ 1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470, | |
| 171388 | + /* 130 */ 1473, -271, -271, -271, -271, -271, -271, -271, -271, -271, | |
| 171389 | + /* 140 */ -271, -271, 138, 459, 396, -158, 470, 302, -212, 521, | |
| 171390 | + /* 150 */ 201, -195, -92, 559, 630, 632, 630, -271, 632, 901, | |
| 171391 | + /* 160 */ 63, 407, 670, -271, -271, -271, -271, 161, 161, 161, | |
| 171392 | + /* 170 */ 251, 335, 847, 979, 1097, 537, 588, 618, 628, 688, | |
| 171393 | + /* 180 */ 688, -166, -161, 674, 787, 794, 799, 852, 996, -122, | |
| 171394 | + /* 190 */ 837, -120, 1018, 1035, 415, 1047, 1001, 958, 1082, 400, | |
| 171395 | + /* 200 */ 1099, 779, 1137, 1142, 263, 1083, 1145, 1150, 1041, 1139, | |
| 171396 | + /* 210 */ 965, 1050, 362, 849, 752, 629, 675, 1162, 1173, 1090, | |
| 171397 | + /* 220 */ 1195, -194, 56, 185, -135, 232, 522, 560, 571, 601, | |
| 171398 | + /* 230 */ 617, 669, 683, 711, 850, 893, 1000, 1040, 1049, 1081, | |
| 171399 | + /* 240 */ 1087, 1101, 392, 1114, 1123, 1155, 1161, 1175, 1271, 1293, | |
| 171400 | + /* 250 */ 1299, 1330, 1339, 1342, 1347, 593, 1282, 1286, 1350, 1359, | |
| 171401 | + /* 260 */ 1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487, | |
| 171402 | + /* 270 */ 1531, 560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450, | |
| 171403 | + /* 280 */ 1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536, | |
| 171404 | + /* 290 */ 1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495, | |
| 171405 | + /* 300 */ 1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566, | |
| 171406 | + /* 310 */ 1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604, | |
| 171407 | + /* 320 */ 1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560, | |
| 171408 | + /* 330 */ 1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570, | |
| 171409 | + /* 340 */ 1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571, | |
| 171410 | + /* 350 */ 1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652, | |
| 171411 | + /* 360 */ 1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682, | |
| 171412 | + /* 370 */ 1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642, | |
| 171413 | + /* 380 */ 1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694, | |
| 171414 | + /* 390 */ 1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738, | |
| 171415 | + /* 400 */ 1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748, | |
| 171416 | + /* 410 */ 1753, | |
| 170366 | 171417 | }; |
| 170367 | 171418 | static const YYACTIONTYPE yy_default[] = { |
| 170368 | - /* 0 */ 1639, 1639, 1639, 1469, 1236, 1347, 1236, 1236, 1236, 1469, | |
| 170369 | - /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, | |
| 170370 | - /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, | |
| 170371 | - /* 30 */ 1236, 1236, 1555, 1555, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170372 | - /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, | |
| 170373 | - /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, | |
| 170374 | - /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, | |
| 170375 | - /* 70 */ 1617, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, | |
| 170376 | - /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170377 | - /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170378 | - /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170379 | - /* 110 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170380 | - /* 120 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170381 | - /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, | |
| 170382 | - /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, | |
| 170383 | - /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, | |
| 170384 | - /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1591, 1590, 1487, 1236, | |
| 170385 | - /* 170 */ 1236, 1236, 1236, 1236, 1236, 1555, 1236, 1236, 1236, 1236, | |
| 170386 | - /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170387 | - /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, | |
| 170388 | - /* 200 */ 1555, 1555, 1236, 1269, 1555, 1555, 1368, 1368, 1265, 1265, | |
| 170389 | - /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, | |
| 170390 | - /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170391 | - /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, | |
| 170392 | - /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170393 | - /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170394 | - /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170395 | - /* 270 */ 1236, 1236, 1236, 1236, 1236, 1584, 1236, 1499, 1325, 1343, | |
| 170396 | - /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1631, | |
| 170397 | - /* 290 */ 1403, 1392, 1344, 1392, 1628, 1390, 1403, 1403, 1390, 1403, | |
| 170398 | - /* 300 */ 1344, 1628, 1286, 1606, 1281, 1377, 1377, 1377, 1367, 1367, | |
| 170399 | - /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1631, 1631, | |
| 170400 | - /* 320 */ 1353, 1353, 1630, 1630, 1353, 1487, 1614, 1412, 1314, 1320, | |
| 170401 | - /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1614, 1614, 1390, 1412, | |
| 170402 | - /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1625, 1353, 1254, | |
| 170403 | - /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, | |
| 170404 | - /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1573, | |
| 170405 | - /* 370 */ 1236, 1481, 1481, 1477, 1353, 1565, 1565, 1380, 1380, 1385, | |
| 170406 | - /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1587, | |
| 170407 | - /* 390 */ 1587, 1583, 1583, 1583, 1636, 1636, 1536, 1599, 1269, 1269, | |
| 170408 | - /* 400 */ 1269, 1269, 1599, 1288, 1288, 1270, 1270, 1269, 1599, 1236, | |
| 170409 | - /* 410 */ 1236, 1236, 1236, 1236, 1236, 1594, 1236, 1531, 1488, 1357, | |
| 170410 | - /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170411 | - /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, | |
| 170412 | - /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, | |
| 170413 | - /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, | |
| 170414 | - /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, | |
| 170415 | - /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170416 | - /* 480 */ 1627, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, | |
| 170417 | - /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170418 | - /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, | |
| 170419 | - /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170420 | - /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, | |
| 170421 | - /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170422 | - /* 540 */ 1236, 1236, 1236, 1236, 1570, 1372, 1236, 1236, 1236, 1236, | |
| 170423 | - /* 550 */ 1618, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, | |
| 170424 | - /* 560 */ 1236, 1236, 1236, 1236, 1236, 1610, 1328, 1418, 1236, 1421, | |
| 170425 | - /* 570 */ 1258, 1236, 1248, 1236, 1236, | |
| 171419 | + /* 0 */ 1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478, | |
| 171420 | + /* 10 */ 1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243, | |
| 171421 | + /* 20 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243, | |
| 171422 | + /* 30 */ 1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243, | |
| 171423 | + /* 40 */ 1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243, | |
| 171424 | + /* 50 */ 1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407, | |
| 171425 | + /* 60 */ 1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475, | |
| 171426 | + /* 70 */ 1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243, | |
| 171427 | + /* 80 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171428 | + /* 90 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171429 | + /* 100 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171430 | + /* 110 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171431 | + /* 120 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171432 | + /* 130 */ 1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443, | |
| 171433 | + /* 140 */ 1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243, | |
| 171434 | + /* 150 */ 1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276, | |
| 171435 | + /* 160 */ 1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599, | |
| 171436 | + /* 170 */ 1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243, | |
| 171437 | + /* 180 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171438 | + /* 190 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171439 | + /* 200 */ 1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375, | |
| 171440 | + /* 210 */ 1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354, | |
| 171441 | + /* 220 */ 1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171442 | + /* 230 */ 1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243, | |
| 171443 | + /* 240 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171444 | + /* 250 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171445 | + /* 260 */ 1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243, | |
| 171446 | + /* 270 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508, | |
| 171447 | + /* 280 */ 1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277, | |
| 171448 | + /* 290 */ 1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410, | |
| 171449 | + /* 300 */ 1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384, | |
| 171450 | + /* 310 */ 1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243, | |
| 171451 | + /* 320 */ 1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419, | |
| 171452 | + /* 330 */ 1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623, | |
| 171453 | + /* 340 */ 1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634, | |
| 171454 | + /* 350 */ 1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319, | |
| 171455 | + /* 360 */ 1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319, | |
| 171456 | + /* 370 */ 1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387, | |
| 171457 | + /* 380 */ 1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397, | |
| 171458 | + /* 390 */ 1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608, | |
| 171459 | + /* 400 */ 1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276, | |
| 171460 | + /* 410 */ 1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540, | |
| 171461 | + /* 420 */ 1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171462 | + /* 430 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243, | |
| 171463 | + /* 440 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424, | |
| 171464 | + /* 450 */ 1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171465 | + /* 460 */ 1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171466 | + /* 470 */ 1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243, | |
| 171467 | + /* 480 */ 1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243, | |
| 171468 | + /* 490 */ 1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243, | |
| 171469 | + /* 500 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291, | |
| 171470 | + /* 510 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171471 | + /* 520 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171472 | + /* 530 */ 1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243, | |
| 171473 | + /* 540 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379, | |
| 171474 | + /* 550 */ 1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243, | |
| 171475 | + /* 560 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619, | |
| 171476 | + /* 570 */ 1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243, | |
| 170426 | 171477 | }; |
| 170427 | 171478 | /********** End of lemon-generated parsing tables *****************************/ |
| 170428 | 171479 | |
| 170429 | 171480 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 170430 | 171481 | ** If a construct like the following: |
| @@ -171227,225 +172278,227 @@ | ||
| 171227 | 172278 | /* 183 */ "term ::= INTEGER", |
| 171228 | 172279 | /* 184 */ "expr ::= VARIABLE", |
| 171229 | 172280 | /* 185 */ "expr ::= expr COLLATE ID|STRING", |
| 171230 | 172281 | /* 186 */ "expr ::= CAST LP expr AS typetoken RP", |
| 171231 | 172282 | /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", |
| 171232 | - /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", | |
| 171233 | - /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", | |
| 171234 | - /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", | |
| 171235 | - /* 191 */ "term ::= CTIME_KW", | |
| 171236 | - /* 192 */ "expr ::= LP nexprlist COMMA expr RP", | |
| 171237 | - /* 193 */ "expr ::= expr AND expr", | |
| 171238 | - /* 194 */ "expr ::= expr OR expr", | |
| 171239 | - /* 195 */ "expr ::= expr LT|GT|GE|LE expr", | |
| 171240 | - /* 196 */ "expr ::= expr EQ|NE expr", | |
| 171241 | - /* 197 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", | |
| 171242 | - /* 198 */ "expr ::= expr PLUS|MINUS expr", | |
| 171243 | - /* 199 */ "expr ::= expr STAR|SLASH|REM expr", | |
| 171244 | - /* 200 */ "expr ::= expr CONCAT expr", | |
| 171245 | - /* 201 */ "likeop ::= NOT LIKE_KW|MATCH", | |
| 171246 | - /* 202 */ "expr ::= expr likeop expr", | |
| 171247 | - /* 203 */ "expr ::= expr likeop expr ESCAPE expr", | |
| 171248 | - /* 204 */ "expr ::= expr ISNULL|NOTNULL", | |
| 171249 | - /* 205 */ "expr ::= expr NOT NULL", | |
| 171250 | - /* 206 */ "expr ::= expr IS expr", | |
| 171251 | - /* 207 */ "expr ::= expr IS NOT expr", | |
| 171252 | - /* 208 */ "expr ::= expr IS NOT DISTINCT FROM expr", | |
| 171253 | - /* 209 */ "expr ::= expr IS DISTINCT FROM expr", | |
| 171254 | - /* 210 */ "expr ::= NOT expr", | |
| 171255 | - /* 211 */ "expr ::= BITNOT expr", | |
| 171256 | - /* 212 */ "expr ::= PLUS|MINUS expr", | |
| 171257 | - /* 213 */ "expr ::= expr PTR expr", | |
| 171258 | - /* 214 */ "between_op ::= BETWEEN", | |
| 171259 | - /* 215 */ "between_op ::= NOT BETWEEN", | |
| 171260 | - /* 216 */ "expr ::= expr between_op expr AND expr", | |
| 171261 | - /* 217 */ "in_op ::= IN", | |
| 171262 | - /* 218 */ "in_op ::= NOT IN", | |
| 171263 | - /* 219 */ "expr ::= expr in_op LP exprlist RP", | |
| 171264 | - /* 220 */ "expr ::= LP select RP", | |
| 171265 | - /* 221 */ "expr ::= expr in_op LP select RP", | |
| 171266 | - /* 222 */ "expr ::= expr in_op nm dbnm paren_exprlist", | |
| 171267 | - /* 223 */ "expr ::= EXISTS LP select RP", | |
| 171268 | - /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", | |
| 171269 | - /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", | |
| 171270 | - /* 226 */ "case_exprlist ::= WHEN expr THEN expr", | |
| 171271 | - /* 227 */ "case_else ::= ELSE expr", | |
| 171272 | - /* 228 */ "case_else ::=", | |
| 171273 | - /* 229 */ "case_operand ::=", | |
| 171274 | - /* 230 */ "exprlist ::=", | |
| 171275 | - /* 231 */ "nexprlist ::= nexprlist COMMA expr", | |
| 171276 | - /* 232 */ "nexprlist ::= expr", | |
| 171277 | - /* 233 */ "paren_exprlist ::=", | |
| 171278 | - /* 234 */ "paren_exprlist ::= LP exprlist RP", | |
| 171279 | - /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", | |
| 171280 | - /* 236 */ "uniqueflag ::= UNIQUE", | |
| 171281 | - /* 237 */ "uniqueflag ::=", | |
| 171282 | - /* 238 */ "eidlist_opt ::=", | |
| 171283 | - /* 239 */ "eidlist_opt ::= LP eidlist RP", | |
| 171284 | - /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder", | |
| 171285 | - /* 241 */ "eidlist ::= nm collate sortorder", | |
| 171286 | - /* 242 */ "collate ::=", | |
| 171287 | - /* 243 */ "collate ::= COLLATE ID|STRING", | |
| 171288 | - /* 244 */ "cmd ::= DROP INDEX ifexists fullname", | |
| 171289 | - /* 245 */ "cmd ::= VACUUM vinto", | |
| 171290 | - /* 246 */ "cmd ::= VACUUM nm vinto", | |
| 171291 | - /* 247 */ "vinto ::= INTO expr", | |
| 171292 | - /* 248 */ "vinto ::=", | |
| 171293 | - /* 249 */ "cmd ::= PRAGMA nm dbnm", | |
| 171294 | - /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", | |
| 171295 | - /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", | |
| 171296 | - /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", | |
| 171297 | - /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", | |
| 171298 | - /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT", | |
| 171299 | - /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT", | |
| 171300 | - /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", | |
| 171301 | - /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", | |
| 171302 | - /* 258 */ "trigger_time ::= BEFORE|AFTER", | |
| 171303 | - /* 259 */ "trigger_time ::= INSTEAD OF", | |
| 171304 | - /* 260 */ "trigger_time ::=", | |
| 171305 | - /* 261 */ "trigger_event ::= DELETE|INSERT", | |
| 171306 | - /* 262 */ "trigger_event ::= UPDATE", | |
| 171307 | - /* 263 */ "trigger_event ::= UPDATE OF idlist", | |
| 171308 | - /* 264 */ "when_clause ::=", | |
| 171309 | - /* 265 */ "when_clause ::= WHEN expr", | |
| 171310 | - /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", | |
| 171311 | - /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI", | |
| 171312 | - /* 268 */ "trnm ::= nm DOT nm", | |
| 171313 | - /* 269 */ "tridxby ::= INDEXED BY nm", | |
| 171314 | - /* 270 */ "tridxby ::= NOT INDEXED", | |
| 171315 | - /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", | |
| 171316 | - /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", | |
| 171317 | - /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", | |
| 171318 | - /* 274 */ "trigger_cmd ::= scanpt select scanpt", | |
| 171319 | - /* 275 */ "expr ::= RAISE LP IGNORE RP", | |
| 171320 | - /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP", | |
| 171321 | - /* 277 */ "raisetype ::= ROLLBACK", | |
| 171322 | - /* 278 */ "raisetype ::= ABORT", | |
| 171323 | - /* 279 */ "raisetype ::= FAIL", | |
| 171324 | - /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname", | |
| 171325 | - /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", | |
| 171326 | - /* 282 */ "cmd ::= DETACH database_kw_opt expr", | |
| 171327 | - /* 283 */ "key_opt ::=", | |
| 171328 | - /* 284 */ "key_opt ::= KEY expr", | |
| 171329 | - /* 285 */ "cmd ::= REINDEX", | |
| 171330 | - /* 286 */ "cmd ::= REINDEX nm dbnm", | |
| 171331 | - /* 287 */ "cmd ::= ANALYZE", | |
| 171332 | - /* 288 */ "cmd ::= ANALYZE nm dbnm", | |
| 171333 | - /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", | |
| 171334 | - /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", | |
| 171335 | - /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", | |
| 171336 | - /* 292 */ "add_column_fullname ::= fullname", | |
| 171337 | - /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", | |
| 171338 | - /* 294 */ "cmd ::= create_vtab", | |
| 171339 | - /* 295 */ "cmd ::= create_vtab LP vtabarglist RP", | |
| 171340 | - /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", | |
| 171341 | - /* 297 */ "vtabarg ::=", | |
| 171342 | - /* 298 */ "vtabargtoken ::= ANY", | |
| 171343 | - /* 299 */ "vtabargtoken ::= lp anylist RP", | |
| 171344 | - /* 300 */ "lp ::= LP", | |
| 171345 | - /* 301 */ "with ::= WITH wqlist", | |
| 171346 | - /* 302 */ "with ::= WITH RECURSIVE wqlist", | |
| 171347 | - /* 303 */ "wqas ::= AS", | |
| 171348 | - /* 304 */ "wqas ::= AS MATERIALIZED", | |
| 171349 | - /* 305 */ "wqas ::= AS NOT MATERIALIZED", | |
| 171350 | - /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", | |
| 171351 | - /* 307 */ "wqlist ::= wqitem", | |
| 171352 | - /* 308 */ "wqlist ::= wqlist COMMA wqitem", | |
| 171353 | - /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", | |
| 171354 | - /* 310 */ "windowdefn ::= nm AS LP window RP", | |
| 171355 | - /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", | |
| 171356 | - /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", | |
| 171357 | - /* 313 */ "window ::= ORDER BY sortlist frame_opt", | |
| 171358 | - /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", | |
| 171359 | - /* 315 */ "window ::= nm frame_opt", | |
| 171360 | - /* 316 */ "frame_opt ::=", | |
| 171361 | - /* 317 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", | |
| 171362 | - /* 318 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", | |
| 171363 | - /* 319 */ "range_or_rows ::= RANGE|ROWS|GROUPS", | |
| 171364 | - /* 320 */ "frame_bound_s ::= frame_bound", | |
| 171365 | - /* 321 */ "frame_bound_s ::= UNBOUNDED PRECEDING", | |
| 171366 | - /* 322 */ "frame_bound_e ::= frame_bound", | |
| 171367 | - /* 323 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", | |
| 171368 | - /* 324 */ "frame_bound ::= expr PRECEDING|FOLLOWING", | |
| 171369 | - /* 325 */ "frame_bound ::= CURRENT ROW", | |
| 171370 | - /* 326 */ "frame_exclude_opt ::=", | |
| 171371 | - /* 327 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", | |
| 171372 | - /* 328 */ "frame_exclude ::= NO OTHERS", | |
| 171373 | - /* 329 */ "frame_exclude ::= CURRENT ROW", | |
| 171374 | - /* 330 */ "frame_exclude ::= GROUP|TIES", | |
| 171375 | - /* 331 */ "window_clause ::= WINDOW windowdefn_list", | |
| 171376 | - /* 332 */ "filter_over ::= filter_clause over_clause", | |
| 171377 | - /* 333 */ "filter_over ::= over_clause", | |
| 171378 | - /* 334 */ "filter_over ::= filter_clause", | |
| 171379 | - /* 335 */ "over_clause ::= OVER LP window RP", | |
| 171380 | - /* 336 */ "over_clause ::= OVER nm", | |
| 171381 | - /* 337 */ "filter_clause ::= FILTER LP WHERE expr RP", | |
| 171382 | - /* 338 */ "input ::= cmdlist", | |
| 171383 | - /* 339 */ "cmdlist ::= cmdlist ecmd", | |
| 171384 | - /* 340 */ "cmdlist ::= ecmd", | |
| 171385 | - /* 341 */ "ecmd ::= SEMI", | |
| 171386 | - /* 342 */ "ecmd ::= cmdx SEMI", | |
| 171387 | - /* 343 */ "ecmd ::= explain cmdx SEMI", | |
| 171388 | - /* 344 */ "trans_opt ::=", | |
| 171389 | - /* 345 */ "trans_opt ::= TRANSACTION", | |
| 171390 | - /* 346 */ "trans_opt ::= TRANSACTION nm", | |
| 171391 | - /* 347 */ "savepoint_opt ::= SAVEPOINT", | |
| 171392 | - /* 348 */ "savepoint_opt ::=", | |
| 171393 | - /* 349 */ "cmd ::= create_table create_table_args", | |
| 171394 | - /* 350 */ "table_option_set ::= table_option", | |
| 171395 | - /* 351 */ "columnlist ::= columnlist COMMA columnname carglist", | |
| 171396 | - /* 352 */ "columnlist ::= columnname carglist", | |
| 171397 | - /* 353 */ "nm ::= ID|INDEXED|JOIN_KW", | |
| 171398 | - /* 354 */ "nm ::= STRING", | |
| 171399 | - /* 355 */ "typetoken ::= typename", | |
| 171400 | - /* 356 */ "typename ::= ID|STRING", | |
| 171401 | - /* 357 */ "signed ::= plus_num", | |
| 171402 | - /* 358 */ "signed ::= minus_num", | |
| 171403 | - /* 359 */ "carglist ::= carglist ccons", | |
| 171404 | - /* 360 */ "carglist ::=", | |
| 171405 | - /* 361 */ "ccons ::= NULL onconf", | |
| 171406 | - /* 362 */ "ccons ::= GENERATED ALWAYS AS generated", | |
| 171407 | - /* 363 */ "ccons ::= AS generated", | |
| 171408 | - /* 364 */ "conslist_opt ::= COMMA conslist", | |
| 171409 | - /* 365 */ "conslist ::= conslist tconscomma tcons", | |
| 171410 | - /* 366 */ "conslist ::= tcons", | |
| 171411 | - /* 367 */ "tconscomma ::=", | |
| 171412 | - /* 368 */ "defer_subclause_opt ::= defer_subclause", | |
| 171413 | - /* 369 */ "resolvetype ::= raisetype", | |
| 171414 | - /* 370 */ "selectnowith ::= oneselect", | |
| 171415 | - /* 371 */ "oneselect ::= values", | |
| 171416 | - /* 372 */ "sclp ::= selcollist COMMA", | |
| 171417 | - /* 373 */ "as ::= ID|STRING", | |
| 171418 | - /* 374 */ "indexed_opt ::= indexed_by", | |
| 171419 | - /* 375 */ "returning ::=", | |
| 171420 | - /* 376 */ "expr ::= term", | |
| 171421 | - /* 377 */ "likeop ::= LIKE_KW|MATCH", | |
| 171422 | - /* 378 */ "case_operand ::= expr", | |
| 171423 | - /* 379 */ "exprlist ::= nexprlist", | |
| 171424 | - /* 380 */ "nmnum ::= plus_num", | |
| 171425 | - /* 381 */ "nmnum ::= nm", | |
| 171426 | - /* 382 */ "nmnum ::= ON", | |
| 171427 | - /* 383 */ "nmnum ::= DELETE", | |
| 171428 | - /* 384 */ "nmnum ::= DEFAULT", | |
| 171429 | - /* 385 */ "plus_num ::= INTEGER|FLOAT", | |
| 171430 | - /* 386 */ "foreach_clause ::=", | |
| 171431 | - /* 387 */ "foreach_clause ::= FOR EACH ROW", | |
| 171432 | - /* 388 */ "trnm ::= nm", | |
| 171433 | - /* 389 */ "tridxby ::=", | |
| 171434 | - /* 390 */ "database_kw_opt ::= DATABASE", | |
| 171435 | - /* 391 */ "database_kw_opt ::=", | |
| 171436 | - /* 392 */ "kwcolumn_opt ::=", | |
| 171437 | - /* 393 */ "kwcolumn_opt ::= COLUMNKW", | |
| 171438 | - /* 394 */ "vtabarglist ::= vtabarg", | |
| 171439 | - /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", | |
| 171440 | - /* 396 */ "vtabarg ::= vtabarg vtabargtoken", | |
| 171441 | - /* 397 */ "anylist ::=", | |
| 171442 | - /* 398 */ "anylist ::= anylist LP anylist RP", | |
| 171443 | - /* 399 */ "anylist ::= anylist ANY", | |
| 171444 | - /* 400 */ "with ::=", | |
| 171445 | - /* 401 */ "windowdefn_list ::= windowdefn", | |
| 171446 | - /* 402 */ "window ::= frame_opt", | |
| 172283 | + /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP", | |
| 172284 | + /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", | |
| 172285 | + /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", | |
| 172286 | + /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over", | |
| 172287 | + /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", | |
| 172288 | + /* 193 */ "term ::= CTIME_KW", | |
| 172289 | + /* 194 */ "expr ::= LP nexprlist COMMA expr RP", | |
| 172290 | + /* 195 */ "expr ::= expr AND expr", | |
| 172291 | + /* 196 */ "expr ::= expr OR expr", | |
| 172292 | + /* 197 */ "expr ::= expr LT|GT|GE|LE expr", | |
| 172293 | + /* 198 */ "expr ::= expr EQ|NE expr", | |
| 172294 | + /* 199 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", | |
| 172295 | + /* 200 */ "expr ::= expr PLUS|MINUS expr", | |
| 172296 | + /* 201 */ "expr ::= expr STAR|SLASH|REM expr", | |
| 172297 | + /* 202 */ "expr ::= expr CONCAT expr", | |
| 172298 | + /* 203 */ "likeop ::= NOT LIKE_KW|MATCH", | |
| 172299 | + /* 204 */ "expr ::= expr likeop expr", | |
| 172300 | + /* 205 */ "expr ::= expr likeop expr ESCAPE expr", | |
| 172301 | + /* 206 */ "expr ::= expr ISNULL|NOTNULL", | |
| 172302 | + /* 207 */ "expr ::= expr NOT NULL", | |
| 172303 | + /* 208 */ "expr ::= expr IS expr", | |
| 172304 | + /* 209 */ "expr ::= expr IS NOT expr", | |
| 172305 | + /* 210 */ "expr ::= expr IS NOT DISTINCT FROM expr", | |
| 172306 | + /* 211 */ "expr ::= expr IS DISTINCT FROM expr", | |
| 172307 | + /* 212 */ "expr ::= NOT expr", | |
| 172308 | + /* 213 */ "expr ::= BITNOT expr", | |
| 172309 | + /* 214 */ "expr ::= PLUS|MINUS expr", | |
| 172310 | + /* 215 */ "expr ::= expr PTR expr", | |
| 172311 | + /* 216 */ "between_op ::= BETWEEN", | |
| 172312 | + /* 217 */ "between_op ::= NOT BETWEEN", | |
| 172313 | + /* 218 */ "expr ::= expr between_op expr AND expr", | |
| 172314 | + /* 219 */ "in_op ::= IN", | |
| 172315 | + /* 220 */ "in_op ::= NOT IN", | |
| 172316 | + /* 221 */ "expr ::= expr in_op LP exprlist RP", | |
| 172317 | + /* 222 */ "expr ::= LP select RP", | |
| 172318 | + /* 223 */ "expr ::= expr in_op LP select RP", | |
| 172319 | + /* 224 */ "expr ::= expr in_op nm dbnm paren_exprlist", | |
| 172320 | + /* 225 */ "expr ::= EXISTS LP select RP", | |
| 172321 | + /* 226 */ "expr ::= CASE case_operand case_exprlist case_else END", | |
| 172322 | + /* 227 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", | |
| 172323 | + /* 228 */ "case_exprlist ::= WHEN expr THEN expr", | |
| 172324 | + /* 229 */ "case_else ::= ELSE expr", | |
| 172325 | + /* 230 */ "case_else ::=", | |
| 172326 | + /* 231 */ "case_operand ::=", | |
| 172327 | + /* 232 */ "exprlist ::=", | |
| 172328 | + /* 233 */ "nexprlist ::= nexprlist COMMA expr", | |
| 172329 | + /* 234 */ "nexprlist ::= expr", | |
| 172330 | + /* 235 */ "paren_exprlist ::=", | |
| 172331 | + /* 236 */ "paren_exprlist ::= LP exprlist RP", | |
| 172332 | + /* 237 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", | |
| 172333 | + /* 238 */ "uniqueflag ::= UNIQUE", | |
| 172334 | + /* 239 */ "uniqueflag ::=", | |
| 172335 | + /* 240 */ "eidlist_opt ::=", | |
| 172336 | + /* 241 */ "eidlist_opt ::= LP eidlist RP", | |
| 172337 | + /* 242 */ "eidlist ::= eidlist COMMA nm collate sortorder", | |
| 172338 | + /* 243 */ "eidlist ::= nm collate sortorder", | |
| 172339 | + /* 244 */ "collate ::=", | |
| 172340 | + /* 245 */ "collate ::= COLLATE ID|STRING", | |
| 172341 | + /* 246 */ "cmd ::= DROP INDEX ifexists fullname", | |
| 172342 | + /* 247 */ "cmd ::= VACUUM vinto", | |
| 172343 | + /* 248 */ "cmd ::= VACUUM nm vinto", | |
| 172344 | + /* 249 */ "vinto ::= INTO expr", | |
| 172345 | + /* 250 */ "vinto ::=", | |
| 172346 | + /* 251 */ "cmd ::= PRAGMA nm dbnm", | |
| 172347 | + /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", | |
| 172348 | + /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", | |
| 172349 | + /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", | |
| 172350 | + /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", | |
| 172351 | + /* 256 */ "plus_num ::= PLUS INTEGER|FLOAT", | |
| 172352 | + /* 257 */ "minus_num ::= MINUS INTEGER|FLOAT", | |
| 172353 | + /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", | |
| 172354 | + /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", | |
| 172355 | + /* 260 */ "trigger_time ::= BEFORE|AFTER", | |
| 172356 | + /* 261 */ "trigger_time ::= INSTEAD OF", | |
| 172357 | + /* 262 */ "trigger_time ::=", | |
| 172358 | + /* 263 */ "trigger_event ::= DELETE|INSERT", | |
| 172359 | + /* 264 */ "trigger_event ::= UPDATE", | |
| 172360 | + /* 265 */ "trigger_event ::= UPDATE OF idlist", | |
| 172361 | + /* 266 */ "when_clause ::=", | |
| 172362 | + /* 267 */ "when_clause ::= WHEN expr", | |
| 172363 | + /* 268 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", | |
| 172364 | + /* 269 */ "trigger_cmd_list ::= trigger_cmd SEMI", | |
| 172365 | + /* 270 */ "trnm ::= nm DOT nm", | |
| 172366 | + /* 271 */ "tridxby ::= INDEXED BY nm", | |
| 172367 | + /* 272 */ "tridxby ::= NOT INDEXED", | |
| 172368 | + /* 273 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", | |
| 172369 | + /* 274 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", | |
| 172370 | + /* 275 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", | |
| 172371 | + /* 276 */ "trigger_cmd ::= scanpt select scanpt", | |
| 172372 | + /* 277 */ "expr ::= RAISE LP IGNORE RP", | |
| 172373 | + /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP", | |
| 172374 | + /* 279 */ "raisetype ::= ROLLBACK", | |
| 172375 | + /* 280 */ "raisetype ::= ABORT", | |
| 172376 | + /* 281 */ "raisetype ::= FAIL", | |
| 172377 | + /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname", | |
| 172378 | + /* 283 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", | |
| 172379 | + /* 284 */ "cmd ::= DETACH database_kw_opt expr", | |
| 172380 | + /* 285 */ "key_opt ::=", | |
| 172381 | + /* 286 */ "key_opt ::= KEY expr", | |
| 172382 | + /* 287 */ "cmd ::= REINDEX", | |
| 172383 | + /* 288 */ "cmd ::= REINDEX nm dbnm", | |
| 172384 | + /* 289 */ "cmd ::= ANALYZE", | |
| 172385 | + /* 290 */ "cmd ::= ANALYZE nm dbnm", | |
| 172386 | + /* 291 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", | |
| 172387 | + /* 292 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", | |
| 172388 | + /* 293 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", | |
| 172389 | + /* 294 */ "add_column_fullname ::= fullname", | |
| 172390 | + /* 295 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", | |
| 172391 | + /* 296 */ "cmd ::= create_vtab", | |
| 172392 | + /* 297 */ "cmd ::= create_vtab LP vtabarglist RP", | |
| 172393 | + /* 298 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", | |
| 172394 | + /* 299 */ "vtabarg ::=", | |
| 172395 | + /* 300 */ "vtabargtoken ::= ANY", | |
| 172396 | + /* 301 */ "vtabargtoken ::= lp anylist RP", | |
| 172397 | + /* 302 */ "lp ::= LP", | |
| 172398 | + /* 303 */ "with ::= WITH wqlist", | |
| 172399 | + /* 304 */ "with ::= WITH RECURSIVE wqlist", | |
| 172400 | + /* 305 */ "wqas ::= AS", | |
| 172401 | + /* 306 */ "wqas ::= AS MATERIALIZED", | |
| 172402 | + /* 307 */ "wqas ::= AS NOT MATERIALIZED", | |
| 172403 | + /* 308 */ "wqitem ::= nm eidlist_opt wqas LP select RP", | |
| 172404 | + /* 309 */ "wqlist ::= wqitem", | |
| 172405 | + /* 310 */ "wqlist ::= wqlist COMMA wqitem", | |
| 172406 | + /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", | |
| 172407 | + /* 312 */ "windowdefn ::= nm AS LP window RP", | |
| 172408 | + /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", | |
| 172409 | + /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", | |
| 172410 | + /* 315 */ "window ::= ORDER BY sortlist frame_opt", | |
| 172411 | + /* 316 */ "window ::= nm ORDER BY sortlist frame_opt", | |
| 172412 | + /* 317 */ "window ::= nm frame_opt", | |
| 172413 | + /* 318 */ "frame_opt ::=", | |
| 172414 | + /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", | |
| 172415 | + /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", | |
| 172416 | + /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS", | |
| 172417 | + /* 322 */ "frame_bound_s ::= frame_bound", | |
| 172418 | + /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING", | |
| 172419 | + /* 324 */ "frame_bound_e ::= frame_bound", | |
| 172420 | + /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", | |
| 172421 | + /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING", | |
| 172422 | + /* 327 */ "frame_bound ::= CURRENT ROW", | |
| 172423 | + /* 328 */ "frame_exclude_opt ::=", | |
| 172424 | + /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", | |
| 172425 | + /* 330 */ "frame_exclude ::= NO OTHERS", | |
| 172426 | + /* 331 */ "frame_exclude ::= CURRENT ROW", | |
| 172427 | + /* 332 */ "frame_exclude ::= GROUP|TIES", | |
| 172428 | + /* 333 */ "window_clause ::= WINDOW windowdefn_list", | |
| 172429 | + /* 334 */ "filter_over ::= filter_clause over_clause", | |
| 172430 | + /* 335 */ "filter_over ::= over_clause", | |
| 172431 | + /* 336 */ "filter_over ::= filter_clause", | |
| 172432 | + /* 337 */ "over_clause ::= OVER LP window RP", | |
| 172433 | + /* 338 */ "over_clause ::= OVER nm", | |
| 172434 | + /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP", | |
| 172435 | + /* 340 */ "input ::= cmdlist", | |
| 172436 | + /* 341 */ "cmdlist ::= cmdlist ecmd", | |
| 172437 | + /* 342 */ "cmdlist ::= ecmd", | |
| 172438 | + /* 343 */ "ecmd ::= SEMI", | |
| 172439 | + /* 344 */ "ecmd ::= cmdx SEMI", | |
| 172440 | + /* 345 */ "ecmd ::= explain cmdx SEMI", | |
| 172441 | + /* 346 */ "trans_opt ::=", | |
| 172442 | + /* 347 */ "trans_opt ::= TRANSACTION", | |
| 172443 | + /* 348 */ "trans_opt ::= TRANSACTION nm", | |
| 172444 | + /* 349 */ "savepoint_opt ::= SAVEPOINT", | |
| 172445 | + /* 350 */ "savepoint_opt ::=", | |
| 172446 | + /* 351 */ "cmd ::= create_table create_table_args", | |
| 172447 | + /* 352 */ "table_option_set ::= table_option", | |
| 172448 | + /* 353 */ "columnlist ::= columnlist COMMA columnname carglist", | |
| 172449 | + /* 354 */ "columnlist ::= columnname carglist", | |
| 172450 | + /* 355 */ "nm ::= ID|INDEXED|JOIN_KW", | |
| 172451 | + /* 356 */ "nm ::= STRING", | |
| 172452 | + /* 357 */ "typetoken ::= typename", | |
| 172453 | + /* 358 */ "typename ::= ID|STRING", | |
| 172454 | + /* 359 */ "signed ::= plus_num", | |
| 172455 | + /* 360 */ "signed ::= minus_num", | |
| 172456 | + /* 361 */ "carglist ::= carglist ccons", | |
| 172457 | + /* 362 */ "carglist ::=", | |
| 172458 | + /* 363 */ "ccons ::= NULL onconf", | |
| 172459 | + /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", | |
| 172460 | + /* 365 */ "ccons ::= AS generated", | |
| 172461 | + /* 366 */ "conslist_opt ::= COMMA conslist", | |
| 172462 | + /* 367 */ "conslist ::= conslist tconscomma tcons", | |
| 172463 | + /* 368 */ "conslist ::= tcons", | |
| 172464 | + /* 369 */ "tconscomma ::=", | |
| 172465 | + /* 370 */ "defer_subclause_opt ::= defer_subclause", | |
| 172466 | + /* 371 */ "resolvetype ::= raisetype", | |
| 172467 | + /* 372 */ "selectnowith ::= oneselect", | |
| 172468 | + /* 373 */ "oneselect ::= values", | |
| 172469 | + /* 374 */ "sclp ::= selcollist COMMA", | |
| 172470 | + /* 375 */ "as ::= ID|STRING", | |
| 172471 | + /* 376 */ "indexed_opt ::= indexed_by", | |
| 172472 | + /* 377 */ "returning ::=", | |
| 172473 | + /* 378 */ "expr ::= term", | |
| 172474 | + /* 379 */ "likeop ::= LIKE_KW|MATCH", | |
| 172475 | + /* 380 */ "case_operand ::= expr", | |
| 172476 | + /* 381 */ "exprlist ::= nexprlist", | |
| 172477 | + /* 382 */ "nmnum ::= plus_num", | |
| 172478 | + /* 383 */ "nmnum ::= nm", | |
| 172479 | + /* 384 */ "nmnum ::= ON", | |
| 172480 | + /* 385 */ "nmnum ::= DELETE", | |
| 172481 | + /* 386 */ "nmnum ::= DEFAULT", | |
| 172482 | + /* 387 */ "plus_num ::= INTEGER|FLOAT", | |
| 172483 | + /* 388 */ "foreach_clause ::=", | |
| 172484 | + /* 389 */ "foreach_clause ::= FOR EACH ROW", | |
| 172485 | + /* 390 */ "trnm ::= nm", | |
| 172486 | + /* 391 */ "tridxby ::=", | |
| 172487 | + /* 392 */ "database_kw_opt ::= DATABASE", | |
| 172488 | + /* 393 */ "database_kw_opt ::=", | |
| 172489 | + /* 394 */ "kwcolumn_opt ::=", | |
| 172490 | + /* 395 */ "kwcolumn_opt ::= COLUMNKW", | |
| 172491 | + /* 396 */ "vtabarglist ::= vtabarg", | |
| 172492 | + /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg", | |
| 172493 | + /* 398 */ "vtabarg ::= vtabarg vtabargtoken", | |
| 172494 | + /* 399 */ "anylist ::=", | |
| 172495 | + /* 400 */ "anylist ::= anylist LP anylist RP", | |
| 172496 | + /* 401 */ "anylist ::= anylist ANY", | |
| 172497 | + /* 402 */ "with ::=", | |
| 172498 | + /* 403 */ "windowdefn_list ::= windowdefn", | |
| 172499 | + /* 404 */ "window ::= frame_opt", | |
| 171447 | 172500 | }; |
| 171448 | 172501 | #endif /* NDEBUG */ |
| 171449 | 172502 | |
| 171450 | 172503 | |
| 171451 | 172504 | #if YYSTACKDEPTH<=0 |
| @@ -172136,225 +173189,227 @@ | ||
| 172136 | 173189 | 216, /* (183) term ::= INTEGER */ |
| 172137 | 173190 | 217, /* (184) expr ::= VARIABLE */ |
| 172138 | 173191 | 217, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 172139 | 173192 | 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 172140 | 173193 | 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 172141 | - 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | |
| 172142 | - 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | |
| 172143 | - 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | |
| 172144 | - 216, /* (191) term ::= CTIME_KW */ | |
| 172145 | - 217, /* (192) expr ::= LP nexprlist COMMA expr RP */ | |
| 172146 | - 217, /* (193) expr ::= expr AND expr */ | |
| 172147 | - 217, /* (194) expr ::= expr OR expr */ | |
| 172148 | - 217, /* (195) expr ::= expr LT|GT|GE|LE expr */ | |
| 172149 | - 217, /* (196) expr ::= expr EQ|NE expr */ | |
| 172150 | - 217, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | |
| 172151 | - 217, /* (198) expr ::= expr PLUS|MINUS expr */ | |
| 172152 | - 217, /* (199) expr ::= expr STAR|SLASH|REM expr */ | |
| 172153 | - 217, /* (200) expr ::= expr CONCAT expr */ | |
| 172154 | - 274, /* (201) likeop ::= NOT LIKE_KW|MATCH */ | |
| 172155 | - 217, /* (202) expr ::= expr likeop expr */ | |
| 172156 | - 217, /* (203) expr ::= expr likeop expr ESCAPE expr */ | |
| 172157 | - 217, /* (204) expr ::= expr ISNULL|NOTNULL */ | |
| 172158 | - 217, /* (205) expr ::= expr NOT NULL */ | |
| 172159 | - 217, /* (206) expr ::= expr IS expr */ | |
| 172160 | - 217, /* (207) expr ::= expr IS NOT expr */ | |
| 172161 | - 217, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ | |
| 172162 | - 217, /* (209) expr ::= expr IS DISTINCT FROM expr */ | |
| 172163 | - 217, /* (210) expr ::= NOT expr */ | |
| 172164 | - 217, /* (211) expr ::= BITNOT expr */ | |
| 172165 | - 217, /* (212) expr ::= PLUS|MINUS expr */ | |
| 172166 | - 217, /* (213) expr ::= expr PTR expr */ | |
| 172167 | - 275, /* (214) between_op ::= BETWEEN */ | |
| 172168 | - 275, /* (215) between_op ::= NOT BETWEEN */ | |
| 172169 | - 217, /* (216) expr ::= expr between_op expr AND expr */ | |
| 172170 | - 276, /* (217) in_op ::= IN */ | |
| 172171 | - 276, /* (218) in_op ::= NOT IN */ | |
| 172172 | - 217, /* (219) expr ::= expr in_op LP exprlist RP */ | |
| 172173 | - 217, /* (220) expr ::= LP select RP */ | |
| 172174 | - 217, /* (221) expr ::= expr in_op LP select RP */ | |
| 172175 | - 217, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ | |
| 172176 | - 217, /* (223) expr ::= EXISTS LP select RP */ | |
| 172177 | - 217, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ | |
| 172178 | - 279, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 172179 | - 279, /* (226) case_exprlist ::= WHEN expr THEN expr */ | |
| 172180 | - 280, /* (227) case_else ::= ELSE expr */ | |
| 172181 | - 280, /* (228) case_else ::= */ | |
| 172182 | - 278, /* (229) case_operand ::= */ | |
| 172183 | - 261, /* (230) exprlist ::= */ | |
| 172184 | - 253, /* (231) nexprlist ::= nexprlist COMMA expr */ | |
| 172185 | - 253, /* (232) nexprlist ::= expr */ | |
| 172186 | - 277, /* (233) paren_exprlist ::= */ | |
| 172187 | - 277, /* (234) paren_exprlist ::= LP exprlist RP */ | |
| 172188 | - 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | |
| 172189 | - 281, /* (236) uniqueflag ::= UNIQUE */ | |
| 172190 | - 281, /* (237) uniqueflag ::= */ | |
| 172191 | - 221, /* (238) eidlist_opt ::= */ | |
| 172192 | - 221, /* (239) eidlist_opt ::= LP eidlist RP */ | |
| 172193 | - 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ | |
| 172194 | - 232, /* (241) eidlist ::= nm collate sortorder */ | |
| 172195 | - 282, /* (242) collate ::= */ | |
| 172196 | - 282, /* (243) collate ::= COLLATE ID|STRING */ | |
| 172197 | - 190, /* (244) cmd ::= DROP INDEX ifexists fullname */ | |
| 172198 | - 190, /* (245) cmd ::= VACUUM vinto */ | |
| 172199 | - 190, /* (246) cmd ::= VACUUM nm vinto */ | |
| 172200 | - 283, /* (247) vinto ::= INTO expr */ | |
| 172201 | - 283, /* (248) vinto ::= */ | |
| 172202 | - 190, /* (249) cmd ::= PRAGMA nm dbnm */ | |
| 172203 | - 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 172204 | - 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 172205 | - 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 172206 | - 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 172207 | - 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ | |
| 172208 | - 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ | |
| 172209 | - 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | |
| 172210 | - 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | |
| 172211 | - 287, /* (258) trigger_time ::= BEFORE|AFTER */ | |
| 172212 | - 287, /* (259) trigger_time ::= INSTEAD OF */ | |
| 172213 | - 287, /* (260) trigger_time ::= */ | |
| 172214 | - 288, /* (261) trigger_event ::= DELETE|INSERT */ | |
| 172215 | - 288, /* (262) trigger_event ::= UPDATE */ | |
| 172216 | - 288, /* (263) trigger_event ::= UPDATE OF idlist */ | |
| 172217 | - 290, /* (264) when_clause ::= */ | |
| 172218 | - 290, /* (265) when_clause ::= WHEN expr */ | |
| 172219 | - 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | |
| 172220 | - 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 172221 | - 292, /* (268) trnm ::= nm DOT nm */ | |
| 172222 | - 293, /* (269) tridxby ::= INDEXED BY nm */ | |
| 172223 | - 293, /* (270) tridxby ::= NOT INDEXED */ | |
| 172224 | - 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | |
| 172225 | - 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | |
| 172226 | - 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | |
| 172227 | - 291, /* (274) trigger_cmd ::= scanpt select scanpt */ | |
| 172228 | - 217, /* (275) expr ::= RAISE LP IGNORE RP */ | |
| 172229 | - 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 172230 | - 236, /* (277) raisetype ::= ROLLBACK */ | |
| 172231 | - 236, /* (278) raisetype ::= ABORT */ | |
| 172232 | - 236, /* (279) raisetype ::= FAIL */ | |
| 172233 | - 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ | |
| 172234 | - 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | |
| 172235 | - 190, /* (282) cmd ::= DETACH database_kw_opt expr */ | |
| 172236 | - 295, /* (283) key_opt ::= */ | |
| 172237 | - 295, /* (284) key_opt ::= KEY expr */ | |
| 172238 | - 190, /* (285) cmd ::= REINDEX */ | |
| 172239 | - 190, /* (286) cmd ::= REINDEX nm dbnm */ | |
| 172240 | - 190, /* (287) cmd ::= ANALYZE */ | |
| 172241 | - 190, /* (288) cmd ::= ANALYZE nm dbnm */ | |
| 172242 | - 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 172243 | - 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | |
| 172244 | - 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | |
| 172245 | - 296, /* (292) add_column_fullname ::= fullname */ | |
| 172246 | - 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | |
| 172247 | - 190, /* (294) cmd ::= create_vtab */ | |
| 172248 | - 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */ | |
| 172249 | - 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | |
| 172250 | - 300, /* (297) vtabarg ::= */ | |
| 172251 | - 301, /* (298) vtabargtoken ::= ANY */ | |
| 172252 | - 301, /* (299) vtabargtoken ::= lp anylist RP */ | |
| 172253 | - 302, /* (300) lp ::= LP */ | |
| 172254 | - 266, /* (301) with ::= WITH wqlist */ | |
| 172255 | - 266, /* (302) with ::= WITH RECURSIVE wqlist */ | |
| 172256 | - 305, /* (303) wqas ::= AS */ | |
| 172257 | - 305, /* (304) wqas ::= AS MATERIALIZED */ | |
| 172258 | - 305, /* (305) wqas ::= AS NOT MATERIALIZED */ | |
| 172259 | - 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ | |
| 172260 | - 241, /* (307) wqlist ::= wqitem */ | |
| 172261 | - 241, /* (308) wqlist ::= wqlist COMMA wqitem */ | |
| 172262 | - 306, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | |
| 172263 | - 307, /* (310) windowdefn ::= nm AS LP window RP */ | |
| 172264 | - 308, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 172265 | - 308, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 172266 | - 308, /* (313) window ::= ORDER BY sortlist frame_opt */ | |
| 172267 | - 308, /* (314) window ::= nm ORDER BY sortlist frame_opt */ | |
| 172268 | - 308, /* (315) window ::= nm frame_opt */ | |
| 172269 | - 309, /* (316) frame_opt ::= */ | |
| 172270 | - 309, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | |
| 172271 | - 309, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | |
| 172272 | - 313, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ | |
| 172273 | - 315, /* (320) frame_bound_s ::= frame_bound */ | |
| 172274 | - 315, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ | |
| 172275 | - 316, /* (322) frame_bound_e ::= frame_bound */ | |
| 172276 | - 316, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ | |
| 172277 | - 314, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ | |
| 172278 | - 314, /* (325) frame_bound ::= CURRENT ROW */ | |
| 172279 | - 317, /* (326) frame_exclude_opt ::= */ | |
| 172280 | - 317, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ | |
| 172281 | - 318, /* (328) frame_exclude ::= NO OTHERS */ | |
| 172282 | - 318, /* (329) frame_exclude ::= CURRENT ROW */ | |
| 172283 | - 318, /* (330) frame_exclude ::= GROUP|TIES */ | |
| 172284 | - 251, /* (331) window_clause ::= WINDOW windowdefn_list */ | |
| 172285 | - 273, /* (332) filter_over ::= filter_clause over_clause */ | |
| 172286 | - 273, /* (333) filter_over ::= over_clause */ | |
| 172287 | - 273, /* (334) filter_over ::= filter_clause */ | |
| 172288 | - 312, /* (335) over_clause ::= OVER LP window RP */ | |
| 172289 | - 312, /* (336) over_clause ::= OVER nm */ | |
| 172290 | - 311, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ | |
| 172291 | - 185, /* (338) input ::= cmdlist */ | |
| 172292 | - 186, /* (339) cmdlist ::= cmdlist ecmd */ | |
| 172293 | - 186, /* (340) cmdlist ::= ecmd */ | |
| 172294 | - 187, /* (341) ecmd ::= SEMI */ | |
| 172295 | - 187, /* (342) ecmd ::= cmdx SEMI */ | |
| 172296 | - 187, /* (343) ecmd ::= explain cmdx SEMI */ | |
| 172297 | - 192, /* (344) trans_opt ::= */ | |
| 172298 | - 192, /* (345) trans_opt ::= TRANSACTION */ | |
| 172299 | - 192, /* (346) trans_opt ::= TRANSACTION nm */ | |
| 172300 | - 194, /* (347) savepoint_opt ::= SAVEPOINT */ | |
| 172301 | - 194, /* (348) savepoint_opt ::= */ | |
| 172302 | - 190, /* (349) cmd ::= create_table create_table_args */ | |
| 172303 | - 203, /* (350) table_option_set ::= table_option */ | |
| 172304 | - 201, /* (351) columnlist ::= columnlist COMMA columnname carglist */ | |
| 172305 | - 201, /* (352) columnlist ::= columnname carglist */ | |
| 172306 | - 193, /* (353) nm ::= ID|INDEXED|JOIN_KW */ | |
| 172307 | - 193, /* (354) nm ::= STRING */ | |
| 172308 | - 208, /* (355) typetoken ::= typename */ | |
| 172309 | - 209, /* (356) typename ::= ID|STRING */ | |
| 172310 | - 210, /* (357) signed ::= plus_num */ | |
| 172311 | - 210, /* (358) signed ::= minus_num */ | |
| 172312 | - 207, /* (359) carglist ::= carglist ccons */ | |
| 172313 | - 207, /* (360) carglist ::= */ | |
| 172314 | - 215, /* (361) ccons ::= NULL onconf */ | |
| 172315 | - 215, /* (362) ccons ::= GENERATED ALWAYS AS generated */ | |
| 172316 | - 215, /* (363) ccons ::= AS generated */ | |
| 172317 | - 202, /* (364) conslist_opt ::= COMMA conslist */ | |
| 172318 | - 228, /* (365) conslist ::= conslist tconscomma tcons */ | |
| 172319 | - 228, /* (366) conslist ::= tcons */ | |
| 172320 | - 229, /* (367) tconscomma ::= */ | |
| 172321 | - 233, /* (368) defer_subclause_opt ::= defer_subclause */ | |
| 172322 | - 235, /* (369) resolvetype ::= raisetype */ | |
| 172323 | - 239, /* (370) selectnowith ::= oneselect */ | |
| 172324 | - 240, /* (371) oneselect ::= values */ | |
| 172325 | - 254, /* (372) sclp ::= selcollist COMMA */ | |
| 172326 | - 255, /* (373) as ::= ID|STRING */ | |
| 172327 | - 264, /* (374) indexed_opt ::= indexed_by */ | |
| 172328 | - 272, /* (375) returning ::= */ | |
| 172329 | - 217, /* (376) expr ::= term */ | |
| 172330 | - 274, /* (377) likeop ::= LIKE_KW|MATCH */ | |
| 172331 | - 278, /* (378) case_operand ::= expr */ | |
| 172332 | - 261, /* (379) exprlist ::= nexprlist */ | |
| 172333 | - 284, /* (380) nmnum ::= plus_num */ | |
| 172334 | - 284, /* (381) nmnum ::= nm */ | |
| 172335 | - 284, /* (382) nmnum ::= ON */ | |
| 172336 | - 284, /* (383) nmnum ::= DELETE */ | |
| 172337 | - 284, /* (384) nmnum ::= DEFAULT */ | |
| 172338 | - 211, /* (385) plus_num ::= INTEGER|FLOAT */ | |
| 172339 | - 289, /* (386) foreach_clause ::= */ | |
| 172340 | - 289, /* (387) foreach_clause ::= FOR EACH ROW */ | |
| 172341 | - 292, /* (388) trnm ::= nm */ | |
| 172342 | - 293, /* (389) tridxby ::= */ | |
| 172343 | - 294, /* (390) database_kw_opt ::= DATABASE */ | |
| 172344 | - 294, /* (391) database_kw_opt ::= */ | |
| 172345 | - 297, /* (392) kwcolumn_opt ::= */ | |
| 172346 | - 297, /* (393) kwcolumn_opt ::= COLUMNKW */ | |
| 172347 | - 299, /* (394) vtabarglist ::= vtabarg */ | |
| 172348 | - 299, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ | |
| 172349 | - 300, /* (396) vtabarg ::= vtabarg vtabargtoken */ | |
| 172350 | - 303, /* (397) anylist ::= */ | |
| 172351 | - 303, /* (398) anylist ::= anylist LP anylist RP */ | |
| 172352 | - 303, /* (399) anylist ::= anylist ANY */ | |
| 172353 | - 266, /* (400) with ::= */ | |
| 172354 | - 306, /* (401) windowdefn_list ::= windowdefn */ | |
| 172355 | - 308, /* (402) window ::= frame_opt */ | |
| 173194 | + 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ | |
| 173195 | + 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | |
| 173196 | + 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | |
| 173197 | + 217, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ | |
| 173198 | + 217, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | |
| 173199 | + 216, /* (193) term ::= CTIME_KW */ | |
| 173200 | + 217, /* (194) expr ::= LP nexprlist COMMA expr RP */ | |
| 173201 | + 217, /* (195) expr ::= expr AND expr */ | |
| 173202 | + 217, /* (196) expr ::= expr OR expr */ | |
| 173203 | + 217, /* (197) expr ::= expr LT|GT|GE|LE expr */ | |
| 173204 | + 217, /* (198) expr ::= expr EQ|NE expr */ | |
| 173205 | + 217, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | |
| 173206 | + 217, /* (200) expr ::= expr PLUS|MINUS expr */ | |
| 173207 | + 217, /* (201) expr ::= expr STAR|SLASH|REM expr */ | |
| 173208 | + 217, /* (202) expr ::= expr CONCAT expr */ | |
| 173209 | + 274, /* (203) likeop ::= NOT LIKE_KW|MATCH */ | |
| 173210 | + 217, /* (204) expr ::= expr likeop expr */ | |
| 173211 | + 217, /* (205) expr ::= expr likeop expr ESCAPE expr */ | |
| 173212 | + 217, /* (206) expr ::= expr ISNULL|NOTNULL */ | |
| 173213 | + 217, /* (207) expr ::= expr NOT NULL */ | |
| 173214 | + 217, /* (208) expr ::= expr IS expr */ | |
| 173215 | + 217, /* (209) expr ::= expr IS NOT expr */ | |
| 173216 | + 217, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ | |
| 173217 | + 217, /* (211) expr ::= expr IS DISTINCT FROM expr */ | |
| 173218 | + 217, /* (212) expr ::= NOT expr */ | |
| 173219 | + 217, /* (213) expr ::= BITNOT expr */ | |
| 173220 | + 217, /* (214) expr ::= PLUS|MINUS expr */ | |
| 173221 | + 217, /* (215) expr ::= expr PTR expr */ | |
| 173222 | + 275, /* (216) between_op ::= BETWEEN */ | |
| 173223 | + 275, /* (217) between_op ::= NOT BETWEEN */ | |
| 173224 | + 217, /* (218) expr ::= expr between_op expr AND expr */ | |
| 173225 | + 276, /* (219) in_op ::= IN */ | |
| 173226 | + 276, /* (220) in_op ::= NOT IN */ | |
| 173227 | + 217, /* (221) expr ::= expr in_op LP exprlist RP */ | |
| 173228 | + 217, /* (222) expr ::= LP select RP */ | |
| 173229 | + 217, /* (223) expr ::= expr in_op LP select RP */ | |
| 173230 | + 217, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ | |
| 173231 | + 217, /* (225) expr ::= EXISTS LP select RP */ | |
| 173232 | + 217, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ | |
| 173233 | + 279, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 173234 | + 279, /* (228) case_exprlist ::= WHEN expr THEN expr */ | |
| 173235 | + 280, /* (229) case_else ::= ELSE expr */ | |
| 173236 | + 280, /* (230) case_else ::= */ | |
| 173237 | + 278, /* (231) case_operand ::= */ | |
| 173238 | + 261, /* (232) exprlist ::= */ | |
| 173239 | + 253, /* (233) nexprlist ::= nexprlist COMMA expr */ | |
| 173240 | + 253, /* (234) nexprlist ::= expr */ | |
| 173241 | + 277, /* (235) paren_exprlist ::= */ | |
| 173242 | + 277, /* (236) paren_exprlist ::= LP exprlist RP */ | |
| 173243 | + 190, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | |
| 173244 | + 281, /* (238) uniqueflag ::= UNIQUE */ | |
| 173245 | + 281, /* (239) uniqueflag ::= */ | |
| 173246 | + 221, /* (240) eidlist_opt ::= */ | |
| 173247 | + 221, /* (241) eidlist_opt ::= LP eidlist RP */ | |
| 173248 | + 232, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ | |
| 173249 | + 232, /* (243) eidlist ::= nm collate sortorder */ | |
| 173250 | + 282, /* (244) collate ::= */ | |
| 173251 | + 282, /* (245) collate ::= COLLATE ID|STRING */ | |
| 173252 | + 190, /* (246) cmd ::= DROP INDEX ifexists fullname */ | |
| 173253 | + 190, /* (247) cmd ::= VACUUM vinto */ | |
| 173254 | + 190, /* (248) cmd ::= VACUUM nm vinto */ | |
| 173255 | + 283, /* (249) vinto ::= INTO expr */ | |
| 173256 | + 283, /* (250) vinto ::= */ | |
| 173257 | + 190, /* (251) cmd ::= PRAGMA nm dbnm */ | |
| 173258 | + 190, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 173259 | + 190, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 173260 | + 190, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 173261 | + 190, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 173262 | + 211, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ | |
| 173263 | + 212, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ | |
| 173264 | + 190, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | |
| 173265 | + 285, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | |
| 173266 | + 287, /* (260) trigger_time ::= BEFORE|AFTER */ | |
| 173267 | + 287, /* (261) trigger_time ::= INSTEAD OF */ | |
| 173268 | + 287, /* (262) trigger_time ::= */ | |
| 173269 | + 288, /* (263) trigger_event ::= DELETE|INSERT */ | |
| 173270 | + 288, /* (264) trigger_event ::= UPDATE */ | |
| 173271 | + 288, /* (265) trigger_event ::= UPDATE OF idlist */ | |
| 173272 | + 290, /* (266) when_clause ::= */ | |
| 173273 | + 290, /* (267) when_clause ::= WHEN expr */ | |
| 173274 | + 286, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | |
| 173275 | + 286, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 173276 | + 292, /* (270) trnm ::= nm DOT nm */ | |
| 173277 | + 293, /* (271) tridxby ::= INDEXED BY nm */ | |
| 173278 | + 293, /* (272) tridxby ::= NOT INDEXED */ | |
| 173279 | + 291, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | |
| 173280 | + 291, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | |
| 173281 | + 291, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | |
| 173282 | + 291, /* (276) trigger_cmd ::= scanpt select scanpt */ | |
| 173283 | + 217, /* (277) expr ::= RAISE LP IGNORE RP */ | |
| 173284 | + 217, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 173285 | + 236, /* (279) raisetype ::= ROLLBACK */ | |
| 173286 | + 236, /* (280) raisetype ::= ABORT */ | |
| 173287 | + 236, /* (281) raisetype ::= FAIL */ | |
| 173288 | + 190, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ | |
| 173289 | + 190, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | |
| 173290 | + 190, /* (284) cmd ::= DETACH database_kw_opt expr */ | |
| 173291 | + 295, /* (285) key_opt ::= */ | |
| 173292 | + 295, /* (286) key_opt ::= KEY expr */ | |
| 173293 | + 190, /* (287) cmd ::= REINDEX */ | |
| 173294 | + 190, /* (288) cmd ::= REINDEX nm dbnm */ | |
| 173295 | + 190, /* (289) cmd ::= ANALYZE */ | |
| 173296 | + 190, /* (290) cmd ::= ANALYZE nm dbnm */ | |
| 173297 | + 190, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 173298 | + 190, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | |
| 173299 | + 190, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | |
| 173300 | + 296, /* (294) add_column_fullname ::= fullname */ | |
| 173301 | + 190, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | |
| 173302 | + 190, /* (296) cmd ::= create_vtab */ | |
| 173303 | + 190, /* (297) cmd ::= create_vtab LP vtabarglist RP */ | |
| 173304 | + 298, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | |
| 173305 | + 300, /* (299) vtabarg ::= */ | |
| 173306 | + 301, /* (300) vtabargtoken ::= ANY */ | |
| 173307 | + 301, /* (301) vtabargtoken ::= lp anylist RP */ | |
| 173308 | + 302, /* (302) lp ::= LP */ | |
| 173309 | + 266, /* (303) with ::= WITH wqlist */ | |
| 173310 | + 266, /* (304) with ::= WITH RECURSIVE wqlist */ | |
| 173311 | + 305, /* (305) wqas ::= AS */ | |
| 173312 | + 305, /* (306) wqas ::= AS MATERIALIZED */ | |
| 173313 | + 305, /* (307) wqas ::= AS NOT MATERIALIZED */ | |
| 173314 | + 304, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ | |
| 173315 | + 241, /* (309) wqlist ::= wqitem */ | |
| 173316 | + 241, /* (310) wqlist ::= wqlist COMMA wqitem */ | |
| 173317 | + 306, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | |
| 173318 | + 307, /* (312) windowdefn ::= nm AS LP window RP */ | |
| 173319 | + 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 173320 | + 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 173321 | + 308, /* (315) window ::= ORDER BY sortlist frame_opt */ | |
| 173322 | + 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */ | |
| 173323 | + 308, /* (317) window ::= nm frame_opt */ | |
| 173324 | + 309, /* (318) frame_opt ::= */ | |
| 173325 | + 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | |
| 173326 | + 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | |
| 173327 | + 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ | |
| 173328 | + 315, /* (322) frame_bound_s ::= frame_bound */ | |
| 173329 | + 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ | |
| 173330 | + 316, /* (324) frame_bound_e ::= frame_bound */ | |
| 173331 | + 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ | |
| 173332 | + 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ | |
| 173333 | + 314, /* (327) frame_bound ::= CURRENT ROW */ | |
| 173334 | + 317, /* (328) frame_exclude_opt ::= */ | |
| 173335 | + 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ | |
| 173336 | + 318, /* (330) frame_exclude ::= NO OTHERS */ | |
| 173337 | + 318, /* (331) frame_exclude ::= CURRENT ROW */ | |
| 173338 | + 318, /* (332) frame_exclude ::= GROUP|TIES */ | |
| 173339 | + 251, /* (333) window_clause ::= WINDOW windowdefn_list */ | |
| 173340 | + 273, /* (334) filter_over ::= filter_clause over_clause */ | |
| 173341 | + 273, /* (335) filter_over ::= over_clause */ | |
| 173342 | + 273, /* (336) filter_over ::= filter_clause */ | |
| 173343 | + 312, /* (337) over_clause ::= OVER LP window RP */ | |
| 173344 | + 312, /* (338) over_clause ::= OVER nm */ | |
| 173345 | + 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ | |
| 173346 | + 185, /* (340) input ::= cmdlist */ | |
| 173347 | + 186, /* (341) cmdlist ::= cmdlist ecmd */ | |
| 173348 | + 186, /* (342) cmdlist ::= ecmd */ | |
| 173349 | + 187, /* (343) ecmd ::= SEMI */ | |
| 173350 | + 187, /* (344) ecmd ::= cmdx SEMI */ | |
| 173351 | + 187, /* (345) ecmd ::= explain cmdx SEMI */ | |
| 173352 | + 192, /* (346) trans_opt ::= */ | |
| 173353 | + 192, /* (347) trans_opt ::= TRANSACTION */ | |
| 173354 | + 192, /* (348) trans_opt ::= TRANSACTION nm */ | |
| 173355 | + 194, /* (349) savepoint_opt ::= SAVEPOINT */ | |
| 173356 | + 194, /* (350) savepoint_opt ::= */ | |
| 173357 | + 190, /* (351) cmd ::= create_table create_table_args */ | |
| 173358 | + 203, /* (352) table_option_set ::= table_option */ | |
| 173359 | + 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */ | |
| 173360 | + 201, /* (354) columnlist ::= columnname carglist */ | |
| 173361 | + 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */ | |
| 173362 | + 193, /* (356) nm ::= STRING */ | |
| 173363 | + 208, /* (357) typetoken ::= typename */ | |
| 173364 | + 209, /* (358) typename ::= ID|STRING */ | |
| 173365 | + 210, /* (359) signed ::= plus_num */ | |
| 173366 | + 210, /* (360) signed ::= minus_num */ | |
| 173367 | + 207, /* (361) carglist ::= carglist ccons */ | |
| 173368 | + 207, /* (362) carglist ::= */ | |
| 173369 | + 215, /* (363) ccons ::= NULL onconf */ | |
| 173370 | + 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */ | |
| 173371 | + 215, /* (365) ccons ::= AS generated */ | |
| 173372 | + 202, /* (366) conslist_opt ::= COMMA conslist */ | |
| 173373 | + 228, /* (367) conslist ::= conslist tconscomma tcons */ | |
| 173374 | + 228, /* (368) conslist ::= tcons */ | |
| 173375 | + 229, /* (369) tconscomma ::= */ | |
| 173376 | + 233, /* (370) defer_subclause_opt ::= defer_subclause */ | |
| 173377 | + 235, /* (371) resolvetype ::= raisetype */ | |
| 173378 | + 239, /* (372) selectnowith ::= oneselect */ | |
| 173379 | + 240, /* (373) oneselect ::= values */ | |
| 173380 | + 254, /* (374) sclp ::= selcollist COMMA */ | |
| 173381 | + 255, /* (375) as ::= ID|STRING */ | |
| 173382 | + 264, /* (376) indexed_opt ::= indexed_by */ | |
| 173383 | + 272, /* (377) returning ::= */ | |
| 173384 | + 217, /* (378) expr ::= term */ | |
| 173385 | + 274, /* (379) likeop ::= LIKE_KW|MATCH */ | |
| 173386 | + 278, /* (380) case_operand ::= expr */ | |
| 173387 | + 261, /* (381) exprlist ::= nexprlist */ | |
| 173388 | + 284, /* (382) nmnum ::= plus_num */ | |
| 173389 | + 284, /* (383) nmnum ::= nm */ | |
| 173390 | + 284, /* (384) nmnum ::= ON */ | |
| 173391 | + 284, /* (385) nmnum ::= DELETE */ | |
| 173392 | + 284, /* (386) nmnum ::= DEFAULT */ | |
| 173393 | + 211, /* (387) plus_num ::= INTEGER|FLOAT */ | |
| 173394 | + 289, /* (388) foreach_clause ::= */ | |
| 173395 | + 289, /* (389) foreach_clause ::= FOR EACH ROW */ | |
| 173396 | + 292, /* (390) trnm ::= nm */ | |
| 173397 | + 293, /* (391) tridxby ::= */ | |
| 173398 | + 294, /* (392) database_kw_opt ::= DATABASE */ | |
| 173399 | + 294, /* (393) database_kw_opt ::= */ | |
| 173400 | + 297, /* (394) kwcolumn_opt ::= */ | |
| 173401 | + 297, /* (395) kwcolumn_opt ::= COLUMNKW */ | |
| 173402 | + 299, /* (396) vtabarglist ::= vtabarg */ | |
| 173403 | + 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ | |
| 173404 | + 300, /* (398) vtabarg ::= vtabarg vtabargtoken */ | |
| 173405 | + 303, /* (399) anylist ::= */ | |
| 173406 | + 303, /* (400) anylist ::= anylist LP anylist RP */ | |
| 173407 | + 303, /* (401) anylist ::= anylist ANY */ | |
| 173408 | + 266, /* (402) with ::= */ | |
| 173409 | + 306, /* (403) windowdefn_list ::= windowdefn */ | |
| 173410 | + 308, /* (404) window ::= frame_opt */ | |
| 172356 | 173411 | }; |
| 172357 | 173412 | |
| 172358 | 173413 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| 172359 | 173414 | ** of symbols on the right-hand side of that rule. */ |
| 172360 | 173415 | static const signed char yyRuleInfoNRhs[] = { |
| @@ -172544,225 +173599,227 @@ | ||
| 172544 | 173599 | -1, /* (183) term ::= INTEGER */ |
| 172545 | 173600 | -1, /* (184) expr ::= VARIABLE */ |
| 172546 | 173601 | -3, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 172547 | 173602 | -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 172548 | 173603 | -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 172549 | - -4, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | |
| 172550 | - -6, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | |
| 172551 | - -5, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | |
| 172552 | - -1, /* (191) term ::= CTIME_KW */ | |
| 172553 | - -5, /* (192) expr ::= LP nexprlist COMMA expr RP */ | |
| 172554 | - -3, /* (193) expr ::= expr AND expr */ | |
| 172555 | - -3, /* (194) expr ::= expr OR expr */ | |
| 172556 | - -3, /* (195) expr ::= expr LT|GT|GE|LE expr */ | |
| 172557 | - -3, /* (196) expr ::= expr EQ|NE expr */ | |
| 172558 | - -3, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | |
| 172559 | - -3, /* (198) expr ::= expr PLUS|MINUS expr */ | |
| 172560 | - -3, /* (199) expr ::= expr STAR|SLASH|REM expr */ | |
| 172561 | - -3, /* (200) expr ::= expr CONCAT expr */ | |
| 172562 | - -2, /* (201) likeop ::= NOT LIKE_KW|MATCH */ | |
| 172563 | - -3, /* (202) expr ::= expr likeop expr */ | |
| 172564 | - -5, /* (203) expr ::= expr likeop expr ESCAPE expr */ | |
| 172565 | - -2, /* (204) expr ::= expr ISNULL|NOTNULL */ | |
| 172566 | - -3, /* (205) expr ::= expr NOT NULL */ | |
| 172567 | - -3, /* (206) expr ::= expr IS expr */ | |
| 172568 | - -4, /* (207) expr ::= expr IS NOT expr */ | |
| 172569 | - -6, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ | |
| 172570 | - -5, /* (209) expr ::= expr IS DISTINCT FROM expr */ | |
| 172571 | - -2, /* (210) expr ::= NOT expr */ | |
| 172572 | - -2, /* (211) expr ::= BITNOT expr */ | |
| 172573 | - -2, /* (212) expr ::= PLUS|MINUS expr */ | |
| 172574 | - -3, /* (213) expr ::= expr PTR expr */ | |
| 172575 | - -1, /* (214) between_op ::= BETWEEN */ | |
| 172576 | - -2, /* (215) between_op ::= NOT BETWEEN */ | |
| 172577 | - -5, /* (216) expr ::= expr between_op expr AND expr */ | |
| 172578 | - -1, /* (217) in_op ::= IN */ | |
| 172579 | - -2, /* (218) in_op ::= NOT IN */ | |
| 172580 | - -5, /* (219) expr ::= expr in_op LP exprlist RP */ | |
| 172581 | - -3, /* (220) expr ::= LP select RP */ | |
| 172582 | - -5, /* (221) expr ::= expr in_op LP select RP */ | |
| 172583 | - -5, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ | |
| 172584 | - -4, /* (223) expr ::= EXISTS LP select RP */ | |
| 172585 | - -5, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ | |
| 172586 | - -5, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 172587 | - -4, /* (226) case_exprlist ::= WHEN expr THEN expr */ | |
| 172588 | - -2, /* (227) case_else ::= ELSE expr */ | |
| 172589 | - 0, /* (228) case_else ::= */ | |
| 172590 | - 0, /* (229) case_operand ::= */ | |
| 172591 | - 0, /* (230) exprlist ::= */ | |
| 172592 | - -3, /* (231) nexprlist ::= nexprlist COMMA expr */ | |
| 172593 | - -1, /* (232) nexprlist ::= expr */ | |
| 172594 | - 0, /* (233) paren_exprlist ::= */ | |
| 172595 | - -3, /* (234) paren_exprlist ::= LP exprlist RP */ | |
| 172596 | - -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | |
| 172597 | - -1, /* (236) uniqueflag ::= UNIQUE */ | |
| 172598 | - 0, /* (237) uniqueflag ::= */ | |
| 172599 | - 0, /* (238) eidlist_opt ::= */ | |
| 172600 | - -3, /* (239) eidlist_opt ::= LP eidlist RP */ | |
| 172601 | - -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ | |
| 172602 | - -3, /* (241) eidlist ::= nm collate sortorder */ | |
| 172603 | - 0, /* (242) collate ::= */ | |
| 172604 | - -2, /* (243) collate ::= COLLATE ID|STRING */ | |
| 172605 | - -4, /* (244) cmd ::= DROP INDEX ifexists fullname */ | |
| 172606 | - -2, /* (245) cmd ::= VACUUM vinto */ | |
| 172607 | - -3, /* (246) cmd ::= VACUUM nm vinto */ | |
| 172608 | - -2, /* (247) vinto ::= INTO expr */ | |
| 172609 | - 0, /* (248) vinto ::= */ | |
| 172610 | - -3, /* (249) cmd ::= PRAGMA nm dbnm */ | |
| 172611 | - -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 172612 | - -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 172613 | - -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 172614 | - -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 172615 | - -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ | |
| 172616 | - -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ | |
| 172617 | - -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | |
| 172618 | - -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | |
| 172619 | - -1, /* (258) trigger_time ::= BEFORE|AFTER */ | |
| 172620 | - -2, /* (259) trigger_time ::= INSTEAD OF */ | |
| 172621 | - 0, /* (260) trigger_time ::= */ | |
| 172622 | - -1, /* (261) trigger_event ::= DELETE|INSERT */ | |
| 172623 | - -1, /* (262) trigger_event ::= UPDATE */ | |
| 172624 | - -3, /* (263) trigger_event ::= UPDATE OF idlist */ | |
| 172625 | - 0, /* (264) when_clause ::= */ | |
| 172626 | - -2, /* (265) when_clause ::= WHEN expr */ | |
| 172627 | - -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | |
| 172628 | - -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 172629 | - -3, /* (268) trnm ::= nm DOT nm */ | |
| 172630 | - -3, /* (269) tridxby ::= INDEXED BY nm */ | |
| 172631 | - -2, /* (270) tridxby ::= NOT INDEXED */ | |
| 172632 | - -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | |
| 172633 | - -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | |
| 172634 | - -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | |
| 172635 | - -3, /* (274) trigger_cmd ::= scanpt select scanpt */ | |
| 172636 | - -4, /* (275) expr ::= RAISE LP IGNORE RP */ | |
| 172637 | - -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 172638 | - -1, /* (277) raisetype ::= ROLLBACK */ | |
| 172639 | - -1, /* (278) raisetype ::= ABORT */ | |
| 172640 | - -1, /* (279) raisetype ::= FAIL */ | |
| 172641 | - -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ | |
| 172642 | - -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | |
| 172643 | - -3, /* (282) cmd ::= DETACH database_kw_opt expr */ | |
| 172644 | - 0, /* (283) key_opt ::= */ | |
| 172645 | - -2, /* (284) key_opt ::= KEY expr */ | |
| 172646 | - -1, /* (285) cmd ::= REINDEX */ | |
| 172647 | - -3, /* (286) cmd ::= REINDEX nm dbnm */ | |
| 172648 | - -1, /* (287) cmd ::= ANALYZE */ | |
| 172649 | - -3, /* (288) cmd ::= ANALYZE nm dbnm */ | |
| 172650 | - -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 172651 | - -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | |
| 172652 | - -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | |
| 172653 | - -1, /* (292) add_column_fullname ::= fullname */ | |
| 172654 | - -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | |
| 172655 | - -1, /* (294) cmd ::= create_vtab */ | |
| 172656 | - -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */ | |
| 172657 | - -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | |
| 172658 | - 0, /* (297) vtabarg ::= */ | |
| 172659 | - -1, /* (298) vtabargtoken ::= ANY */ | |
| 172660 | - -3, /* (299) vtabargtoken ::= lp anylist RP */ | |
| 172661 | - -1, /* (300) lp ::= LP */ | |
| 172662 | - -2, /* (301) with ::= WITH wqlist */ | |
| 172663 | - -3, /* (302) with ::= WITH RECURSIVE wqlist */ | |
| 172664 | - -1, /* (303) wqas ::= AS */ | |
| 172665 | - -2, /* (304) wqas ::= AS MATERIALIZED */ | |
| 172666 | - -3, /* (305) wqas ::= AS NOT MATERIALIZED */ | |
| 172667 | - -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ | |
| 172668 | - -1, /* (307) wqlist ::= wqitem */ | |
| 172669 | - -3, /* (308) wqlist ::= wqlist COMMA wqitem */ | |
| 172670 | - -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | |
| 172671 | - -5, /* (310) windowdefn ::= nm AS LP window RP */ | |
| 172672 | - -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 172673 | - -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 172674 | - -4, /* (313) window ::= ORDER BY sortlist frame_opt */ | |
| 172675 | - -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ | |
| 172676 | - -2, /* (315) window ::= nm frame_opt */ | |
| 172677 | - 0, /* (316) frame_opt ::= */ | |
| 172678 | - -3, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | |
| 172679 | - -6, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | |
| 172680 | - -1, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ | |
| 172681 | - -1, /* (320) frame_bound_s ::= frame_bound */ | |
| 172682 | - -2, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ | |
| 172683 | - -1, /* (322) frame_bound_e ::= frame_bound */ | |
| 172684 | - -2, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ | |
| 172685 | - -2, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ | |
| 172686 | - -2, /* (325) frame_bound ::= CURRENT ROW */ | |
| 172687 | - 0, /* (326) frame_exclude_opt ::= */ | |
| 172688 | - -2, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ | |
| 172689 | - -2, /* (328) frame_exclude ::= NO OTHERS */ | |
| 172690 | - -2, /* (329) frame_exclude ::= CURRENT ROW */ | |
| 172691 | - -1, /* (330) frame_exclude ::= GROUP|TIES */ | |
| 172692 | - -2, /* (331) window_clause ::= WINDOW windowdefn_list */ | |
| 172693 | - -2, /* (332) filter_over ::= filter_clause over_clause */ | |
| 172694 | - -1, /* (333) filter_over ::= over_clause */ | |
| 172695 | - -1, /* (334) filter_over ::= filter_clause */ | |
| 172696 | - -4, /* (335) over_clause ::= OVER LP window RP */ | |
| 172697 | - -2, /* (336) over_clause ::= OVER nm */ | |
| 172698 | - -5, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ | |
| 172699 | - -1, /* (338) input ::= cmdlist */ | |
| 172700 | - -2, /* (339) cmdlist ::= cmdlist ecmd */ | |
| 172701 | - -1, /* (340) cmdlist ::= ecmd */ | |
| 172702 | - -1, /* (341) ecmd ::= SEMI */ | |
| 172703 | - -2, /* (342) ecmd ::= cmdx SEMI */ | |
| 172704 | - -3, /* (343) ecmd ::= explain cmdx SEMI */ | |
| 172705 | - 0, /* (344) trans_opt ::= */ | |
| 172706 | - -1, /* (345) trans_opt ::= TRANSACTION */ | |
| 172707 | - -2, /* (346) trans_opt ::= TRANSACTION nm */ | |
| 172708 | - -1, /* (347) savepoint_opt ::= SAVEPOINT */ | |
| 172709 | - 0, /* (348) savepoint_opt ::= */ | |
| 172710 | - -2, /* (349) cmd ::= create_table create_table_args */ | |
| 172711 | - -1, /* (350) table_option_set ::= table_option */ | |
| 172712 | - -4, /* (351) columnlist ::= columnlist COMMA columnname carglist */ | |
| 172713 | - -2, /* (352) columnlist ::= columnname carglist */ | |
| 172714 | - -1, /* (353) nm ::= ID|INDEXED|JOIN_KW */ | |
| 172715 | - -1, /* (354) nm ::= STRING */ | |
| 172716 | - -1, /* (355) typetoken ::= typename */ | |
| 172717 | - -1, /* (356) typename ::= ID|STRING */ | |
| 172718 | - -1, /* (357) signed ::= plus_num */ | |
| 172719 | - -1, /* (358) signed ::= minus_num */ | |
| 172720 | - -2, /* (359) carglist ::= carglist ccons */ | |
| 172721 | - 0, /* (360) carglist ::= */ | |
| 172722 | - -2, /* (361) ccons ::= NULL onconf */ | |
| 172723 | - -4, /* (362) ccons ::= GENERATED ALWAYS AS generated */ | |
| 172724 | - -2, /* (363) ccons ::= AS generated */ | |
| 172725 | - -2, /* (364) conslist_opt ::= COMMA conslist */ | |
| 172726 | - -3, /* (365) conslist ::= conslist tconscomma tcons */ | |
| 172727 | - -1, /* (366) conslist ::= tcons */ | |
| 172728 | - 0, /* (367) tconscomma ::= */ | |
| 172729 | - -1, /* (368) defer_subclause_opt ::= defer_subclause */ | |
| 172730 | - -1, /* (369) resolvetype ::= raisetype */ | |
| 172731 | - -1, /* (370) selectnowith ::= oneselect */ | |
| 172732 | - -1, /* (371) oneselect ::= values */ | |
| 172733 | - -2, /* (372) sclp ::= selcollist COMMA */ | |
| 172734 | - -1, /* (373) as ::= ID|STRING */ | |
| 172735 | - -1, /* (374) indexed_opt ::= indexed_by */ | |
| 172736 | - 0, /* (375) returning ::= */ | |
| 172737 | - -1, /* (376) expr ::= term */ | |
| 172738 | - -1, /* (377) likeop ::= LIKE_KW|MATCH */ | |
| 172739 | - -1, /* (378) case_operand ::= expr */ | |
| 172740 | - -1, /* (379) exprlist ::= nexprlist */ | |
| 172741 | - -1, /* (380) nmnum ::= plus_num */ | |
| 172742 | - -1, /* (381) nmnum ::= nm */ | |
| 172743 | - -1, /* (382) nmnum ::= ON */ | |
| 172744 | - -1, /* (383) nmnum ::= DELETE */ | |
| 172745 | - -1, /* (384) nmnum ::= DEFAULT */ | |
| 172746 | - -1, /* (385) plus_num ::= INTEGER|FLOAT */ | |
| 172747 | - 0, /* (386) foreach_clause ::= */ | |
| 172748 | - -3, /* (387) foreach_clause ::= FOR EACH ROW */ | |
| 172749 | - -1, /* (388) trnm ::= nm */ | |
| 172750 | - 0, /* (389) tridxby ::= */ | |
| 172751 | - -1, /* (390) database_kw_opt ::= DATABASE */ | |
| 172752 | - 0, /* (391) database_kw_opt ::= */ | |
| 172753 | - 0, /* (392) kwcolumn_opt ::= */ | |
| 172754 | - -1, /* (393) kwcolumn_opt ::= COLUMNKW */ | |
| 172755 | - -1, /* (394) vtabarglist ::= vtabarg */ | |
| 172756 | - -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ | |
| 172757 | - -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ | |
| 172758 | - 0, /* (397) anylist ::= */ | |
| 172759 | - -4, /* (398) anylist ::= anylist LP anylist RP */ | |
| 172760 | - -2, /* (399) anylist ::= anylist ANY */ | |
| 172761 | - 0, /* (400) with ::= */ | |
| 172762 | - -1, /* (401) windowdefn_list ::= windowdefn */ | |
| 172763 | - -1, /* (402) window ::= frame_opt */ | |
| 173604 | + -8, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ | |
| 173605 | + -4, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | |
| 173606 | + -6, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | |
| 173607 | + -9, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ | |
| 173608 | + -5, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | |
| 173609 | + -1, /* (193) term ::= CTIME_KW */ | |
| 173610 | + -5, /* (194) expr ::= LP nexprlist COMMA expr RP */ | |
| 173611 | + -3, /* (195) expr ::= expr AND expr */ | |
| 173612 | + -3, /* (196) expr ::= expr OR expr */ | |
| 173613 | + -3, /* (197) expr ::= expr LT|GT|GE|LE expr */ | |
| 173614 | + -3, /* (198) expr ::= expr EQ|NE expr */ | |
| 173615 | + -3, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | |
| 173616 | + -3, /* (200) expr ::= expr PLUS|MINUS expr */ | |
| 173617 | + -3, /* (201) expr ::= expr STAR|SLASH|REM expr */ | |
| 173618 | + -3, /* (202) expr ::= expr CONCAT expr */ | |
| 173619 | + -2, /* (203) likeop ::= NOT LIKE_KW|MATCH */ | |
| 173620 | + -3, /* (204) expr ::= expr likeop expr */ | |
| 173621 | + -5, /* (205) expr ::= expr likeop expr ESCAPE expr */ | |
| 173622 | + -2, /* (206) expr ::= expr ISNULL|NOTNULL */ | |
| 173623 | + -3, /* (207) expr ::= expr NOT NULL */ | |
| 173624 | + -3, /* (208) expr ::= expr IS expr */ | |
| 173625 | + -4, /* (209) expr ::= expr IS NOT expr */ | |
| 173626 | + -6, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ | |
| 173627 | + -5, /* (211) expr ::= expr IS DISTINCT FROM expr */ | |
| 173628 | + -2, /* (212) expr ::= NOT expr */ | |
| 173629 | + -2, /* (213) expr ::= BITNOT expr */ | |
| 173630 | + -2, /* (214) expr ::= PLUS|MINUS expr */ | |
| 173631 | + -3, /* (215) expr ::= expr PTR expr */ | |
| 173632 | + -1, /* (216) between_op ::= BETWEEN */ | |
| 173633 | + -2, /* (217) between_op ::= NOT BETWEEN */ | |
| 173634 | + -5, /* (218) expr ::= expr between_op expr AND expr */ | |
| 173635 | + -1, /* (219) in_op ::= IN */ | |
| 173636 | + -2, /* (220) in_op ::= NOT IN */ | |
| 173637 | + -5, /* (221) expr ::= expr in_op LP exprlist RP */ | |
| 173638 | + -3, /* (222) expr ::= LP select RP */ | |
| 173639 | + -5, /* (223) expr ::= expr in_op LP select RP */ | |
| 173640 | + -5, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ | |
| 173641 | + -4, /* (225) expr ::= EXISTS LP select RP */ | |
| 173642 | + -5, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ | |
| 173643 | + -5, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 173644 | + -4, /* (228) case_exprlist ::= WHEN expr THEN expr */ | |
| 173645 | + -2, /* (229) case_else ::= ELSE expr */ | |
| 173646 | + 0, /* (230) case_else ::= */ | |
| 173647 | + 0, /* (231) case_operand ::= */ | |
| 173648 | + 0, /* (232) exprlist ::= */ | |
| 173649 | + -3, /* (233) nexprlist ::= nexprlist COMMA expr */ | |
| 173650 | + -1, /* (234) nexprlist ::= expr */ | |
| 173651 | + 0, /* (235) paren_exprlist ::= */ | |
| 173652 | + -3, /* (236) paren_exprlist ::= LP exprlist RP */ | |
| 173653 | + -12, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | |
| 173654 | + -1, /* (238) uniqueflag ::= UNIQUE */ | |
| 173655 | + 0, /* (239) uniqueflag ::= */ | |
| 173656 | + 0, /* (240) eidlist_opt ::= */ | |
| 173657 | + -3, /* (241) eidlist_opt ::= LP eidlist RP */ | |
| 173658 | + -5, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ | |
| 173659 | + -3, /* (243) eidlist ::= nm collate sortorder */ | |
| 173660 | + 0, /* (244) collate ::= */ | |
| 173661 | + -2, /* (245) collate ::= COLLATE ID|STRING */ | |
| 173662 | + -4, /* (246) cmd ::= DROP INDEX ifexists fullname */ | |
| 173663 | + -2, /* (247) cmd ::= VACUUM vinto */ | |
| 173664 | + -3, /* (248) cmd ::= VACUUM nm vinto */ | |
| 173665 | + -2, /* (249) vinto ::= INTO expr */ | |
| 173666 | + 0, /* (250) vinto ::= */ | |
| 173667 | + -3, /* (251) cmd ::= PRAGMA nm dbnm */ | |
| 173668 | + -5, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 173669 | + -6, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 173670 | + -5, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 173671 | + -6, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 173672 | + -2, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ | |
| 173673 | + -2, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ | |
| 173674 | + -5, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | |
| 173675 | + -11, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | |
| 173676 | + -1, /* (260) trigger_time ::= BEFORE|AFTER */ | |
| 173677 | + -2, /* (261) trigger_time ::= INSTEAD OF */ | |
| 173678 | + 0, /* (262) trigger_time ::= */ | |
| 173679 | + -1, /* (263) trigger_event ::= DELETE|INSERT */ | |
| 173680 | + -1, /* (264) trigger_event ::= UPDATE */ | |
| 173681 | + -3, /* (265) trigger_event ::= UPDATE OF idlist */ | |
| 173682 | + 0, /* (266) when_clause ::= */ | |
| 173683 | + -2, /* (267) when_clause ::= WHEN expr */ | |
| 173684 | + -3, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | |
| 173685 | + -2, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 173686 | + -3, /* (270) trnm ::= nm DOT nm */ | |
| 173687 | + -3, /* (271) tridxby ::= INDEXED BY nm */ | |
| 173688 | + -2, /* (272) tridxby ::= NOT INDEXED */ | |
| 173689 | + -9, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | |
| 173690 | + -8, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | |
| 173691 | + -6, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | |
| 173692 | + -3, /* (276) trigger_cmd ::= scanpt select scanpt */ | |
| 173693 | + -4, /* (277) expr ::= RAISE LP IGNORE RP */ | |
| 173694 | + -6, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 173695 | + -1, /* (279) raisetype ::= ROLLBACK */ | |
| 173696 | + -1, /* (280) raisetype ::= ABORT */ | |
| 173697 | + -1, /* (281) raisetype ::= FAIL */ | |
| 173698 | + -4, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ | |
| 173699 | + -6, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | |
| 173700 | + -3, /* (284) cmd ::= DETACH database_kw_opt expr */ | |
| 173701 | + 0, /* (285) key_opt ::= */ | |
| 173702 | + -2, /* (286) key_opt ::= KEY expr */ | |
| 173703 | + -1, /* (287) cmd ::= REINDEX */ | |
| 173704 | + -3, /* (288) cmd ::= REINDEX nm dbnm */ | |
| 173705 | + -1, /* (289) cmd ::= ANALYZE */ | |
| 173706 | + -3, /* (290) cmd ::= ANALYZE nm dbnm */ | |
| 173707 | + -6, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 173708 | + -7, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | |
| 173709 | + -6, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | |
| 173710 | + -1, /* (294) add_column_fullname ::= fullname */ | |
| 173711 | + -8, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | |
| 173712 | + -1, /* (296) cmd ::= create_vtab */ | |
| 173713 | + -4, /* (297) cmd ::= create_vtab LP vtabarglist RP */ | |
| 173714 | + -8, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | |
| 173715 | + 0, /* (299) vtabarg ::= */ | |
| 173716 | + -1, /* (300) vtabargtoken ::= ANY */ | |
| 173717 | + -3, /* (301) vtabargtoken ::= lp anylist RP */ | |
| 173718 | + -1, /* (302) lp ::= LP */ | |
| 173719 | + -2, /* (303) with ::= WITH wqlist */ | |
| 173720 | + -3, /* (304) with ::= WITH RECURSIVE wqlist */ | |
| 173721 | + -1, /* (305) wqas ::= AS */ | |
| 173722 | + -2, /* (306) wqas ::= AS MATERIALIZED */ | |
| 173723 | + -3, /* (307) wqas ::= AS NOT MATERIALIZED */ | |
| 173724 | + -6, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ | |
| 173725 | + -1, /* (309) wqlist ::= wqitem */ | |
| 173726 | + -3, /* (310) wqlist ::= wqlist COMMA wqitem */ | |
| 173727 | + -3, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | |
| 173728 | + -5, /* (312) windowdefn ::= nm AS LP window RP */ | |
| 173729 | + -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 173730 | + -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 173731 | + -4, /* (315) window ::= ORDER BY sortlist frame_opt */ | |
| 173732 | + -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */ | |
| 173733 | + -2, /* (317) window ::= nm frame_opt */ | |
| 173734 | + 0, /* (318) frame_opt ::= */ | |
| 173735 | + -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | |
| 173736 | + -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | |
| 173737 | + -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ | |
| 173738 | + -1, /* (322) frame_bound_s ::= frame_bound */ | |
| 173739 | + -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ | |
| 173740 | + -1, /* (324) frame_bound_e ::= frame_bound */ | |
| 173741 | + -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ | |
| 173742 | + -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ | |
| 173743 | + -2, /* (327) frame_bound ::= CURRENT ROW */ | |
| 173744 | + 0, /* (328) frame_exclude_opt ::= */ | |
| 173745 | + -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ | |
| 173746 | + -2, /* (330) frame_exclude ::= NO OTHERS */ | |
| 173747 | + -2, /* (331) frame_exclude ::= CURRENT ROW */ | |
| 173748 | + -1, /* (332) frame_exclude ::= GROUP|TIES */ | |
| 173749 | + -2, /* (333) window_clause ::= WINDOW windowdefn_list */ | |
| 173750 | + -2, /* (334) filter_over ::= filter_clause over_clause */ | |
| 173751 | + -1, /* (335) filter_over ::= over_clause */ | |
| 173752 | + -1, /* (336) filter_over ::= filter_clause */ | |
| 173753 | + -4, /* (337) over_clause ::= OVER LP window RP */ | |
| 173754 | + -2, /* (338) over_clause ::= OVER nm */ | |
| 173755 | + -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ | |
| 173756 | + -1, /* (340) input ::= cmdlist */ | |
| 173757 | + -2, /* (341) cmdlist ::= cmdlist ecmd */ | |
| 173758 | + -1, /* (342) cmdlist ::= ecmd */ | |
| 173759 | + -1, /* (343) ecmd ::= SEMI */ | |
| 173760 | + -2, /* (344) ecmd ::= cmdx SEMI */ | |
| 173761 | + -3, /* (345) ecmd ::= explain cmdx SEMI */ | |
| 173762 | + 0, /* (346) trans_opt ::= */ | |
| 173763 | + -1, /* (347) trans_opt ::= TRANSACTION */ | |
| 173764 | + -2, /* (348) trans_opt ::= TRANSACTION nm */ | |
| 173765 | + -1, /* (349) savepoint_opt ::= SAVEPOINT */ | |
| 173766 | + 0, /* (350) savepoint_opt ::= */ | |
| 173767 | + -2, /* (351) cmd ::= create_table create_table_args */ | |
| 173768 | + -1, /* (352) table_option_set ::= table_option */ | |
| 173769 | + -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */ | |
| 173770 | + -2, /* (354) columnlist ::= columnname carglist */ | |
| 173771 | + -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */ | |
| 173772 | + -1, /* (356) nm ::= STRING */ | |
| 173773 | + -1, /* (357) typetoken ::= typename */ | |
| 173774 | + -1, /* (358) typename ::= ID|STRING */ | |
| 173775 | + -1, /* (359) signed ::= plus_num */ | |
| 173776 | + -1, /* (360) signed ::= minus_num */ | |
| 173777 | + -2, /* (361) carglist ::= carglist ccons */ | |
| 173778 | + 0, /* (362) carglist ::= */ | |
| 173779 | + -2, /* (363) ccons ::= NULL onconf */ | |
| 173780 | + -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ | |
| 173781 | + -2, /* (365) ccons ::= AS generated */ | |
| 173782 | + -2, /* (366) conslist_opt ::= COMMA conslist */ | |
| 173783 | + -3, /* (367) conslist ::= conslist tconscomma tcons */ | |
| 173784 | + -1, /* (368) conslist ::= tcons */ | |
| 173785 | + 0, /* (369) tconscomma ::= */ | |
| 173786 | + -1, /* (370) defer_subclause_opt ::= defer_subclause */ | |
| 173787 | + -1, /* (371) resolvetype ::= raisetype */ | |
| 173788 | + -1, /* (372) selectnowith ::= oneselect */ | |
| 173789 | + -1, /* (373) oneselect ::= values */ | |
| 173790 | + -2, /* (374) sclp ::= selcollist COMMA */ | |
| 173791 | + -1, /* (375) as ::= ID|STRING */ | |
| 173792 | + -1, /* (376) indexed_opt ::= indexed_by */ | |
| 173793 | + 0, /* (377) returning ::= */ | |
| 173794 | + -1, /* (378) expr ::= term */ | |
| 173795 | + -1, /* (379) likeop ::= LIKE_KW|MATCH */ | |
| 173796 | + -1, /* (380) case_operand ::= expr */ | |
| 173797 | + -1, /* (381) exprlist ::= nexprlist */ | |
| 173798 | + -1, /* (382) nmnum ::= plus_num */ | |
| 173799 | + -1, /* (383) nmnum ::= nm */ | |
| 173800 | + -1, /* (384) nmnum ::= ON */ | |
| 173801 | + -1, /* (385) nmnum ::= DELETE */ | |
| 173802 | + -1, /* (386) nmnum ::= DEFAULT */ | |
| 173803 | + -1, /* (387) plus_num ::= INTEGER|FLOAT */ | |
| 173804 | + 0, /* (388) foreach_clause ::= */ | |
| 173805 | + -3, /* (389) foreach_clause ::= FOR EACH ROW */ | |
| 173806 | + -1, /* (390) trnm ::= nm */ | |
| 173807 | + 0, /* (391) tridxby ::= */ | |
| 173808 | + -1, /* (392) database_kw_opt ::= DATABASE */ | |
| 173809 | + 0, /* (393) database_kw_opt ::= */ | |
| 173810 | + 0, /* (394) kwcolumn_opt ::= */ | |
| 173811 | + -1, /* (395) kwcolumn_opt ::= COLUMNKW */ | |
| 173812 | + -1, /* (396) vtabarglist ::= vtabarg */ | |
| 173813 | + -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ | |
| 173814 | + -2, /* (398) vtabarg ::= vtabarg vtabargtoken */ | |
| 173815 | + 0, /* (399) anylist ::= */ | |
| 173816 | + -4, /* (400) anylist ::= anylist LP anylist RP */ | |
| 173817 | + -2, /* (401) anylist ::= anylist ANY */ | |
| 173818 | + 0, /* (402) with ::= */ | |
| 173819 | + -1, /* (403) windowdefn_list ::= windowdefn */ | |
| 173820 | + -1, /* (404) window ::= frame_opt */ | |
| 172764 | 173821 | }; |
| 172765 | 173822 | |
| 172766 | 173823 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 172767 | 173824 | |
| 172768 | 173825 | /* |
| @@ -172818,11 +173875,11 @@ | ||
| 172818 | 173875 | {yymsp[1].minor.yy394 = TK_DEFERRED;} |
| 172819 | 173876 | break; |
| 172820 | 173877 | case 5: /* transtype ::= DEFERRED */ |
| 172821 | 173878 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 172822 | 173879 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 172823 | - case 319: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==319); | |
| 173880 | + case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321); | |
| 172824 | 173881 | {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} |
| 172825 | 173882 | break; |
| 172826 | 173883 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 172827 | 173884 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| 172828 | 173885 | {sqlite3EndTransaction(pParse,yymsp[-1].major);} |
| @@ -172855,11 +173912,11 @@ | ||
| 172855 | 173912 | case 47: /* autoinc ::= */ yytestcase(yyruleno==47); |
| 172856 | 173913 | case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62); |
| 172857 | 173914 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 172858 | 173915 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 172859 | 173916 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); |
| 172860 | - case 242: /* collate ::= */ yytestcase(yyruleno==242); | |
| 173917 | + case 244: /* collate ::= */ yytestcase(yyruleno==244); | |
| 172861 | 173918 | {yymsp[1].minor.yy394 = 0;} |
| 172862 | 173919 | break; |
| 172863 | 173920 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 172864 | 173921 | {yymsp[-2].minor.yy394 = 1;} |
| 172865 | 173922 | break; |
| @@ -173039,13 +174096,13 @@ | ||
| 173039 | 174096 | case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171); |
| 173040 | 174097 | {yymsp[-1].minor.yy394 = yymsp[0].minor.yy394;} |
| 173041 | 174098 | break; |
| 173042 | 174099 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 173043 | 174100 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 173044 | - case 215: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==215); | |
| 173045 | - case 218: /* in_op ::= NOT IN */ yytestcase(yyruleno==218); | |
| 173046 | - case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243); | |
| 174101 | + case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217); | |
| 174102 | + case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220); | |
| 174103 | + case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245); | |
| 173047 | 174104 | {yymsp[-1].minor.yy394 = 1;} |
| 173048 | 174105 | break; |
| 173049 | 174106 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 173050 | 174107 | {yymsp[-1].minor.yy394 = 0;} |
| 173051 | 174108 | break; |
| @@ -173190,13 +174247,13 @@ | ||
| 173190 | 174247 | {yymsp[0].minor.yy394 = SF_All;} |
| 173191 | 174248 | break; |
| 173192 | 174249 | case 99: /* sclp ::= */ |
| 173193 | 174250 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); |
| 173194 | 174251 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); |
| 173195 | - case 230: /* exprlist ::= */ yytestcase(yyruleno==230); | |
| 173196 | - case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233); | |
| 173197 | - case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238); | |
| 174252 | + case 232: /* exprlist ::= */ yytestcase(yyruleno==232); | |
| 174253 | + case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235); | |
| 174254 | + case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240); | |
| 173198 | 174255 | {yymsp[1].minor.yy322 = 0;} |
| 173199 | 174256 | break; |
| 173200 | 174257 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 173201 | 174258 | { |
| 173202 | 174259 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| @@ -173221,12 +174278,12 @@ | ||
| 173221 | 174278 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot); |
| 173222 | 174279 | } |
| 173223 | 174280 | break; |
| 173224 | 174281 | case 103: /* as ::= AS nm */ |
| 173225 | 174282 | case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); |
| 173226 | - case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); | |
| 173227 | - case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); | |
| 174283 | + case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256); | |
| 174284 | + case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257); | |
| 173228 | 174285 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 173229 | 174286 | break; |
| 173230 | 174287 | case 105: /* from ::= */ |
| 173231 | 174288 | case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108); |
| 173232 | 174289 | {yymsp[1].minor.yy131 = 0;} |
| @@ -173394,20 +174451,20 @@ | ||
| 173394 | 174451 | break; |
| 173395 | 174452 | case 144: /* having_opt ::= */ |
| 173396 | 174453 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 173397 | 174454 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 173398 | 174455 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 173399 | - case 228: /* case_else ::= */ yytestcase(yyruleno==228); | |
| 173400 | - case 229: /* case_operand ::= */ yytestcase(yyruleno==229); | |
| 173401 | - case 248: /* vinto ::= */ yytestcase(yyruleno==248); | |
| 174456 | + case 230: /* case_else ::= */ yytestcase(yyruleno==230); | |
| 174457 | + case 231: /* case_operand ::= */ yytestcase(yyruleno==231); | |
| 174458 | + case 250: /* vinto ::= */ yytestcase(yyruleno==250); | |
| 173402 | 174459 | {yymsp[1].minor.yy528 = 0;} |
| 173403 | 174460 | break; |
| 173404 | 174461 | case 145: /* having_opt ::= HAVING expr */ |
| 173405 | 174462 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 173406 | 174463 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 173407 | - case 227: /* case_else ::= ELSE expr */ yytestcase(yyruleno==227); | |
| 173408 | - case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); | |
| 174464 | + case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229); | |
| 174465 | + case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249); | |
| 173409 | 174466 | {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 173410 | 174467 | break; |
| 173411 | 174468 | case 147: /* limit_opt ::= LIMIT expr */ |
| 173412 | 174469 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);} |
| 173413 | 174470 | break; |
| @@ -173589,37 +174646,52 @@ | ||
| 173589 | 174646 | { |
| 173590 | 174647 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy394); |
| 173591 | 174648 | } |
| 173592 | 174649 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 173593 | 174650 | break; |
| 173594 | - case 188: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | |
| 174651 | + case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ | |
| 174652 | +{ | |
| 174653 | + yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394); | |
| 174654 | + sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322); | |
| 174655 | +} | |
| 174656 | + yymsp[-7].minor.yy528 = yylhsminor.yy528; | |
| 174657 | + break; | |
| 174658 | + case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ | |
| 173595 | 174659 | { |
| 173596 | 174660 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 173597 | 174661 | } |
| 173598 | 174662 | yymsp[-3].minor.yy528 = yylhsminor.yy528; |
| 173599 | 174663 | break; |
| 173600 | - case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | |
| 174664 | + case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ | |
| 173601 | 174665 | { |
| 173602 | 174666 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394); |
| 173603 | 174667 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 173604 | 174668 | } |
| 173605 | 174669 | yymsp[-5].minor.yy528 = yylhsminor.yy528; |
| 173606 | 174670 | break; |
| 173607 | - case 190: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | |
| 174671 | + case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ | |
| 174672 | +{ | |
| 174673 | + yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394); | |
| 174674 | + sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); | |
| 174675 | + sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322); | |
| 174676 | +} | |
| 174677 | + yymsp[-8].minor.yy528 = yylhsminor.yy528; | |
| 174678 | + break; | |
| 174679 | + case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ | |
| 173608 | 174680 | { |
| 173609 | 174681 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 173610 | 174682 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 173611 | 174683 | } |
| 173612 | 174684 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 173613 | 174685 | break; |
| 173614 | - case 191: /* term ::= CTIME_KW */ | |
| 174686 | + case 193: /* term ::= CTIME_KW */ | |
| 173615 | 174687 | { |
| 173616 | 174688 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 173617 | 174689 | } |
| 173618 | 174690 | yymsp[0].minor.yy528 = yylhsminor.yy528; |
| 173619 | 174691 | break; |
| 173620 | - case 192: /* expr ::= LP nexprlist COMMA expr RP */ | |
| 174692 | + case 194: /* expr ::= LP nexprlist COMMA expr RP */ | |
| 173621 | 174693 | { |
| 173622 | 174694 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); |
| 173623 | 174695 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 173624 | 174696 | if( yymsp[-4].minor.yy528 ){ |
| 173625 | 174697 | yymsp[-4].minor.yy528->x.pList = pList; |
| @@ -173629,26 +174701,26 @@ | ||
| 173629 | 174701 | }else{ |
| 173630 | 174702 | sqlite3ExprListDelete(pParse->db, pList); |
| 173631 | 174703 | } |
| 173632 | 174704 | } |
| 173633 | 174705 | break; |
| 173634 | - case 193: /* expr ::= expr AND expr */ | |
| 174706 | + case 195: /* expr ::= expr AND expr */ | |
| 173635 | 174707 | {yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 173636 | 174708 | break; |
| 173637 | - case 194: /* expr ::= expr OR expr */ | |
| 173638 | - case 195: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==195); | |
| 173639 | - case 196: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==196); | |
| 173640 | - case 197: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==197); | |
| 173641 | - case 198: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==198); | |
| 173642 | - case 199: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==199); | |
| 173643 | - case 200: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==200); | |
| 174709 | + case 196: /* expr ::= expr OR expr */ | |
| 174710 | + case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197); | |
| 174711 | + case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198); | |
| 174712 | + case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199); | |
| 174713 | + case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200); | |
| 174714 | + case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201); | |
| 174715 | + case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202); | |
| 173644 | 174716 | {yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 173645 | 174717 | break; |
| 173646 | - case 201: /* likeop ::= NOT LIKE_KW|MATCH */ | |
| 174718 | + case 203: /* likeop ::= NOT LIKE_KW|MATCH */ | |
| 173647 | 174719 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 173648 | 174720 | break; |
| 173649 | - case 202: /* expr ::= expr likeop expr */ | |
| 174721 | + case 204: /* expr ::= expr likeop expr */ | |
| 173650 | 174722 | { |
| 173651 | 174723 | ExprList *pList; |
| 173652 | 174724 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 173653 | 174725 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 173654 | 174726 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy528); |
| @@ -173656,11 +174728,11 @@ | ||
| 173656 | 174728 | yymsp[-2].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 173657 | 174729 | if( bNot ) yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy528, 0); |
| 173658 | 174730 | if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; |
| 173659 | 174731 | } |
| 173660 | 174732 | break; |
| 173661 | - case 203: /* expr ::= expr likeop expr ESCAPE expr */ | |
| 174733 | + case 205: /* expr ::= expr likeop expr ESCAPE expr */ | |
| 173662 | 174734 | { |
| 173663 | 174735 | ExprList *pList; |
| 173664 | 174736 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 173665 | 174737 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 173666 | 174738 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| @@ -173669,63 +174741,63 @@ | ||
| 173669 | 174741 | yymsp[-4].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 173670 | 174742 | if( bNot ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173671 | 174743 | if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; |
| 173672 | 174744 | } |
| 173673 | 174745 | break; |
| 173674 | - case 204: /* expr ::= expr ISNULL|NOTNULL */ | |
| 174746 | + case 206: /* expr ::= expr ISNULL|NOTNULL */ | |
| 173675 | 174747 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} |
| 173676 | 174748 | break; |
| 173677 | - case 205: /* expr ::= expr NOT NULL */ | |
| 174749 | + case 207: /* expr ::= expr NOT NULL */ | |
| 173678 | 174750 | {yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} |
| 173679 | 174751 | break; |
| 173680 | - case 206: /* expr ::= expr IS expr */ | |
| 174752 | + case 208: /* expr ::= expr IS expr */ | |
| 173681 | 174753 | { |
| 173682 | 174754 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528); |
| 173683 | 174755 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL); |
| 173684 | 174756 | } |
| 173685 | 174757 | break; |
| 173686 | - case 207: /* expr ::= expr IS NOT expr */ | |
| 174758 | + case 209: /* expr ::= expr IS NOT expr */ | |
| 173687 | 174759 | { |
| 173688 | 174760 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528); |
| 173689 | 174761 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL); |
| 173690 | 174762 | } |
| 173691 | 174763 | break; |
| 173692 | - case 208: /* expr ::= expr IS NOT DISTINCT FROM expr */ | |
| 174764 | + case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */ | |
| 173693 | 174765 | { |
| 173694 | 174766 | yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528); |
| 173695 | 174767 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL); |
| 173696 | 174768 | } |
| 173697 | 174769 | break; |
| 173698 | - case 209: /* expr ::= expr IS DISTINCT FROM expr */ | |
| 174770 | + case 211: /* expr ::= expr IS DISTINCT FROM expr */ | |
| 173699 | 174771 | { |
| 173700 | 174772 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528); |
| 173701 | 174773 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL); |
| 173702 | 174774 | } |
| 173703 | 174775 | break; |
| 173704 | - case 210: /* expr ::= NOT expr */ | |
| 173705 | - case 211: /* expr ::= BITNOT expr */ yytestcase(yyruleno==211); | |
| 174776 | + case 212: /* expr ::= NOT expr */ | |
| 174777 | + case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213); | |
| 173706 | 174778 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} |
| 173707 | 174779 | break; |
| 173708 | - case 212: /* expr ::= PLUS|MINUS expr */ | |
| 174780 | + case 214: /* expr ::= PLUS|MINUS expr */ | |
| 173709 | 174781 | { |
| 173710 | 174782 | yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); |
| 173711 | 174783 | /*A-overwrites-B*/ |
| 173712 | 174784 | } |
| 173713 | 174785 | break; |
| 173714 | - case 213: /* expr ::= expr PTR expr */ | |
| 174786 | + case 215: /* expr ::= expr PTR expr */ | |
| 173715 | 174787 | { |
| 173716 | 174788 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); |
| 173717 | 174789 | pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); |
| 173718 | 174790 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 173719 | 174791 | } |
| 173720 | 174792 | yymsp[-2].minor.yy528 = yylhsminor.yy528; |
| 173721 | 174793 | break; |
| 173722 | - case 214: /* between_op ::= BETWEEN */ | |
| 173723 | - case 217: /* in_op ::= IN */ yytestcase(yyruleno==217); | |
| 174794 | + case 216: /* between_op ::= BETWEEN */ | |
| 174795 | + case 219: /* in_op ::= IN */ yytestcase(yyruleno==219); | |
| 173724 | 174796 | {yymsp[0].minor.yy394 = 0;} |
| 173725 | 174797 | break; |
| 173726 | - case 216: /* expr ::= expr between_op expr AND expr */ | |
| 174798 | + case 218: /* expr ::= expr between_op expr AND expr */ | |
| 173727 | 174799 | { |
| 173728 | 174800 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 173729 | 174801 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); |
| 173730 | 174802 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy528, 0); |
| 173731 | 174803 | if( yymsp[-4].minor.yy528 ){ |
| @@ -173734,11 +174806,11 @@ | ||
| 173734 | 174806 | sqlite3ExprListDelete(pParse->db, pList); |
| 173735 | 174807 | } |
| 173736 | 174808 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173737 | 174809 | } |
| 173738 | 174810 | break; |
| 173739 | - case 219: /* expr ::= expr in_op LP exprlist RP */ | |
| 174811 | + case 221: /* expr ::= expr in_op LP exprlist RP */ | |
| 173740 | 174812 | { |
| 173741 | 174813 | if( yymsp[-1].minor.yy322==0 ){ |
| 173742 | 174814 | /* Expressions of the form |
| 173743 | 174815 | ** |
| 173744 | 174816 | ** expr1 IN () |
| @@ -173780,41 +174852,41 @@ | ||
| 173780 | 174852 | } |
| 173781 | 174853 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173782 | 174854 | } |
| 173783 | 174855 | } |
| 173784 | 174856 | break; |
| 173785 | - case 220: /* expr ::= LP select RP */ | |
| 174857 | + case 222: /* expr ::= LP select RP */ | |
| 173786 | 174858 | { |
| 173787 | 174859 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 173788 | 174860 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); |
| 173789 | 174861 | } |
| 173790 | 174862 | break; |
| 173791 | - case 221: /* expr ::= expr in_op LP select RP */ | |
| 174863 | + case 223: /* expr ::= expr in_op LP select RP */ | |
| 173792 | 174864 | { |
| 173793 | 174865 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 173794 | 174866 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47); |
| 173795 | 174867 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173796 | 174868 | } |
| 173797 | 174869 | break; |
| 173798 | - case 222: /* expr ::= expr in_op nm dbnm paren_exprlist */ | |
| 174870 | + case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */ | |
| 173799 | 174871 | { |
| 173800 | 174872 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 173801 | 174873 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 173802 | 174874 | if( yymsp[0].minor.yy322 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322); |
| 173803 | 174875 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 173804 | 174876 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelect); |
| 173805 | 174877 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173806 | 174878 | } |
| 173807 | 174879 | break; |
| 173808 | - case 223: /* expr ::= EXISTS LP select RP */ | |
| 174880 | + case 225: /* expr ::= EXISTS LP select RP */ | |
| 173809 | 174881 | { |
| 173810 | 174882 | Expr *p; |
| 173811 | 174883 | p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 173812 | 174884 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); |
| 173813 | 174885 | } |
| 173814 | 174886 | break; |
| 173815 | - case 224: /* expr ::= CASE case_operand case_exprlist case_else END */ | |
| 174887 | + case 226: /* expr ::= CASE case_operand case_exprlist case_else END */ | |
| 173816 | 174888 | { |
| 173817 | 174889 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); |
| 173818 | 174890 | if( yymsp[-4].minor.yy528 ){ |
| 173819 | 174891 | yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy528 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528) : yymsp[-2].minor.yy322; |
| 173820 | 174892 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528); |
| @@ -173822,392 +174894,392 @@ | ||
| 173822 | 174894 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 173823 | 174895 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| 173824 | 174896 | } |
| 173825 | 174897 | } |
| 173826 | 174898 | break; |
| 173827 | - case 225: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 174899 | + case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 173828 | 174900 | { |
| 173829 | 174901 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| 173830 | 174902 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528); |
| 173831 | 174903 | } |
| 173832 | 174904 | break; |
| 173833 | - case 226: /* case_exprlist ::= WHEN expr THEN expr */ | |
| 174905 | + case 228: /* case_exprlist ::= WHEN expr THEN expr */ | |
| 173834 | 174906 | { |
| 173835 | 174907 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 173836 | 174908 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); |
| 173837 | 174909 | } |
| 173838 | 174910 | break; |
| 173839 | - case 231: /* nexprlist ::= nexprlist COMMA expr */ | |
| 174911 | + case 233: /* nexprlist ::= nexprlist COMMA expr */ | |
| 173840 | 174912 | {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} |
| 173841 | 174913 | break; |
| 173842 | - case 232: /* nexprlist ::= expr */ | |
| 174914 | + case 234: /* nexprlist ::= expr */ | |
| 173843 | 174915 | {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} |
| 173844 | 174916 | break; |
| 173845 | - case 234: /* paren_exprlist ::= LP exprlist RP */ | |
| 173846 | - case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239); | |
| 174917 | + case 236: /* paren_exprlist ::= LP exprlist RP */ | |
| 174918 | + case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241); | |
| 173847 | 174919 | {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} |
| 173848 | 174920 | break; |
| 173849 | - case 235: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | |
| 174921 | + case 237: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | |
| 173850 | 174922 | { |
| 173851 | 174923 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 173852 | 174924 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, |
| 173853 | 174925 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF); |
| 173854 | 174926 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 173855 | 174927 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 173856 | 174928 | } |
| 173857 | 174929 | } |
| 173858 | 174930 | break; |
| 173859 | - case 236: /* uniqueflag ::= UNIQUE */ | |
| 173860 | - case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278); | |
| 174931 | + case 238: /* uniqueflag ::= UNIQUE */ | |
| 174932 | + case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280); | |
| 173861 | 174933 | {yymsp[0].minor.yy394 = OE_Abort;} |
| 173862 | 174934 | break; |
| 173863 | - case 237: /* uniqueflag ::= */ | |
| 174935 | + case 239: /* uniqueflag ::= */ | |
| 173864 | 174936 | {yymsp[1].minor.yy394 = OE_None;} |
| 173865 | 174937 | break; |
| 173866 | - case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */ | |
| 174938 | + case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */ | |
| 173867 | 174939 | { |
| 173868 | 174940 | yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); |
| 173869 | 174941 | } |
| 173870 | 174942 | break; |
| 173871 | - case 241: /* eidlist ::= nm collate sortorder */ | |
| 174943 | + case 243: /* eidlist ::= nm collate sortorder */ | |
| 173872 | 174944 | { |
| 173873 | 174945 | yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ |
| 173874 | 174946 | } |
| 173875 | 174947 | break; |
| 173876 | - case 244: /* cmd ::= DROP INDEX ifexists fullname */ | |
| 174948 | + case 246: /* cmd ::= DROP INDEX ifexists fullname */ | |
| 173877 | 174949 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} |
| 173878 | 174950 | break; |
| 173879 | - case 245: /* cmd ::= VACUUM vinto */ | |
| 174951 | + case 247: /* cmd ::= VACUUM vinto */ | |
| 173880 | 174952 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} |
| 173881 | 174953 | break; |
| 173882 | - case 246: /* cmd ::= VACUUM nm vinto */ | |
| 174954 | + case 248: /* cmd ::= VACUUM nm vinto */ | |
| 173883 | 174955 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} |
| 173884 | 174956 | break; |
| 173885 | - case 249: /* cmd ::= PRAGMA nm dbnm */ | |
| 174957 | + case 251: /* cmd ::= PRAGMA nm dbnm */ | |
| 173886 | 174958 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 173887 | 174959 | break; |
| 173888 | - case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 174960 | + case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 173889 | 174961 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 173890 | 174962 | break; |
| 173891 | - case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 174963 | + case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 173892 | 174964 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 173893 | 174965 | break; |
| 173894 | - case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 174966 | + case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 173895 | 174967 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 173896 | 174968 | break; |
| 173897 | - case 253: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 174969 | + case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 173898 | 174970 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 173899 | 174971 | break; |
| 173900 | - case 256: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | |
| 174972 | + case 258: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | |
| 173901 | 174973 | { |
| 173902 | 174974 | Token all; |
| 173903 | 174975 | all.z = yymsp[-3].minor.yy0.z; |
| 173904 | 174976 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 173905 | 174977 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); |
| 173906 | 174978 | } |
| 173907 | 174979 | break; |
| 173908 | - case 257: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | |
| 174980 | + case 259: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | |
| 173909 | 174981 | { |
| 173910 | 174982 | 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 | 174983 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 173912 | 174984 | } |
| 173913 | 174985 | break; |
| 173914 | - case 258: /* trigger_time ::= BEFORE|AFTER */ | |
| 174986 | + case 260: /* trigger_time ::= BEFORE|AFTER */ | |
| 173915 | 174987 | { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } |
| 173916 | 174988 | break; |
| 173917 | - case 259: /* trigger_time ::= INSTEAD OF */ | |
| 174989 | + case 261: /* trigger_time ::= INSTEAD OF */ | |
| 173918 | 174990 | { yymsp[-1].minor.yy394 = TK_INSTEAD;} |
| 173919 | 174991 | break; |
| 173920 | - case 260: /* trigger_time ::= */ | |
| 174992 | + case 262: /* trigger_time ::= */ | |
| 173921 | 174993 | { yymsp[1].minor.yy394 = TK_BEFORE; } |
| 173922 | 174994 | break; |
| 173923 | - case 261: /* trigger_event ::= DELETE|INSERT */ | |
| 173924 | - case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262); | |
| 174995 | + case 263: /* trigger_event ::= DELETE|INSERT */ | |
| 174996 | + case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264); | |
| 173925 | 174997 | {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} |
| 173926 | 174998 | break; |
| 173927 | - case 263: /* trigger_event ::= UPDATE OF idlist */ | |
| 174999 | + case 265: /* trigger_event ::= UPDATE OF idlist */ | |
| 173928 | 175000 | {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} |
| 173929 | 175001 | break; |
| 173930 | - case 264: /* when_clause ::= */ | |
| 173931 | - case 283: /* key_opt ::= */ yytestcase(yyruleno==283); | |
| 175002 | + case 266: /* when_clause ::= */ | |
| 175003 | + case 285: /* key_opt ::= */ yytestcase(yyruleno==285); | |
| 173932 | 175004 | { yymsp[1].minor.yy528 = 0; } |
| 173933 | 175005 | break; |
| 173934 | - case 265: /* when_clause ::= WHEN expr */ | |
| 173935 | - case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284); | |
| 175006 | + case 267: /* when_clause ::= WHEN expr */ | |
| 175007 | + case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286); | |
| 173936 | 175008 | { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } |
| 173937 | 175009 | break; |
| 173938 | - case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | |
| 175010 | + case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | |
| 173939 | 175011 | { |
| 173940 | 175012 | assert( yymsp[-2].minor.yy33!=0 ); |
| 173941 | 175013 | yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; |
| 173942 | 175014 | yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 173943 | 175015 | } |
| 173944 | 175016 | break; |
| 173945 | - case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 175017 | + case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 173946 | 175018 | { |
| 173947 | 175019 | assert( yymsp[-1].minor.yy33!=0 ); |
| 173948 | 175020 | yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 173949 | 175021 | } |
| 173950 | 175022 | break; |
| 173951 | - case 268: /* trnm ::= nm DOT nm */ | |
| 175023 | + case 270: /* trnm ::= nm DOT nm */ | |
| 173952 | 175024 | { |
| 173953 | 175025 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 173954 | 175026 | sqlite3ErrorMsg(pParse, |
| 173955 | 175027 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 173956 | 175028 | "statements within triggers"); |
| 173957 | 175029 | } |
| 173958 | 175030 | break; |
| 173959 | - case 269: /* tridxby ::= INDEXED BY nm */ | |
| 175031 | + case 271: /* tridxby ::= INDEXED BY nm */ | |
| 173960 | 175032 | { |
| 173961 | 175033 | sqlite3ErrorMsg(pParse, |
| 173962 | 175034 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 173963 | 175035 | "within triggers"); |
| 173964 | 175036 | } |
| 173965 | 175037 | break; |
| 173966 | - case 270: /* tridxby ::= NOT INDEXED */ | |
| 175038 | + case 272: /* tridxby ::= NOT INDEXED */ | |
| 173967 | 175039 | { |
| 173968 | 175040 | sqlite3ErrorMsg(pParse, |
| 173969 | 175041 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 173970 | 175042 | "within triggers"); |
| 173971 | 175043 | } |
| 173972 | 175044 | break; |
| 173973 | - case 271: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | |
| 175045 | + case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | |
| 173974 | 175046 | {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 | 175047 | yymsp[-8].minor.yy33 = yylhsminor.yy33; |
| 173976 | 175048 | break; |
| 173977 | - case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | |
| 175049 | + case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | |
| 173978 | 175050 | { |
| 173979 | 175051 | 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 | 175052 | } |
| 173981 | 175053 | yymsp[-7].minor.yy33 = yylhsminor.yy33; |
| 173982 | 175054 | break; |
| 173983 | - case 273: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | |
| 175055 | + case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | |
| 173984 | 175056 | {yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} |
| 173985 | 175057 | yymsp[-5].minor.yy33 = yylhsminor.yy33; |
| 173986 | 175058 | break; |
| 173987 | - case 274: /* trigger_cmd ::= scanpt select scanpt */ | |
| 175059 | + case 276: /* trigger_cmd ::= scanpt select scanpt */ | |
| 173988 | 175060 | {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 | 175061 | yymsp[-2].minor.yy33 = yylhsminor.yy33; |
| 173990 | 175062 | break; |
| 173991 | - case 275: /* expr ::= RAISE LP IGNORE RP */ | |
| 175063 | + case 277: /* expr ::= RAISE LP IGNORE RP */ | |
| 173992 | 175064 | { |
| 173993 | 175065 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 173994 | 175066 | if( yymsp[-3].minor.yy528 ){ |
| 173995 | 175067 | yymsp[-3].minor.yy528->affExpr = OE_Ignore; |
| 173996 | 175068 | } |
| 173997 | 175069 | } |
| 173998 | 175070 | break; |
| 173999 | - case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 175071 | + case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 174000 | 175072 | { |
| 174001 | 175073 | yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 174002 | 175074 | if( yymsp[-5].minor.yy528 ) { |
| 174003 | 175075 | yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394; |
| 174004 | 175076 | } |
| 174005 | 175077 | } |
| 174006 | 175078 | break; |
| 174007 | - case 277: /* raisetype ::= ROLLBACK */ | |
| 175079 | + case 279: /* raisetype ::= ROLLBACK */ | |
| 174008 | 175080 | {yymsp[0].minor.yy394 = OE_Rollback;} |
| 174009 | 175081 | break; |
| 174010 | - case 279: /* raisetype ::= FAIL */ | |
| 175082 | + case 281: /* raisetype ::= FAIL */ | |
| 174011 | 175083 | {yymsp[0].minor.yy394 = OE_Fail;} |
| 174012 | 175084 | break; |
| 174013 | - case 280: /* cmd ::= DROP TRIGGER ifexists fullname */ | |
| 175085 | + case 282: /* cmd ::= DROP TRIGGER ifexists fullname */ | |
| 174014 | 175086 | { |
| 174015 | 175087 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); |
| 174016 | 175088 | } |
| 174017 | 175089 | break; |
| 174018 | - case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | |
| 175090 | + case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | |
| 174019 | 175091 | { |
| 174020 | 175092 | sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); |
| 174021 | 175093 | } |
| 174022 | 175094 | break; |
| 174023 | - case 282: /* cmd ::= DETACH database_kw_opt expr */ | |
| 175095 | + case 284: /* cmd ::= DETACH database_kw_opt expr */ | |
| 174024 | 175096 | { |
| 174025 | 175097 | sqlite3Detach(pParse, yymsp[0].minor.yy528); |
| 174026 | 175098 | } |
| 174027 | 175099 | break; |
| 174028 | - case 285: /* cmd ::= REINDEX */ | |
| 175100 | + case 287: /* cmd ::= REINDEX */ | |
| 174029 | 175101 | {sqlite3Reindex(pParse, 0, 0);} |
| 174030 | 175102 | break; |
| 174031 | - case 286: /* cmd ::= REINDEX nm dbnm */ | |
| 175103 | + case 288: /* cmd ::= REINDEX nm dbnm */ | |
| 174032 | 175104 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 174033 | 175105 | break; |
| 174034 | - case 287: /* cmd ::= ANALYZE */ | |
| 175106 | + case 289: /* cmd ::= ANALYZE */ | |
| 174035 | 175107 | {sqlite3Analyze(pParse, 0, 0);} |
| 174036 | 175108 | break; |
| 174037 | - case 288: /* cmd ::= ANALYZE nm dbnm */ | |
| 175109 | + case 290: /* cmd ::= ANALYZE nm dbnm */ | |
| 174038 | 175110 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 174039 | 175111 | break; |
| 174040 | - case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 175112 | + case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 174041 | 175113 | { |
| 174042 | 175114 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); |
| 174043 | 175115 | } |
| 174044 | 175116 | break; |
| 174045 | - case 290: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | |
| 175117 | + case 292: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | |
| 174046 | 175118 | { |
| 174047 | 175119 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 174048 | 175120 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 174049 | 175121 | } |
| 174050 | 175122 | break; |
| 174051 | - case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | |
| 175123 | + case 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | |
| 174052 | 175124 | { |
| 174053 | 175125 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); |
| 174054 | 175126 | } |
| 174055 | 175127 | break; |
| 174056 | - case 292: /* add_column_fullname ::= fullname */ | |
| 175128 | + case 294: /* add_column_fullname ::= fullname */ | |
| 174057 | 175129 | { |
| 174058 | 175130 | disableLookaside(pParse); |
| 174059 | 175131 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); |
| 174060 | 175132 | } |
| 174061 | 175133 | break; |
| 174062 | - case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | |
| 175134 | + case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | |
| 174063 | 175135 | { |
| 174064 | 175136 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 174065 | 175137 | } |
| 174066 | 175138 | break; |
| 174067 | - case 294: /* cmd ::= create_vtab */ | |
| 175139 | + case 296: /* cmd ::= create_vtab */ | |
| 174068 | 175140 | {sqlite3VtabFinishParse(pParse,0);} |
| 174069 | 175141 | break; |
| 174070 | - case 295: /* cmd ::= create_vtab LP vtabarglist RP */ | |
| 175142 | + case 297: /* cmd ::= create_vtab LP vtabarglist RP */ | |
| 174071 | 175143 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 174072 | 175144 | break; |
| 174073 | - case 296: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | |
| 175145 | + case 298: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | |
| 174074 | 175146 | { |
| 174075 | 175147 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); |
| 174076 | 175148 | } |
| 174077 | 175149 | break; |
| 174078 | - case 297: /* vtabarg ::= */ | |
| 175150 | + case 299: /* vtabarg ::= */ | |
| 174079 | 175151 | {sqlite3VtabArgInit(pParse);} |
| 174080 | 175152 | break; |
| 174081 | - case 298: /* vtabargtoken ::= ANY */ | |
| 174082 | - case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299); | |
| 174083 | - case 300: /* lp ::= LP */ yytestcase(yyruleno==300); | |
| 175153 | + case 300: /* vtabargtoken ::= ANY */ | |
| 175154 | + case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301); | |
| 175155 | + case 302: /* lp ::= LP */ yytestcase(yyruleno==302); | |
| 174084 | 175156 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 174085 | 175157 | break; |
| 174086 | - case 301: /* with ::= WITH wqlist */ | |
| 174087 | - case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302); | |
| 175158 | + case 303: /* with ::= WITH wqlist */ | |
| 175159 | + case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304); | |
| 174088 | 175160 | { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } |
| 174089 | 175161 | break; |
| 174090 | - case 303: /* wqas ::= AS */ | |
| 175162 | + case 305: /* wqas ::= AS */ | |
| 174091 | 175163 | {yymsp[0].minor.yy516 = M10d_Any;} |
| 174092 | 175164 | break; |
| 174093 | - case 304: /* wqas ::= AS MATERIALIZED */ | |
| 175165 | + case 306: /* wqas ::= AS MATERIALIZED */ | |
| 174094 | 175166 | {yymsp[-1].minor.yy516 = M10d_Yes;} |
| 174095 | 175167 | break; |
| 174096 | - case 305: /* wqas ::= AS NOT MATERIALIZED */ | |
| 175168 | + case 307: /* wqas ::= AS NOT MATERIALIZED */ | |
| 174097 | 175169 | {yymsp[-2].minor.yy516 = M10d_No;} |
| 174098 | 175170 | break; |
| 174099 | - case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */ | |
| 175171 | + case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */ | |
| 174100 | 175172 | { |
| 174101 | 175173 | 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 | 175174 | } |
| 174103 | 175175 | break; |
| 174104 | - case 307: /* wqlist ::= wqitem */ | |
| 175176 | + case 309: /* wqlist ::= wqitem */ | |
| 174105 | 175177 | { |
| 174106 | 175178 | yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ |
| 174107 | 175179 | } |
| 174108 | 175180 | break; |
| 174109 | - case 308: /* wqlist ::= wqlist COMMA wqitem */ | |
| 175181 | + case 310: /* wqlist ::= wqlist COMMA wqitem */ | |
| 174110 | 175182 | { |
| 174111 | 175183 | yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); |
| 174112 | 175184 | } |
| 174113 | 175185 | break; |
| 174114 | - case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | |
| 175186 | + case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | |
| 174115 | 175187 | { |
| 174116 | 175188 | assert( yymsp[0].minor.yy41!=0 ); |
| 174117 | 175189 | sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); |
| 174118 | 175190 | yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41; |
| 174119 | 175191 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174120 | 175192 | } |
| 174121 | 175193 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 174122 | 175194 | break; |
| 174123 | - case 310: /* windowdefn ::= nm AS LP window RP */ | |
| 175195 | + case 312: /* windowdefn ::= nm AS LP window RP */ | |
| 174124 | 175196 | { |
| 174125 | 175197 | if( ALWAYS(yymsp[-1].minor.yy41) ){ |
| 174126 | 175198 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 174127 | 175199 | } |
| 174128 | 175200 | yylhsminor.yy41 = yymsp[-1].minor.yy41; |
| 174129 | 175201 | } |
| 174130 | 175202 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 174131 | 175203 | break; |
| 174132 | - case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 175204 | + case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 174133 | 175205 | { |
| 174134 | 175206 | yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); |
| 174135 | 175207 | } |
| 174136 | 175208 | break; |
| 174137 | - case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 175209 | + case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | |
| 174138 | 175210 | { |
| 174139 | 175211 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); |
| 174140 | 175212 | } |
| 174141 | 175213 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 174142 | 175214 | break; |
| 174143 | - case 313: /* window ::= ORDER BY sortlist frame_opt */ | |
| 175215 | + case 315: /* window ::= ORDER BY sortlist frame_opt */ | |
| 174144 | 175216 | { |
| 174145 | 175217 | yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); |
| 174146 | 175218 | } |
| 174147 | 175219 | break; |
| 174148 | - case 314: /* window ::= nm ORDER BY sortlist frame_opt */ | |
| 175220 | + case 316: /* window ::= nm ORDER BY sortlist frame_opt */ | |
| 174149 | 175221 | { |
| 174150 | 175222 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| 174151 | 175223 | } |
| 174152 | 175224 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 174153 | 175225 | break; |
| 174154 | - case 315: /* window ::= nm frame_opt */ | |
| 175226 | + case 317: /* window ::= nm frame_opt */ | |
| 174155 | 175227 | { |
| 174156 | 175228 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); |
| 174157 | 175229 | } |
| 174158 | 175230 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 174159 | 175231 | break; |
| 174160 | - case 316: /* frame_opt ::= */ | |
| 175232 | + case 318: /* frame_opt ::= */ | |
| 174161 | 175233 | { |
| 174162 | 175234 | yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 174163 | 175235 | } |
| 174164 | 175236 | break; |
| 174165 | - case 317: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | |
| 175237 | + case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | |
| 174166 | 175238 | { |
| 174167 | 175239 | 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 | 175240 | } |
| 174169 | 175241 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 174170 | 175242 | break; |
| 174171 | - case 318: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | |
| 175243 | + case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | |
| 174172 | 175244 | { |
| 174173 | 175245 | 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 | 175246 | } |
| 174175 | 175247 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 174176 | 175248 | break; |
| 174177 | - case 320: /* frame_bound_s ::= frame_bound */ | |
| 174178 | - case 322: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==322); | |
| 175249 | + case 322: /* frame_bound_s ::= frame_bound */ | |
| 175250 | + case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324); | |
| 174179 | 175251 | {yylhsminor.yy595 = yymsp[0].minor.yy595;} |
| 174180 | 175252 | yymsp[0].minor.yy595 = yylhsminor.yy595; |
| 174181 | 175253 | break; |
| 174182 | - case 321: /* frame_bound_s ::= UNBOUNDED PRECEDING */ | |
| 174183 | - case 323: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==323); | |
| 174184 | - case 325: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==325); | |
| 175254 | + case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */ | |
| 175255 | + case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325); | |
| 175256 | + case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327); | |
| 174185 | 175257 | {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} |
| 174186 | 175258 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 174187 | 175259 | break; |
| 174188 | - case 324: /* frame_bound ::= expr PRECEDING|FOLLOWING */ | |
| 175260 | + case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */ | |
| 174189 | 175261 | {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} |
| 174190 | 175262 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 174191 | 175263 | break; |
| 174192 | - case 326: /* frame_exclude_opt ::= */ | |
| 175264 | + case 328: /* frame_exclude_opt ::= */ | |
| 174193 | 175265 | {yymsp[1].minor.yy516 = 0;} |
| 174194 | 175266 | break; |
| 174195 | - case 327: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ | |
| 175267 | + case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ | |
| 174196 | 175268 | {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} |
| 174197 | 175269 | break; |
| 174198 | - case 328: /* frame_exclude ::= NO OTHERS */ | |
| 174199 | - case 329: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==329); | |
| 175270 | + case 330: /* frame_exclude ::= NO OTHERS */ | |
| 175271 | + case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331); | |
| 174200 | 175272 | {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} |
| 174201 | 175273 | break; |
| 174202 | - case 330: /* frame_exclude ::= GROUP|TIES */ | |
| 175274 | + case 332: /* frame_exclude ::= GROUP|TIES */ | |
| 174203 | 175275 | {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} |
| 174204 | 175276 | break; |
| 174205 | - case 331: /* window_clause ::= WINDOW windowdefn_list */ | |
| 175277 | + case 333: /* window_clause ::= WINDOW windowdefn_list */ | |
| 174206 | 175278 | { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } |
| 174207 | 175279 | break; |
| 174208 | - case 332: /* filter_over ::= filter_clause over_clause */ | |
| 175280 | + case 334: /* filter_over ::= filter_clause over_clause */ | |
| 174209 | 175281 | { |
| 174210 | 175282 | if( yymsp[0].minor.yy41 ){ |
| 174211 | 175283 | yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; |
| 174212 | 175284 | }else{ |
| 174213 | 175285 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| @@ -174214,17 +175286,17 @@ | ||
| 174214 | 175286 | } |
| 174215 | 175287 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174216 | 175288 | } |
| 174217 | 175289 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 174218 | 175290 | break; |
| 174219 | - case 333: /* filter_over ::= over_clause */ | |
| 175291 | + case 335: /* filter_over ::= over_clause */ | |
| 174220 | 175292 | { |
| 174221 | 175293 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174222 | 175294 | } |
| 174223 | 175295 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 174224 | 175296 | break; |
| 174225 | - case 334: /* filter_over ::= filter_clause */ | |
| 175297 | + case 336: /* filter_over ::= filter_clause */ | |
| 174226 | 175298 | { |
| 174227 | 175299 | yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 174228 | 175300 | if( yylhsminor.yy41 ){ |
| 174229 | 175301 | yylhsminor.yy41->eFrmType = TK_FILTER; |
| 174230 | 175302 | yylhsminor.yy41->pFilter = yymsp[0].minor.yy528; |
| @@ -174232,93 +175304,93 @@ | ||
| 174232 | 175304 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528); |
| 174233 | 175305 | } |
| 174234 | 175306 | } |
| 174235 | 175307 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 174236 | 175308 | break; |
| 174237 | - case 335: /* over_clause ::= OVER LP window RP */ | |
| 175309 | + case 337: /* over_clause ::= OVER LP window RP */ | |
| 174238 | 175310 | { |
| 174239 | 175311 | yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; |
| 174240 | 175312 | assert( yymsp[-3].minor.yy41!=0 ); |
| 174241 | 175313 | } |
| 174242 | 175314 | break; |
| 174243 | - case 336: /* over_clause ::= OVER nm */ | |
| 175315 | + case 338: /* over_clause ::= OVER nm */ | |
| 174244 | 175316 | { |
| 174245 | 175317 | yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 174246 | 175318 | if( yymsp[-1].minor.yy41 ){ |
| 174247 | 175319 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 174248 | 175320 | } |
| 174249 | 175321 | } |
| 174250 | 175322 | break; |
| 174251 | - case 337: /* filter_clause ::= FILTER LP WHERE expr RP */ | |
| 175323 | + case 339: /* filter_clause ::= FILTER LP WHERE expr RP */ | |
| 174252 | 175324 | { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } |
| 174253 | 175325 | break; |
| 174254 | 175326 | default: |
| 174255 | - /* (338) input ::= cmdlist */ yytestcase(yyruleno==338); | |
| 174256 | - /* (339) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==339); | |
| 174257 | - /* (340) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=340); | |
| 174258 | - /* (341) ecmd ::= SEMI */ yytestcase(yyruleno==341); | |
| 174259 | - /* (342) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==342); | |
| 174260 | - /* (343) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=343); | |
| 174261 | - /* (344) trans_opt ::= */ yytestcase(yyruleno==344); | |
| 174262 | - /* (345) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==345); | |
| 174263 | - /* (346) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==346); | |
| 174264 | - /* (347) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==347); | |
| 174265 | - /* (348) savepoint_opt ::= */ yytestcase(yyruleno==348); | |
| 174266 | - /* (349) cmd ::= create_table create_table_args */ yytestcase(yyruleno==349); | |
| 174267 | - /* (350) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=350); | |
| 174268 | - /* (351) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==351); | |
| 174269 | - /* (352) columnlist ::= columnname carglist */ yytestcase(yyruleno==352); | |
| 174270 | - /* (353) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==353); | |
| 174271 | - /* (354) nm ::= STRING */ yytestcase(yyruleno==354); | |
| 174272 | - /* (355) typetoken ::= typename */ yytestcase(yyruleno==355); | |
| 174273 | - /* (356) typename ::= ID|STRING */ yytestcase(yyruleno==356); | |
| 174274 | - /* (357) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); | |
| 174275 | - /* (358) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=358); | |
| 174276 | - /* (359) carglist ::= carglist ccons */ yytestcase(yyruleno==359); | |
| 174277 | - /* (360) carglist ::= */ yytestcase(yyruleno==360); | |
| 174278 | - /* (361) ccons ::= NULL onconf */ yytestcase(yyruleno==361); | |
| 174279 | - /* (362) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==362); | |
| 174280 | - /* (363) ccons ::= AS generated */ yytestcase(yyruleno==363); | |
| 174281 | - /* (364) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==364); | |
| 174282 | - /* (365) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==365); | |
| 174283 | - /* (366) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=366); | |
| 174284 | - /* (367) tconscomma ::= */ yytestcase(yyruleno==367); | |
| 174285 | - /* (368) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=368); | |
| 174286 | - /* (369) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=369); | |
| 174287 | - /* (370) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=370); | |
| 174288 | - /* (371) oneselect ::= values */ yytestcase(yyruleno==371); | |
| 174289 | - /* (372) sclp ::= selcollist COMMA */ yytestcase(yyruleno==372); | |
| 174290 | - /* (373) as ::= ID|STRING */ yytestcase(yyruleno==373); | |
| 174291 | - /* (374) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=374); | |
| 174292 | - /* (375) returning ::= */ yytestcase(yyruleno==375); | |
| 174293 | - /* (376) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=376); | |
| 174294 | - /* (377) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==377); | |
| 174295 | - /* (378) case_operand ::= expr */ yytestcase(yyruleno==378); | |
| 174296 | - /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); | |
| 174297 | - /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); | |
| 174298 | - /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); | |
| 174299 | - /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); | |
| 174300 | - /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); | |
| 174301 | - /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); | |
| 174302 | - /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); | |
| 174303 | - /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); | |
| 174304 | - /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); | |
| 174305 | - /* (388) trnm ::= nm */ yytestcase(yyruleno==388); | |
| 174306 | - /* (389) tridxby ::= */ yytestcase(yyruleno==389); | |
| 174307 | - /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); | |
| 174308 | - /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); | |
| 174309 | - /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); | |
| 174310 | - /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); | |
| 174311 | - /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); | |
| 174312 | - /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); | |
| 174313 | - /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); | |
| 174314 | - /* (397) anylist ::= */ yytestcase(yyruleno==397); | |
| 174315 | - /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); | |
| 174316 | - /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); | |
| 174317 | - /* (400) with ::= */ yytestcase(yyruleno==400); | |
| 174318 | - /* (401) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=401); | |
| 174319 | - /* (402) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=402); | |
| 175327 | + /* (340) input ::= cmdlist */ yytestcase(yyruleno==340); | |
| 175328 | + /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341); | |
| 175329 | + /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342); | |
| 175330 | + /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343); | |
| 175331 | + /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344); | |
| 175332 | + /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345); | |
| 175333 | + /* (346) trans_opt ::= */ yytestcase(yyruleno==346); | |
| 175334 | + /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347); | |
| 175335 | + /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348); | |
| 175336 | + /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349); | |
| 175337 | + /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350); | |
| 175338 | + /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351); | |
| 175339 | + /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352); | |
| 175340 | + /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353); | |
| 175341 | + /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354); | |
| 175342 | + /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355); | |
| 175343 | + /* (356) nm ::= STRING */ yytestcase(yyruleno==356); | |
| 175344 | + /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); | |
| 175345 | + /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); | |
| 175346 | + /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); | |
| 175347 | + /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); | |
| 175348 | + /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); | |
| 175349 | + /* (362) carglist ::= */ yytestcase(yyruleno==362); | |
| 175350 | + /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); | |
| 175351 | + /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); | |
| 175352 | + /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); | |
| 175353 | + /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); | |
| 175354 | + /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); | |
| 175355 | + /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); | |
| 175356 | + /* (369) tconscomma ::= */ yytestcase(yyruleno==369); | |
| 175357 | + /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); | |
| 175358 | + /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); | |
| 175359 | + /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); | |
| 175360 | + /* (373) oneselect ::= values */ yytestcase(yyruleno==373); | |
| 175361 | + /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); | |
| 175362 | + /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); | |
| 175363 | + /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376); | |
| 175364 | + /* (377) returning ::= */ yytestcase(yyruleno==377); | |
| 175365 | + /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); | |
| 175366 | + /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); | |
| 175367 | + /* (380) case_operand ::= expr */ yytestcase(yyruleno==380); | |
| 175368 | + /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); | |
| 175369 | + /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); | |
| 175370 | + /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); | |
| 175371 | + /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); | |
| 175372 | + /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); | |
| 175373 | + /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386); | |
| 175374 | + /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387); | |
| 175375 | + /* (388) foreach_clause ::= */ yytestcase(yyruleno==388); | |
| 175376 | + /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389); | |
| 175377 | + /* (390) trnm ::= nm */ yytestcase(yyruleno==390); | |
| 175378 | + /* (391) tridxby ::= */ yytestcase(yyruleno==391); | |
| 175379 | + /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392); | |
| 175380 | + /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393); | |
| 175381 | + /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394); | |
| 175382 | + /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395); | |
| 175383 | + /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396); | |
| 175384 | + /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397); | |
| 175385 | + /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398); | |
| 175386 | + /* (399) anylist ::= */ yytestcase(yyruleno==399); | |
| 175387 | + /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400); | |
| 175388 | + /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401); | |
| 175389 | + /* (402) with ::= */ yytestcase(yyruleno==402); | |
| 175390 | + /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403); | |
| 175391 | + /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404); | |
| 174320 | 175392 | break; |
| 174321 | 175393 | /********** End reduce actions ************************************************/ |
| 174322 | 175394 | }; |
| 174323 | 175395 | assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) ); |
| 174324 | 175396 | yygoto = yyRuleInfoLhs[yyruleno]; |
| @@ -176438,11 +177510,13 @@ | ||
| 176438 | 177510 | SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*); |
| 176439 | 177511 | #endif |
| 176440 | 177512 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 176441 | 177513 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); |
| 176442 | 177514 | #endif |
| 176443 | - | |
| 177515 | +#ifdef SQLITE_EXTRA_AUTOEXT | |
| 177516 | +int SQLITE_EXTRA_AUTOEXT(sqlite3*); | |
| 177517 | +#endif | |
| 176444 | 177518 | /* |
| 176445 | 177519 | ** An array of pointers to extension initializer functions for |
| 176446 | 177520 | ** built-in extensions. |
| 176447 | 177521 | */ |
| 176448 | 177522 | static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = { |
| @@ -176471,10 +177545,13 @@ | ||
| 176471 | 177545 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 176472 | 177546 | sqlite3StmtVtabInit, |
| 176473 | 177547 | #endif |
| 176474 | 177548 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 176475 | 177549 | sqlite3VdbeBytecodeVtabInit, |
| 177550 | +#endif | |
| 177551 | +#ifdef SQLITE_EXTRA_AUTOEXT | |
| 177552 | + SQLITE_EXTRA_AUTOEXT, | |
| 176476 | 177553 | #endif |
| 176477 | 177554 | }; |
| 176478 | 177555 | |
| 176479 | 177556 | #ifndef SQLITE_AMALGAMATION |
| 176480 | 177557 | /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant |
| @@ -176544,10 +177621,36 @@ | ||
| 176544 | 177621 | ** all database files specified with a relative pathname. |
| 176545 | 177622 | ** |
| 176546 | 177623 | ** See also the "PRAGMA data_store_directory" SQL command. |
| 176547 | 177624 | */ |
| 176548 | 177625 | SQLITE_API char *sqlite3_data_directory = 0; |
| 177626 | + | |
| 177627 | +/* | |
| 177628 | +** Determine whether or not high-precision (long double) floating point | |
| 177629 | +** math works correctly on CPU currently running. | |
| 177630 | +*/ | |
| 177631 | +static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){ | |
| 177632 | + if( sizeof(LONGDOUBLE_TYPE)<=8 ){ | |
| 177633 | + /* If the size of "long double" is not more than 8, then | |
| 177634 | + ** high-precision math is not possible. */ | |
| 177635 | + return 0; | |
| 177636 | + }else{ | |
| 177637 | + /* Just because sizeof(long double)>8 does not mean that the underlying | |
| 177638 | + ** hardware actually supports high-precision floating point. For example, | |
| 177639 | + ** clearing the 0x100 bit in the floating-point control word on Intel | |
| 177640 | + ** processors will make long double work like double, even though long | |
| 177641 | + ** double takes up more space. The only way to determine if long double | |
| 177642 | + ** actually works is to run an experiment. */ | |
| 177643 | + LONGDOUBLE_TYPE a, b, c; | |
| 177644 | + rc++; | |
| 177645 | + a = 1.0+rc*0.1; | |
| 177646 | + b = 1.0e+18+rc*25.0; | |
| 177647 | + c = a+b; | |
| 177648 | + return b!=c; | |
| 177649 | + } | |
| 177650 | +} | |
| 177651 | + | |
| 176549 | 177652 | |
| 176550 | 177653 | /* |
| 176551 | 177654 | ** Initialize SQLite. |
| 176552 | 177655 | ** |
| 176553 | 177656 | ** This routine must be called to initialize the memory allocation, |
| @@ -176739,10 +177842,14 @@ | ||
| 176739 | 177842 | if( bRunExtraInit ){ |
| 176740 | 177843 | int SQLITE_EXTRA_INIT(const char*); |
| 176741 | 177844 | rc = SQLITE_EXTRA_INIT(0); |
| 176742 | 177845 | } |
| 176743 | 177846 | #endif |
| 177847 | + | |
| 177848 | + /* Experimentally determine if high-precision floating point is | |
| 177849 | + ** available. */ | |
| 177850 | + sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc); | |
| 176744 | 177851 | |
| 176745 | 177852 | return rc; |
| 176746 | 177853 | } |
| 176747 | 177854 | |
| 176748 | 177855 | /* |
| @@ -177310,10 +178417,14 @@ | ||
| 177310 | 178417 | ** Configuration settings for an individual database connection |
| 177311 | 178418 | */ |
| 177312 | 178419 | SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ |
| 177313 | 178420 | va_list ap; |
| 177314 | 178421 | int rc; |
| 178422 | + | |
| 178423 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 178424 | + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | |
| 178425 | +#endif | |
| 177315 | 178426 | sqlite3_mutex_enter(db->mutex); |
| 177316 | 178427 | va_start(ap, op); |
| 177317 | 178428 | switch( op ){ |
| 177318 | 178429 | case SQLITE_DBCONFIG_MAINDBNAME: { |
| 177319 | 178430 | /* IMP: R-06824-28531 */ |
| @@ -177638,10 +178749,18 @@ | ||
| 177638 | 178749 | if( sqlite3GlobalConfig.xSqllog ){ |
| 177639 | 178750 | /* Closing the handle. Fourth parameter is passed the value 2. */ |
| 177640 | 178751 | sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2); |
| 177641 | 178752 | } |
| 177642 | 178753 | #endif |
| 178754 | + | |
| 178755 | + while( db->pDbData ){ | |
| 178756 | + DbClientData *p = db->pDbData; | |
| 178757 | + db->pDbData = p->pNext; | |
| 178758 | + assert( p->pData!=0 ); | |
| 178759 | + if( p->xDestructor ) p->xDestructor(p->pData); | |
| 178760 | + sqlite3_free(p); | |
| 178761 | + } | |
| 177643 | 178762 | |
| 177644 | 178763 | /* Convert the connection into a zombie and then close it. |
| 177645 | 178764 | */ |
| 177646 | 178765 | db->eOpenState = SQLITE_STATE_ZOMBIE; |
| 177647 | 178766 | sqlite3LeaveMutexAndCloseZombie(db); |
| @@ -178713,10 +179832,16 @@ | ||
| 178713 | 179832 | void(*xCallback)( /* Callback function */ |
| 178714 | 179833 | void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64), |
| 178715 | 179834 | void *pArg /* First callback argument */ |
| 178716 | 179835 | ){ |
| 178717 | 179836 | void *pRet; |
| 179837 | + | |
| 179838 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 179839 | + if( db==0 || xCallback==0 ){ | |
| 179840 | + return 0; | |
| 179841 | + } | |
| 179842 | +#endif | |
| 178718 | 179843 | sqlite3_mutex_enter(db->mutex); |
| 178719 | 179844 | pRet = db->pPreUpdateArg; |
| 178720 | 179845 | db->xPreUpdateCallback = xCallback; |
| 178721 | 179846 | db->pPreUpdateArg = pArg; |
| 178722 | 179847 | sqlite3_mutex_leave(db->mutex); |
| @@ -178859,11 +179984,11 @@ | ||
| 178859 | 179984 | assert( SQLITE_CHECKPOINT_RESTART==2 ); |
| 178860 | 179985 | assert( SQLITE_CHECKPOINT_TRUNCATE==3 ); |
| 178861 | 179986 | if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){ |
| 178862 | 179987 | /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint |
| 178863 | 179988 | ** mode: */ |
| 178864 | - return SQLITE_MISUSE; | |
| 179989 | + return SQLITE_MISUSE_BKPT; | |
| 178865 | 179990 | } |
| 178866 | 179991 | |
| 178867 | 179992 | sqlite3_mutex_enter(db->mutex); |
| 178868 | 179993 | if( zDb && zDb[0] ){ |
| 178869 | 179994 | iDb = sqlite3FindDbName(db, zDb); |
| @@ -180095,10 +181220,73 @@ | ||
| 180095 | 181220 | db->pCollNeededArg = pCollNeededArg; |
| 180096 | 181221 | sqlite3_mutex_leave(db->mutex); |
| 180097 | 181222 | return SQLITE_OK; |
| 180098 | 181223 | } |
| 180099 | 181224 | #endif /* SQLITE_OMIT_UTF16 */ |
| 181225 | + | |
| 181226 | +/* | |
| 181227 | +** Find existing client data. | |
| 181228 | +*/ | |
| 181229 | +SQLITE_API void *sqlite3_get_clientdata(sqlite3 *db, const char *zName){ | |
| 181230 | + DbClientData *p; | |
| 181231 | + sqlite3_mutex_enter(db->mutex); | |
| 181232 | + for(p=db->pDbData; p; p=p->pNext){ | |
| 181233 | + if( strcmp(p->zName, zName)==0 ){ | |
| 181234 | + void *pResult = p->pData; | |
| 181235 | + sqlite3_mutex_leave(db->mutex); | |
| 181236 | + return pResult; | |
| 181237 | + } | |
| 181238 | + } | |
| 181239 | + sqlite3_mutex_leave(db->mutex); | |
| 181240 | + return 0; | |
| 181241 | +} | |
| 181242 | + | |
| 181243 | +/* | |
| 181244 | +** Add new client data to a database connection. | |
| 181245 | +*/ | |
| 181246 | +SQLITE_API int sqlite3_set_clientdata( | |
| 181247 | + sqlite3 *db, /* Attach client data to this connection */ | |
| 181248 | + const char *zName, /* Name of the client data */ | |
| 181249 | + void *pData, /* The client data itself */ | |
| 181250 | + void (*xDestructor)(void*) /* Destructor */ | |
| 181251 | +){ | |
| 181252 | + DbClientData *p, **pp; | |
| 181253 | + sqlite3_mutex_enter(db->mutex); | |
| 181254 | + pp = &db->pDbData; | |
| 181255 | + for(p=db->pDbData; p && strcmp(p->zName,zName); p=p->pNext){ | |
| 181256 | + pp = &p->pNext; | |
| 181257 | + } | |
| 181258 | + if( p ){ | |
| 181259 | + assert( p->pData!=0 ); | |
| 181260 | + if( p->xDestructor ) p->xDestructor(p->pData); | |
| 181261 | + if( pData==0 ){ | |
| 181262 | + *pp = p->pNext; | |
| 181263 | + sqlite3_free(p); | |
| 181264 | + sqlite3_mutex_leave(db->mutex); | |
| 181265 | + return SQLITE_OK; | |
| 181266 | + } | |
| 181267 | + }else if( pData==0 ){ | |
| 181268 | + sqlite3_mutex_leave(db->mutex); | |
| 181269 | + return SQLITE_OK; | |
| 181270 | + }else{ | |
| 181271 | + size_t n = strlen(zName); | |
| 181272 | + p = sqlite3_malloc64( sizeof(DbClientData)+n+1 ); | |
| 181273 | + if( p==0 ){ | |
| 181274 | + if( xDestructor ) xDestructor(pData); | |
| 181275 | + sqlite3_mutex_leave(db->mutex); | |
| 181276 | + return SQLITE_NOMEM; | |
| 181277 | + } | |
| 181278 | + memcpy(p->zName, zName, n+1); | |
| 181279 | + p->pNext = db->pDbData; | |
| 181280 | + db->pDbData = p; | |
| 181281 | + } | |
| 181282 | + p->pData = pData; | |
| 181283 | + p->xDestructor = xDestructor; | |
| 181284 | + sqlite3_mutex_leave(db->mutex); | |
| 181285 | + return SQLITE_OK; | |
| 181286 | +} | |
| 181287 | + | |
| 180100 | 181288 | |
| 180101 | 181289 | #ifndef SQLITE_OMIT_DEPRECATED |
| 180102 | 181290 | /* |
| 180103 | 181291 | ** This function is now an anachronism. It used to be used to recover from a |
| 180104 | 181292 | ** malloc() failure, but SQLite now does this automatically. |
| @@ -180444,10 +181632,32 @@ | ||
| 180444 | 181632 | sqlite3Config.iPrngSeed = x; |
| 180445 | 181633 | sqlite3_randomness(0,0); |
| 180446 | 181634 | break; |
| 180447 | 181635 | } |
| 180448 | 181636 | #endif |
| 181637 | + | |
| 181638 | + /* sqlite3_test_control(SQLITE_TESTCTRL_FK_NO_ACTION, sqlite3 *db, int b); | |
| 181639 | + ** | |
| 181640 | + ** If b is true, then activate the SQLITE_FkNoAction setting. If b is | |
| 181641 | + ** false then clearn that setting. If the SQLITE_FkNoAction setting is | |
| 181642 | + ** abled, all foreign key ON DELETE and ON UPDATE actions behave as if | |
| 181643 | + ** they were NO ACTION, regardless of how they are defined. | |
| 181644 | + ** | |
| 181645 | + ** NB: One must usually run "PRAGMA writable_schema=RESET" after | |
| 181646 | + ** using this test-control, before it will take full effect. failing | |
| 181647 | + ** to reset the schema can result in some unexpected behavior. | |
| 181648 | + */ | |
| 181649 | + case SQLITE_TESTCTRL_FK_NO_ACTION: { | |
| 181650 | + sqlite3 *db = va_arg(ap, sqlite3*); | |
| 181651 | + int b = va_arg(ap, int); | |
| 181652 | + if( b ){ | |
| 181653 | + db->flags |= SQLITE_FkNoAction; | |
| 181654 | + }else{ | |
| 181655 | + db->flags &= ~SQLITE_FkNoAction; | |
| 181656 | + } | |
| 181657 | + break; | |
| 181658 | + } | |
| 180449 | 181659 | |
| 180450 | 181660 | /* |
| 180451 | 181661 | ** sqlite3_test_control(BITVEC_TEST, size, program) |
| 180452 | 181662 | ** |
| 180453 | 181663 | ** Run a test against a Bitvec object of size. The program argument |
| @@ -180869,15 +182079,15 @@ | ||
| 180869 | 182079 | /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X); |
| 180870 | 182080 | ** |
| 180871 | 182081 | ** X<0 Make no changes to the bUseLongDouble. Just report value. |
| 180872 | 182082 | ** X==0 Disable bUseLongDouble |
| 180873 | 182083 | ** X==1 Enable bUseLongDouble |
| 180874 | - ** X==2 Set bUseLongDouble to its default value for this platform | |
| 182084 | + ** X>=2 Set bUseLongDouble to its default value for this platform | |
| 180875 | 182085 | */ |
| 180876 | 182086 | case SQLITE_TESTCTRL_USELONGDOUBLE: { |
| 180877 | 182087 | int b = va_arg(ap, int); |
| 180878 | - if( b==2 ) b = sizeof(LONGDOUBLE_TYPE)>8; | |
| 182088 | + if( b>=2 ) b = hasHighPrecisionDouble(b); | |
| 180879 | 182089 | if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; |
| 180880 | 182090 | rc = sqlite3Config.bUseLongDouble!=0; |
| 180881 | 182091 | break; |
| 180882 | 182092 | } |
| 180883 | 182093 | #endif |
| @@ -181287,11 +182497,11 @@ | ||
| 181287 | 182497 | SQLITE_API int sqlite3_compileoption_used(const char *zOptName){ |
| 181288 | 182498 | int i, n; |
| 181289 | 182499 | int nOpt; |
| 181290 | 182500 | const char **azCompileOpt; |
| 181291 | 182501 | |
| 181292 | -#if SQLITE_ENABLE_API_ARMOR | |
| 182502 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 181293 | 182503 | if( zOptName==0 ){ |
| 181294 | 182504 | (void)SQLITE_MISUSE_BKPT; |
| 181295 | 182505 | return 0; |
| 181296 | 182506 | } |
| 181297 | 182507 | #endif |
| @@ -181482,10 +182692,13 @@ | ||
| 181482 | 182692 | void (*xNotify)(void **, int), |
| 181483 | 182693 | void *pArg |
| 181484 | 182694 | ){ |
| 181485 | 182695 | int rc = SQLITE_OK; |
| 181486 | 182696 | |
| 182697 | +#ifdef SQLITE_ENABLE_API_ARMOR | |
| 182698 | + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | |
| 182699 | +#endif | |
| 181487 | 182700 | sqlite3_mutex_enter(db->mutex); |
| 181488 | 182701 | enterMutex(); |
| 181489 | 182702 | |
| 181490 | 182703 | if( xNotify==0 ){ |
| 181491 | 182704 | removeFromBlockedList(db); |
| @@ -182503,10 +183716,11 @@ | ||
| 182503 | 183716 | u8 bDescIdx; /* True if doclists are in reverse order */ |
| 182504 | 183717 | u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */ |
| 182505 | 183718 | int nPgsz; /* Page size for host database */ |
| 182506 | 183719 | char *zSegmentsTbl; /* Name of %_segments table */ |
| 182507 | 183720 | sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ |
| 183721 | + int iSavepoint; | |
| 182508 | 183722 | |
| 182509 | 183723 | /* |
| 182510 | 183724 | ** The following array of hash tables is used to buffer pending index |
| 182511 | 183725 | ** updates during transactions. All pending updates buffered at any one |
| 182512 | 183726 | ** time must share a common language-id (see the FTS4 langid= feature). |
| @@ -183246,10 +184460,11 @@ | ||
| 183246 | 184460 | char *zCols; /* List of user defined columns */ |
| 183247 | 184461 | const char *zLanguageid; |
| 183248 | 184462 | |
| 183249 | 184463 | zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); |
| 183250 | 184464 | sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 184465 | + sqlite3_vtab_config(p->db, SQLITE_VTAB_INNOCUOUS); | |
| 183251 | 184466 | |
| 183252 | 184467 | /* Create a list of user columns for the virtual table */ |
| 183253 | 184468 | zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); |
| 183254 | 184469 | for(i=1; zCols && i<p->nColumn; i++){ |
| 183255 | 184470 | zCols = sqlite3_mprintf("%z%Q, ", zCols, p->azColumn[i]); |
| @@ -186495,10 +187710,12 @@ | ||
| 186495 | 187710 | assert( p->nPendingData==0 ); |
| 186496 | 187711 | if( rc==SQLITE_OK ){ |
| 186497 | 187712 | rc = sqlite3Fts3PendingTermsFlush(p); |
| 186498 | 187713 | } |
| 186499 | 187714 | |
| 187715 | + p->bIgnoreSavepoint = 1; | |
| 187716 | + | |
| 186500 | 187717 | if( p->zContentTbl==0 ){ |
| 186501 | 187718 | fts3DbExec(&rc, db, |
| 186502 | 187719 | "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", |
| 186503 | 187720 | p->zDb, p->zName, zName |
| 186504 | 187721 | ); |
| @@ -186522,10 +187739,12 @@ | ||
| 186522 | 187739 | ); |
| 186523 | 187740 | fts3DbExec(&rc, db, |
| 186524 | 187741 | "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", |
| 186525 | 187742 | p->zDb, p->zName, zName |
| 186526 | 187743 | ); |
| 187744 | + | |
| 187745 | + p->bIgnoreSavepoint = 0; | |
| 186527 | 187746 | return rc; |
| 186528 | 187747 | } |
| 186529 | 187748 | |
| 186530 | 187749 | /* |
| 186531 | 187750 | ** The xSavepoint() method. |
| @@ -186532,16 +187751,32 @@ | ||
| 186532 | 187751 | ** |
| 186533 | 187752 | ** Flush the contents of the pending-terms table to disk. |
| 186534 | 187753 | */ |
| 186535 | 187754 | static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186536 | 187755 | int rc = SQLITE_OK; |
| 186537 | - UNUSED_PARAMETER(iSavepoint); | |
| 186538 | - assert( ((Fts3Table *)pVtab)->inTransaction ); | |
| 186539 | - assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint ); | |
| 186540 | - TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint ); | |
| 186541 | - if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){ | |
| 186542 | - rc = fts3SyncMethod(pVtab); | |
| 187756 | + Fts3Table *pTab = (Fts3Table*)pVtab; | |
| 187757 | + assert( pTab->inTransaction ); | |
| 187758 | + assert( pTab->mxSavepoint<=iSavepoint ); | |
| 187759 | + TESTONLY( pTab->mxSavepoint = iSavepoint ); | |
| 187760 | + | |
| 187761 | + if( pTab->bIgnoreSavepoint==0 ){ | |
| 187762 | + if( fts3HashCount(&pTab->aIndex[0].hPending)>0 ){ | |
| 187763 | + char *zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", | |
| 187764 | + pTab->zDb, pTab->zName, pTab->zName | |
| 187765 | + ); | |
| 187766 | + if( zSql ){ | |
| 187767 | + pTab->bIgnoreSavepoint = 1; | |
| 187768 | + rc = sqlite3_exec(pTab->db, zSql, 0, 0, 0); | |
| 187769 | + pTab->bIgnoreSavepoint = 0; | |
| 187770 | + sqlite3_free(zSql); | |
| 187771 | + }else{ | |
| 187772 | + rc = SQLITE_NOMEM; | |
| 187773 | + } | |
| 187774 | + } | |
| 187775 | + if( rc==SQLITE_OK ){ | |
| 187776 | + pTab->iSavepoint = iSavepoint+1; | |
| 187777 | + } | |
| 186543 | 187778 | } |
| 186544 | 187779 | return rc; |
| 186545 | 187780 | } |
| 186546 | 187781 | |
| 186547 | 187782 | /* |
| @@ -186548,30 +187783,31 @@ | ||
| 186548 | 187783 | ** The xRelease() method. |
| 186549 | 187784 | ** |
| 186550 | 187785 | ** This is a no-op. |
| 186551 | 187786 | */ |
| 186552 | 187787 | static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186553 | - TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); | |
| 186554 | - UNUSED_PARAMETER(iSavepoint); | |
| 186555 | - UNUSED_PARAMETER(pVtab); | |
| 186556 | - assert( p->inTransaction ); | |
| 186557 | - assert( p->mxSavepoint >= iSavepoint ); | |
| 186558 | - TESTONLY( p->mxSavepoint = iSavepoint-1 ); | |
| 187788 | + Fts3Table *pTab = (Fts3Table*)pVtab; | |
| 187789 | + assert( pTab->inTransaction ); | |
| 187790 | + assert( pTab->mxSavepoint >= iSavepoint ); | |
| 187791 | + TESTONLY( pTab->mxSavepoint = iSavepoint-1 ); | |
| 187792 | + pTab->iSavepoint = iSavepoint; | |
| 186559 | 187793 | return SQLITE_OK; |
| 186560 | 187794 | } |
| 186561 | 187795 | |
| 186562 | 187796 | /* |
| 186563 | 187797 | ** The xRollbackTo() method. |
| 186564 | 187798 | ** |
| 186565 | 187799 | ** Discard the contents of the pending terms table. |
| 186566 | 187800 | */ |
| 186567 | 187801 | static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186568 | - Fts3Table *p = (Fts3Table*)pVtab; | |
| 187802 | + Fts3Table *pTab = (Fts3Table*)pVtab; | |
| 186569 | 187803 | UNUSED_PARAMETER(iSavepoint); |
| 186570 | - assert( p->inTransaction ); | |
| 186571 | - TESTONLY( p->mxSavepoint = iSavepoint ); | |
| 186572 | - sqlite3Fts3PendingTermsClear(p); | |
| 187804 | + assert( pTab->inTransaction ); | |
| 187805 | + TESTONLY( pTab->mxSavepoint = iSavepoint ); | |
| 187806 | + if( (iSavepoint+1)<=pTab->iSavepoint ){ | |
| 187807 | + sqlite3Fts3PendingTermsClear(pTab); | |
| 187808 | + } | |
| 186573 | 187809 | return SQLITE_OK; |
| 186574 | 187810 | } |
| 186575 | 187811 | |
| 186576 | 187812 | /* |
| 186577 | 187813 | ** Return true if zName is the extension on one of the shadow tables used |
| @@ -186585,13 +187821,37 @@ | ||
| 186585 | 187821 | for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 186586 | 187822 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 186587 | 187823 | } |
| 186588 | 187824 | return 0; |
| 186589 | 187825 | } |
| 187826 | + | |
| 187827 | +/* | |
| 187828 | +** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual | |
| 187829 | +** table. | |
| 187830 | +*/ | |
| 187831 | +static int fts3Integrity(sqlite3_vtab *pVtab, char **pzErr){ | |
| 187832 | + Fts3Table *p = (Fts3Table*)pVtab; | |
| 187833 | + char *zSql; | |
| 187834 | + int rc; | |
| 187835 | + | |
| 187836 | + zSql = sqlite3_mprintf( | |
| 187837 | + "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", | |
| 187838 | + p->zDb, p->zName, p->zName); | |
| 187839 | + rc = sqlite3_exec(p->db, zSql, 0, 0, 0); | |
| 187840 | + sqlite3_free(zSql); | |
| 187841 | + if( (rc&0xff)==SQLITE_CORRUPT ){ | |
| 187842 | + *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", | |
| 187843 | + p->bFts4 ? 4 : 3, p->zDb, p->zName); | |
| 187844 | + rc = SQLITE_OK; | |
| 187845 | + } | |
| 187846 | + return rc; | |
| 187847 | +} | |
| 187848 | + | |
| 187849 | + | |
| 186590 | 187850 | |
| 186591 | 187851 | static const sqlite3_module fts3Module = { |
| 186592 | - /* iVersion */ 3, | |
| 187852 | + /* iVersion */ 4, | |
| 186593 | 187853 | /* xCreate */ fts3CreateMethod, |
| 186594 | 187854 | /* xConnect */ fts3ConnectMethod, |
| 186595 | 187855 | /* xBestIndex */ fts3BestIndexMethod, |
| 186596 | 187856 | /* xDisconnect */ fts3DisconnectMethod, |
| 186597 | 187857 | /* xDestroy */ fts3DestroyMethod, |
| @@ -186611,10 +187871,11 @@ | ||
| 186611 | 187871 | /* xRename */ fts3RenameMethod, |
| 186612 | 187872 | /* xSavepoint */ fts3SavepointMethod, |
| 186613 | 187873 | /* xRelease */ fts3ReleaseMethod, |
| 186614 | 187874 | /* xRollbackTo */ fts3RollbackToMethod, |
| 186615 | 187875 | /* xShadowName */ fts3ShadowName, |
| 187876 | + /* xIntegrity */ fts3Integrity, | |
| 186616 | 187877 | }; |
| 186617 | 187878 | |
| 186618 | 187879 | /* |
| 186619 | 187880 | ** This function is registered as the module destructor (called when an |
| 186620 | 187881 | ** FTS3 enabled database connection is closed). It frees the memory |
| @@ -189286,11 +190547,12 @@ | ||
| 189286 | 190547 | 0, /* xFindFunction */ |
| 189287 | 190548 | 0, /* xRename */ |
| 189288 | 190549 | 0, /* xSavepoint */ |
| 189289 | 190550 | 0, /* xRelease */ |
| 189290 | 190551 | 0, /* xRollbackTo */ |
| 189291 | - 0 /* xShadowName */ | |
| 190552 | + 0, /* xShadowName */ | |
| 190553 | + 0 /* xIntegrity */ | |
| 189292 | 190554 | }; |
| 189293 | 190555 | int rc; /* Return code */ |
| 189294 | 190556 | |
| 189295 | 190557 | rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0); |
| 189296 | 190558 | return rc; |
| @@ -192852,11 +194114,12 @@ | ||
| 192852 | 194114 | 0, /* xFindFunction */ |
| 192853 | 194115 | 0, /* xRename */ |
| 192854 | 194116 | 0, /* xSavepoint */ |
| 192855 | 194117 | 0, /* xRelease */ |
| 192856 | 194118 | 0, /* xRollbackTo */ |
| 192857 | - 0 /* xShadowName */ | |
| 194119 | + 0, /* xShadowName */ | |
| 194120 | + 0 /* xIntegrity */ | |
| 192858 | 194121 | }; |
| 192859 | 194122 | int rc; /* Return code */ |
| 192860 | 194123 | |
| 192861 | 194124 | rc = sqlite3_create_module_v2( |
| 192862 | 194125 | db, "fts3tokenize", &fts3tok_module, (void*)pHash, xDestroy |
| @@ -196193,11 +197456,10 @@ | ||
| 196193 | 197456 | |
| 196194 | 197457 | for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){ |
| 196195 | 197458 | rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); |
| 196196 | 197459 | if( rc==SQLITE_DONE ) rc = SQLITE_OK; |
| 196197 | 197460 | } |
| 196198 | - sqlite3Fts3PendingTermsClear(p); | |
| 196199 | 197461 | |
| 196200 | 197462 | /* Determine the auto-incr-merge setting if unknown. If enabled, |
| 196201 | 197463 | ** estimate the number of leaf blocks of content to be written |
| 196202 | 197464 | */ |
| 196203 | 197465 | if( rc==SQLITE_OK && p->bHasStat |
| @@ -196215,10 +197477,14 @@ | ||
| 196215 | 197477 | p->nAutoincrmerge = 0; |
| 196216 | 197478 | } |
| 196217 | 197479 | rc = sqlite3_reset(pStmt); |
| 196218 | 197480 | } |
| 196219 | 197481 | } |
| 197482 | + | |
| 197483 | + if( rc==SQLITE_OK ){ | |
| 197484 | + sqlite3Fts3PendingTermsClear(p); | |
| 197485 | + } | |
| 196220 | 197486 | return rc; |
| 196221 | 197487 | } |
| 196222 | 197488 | |
| 196223 | 197489 | /* |
| 196224 | 197490 | ** Encode N integers as varints into a blob. |
| @@ -196902,13 +198168,17 @@ | ||
| 196902 | 198168 | nSpace = sqlite3Fts3VarintLen(nPrefix); |
| 196903 | 198169 | nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 196904 | 198170 | nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 196905 | 198171 | |
| 196906 | 198172 | /* 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 | |
| 196908 | - ** bytes, write this block out to the database. */ | |
| 196909 | - if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){ | |
| 198173 | + ** to the current block would make it larger than Fts3Table.nNodeSize bytes, | |
| 198174 | + ** and if there is still room for another leaf page, write this block out to | |
| 198175 | + ** the database. */ | |
| 198176 | + if( pLeaf->block.n>0 | |
| 198177 | + && (pLeaf->block.n + nSpace)>p->nNodeSize | |
| 198178 | + && pLeaf->iBlock < (pWriter->iStart + pWriter->nLeafEst) | |
| 198179 | + ){ | |
| 196910 | 198180 | rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); |
| 196911 | 198181 | pWriter->nWork++; |
| 196912 | 198182 | |
| 196913 | 198183 | /* Add the current term to the parent node. The term added to the |
| 196914 | 198184 | ** parent must: |
| @@ -197236,11 +198506,11 @@ | ||
| 197236 | 198506 | pNode = &pWriter->aNodeWriter[i-1]; |
| 197237 | 198507 | pNode->iBlock = reader.iChild; |
| 197238 | 198508 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); |
| 197239 | 198509 | blobGrowBuffer(&pNode->block, |
| 197240 | 198510 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc |
| 197241 | - ); | |
| 198511 | + ); | |
| 197242 | 198512 | if( rc==SQLITE_OK ){ |
| 197243 | 198513 | memcpy(pNode->block.a, aBlock, nBlock); |
| 197244 | 198514 | pNode->block.n = nBlock; |
| 197245 | 198515 | memset(&pNode->block.a[nBlock], 0, FTS3_NODE_PADDING); |
| 197246 | 198516 | } |
| @@ -198301,12 +199571,15 @@ | ||
| 198301 | 199571 | rc = fts3DoIntegrityCheck(p); |
| 198302 | 199572 | }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){ |
| 198303 | 199573 | rc = fts3DoIncrmerge(p, &zVal[6]); |
| 198304 | 199574 | }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ |
| 198305 | 199575 | rc = fts3DoAutoincrmerge(p, &zVal[10]); |
| 199576 | + }else if( nVal==5 && 0==sqlite3_strnicmp(zVal, "flush", 5) ){ | |
| 199577 | + rc = sqlite3Fts3PendingTermsFlush(p); | |
| 199578 | + } | |
| 198306 | 199579 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| 198307 | - }else{ | |
| 199580 | + else{ | |
| 198308 | 199581 | int v; |
| 198309 | 199582 | if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ |
| 198310 | 199583 | v = atoi(&zVal[9]); |
| 198311 | 199584 | if( v>=24 && v<=p->nPgsz-35 ) p->nNodeSize = v; |
| 198312 | 199585 | rc = SQLITE_OK; |
| @@ -198320,12 +199593,12 @@ | ||
| 198320 | 199593 | }else if( nVal>11 && 0==sqlite3_strnicmp(zVal,"mergecount=",11) ){ |
| 198321 | 199594 | v = atoi(&zVal[11]); |
| 198322 | 199595 | if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; |
| 198323 | 199596 | rc = SQLITE_OK; |
| 198324 | 199597 | } |
| 199598 | + } | |
| 198325 | 199599 | #endif |
| 198326 | - } | |
| 198327 | 199600 | return rc; |
| 198328 | 199601 | } |
| 198329 | 199602 | |
| 198330 | 199603 | #ifndef SQLITE_DISABLE_FTS4_DEFERRED |
| 198331 | 199604 | /* |
| @@ -201834,11 +203107,11 @@ | ||
| 201834 | 203107 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 201835 | 203108 | SQLITE_TRANSIENT, SQLITE_UTF8); |
| 201836 | 203109 | }else if( jsonForceRCStr(p) ){ |
| 201837 | 203110 | sqlite3RCStrRef(p->zBuf); |
| 201838 | 203111 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 201839 | - (void(*)(void*))sqlite3RCStrUnref, | |
| 203112 | + sqlite3RCStrUnref, | |
| 201840 | 203113 | SQLITE_UTF8); |
| 201841 | 203114 | } |
| 201842 | 203115 | } |
| 201843 | 203116 | if( p->bErr==1 ){ |
| 201844 | 203117 | sqlite3_result_error_nomem(p->pCtx); |
| @@ -203174,11 +204447,11 @@ | ||
| 203174 | 204447 | } |
| 203175 | 204448 | |
| 203176 | 204449 | /* The input JSON was not found anywhere in the cache. We will need |
| 203177 | 204450 | ** to parse it ourselves and generate a new JsonParse object. |
| 203178 | 204451 | */ |
| 203179 | - bJsonRCStr = sqlite3ValueIsOfClass(pJson,(void(*)(void*))sqlite3RCStrUnref); | |
| 204452 | + bJsonRCStr = sqlite3ValueIsOfClass(pJson,sqlite3RCStrUnref); | |
| 203180 | 204453 | p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); |
| 203181 | 204454 | if( p==0 ){ |
| 203182 | 204455 | sqlite3_result_error_nomem(pCtx); |
| 203183 | 204456 | return 0; |
| 203184 | 204457 | } |
| @@ -203388,10 +204661,11 @@ | ||
| 203388 | 204661 | && (i>0 || ((pRoot[j].jnFlags & JNODE_REMOVE)!=0 && pParse->useMod)) |
| 203389 | 204662 | ){ |
| 203390 | 204663 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; |
| 203391 | 204664 | j += jsonNodeSize(&pRoot[j]); |
| 203392 | 204665 | } |
| 204666 | + if( i==0 && j<=pRoot->n ) break; | |
| 203393 | 204667 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
| 203394 | 204668 | if( pParse->useMod==0 ) break; |
| 203395 | 204669 | assert( pRoot->eU==2 ); |
| 203396 | 204670 | iRoot = pRoot->u.iAppend; |
| 203397 | 204671 | pRoot = &pParse->aNode[iRoot]; |
| @@ -204075,15 +205349,17 @@ | ||
| 204075 | 205349 | if( z==0 ){ |
| 204076 | 205350 | p->oom = 1; |
| 204077 | 205351 | break; |
| 204078 | 205352 | } |
| 204079 | 205353 | if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ |
| 204080 | - char *zCopy = sqlite3DbStrDup(0, z); | |
| 205354 | + char *zCopy = sqlite3_malloc64( n+1 ); | |
| 204081 | 205355 | int k; |
| 204082 | 205356 | if( zCopy ){ |
| 205357 | + memcpy(zCopy, z, n); | |
| 205358 | + zCopy[n] = 0; | |
| 204083 | 205359 | jsonParseAddCleanup(p, sqlite3_free, zCopy); |
| 204084 | - }else{ | |
| 205360 | + }else{ | |
| 204085 | 205361 | p->oom = 1; |
| 204086 | 205362 | sqlite3_result_error_nomem(pCtx); |
| 204087 | 205363 | } |
| 204088 | 205364 | k = jsonParseAddNode(p, JSON_STRING, n, zCopy); |
| 204089 | 205365 | assert( k>0 || p->oom ); |
| @@ -204134,10 +205410,11 @@ | ||
| 204134 | 205410 | jsonWrongNumArgs(ctx, "replace"); |
| 204135 | 205411 | return; |
| 204136 | 205412 | } |
| 204137 | 205413 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 204138 | 205414 | if( pParse==0 ) return; |
| 205415 | + pParse->nJPRef++; | |
| 204139 | 205416 | for(i=1; i<(u32)argc; i+=2){ |
| 204140 | 205417 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 204141 | 205418 | pParse->useMod = 1; |
| 204142 | 205419 | pNode = jsonLookup(pParse, zPath, 0, ctx); |
| 204143 | 205420 | if( pParse->nErr ) goto replace_err; |
| @@ -204146,10 +205423,11 @@ | ||
| 204146 | 205423 | } |
| 204147 | 205424 | } |
| 204148 | 205425 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 204149 | 205426 | replace_err: |
| 204150 | 205427 | jsonDebugPrintParse(pParse); |
| 205428 | + jsonParseFree(pParse); | |
| 204151 | 205429 | } |
| 204152 | 205430 | |
| 204153 | 205431 | |
| 204154 | 205432 | /* |
| 204155 | 205433 | ** json_set(JSON, PATH, VALUE, ...) |
| @@ -204180,10 +205458,11 @@ | ||
| 204180 | 205458 | jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); |
| 204181 | 205459 | return; |
| 204182 | 205460 | } |
| 204183 | 205461 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 204184 | 205462 | if( pParse==0 ) return; |
| 205463 | + pParse->nJPRef++; | |
| 204185 | 205464 | for(i=1; i<(u32)argc; i+=2){ |
| 204186 | 205465 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 204187 | 205466 | bApnd = 0; |
| 204188 | 205467 | pParse->useMod = 1; |
| 204189 | 205468 | pNode = jsonLookup(pParse, zPath, &bApnd, ctx); |
| @@ -204196,13 +205475,12 @@ | ||
| 204196 | 205475 | jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); |
| 204197 | 205476 | } |
| 204198 | 205477 | } |
| 204199 | 205478 | jsonDebugPrintParse(pParse); |
| 204200 | 205479 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 204201 | - | |
| 204202 | 205480 | jsonSetDone: |
| 204203 | - /* no cleanup required */; | |
| 205481 | + jsonParseFree(pParse); | |
| 204204 | 205482 | } |
| 204205 | 205483 | |
| 204206 | 205484 | /* |
| 204207 | 205485 | ** json_type(JSON) |
| 204208 | 205486 | ** json_type(JSON, PATH) |
| @@ -204354,11 +205632,11 @@ | ||
| 204354 | 205632 | if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); |
| 204355 | 205633 | assert( pStr->bStatic ); |
| 204356 | 205634 | }else if( isFinal ){ |
| 204357 | 205635 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 204358 | 205636 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 204359 | - (void(*)(void*))sqlite3RCStrUnref); | |
| 205637 | + sqlite3RCStrUnref); | |
| 204360 | 205638 | pStr->bStatic = 1; |
| 204361 | 205639 | }else{ |
| 204362 | 205640 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| 204363 | 205641 | pStr->nUsed--; |
| 204364 | 205642 | } |
| @@ -204463,11 +205741,11 @@ | ||
| 204463 | 205741 | if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); |
| 204464 | 205742 | assert( pStr->bStatic ); |
| 204465 | 205743 | }else if( isFinal ){ |
| 204466 | 205744 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 204467 | 205745 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 204468 | - (void(*)(void*))sqlite3RCStrUnref); | |
| 205746 | + sqlite3RCStrUnref); | |
| 204469 | 205747 | pStr->bStatic = 1; |
| 204470 | 205748 | }else{ |
| 204471 | 205749 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| 204472 | 205750 | pStr->nUsed--; |
| 204473 | 205751 | } |
| @@ -204895,11 +206173,11 @@ | ||
| 204895 | 206173 | if( idxNum==0 ) return SQLITE_OK; |
| 204896 | 206174 | z = (const char*)sqlite3_value_text(argv[0]); |
| 204897 | 206175 | if( z==0 ) return SQLITE_OK; |
| 204898 | 206176 | memset(&p->sParse, 0, sizeof(p->sParse)); |
| 204899 | 206177 | p->sParse.nJPRef = 1; |
| 204900 | - if( sqlite3ValueIsOfClass(argv[0], (void(*)(void*))sqlite3RCStrUnref) ){ | |
| 206178 | + if( sqlite3ValueIsOfClass(argv[0], sqlite3RCStrUnref) ){ | |
| 204901 | 206179 | p->sParse.zJson = sqlite3RCStrRef((char*)z); |
| 204902 | 206180 | }else{ |
| 204903 | 206181 | n = sqlite3_value_bytes(argv[0]); |
| 204904 | 206182 | p->sParse.zJson = sqlite3RCStrNew( n+1 ); |
| 204905 | 206183 | if( p->sParse.zJson==0 ) return SQLITE_NOMEM; |
| @@ -204990,11 +206268,12 @@ | ||
| 204990 | 206268 | 0, /* xFindMethod */ |
| 204991 | 206269 | 0, /* xRename */ |
| 204992 | 206270 | 0, /* xSavepoint */ |
| 204993 | 206271 | 0, /* xRelease */ |
| 204994 | 206272 | 0, /* xRollbackTo */ |
| 204995 | - 0 /* xShadowName */ | |
| 206273 | + 0, /* xShadowName */ | |
| 206274 | + 0 /* xIntegrity */ | |
| 204996 | 206275 | }; |
| 204997 | 206276 | |
| 204998 | 206277 | /* The methods of the json_tree virtual table. */ |
| 204999 | 206278 | static sqlite3_module jsonTreeModule = { |
| 205000 | 206279 | 0, /* iVersion */ |
| @@ -205018,11 +206297,12 @@ | ||
| 205018 | 206297 | 0, /* xFindMethod */ |
| 205019 | 206298 | 0, /* xRename */ |
| 205020 | 206299 | 0, /* xSavepoint */ |
| 205021 | 206300 | 0, /* xRelease */ |
| 205022 | 206301 | 0, /* xRollbackTo */ |
| 205023 | - 0 /* xShadowName */ | |
| 206302 | + 0, /* xShadowName */ | |
| 206303 | + 0 /* xIntegrity */ | |
| 205024 | 206304 | }; |
| 205025 | 206305 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 205026 | 206306 | #endif /* !defined(SQLITE_OMIT_JSON) */ |
| 205027 | 206307 | |
| 205028 | 206308 | /* |
| @@ -205253,10 +206533,11 @@ | ||
| 205253 | 206533 | u8 bCorrupt; /* Shadow table corruption detected */ |
| 205254 | 206534 | #endif |
| 205255 | 206535 | int iDepth; /* Current depth of the r-tree structure */ |
| 205256 | 206536 | char *zDb; /* Name of database containing r-tree table */ |
| 205257 | 206537 | char *zName; /* Name of r-tree table */ |
| 206538 | + char *zNodeName; /* Name of the %_node table */ | |
| 205258 | 206539 | u32 nBusy; /* Current number of users of this structure */ |
| 205259 | 206540 | i64 nRowEst; /* Estimated number of rows in this table */ |
| 205260 | 206541 | u32 nCursor; /* Number of open cursors */ |
| 205261 | 206542 | u32 nNodeRef; /* Number RtreeNodes with positive nRef */ |
| 205262 | 206543 | char *zReadAuxSql; /* SQL for statement to read aux data */ |
| @@ -205265,11 +206546,10 @@ | ||
| 205265 | 206546 | ** linked together via the pointer normally used for hash chains - |
| 205266 | 206547 | ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree |
| 205267 | 206548 | ** headed by the node (leaf nodes have RtreeNode.iNode==0). |
| 205268 | 206549 | */ |
| 205269 | 206550 | RtreeNode *pDeleted; |
| 205270 | - int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */ | |
| 205271 | 206551 | |
| 205272 | 206552 | /* Blob I/O on xxx_node */ |
| 205273 | 206553 | sqlite3_blob *pNodeBlob; |
| 205274 | 206554 | |
| 205275 | 206555 | /* Statements to read/write/delete a record from xxx_node */ |
| @@ -205562,19 +206842,24 @@ | ||
| 205562 | 206842 | ** For best performance, an attempt is made to guess at the byte-order |
| 205563 | 206843 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 205564 | 206844 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 205565 | 206845 | ** at run-time. |
| 205566 | 206846 | */ |
| 205567 | -#ifndef SQLITE_BYTEORDER | |
| 205568 | -# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | |
| 206847 | +#ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ | |
| 206848 | +# if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
| 206849 | +# define SQLITE_BYTEORDER 4321 | |
| 206850 | +# elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ | |
| 206851 | +# define SQLITE_BYTEORDER 1234 | |
| 206852 | +# elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 | |
| 206853 | +# define SQLITE_BYTEORDER 4321 | |
| 206854 | +# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | |
| 205569 | 206855 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 205570 | 206856 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 205571 | 206857 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 205572 | -# define SQLITE_BYTEORDER 1234 | |
| 205573 | -# elif defined(sparc) || defined(__ppc__) || \ | |
| 205574 | - defined(__ARMEB__) || defined(__AARCH64EB__) | |
| 205575 | -# define SQLITE_BYTEORDER 4321 | |
| 206858 | +# define SQLITE_BYTEORDER 1234 | |
| 206859 | +# elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) | |
| 206860 | +# define SQLITE_BYTEORDER 4321 | |
| 205576 | 206861 | # else |
| 205577 | 206862 | # define SQLITE_BYTEORDER 0 |
| 205578 | 206863 | # endif |
| 205579 | 206864 | #endif |
| 205580 | 206865 | |
| @@ -205819,15 +207104,13 @@ | ||
| 205819 | 207104 | nodeBlobReset(pRtree); |
| 205820 | 207105 | if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM; |
| 205821 | 207106 | } |
| 205822 | 207107 | } |
| 205823 | 207108 | if( pRtree->pNodeBlob==0 ){ |
| 205824 | - char *zTab = sqlite3_mprintf("%s_node", pRtree->zName); | |
| 205825 | - if( zTab==0 ) return SQLITE_NOMEM; | |
| 205826 | - rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0, | |
| 207109 | + rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, pRtree->zNodeName, | |
| 207110 | + "data", iNode, 0, | |
| 205827 | 207111 | &pRtree->pNodeBlob); |
| 205828 | - sqlite3_free(zTab); | |
| 205829 | 207112 | } |
| 205830 | 207113 | if( rc ){ |
| 205831 | 207114 | nodeBlobReset(pRtree); |
| 205832 | 207115 | *ppNode = 0; |
| 205833 | 207116 | /* If unable to open an sqlite3_blob on the desired row, that can only |
| @@ -207164,12 +208447,16 @@ | ||
| 207164 | 208447 | } |
| 207165 | 208448 | } |
| 207166 | 208449 | |
| 207167 | 208450 | pIdxInfo->idxNum = 2; |
| 207168 | 208451 | pIdxInfo->needToFreeIdxStr = 1; |
| 207169 | - if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ | |
| 207170 | - return SQLITE_NOMEM; | |
| 208452 | + if( iIdx>0 ){ | |
| 208453 | + pIdxInfo->idxStr = sqlite3_malloc( iIdx+1 ); | |
| 208454 | + if( pIdxInfo->idxStr==0 ){ | |
| 208455 | + return SQLITE_NOMEM; | |
| 208456 | + } | |
| 208457 | + memcpy(pIdxInfo->idxStr, zIdxStr, iIdx+1); | |
| 207171 | 208458 | } |
| 207172 | 208459 | |
| 207173 | 208460 | nRow = pRtree->nRowEst >> (iIdx/2); |
| 207174 | 208461 | pIdxInfo->estimatedCost = (double)6.0 * (double)nRow; |
| 207175 | 208462 | pIdxInfo->estimatedRows = nRow; |
| @@ -207244,35 +208531,26 @@ | ||
| 207244 | 208531 | ** Return true if the area covered by p2 is a subset of the area covered |
| 207245 | 208532 | ** by p1. False otherwise. |
| 207246 | 208533 | */ |
| 207247 | 208534 | static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ |
| 207248 | 208535 | int ii; |
| 207249 | - int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); | |
| 207250 | - for(ii=0; ii<pRtree->nDim2; ii+=2){ | |
| 207251 | - RtreeCoord *a1 = &p1->aCoord[ii]; | |
| 207252 | - RtreeCoord *a2 = &p2->aCoord[ii]; | |
| 207253 | - if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) | |
| 207254 | - || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) | |
| 207255 | - ){ | |
| 207256 | - return 0; | |
| 208536 | + if( pRtree->eCoordType==RTREE_COORD_INT32 ){ | |
| 208537 | + for(ii=0; ii<pRtree->nDim2; ii+=2){ | |
| 208538 | + RtreeCoord *a1 = &p1->aCoord[ii]; | |
| 208539 | + RtreeCoord *a2 = &p2->aCoord[ii]; | |
| 208540 | + if( a2[0].i<a1[0].i || a2[1].i>a1[1].i ) return 0; | |
| 208541 | + } | |
| 208542 | + }else{ | |
| 208543 | + for(ii=0; ii<pRtree->nDim2; ii+=2){ | |
| 208544 | + RtreeCoord *a1 = &p1->aCoord[ii]; | |
| 208545 | + RtreeCoord *a2 = &p2->aCoord[ii]; | |
| 208546 | + if( a2[0].f<a1[0].f || a2[1].f>a1[1].f ) return 0; | |
| 207257 | 208547 | } |
| 207258 | 208548 | } |
| 207259 | 208549 | return 1; |
| 207260 | 208550 | } |
| 207261 | 208551 | |
| 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 | 208552 | static RtreeDValue cellOverlap( |
| 207275 | 208553 | Rtree *pRtree, |
| 207276 | 208554 | RtreeCell *p, |
| 207277 | 208555 | RtreeCell *aCell, |
| 207278 | 208556 | int nCell |
| @@ -207315,42 +208593,56 @@ | ||
| 207315 | 208593 | rc = nodeAcquire(pRtree, 1, 0, &pNode); |
| 207316 | 208594 | |
| 207317 | 208595 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 207318 | 208596 | int iCell; |
| 207319 | 208597 | sqlite3_int64 iBest = 0; |
| 207320 | - | |
| 208598 | + int bFound = 0; | |
| 207321 | 208599 | RtreeDValue fMinGrowth = RTREE_ZERO; |
| 207322 | 208600 | RtreeDValue fMinArea = RTREE_ZERO; |
| 207323 | - | |
| 207324 | 208601 | int nCell = NCELL(pNode); |
| 207325 | - RtreeCell cell; | |
| 207326 | 208602 | RtreeNode *pChild = 0; |
| 207327 | 208603 | |
| 207328 | - RtreeCell *aCell = 0; | |
| 207329 | - | |
| 207330 | - /* Select the child node which will be enlarged the least if pCell | |
| 207331 | - ** is inserted into it. Resolve ties by choosing the entry with | |
| 207332 | - ** the smallest area. | |
| 208604 | + /* First check to see if there is are any cells in pNode that completely | |
| 208605 | + ** contains pCell. If two or more cells in pNode completely contain pCell | |
| 208606 | + ** then pick the smallest. | |
| 207333 | 208607 | */ |
| 207334 | 208608 | for(iCell=0; iCell<nCell; iCell++){ |
| 207335 | - int bBest = 0; | |
| 207336 | - RtreeDValue growth; | |
| 207337 | - RtreeDValue area; | |
| 208609 | + RtreeCell cell; | |
| 207338 | 208610 | nodeGetCell(pRtree, pNode, iCell, &cell); |
| 207339 | - growth = cellGrowth(pRtree, &cell, pCell); | |
| 207340 | - area = cellArea(pRtree, &cell); | |
| 207341 | - if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){ | |
| 207342 | - bBest = 1; | |
| 207343 | - } | |
| 207344 | - if( bBest ){ | |
| 207345 | - fMinGrowth = growth; | |
| 207346 | - fMinArea = area; | |
| 207347 | - iBest = cell.iRowid; | |
| 208611 | + if( cellContains(pRtree, &cell, pCell) ){ | |
| 208612 | + RtreeDValue area = cellArea(pRtree, &cell); | |
| 208613 | + if( bFound==0 || area<fMinArea ){ | |
| 208614 | + iBest = cell.iRowid; | |
| 208615 | + fMinArea = area; | |
| 208616 | + bFound = 1; | |
| 208617 | + } | |
| 208618 | + } | |
| 208619 | + } | |
| 208620 | + if( !bFound ){ | |
| 208621 | + /* No cells of pNode will completely contain pCell. So pick the | |
| 208622 | + ** cell of pNode that grows by the least amount when pCell is added. | |
| 208623 | + ** Break ties by selecting the smaller cell. | |
| 208624 | + */ | |
| 208625 | + for(iCell=0; iCell<nCell; iCell++){ | |
| 208626 | + RtreeCell cell; | |
| 208627 | + RtreeDValue growth; | |
| 208628 | + RtreeDValue area; | |
| 208629 | + nodeGetCell(pRtree, pNode, iCell, &cell); | |
| 208630 | + area = cellArea(pRtree, &cell); | |
| 208631 | + cellUnion(pRtree, &cell, pCell); | |
| 208632 | + growth = cellArea(pRtree, &cell)-area; | |
| 208633 | + if( iCell==0 | |
| 208634 | + || growth<fMinGrowth | |
| 208635 | + || (growth==fMinGrowth && area<fMinArea) | |
| 208636 | + ){ | |
| 208637 | + fMinGrowth = growth; | |
| 208638 | + fMinArea = area; | |
| 208639 | + iBest = cell.iRowid; | |
| 208640 | + } | |
| 207348 | 208641 | } |
| 207349 | 208642 | } |
| 207350 | 208643 | |
| 207351 | - sqlite3_free(aCell); | |
| 207352 | 208644 | rc = nodeAcquire(pRtree, iBest, pNode, &pChild); |
| 207353 | 208645 | nodeRelease(pRtree, pNode); |
| 207354 | 208646 | pNode = pChild; |
| 207355 | 208647 | } |
| 207356 | 208648 | |
| @@ -207419,81 +208711,10 @@ | ||
| 207419 | 208711 | } |
| 207420 | 208712 | |
| 207421 | 208713 | static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); |
| 207422 | 208714 | |
| 207423 | 208715 | |
| 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 | 208716 | |
| 207496 | 208717 | /* |
| 207497 | 208718 | ** Arguments aIdx, aCell and aSpare all point to arrays of size |
| 207498 | 208719 | ** nIdx. The aIdx array contains the set of integers from 0 to |
| 207499 | 208720 | ** (nIdx-1) in no particular order. This function sorts the values |
| @@ -207974,111 +209195,10 @@ | ||
| 207974 | 209195 | } |
| 207975 | 209196 | |
| 207976 | 209197 | return rc; |
| 207977 | 209198 | } |
| 207978 | 209199 | |
| 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 | 209200 | /* |
| 208081 | 209201 | ** Insert cell pCell into node pNode. Node pNode is the head of a |
| 208082 | 209202 | ** subtree iHeight high (leaf nodes have iHeight==0). |
| 208083 | 209203 | */ |
| 208084 | 209204 | static int rtreeInsertCell( |
| @@ -208095,16 +209215,11 @@ | ||
| 208095 | 209215 | nodeReference(pNode); |
| 208096 | 209216 | pChild->pParent = pNode; |
| 208097 | 209217 | } |
| 208098 | 209218 | } |
| 208099 | 209219 | if( nodeInsertCell(pRtree, pNode, pCell) ){ |
| 208100 | - if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){ | |
| 208101 | - rc = SplitNode(pRtree, pNode, pCell, iHeight); | |
| 208102 | - }else{ | |
| 208103 | - pRtree->iReinsertHeight = iHeight; | |
| 208104 | - rc = Reinsert(pRtree, pNode, pCell, iHeight); | |
| 208105 | - } | |
| 209220 | + rc = SplitNode(pRtree, pNode, pCell, iHeight); | |
| 208106 | 209221 | }else{ |
| 208107 | 209222 | rc = AdjustTree(pRtree, pNode, pCell); |
| 208108 | 209223 | if( ALWAYS(rc==SQLITE_OK) ){ |
| 208109 | 209224 | if( iHeight==0 ){ |
| 208110 | 209225 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); |
| @@ -208443,11 +209558,10 @@ | ||
| 208443 | 209558 | if( rc==SQLITE_OK ){ |
| 208444 | 209559 | rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); |
| 208445 | 209560 | } |
| 208446 | 209561 | if( rc==SQLITE_OK ){ |
| 208447 | 209562 | int rc2; |
| 208448 | - pRtree->iReinsertHeight = -1; | |
| 208449 | 209563 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 208450 | 209564 | rc2 = nodeRelease(pRtree, pLeaf); |
| 208451 | 209565 | if( rc==SQLITE_OK ){ |
| 208452 | 209566 | rc = rc2; |
| 208453 | 209567 | } |
| @@ -208584,12 +209698,15 @@ | ||
| 208584 | 209698 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 208585 | 209699 | } |
| 208586 | 209700 | return 0; |
| 208587 | 209701 | } |
| 208588 | 209702 | |
| 209703 | +/* Forward declaration */ | |
| 209704 | +static int rtreeIntegrity(sqlite3_vtab*, char**); | |
| 209705 | + | |
| 208589 | 209706 | static sqlite3_module rtreeModule = { |
| 208590 | - 3, /* iVersion */ | |
| 209707 | + 4, /* iVersion */ | |
| 208591 | 209708 | rtreeCreate, /* xCreate - create a table */ |
| 208592 | 209709 | rtreeConnect, /* xConnect - connect to an existing table */ |
| 208593 | 209710 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ |
| 208594 | 209711 | rtreeDisconnect, /* xDisconnect - Disconnect from a table */ |
| 208595 | 209712 | rtreeDestroy, /* xDestroy - Drop a table */ |
| @@ -208608,11 +209725,12 @@ | ||
| 208608 | 209725 | 0, /* xFindFunction - function overloading */ |
| 208609 | 209726 | rtreeRename, /* xRename - rename the table */ |
| 208610 | 209727 | rtreeSavepoint, /* xSavepoint */ |
| 208611 | 209728 | 0, /* xRelease */ |
| 208612 | 209729 | 0, /* xRollbackTo */ |
| 208613 | - rtreeShadowName /* xShadowName */ | |
| 209730 | + rtreeShadowName, /* xShadowName */ | |
| 209731 | + rtreeIntegrity /* xIntegrity */ | |
| 208614 | 209732 | }; |
| 208615 | 209733 | |
| 208616 | 209734 | static int rtreeSqlInit( |
| 208617 | 209735 | Rtree *pRtree, |
| 208618 | 209736 | sqlite3 *db, |
| @@ -208864,26 +209982,31 @@ | ||
| 208864 | 209982 | *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]); |
| 208865 | 209983 | return SQLITE_ERROR; |
| 208866 | 209984 | } |
| 208867 | 209985 | |
| 208868 | 209986 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 209987 | + sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); | |
| 209988 | + | |
| 208869 | 209989 | |
| 208870 | 209990 | /* Allocate the sqlite3_vtab structure */ |
| 208871 | 209991 | nDb = (int)strlen(argv[1]); |
| 208872 | 209992 | nName = (int)strlen(argv[2]); |
| 208873 | - pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); | |
| 209993 | + pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); | |
| 208874 | 209994 | if( !pRtree ){ |
| 208875 | 209995 | return SQLITE_NOMEM; |
| 208876 | 209996 | } |
| 208877 | - memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); | |
| 209997 | + memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); | |
| 208878 | 209998 | pRtree->nBusy = 1; |
| 208879 | 209999 | pRtree->base.pModule = &rtreeModule; |
| 208880 | 210000 | pRtree->zDb = (char *)&pRtree[1]; |
| 208881 | 210001 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 210002 | + pRtree->zNodeName = &pRtree->zName[nName+1]; | |
| 208882 | 210003 | pRtree->eCoordType = (u8)eCoordType; |
| 208883 | 210004 | memcpy(pRtree->zDb, argv[1], nDb); |
| 208884 | 210005 | memcpy(pRtree->zName, argv[2], nName); |
| 210006 | + memcpy(pRtree->zNodeName, argv[2], nName); | |
| 210007 | + memcpy(&pRtree->zNodeName[nName], "_node", 6); | |
| 208885 | 210008 | |
| 208886 | 210009 | |
| 208887 | 210010 | /* Create/Connect to the underlying relational database schema. If |
| 208888 | 210011 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 208889 | 210012 | ** the r-tree table schema. |
| @@ -209376,27 +210499,18 @@ | ||
| 209376 | 210499 | const char *zTab, /* Name of rtree table to check */ |
| 209377 | 210500 | char **pzReport /* OUT: sqlite3_malloc'd report text */ |
| 209378 | 210501 | ){ |
| 209379 | 210502 | RtreeCheck check; /* Common context for various routines */ |
| 209380 | 210503 | sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ |
| 209381 | - int bEnd = 0; /* True if transaction should be closed */ | |
| 209382 | 210504 | int nAux = 0; /* Number of extra columns. */ |
| 209383 | 210505 | |
| 209384 | 210506 | /* Initialize the context object */ |
| 209385 | 210507 | memset(&check, 0, sizeof(check)); |
| 209386 | 210508 | check.db = db; |
| 209387 | 210509 | check.zDb = zDb; |
| 209388 | 210510 | check.zTab = zTab; |
| 209389 | 210511 | |
| 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 | 210512 | /* Find the number of auxiliary columns */ |
| 209399 | 210513 | if( check.rc==SQLITE_OK ){ |
| 209400 | 210514 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); |
| 209401 | 210515 | if( pStmt ){ |
| 209402 | 210516 | nAux = sqlite3_column_count(pStmt) - 2; |
| @@ -209433,18 +210547,27 @@ | ||
| 209433 | 210547 | /* Finalize SQL statements used by the integrity-check */ |
| 209434 | 210548 | sqlite3_finalize(check.pGetNode); |
| 209435 | 210549 | sqlite3_finalize(check.aCheckMapping[0]); |
| 209436 | 210550 | sqlite3_finalize(check.aCheckMapping[1]); |
| 209437 | 210551 | |
| 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 | 210552 | *pzReport = check.zReport; |
| 209444 | 210553 | return check.rc; |
| 209445 | 210554 | } |
| 210555 | + | |
| 210556 | +/* | |
| 210557 | +** Implementation of the xIntegrity method for Rtree. | |
| 210558 | +*/ | |
| 210559 | +static int rtreeIntegrity(sqlite3_vtab *pVtab, char **pzErr){ | |
| 210560 | + Rtree *pRtree = (Rtree*)pVtab; | |
| 210561 | + int rc; | |
| 210562 | + rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr); | |
| 210563 | + if( rc==SQLITE_OK && *pzErr ){ | |
| 210564 | + *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z", | |
| 210565 | + pRtree->zDb, pRtree->zName, *pzErr); | |
| 210566 | + } | |
| 210567 | + return rc; | |
| 210568 | +} | |
| 209446 | 210569 | |
| 209447 | 210570 | /* |
| 209448 | 210571 | ** Usage: |
| 209449 | 210572 | ** |
| 209450 | 210573 | ** rtreecheck(<rtree-table>); |
| @@ -210763,28 +211886,32 @@ | ||
| 210763 | 211886 | char *zSql; |
| 210764 | 211887 | int ii; |
| 210765 | 211888 | (void)pAux; |
| 210766 | 211889 | |
| 210767 | 211890 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 211891 | + sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); | |
| 210768 | 211892 | |
| 210769 | 211893 | /* Allocate the sqlite3_vtab structure */ |
| 210770 | 211894 | nDb = strlen(argv[1]); |
| 210771 | 211895 | nName = strlen(argv[2]); |
| 210772 | - pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); | |
| 211896 | + pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); | |
| 210773 | 211897 | if( !pRtree ){ |
| 210774 | 211898 | return SQLITE_NOMEM; |
| 210775 | 211899 | } |
| 210776 | - memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); | |
| 211900 | + memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); | |
| 210777 | 211901 | pRtree->nBusy = 1; |
| 210778 | 211902 | pRtree->base.pModule = &rtreeModule; |
| 210779 | 211903 | pRtree->zDb = (char *)&pRtree[1]; |
| 210780 | 211904 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 211905 | + pRtree->zNodeName = &pRtree->zName[nName+1]; | |
| 210781 | 211906 | pRtree->eCoordType = RTREE_COORD_REAL32; |
| 210782 | 211907 | pRtree->nDim = 2; |
| 210783 | 211908 | pRtree->nDim2 = 4; |
| 210784 | 211909 | memcpy(pRtree->zDb, argv[1], nDb); |
| 210785 | 211910 | memcpy(pRtree->zName, argv[2], nName); |
| 211911 | + memcpy(pRtree->zNodeName, argv[2], nName); | |
| 211912 | + memcpy(&pRtree->zNodeName[nName], "_node", 6); | |
| 210786 | 211913 | |
| 210787 | 211914 | |
| 210788 | 211915 | /* Create/Connect to the underlying relational database schema. If |
| 210789 | 211916 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 210790 | 211917 | ** the r-tree table schema. |
| @@ -211194,11 +212321,10 @@ | ||
| 211194 | 212321 | if( rc==SQLITE_OK ){ |
| 211195 | 212322 | rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); |
| 211196 | 212323 | } |
| 211197 | 212324 | if( rc==SQLITE_OK ){ |
| 211198 | 212325 | int rc2; |
| 211199 | - pRtree->iReinsertHeight = -1; | |
| 211200 | 212326 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 211201 | 212327 | rc2 = nodeRelease(pRtree, pLeaf); |
| 211202 | 212328 | if( rc==SQLITE_OK ){ |
| 211203 | 212329 | rc = rc2; |
| 211204 | 212330 | } |
| @@ -211291,11 +212417,12 @@ | ||
| 211291 | 212417 | geopolyFindFunction, /* xFindFunction - function overloading */ |
| 211292 | 212418 | rtreeRename, /* xRename - rename the table */ |
| 211293 | 212419 | rtreeSavepoint, /* xSavepoint */ |
| 211294 | 212420 | 0, /* xRelease */ |
| 211295 | 212421 | 0, /* xRollbackTo */ |
| 211296 | - rtreeShadowName /* xShadowName */ | |
| 212422 | + rtreeShadowName, /* xShadowName */ | |
| 212423 | + rtreeIntegrity /* xIntegrity */ | |
| 211297 | 212424 | }; |
| 211298 | 212425 | |
| 211299 | 212426 | static int sqlite3_geopoly_init(sqlite3 *db){ |
| 211300 | 212427 | int rc = SQLITE_OK; |
| 211301 | 212428 | static const struct { |
| @@ -219305,11 +220432,12 @@ | ||
| 219305 | 220432 | 0, /* xFindMethod */ |
| 219306 | 220433 | 0, /* xRename */ |
| 219307 | 220434 | 0, /* xSavepoint */ |
| 219308 | 220435 | 0, /* xRelease */ |
| 219309 | 220436 | 0, /* xRollbackTo */ |
| 219310 | - 0 /* xShadowName */ | |
| 220437 | + 0, /* xShadowName */ | |
| 220438 | + 0 /* xIntegrity */ | |
| 219311 | 220439 | }; |
| 219312 | 220440 | return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); |
| 219313 | 220441 | } |
| 219314 | 220442 | #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) |
| 219315 | 220443 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } |
| @@ -219742,11 +220870,12 @@ | ||
| 219742 | 220870 | 0, /* xFindMethod */ |
| 219743 | 220871 | 0, /* xRename */ |
| 219744 | 220872 | 0, /* xSavepoint */ |
| 219745 | 220873 | 0, /* xRelease */ |
| 219746 | 220874 | 0, /* xRollbackTo */ |
| 219747 | - 0 /* xShadowName */ | |
| 220875 | + 0, /* xShadowName */ | |
| 220876 | + 0 /* xIntegrity */ | |
| 219748 | 220877 | }; |
| 219749 | 220878 | return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); |
| 219750 | 220879 | } |
| 219751 | 220880 | #elif defined(SQLITE_ENABLE_DBPAGE_VTAB) |
| 219752 | 220881 | SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; } |
| @@ -219873,22 +221002,36 @@ | ||
| 219873 | 221002 | ** table. |
| 219874 | 221003 | ** |
| 219875 | 221004 | ** The data associated with each hash-table entry is a structure containing |
| 219876 | 221005 | ** a subset of the initial values that the modified row contained at the |
| 219877 | 221006 | ** start of the session. Or no initial values if the row was inserted. |
| 221007 | +** | |
| 221008 | +** pDfltStmt: | |
| 221009 | +** This is only used by the sqlite3changegroup_xxx() APIs, not by | |
| 221010 | +** regular sqlite3_session objects. It is a SELECT statement that | |
| 221011 | +** selects the default value for each table column. For example, | |
| 221012 | +** if the table is | |
| 221013 | +** | |
| 221014 | +** CREATE TABLE xx(a DEFAULT 1, b, c DEFAULT 'abc') | |
| 221015 | +** | |
| 221016 | +** then this variable is the compiled version of: | |
| 221017 | +** | |
| 221018 | +** SELECT 1, NULL, 'abc' | |
| 219878 | 221019 | */ |
| 219879 | 221020 | struct SessionTable { |
| 219880 | 221021 | SessionTable *pNext; |
| 219881 | 221022 | char *zName; /* Local name of table */ |
| 219882 | 221023 | int nCol; /* Number of columns in table zName */ |
| 219883 | 221024 | int bStat1; /* True if this is sqlite_stat1 */ |
| 219884 | 221025 | int bRowid; /* True if this table uses rowid for PK */ |
| 219885 | 221026 | const char **azCol; /* Column names */ |
| 221027 | + const char **azDflt; /* Default value expressions */ | |
| 219886 | 221028 | u8 *abPK; /* Array of primary key flags */ |
| 219887 | 221029 | int nEntry; /* Total number of entries in hash table */ |
| 219888 | 221030 | int nChange; /* Size of apChange[] array */ |
| 219889 | 221031 | SessionChange **apChange; /* Hash table buckets */ |
| 221032 | + sqlite3_stmt *pDfltStmt; | |
| 219890 | 221033 | }; |
| 219891 | 221034 | |
| 219892 | 221035 | /* |
| 219893 | 221036 | ** RECORD FORMAT: |
| 219894 | 221037 | ** |
| @@ -220053,10 +221196,11 @@ | ||
| 220053 | 221196 | ** this structure stored in a SessionTable.aChange[] hash table. |
| 220054 | 221197 | */ |
| 220055 | 221198 | struct SessionChange { |
| 220056 | 221199 | u8 op; /* One of UPDATE, DELETE, INSERT */ |
| 220057 | 221200 | u8 bIndirect; /* True if this change is "indirect" */ |
| 221201 | + u16 nRecordField; /* Number of fields in aRecord[] */ | |
| 220058 | 221202 | int nMaxSize; /* Max size of eventual changeset record */ |
| 220059 | 221203 | int nRecord; /* Number of bytes in buffer aRecord[] */ |
| 220060 | 221204 | u8 *aRecord; /* Buffer containing old.* record */ |
| 220061 | 221205 | SessionChange *pNext; /* For hash-table collisions */ |
| 220062 | 221206 | }; |
| @@ -220078,11 +221222,11 @@ | ||
| 220078 | 221222 | |
| 220079 | 221223 | /* |
| 220080 | 221224 | ** Read a varint value from aBuf[] into *piVal. Return the number of |
| 220081 | 221225 | ** bytes read. |
| 220082 | 221226 | */ |
| 220083 | -static int sessionVarintGet(u8 *aBuf, int *piVal){ | |
| 221227 | +static int sessionVarintGet(const u8 *aBuf, int *piVal){ | |
| 220084 | 221228 | return getVarint32(aBuf, *piVal); |
| 220085 | 221229 | } |
| 220086 | 221230 | |
| 220087 | 221231 | /* Load an unaligned and unsigned 32-bit integer */ |
| 220088 | 221232 | #define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| @@ -220341,11 +221485,11 @@ | ||
| 220341 | 221485 | /* |
| 220342 | 221486 | ** The buffer that the argument points to contains a serialized SQL value. |
| 220343 | 221487 | ** Return the number of bytes of space occupied by the value (including |
| 220344 | 221488 | ** the type byte). |
| 220345 | 221489 | */ |
| 220346 | -static int sessionSerialLen(u8 *a){ | |
| 221490 | +static int sessionSerialLen(const u8 *a){ | |
| 220347 | 221491 | int e = *a; |
| 220348 | 221492 | int n; |
| 220349 | 221493 | if( e==0 || e==0xFF ) return 1; |
| 220350 | 221494 | if( e==SQLITE_NULL ) return 1; |
| 220351 | 221495 | if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; |
| @@ -220748,17 +221892,18 @@ | ||
| 220748 | 221892 | ** NULL) is set to point to an array of booleans - true if the corresponding |
| 220749 | 221893 | ** column is part of the primary key. |
| 220750 | 221894 | ** |
| 220751 | 221895 | ** For example, if the table is declared as: |
| 220752 | 221896 | ** |
| 220753 | -** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z)); | |
| 221897 | +** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z)); | |
| 220754 | 221898 | ** |
| 220755 | -** Then the four output variables are populated as follows: | |
| 221899 | +** Then the five output variables are populated as follows: | |
| 220756 | 221900 | ** |
| 220757 | 221901 | ** *pnCol = 4 |
| 220758 | 221902 | ** *pzTab = "tbl1" |
| 220759 | 221903 | ** *pazCol = {"w", "x", "y", "z"} |
| 221904 | +** *pazDflt = {NULL, 'abc', NULL, NULL} | |
| 220760 | 221905 | ** *pabPK = {1, 0, 0, 1} |
| 220761 | 221906 | ** |
| 220762 | 221907 | ** All returned buffers are part of the same single allocation, which must |
| 220763 | 221908 | ** be freed using sqlite3_free() by the caller |
| 220764 | 221909 | */ |
| @@ -220768,10 +221913,11 @@ | ||
| 220768 | 221913 | const char *zDb, /* Name of attached database (e.g. "main") */ |
| 220769 | 221914 | const char *zThis, /* Table name */ |
| 220770 | 221915 | int *pnCol, /* OUT: number of columns */ |
| 220771 | 221916 | const char **pzTab, /* OUT: Copy of zThis */ |
| 220772 | 221917 | const char ***pazCol, /* OUT: Array of column names for table */ |
| 221918 | + const char ***pazDflt, /* OUT: Array of default value expressions */ | |
| 220773 | 221919 | u8 **pabPK, /* OUT: Array of booleans - true for PK col */ |
| 220774 | 221920 | int *pbRowid /* OUT: True if only PK is a rowid */ |
| 220775 | 221921 | ){ |
| 220776 | 221922 | char *zPragma; |
| 220777 | 221923 | sqlite3_stmt *pStmt; |
| @@ -220780,15 +221926,22 @@ | ||
| 220780 | 221926 | int nDbCol = 0; |
| 220781 | 221927 | int nThis; |
| 220782 | 221928 | int i; |
| 220783 | 221929 | u8 *pAlloc = 0; |
| 220784 | 221930 | char **azCol = 0; |
| 221931 | + char **azDflt = 0; | |
| 220785 | 221932 | u8 *abPK = 0; |
| 220786 | 221933 | int bRowid = 0; /* Set to true to use rowid as PK */ |
| 220787 | 221934 | |
| 220788 | 221935 | assert( pazCol && pabPK ); |
| 220789 | 221936 | |
| 221937 | + *pazCol = 0; | |
| 221938 | + *pabPK = 0; | |
| 221939 | + *pnCol = 0; | |
| 221940 | + if( pzTab ) *pzTab = 0; | |
| 221941 | + if( pazDflt ) *pazDflt = 0; | |
| 221942 | + | |
| 220790 | 221943 | nThis = sqlite3Strlen30(zThis); |
| 220791 | 221944 | if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ |
| 220792 | 221945 | rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); |
| 220793 | 221946 | if( rc==SQLITE_OK ){ |
| 220794 | 221947 | /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ |
| @@ -220798,59 +221951,51 @@ | ||
| 220798 | 221951 | "SELECT 2, 'stat', '', 0, '', 0" |
| 220799 | 221952 | ); |
| 220800 | 221953 | }else if( rc==SQLITE_ERROR ){ |
| 220801 | 221954 | zPragma = sqlite3_mprintf(""); |
| 220802 | 221955 | }else{ |
| 220803 | - *pazCol = 0; | |
| 220804 | - *pabPK = 0; | |
| 220805 | - *pnCol = 0; | |
| 220806 | - if( pzTab ) *pzTab = 0; | |
| 220807 | 221956 | return rc; |
| 220808 | 221957 | } |
| 220809 | 221958 | }else{ |
| 220810 | 221959 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); |
| 220811 | 221960 | } |
| 220812 | 221961 | if( !zPragma ){ |
| 220813 | - *pazCol = 0; | |
| 220814 | - *pabPK = 0; | |
| 220815 | - *pnCol = 0; | |
| 220816 | - if( pzTab ) *pzTab = 0; | |
| 220817 | 221962 | return SQLITE_NOMEM; |
| 220818 | 221963 | } |
| 220819 | 221964 | |
| 220820 | 221965 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); |
| 220821 | 221966 | sqlite3_free(zPragma); |
| 220822 | 221967 | if( rc!=SQLITE_OK ){ |
| 220823 | - *pazCol = 0; | |
| 220824 | - *pabPK = 0; | |
| 220825 | - *pnCol = 0; | |
| 220826 | - if( pzTab ) *pzTab = 0; | |
| 220827 | 221968 | return rc; |
| 220828 | 221969 | } |
| 220829 | 221970 | |
| 220830 | 221971 | nByte = nThis + 1; |
| 220831 | 221972 | bRowid = (pbRowid!=0); |
| 220832 | 221973 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 220833 | - nByte += sqlite3_column_bytes(pStmt, 1); | |
| 221974 | + nByte += sqlite3_column_bytes(pStmt, 1); /* name */ | |
| 221975 | + nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */ | |
| 220834 | 221976 | nDbCol++; |
| 220835 | - if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; | |
| 221977 | + if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */ | |
| 220836 | 221978 | } |
| 220837 | 221979 | if( nDbCol==0 ) bRowid = 0; |
| 220838 | 221980 | nDbCol += bRowid; |
| 220839 | 221981 | nByte += strlen(SESSIONS_ROWID); |
| 220840 | 221982 | rc = sqlite3_reset(pStmt); |
| 220841 | 221983 | |
| 220842 | 221984 | if( rc==SQLITE_OK ){ |
| 220843 | - nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); | |
| 221985 | + nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1); | |
| 220844 | 221986 | pAlloc = sessionMalloc64(pSession, nByte); |
| 220845 | 221987 | if( pAlloc==0 ){ |
| 220846 | 221988 | rc = SQLITE_NOMEM; |
| 221989 | + }else{ | |
| 221990 | + memset(pAlloc, 0, nByte); | |
| 220847 | 221991 | } |
| 220848 | 221992 | } |
| 220849 | 221993 | if( rc==SQLITE_OK ){ |
| 220850 | 221994 | azCol = (char **)pAlloc; |
| 220851 | - pAlloc = (u8 *)&azCol[nDbCol]; | |
| 221995 | + azDflt = (char**)&azCol[nDbCol]; | |
| 221996 | + pAlloc = (u8 *)&azDflt[nDbCol]; | |
| 220852 | 221997 | abPK = (u8 *)pAlloc; |
| 220853 | 221998 | pAlloc = &abPK[nDbCol]; |
| 220854 | 221999 | if( pzTab ){ |
| 220855 | 222000 | memcpy(pAlloc, zThis, nThis+1); |
| 220856 | 222001 | *pzTab = (char *)pAlloc; |
| @@ -220866,15 +222011,25 @@ | ||
| 220866 | 222011 | abPK[i] = 1; |
| 220867 | 222012 | i++; |
| 220868 | 222013 | } |
| 220869 | 222014 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 220870 | 222015 | int nName = sqlite3_column_bytes(pStmt, 1); |
| 222016 | + int nDflt = sqlite3_column_bytes(pStmt, 4); | |
| 220871 | 222017 | const unsigned char *zName = sqlite3_column_text(pStmt, 1); |
| 222018 | + const unsigned char *zDflt = sqlite3_column_text(pStmt, 4); | |
| 222019 | + | |
| 220872 | 222020 | if( zName==0 ) break; |
| 220873 | 222021 | memcpy(pAlloc, zName, nName+1); |
| 220874 | 222022 | azCol[i] = (char *)pAlloc; |
| 220875 | 222023 | pAlloc += nName+1; |
| 222024 | + if( zDflt ){ | |
| 222025 | + memcpy(pAlloc, zDflt, nDflt+1); | |
| 222026 | + azDflt[i] = (char *)pAlloc; | |
| 222027 | + pAlloc += nDflt+1; | |
| 222028 | + }else{ | |
| 222029 | + azDflt[i] = 0; | |
| 222030 | + } | |
| 220876 | 222031 | abPK[i] = sqlite3_column_int(pStmt, 5); |
| 220877 | 222032 | i++; |
| 220878 | 222033 | } |
| 220879 | 222034 | rc = sqlite3_reset(pStmt); |
| 220880 | 222035 | } |
| @@ -220881,46 +222036,49 @@ | ||
| 220881 | 222036 | |
| 220882 | 222037 | /* If successful, populate the output variables. Otherwise, zero them and |
| 220883 | 222038 | ** free any allocation made. An error code will be returned in this case. |
| 220884 | 222039 | */ |
| 220885 | 222040 | if( rc==SQLITE_OK ){ |
| 220886 | - *pazCol = (const char **)azCol; | |
| 222041 | + *pazCol = (const char**)azCol; | |
| 222042 | + if( pazDflt ) *pazDflt = (const char**)azDflt; | |
| 220887 | 222043 | *pabPK = abPK; |
| 220888 | 222044 | *pnCol = nDbCol; |
| 220889 | 222045 | }else{ |
| 220890 | - *pazCol = 0; | |
| 220891 | - *pabPK = 0; | |
| 220892 | - *pnCol = 0; | |
| 220893 | - if( pzTab ) *pzTab = 0; | |
| 220894 | 222046 | sessionFree(pSession, azCol); |
| 220895 | 222047 | } |
| 220896 | 222048 | if( pbRowid ) *pbRowid = bRowid; |
| 220897 | 222049 | sqlite3_finalize(pStmt); |
| 220898 | 222050 | return rc; |
| 220899 | 222051 | } |
| 220900 | 222052 | |
| 220901 | 222053 | /* |
| 220902 | -** This function is only called from within a pre-update handler for a | |
| 220903 | -** write to table pTab, part of session pSession. If this is the first | |
| 220904 | -** write to this table, initalize the SessionTable.nCol, azCol[] and | |
| 220905 | -** abPK[] arrays accordingly. | |
| 222054 | +** This function is called to initialize the SessionTable.nCol, azCol[] | |
| 222055 | +** abPK[] and azDflt[] members of SessionTable object pTab. If these | |
| 222056 | +** fields are already initilialized, this function is a no-op. | |
| 220906 | 222057 | ** |
| 220907 | 222058 | ** If an error occurs, an error code is stored in sqlite3_session.rc and |
| 220908 | 222059 | ** non-zero returned. Or, if no error occurs but the table has no primary |
| 220909 | 222060 | ** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to |
| 220910 | 222061 | ** indicate that updates on this table should be ignored. SessionTable.abPK |
| 220911 | 222062 | ** is set to NULL in this case. |
| 220912 | 222063 | */ |
| 220913 | -static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ | |
| 222064 | +static int sessionInitTable( | |
| 222065 | + sqlite3_session *pSession, /* Optional session handle */ | |
| 222066 | + SessionTable *pTab, /* Table object to initialize */ | |
| 222067 | + sqlite3 *db, /* Database handle to read schema from */ | |
| 222068 | + const char *zDb /* Name of db - "main", "temp" etc. */ | |
| 222069 | +){ | |
| 222070 | + int rc = SQLITE_OK; | |
| 222071 | + | |
| 220914 | 222072 | if( pTab->nCol==0 ){ |
| 220915 | 222073 | u8 *abPK; |
| 220916 | 222074 | assert( pTab->azCol==0 || pTab->abPK==0 ); |
| 220917 | - pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, | |
| 220918 | - pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK, | |
| 220919 | - (pSession->bImplicitPK ? &pTab->bRowid : 0) | |
| 222075 | + rc = sessionTableInfo(pSession, db, zDb, | |
| 222076 | + pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK, | |
| 222077 | + ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0) | |
| 220920 | 222078 | ); |
| 220921 | - if( pSession->rc==SQLITE_OK ){ | |
| 222079 | + if( rc==SQLITE_OK ){ | |
| 220922 | 222080 | int i; |
| 220923 | 222081 | for(i=0; i<pTab->nCol; i++){ |
| 220924 | 222082 | if( abPK[i] ){ |
| 220925 | 222083 | pTab->abPK = abPK; |
| 220926 | 222084 | break; |
| @@ -220928,18 +222086,325 @@ | ||
| 220928 | 222086 | } |
| 220929 | 222087 | if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ |
| 220930 | 222088 | pTab->bStat1 = 1; |
| 220931 | 222089 | } |
| 220932 | 222090 | |
| 220933 | - if( pSession->bEnableSize ){ | |
| 222091 | + if( pSession && pSession->bEnableSize ){ | |
| 220934 | 222092 | pSession->nMaxChangesetSize += ( |
| 220935 | 222093 | 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 |
| 220936 | 222094 | ); |
| 220937 | 222095 | } |
| 220938 | 222096 | } |
| 220939 | 222097 | } |
| 220940 | - return (pSession->rc || pTab->abPK==0); | |
| 222098 | + | |
| 222099 | + if( pSession ){ | |
| 222100 | + pSession->rc = rc; | |
| 222101 | + return (rc || pTab->abPK==0); | |
| 222102 | + } | |
| 222103 | + return rc; | |
| 222104 | +} | |
| 222105 | + | |
| 222106 | +/* | |
| 222107 | +** Re-initialize table object pTab. | |
| 222108 | +*/ | |
| 222109 | +static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){ | |
| 222110 | + int nCol = 0; | |
| 222111 | + const char **azCol = 0; | |
| 222112 | + const char **azDflt = 0; | |
| 222113 | + u8 *abPK = 0; | |
| 222114 | + int bRowid = 0; | |
| 222115 | + | |
| 222116 | + assert( pSession->rc==SQLITE_OK ); | |
| 222117 | + | |
| 222118 | + pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, | |
| 222119 | + pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK, | |
| 222120 | + (pSession->bImplicitPK ? &bRowid : 0) | |
| 222121 | + ); | |
| 222122 | + if( pSession->rc==SQLITE_OK ){ | |
| 222123 | + if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){ | |
| 222124 | + pSession->rc = SQLITE_SCHEMA; | |
| 222125 | + }else{ | |
| 222126 | + int ii; | |
| 222127 | + int nOldCol = pTab->nCol; | |
| 222128 | + for(ii=0; ii<nCol; ii++){ | |
| 222129 | + if( ii<pTab->nCol ){ | |
| 222130 | + if( pTab->abPK[ii]!=abPK[ii] ){ | |
| 222131 | + pSession->rc = SQLITE_SCHEMA; | |
| 222132 | + } | |
| 222133 | + }else if( abPK[ii] ){ | |
| 222134 | + pSession->rc = SQLITE_SCHEMA; | |
| 222135 | + } | |
| 222136 | + } | |
| 222137 | + | |
| 222138 | + if( pSession->rc==SQLITE_OK ){ | |
| 222139 | + const char **a = pTab->azCol; | |
| 222140 | + pTab->azCol = azCol; | |
| 222141 | + pTab->nCol = nCol; | |
| 222142 | + pTab->azDflt = azDflt; | |
| 222143 | + pTab->abPK = abPK; | |
| 222144 | + azCol = a; | |
| 222145 | + } | |
| 222146 | + if( pSession->bEnableSize ){ | |
| 222147 | + pSession->nMaxChangesetSize += (nCol - nOldCol); | |
| 222148 | + pSession->nMaxChangesetSize += sessionVarintLen(nCol); | |
| 222149 | + pSession->nMaxChangesetSize -= sessionVarintLen(nOldCol); | |
| 222150 | + } | |
| 222151 | + } | |
| 222152 | + } | |
| 222153 | + | |
| 222154 | + sqlite3_free(azCol); | |
| 222155 | + return pSession->rc; | |
| 222156 | +} | |
| 222157 | + | |
| 222158 | +/* | |
| 222159 | +** Session-change object (*pp) contains an old.* record with fewer than | |
| 222160 | +** nCol fields. This function updates it with the default values for | |
| 222161 | +** the missing fields. | |
| 222162 | +*/ | |
| 222163 | +static void sessionUpdateOneChange( | |
| 222164 | + sqlite3_session *pSession, /* For memory accounting */ | |
| 222165 | + int *pRc, /* IN/OUT: Error code */ | |
| 222166 | + SessionChange **pp, /* IN/OUT: Change object to update */ | |
| 222167 | + int nCol, /* Number of columns now in table */ | |
| 222168 | + sqlite3_stmt *pDflt /* SELECT <default-values...> */ | |
| 222169 | +){ | |
| 222170 | + SessionChange *pOld = *pp; | |
| 222171 | + | |
| 222172 | + while( pOld->nRecordField<nCol ){ | |
| 222173 | + SessionChange *pNew = 0; | |
| 222174 | + int nByte = 0; | |
| 222175 | + int nIncr = 0; | |
| 222176 | + int iField = pOld->nRecordField; | |
| 222177 | + int eType = sqlite3_column_type(pDflt, iField); | |
| 222178 | + switch( eType ){ | |
| 222179 | + case SQLITE_NULL: | |
| 222180 | + nIncr = 1; | |
| 222181 | + break; | |
| 222182 | + case SQLITE_INTEGER: | |
| 222183 | + case SQLITE_FLOAT: | |
| 222184 | + nIncr = 9; | |
| 222185 | + break; | |
| 222186 | + default: { | |
| 222187 | + int n = sqlite3_column_bytes(pDflt, iField); | |
| 222188 | + nIncr = 1 + sessionVarintLen(n) + n; | |
| 222189 | + assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); | |
| 222190 | + break; | |
| 222191 | + } | |
| 222192 | + } | |
| 222193 | + | |
| 222194 | + nByte = nIncr + (sizeof(SessionChange) + pOld->nRecord); | |
| 222195 | + pNew = sessionMalloc64(pSession, nByte); | |
| 222196 | + if( pNew==0 ){ | |
| 222197 | + *pRc = SQLITE_NOMEM; | |
| 222198 | + return; | |
| 222199 | + }else{ | |
| 222200 | + memcpy(pNew, pOld, sizeof(SessionChange)); | |
| 222201 | + pNew->aRecord = (u8*)&pNew[1]; | |
| 222202 | + memcpy(pNew->aRecord, pOld->aRecord, pOld->nRecord); | |
| 222203 | + pNew->aRecord[pNew->nRecord++] = (u8)eType; | |
| 222204 | + switch( eType ){ | |
| 222205 | + case SQLITE_INTEGER: { | |
| 222206 | + i64 iVal = sqlite3_column_int64(pDflt, iField); | |
| 222207 | + sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); | |
| 222208 | + pNew->nRecord += 8; | |
| 222209 | + break; | |
| 222210 | + } | |
| 222211 | + | |
| 222212 | + case SQLITE_FLOAT: { | |
| 222213 | + double rVal = sqlite3_column_double(pDflt, iField); | |
| 222214 | + i64 iVal = 0; | |
| 222215 | + memcpy(&iVal, &rVal, sizeof(rVal)); | |
| 222216 | + sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); | |
| 222217 | + pNew->nRecord += 8; | |
| 222218 | + break; | |
| 222219 | + } | |
| 222220 | + | |
| 222221 | + case SQLITE_TEXT: { | |
| 222222 | + int n = sqlite3_column_bytes(pDflt, iField); | |
| 222223 | + const char *z = (const char*)sqlite3_column_text(pDflt, iField); | |
| 222224 | + pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); | |
| 222225 | + memcpy(&pNew->aRecord[pNew->nRecord], z, n); | |
| 222226 | + pNew->nRecord += n; | |
| 222227 | + break; | |
| 222228 | + } | |
| 222229 | + | |
| 222230 | + case SQLITE_BLOB: { | |
| 222231 | + int n = sqlite3_column_bytes(pDflt, iField); | |
| 222232 | + const u8 *z = (const u8*)sqlite3_column_blob(pDflt, iField); | |
| 222233 | + pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); | |
| 222234 | + memcpy(&pNew->aRecord[pNew->nRecord], z, n); | |
| 222235 | + pNew->nRecord += n; | |
| 222236 | + break; | |
| 222237 | + } | |
| 222238 | + | |
| 222239 | + default: | |
| 222240 | + assert( eType==SQLITE_NULL ); | |
| 222241 | + break; | |
| 222242 | + } | |
| 222243 | + | |
| 222244 | + sessionFree(pSession, pOld); | |
| 222245 | + *pp = pOld = pNew; | |
| 222246 | + pNew->nRecordField++; | |
| 222247 | + pNew->nMaxSize += nIncr; | |
| 222248 | + if( pSession ){ | |
| 222249 | + pSession->nMaxChangesetSize += nIncr; | |
| 222250 | + } | |
| 222251 | + } | |
| 222252 | + } | |
| 222253 | +} | |
| 222254 | + | |
| 222255 | +/* | |
| 222256 | +** Ensure that there is room in the buffer to append nByte bytes of data. | |
| 222257 | +** If not, use sqlite3_realloc() to grow the buffer so that there is. | |
| 222258 | +** | |
| 222259 | +** If successful, return zero. Otherwise, if an OOM condition is encountered, | |
| 222260 | +** set *pRc to SQLITE_NOMEM and return non-zero. | |
| 222261 | +*/ | |
| 222262 | +static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ | |
| 222263 | +#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) | |
| 222264 | + i64 nReq = p->nBuf + nByte; | |
| 222265 | + if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ | |
| 222266 | + u8 *aNew; | |
| 222267 | + i64 nNew = p->nAlloc ? p->nAlloc : 128; | |
| 222268 | + | |
| 222269 | + do { | |
| 222270 | + nNew = nNew*2; | |
| 222271 | + }while( nNew<nReq ); | |
| 222272 | + | |
| 222273 | + /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation | |
| 222274 | + ** of sqlite3_realloc64(). Allocations greater than this size in bytes | |
| 222275 | + ** always fail. It is used here to ensure that this routine can always | |
| 222276 | + ** allocate up to this limit - instead of up to the largest power of | |
| 222277 | + ** two smaller than the limit. */ | |
| 222278 | + if( nNew>SESSION_MAX_BUFFER_SZ ){ | |
| 222279 | + nNew = SESSION_MAX_BUFFER_SZ; | |
| 222280 | + if( nNew<nReq ){ | |
| 222281 | + *pRc = SQLITE_NOMEM; | |
| 222282 | + return 1; | |
| 222283 | + } | |
| 222284 | + } | |
| 222285 | + | |
| 222286 | + aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); | |
| 222287 | + if( 0==aNew ){ | |
| 222288 | + *pRc = SQLITE_NOMEM; | |
| 222289 | + }else{ | |
| 222290 | + p->aBuf = aNew; | |
| 222291 | + p->nAlloc = nNew; | |
| 222292 | + } | |
| 222293 | + } | |
| 222294 | + return (*pRc!=SQLITE_OK); | |
| 222295 | +} | |
| 222296 | + | |
| 222297 | + | |
| 222298 | +/* | |
| 222299 | +** This function is a no-op if *pRc is other than SQLITE_OK when it is | |
| 222300 | +** called. Otherwise, append a string to the buffer. All bytes in the string | |
| 222301 | +** up to (but not including) the nul-terminator are written to the buffer. | |
| 222302 | +** | |
| 222303 | +** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before | |
| 222304 | +** returning. | |
| 222305 | +*/ | |
| 222306 | +static void sessionAppendStr( | |
| 222307 | + SessionBuffer *p, | |
| 222308 | + const char *zStr, | |
| 222309 | + int *pRc | |
| 222310 | +){ | |
| 222311 | + int nStr = sqlite3Strlen30(zStr); | |
| 222312 | + if( 0==sessionBufferGrow(p, nStr+1, pRc) ){ | |
| 222313 | + memcpy(&p->aBuf[p->nBuf], zStr, nStr); | |
| 222314 | + p->nBuf += nStr; | |
| 222315 | + p->aBuf[p->nBuf] = 0x00; | |
| 222316 | + } | |
| 222317 | +} | |
| 222318 | + | |
| 222319 | +/* | |
| 222320 | +** Format a string using printf() style formatting and then append it to the | |
| 222321 | +** buffer using sessionAppendString(). | |
| 222322 | +*/ | |
| 222323 | +static void sessionAppendPrintf( | |
| 222324 | + SessionBuffer *p, /* Buffer to append to */ | |
| 222325 | + int *pRc, | |
| 222326 | + const char *zFmt, | |
| 222327 | + ... | |
| 222328 | +){ | |
| 222329 | + if( *pRc==SQLITE_OK ){ | |
| 222330 | + char *zApp = 0; | |
| 222331 | + va_list ap; | |
| 222332 | + va_start(ap, zFmt); | |
| 222333 | + zApp = sqlite3_vmprintf(zFmt, ap); | |
| 222334 | + if( zApp==0 ){ | |
| 222335 | + *pRc = SQLITE_NOMEM; | |
| 222336 | + }else{ | |
| 222337 | + sessionAppendStr(p, zApp, pRc); | |
| 222338 | + } | |
| 222339 | + va_end(ap); | |
| 222340 | + sqlite3_free(zApp); | |
| 222341 | + } | |
| 222342 | +} | |
| 222343 | + | |
| 222344 | +/* | |
| 222345 | +** Prepare a statement against database handle db that SELECTs a single | |
| 222346 | +** row containing the default values for each column in table pTab. For | |
| 222347 | +** example, if pTab is declared as: | |
| 222348 | +** | |
| 222349 | +** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd'); | |
| 222350 | +** | |
| 222351 | +** Then this function prepares and returns the SQL statement: | |
| 222352 | +** | |
| 222353 | +** SELECT NULL, 123, 'abcd'; | |
| 222354 | +*/ | |
| 222355 | +static int sessionPrepareDfltStmt( | |
| 222356 | + sqlite3 *db, /* Database handle */ | |
| 222357 | + SessionTable *pTab, /* Table to prepare statement for */ | |
| 222358 | + sqlite3_stmt **ppStmt /* OUT: Statement handle */ | |
| 222359 | +){ | |
| 222360 | + SessionBuffer sql = {0,0,0}; | |
| 222361 | + int rc = SQLITE_OK; | |
| 222362 | + const char *zSep = " "; | |
| 222363 | + int ii = 0; | |
| 222364 | + | |
| 222365 | + *ppStmt = 0; | |
| 222366 | + sessionAppendPrintf(&sql, &rc, "SELECT"); | |
| 222367 | + for(ii=0; ii<pTab->nCol; ii++){ | |
| 222368 | + const char *zDflt = pTab->azDflt[ii] ? pTab->azDflt[ii] : "NULL"; | |
| 222369 | + sessionAppendPrintf(&sql, &rc, "%s%s", zSep, zDflt); | |
| 222370 | + zSep = ", "; | |
| 222371 | + } | |
| 222372 | + if( rc==SQLITE_OK ){ | |
| 222373 | + rc = sqlite3_prepare_v2(db, (const char*)sql.aBuf, -1, ppStmt, 0); | |
| 222374 | + } | |
| 222375 | + sqlite3_free(sql.aBuf); | |
| 222376 | + | |
| 222377 | + return rc; | |
| 222378 | +} | |
| 222379 | + | |
| 222380 | +/* | |
| 222381 | +** Table pTab has one or more existing change-records with old.* records | |
| 222382 | +** with fewer than pTab->nCol columns. This function updates all such | |
| 222383 | +** change-records with the default values for the missing columns. | |
| 222384 | +*/ | |
| 222385 | +static int sessionUpdateChanges(sqlite3_session *pSession, SessionTable *pTab){ | |
| 222386 | + sqlite3_stmt *pStmt = 0; | |
| 222387 | + int rc = pSession->rc; | |
| 222388 | + | |
| 222389 | + rc = sessionPrepareDfltStmt(pSession->db, pTab, &pStmt); | |
| 222390 | + if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ | |
| 222391 | + int ii = 0; | |
| 222392 | + SessionChange **pp = 0; | |
| 222393 | + for(ii=0; ii<pTab->nChange; ii++){ | |
| 222394 | + for(pp=&pTab->apChange[ii]; *pp; pp=&((*pp)->pNext)){ | |
| 222395 | + if( (*pp)->nRecordField!=pTab->nCol ){ | |
| 222396 | + sessionUpdateOneChange(pSession, &rc, pp, pTab->nCol, pStmt); | |
| 222397 | + } | |
| 222398 | + } | |
| 222399 | + } | |
| 222400 | + } | |
| 222401 | + | |
| 222402 | + pSession->rc = rc; | |
| 222403 | + rc = sqlite3_finalize(pStmt); | |
| 222404 | + if( pSession->rc==SQLITE_OK ) pSession->rc = rc; | |
| 222405 | + return pSession->rc; | |
| 220941 | 222406 | } |
| 220942 | 222407 | |
| 220943 | 222408 | /* |
| 220944 | 222409 | ** Versions of the four methods in object SessionHook for use with the |
| 220945 | 222410 | ** sqlite_stat1 table. The purpose of this is to substitute a zero-length |
| @@ -221098,20 +222563,26 @@ | ||
| 221098 | 222563 | SessionTable *pTab /* Table that change applies to */ |
| 221099 | 222564 | ){ |
| 221100 | 222565 | int iHash; |
| 221101 | 222566 | int bNull = 0; |
| 221102 | 222567 | int rc = SQLITE_OK; |
| 222568 | + int nExpect = 0; | |
| 221103 | 222569 | SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; |
| 221104 | 222570 | |
| 221105 | 222571 | if( pSession->rc ) return; |
| 221106 | 222572 | |
| 221107 | 222573 | /* Load table details if required */ |
| 221108 | - if( sessionInitTable(pSession, pTab) ) return; | |
| 222574 | + if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return; | |
| 221109 | 222575 | |
| 221110 | 222576 | /* Check the number of columns in this xPreUpdate call matches the |
| 221111 | 222577 | ** number of columns in the table. */ |
| 221112 | - if( (pTab->nCol-pTab->bRowid)!=pSession->hook.xCount(pSession->hook.pCtx) ){ | |
| 222578 | + nExpect = pSession->hook.xCount(pSession->hook.pCtx); | |
| 222579 | + if( (pTab->nCol-pTab->bRowid)<nExpect ){ | |
| 222580 | + if( sessionReinitTable(pSession, pTab) ) return; | |
| 222581 | + if( sessionUpdateChanges(pSession, pTab) ) return; | |
| 222582 | + } | |
| 222583 | + if( (pTab->nCol-pTab->bRowid)!=nExpect ){ | |
| 221113 | 222584 | pSession->rc = SQLITE_SCHEMA; |
| 221114 | 222585 | return; |
| 221115 | 222586 | } |
| 221116 | 222587 | |
| 221117 | 222588 | /* Grow the hash table if required */ |
| @@ -221184,11 +222655,11 @@ | ||
| 221184 | 222655 | if( pTab->bRowid ){ |
| 221185 | 222656 | nByte += 9; /* Size of rowid field - an integer */ |
| 221186 | 222657 | } |
| 221187 | 222658 | |
| 221188 | 222659 | /* Allocate the change object */ |
| 221189 | - pC = (SessionChange *)sessionMalloc64(pSession, nByte); | |
| 222660 | + pC = (SessionChange*)sessionMalloc64(pSession, nByte); | |
| 221190 | 222661 | if( !pC ){ |
| 221191 | 222662 | rc = SQLITE_NOMEM; |
| 221192 | 222663 | goto error_out; |
| 221193 | 222664 | }else{ |
| 221194 | 222665 | memset(pC, 0, sizeof(SessionChange)); |
| @@ -221217,10 +222688,11 @@ | ||
| 221217 | 222688 | |
| 221218 | 222689 | /* Add the change to the hash-table */ |
| 221219 | 222690 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ |
| 221220 | 222691 | pC->bIndirect = 1; |
| 221221 | 222692 | } |
| 222693 | + pC->nRecordField = pTab->nCol; | |
| 221222 | 222694 | pC->nRecord = nByte; |
| 221223 | 222695 | pC->op = op; |
| 221224 | 222696 | pC->pNext = pTab->apChange[iHash]; |
| 221225 | 222697 | pTab->apChange[iHash] = pC; |
| 221226 | 222698 | |
| @@ -221596,11 +223068,11 @@ | ||
| 221596 | 223068 | SessionTable *pTo; /* Table zTbl */ |
| 221597 | 223069 | |
| 221598 | 223070 | /* Locate and if necessary initialize the target table object */ |
| 221599 | 223071 | rc = sessionFindTable(pSession, zTbl, &pTo); |
| 221600 | 223072 | if( pTo==0 ) goto diff_out; |
| 221601 | - if( sessionInitTable(pSession, pTo) ){ | |
| 223073 | + if( sessionInitTable(pSession, pTo, pSession->db, pSession->zDb) ){ | |
| 221602 | 223074 | rc = pSession->rc; |
| 221603 | 223075 | goto diff_out; |
| 221604 | 223076 | } |
| 221605 | 223077 | |
| 221606 | 223078 | /* Check the table schemas match */ |
| @@ -221609,11 +223081,11 @@ | ||
| 221609 | 223081 | int bMismatch = 0; |
| 221610 | 223082 | int nCol; /* Columns in zFrom.zTbl */ |
| 221611 | 223083 | int bRowid = 0; |
| 221612 | 223084 | u8 *abPK; |
| 221613 | 223085 | const char **azCol = 0; |
| 221614 | - rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK, | |
| 223086 | + rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK, | |
| 221615 | 223087 | pSession->bImplicitPK ? &bRowid : 0 |
| 221616 | 223088 | ); |
| 221617 | 223089 | if( rc==SQLITE_OK ){ |
| 221618 | 223090 | if( pTo->nCol!=nCol ){ |
| 221619 | 223091 | bMismatch = 1; |
| @@ -221724,10 +223196,11 @@ | ||
| 221724 | 223196 | for(p=pTab->apChange[i]; p; p=pNextChange){ |
| 221725 | 223197 | pNextChange = p->pNext; |
| 221726 | 223198 | sessionFree(pSession, p); |
| 221727 | 223199 | } |
| 221728 | 223200 | } |
| 223201 | + sqlite3_finalize(pTab->pDfltStmt); | |
| 221729 | 223202 | sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ |
| 221730 | 223203 | sessionFree(pSession, pTab->apChange); |
| 221731 | 223204 | sessionFree(pSession, pTab); |
| 221732 | 223205 | } |
| 221733 | 223206 | } |
| @@ -221758,11 +223231,11 @@ | ||
| 221758 | 223231 | ** associated hash-tables. */ |
| 221759 | 223232 | sessionDeleteTable(pSession, pSession->pTable); |
| 221760 | 223233 | |
| 221761 | 223234 | /* Assert that all allocations have been freed and then free the |
| 221762 | 223235 | ** session object itself. */ |
| 221763 | - assert( pSession->nMalloc==0 ); | |
| 223236 | + // assert( pSession->nMalloc==0 ); | |
| 221764 | 223237 | sqlite3_free(pSession); |
| 221765 | 223238 | } |
| 221766 | 223239 | |
| 221767 | 223240 | /* |
| 221768 | 223241 | ** Set a table filter on a Session Object. |
| @@ -221829,52 +223302,10 @@ | ||
| 221829 | 223302 | |
| 221830 | 223303 | sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db)); |
| 221831 | 223304 | return rc; |
| 221832 | 223305 | } |
| 221833 | 223306 | |
| 221834 | -/* | |
| 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 | 223307 | /* |
| 221877 | 223308 | ** Append the value passed as the second argument to the buffer passed |
| 221878 | 223309 | ** as the first. |
| 221879 | 223310 | ** |
| 221880 | 223311 | ** This function is a no-op if *pRc is non-zero when it is called. |
| @@ -221939,31 +223370,10 @@ | ||
| 221939 | 223370 | memcpy(&p->aBuf[p->nBuf], aBlob, nBlob); |
| 221940 | 223371 | p->nBuf += nBlob; |
| 221941 | 223372 | } |
| 221942 | 223373 | } |
| 221943 | 223374 | |
| 221944 | -/* | |
| 221945 | -** 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 | 223375 | /* |
| 221966 | 223376 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 221967 | 223377 | ** called. Otherwise, append the string representation of integer iVal |
| 221968 | 223378 | ** to the buffer. No nul-terminator is written. |
| 221969 | 223379 | ** |
| @@ -221978,31 +223388,10 @@ | ||
| 221978 | 223388 | char aBuf[24]; |
| 221979 | 223389 | sqlite3_snprintf(sizeof(aBuf)-1, aBuf, "%d", iVal); |
| 221980 | 223390 | sessionAppendStr(p, aBuf, pRc); |
| 221981 | 223391 | } |
| 221982 | 223392 | |
| 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 | 223393 | /* |
| 222005 | 223394 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 222006 | 223395 | ** called. Otherwise, append the string zStr enclosed in quotes (") and |
| 222007 | 223396 | ** with any embedded quote characters escaped to the buffer. No |
| 222008 | 223397 | ** nul-terminator byte is written. |
| @@ -222489,63 +223878,53 @@ | ||
| 222489 | 223878 | sqlite3_mutex_enter(sqlite3_db_mutex(db)); |
| 222490 | 223879 | |
| 222491 | 223880 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ |
| 222492 | 223881 | if( pTab->nEntry ){ |
| 222493 | 223882 | 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 | 223883 | int i; /* Used to iterate through hash buckets */ |
| 222498 | 223884 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ |
| 222499 | 223885 | int nRewind = buf.nBuf; /* Initial size of write buffer */ |
| 222500 | 223886 | int nNoop; /* Size of buffer after writing tbl header */ |
| 222501 | - int bRowid = 0; | |
| 223887 | + int nOldCol = pTab->nCol; | |
| 222502 | 223888 | |
| 222503 | 223889 | /* Check the table schema is still Ok. */ |
| 222504 | - rc = sessionTableInfo( | |
| 222505 | - 0, db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK, | |
| 222506 | - (pSession->bImplicitPK ? &bRowid : 0) | |
| 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; | |
| 223890 | + rc = sessionReinitTable(pSession, pTab); | |
| 223891 | + if( rc==SQLITE_OK && pTab->nCol!=nOldCol ){ | |
| 223892 | + rc = sessionUpdateChanges(pSession, pTab); | |
| 222514 | 223893 | } |
| 222515 | 223894 | |
| 222516 | 223895 | /* Write a table header */ |
| 222517 | 223896 | sessionAppendTableHdr(&buf, bPatchset, pTab, &rc); |
| 222518 | 223897 | |
| 222519 | 223898 | /* Build and compile a statement to execute: */ |
| 222520 | 223899 | if( rc==SQLITE_OK ){ |
| 222521 | - rc = sessionSelectStmt( | |
| 222522 | - db, 0, pSession->zDb, zName, bRowid, nCol, azCol, abPK, &pSel | |
| 223900 | + rc = sessionSelectStmt(db, 0, pSession->zDb, | |
| 223901 | + zName, pTab->bRowid, pTab->nCol, pTab->azCol, pTab->abPK, &pSel | |
| 222523 | 223902 | ); |
| 222524 | 223903 | } |
| 222525 | 223904 | |
| 222526 | 223905 | nNoop = buf.nBuf; |
| 222527 | 223906 | for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){ |
| 222528 | 223907 | SessionChange *p; /* Used to iterate through changes */ |
| 222529 | 223908 | |
| 222530 | 223909 | for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ |
| 222531 | - rc = sessionSelectBind(pSel, nCol, abPK, p); | |
| 223910 | + rc = sessionSelectBind(pSel, pTab->nCol, pTab->abPK, p); | |
| 222532 | 223911 | if( rc!=SQLITE_OK ) continue; |
| 222533 | 223912 | if( sqlite3_step(pSel)==SQLITE_ROW ){ |
| 222534 | 223913 | if( p->op==SQLITE_INSERT ){ |
| 222535 | 223914 | int iCol; |
| 222536 | 223915 | sessionAppendByte(&buf, SQLITE_INSERT, &rc); |
| 222537 | 223916 | sessionAppendByte(&buf, p->bIndirect, &rc); |
| 222538 | - for(iCol=0; iCol<nCol; iCol++){ | |
| 223917 | + for(iCol=0; iCol<pTab->nCol; iCol++){ | |
| 222539 | 223918 | sessionAppendCol(&buf, pSel, iCol, &rc); |
| 222540 | 223919 | } |
| 222541 | 223920 | }else{ |
| 222542 | - assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */ | |
| 222543 | - rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); | |
| 223921 | + assert( pTab->abPK!=0 ); | |
| 223922 | + rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, pTab->abPK); | |
| 222544 | 223923 | } |
| 222545 | 223924 | }else if( p->op!=SQLITE_INSERT ){ |
| 222546 | - rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK); | |
| 223925 | + rc = sessionAppendDelete(&buf, bPatchset, p, pTab->nCol,pTab->abPK); | |
| 222547 | 223926 | } |
| 222548 | 223927 | if( rc==SQLITE_OK ){ |
| 222549 | 223928 | rc = sqlite3_reset(pSel); |
| 222550 | 223929 | } |
| 222551 | 223930 | |
| @@ -222566,11 +223945,10 @@ | ||
| 222566 | 223945 | |
| 222567 | 223946 | sqlite3_finalize(pSel); |
| 222568 | 223947 | if( buf.nBuf==nNoop ){ |
| 222569 | 223948 | buf.nBuf = nRewind; |
| 222570 | 223949 | } |
| 222571 | - sqlite3_free((char*)azCol); /* cast works around VC++ bug */ | |
| 222572 | 223950 | } |
| 222573 | 223951 | } |
| 222574 | 223952 | |
| 222575 | 223953 | if( rc==SQLITE_OK ){ |
| 222576 | 223954 | if( xOutput==0 ){ |
| @@ -224695,11 +226073,11 @@ | ||
| 224695 | 226073 | int nMinCol = 0; |
| 224696 | 226074 | int i; |
| 224697 | 226075 | |
| 224698 | 226076 | sqlite3changeset_pk(pIter, &abPK, 0); |
| 224699 | 226077 | rc = sessionTableInfo(0, db, "main", zNew, |
| 224700 | - &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK, &sApply.bRowid | |
| 226078 | + &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid | |
| 224701 | 226079 | ); |
| 224702 | 226080 | if( rc!=SQLITE_OK ) break; |
| 224703 | 226081 | for(i=0; i<sApply.nCol; i++){ |
| 224704 | 226082 | if( sApply.abPK[i] ) nMinCol = i+1; |
| 224705 | 226083 | } |
| @@ -224827,15 +226205,28 @@ | ||
| 224827 | 226205 | int flags |
| 224828 | 226206 | ){ |
| 224829 | 226207 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ |
| 224830 | 226208 | int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); |
| 224831 | 226209 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); |
| 226210 | + u64 savedFlag = db->flags & SQLITE_FkNoAction; | |
| 226211 | + | |
| 226212 | + if( flags & SQLITE_CHANGESETAPPLY_FKNOACTION ){ | |
| 226213 | + db->flags |= ((u64)SQLITE_FkNoAction); | |
| 226214 | + db->aDb[0].pSchema->schema_cookie -= 32; | |
| 226215 | + } | |
| 226216 | + | |
| 224832 | 226217 | if( rc==SQLITE_OK ){ |
| 224833 | 226218 | rc = sessionChangesetApply( |
| 224834 | 226219 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags |
| 224835 | 226220 | ); |
| 224836 | 226221 | } |
| 226222 | + | |
| 226223 | + if( (flags & SQLITE_CHANGESETAPPLY_FKNOACTION) && savedFlag==0 ){ | |
| 226224 | + assert( db->flags & SQLITE_FkNoAction ); | |
| 226225 | + db->flags &= ~((u64)SQLITE_FkNoAction); | |
| 226226 | + db->aDb[0].pSchema->schema_cookie -= 32; | |
| 226227 | + } | |
| 224837 | 226228 | return rc; |
| 224838 | 226229 | } |
| 224839 | 226230 | |
| 224840 | 226231 | /* |
| 224841 | 226232 | ** Apply the changeset passed via pChangeset/nChangeset to the main database |
| @@ -224919,10 +226310,13 @@ | ||
| 224919 | 226310 | */ |
| 224920 | 226311 | struct sqlite3_changegroup { |
| 224921 | 226312 | int rc; /* Error code */ |
| 224922 | 226313 | int bPatch; /* True to accumulate patchsets */ |
| 224923 | 226314 | SessionTable *pList; /* List of tables in current patch */ |
| 226315 | + | |
| 226316 | + sqlite3 *db; /* Configured by changegroup_schema() */ | |
| 226317 | + char *zDb; /* Configured by changegroup_schema() */ | |
| 224924 | 226318 | }; |
| 224925 | 226319 | |
| 224926 | 226320 | /* |
| 224927 | 226321 | ** This function is called to merge two changes to the same row together as |
| 224928 | 226322 | ** part of an sqlite3changeset_concat() operation. A new change object is |
| @@ -225103,10 +226497,118 @@ | ||
| 225103 | 226497 | } |
| 225104 | 226498 | |
| 225105 | 226499 | *ppNew = pNew; |
| 225106 | 226500 | return rc; |
| 225107 | 226501 | } |
| 226502 | + | |
| 226503 | +/* | |
| 226504 | +** Check if a changeset entry with nCol columns and the PK array passed | |
| 226505 | +** as the final argument to this function is compatible with SessionTable | |
| 226506 | +** pTab. If so, return 1. Otherwise, if they are incompatible in some way, | |
| 226507 | +** return 0. | |
| 226508 | +*/ | |
| 226509 | +static int sessionChangesetCheckCompat( | |
| 226510 | + SessionTable *pTab, | |
| 226511 | + int nCol, | |
| 226512 | + u8 *abPK | |
| 226513 | +){ | |
| 226514 | + if( pTab->azCol && nCol<pTab->nCol ){ | |
| 226515 | + int ii; | |
| 226516 | + for(ii=0; ii<pTab->nCol; ii++){ | |
| 226517 | + u8 bPK = (ii < nCol) ? abPK[ii] : 0; | |
| 226518 | + if( pTab->abPK[ii]!=bPK ) return 0; | |
| 226519 | + } | |
| 226520 | + return 1; | |
| 226521 | + } | |
| 226522 | + return (pTab->nCol==nCol && 0==memcmp(abPK, pTab->abPK, nCol)); | |
| 226523 | +} | |
| 226524 | + | |
| 226525 | +static int sessionChangesetExtendRecord( | |
| 226526 | + sqlite3_changegroup *pGrp, | |
| 226527 | + SessionTable *pTab, | |
| 226528 | + int nCol, | |
| 226529 | + int op, | |
| 226530 | + const u8 *aRec, | |
| 226531 | + int nRec, | |
| 226532 | + SessionBuffer *pOut | |
| 226533 | +){ | |
| 226534 | + int rc = SQLITE_OK; | |
| 226535 | + int ii = 0; | |
| 226536 | + | |
| 226537 | + assert( pTab->azCol ); | |
| 226538 | + assert( nCol<pTab->nCol ); | |
| 226539 | + | |
| 226540 | + pOut->nBuf = 0; | |
| 226541 | + if( op==SQLITE_INSERT || (op==SQLITE_DELETE && pGrp->bPatch==0) ){ | |
| 226542 | + /* Append the missing default column values to the record. */ | |
| 226543 | + sessionAppendBlob(pOut, aRec, nRec, &rc); | |
| 226544 | + if( rc==SQLITE_OK && pTab->pDfltStmt==0 ){ | |
| 226545 | + rc = sessionPrepareDfltStmt(pGrp->db, pTab, &pTab->pDfltStmt); | |
| 226546 | + } | |
| 226547 | + for(ii=nCol; rc==SQLITE_OK && ii<pTab->nCol; ii++){ | |
| 226548 | + int eType = sqlite3_column_type(pTab->pDfltStmt, ii); | |
| 226549 | + sessionAppendByte(pOut, eType, &rc); | |
| 226550 | + switch( eType ){ | |
| 226551 | + case SQLITE_FLOAT: | |
| 226552 | + case SQLITE_INTEGER: { | |
| 226553 | + i64 iVal; | |
| 226554 | + if( eType==SQLITE_INTEGER ){ | |
| 226555 | + iVal = sqlite3_column_int64(pTab->pDfltStmt, ii); | |
| 226556 | + }else{ | |
| 226557 | + double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii); | |
| 226558 | + memcpy(&iVal, &rVal, sizeof(i64)); | |
| 226559 | + } | |
| 226560 | + if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){ | |
| 226561 | + sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal); | |
| 226562 | + } | |
| 226563 | + break; | |
| 226564 | + } | |
| 226565 | + | |
| 226566 | + case SQLITE_BLOB: | |
| 226567 | + case SQLITE_TEXT: { | |
| 226568 | + int n = sqlite3_column_bytes(pTab->pDfltStmt, ii); | |
| 226569 | + sessionAppendVarint(pOut, n, &rc); | |
| 226570 | + if( eType==SQLITE_TEXT ){ | |
| 226571 | + const u8 *z = (const u8*)sqlite3_column_text(pTab->pDfltStmt, ii); | |
| 226572 | + sessionAppendBlob(pOut, z, n, &rc); | |
| 226573 | + }else{ | |
| 226574 | + const u8 *z = (const u8*)sqlite3_column_blob(pTab->pDfltStmt, ii); | |
| 226575 | + sessionAppendBlob(pOut, z, n, &rc); | |
| 226576 | + } | |
| 226577 | + break; | |
| 226578 | + } | |
| 226579 | + | |
| 226580 | + default: | |
| 226581 | + assert( eType==SQLITE_NULL ); | |
| 226582 | + break; | |
| 226583 | + } | |
| 226584 | + } | |
| 226585 | + }else if( op==SQLITE_UPDATE ){ | |
| 226586 | + /* Append missing "undefined" entries to the old.* record. And, if this | |
| 226587 | + ** is an UPDATE, to the new.* record as well. */ | |
| 226588 | + int iOff = 0; | |
| 226589 | + if( pGrp->bPatch==0 ){ | |
| 226590 | + for(ii=0; ii<nCol; ii++){ | |
| 226591 | + iOff += sessionSerialLen(&aRec[iOff]); | |
| 226592 | + } | |
| 226593 | + sessionAppendBlob(pOut, aRec, iOff, &rc); | |
| 226594 | + for(ii=0; ii<(pTab->nCol-nCol); ii++){ | |
| 226595 | + sessionAppendByte(pOut, 0x00, &rc); | |
| 226596 | + } | |
| 226597 | + } | |
| 226598 | + | |
| 226599 | + sessionAppendBlob(pOut, &aRec[iOff], nRec-iOff, &rc); | |
| 226600 | + for(ii=0; ii<(pTab->nCol-nCol); ii++){ | |
| 226601 | + sessionAppendByte(pOut, 0x00, &rc); | |
| 226602 | + } | |
| 226603 | + }else{ | |
| 226604 | + assert( op==SQLITE_DELETE && pGrp->bPatch ); | |
| 226605 | + sessionAppendBlob(pOut, aRec, nRec, &rc); | |
| 226606 | + } | |
| 226607 | + | |
| 226608 | + return rc; | |
| 226609 | +} | |
| 225108 | 226610 | |
| 225109 | 226611 | /* |
| 225110 | 226612 | ** Add all changes in the changeset traversed by the iterator passed as |
| 225111 | 226613 | ** the first argument to the changegroup hash tables. |
| 225112 | 226614 | */ |
| @@ -225117,10 +226619,11 @@ | ||
| 225117 | 226619 | ){ |
| 225118 | 226620 | u8 *aRec; |
| 225119 | 226621 | int nRec; |
| 225120 | 226622 | int rc = SQLITE_OK; |
| 225121 | 226623 | SessionTable *pTab = 0; |
| 226624 | + SessionBuffer rec = {0, 0, 0}; | |
| 225122 | 226625 | |
| 225123 | 226626 | while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ |
| 225124 | 226627 | const char *zNew; |
| 225125 | 226628 | int nCol; |
| 225126 | 226629 | int op; |
| @@ -225128,10 +226631,13 @@ | ||
| 225128 | 226631 | int bIndirect; |
| 225129 | 226632 | SessionChange *pChange; |
| 225130 | 226633 | SessionChange *pExist = 0; |
| 225131 | 226634 | SessionChange **pp; |
| 225132 | 226635 | |
| 226636 | + /* Ensure that only changesets, or only patchsets, but not a mixture | |
| 226637 | + ** of both, are being combined. It is an error to try to combine a | |
| 226638 | + ** changeset and a patchset. */ | |
| 225133 | 226639 | if( pGrp->pList==0 ){ |
| 225134 | 226640 | pGrp->bPatch = pIter->bPatchset; |
| 225135 | 226641 | }else if( pIter->bPatchset!=pGrp->bPatch ){ |
| 225136 | 226642 | rc = SQLITE_ERROR; |
| 225137 | 226643 | break; |
| @@ -225159,22 +226665,42 @@ | ||
| 225159 | 226665 | pTab->nCol = nCol; |
| 225160 | 226666 | pTab->abPK = (u8*)&pTab[1]; |
| 225161 | 226667 | memcpy(pTab->abPK, abPK, nCol); |
| 225162 | 226668 | pTab->zName = (char*)&pTab->abPK[nCol]; |
| 225163 | 226669 | memcpy(pTab->zName, zNew, nNew+1); |
| 226670 | + | |
| 226671 | + if( pGrp->db ){ | |
| 226672 | + pTab->nCol = 0; | |
| 226673 | + rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); | |
| 226674 | + if( rc ){ | |
| 226675 | + assert( pTab->azCol==0 ); | |
| 226676 | + sqlite3_free(pTab); | |
| 226677 | + break; | |
| 226678 | + } | |
| 226679 | + } | |
| 225164 | 226680 | |
| 225165 | 226681 | /* The new object must be linked on to the end of the list, not |
| 225166 | 226682 | ** simply added to the start of it. This is to ensure that the |
| 225167 | 226683 | ** tables within the output of sqlite3changegroup_output() are in |
| 225168 | 226684 | ** the right order. */ |
| 225169 | 226685 | for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); |
| 225170 | 226686 | *ppTab = pTab; |
| 225171 | - }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){ | |
| 226687 | + } | |
| 226688 | + | |
| 226689 | + if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ | |
| 225172 | 226690 | rc = SQLITE_SCHEMA; |
| 225173 | 226691 | break; |
| 225174 | 226692 | } |
| 225175 | 226693 | } |
| 226694 | + | |
| 226695 | + if( nCol<pTab->nCol ){ | |
| 226696 | + assert( pGrp->db ); | |
| 226697 | + rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec); | |
| 226698 | + if( rc ) break; | |
| 226699 | + aRec = rec.aBuf; | |
| 226700 | + nRec = rec.nBuf; | |
| 226701 | + } | |
| 225176 | 226702 | |
| 225177 | 226703 | if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 225178 | 226704 | rc = SQLITE_NOMEM; |
| 225179 | 226705 | break; |
| 225180 | 226706 | } |
| @@ -225209,10 +226735,11 @@ | ||
| 225209 | 226735 | pTab->apChange[iHash] = pChange; |
| 225210 | 226736 | pTab->nEntry++; |
| 225211 | 226737 | } |
| 225212 | 226738 | } |
| 225213 | 226739 | |
| 226740 | + sqlite3_free(rec.aBuf); | |
| 225214 | 226741 | if( rc==SQLITE_OK ) rc = pIter->rc; |
| 225215 | 226742 | return rc; |
| 225216 | 226743 | } |
| 225217 | 226744 | |
| 225218 | 226745 | /* |
| @@ -225294,10 +226821,35 @@ | ||
| 225294 | 226821 | memset(p, 0, sizeof(sqlite3_changegroup)); |
| 225295 | 226822 | } |
| 225296 | 226823 | *pp = p; |
| 225297 | 226824 | return rc; |
| 225298 | 226825 | } |
| 226826 | + | |
| 226827 | +/* | |
| 226828 | +** Provide a database schema to the changegroup object. | |
| 226829 | +*/ | |
| 226830 | +SQLITE_API int sqlite3changegroup_schema( | |
| 226831 | + sqlite3_changegroup *pGrp, | |
| 226832 | + sqlite3 *db, | |
| 226833 | + const char *zDb | |
| 226834 | +){ | |
| 226835 | + int rc = SQLITE_OK; | |
| 226836 | + | |
| 226837 | + if( pGrp->pList || pGrp->db ){ | |
| 226838 | + /* Cannot add a schema after one or more calls to sqlite3changegroup_add(), | |
| 226839 | + ** or after sqlite3changegroup_schema() has already been called. */ | |
| 226840 | + rc = SQLITE_MISUSE; | |
| 226841 | + }else{ | |
| 226842 | + pGrp->zDb = sqlite3_mprintf("%s", zDb); | |
| 226843 | + if( pGrp->zDb==0 ){ | |
| 226844 | + rc = SQLITE_NOMEM; | |
| 226845 | + }else{ | |
| 226846 | + pGrp->db = db; | |
| 226847 | + } | |
| 226848 | + } | |
| 226849 | + return rc; | |
| 226850 | +} | |
| 225299 | 226851 | |
| 225300 | 226852 | /* |
| 225301 | 226853 | ** Add the changeset currently stored in buffer pData, size nData bytes, |
| 225302 | 226854 | ** to changeset-group p. |
| 225303 | 226855 | */ |
| @@ -225358,10 +226910,11 @@ | ||
| 225358 | 226910 | /* |
| 225359 | 226911 | ** Delete a changegroup object. |
| 225360 | 226912 | */ |
| 225361 | 226913 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ |
| 225362 | 226914 | if( pGrp ){ |
| 226915 | + sqlite3_free(pGrp->zDb); | |
| 225363 | 226916 | sessionDeleteTable(0, pGrp->pList); |
| 225364 | 226917 | sqlite3_free(pGrp); |
| 225365 | 226918 | } |
| 225366 | 226919 | } |
| 225367 | 226920 | |
| @@ -237534,11 +239087,10 @@ | ||
| 237534 | 239087 | if( res==0 ){ |
| 237535 | 239088 | assert_nc( i2>i1 ); |
| 237536 | 239089 | assert_nc( i2!=0 ); |
| 237537 | 239090 | pRes->bTermEq = 1; |
| 237538 | 239091 | if( p1->iRowid==p2->iRowid ){ |
| 237539 | - p1->bDel = p2->bDel; | |
| 237540 | 239092 | return i2; |
| 237541 | 239093 | } |
| 237542 | 239094 | res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; |
| 237543 | 239095 | } |
| 237544 | 239096 | assert( res!=0 ); |
| @@ -237902,11 +239454,11 @@ | ||
| 237902 | 239454 | static Fts5Iter *fts5MultiIterAlloc( |
| 237903 | 239455 | Fts5Index *p, /* FTS5 backend to iterate within */ |
| 237904 | 239456 | int nSeg |
| 237905 | 239457 | ){ |
| 237906 | 239458 | Fts5Iter *pNew; |
| 237907 | - int nSlot; /* Power of two >= nSeg */ | |
| 239459 | + i64 nSlot; /* Power of two >= nSeg */ | |
| 237908 | 239460 | |
| 237909 | 239461 | for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2); |
| 237910 | 239462 | pNew = fts5IdxMalloc(p, |
| 237911 | 239463 | sizeof(Fts5Iter) + /* pNew */ |
| 237912 | 239464 | sizeof(Fts5SegIter) * (nSlot-1) + /* pNew->aSeg[] */ |
| @@ -239678,19 +241230,17 @@ | ||
| 239678 | 241230 | u8 *aPg = pSeg->pLeaf->p; |
| 239679 | 241231 | int nPg = pSeg->pLeaf->nn; |
| 239680 | 241232 | int iPgIdx = pSeg->pLeaf->szLeaf; |
| 239681 | 241233 | |
| 239682 | 241234 | u64 iDelta = 0; |
| 239683 | - u64 iNextDelta = 0; | |
| 239684 | 241235 | int iNextOff = 0; |
| 239685 | 241236 | int iOff = 0; |
| 239686 | 241237 | int nIdx = 0; |
| 239687 | 241238 | u8 *aIdx = 0; |
| 239688 | 241239 | int bLastInDoclist = 0; |
| 239689 | 241240 | int iIdx = 0; |
| 239690 | 241241 | int iStart = 0; |
| 239691 | - int iKeyOff = 0; | |
| 239692 | 241242 | int iDelKeyOff = 0; /* Offset of deleted key, if any */ |
| 239693 | 241243 | |
| 239694 | 241244 | nIdx = nPg-iPgIdx; |
| 239695 | 241245 | aIdx = sqlite3Fts5MallocZero(&p->rc, nIdx+16); |
| 239696 | 241246 | if( p->rc ) return; |
| @@ -239711,14 +241261,25 @@ | ||
| 239711 | 241261 | ** pSeg->iLeafOffset - the rowid or delta rowid value. |
| 239712 | 241262 | ** |
| 239713 | 241263 | ** This block sets the following variables: |
| 239714 | 241264 | ** |
| 239715 | 241265 | ** iStart: |
| 241266 | + ** The offset of the first byte of the rowid or delta-rowid | |
| 241267 | + ** value for the doclist entry being removed. | |
| 241268 | + ** | |
| 239716 | 241269 | ** iDelta: |
| 241270 | + ** The value of the rowid or delta-rowid value for the doclist | |
| 241271 | + ** entry being removed. | |
| 241272 | + ** | |
| 241273 | + ** iNextOff: | |
| 241274 | + ** The offset of the next entry following the position list | |
| 241275 | + ** for the one being removed. If the position list for this | |
| 241276 | + ** entry overflows onto the next leaf page, this value will be | |
| 241277 | + ** greater than pLeaf->szLeaf. | |
| 239717 | 241278 | */ |
| 239718 | 241279 | { |
| 239719 | - int iSOP; | |
| 241280 | + int iSOP; /* Start-Of-Position-list */ | |
| 239720 | 241281 | if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ |
| 239721 | 241282 | iStart = pSeg->iTermLeafOffset; |
| 239722 | 241283 | }else{ |
| 239723 | 241284 | iStart = fts5GetU16(&aPg[0]); |
| 239724 | 241285 | } |
| @@ -239750,51 +241311,79 @@ | ||
| 239750 | 241311 | iNextOff = pSeg->iLeafOffset + pSeg->nPos; |
| 239751 | 241312 | } |
| 239752 | 241313 | } |
| 239753 | 241314 | |
| 239754 | 241315 | iOff = iStart; |
| 239755 | - if( iNextOff>=iPgIdx ){ | |
| 239756 | - int pgno = pSeg->iLeafPgno+1; | |
| 239757 | - fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); | |
| 239758 | - iNextOff = iPgIdx; | |
| 239759 | - }else{ | |
| 239760 | - /* Set bLastInDoclist to true if the entry being removed is the last | |
| 239761 | - ** in its doclist. */ | |
| 239762 | - for(iIdx=0, iKeyOff=0; iIdx<nIdx; /* no-op */){ | |
| 239763 | - u32 iVal = 0; | |
| 239764 | - iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | |
| 239765 | - iKeyOff += iVal; | |
| 239766 | - if( iKeyOff==iNextOff ){ | |
| 239767 | - bLastInDoclist = 1; | |
| 239768 | - } | |
| 239769 | - } | |
| 239770 | - } | |
| 239771 | - | |
| 239772 | - if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist||iNextOff==iPgIdx) ){ | |
| 239773 | - fts5PutU16(&aPg[0], 0); | |
| 239774 | - } | |
| 239775 | - | |
| 239776 | - if( bLastInDoclist==0 ){ | |
| 241316 | + | |
| 241317 | + /* Set variable bLastInDoclist to true if this entry happens to be | |
| 241318 | + ** the last rowid in the doclist for its term. */ | |
| 241319 | + if( pSeg->bDel==0 ){ | |
| 241320 | + if( iNextOff>=iPgIdx ){ | |
| 241321 | + int pgno = pSeg->iLeafPgno+1; | |
| 241322 | + fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); | |
| 241323 | + iNextOff = iPgIdx; | |
| 241324 | + }else{ | |
| 241325 | + /* Loop through the page-footer. If iNextOff (offset of the | |
| 241326 | + ** entry following the one we are removing) is equal to the | |
| 241327 | + ** offset of a key on this page, then the entry is the last | |
| 241328 | + ** in its doclist. */ | |
| 241329 | + int iKeyOff = 0; | |
| 241330 | + for(iIdx=0; iIdx<nIdx; /* no-op */){ | |
| 241331 | + u32 iVal = 0; | |
| 241332 | + iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | |
| 241333 | + iKeyOff += iVal; | |
| 241334 | + if( iKeyOff==iNextOff ){ | |
| 241335 | + bLastInDoclist = 1; | |
| 241336 | + } | |
| 241337 | + } | |
| 241338 | + } | |
| 241339 | + | |
| 241340 | + /* If this is (a) the first rowid on a page and (b) is not followed by | |
| 241341 | + ** another position list on the same page, set the "first-rowid" field | |
| 241342 | + ** of the header to 0. */ | |
| 241343 | + if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist || iNextOff==iPgIdx) ){ | |
| 241344 | + fts5PutU16(&aPg[0], 0); | |
| 241345 | + } | |
| 241346 | + } | |
| 241347 | + | |
| 241348 | + if( pSeg->bDel ){ | |
| 241349 | + iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta); | |
| 241350 | + aPg[iOff++] = 0x01; | |
| 241351 | + }else if( bLastInDoclist==0 ){ | |
| 239777 | 241352 | if( iNextOff!=iPgIdx ){ |
| 241353 | + u64 iNextDelta = 0; | |
| 239778 | 241354 | iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); |
| 239779 | 241355 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); |
| 239780 | 241356 | } |
| 239781 | 241357 | }else if( |
| 239782 | - iStart==pSeg->iTermLeafOffset && pSeg->iLeafPgno==pSeg->iTermLeafPgno | |
| 241358 | + pSeg->iLeafPgno==pSeg->iTermLeafPgno | |
| 241359 | + && iStart==pSeg->iTermLeafOffset | |
| 239783 | 241360 | ){ |
| 239784 | 241361 | /* The entry being removed was the only position list in its |
| 239785 | 241362 | ** doclist. Therefore the term needs to be removed as well. */ |
| 239786 | 241363 | int iKey = 0; |
| 239787 | - for(iIdx=0, iKeyOff=0; iIdx<nIdx; iKey++){ | |
| 241364 | + int iKeyOff = 0; | |
| 241365 | + | |
| 241366 | + /* Set iKeyOff to the offset of the term that will be removed - the | |
| 241367 | + ** last offset in the footer that is not greater than iStart. */ | |
| 241368 | + for(iIdx=0; iIdx<nIdx; iKey++){ | |
| 239788 | 241369 | u32 iVal = 0; |
| 239789 | 241370 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 239790 | 241371 | if( (iKeyOff+iVal)>(u32)iStart ) break; |
| 239791 | 241372 | iKeyOff += iVal; |
| 239792 | 241373 | } |
| 241374 | + assert_nc( iKey>=1 ); | |
| 239793 | 241375 | |
| 241376 | + /* Set iDelKeyOff to the value of the footer entry to remove from | |
| 241377 | + ** the page. */ | |
| 239794 | 241378 | iDelKeyOff = iOff = iKeyOff; |
| 241379 | + | |
| 239795 | 241380 | if( iNextOff!=iPgIdx ){ |
| 241381 | + /* This is the only position-list associated with the term, and there | |
| 241382 | + ** is another term following it on this page. So the subsequent term | |
| 241383 | + ** needs to be moved to replace the term associated with the entry | |
| 241384 | + ** being removed. */ | |
| 239796 | 241385 | int nPrefix = 0; |
| 239797 | 241386 | int nSuffix = 0; |
| 239798 | 241387 | int nPrefix2 = 0; |
| 239799 | 241388 | int nSuffix2 = 0; |
| 239800 | 241389 | |
| @@ -239869,10 +241458,19 @@ | ||
| 239869 | 241458 | } |
| 239870 | 241459 | fts5DataRelease(pTerm); |
| 239871 | 241460 | } |
| 239872 | 241461 | } |
| 239873 | 241462 | |
| 241463 | + /* Assuming no error has occurred, this block does final edits to the | |
| 241464 | + ** leaf page before writing it back to disk. Input variables are: | |
| 241465 | + ** | |
| 241466 | + ** nPg: Total initial size of leaf page. | |
| 241467 | + ** iPgIdx: Initial offset of page footer. | |
| 241468 | + ** | |
| 241469 | + ** iOff: Offset to move data to | |
| 241470 | + ** iNextOff: Offset to move data from | |
| 241471 | + */ | |
| 239874 | 241472 | if( p->rc==SQLITE_OK ){ |
| 239875 | 241473 | const int nMove = nPg - iNextOff; /* Number of bytes to move */ |
| 239876 | 241474 | int nShift = iNextOff - iOff; /* Distance to move them */ |
| 239877 | 241475 | |
| 239878 | 241476 | int iPrevKeyOut = 0; |
| @@ -240069,14 +241667,20 @@ | ||
| 240069 | 241667 | } |
| 240070 | 241668 | if( (pBuf->n + pPgidx->n)>=pgsz ){ |
| 240071 | 241669 | fts5WriteFlushLeaf(p, &writer); |
| 240072 | 241670 | } |
| 240073 | 241671 | }else{ |
| 240074 | - int bDummy; | |
| 240075 | - int nPos; | |
| 240076 | - int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); | |
| 240077 | - nCopy += nPos; | |
| 241672 | + int bDel = 0; | |
| 241673 | + int nPos = 0; | |
| 241674 | + int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDel); | |
| 241675 | + if( bDel && bSecureDelete ){ | |
| 241676 | + fts5BufferAppendVarint(&p->rc, pBuf, nPos*2); | |
| 241677 | + iOff += nCopy; | |
| 241678 | + nCopy = nPos; | |
| 241679 | + }else{ | |
| 241680 | + nCopy += nPos; | |
| 241681 | + } | |
| 240078 | 241682 | if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ |
| 240079 | 241683 | /* The entire poslist will fit on the current leaf. So copy |
| 240080 | 241684 | ** it in one go. */ |
| 240081 | 241685 | fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); |
| 240082 | 241686 | }else{ |
| @@ -240110,11 +241714,10 @@ | ||
| 240110 | 241714 | /* TODO2: Doclist terminator written here. */ |
| 240111 | 241715 | /* pBuf->p[pBuf->n++] = '\0'; */ |
| 240112 | 241716 | assert( pBuf->n<=pBuf->nSpace ); |
| 240113 | 241717 | if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); |
| 240114 | 241718 | } |
| 240115 | - sqlite3Fts5HashClear(pHash); | |
| 240116 | 241719 | fts5WriteFinish(p, &writer, &pgnoLast); |
| 240117 | 241720 | |
| 240118 | 241721 | assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); |
| 240119 | 241722 | if( pgnoLast>0 ){ |
| 240120 | 241723 | /* Update the Fts5Structure. It is written back to the database by the |
| @@ -240143,11 +241746,10 @@ | ||
| 240143 | 241746 | |
| 240144 | 241747 | fts5IndexAutomerge(p, &pStruct, pgnoLast + p->nContentlessDelete); |
| 240145 | 241748 | fts5IndexCrisismerge(p, &pStruct); |
| 240146 | 241749 | fts5StructureWrite(p, pStruct); |
| 240147 | 241750 | fts5StructureRelease(pStruct); |
| 240148 | - p->nContentlessDelete = 0; | |
| 240149 | 241751 | } |
| 240150 | 241752 | |
| 240151 | 241753 | /* |
| 240152 | 241754 | ** Flush any data stored in the in-memory hash tables to the database. |
| 240153 | 241755 | */ |
| @@ -240154,12 +241756,16 @@ | ||
| 240154 | 241756 | static void fts5IndexFlush(Fts5Index *p){ |
| 240155 | 241757 | /* Unless it is empty, flush the hash table to disk */ |
| 240156 | 241758 | if( p->nPendingData || p->nContentlessDelete ){ |
| 240157 | 241759 | assert( p->pHash ); |
| 240158 | 241760 | fts5FlushOneHash(p); |
| 240159 | - p->nPendingData = 0; | |
| 240160 | - p->nPendingRow = 0; | |
| 241761 | + if( p->rc==SQLITE_OK ){ | |
| 241762 | + sqlite3Fts5HashClear(p->pHash); | |
| 241763 | + p->nPendingData = 0; | |
| 241764 | + p->nPendingRow = 0; | |
| 241765 | + p->nContentlessDelete = 0; | |
| 241766 | + } | |
| 240161 | 241767 | } |
| 240162 | 241768 | } |
| 240163 | 241769 | |
| 240164 | 241770 | static Fts5Structure *fts5IndexOptimizeStruct( |
| 240165 | 241771 | Fts5Index *p, |
| @@ -242897,11 +244503,12 @@ | ||
| 242897 | 244503 | 0, /* xFindFunction */ |
| 242898 | 244504 | 0, /* xRename */ |
| 242899 | 244505 | 0, /* xSavepoint */ |
| 242900 | 244506 | 0, /* xRelease */ |
| 242901 | 244507 | 0, /* xRollbackTo */ |
| 242902 | - 0 /* xShadowName */ | |
| 244508 | + 0, /* xShadowName */ | |
| 244509 | + 0 /* xIntegrity */ | |
| 242903 | 244510 | }; |
| 242904 | 244511 | rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); |
| 242905 | 244512 | } |
| 242906 | 244513 | return rc; |
| 242907 | 244514 | #else |
| @@ -243036,10 +244643,12 @@ | ||
| 243036 | 244643 | struct Fts5FullTable { |
| 243037 | 244644 | Fts5Table p; /* Public class members from fts5Int.h */ |
| 243038 | 244645 | Fts5Storage *pStorage; /* Document store */ |
| 243039 | 244646 | Fts5Global *pGlobal; /* Global (connection wide) data */ |
| 243040 | 244647 | Fts5Cursor *pSortCsr; /* Sort data from this cursor */ |
| 244648 | + int iSavepoint; /* Successful xSavepoint()+1 */ | |
| 244649 | + int bInSavepoint; | |
| 243041 | 244650 | #ifdef SQLITE_DEBUG |
| 243042 | 244651 | struct Fts5TransactionState ts; |
| 243043 | 244652 | #endif |
| 243044 | 244653 | }; |
| 243045 | 244654 | |
| @@ -243323,10 +244932,17 @@ | ||
| 243323 | 244932 | pConfig->pzErrmsg = pzErr; |
| 243324 | 244933 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 243325 | 244934 | sqlite3Fts5IndexRollback(pTab->p.pIndex); |
| 243326 | 244935 | pConfig->pzErrmsg = 0; |
| 243327 | 244936 | } |
| 244937 | + | |
| 244938 | + if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ | |
| 244939 | + rc = sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, (int)1); | |
| 244940 | + } | |
| 244941 | + if( rc==SQLITE_OK ){ | |
| 244942 | + rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); | |
| 244943 | + } | |
| 243328 | 244944 | |
| 243329 | 244945 | if( rc!=SQLITE_OK ){ |
| 243330 | 244946 | fts5FreeVtab(pTab); |
| 243331 | 244947 | pTab = 0; |
| 243332 | 244948 | }else if( bCreate ){ |
| @@ -244248,10 +245864,13 @@ | ||
| 244248 | 245864 | }else{ |
| 244249 | 245865 | pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); |
| 244250 | 245866 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); |
| 244251 | 245867 | } |
| 244252 | 245868 | |
| 245869 | + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); | |
| 245870 | + if( rc!=SQLITE_OK ) goto filter_out; | |
| 245871 | + | |
| 244253 | 245872 | if( pTab->pSortCsr ){ |
| 244254 | 245873 | /* If pSortCsr is non-NULL, then this call is being made as part of |
| 244255 | 245874 | ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is |
| 244256 | 245875 | ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will |
| 244257 | 245876 | ** return results to the user for this query. The current cursor |
| @@ -244270,10 +245889,11 @@ | ||
| 244270 | 245889 | } |
| 244271 | 245890 | pCsr->ePlan = FTS5_PLAN_SOURCE; |
| 244272 | 245891 | pCsr->pExpr = pTab->pSortCsr->pExpr; |
| 244273 | 245892 | rc = fts5CursorFirst(pTab, pCsr, bDesc); |
| 244274 | 245893 | }else if( pCsr->pExpr ){ |
| 245894 | + assert( rc==SQLITE_OK ); | |
| 244275 | 245895 | rc = fts5CursorParseRank(pConfig, pCsr, pRank); |
| 244276 | 245896 | if( rc==SQLITE_OK ){ |
| 244277 | 245897 | if( bOrderByRank ){ |
| 244278 | 245898 | pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; |
| 244279 | 245899 | rc = fts5CursorFirstSorted(pTab, pCsr, bDesc); |
| @@ -244441,10 +246061,11 @@ | ||
| 244441 | 246061 | sqlite3_value *pVal /* Value inserted into rank column */ |
| 244442 | 246062 | ){ |
| 244443 | 246063 | Fts5Config *pConfig = pTab->p.pConfig; |
| 244444 | 246064 | int rc = SQLITE_OK; |
| 244445 | 246065 | int bError = 0; |
| 246066 | + int bLoadConfig = 0; | |
| 244446 | 246067 | |
| 244447 | 246068 | if( 0==sqlite3_stricmp("delete-all", zCmd) ){ |
| 244448 | 246069 | if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
| 244449 | 246070 | fts5SetVtabError(pTab, |
| 244450 | 246071 | "'delete-all' may only be used with a " |
| @@ -244452,19 +246073,21 @@ | ||
| 244452 | 246073 | ); |
| 244453 | 246074 | rc = SQLITE_ERROR; |
| 244454 | 246075 | }else{ |
| 244455 | 246076 | rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); |
| 244456 | 246077 | } |
| 246078 | + bLoadConfig = 1; | |
| 244457 | 246079 | }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ |
| 244458 | 246080 | if( pConfig->eContent==FTS5_CONTENT_NONE ){ |
| 244459 | 246081 | fts5SetVtabError(pTab, |
| 244460 | 246082 | "'rebuild' may not be used with a contentless fts5 table" |
| 244461 | 246083 | ); |
| 244462 | 246084 | rc = SQLITE_ERROR; |
| 244463 | 246085 | }else{ |
| 244464 | 246086 | rc = sqlite3Fts5StorageRebuild(pTab->pStorage); |
| 244465 | 246087 | } |
| 246088 | + bLoadConfig = 1; | |
| 244466 | 246089 | }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ |
| 244467 | 246090 | rc = sqlite3Fts5StorageOptimize(pTab->pStorage); |
| 244468 | 246091 | }else if( 0==sqlite3_stricmp("merge", zCmd) ){ |
| 244469 | 246092 | int nMerge = sqlite3_value_int(pVal); |
| 244470 | 246093 | rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge); |
| @@ -244473,10 +246096,12 @@ | ||
| 244473 | 246096 | rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, iArg); |
| 244474 | 246097 | #ifdef SQLITE_DEBUG |
| 244475 | 246098 | }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ |
| 244476 | 246099 | pConfig->bPrefixIndex = sqlite3_value_int(pVal); |
| 244477 | 246100 | #endif |
| 246101 | + }else if( 0==sqlite3_stricmp("flush", zCmd) ){ | |
| 246102 | + rc = sqlite3Fts5FlushToDisk(&pTab->p); | |
| 244478 | 246103 | }else{ |
| 244479 | 246104 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 244480 | 246105 | if( rc==SQLITE_OK ){ |
| 244481 | 246106 | rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError); |
| 244482 | 246107 | } |
| @@ -244486,10 +246111,16 @@ | ||
| 244486 | 246111 | }else{ |
| 244487 | 246112 | rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0); |
| 244488 | 246113 | } |
| 244489 | 246114 | } |
| 244490 | 246115 | } |
| 246116 | + | |
| 246117 | + if( rc==SQLITE_OK && bLoadConfig ){ | |
| 246118 | + pTab->p.pConfig->iCookie--; | |
| 246119 | + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); | |
| 246120 | + } | |
| 246121 | + | |
| 244491 | 246122 | return rc; |
| 244492 | 246123 | } |
| 244493 | 246124 | |
| 244494 | 246125 | static int fts5SpecialDelete( |
| 244495 | 246126 | Fts5FullTable *pTab, |
| @@ -244604,11 +246235,11 @@ | ||
| 244604 | 246235 | |
| 244605 | 246236 | assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); |
| 244606 | 246237 | assert( nArg!=1 || eType0==SQLITE_INTEGER ); |
| 244607 | 246238 | |
| 244608 | 246239 | /* Filter out attempts to run UPDATE or DELETE on contentless tables. |
| 244609 | - ** This is not suported. Except - DELETE is supported if the CREATE | |
| 246240 | + ** This is not suported. Except - they are both supported if the CREATE | |
| 244610 | 246241 | ** VIRTUAL TABLE statement contained "contentless_delete=1". */ |
| 244611 | 246242 | if( eType0==SQLITE_INTEGER |
| 244612 | 246243 | && pConfig->eContent==FTS5_CONTENT_NONE |
| 244613 | 246244 | && pConfig->bContentlessDelete==0 |
| 244614 | 246245 | ){ |
| @@ -244633,11 +246264,12 @@ | ||
| 244633 | 246264 | if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ |
| 244634 | 246265 | rc = SQLITE_MISMATCH; |
| 244635 | 246266 | } |
| 244636 | 246267 | |
| 244637 | 246268 | else if( eType0!=SQLITE_INTEGER ){ |
| 244638 | - /* If this is a REPLACE, first remove the current entry (if any) */ | |
| 246269 | + /* An INSERT statement. If the conflict-mode is REPLACE, first remove | |
| 246270 | + ** the current entry (if any). */ | |
| 244639 | 246271 | if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ |
| 244640 | 246272 | i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ |
| 244641 | 246273 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); |
| 244642 | 246274 | bUpdateOrDelete = 1; |
| 244643 | 246275 | } |
| @@ -245507,12 +247139,16 @@ | ||
| 245507 | 247139 | */ |
| 245508 | 247140 | static int fts5RenameMethod( |
| 245509 | 247141 | sqlite3_vtab *pVtab, /* Virtual table handle */ |
| 245510 | 247142 | const char *zName /* New name of table */ |
| 245511 | 247143 | ){ |
| 247144 | + int rc; | |
| 245512 | 247145 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245513 | - return sqlite3Fts5StorageRename(pTab->pStorage, zName); | |
| 247146 | + pTab->bInSavepoint = 1; | |
| 247147 | + rc = sqlite3Fts5StorageRename(pTab->pStorage, zName); | |
| 247148 | + pTab->bInSavepoint = 0; | |
| 247149 | + return rc; | |
| 245514 | 247150 | } |
| 245515 | 247151 | |
| 245516 | 247152 | static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ |
| 245517 | 247153 | fts5TripCursors((Fts5FullTable*)pTab); |
| 245518 | 247154 | return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage); |
| @@ -245522,38 +247158,68 @@ | ||
| 245522 | 247158 | ** The xSavepoint() method. |
| 245523 | 247159 | ** |
| 245524 | 247160 | ** Flush the contents of the pending-terms table to disk. |
| 245525 | 247161 | */ |
| 245526 | 247162 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245527 | - UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ | |
| 245528 | - fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint); | |
| 245529 | - return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); | |
| 247163 | + Fts5FullTable *pTab = (Fts5FullTable*)pVtab; | |
| 247164 | + int rc = SQLITE_OK; | |
| 247165 | + char *zSql = 0; | |
| 247166 | + fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); | |
| 247167 | + | |
| 247168 | + if( pTab->bInSavepoint==0 ){ | |
| 247169 | + zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", | |
| 247170 | + pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName | |
| 247171 | + ); | |
| 247172 | + if( zSql ){ | |
| 247173 | + pTab->bInSavepoint = 1; | |
| 247174 | + rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0); | |
| 247175 | + pTab->bInSavepoint = 0; | |
| 247176 | + sqlite3_free(zSql); | |
| 247177 | + }else{ | |
| 247178 | + rc = SQLITE_NOMEM; | |
| 247179 | + } | |
| 247180 | + if( rc==SQLITE_OK ){ | |
| 247181 | + pTab->iSavepoint = iSavepoint+1; | |
| 247182 | + } | |
| 247183 | + } | |
| 247184 | + | |
| 247185 | + return rc; | |
| 245530 | 247186 | } |
| 245531 | 247187 | |
| 245532 | 247188 | /* |
| 245533 | 247189 | ** The xRelease() method. |
| 245534 | 247190 | ** |
| 245535 | 247191 | ** This is a no-op. |
| 245536 | 247192 | */ |
| 245537 | 247193 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245538 | - UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ | |
| 245539 | - fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint); | |
| 245540 | - return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); | |
| 247194 | + Fts5FullTable *pTab = (Fts5FullTable*)pVtab; | |
| 247195 | + int rc = SQLITE_OK; | |
| 247196 | + fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); | |
| 247197 | + if( (iSavepoint+1)<pTab->iSavepoint ){ | |
| 247198 | + rc = sqlite3Fts5FlushToDisk(&pTab->p); | |
| 247199 | + if( rc==SQLITE_OK ){ | |
| 247200 | + pTab->iSavepoint = iSavepoint; | |
| 247201 | + } | |
| 247202 | + } | |
| 247203 | + return rc; | |
| 245541 | 247204 | } |
| 245542 | 247205 | |
| 245543 | 247206 | /* |
| 245544 | 247207 | ** The xRollbackTo() method. |
| 245545 | 247208 | ** |
| 245546 | 247209 | ** Discard the contents of the pending terms table. |
| 245547 | 247210 | */ |
| 245548 | 247211 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245549 | 247212 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245550 | - UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ | |
| 247213 | + int rc = SQLITE_OK; | |
| 245551 | 247214 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); |
| 245552 | 247215 | fts5TripCursors(pTab); |
| 245553 | 247216 | pTab->p.pConfig->pgsz = 0; |
| 245554 | - return sqlite3Fts5StorageRollback(pTab->pStorage); | |
| 247217 | + if( (iSavepoint+1)<=pTab->iSavepoint ){ | |
| 247218 | + rc = sqlite3Fts5StorageRollback(pTab->pStorage); | |
| 247219 | + } | |
| 247220 | + return rc; | |
| 245555 | 247221 | } |
| 245556 | 247222 | |
| 245557 | 247223 | /* |
| 245558 | 247224 | ** Register a new auxiliary function with global context pGlobal. |
| 245559 | 247225 | */ |
| @@ -245751,11 +247417,11 @@ | ||
| 245751 | 247417 | int nArg, /* Number of args */ |
| 245752 | 247418 | sqlite3_value **apUnused /* Function arguments */ |
| 245753 | 247419 | ){ |
| 245754 | 247420 | assert( nArg==0 ); |
| 245755 | 247421 | UNUSED_PARAM2(nArg, apUnused); |
| 245756 | - sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); | |
| 247422 | + sqlite3_result_text(pCtx, "fts5: 2023-10-21 18:12:07 7f41d7006db4225cf9b3d197d3a76842778669ac079e76361214a8023c9976e6", -1, SQLITE_TRANSIENT); | |
| 245757 | 247423 | } |
| 245758 | 247424 | |
| 245759 | 247425 | /* |
| 245760 | 247426 | ** Return true if zName is the extension on one of the shadow tables used |
| 245761 | 247427 | ** by this module. |
| @@ -245768,14 +247434,38 @@ | ||
| 245768 | 247434 | for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 245769 | 247435 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 245770 | 247436 | } |
| 245771 | 247437 | return 0; |
| 245772 | 247438 | } |
| 247439 | + | |
| 247440 | +/* | |
| 247441 | +** Run an integrity check on the FTS5 data structures. Return a string | |
| 247442 | +** if anything is found amiss. Return a NULL pointer if everything is | |
| 247443 | +** OK. | |
| 247444 | +*/ | |
| 247445 | +static int fts5Integrity(sqlite3_vtab *pVtab, char **pzErr){ | |
| 247446 | + Fts5FullTable *pTab = (Fts5FullTable*)pVtab; | |
| 247447 | + Fts5Config *pConfig = pTab->p.pConfig; | |
| 247448 | + char *zSql; | |
| 247449 | + int rc; | |
| 247450 | + zSql = sqlite3_mprintf( | |
| 247451 | + "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", | |
| 247452 | + pConfig->zDb, pConfig->zName, pConfig->zName); | |
| 247453 | + rc = sqlite3_exec(pConfig->db, zSql, 0, 0, 0); | |
| 247454 | + sqlite3_free(zSql); | |
| 247455 | + if( (rc&0xff)==SQLITE_CORRUPT ){ | |
| 247456 | + *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", | |
| 247457 | + pConfig->zDb, pConfig->zName); | |
| 247458 | + rc = SQLITE_OK; | |
| 247459 | + } | |
| 247460 | + return rc; | |
| 247461 | + | |
| 247462 | +} | |
| 245773 | 247463 | |
| 245774 | 247464 | static int fts5Init(sqlite3 *db){ |
| 245775 | 247465 | static const sqlite3_module fts5Mod = { |
| 245776 | - /* iVersion */ 3, | |
| 247466 | + /* iVersion */ 4, | |
| 245777 | 247467 | /* xCreate */ fts5CreateMethod, |
| 245778 | 247468 | /* xConnect */ fts5ConnectMethod, |
| 245779 | 247469 | /* xBestIndex */ fts5BestIndexMethod, |
| 245780 | 247470 | /* xDisconnect */ fts5DisconnectMethod, |
| 245781 | 247471 | /* xDestroy */ fts5DestroyMethod, |
| @@ -245794,11 +247484,12 @@ | ||
| 245794 | 247484 | /* xFindFunction */ fts5FindFunctionMethod, |
| 245795 | 247485 | /* xRename */ fts5RenameMethod, |
| 245796 | 247486 | /* xSavepoint */ fts5SavepointMethod, |
| 245797 | 247487 | /* xRelease */ fts5ReleaseMethod, |
| 245798 | 247488 | /* xRollbackTo */ fts5RollbackToMethod, |
| 245799 | - /* xShadowName */ fts5ShadowName | |
| 247489 | + /* xShadowName */ fts5ShadowName, | |
| 247490 | + /* xIntegrity */ fts5Integrity | |
| 245800 | 247491 | }; |
| 245801 | 247492 | |
| 245802 | 247493 | int rc; |
| 245803 | 247494 | Fts5Global *pGlobal = 0; |
| 245804 | 247495 | |
| @@ -247071,11 +248762,13 @@ | ||
| 247071 | 248762 | static int sqlite3Fts5StorageSync(Fts5Storage *p){ |
| 247072 | 248763 | int rc = SQLITE_OK; |
| 247073 | 248764 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 247074 | 248765 | if( p->bTotalsValid ){ |
| 247075 | 248766 | rc = fts5StorageSaveTotals(p); |
| 247076 | - p->bTotalsValid = 0; | |
| 248767 | + if( rc==SQLITE_OK ){ | |
| 248768 | + p->bTotalsValid = 0; | |
| 248769 | + } | |
| 247077 | 248770 | } |
| 247078 | 248771 | if( rc==SQLITE_OK ){ |
| 247079 | 248772 | rc = sqlite3Fts5IndexSync(p->pIndex); |
| 247080 | 248773 | } |
| 247081 | 248774 | sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid); |
| @@ -250439,11 +252132,12 @@ | ||
| 250439 | 252132 | /* xFindFunction */ 0, |
| 250440 | 252133 | /* xRename */ 0, |
| 250441 | 252134 | /* xSavepoint */ 0, |
| 250442 | 252135 | /* xRelease */ 0, |
| 250443 | 252136 | /* xRollbackTo */ 0, |
| 250444 | - /* xShadowName */ 0 | |
| 252137 | + /* xShadowName */ 0, | |
| 252138 | + /* xIntegrity */ 0 | |
| 250445 | 252139 | }; |
| 250446 | 252140 | void *p = (void*)pGlobal; |
| 250447 | 252141 | |
| 250448 | 252142 | return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0); |
| 250449 | 252143 | } |
| @@ -250768,10 +252462,11 @@ | ||
| 250768 | 252462 | 0, /* xRename */ |
| 250769 | 252463 | 0, /* xSavepoint */ |
| 250770 | 252464 | 0, /* xRelease */ |
| 250771 | 252465 | 0, /* xRollbackTo */ |
| 250772 | 252466 | 0, /* xShadowName */ |
| 252467 | + 0 /* xIntegrity */ | |
| 250773 | 252468 | }; |
| 250774 | 252469 | |
| 250775 | 252470 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 250776 | 252471 | |
| 250777 | 252472 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){ |
| 250778 | 252473 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 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 |
| 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 |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -16,11 +16,11 @@ | |
| 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | ** |
| 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | ** d3a40c05c49e1a49264912b1a05bc2143ac. |
| 22 | */ |
| 23 | #define SQLITE_CORE 1 |
| 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | #ifndef SQLITE_PRIVATE |
| 26 | # define SQLITE_PRIVATE static |
| @@ -457,13 +457,13 @@ | |
| 457 | ** |
| 458 | ** See also: [sqlite3_libversion()], |
| 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | */ |
| 462 | #define SQLITE_VERSION "3.43.1" |
| 463 | #define SQLITE_VERSION_NUMBER 3043001 |
| 464 | #define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" |
| 465 | |
| 466 | /* |
| 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | ** |
| @@ -5635,10 +5635,11 @@ | |
| 5635 | ** |
| 5636 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 5637 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 5638 | */ |
| 5639 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5640 | |
| 5641 | /* |
| 5642 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5643 | ** KEYWORDS: {function creation routines} |
| 5644 | ** METHOD: sqlite3 |
| @@ -6190,36 +6191,36 @@ | |
| 6190 | /* |
| 6191 | ** CAPI3REF: Function Auxiliary Data |
| 6192 | ** METHOD: sqlite3_context |
| 6193 | ** |
| 6194 | ** These functions may be used by (non-aggregate) SQL functions to |
| 6195 | ** associate metadata with argument values. If the same value is passed to |
| 6196 | ** multiple invocations of the same SQL function during query execution, under |
| 6197 | ** some circumstances the associated metadata may be preserved. An example |
| 6198 | ** of where this might be useful is in a regular-expression matching |
| 6199 | ** function. The compiled version of the regular expression can be stored as |
| 6200 | ** metadata associated with the pattern string. |
| 6201 | ** Then as long as the pattern string remains the same, |
| 6202 | ** the compiled regular expression can be reused on multiple |
| 6203 | ** invocations of the same function. |
| 6204 | ** |
| 6205 | ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata |
| 6206 | ** 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 |
| 6208 | ** function argument. ^If there is no metadata |
| 6209 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 6210 | ** returns a NULL pointer. |
| 6211 | ** |
| 6212 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th |
| 6213 | ** argument of the application-defined function. ^Subsequent |
| 6214 | ** 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 |
| 6216 | ** NULL if the metadata has been discarded. |
| 6217 | ** ^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 |
| 6219 | ** once, when the metadata is discarded. |
| 6220 | ** SQLite is free to discard the metadata at any time, including: <ul> |
| 6221 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 6222 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 6223 | ** SQL statement)^, or |
| 6224 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 6225 | ** parameter)^, or |
| @@ -6231,24 +6232,81 @@ | |
| 6231 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 6232 | ** should be called near the end of the function implementation and the |
| 6233 | ** function implementation should not make any use of P after |
| 6234 | ** sqlite3_set_auxdata() has been called. |
| 6235 | ** |
| 6236 | ** ^(In practice, metadata is preserved between function calls for |
| 6237 | ** function parameters that are compile-time constants, including literal |
| 6238 | ** values and [parameters] and expressions composed from the same.)^ |
| 6239 | ** |
| 6240 | ** The value of the N parameter to these interfaces should be non-negative. |
| 6241 | ** Future enhancements may make use of negative N values to define new |
| 6242 | ** kinds of function caching behavior. |
| 6243 | ** |
| 6244 | ** These routines must be called from the same thread in which |
| 6245 | ** the SQL function is running. |
| 6246 | */ |
| 6247 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 6248 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 6249 | |
| 6250 | |
| 6251 | /* |
| 6252 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 6253 | ** |
| 6254 | ** These are special values for the destructor that is passed in as the |
| @@ -7528,10 +7586,13 @@ | |
| 7528 | int (*xRelease)(sqlite3_vtab *pVTab, int); |
| 7529 | int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
| 7530 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7531 | ** Those below are for version 3 and greater. */ |
| 7532 | int (*xShadowName)(const char*); |
| 7533 | }; |
| 7534 | |
| 7535 | /* |
| 7536 | ** CAPI3REF: Virtual Table Indexing Information |
| 7537 | ** KEYWORDS: sqlite3_index_info |
| @@ -8495,10 +8556,11 @@ | |
| 8495 | */ |
| 8496 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8497 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8498 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8499 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8500 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8501 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8502 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8503 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8504 | #define SQLITE_TESTCTRL_ASSERT 12 |
| @@ -10859,10 +10921,17 @@ | |
| 10859 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 10860 | ** values of D and S. |
| 10861 | ** The size of the database is written into *P even if the |
| 10862 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10863 | ** of the database exists. |
| 10864 | ** |
| 10865 | ** 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 |
| 10867 | ** allocation error occurs. |
| 10868 | ** |
| @@ -10907,18 +10976,28 @@ | |
| 10907 | ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will |
| 10908 | ** invoke sqlite3_free() on the serialization buffer when the database |
| 10909 | ** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then |
| 10910 | ** 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. |
| 10912 | ** |
| 10913 | ** 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 |
| 10915 | ** operation. |
| 10916 | ** |
| 10917 | ** It is not possible to deserialized into the TEMP database. If the |
| 10918 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10919 | ** function returns SQLITE_ERROR. |
| 10920 | ** |
| 10921 | ** 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 |
| 10923 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10924 | ** |
| @@ -11987,10 +12066,22 @@ | |
| 11987 | void *pB, /* Pointer to buffer containing changeset B */ |
| 11988 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| 11989 | void **ppOut /* OUT: Buffer containing output changeset */ |
| 11990 | ); |
| 11991 | |
| 11992 | |
| 11993 | /* |
| 11994 | ** CAPI3REF: Changegroup Handle |
| 11995 | ** |
| 11996 | ** A changegroup is an object used to combine two or more |
| @@ -12034,10 +12125,42 @@ | |
| 12034 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 12035 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 12036 | */ |
| 12037 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 12038 | |
| 12039 | /* |
| 12040 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 12041 | ** METHOD: sqlite3_changegroup |
| 12042 | ** |
| 12043 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| @@ -12102,17 +12225,22 @@ | |
| 12102 | ** </table> |
| 12103 | ** |
| 12104 | ** 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 |
| 12106 | ** 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 |
| 12108 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is |
| 12109 | ** returned. Or, if an out-of-memory condition occurs during processing, this |
| 12110 | ** function returns SQLITE_NOMEM. In all cases, if an error occurs the state |
| 12111 | ** of the final contents of the changegroup is undefined. |
| 12112 | ** |
| 12113 | ** If no error occurs, SQLITE_OK is returned. |
| 12114 | */ |
| 12115 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 12116 | |
| 12117 | /* |
| 12118 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| @@ -12373,14 +12501,21 @@ | |
| 12373 | ** <li>an update change if the modified fields are already set to |
| 12374 | ** their new values in the conflicting row, or |
| 12375 | ** <li>an insert change if all fields of the conflicting row match |
| 12376 | ** the row being inserted. |
| 12377 | ** </ul> |
| 12378 | */ |
| 12379 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12380 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12381 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12382 | |
| 12383 | /* |
| 12384 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| 12385 | ** |
| 12386 | ** Values that may be passed as the second argument to a conflict-handler. |
| @@ -13767,10 +13902,20 @@ | |
| 13767 | # include <cmnintrin.h> |
| 13768 | # endif |
| 13769 | # endif |
| 13770 | #endif |
| 13771 | |
| 13772 | /* |
| 13773 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
| 13774 | ** 0 means mutexes are permanently disable and the library is never |
| 13775 | ** threadsafe. 1 means the library is serialized which is the highest |
| 13776 | ** level of threadsafety. 2 means the library is multithreaded - multiple |
| @@ -14660,20 +14805,37 @@ | |
| 14660 | ** |
| 14661 | ** For best performance, an attempt is made to guess at the byte-order |
| 14662 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 14663 | ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined |
| 14664 | ** at run-time. |
| 14665 | */ |
| 14666 | #ifndef SQLITE_BYTEORDER |
| 14667 | # if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 14668 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 14669 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 14670 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 14671 | # define SQLITE_BYTEORDER 1234 |
| 14672 | # elif defined(sparc) || defined(__ppc__) || \ |
| 14673 | defined(__ARMEB__) || defined(__AARCH64EB__) |
| 14674 | # define SQLITE_BYTEORDER 4321 |
| 14675 | # else |
| 14676 | # define SQLITE_BYTEORDER 0 |
| 14677 | # endif |
| 14678 | #endif |
| 14679 | #if SQLITE_BYTEORDER==4321 |
| @@ -14993,10 +15155,11 @@ | |
| 14993 | typedef struct CollSeq CollSeq; |
| 14994 | typedef struct Column Column; |
| 14995 | typedef struct Cte Cte; |
| 14996 | typedef struct CteUse CteUse; |
| 14997 | typedef struct Db Db; |
| 14998 | typedef struct DbFixer DbFixer; |
| 14999 | typedef struct Schema Schema; |
| 15000 | typedef struct Expr Expr; |
| 15001 | typedef struct ExprList ExprList; |
| 15002 | typedef struct FKey FKey; |
| @@ -16433,23 +16596,24 @@ | |
| 16433 | #define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 16434 | #define OP_VBegin 170 |
| 16435 | #define OP_VCreate 171 |
| 16436 | #define OP_VDestroy 172 |
| 16437 | #define OP_VOpen 173 |
| 16438 | #define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */ |
| 16439 | #define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */ |
| 16440 | #define OP_VRename 176 |
| 16441 | #define OP_Pagecount 177 |
| 16442 | #define OP_MaxPgcnt 178 |
| 16443 | #define OP_ClrSubtype 179 /* synopsis: r[P1].subtype = 0 */ |
| 16444 | #define OP_FilterAdd 180 /* synopsis: filter(P1) += key(P3@P4) */ |
| 16445 | #define OP_Trace 181 |
| 16446 | #define OP_CursorHint 182 |
| 16447 | #define OP_ReleaseReg 183 /* synopsis: release r[P1@P2] mask P3 */ |
| 16448 | #define OP_Noop 184 |
| 16449 | #define OP_Explain 185 |
| 16450 | #define OP_Abortable 186 |
| 16451 | |
| 16452 | /* Properties such as "out2" or "jump" that are specified in |
| 16453 | ** comments following the "case" for each opcode in the vdbe.c |
| 16454 | ** are encoded into bitvectors as follows: |
| 16455 | */ |
| @@ -16480,13 +16644,13 @@ | |
| 16480 | /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\ |
| 16481 | /* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\ |
| 16482 | /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 16483 | /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 16484 | /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16485 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0x40,\ |
| 16486 | /* 176 */ 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00,\ |
| 16487 | /* 184 */ 0x00, 0x00, 0x00,} |
| 16488 | |
| 16489 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 16490 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 16491 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 16492 | ** generated this include file strives to group all JUMP opcodes |
| @@ -17391,10 +17555,11 @@ | |
| 17391 | int nSavepoint; /* Number of non-transaction savepoints */ |
| 17392 | int nStatement; /* Number of nested statement-transactions */ |
| 17393 | i64 nDeferredCons; /* Net deferred constraints this transaction. */ |
| 17394 | i64 nDeferredImmCons; /* Net deferred immediate constraints */ |
| 17395 | int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ |
| 17396 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 17397 | /* The following variables are all protected by the STATIC_MAIN |
| 17398 | ** mutex, not by sqlite3.mutex. They are used by code in notify.c. |
| 17399 | ** |
| 17400 | ** When X.pUnlockConnection==Y, that means that X is waiting for Y to |
| @@ -17473,10 +17638,11 @@ | |
| 17473 | #define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ |
| 17474 | /* DELETE, or UPDATE and return */ |
| 17475 | /* the count using a callback. */ |
| 17476 | #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ |
| 17477 | #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ |
| 17478 | |
| 17479 | /* Flags used only if debugging */ |
| 17480 | #ifdef SQLITE_DEBUG |
| 17481 | #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */ |
| 17482 | #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */ |
| @@ -18488,10 +18654,13 @@ | |
| 18488 | struct AggInfo_func { /* For each aggregate function */ |
| 18489 | Expr *pFExpr; /* Expression encoding the function */ |
| 18490 | FuncDef *pFunc; /* The aggregate function implementation */ |
| 18491 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ |
| 18492 | int iDistAddr; /* Address of OP_OpenEphemeral */ |
| 18493 | } *aFunc; |
| 18494 | int nFunc; /* Number of entries in aFunc[] */ |
| 18495 | u32 selId; /* Select to which this AggInfo belongs */ |
| 18496 | #ifdef SQLITE_DEBUG |
| 18497 | Select *pSelect; /* SELECT statement that this AggInfo supports */ |
| @@ -18672,11 +18841,11 @@ | |
| 18672 | #define EP_xIsSelect 0x001000 /* x.pSelect is valid (otherwise x.pList is) */ |
| 18673 | #define EP_Skip 0x002000 /* Operator does not contribute to affinity */ |
| 18674 | #define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
| 18675 | #define EP_Win 0x008000 /* Contains window functions */ |
| 18676 | #define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| 18677 | /* 0x020000 // Available for reuse */ |
| 18678 | #define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ |
| 18679 | #define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ |
| 18680 | #define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| 18681 | #define EP_CanBeNull 0x200000 /* Can be null despite NOT NULL constraint */ |
| 18682 | #define EP_Subquery 0x400000 /* Tree contains a TK_SELECT operator */ |
| @@ -18702,10 +18871,11 @@ | |
| 18702 | #define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P)) |
| 18703 | #define ExprSetProperty(E,P) (E)->flags|=(P) |
| 18704 | #define ExprClearProperty(E,P) (E)->flags&=~(P) |
| 18705 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) |
| 18706 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) |
| 18707 | |
| 18708 | /* Macros used to ensure that the correct members of unions are accessed |
| 18709 | ** in Expr. |
| 18710 | */ |
| 18711 | #define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0) |
| @@ -18819,10 +18989,11 @@ | |
| 18819 | ** Allowed values for Expr.a.eEName |
| 18820 | */ |
| 18821 | #define ENAME_NAME 0 /* The AS clause of a result set */ |
| 18822 | #define ENAME_SPAN 1 /* Complete text of the result set expression */ |
| 18823 | #define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ |
| 18824 | |
| 18825 | /* |
| 18826 | ** An instance of this structure can hold a simple list of identifiers, |
| 18827 | ** such as the list "a,b,c" in the following statements: |
| 18828 | ** |
| @@ -19427,10 +19598,11 @@ | |
| 19427 | int nLabel; /* The *negative* of the number of labels used */ |
| 19428 | int nLabelAlloc; /* Number of slots in aLabel */ |
| 19429 | int *aLabel; /* Space to hold the labels */ |
| 19430 | ExprList *pConstExpr;/* Constant expressions */ |
| 19431 | IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ |
| 19432 | Token constraintName;/* Name of the constraint currently being parsed */ |
| 19433 | yDbMask writeMask; /* Start a write transaction on these databases */ |
| 19434 | yDbMask cookieMask; /* Bitmask of schema verified databases */ |
| 19435 | int regRowid; /* Register holding rowid of CREATE TABLE entry */ |
| 19436 | int regRoot; /* Register holding root page number for new objects */ |
| @@ -19997,10 +20169,20 @@ | |
| 19997 | int iCur; /* Ephemeral table holding the materialization */ |
| 19998 | LogEst nRowEst; /* Estimated number of rows in the table */ |
| 19999 | u8 eM10d; /* The MATERIALIZED flag */ |
| 20000 | }; |
| 20001 | |
| 20002 | |
| 20003 | #ifdef SQLITE_DEBUG |
| 20004 | /* |
| 20005 | ** An instance of the TreeView object is used for printing the content of |
| 20006 | ** data structures on sqlite3DebugPrintf() using a tree-like view. |
| @@ -20402,10 +20584,12 @@ | |
| 20402 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*); |
| 20403 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 20404 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 20405 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 20406 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); |
| 20407 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 20408 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 20409 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 20410 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20411 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| @@ -20638,10 +20822,11 @@ | |
| 20638 | #endif |
| 20639 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20640 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 20641 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 20642 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 20643 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( |
| 20644 | Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); |
| 20645 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); |
| 20646 | SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); |
| 20647 | SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int); |
| @@ -20909,11 +21094,12 @@ | |
| 20909 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| 20910 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 20911 | const struct ExprList_item*, |
| 20912 | const char*, |
| 20913 | const char*, |
| 20914 | const char* |
| 20915 | ); |
| 20916 | SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); |
| 20917 | SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); |
| 20918 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 20919 | SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*); |
| @@ -20966,11 +21152,11 @@ | |
| 20966 | SQLITE_PRIVATE void sqlite3OomClear(sqlite3*); |
| 20967 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 20968 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 20969 | |
| 20970 | SQLITE_PRIVATE char *sqlite3RCStrRef(char*); |
| 20971 | SQLITE_PRIVATE void sqlite3RCStrUnref(char*); |
| 20972 | SQLITE_PRIVATE char *sqlite3RCStrNew(u64); |
| 20973 | SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); |
| 20974 | |
| 20975 | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); |
| 20976 | SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64); |
| @@ -21802,10 +21988,13 @@ | |
| 21802 | "ENABLE_ZIPVFS", |
| 21803 | #endif |
| 21804 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS |
| 21805 | "EXPLAIN_ESTIMATED_ROWS", |
| 21806 | #endif |
| 21807 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 21808 | "EXTRA_IFNULLROW", |
| 21809 | #endif |
| 21810 | #ifdef SQLITE_EXTRA_INIT |
| 21811 | "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT), |
| @@ -22082,10 +22271,13 @@ | |
| 22082 | #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS |
| 22083 | "OMIT_SCHEMA_PRAGMAS", |
| 22084 | #endif |
| 22085 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS |
| 22086 | "OMIT_SCHEMA_VERSION_PRAGMAS", |
| 22087 | #endif |
| 22088 | #ifdef SQLITE_OMIT_SHARED_CACHE |
| 22089 | "OMIT_SHARED_CACHE", |
| 22090 | #endif |
| 22091 | #ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES |
| @@ -25042,27 +25234,43 @@ | |
| 25042 | sqlite3StrAccumInit(&sRes, 0, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]); |
| 25043 | |
| 25044 | computeJD(&x); |
| 25045 | computeYMD_HMS(&x); |
| 25046 | for(i=j=0; zFmt[i]; i++){ |
| 25047 | if( zFmt[i]!='%' ) continue; |
| 25048 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); |
| 25049 | i++; |
| 25050 | j = i + 1; |
| 25051 | switch( zFmt[i] ){ |
| 25052 | case 'd': { |
| 25053 | sqlite3_str_appendf(&sRes, "%02d", x.D); |
| 25054 | break; |
| 25055 | } |
| 25056 | case 'f': { |
| 25057 | double s = x.s; |
| 25058 | if( s>59.999 ) s = 59.999; |
| 25059 | sqlite3_str_appendf(&sRes, "%06.3f", s); |
| 25060 | break; |
| 25061 | } |
| 25062 | case 'H': { |
| 25063 | sqlite3_str_appendf(&sRes, "%02d", x.h); |
| 25064 | break; |
| 25065 | } |
| 25066 | case 'W': /* Fall thru */ |
| 25067 | case 'j': { |
| 25068 | int nDay; /* Number of days since 1st day of year */ |
| @@ -25070,11 +25278,11 @@ | |
| 25070 | y.validJD = 0; |
| 25071 | y.M = 1; |
| 25072 | y.D = 1; |
| 25073 | computeJD(&y); |
| 25074 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); |
| 25075 | if( zFmt[i]=='W' ){ |
| 25076 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ |
| 25077 | wd = (int)(((x.iJD+43200000)/86400000)%7); |
| 25078 | sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); |
| 25079 | }else{ |
| 25080 | sqlite3_str_appendf(&sRes,"%03d",nDay+1); |
| @@ -25090,10 +25298,23 @@ | |
| 25090 | break; |
| 25091 | } |
| 25092 | case 'M': { |
| 25093 | sqlite3_str_appendf(&sRes,"%02d",x.m); |
| 25094 | break; |
| 25095 | } |
| 25096 | case 's': { |
| 25097 | if( x.useSubsec ){ |
| 25098 | sqlite3_str_appendf(&sRes,"%.3f", |
| 25099 | (x.iJD - 21086676*(i64)10000000)/1000.0); |
| @@ -25105,13 +25326,19 @@ | |
| 25105 | } |
| 25106 | case 'S': { |
| 25107 | sqlite3_str_appendf(&sRes,"%02d",(int)x.s); |
| 25108 | break; |
| 25109 | } |
| 25110 | case 'w': { |
| 25111 | sqlite3_str_appendchar(&sRes, 1, |
| 25112 | (char)(((x.iJD+129600000)/86400000) % 7) + '0'); |
| 25113 | break; |
| 25114 | } |
| 25115 | case 'Y': { |
| 25116 | sqlite3_str_appendf(&sRes,"%04d",x.Y); |
| 25117 | break; |
| @@ -28196,11 +28423,11 @@ | |
| 28196 | static void checkMutexFree(sqlite3_mutex *p){ |
| 28197 | assert( SQLITE_MUTEX_RECURSIVE<2 ); |
| 28198 | assert( SQLITE_MUTEX_FAST<2 ); |
| 28199 | assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); |
| 28200 | |
| 28201 | #if SQLITE_ENABLE_API_ARMOR |
| 28202 | if( ((CheckMutex*)p)->iType<2 ) |
| 28203 | #endif |
| 28204 | { |
| 28205 | CheckMutex *pCheck = (CheckMutex*)p; |
| 28206 | pGlobalMutexMethods->xMutexFree(pCheck->mutex); |
| @@ -28868,11 +29095,11 @@ | |
| 28868 | ** allocated mutex. SQLite is careful to deallocate every |
| 28869 | ** mutex that it allocates. |
| 28870 | */ |
| 28871 | static void pthreadMutexFree(sqlite3_mutex *p){ |
| 28872 | assert( p->nRef==0 ); |
| 28873 | #if SQLITE_ENABLE_API_ARMOR |
| 28874 | if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) |
| 28875 | #endif |
| 28876 | { |
| 28877 | pthread_mutex_destroy(&p->mutex); |
| 28878 | sqlite3_free(p); |
| @@ -30432,11 +30659,11 @@ | |
| 30432 | assert( db!=0 ); |
| 30433 | assert( sqlite3_mutex_held(db->mutex) ); |
| 30434 | if( db->mallocFailed || rc ){ |
| 30435 | return apiHandleError(db, rc); |
| 30436 | } |
| 30437 | return rc & db->errMask; |
| 30438 | } |
| 30439 | |
| 30440 | /************** End of malloc.c **********************************************/ |
| 30441 | /************** Begin file printf.c ******************************************/ |
| 30442 | /* |
| @@ -31828,11 +32055,11 @@ | |
| 31828 | |
| 31829 | /* |
| 31830 | ** Decrease the reference count by one. Free the string when the |
| 31831 | ** reference count reaches zero. |
| 31832 | */ |
| 31833 | SQLITE_PRIVATE void sqlite3RCStrUnref(char *z){ |
| 31834 | RCStr *p = (RCStr*)z; |
| 31835 | assert( p!=0 ); |
| 31836 | p--; |
| 31837 | assert( p->nRCRef>0 ); |
| 31838 | if( p->nRCRef>=2 ){ |
| @@ -32291,20 +32518,21 @@ | |
| 32291 | if( pWin==0 ) return; |
| 32292 | if( pWin->pFilter ){ |
| 32293 | sqlite3TreeViewItem(pView, "FILTER", 1); |
| 32294 | sqlite3TreeViewExpr(pView, pWin->pFilter, 0); |
| 32295 | sqlite3TreeViewPop(&pView); |
| 32296 | } |
| 32297 | sqlite3TreeViewPush(&pView, more); |
| 32298 | if( pWin->zName ){ |
| 32299 | sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin); |
| 32300 | }else{ |
| 32301 | sqlite3TreeViewLine(pView, "OVER (%p)", pWin); |
| 32302 | } |
| 32303 | if( pWin->zBase ) nElement++; |
| 32304 | if( pWin->pOrderBy ) nElement++; |
| 32305 | if( pWin->eFrmType ) nElement++; |
| 32306 | if( pWin->eExclude ) nElement++; |
| 32307 | if( pWin->zBase ){ |
| 32308 | sqlite3TreeViewPush(&pView, (--nElement)>0); |
| 32309 | sqlite3TreeViewLine(pView, "window: %s", pWin->zBase); |
| 32310 | sqlite3TreeViewPop(&pView); |
| @@ -32313,11 +32541,11 @@ | |
| 32313 | sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY"); |
| 32314 | } |
| 32315 | if( pWin->pOrderBy ){ |
| 32316 | sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); |
| 32317 | } |
| 32318 | if( pWin->eFrmType ){ |
| 32319 | char zBuf[30]; |
| 32320 | const char *zFrmType = "ROWS"; |
| 32321 | if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; |
| 32322 | if( pWin->eFrmType==TK_GROUPS ) zFrmType = "GROUPS"; |
| 32323 | sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType, |
| @@ -32561,11 +32789,11 @@ | |
| 32561 | pWin = 0; |
| 32562 | }else{ |
| 32563 | assert( ExprUseXList(pExpr) ); |
| 32564 | pFarg = pExpr->x.pList; |
| 32565 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32566 | pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; |
| 32567 | #else |
| 32568 | pWin = 0; |
| 32569 | #endif |
| 32570 | } |
| 32571 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| @@ -32587,18 +32815,28 @@ | |
| 32587 | pExpr->u.zToken, zFlgs, zOp2); |
| 32588 | }else{ |
| 32589 | sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); |
| 32590 | } |
| 32591 | if( pFarg ){ |
| 32592 | sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0); |
| 32593 | } |
| 32594 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32595 | if( pWin ){ |
| 32596 | sqlite3TreeViewWindow(pView, pWin, 0); |
| 32597 | } |
| 32598 | #endif |
| 32599 | break; |
| 32600 | } |
| 32601 | #ifndef SQLITE_OMIT_SUBQUERY |
| 32602 | case TK_EXISTS: { |
| 32603 | assert( ExprUseXSelect(pExpr) ); |
| 32604 | sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags); |
| @@ -34360,16 +34598,20 @@ | |
| 34360 | if( AtomicLoad(&db->u1.isInterrupted) ){ |
| 34361 | p->nErr++; |
| 34362 | p->rc = SQLITE_INTERRUPT; |
| 34363 | } |
| 34364 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 34365 | if( db->xProgress && (++p->nProgressSteps)>=db->nProgressOps ){ |
| 34366 | if( db->xProgress(db->pProgressArg) ){ |
| 34367 | p->nErr++; |
| 34368 | p->rc = SQLITE_INTERRUPT; |
| 34369 | } |
| 34370 | p->nProgressSteps = 0; |
| 34371 | } |
| 34372 | #endif |
| 34373 | } |
| 34374 | |
| 34375 | /* |
| @@ -35183,33 +35425,33 @@ | |
| 35183 | ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); |
| 35184 | */ |
| 35185 | double rr[2]; |
| 35186 | rr[0] = r; |
| 35187 | rr[1] = 0.0; |
| 35188 | if( rr[0]>1.84e+19 ){ |
| 35189 | while( rr[0]>1.84e+119 ){ |
| 35190 | exp += 100; |
| 35191 | dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); |
| 35192 | } |
| 35193 | while( rr[0]>1.84e+29 ){ |
| 35194 | exp += 10; |
| 35195 | dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); |
| 35196 | } |
| 35197 | while( rr[0]>1.84e+19 ){ |
| 35198 | exp += 1; |
| 35199 | dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); |
| 35200 | } |
| 35201 | }else{ |
| 35202 | while( rr[0]<1.84e-82 ){ |
| 35203 | exp -= 100; |
| 35204 | dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); |
| 35205 | } |
| 35206 | while( rr[0]<1.84e+08 ){ |
| 35207 | exp -= 10; |
| 35208 | dekkerMul2(rr, 1.0e+10, 0.0); |
| 35209 | } |
| 35210 | while( rr[0]<1.84e+18 ){ |
| 35211 | exp -= 1; |
| 35212 | dekkerMul2(rr, 1.0e+01, 0.0); |
| 35213 | } |
| 35214 | } |
| 35215 | v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1]; |
| @@ -35521,125 +35763,36 @@ | |
| 35521 | ** A MACRO version, getVarint32, is provided which inlines the |
| 35522 | ** single-byte case. All code should use the MACRO version as |
| 35523 | ** this function assumes the single-byte case has already been handled. |
| 35524 | */ |
| 35525 | SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ |
| 35526 | u32 a,b; |
| 35527 | |
| 35528 | /* The 1-byte case. Overwhelmingly the most common. Handled inline |
| 35529 | ** by the getVarin32() macro */ |
| 35530 | a = *p; |
| 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 | |
| 35541 | /* The 2-byte case */ |
| 35542 | p++; |
| 35543 | b = *p; |
| 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; |
| 35552 | } |
| 35553 | |
| 35554 | /* The 3-byte case */ |
| 35555 | p++; |
| 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; |
| 35567 | } |
| 35568 | |
| 35569 | /* A 32-bit varint is used to store size information in btrees. |
| 35570 | ** Objects are rarely larger than 2MiB limit of a 3-byte varint. |
| 35571 | ** A 3-byte varint is sufficient, for example, to record the size |
| 35572 | ** of a 1048569-byte BLOB or string. |
| 35573 | ** |
| 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; |
| 35638 | return n; |
| 35639 | } |
| 35640 | #endif |
| 35641 | } |
| 35642 | |
| 35643 | /* |
| 35644 | ** Return the number of bytes that will be needed to store the given |
| 35645 | ** 64-bit integer. |
| @@ -36631,23 +36784,24 @@ | |
| 36631 | /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 36632 | /* 170 */ "VBegin" OpHelp(""), |
| 36633 | /* 171 */ "VCreate" OpHelp(""), |
| 36634 | /* 172 */ "VDestroy" OpHelp(""), |
| 36635 | /* 173 */ "VOpen" OpHelp(""), |
| 36636 | /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), |
| 36637 | /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 36638 | /* 176 */ "VRename" OpHelp(""), |
| 36639 | /* 177 */ "Pagecount" OpHelp(""), |
| 36640 | /* 178 */ "MaxPgcnt" OpHelp(""), |
| 36641 | /* 179 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), |
| 36642 | /* 180 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), |
| 36643 | /* 181 */ "Trace" OpHelp(""), |
| 36644 | /* 182 */ "CursorHint" OpHelp(""), |
| 36645 | /* 183 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 36646 | /* 184 */ "Noop" OpHelp(""), |
| 36647 | /* 185 */ "Explain" OpHelp(""), |
| 36648 | /* 186 */ "Abortable" OpHelp(""), |
| 36649 | }; |
| 36650 | return azName[i]; |
| 36651 | } |
| 36652 | #endif |
| 36653 | |
| @@ -57726,14 +57880,37 @@ | |
| 57726 | memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); |
| 57727 | put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff); |
| 57728 | }else{ |
| 57729 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 57730 | } |
| 57731 | |
| 57732 | /* The random check-hash initializer */ |
| 57733 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); |
| 57734 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 57735 | /* The initial database size */ |
| 57736 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 57737 | /* The assumed sector size for this process */ |
| 57738 | put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize); |
| 57739 | |
| @@ -58373,10 +58550,13 @@ | |
| 58373 | pPager->setSuper = 0; |
| 58374 | |
| 58375 | return (rc==SQLITE_OK?rc2:rc); |
| 58376 | } |
| 58377 | |
| 58378 | /* |
| 58379 | ** Execute a rollback if a transaction is active and unlock the |
| 58380 | ** database file. |
| 58381 | ** |
| 58382 | ** If the pager has already entered the ERROR state, do not attempt |
| @@ -58401,10 +58581,25 @@ | |
| 58401 | sqlite3EndBenignMalloc(); |
| 58402 | }else if( !pPager->exclusiveMode ){ |
| 58403 | assert( pPager->eState==PAGER_READER ); |
| 58404 | pager_end_transaction(pPager, 0, 0); |
| 58405 | } |
| 58406 | } |
| 58407 | pager_unlock(pPager); |
| 58408 | } |
| 58409 | |
| 58410 | /* |
| @@ -61893,12 +62088,24 @@ | |
| 61893 | Pager *pPager, /* The pager open on the database file */ |
| 61894 | Pgno pgno, /* Page number to fetch */ |
| 61895 | DbPage **ppPage, /* Write a pointer to the page here */ |
| 61896 | int flags /* PAGER_GET_XXX flags */ |
| 61897 | ){ |
| 61898 | /* printf("PAGE %u\n", pgno); fflush(stdout); */ |
| 61899 | return pPager->xGet(pPager, pgno, ppPage, flags); |
| 61900 | } |
| 61901 | |
| 61902 | /* |
| 61903 | ** Acquire a page if it is already in the in-memory cache. Do |
| 61904 | ** not read the page from disk. Return a pointer to the page, |
| @@ -63581,11 +63788,11 @@ | |
| 63581 | }else if( state==PAGER_OPEN ){ |
| 63582 | pager_unlock(pPager); |
| 63583 | } |
| 63584 | assert( state==pPager->eState ); |
| 63585 | } |
| 63586 | }else if( eMode==PAGER_JOURNALMODE_OFF ){ |
| 63587 | sqlite3OsClose(pPager->jfd); |
| 63588 | } |
| 63589 | } |
| 63590 | |
| 63591 | /* Return the new journal mode */ |
| @@ -69194,11 +69401,11 @@ | |
| 69194 | typedef struct IntegrityCk IntegrityCk; |
| 69195 | struct IntegrityCk { |
| 69196 | BtShared *pBt; /* The tree being checked out */ |
| 69197 | Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ |
| 69198 | u8 *aPgRef; /* 1 bit per page in the db (see above) */ |
| 69199 | Pgno nPage; /* Number of pages in the database */ |
| 69200 | int mxErr; /* Stop accumulating errors when this reaches zero */ |
| 69201 | int nErr; /* Number of messages written to zErrMsg so far */ |
| 69202 | int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ |
| 69203 | u32 nStep; /* Number of steps into the integrity_check process */ |
| 69204 | const char *zPfx; /* Error message prefix */ |
| @@ -69527,11 +69734,10 @@ | |
| 69527 | |
| 69528 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 69529 | |
| 69530 | /************** End of btmutex.c *********************************************/ |
| 69531 | /************** Begin file btree.c *******************************************/ |
| 69532 | |
| 69533 | /* |
| 69534 | ** 2004 April 6 |
| 69535 | ** |
| 69536 | ** The author disclaims copyright to this source code. In place of |
| 69537 | ** a legal notice, here is a blessing: |
| @@ -77022,13 +77228,14 @@ | |
| 77022 | u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager); |
| 77023 | u8 *pData; |
| 77024 | int k; /* Current slot in pCArray->apEnd[] */ |
| 77025 | u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ |
| 77026 | |
| 77027 | assert( i<iEnd ); |
| 77028 | j = get2byte(&aData[hdr+5]); |
| 77029 | if( NEVER(j>(u32)usableSize) ){ j = 0; } |
| 77030 | memcpy(&pTmp[j], &aData[j], usableSize - j); |
| 77031 | |
| 77032 | for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} |
| 77033 | pSrcEnd = pCArray->apEnd[k]; |
| 77034 | |
| @@ -77328,10 +77535,11 @@ | |
| 77328 | #endif |
| 77329 | |
| 77330 | return SQLITE_OK; |
| 77331 | editpage_fail: |
| 77332 | /* Unable to edit this page. Rebuild it from scratch instead. */ |
| 77333 | populateCellCache(pCArray, iNew, nNew); |
| 77334 | return rebuildPage(pCArray, iNew, nNew, pPg); |
| 77335 | } |
| 77336 | |
| 77337 | |
| @@ -79987,19 +80195,19 @@ | |
| 79987 | /* |
| 79988 | ** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that |
| 79989 | ** corresponds to page iPg is already set. |
| 79990 | */ |
| 79991 | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 79992 | assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); |
| 79993 | return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); |
| 79994 | } |
| 79995 | |
| 79996 | /* |
| 79997 | ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. |
| 79998 | */ |
| 79999 | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80000 | assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); |
| 80001 | pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); |
| 80002 | } |
| 80003 | |
| 80004 | |
| 80005 | /* |
| @@ -80009,11 +80217,12 @@ | |
| 80009 | ** if this is the first reference to the page. |
| 80010 | ** |
| 80011 | ** Also check that the page number is in bounds. |
| 80012 | */ |
| 80013 | static int checkRef(IntegrityCk *pCheck, Pgno iPage){ |
| 80014 | if( iPage>pCheck->nPage || iPage==0 ){ |
| 80015 | checkAppendMsg(pCheck, "invalid page number %u", iPage); |
| 80016 | return 1; |
| 80017 | } |
| 80018 | if( getPageReferenced(pCheck, iPage) ){ |
| 80019 | checkAppendMsg(pCheck, "2nd reference to page %u", iPage); |
| @@ -80236,10 +80445,11 @@ | |
| 80236 | pCheck->zPfx = "Tree %u page %u: "; |
| 80237 | pCheck->v1 = iPage; |
| 80238 | if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ |
| 80239 | checkAppendMsg(pCheck, |
| 80240 | "unable to get the page. error code=%d", rc); |
| 80241 | goto end_of_check; |
| 80242 | } |
| 80243 | |
| 80244 | /* Clear MemPage.isInit to make sure the corruption detection code in |
| 80245 | ** btreeInitPage() is executed. */ |
| @@ -80506,31 +80716,36 @@ | |
| 80506 | assert( nRef>=0 ); |
| 80507 | memset(&sCheck, 0, sizeof(sCheck)); |
| 80508 | sCheck.db = db; |
| 80509 | sCheck.pBt = pBt; |
| 80510 | sCheck.pPager = pBt->pPager; |
| 80511 | sCheck.nPage = btreePagecount(sCheck.pBt); |
| 80512 | sCheck.mxErr = mxErr; |
| 80513 | sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); |
| 80514 | sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; |
| 80515 | if( sCheck.nPage==0 ){ |
| 80516 | goto integrity_ck_cleanup; |
| 80517 | } |
| 80518 | |
| 80519 | sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1); |
| 80520 | if( !sCheck.aPgRef ){ |
| 80521 | checkOom(&sCheck); |
| 80522 | goto integrity_ck_cleanup; |
| 80523 | } |
| 80524 | sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize ); |
| 80525 | if( sCheck.heap==0 ){ |
| 80526 | checkOom(&sCheck); |
| 80527 | goto integrity_ck_cleanup; |
| 80528 | } |
| 80529 | |
| 80530 | i = PENDING_BYTE_PAGE(pBt); |
| 80531 | if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i); |
| 80532 | |
| 80533 | /* Check the integrity of the freelist |
| 80534 | */ |
| 80535 | if( bCkFreelist ){ |
| 80536 | sCheck.zPfx = "Freelist: "; |
| @@ -80577,11 +80792,11 @@ | |
| 80577 | pBt->db->flags = savedDbFlags; |
| 80578 | |
| 80579 | /* Make sure every page in the file is referenced |
| 80580 | */ |
| 80581 | if( !bPartial ){ |
| 80582 | for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){ |
| 80583 | #ifdef SQLITE_OMIT_AUTOVACUUM |
| 80584 | if( getPageReferenced(&sCheck, i)==0 ){ |
| 80585 | checkAppendMsg(&sCheck, "Page %u: never used", i); |
| 80586 | } |
| 80587 | #else |
| @@ -82018,11 +82233,11 @@ | |
| 82018 | ){ |
| 82019 | pMem->z[pMem->n] = 0; |
| 82020 | pMem->flags |= MEM_Term; |
| 82021 | return; |
| 82022 | } |
| 82023 | if( pMem->xDel==(void(*)(void*))sqlite3RCStrUnref ){ |
| 82024 | /* Blindly assume that all RCStr objects are zero-terminated */ |
| 82025 | pMem->flags |= MEM_Term; |
| 82026 | return; |
| 82027 | } |
| 82028 | }else if( pMem->szMalloc >= pMem->n+1 ){ |
| @@ -83398,10 +83613,11 @@ | |
| 83398 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 83399 | pVal = valueNew(db, pCtx); |
| 83400 | if( pVal ){ |
| 83401 | pVal->flags = MEM_Int; |
| 83402 | pVal->u.i = pExpr->u.zToken[4]==0; |
| 83403 | } |
| 83404 | } |
| 83405 | |
| 83406 | *ppVal = pVal; |
| 83407 | return rc; |
| @@ -84711,10 +84927,14 @@ | |
| 84711 | for(i=iFirst; i<=iLast; i++, pOp++){ |
| 84712 | if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ){ |
| 84713 | int iDest = pOp->p2; /* Jump destination */ |
| 84714 | if( iDest==0 ) continue; |
| 84715 | if( pOp->opcode==OP_Gosub ) continue; |
| 84716 | if( iDest<0 ){ |
| 84717 | int j = ADDR(iDest); |
| 84718 | assert( j>=0 ); |
| 84719 | if( j>=-pParse->nLabel || pParse->aLabel[j]<0 ){ |
| 84720 | continue; |
| @@ -88170,36 +88390,45 @@ | |
| 88170 | c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1); |
| 88171 | if( c ) return c; |
| 88172 | return n1 - n2; |
| 88173 | } |
| 88174 | |
| 88175 | /* |
| 88176 | ** 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, |
| 88178 | ** equal to, or greater than the second (double). |
| 88179 | */ |
| 88180 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ |
| 88181 | if( sizeof(LONGDOUBLE_TYPE)>8 ){ |
| 88182 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; |
| 88183 | testcase( x<r ); |
| 88184 | testcase( x>r ); |
| 88185 | testcase( x==r ); |
| 88186 | if( x<r ) return -1; |
| 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{ |
| 88190 | i64 y; |
| 88191 | double s; |
| 88192 | if( r<-9223372036854775808.0 ) return +1; |
| 88193 | if( r>=9223372036854775808.0 ) return -1; |
| 88194 | y = (i64)r; |
| 88195 | if( i<y ) return -1; |
| 88196 | if( i>y ) return +1; |
| 88197 | s = (double)i; |
| 88198 | if( s<r ) return -1; |
| 88199 | if( s>r ) return +1; |
| 88200 | return 0; |
| 88201 | } |
| 88202 | } |
| 88203 | |
| 88204 | /* |
| 88205 | ** Compare the values contained by the two memory cells, returning |
| @@ -89563,11 +89792,11 @@ | |
| 89563 | ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the |
| 89564 | ** result as a string or blob. Appropriate errors are set if the string/blob |
| 89565 | ** is too big or if an OOM occurs. |
| 89566 | ** |
| 89567 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() |
| 89568 | ** on value P is not going to be used and need to be destroyed. |
| 89569 | */ |
| 89570 | static void setResultStrOrError( |
| 89571 | sqlite3_context *pCtx, /* Function context */ |
| 89572 | const char *z, /* String pointer */ |
| 89573 | int n, /* Bytes in string, or negative */ |
| @@ -89593,29 +89822,42 @@ | |
| 89593 | } |
| 89594 | } |
| 89595 | static int invokeValueDestructor( |
| 89596 | const void *p, /* Value to destroy */ |
| 89597 | void (*xDel)(void*), /* The destructor */ |
| 89598 | sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if no NULL */ |
| 89599 | ){ |
| 89600 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89601 | if( xDel==0 ){ |
| 89602 | /* noop */ |
| 89603 | }else if( xDel==SQLITE_TRANSIENT ){ |
| 89604 | /* noop */ |
| 89605 | }else{ |
| 89606 | xDel((void*)p); |
| 89607 | } |
| 89608 | sqlite3_result_error_toobig(pCtx); |
| 89609 | return SQLITE_TOOBIG; |
| 89610 | } |
| 89611 | SQLITE_API void sqlite3_result_blob( |
| 89612 | sqlite3_context *pCtx, |
| 89613 | const void *z, |
| 89614 | int n, |
| 89615 | void (*xDel)(void *) |
| 89616 | ){ |
| 89617 | assert( n>=0 ); |
| 89618 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89619 | setResultStrOrError(pCtx, z, n, 0, xDel); |
| 89620 | } |
| 89621 | SQLITE_API void sqlite3_result_blob64( |
| @@ -89622,60 +89864,95 @@ | |
| 89622 | sqlite3_context *pCtx, |
| 89623 | const void *z, |
| 89624 | sqlite3_uint64 n, |
| 89625 | void (*xDel)(void *) |
| 89626 | ){ |
| 89627 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89628 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89629 | if( n>0x7fffffff ){ |
| 89630 | (void)invokeValueDestructor(z, xDel, pCtx); |
| 89631 | }else{ |
| 89632 | setResultStrOrError(pCtx, z, (int)n, 0, xDel); |
| 89633 | } |
| 89634 | } |
| 89635 | SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ |
| 89636 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89637 | sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); |
| 89638 | } |
| 89639 | SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ |
| 89640 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89641 | pCtx->isError = SQLITE_ERROR; |
| 89642 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); |
| 89643 | } |
| 89644 | #ifndef SQLITE_OMIT_UTF16 |
| 89645 | SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ |
| 89646 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89647 | pCtx->isError = SQLITE_ERROR; |
| 89648 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); |
| 89649 | } |
| 89650 | #endif |
| 89651 | SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ |
| 89652 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89653 | sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); |
| 89654 | } |
| 89655 | SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ |
| 89656 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89657 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 89658 | } |
| 89659 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 89660 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89661 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89662 | } |
| 89663 | SQLITE_API void sqlite3_result_pointer( |
| 89664 | sqlite3_context *pCtx, |
| 89665 | void *pPtr, |
| 89666 | const char *zPType, |
| 89667 | void (*xDestructor)(void*) |
| 89668 | ){ |
| 89669 | Mem *pOut = pCtx->pOut; |
| 89670 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89671 | sqlite3VdbeMemRelease(pOut); |
| 89672 | pOut->flags = MEM_Null; |
| 89673 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); |
| 89674 | } |
| 89675 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 89676 | Mem *pOut = pCtx->pOut; |
| 89677 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89678 | pOut->eSubtype = eSubtype & 0xff; |
| 89679 | pOut->flags |= MEM_Subtype; |
| 89680 | } |
| 89681 | SQLITE_API void sqlite3_result_text( |
| @@ -89682,10 +89959,16 @@ | |
| 89682 | sqlite3_context *pCtx, |
| 89683 | const char *z, |
| 89684 | int n, |
| 89685 | void (*xDel)(void *) |
| 89686 | ){ |
| 89687 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89688 | setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); |
| 89689 | } |
| 89690 | SQLITE_API void sqlite3_result_text64( |
| 89691 | sqlite3_context *pCtx, |
| @@ -89692,10 +89975,16 @@ | |
| 89692 | const char *z, |
| 89693 | sqlite3_uint64 n, |
| 89694 | void (*xDel)(void *), |
| 89695 | unsigned char enc |
| 89696 | ){ |
| 89697 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89698 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89699 | if( enc!=SQLITE_UTF8 ){ |
| 89700 | if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 89701 | n &= ~(u64)1; |
| @@ -89735,11 +90024,20 @@ | |
| 89735 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89736 | setResultStrOrError(pCtx, z, n & ~(u64)1, SQLITE_UTF16LE, xDel); |
| 89737 | } |
| 89738 | #endif /* SQLITE_OMIT_UTF16 */ |
| 89739 | SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ |
| 89740 | Mem *pOut = pCtx->pOut; |
| 89741 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89742 | sqlite3VdbeMemCopy(pOut, pValue); |
| 89743 | sqlite3VdbeChangeEncoding(pOut, pCtx->enc); |
| 89744 | if( sqlite3VdbeMemTooBig(pOut) ){ |
| 89745 | sqlite3_result_error_toobig(pCtx); |
| @@ -89747,11 +90045,16 @@ | |
| 89747 | } |
| 89748 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ |
| 89749 | sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); |
| 89750 | } |
| 89751 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ |
| 89752 | Mem *pOut = pCtx->pOut; |
| 89753 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89754 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 89755 | sqlite3_result_error_toobig(pCtx); |
| 89756 | return SQLITE_TOOBIG; |
| 89757 | } |
| @@ -89761,10 +90064,13 @@ | |
| 89761 | #else |
| 89762 | return sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 89763 | #endif |
| 89764 | } |
| 89765 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 89766 | pCtx->isError = errCode ? errCode : -1; |
| 89767 | #ifdef SQLITE_DEBUG |
| 89768 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| 89769 | #endif |
| 89770 | if( pCtx->pOut->flags & MEM_Null ){ |
| @@ -89773,18 +90079,24 @@ | |
| 89773 | } |
| 89774 | } |
| 89775 | |
| 89776 | /* Force an SQLITE_TOOBIG error. */ |
| 89777 | SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ |
| 89778 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89779 | pCtx->isError = SQLITE_TOOBIG; |
| 89780 | sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, |
| 89781 | SQLITE_UTF8, SQLITE_STATIC); |
| 89782 | } |
| 89783 | |
| 89784 | /* An SQLITE_NOMEM error. */ |
| 89785 | SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ |
| 89786 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89787 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89788 | pCtx->isError = SQLITE_NOMEM_BKPT; |
| 89789 | sqlite3OomFault(pCtx->pOut->db); |
| 89790 | } |
| @@ -90033,11 +90345,15 @@ | |
| 90033 | /* |
| 90034 | ** Extract the user data from a sqlite3_context structure and return a |
| 90035 | ** pointer to it. |
| 90036 | */ |
| 90037 | SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ |
| 90038 | assert( p && p->pFunc ); |
| 90039 | return p->pFunc->pUserData; |
| 90040 | } |
| 90041 | |
| 90042 | /* |
| 90043 | ** Extract the user data from a sqlite3_context structure and return a |
| @@ -90048,11 +90364,15 @@ | |
| 90048 | ** parameter) of the sqlite3_create_function() and |
| 90049 | ** sqlite3_create_function16() routines that originally registered the |
| 90050 | ** application defined function. |
| 90051 | */ |
| 90052 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ |
| 90053 | assert( p && p->pOut ); |
| 90054 | return p->pOut->db; |
| 90055 | } |
| 90056 | |
| 90057 | /* |
| 90058 | ** If this routine is invoked from within an xColumn method of a virtual |
| @@ -90067,11 +90387,15 @@ | |
| 90067 | ** Virtual table implements might use this routine to optimize their |
| 90068 | ** performance by substituting a NULL result, or some other light-weight |
| 90069 | ** value, as a signal to the xUpdate routine that the column is unchanged. |
| 90070 | */ |
| 90071 | SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ |
| 90072 | assert( p ); |
| 90073 | return sqlite3_value_nochange(p->pOut); |
| 90074 | } |
| 90075 | |
| 90076 | /* |
| 90077 | ** The destructor function for a ValueList object. This needs to be |
| @@ -90095,11 +90419,11 @@ | |
| 90095 | ){ |
| 90096 | int rc; |
| 90097 | ValueList *pRhs; |
| 90098 | |
| 90099 | *ppOut = 0; |
| 90100 | if( pVal==0 ) return SQLITE_MISUSE; |
| 90101 | if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ |
| 90102 | return SQLITE_ERROR; |
| 90103 | }else{ |
| 90104 | assert( (pVal->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) == |
| 90105 | (MEM_Null|MEM_Term|MEM_Subtype) ); |
| @@ -90226,10 +90550,13 @@ | |
| 90226 | ** single prepared statement. The iArg values must match. |
| 90227 | */ |
| 90228 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 90229 | AuxData *pAuxData; |
| 90230 | |
| 90231 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90232 | #if SQLITE_ENABLE_STAT4 |
| 90233 | if( pCtx->pVdbe==0 ) return 0; |
| 90234 | #else |
| 90235 | assert( pCtx->pVdbe!=0 ); |
| @@ -90258,12 +90585,16 @@ | |
| 90258 | int iArg, |
| 90259 | void *pAux, |
| 90260 | void (*xDelete)(void*) |
| 90261 | ){ |
| 90262 | AuxData *pAuxData; |
| 90263 | Vdbe *pVdbe = pCtx->pVdbe; |
| 90264 | |
| 90265 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90266 | #ifdef SQLITE_ENABLE_STAT4 |
| 90267 | if( pVdbe==0 ) goto failed; |
| 90268 | #else |
| 90269 | assert( pVdbe!=0 ); |
| @@ -90696,11 +91027,11 @@ | |
| 90696 | if( vdbeSafetyNotNull(p) ){ |
| 90697 | return SQLITE_MISUSE_BKPT; |
| 90698 | } |
| 90699 | sqlite3_mutex_enter(p->db->mutex); |
| 90700 | if( p->eVdbeState!=VDBE_READY_STATE ){ |
| 90701 | sqlite3Error(p->db, SQLITE_MISUSE); |
| 90702 | sqlite3_mutex_leave(p->db->mutex); |
| 90703 | sqlite3_log(SQLITE_MISUSE, |
| 90704 | "bind on a busy prepared statement: [%s]", p->zSql); |
| 90705 | return SQLITE_MISUSE_BKPT; |
| 90706 | } |
| @@ -90925,10 +91256,13 @@ | |
| 90925 | return rc; |
| 90926 | } |
| 90927 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| 90928 | int rc; |
| 90929 | Vdbe *p = (Vdbe *)pStmt; |
| 90930 | sqlite3_mutex_enter(p->db->mutex); |
| 90931 | if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 90932 | rc = SQLITE_TOOBIG; |
| 90933 | }else{ |
| 90934 | assert( (n & 0x7FFFFFFF)==n ); |
| @@ -91051,10 +91385,13 @@ | |
| 91051 | ** Set the explain mode for a statement. |
| 91052 | */ |
| 91053 | SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ |
| 91054 | Vdbe *v = (Vdbe*)pStmt; |
| 91055 | int rc; |
| 91056 | sqlite3_mutex_enter(v->db->mutex); |
| 91057 | if( ((int)v->explain)==eMode ){ |
| 91058 | rc = SQLITE_OK; |
| 91059 | }else if( eMode<0 || eMode>2 ){ |
| 91060 | rc = SQLITE_ERROR; |
| @@ -91217,14 +91554,20 @@ | |
| 91217 | /* |
| 91218 | ** This function is called from within a pre-update callback to retrieve |
| 91219 | ** a field of the row currently being updated or deleted. |
| 91220 | */ |
| 91221 | SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91222 | PreUpdate *p = db->pPreUpdate; |
| 91223 | Mem *pMem; |
| 91224 | int rc = SQLITE_OK; |
| 91225 | |
| 91226 | /* 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. */ |
| 91228 | if( !p || p->op==SQLITE_INSERT ){ |
| 91229 | rc = SQLITE_MISUSE_BKPT; |
| 91230 | goto preupdate_old_out; |
| @@ -91281,11 +91624,16 @@ | |
| 91281 | /* |
| 91282 | ** This function is called from within a pre-update callback to retrieve |
| 91283 | ** the number of columns in the row being updated, deleted or inserted. |
| 91284 | */ |
| 91285 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ |
| 91286 | PreUpdate *p = db->pPreUpdate; |
| 91287 | return (p ? p->keyinfo.nKeyField : 0); |
| 91288 | } |
| 91289 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 91290 | |
| 91291 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91299,11 +91647,16 @@ | |
| 91299 | ** |
| 91300 | ** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL |
| 91301 | ** or SET DEFAULT action is considered a trigger. |
| 91302 | */ |
| 91303 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ |
| 91304 | PreUpdate *p = db->pPreUpdate; |
| 91305 | return (p ? p->v->nFrame : 0); |
| 91306 | } |
| 91307 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 91308 | |
| 91309 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91310,11 +91663,16 @@ | |
| 91310 | /* |
| 91311 | ** This function is designed to be called from within a pre-update callback |
| 91312 | ** only. |
| 91313 | */ |
| 91314 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ |
| 91315 | PreUpdate *p = db->pPreUpdate; |
| 91316 | return (p ? p->iBlobWrite : -1); |
| 91317 | } |
| 91318 | #endif |
| 91319 | |
| 91320 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91321,14 +91679,20 @@ | |
| 91321 | /* |
| 91322 | ** This function is called from within a pre-update callback to retrieve |
| 91323 | ** a field of the row currently being updated or inserted. |
| 91324 | */ |
| 91325 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91326 | PreUpdate *p = db->pPreUpdate; |
| 91327 | int rc = SQLITE_OK; |
| 91328 | Mem *pMem; |
| 91329 | |
| 91330 | if( !p || p->op==SQLITE_DELETE ){ |
| 91331 | rc = SQLITE_MISUSE_BKPT; |
| 91332 | goto preupdate_new_out; |
| 91333 | } |
| 91334 | if( p->pPk && p->op!=SQLITE_UPDATE ){ |
| @@ -91403,15 +91767,24 @@ | |
| 91403 | int iScanStatusOp, /* Which metric to return */ |
| 91404 | int flags, |
| 91405 | void *pOut /* OUT: Write the answer here */ |
| 91406 | ){ |
| 91407 | Vdbe *p = (Vdbe*)pStmt; |
| 91408 | VdbeOp *aOp = p->aOp; |
| 91409 | int nOp = p->nOp; |
| 91410 | ScanStatus *pScan = 0; |
| 91411 | int idx; |
| 91412 | |
| 91413 | if( p->pFrame ){ |
| 91414 | VdbeFrame *pFrame; |
| 91415 | for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); |
| 91416 | aOp = pFrame->aOp; |
| 91417 | nOp = pFrame->nOp; |
| @@ -91554,11 +91927,11 @@ | |
| 91554 | ** Zero all counters associated with the sqlite3_stmt_scanstatus() data. |
| 91555 | */ |
| 91556 | SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ |
| 91557 | Vdbe *p = (Vdbe*)pStmt; |
| 91558 | int ii; |
| 91559 | for(ii=0; ii<p->nOp; ii++){ |
| 91560 | Op *pOp = &p->aOp[ii]; |
| 91561 | pOp->nExec = 0; |
| 91562 | pOp->nCycle = 0; |
| 91563 | } |
| 91564 | } |
| @@ -92523,15 +92896,15 @@ | |
| 92523 | } |
| 92524 | assert( t>=12 ); |
| 92525 | sqlite3RCStrRef(pBuf); |
| 92526 | if( t&1 ){ |
| 92527 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, |
| 92528 | (void(*)(void*))sqlite3RCStrUnref); |
| 92529 | pDest->flags |= MEM_Term; |
| 92530 | }else{ |
| 92531 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, |
| 92532 | (void(*)(void*))sqlite3RCStrUnref); |
| 92533 | } |
| 92534 | }else{ |
| 92535 | rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); |
| 92536 | if( rc ) return rc; |
| 92537 | sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); |
| @@ -95402,24 +95775,28 @@ | |
| 95402 | *(zHdr++) = serial_type; |
| 95403 | if( serial_type==0 ){ |
| 95404 | /* NULL value. No change in zPayload */ |
| 95405 | }else{ |
| 95406 | u64 v; |
| 95407 | u32 i; |
| 95408 | if( serial_type==7 ){ |
| 95409 | assert( sizeof(v)==sizeof(pRec->u.r) ); |
| 95410 | memcpy(&v, &pRec->u.r, sizeof(v)); |
| 95411 | swapMixedEndianFloat(v); |
| 95412 | }else{ |
| 95413 | v = pRec->u.i; |
| 95414 | } |
| 95415 | len = i = sqlite3SmallTypeSizes[serial_type]; |
| 95416 | assert( i>0 ); |
| 95417 | while( 1 /*exit-by-break*/ ){ |
| 95418 | zPayload[--i] = (u8)(v&0xFF); |
| 95419 | if( i==0 ) break; |
| 95420 | v >>= 8; |
| 95421 | } |
| 95422 | zPayload += len; |
| 95423 | } |
| 95424 | }else if( serial_type<0x80 ){ |
| 95425 | *(zHdr++) = serial_type; |
| @@ -97532,12 +97909,17 @@ | |
| 97532 | ** delete is one of several associated with deleting a table row and |
| 97533 | ** all its associated index entries. Exactly one of those deletes is |
| 97534 | ** the "primary" delete. The others are all on OPFLAG_FORDELETE |
| 97535 | ** cursors or else are marked with the AUXDELETE flag. |
| 97536 | ** |
| 97537 | ** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row |
| 97538 | ** change count is incremented (otherwise not). |
| 97539 | ** |
| 97540 | ** P1 must not be pseudo-table. It has to be a real table with |
| 97541 | ** multiple rows. |
| 97542 | ** |
| 97543 | ** If P4 is not NULL then it points to a Table object. In this case either |
| @@ -98658,17 +99040,37 @@ | |
| 98658 | } |
| 98659 | |
| 98660 | /* Opcode: SqlExec * * * P4 * |
| 98661 | ** |
| 98662 | ** Run the SQL statement or statements specified in the P4 string. |
| 98663 | */ |
| 98664 | case OP_SqlExec: { |
| 98665 | sqlite3VdbeIncrWriteCounter(p, 0); |
| 98666 | db->nSqlExec++; |
| 98667 | rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0); |
| 98668 | db->nSqlExec--; |
| 98669 | if( rc ) goto abort_due_to_error; |
| 98670 | break; |
| 98671 | } |
| 98672 | |
| 98673 | /* Opcode: ParseSchema P1 * * P4 * |
| 98674 | ** |
| @@ -99885,10 +100287,54 @@ | |
| 99885 | } |
| 99886 | break; |
| 99887 | } |
| 99888 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 99889 | |
| 99890 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 99891 | /* Opcode: VInitIn P1 P2 P3 * * |
| 99892 | ** Synopsis: r[P2]=ValueList(P1,P3) |
| 99893 | ** |
| 99894 | ** Set register P2 to be a pointer to a ValueList object for cursor P1 |
| @@ -100831,12 +101277,11 @@ | |
| 100831 | Vdbe *v = (Vdbe *)p->pStmt; |
| 100832 | |
| 100833 | /* Set the value of register r[1] in the SQL statement to integer iRow. |
| 100834 | ** This is done directly as a performance optimization |
| 100835 | */ |
| 100836 | v->aMem[1].flags = MEM_Int; |
| 100837 | v->aMem[1].u.i = iRow; |
| 100838 | |
| 100839 | /* 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 |
| 100841 | ** have been down with an extra OP_Goto, but simply setting the program |
| 100842 | ** counter is faster. */ |
| @@ -100915,11 +101360,11 @@ | |
| 100915 | return SQLITE_MISUSE_BKPT; |
| 100916 | } |
| 100917 | #endif |
| 100918 | *ppBlob = 0; |
| 100919 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 100920 | if( !sqlite3SafetyCheckOk(db) || zTable==0 ){ |
| 100921 | return SQLITE_MISUSE_BKPT; |
| 100922 | } |
| 100923 | #endif |
| 100924 | wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */ |
| 100925 | |
| @@ -101477,11 +101922,11 @@ | |
| 101477 | ** are connected using SorterRecord.u.iNext. |
| 101478 | */ |
| 101479 | struct SorterList { |
| 101480 | SorterRecord *pList; /* Linked list of records */ |
| 101481 | u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ |
| 101482 | int szPMA; /* Size of pList as PMA in bytes */ |
| 101483 | }; |
| 101484 | |
| 101485 | /* |
| 101486 | ** The MergeEngine object is used to combine two or more smaller PMAs into |
| 101487 | ** one big PMA using a merge operation. Separate PMAs all need to be |
| @@ -101586,14 +102031,14 @@ | |
| 101586 | */ |
| 101587 | typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int); |
| 101588 | struct SortSubtask { |
| 101589 | SQLiteThread *pThread; /* Background thread, if any */ |
| 101590 | int bDone; /* Set if thread is finished but not joined */ |
| 101591 | VdbeSorter *pSorter; /* Sorter that owns this sub-task */ |
| 101592 | UnpackedRecord *pUnpacked; /* Space to unpack a record */ |
| 101593 | 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 */ |
| 101596 | SorterFile file; /* Temp file for level-0 PMAs */ |
| 101597 | SorterFile file2; /* Space for other PMAs */ |
| 101598 | }; |
| 101599 | |
| @@ -103063,12 +103508,12 @@ | |
| 103063 | ){ |
| 103064 | VdbeSorter *pSorter; |
| 103065 | int rc = SQLITE_OK; /* Return Code */ |
| 103066 | SorterRecord *pNew; /* New list element */ |
| 103067 | int bFlush; /* True to flush contents of memory to PMA */ |
| 103068 | int nReq; /* Bytes of memory required */ |
| 103069 | int nPMA; /* Bytes of PMA space required */ |
| 103070 | int t; /* serial type of first record field */ |
| 103071 | |
| 103072 | assert( pCsr->eCurType==CURTYPE_SORTER ); |
| 103073 | pSorter = pCsr->uc.pSorter; |
| 103074 | getVarint32NR((const u8*)&pVal->z[1], t); |
| @@ -104488,11 +104933,12 @@ | |
| 104488 | /* xFindMethod */ 0, |
| 104489 | /* xRename */ 0, |
| 104490 | /* xSavepoint */ 0, |
| 104491 | /* xRelease */ 0, |
| 104492 | /* xRollbackTo */ 0, |
| 104493 | /* xShadowName */ 0 |
| 104494 | }; |
| 104495 | |
| 104496 | |
| 104497 | SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3 *db){ |
| 104498 | int rc; |
| @@ -105317,25 +105763,40 @@ | |
| 105317 | sqlite3ExprDeferredDelete(pParse, pDup); |
| 105318 | } |
| 105319 | } |
| 105320 | |
| 105321 | /* |
| 105322 | ** Subqueries stores the original database, table and column names for their |
| 105323 | ** 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, |
| 105325 | ** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will |
| 105326 | ** match anything. |
| 105327 | */ |
| 105328 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 105329 | const struct ExprList_item *pItem, |
| 105330 | const char *zCol, |
| 105331 | const char *zTab, |
| 105332 | const char *zDb |
| 105333 | ){ |
| 105334 | int n; |
| 105335 | const char *zSpan; |
| 105336 | if( pItem->fg.eEName!=ENAME_TAB ) return 0; |
| 105337 | zSpan = pItem->zEName; |
| 105338 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105339 | if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ |
| 105340 | return 0; |
| 105341 | } |
| @@ -105343,13 +105804,15 @@ | |
| 105343 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105344 | if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){ |
| 105345 | return 0; |
| 105346 | } |
| 105347 | zSpan += n+1; |
| 105348 | if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){ |
| 105349 | return 0; |
| 105350 | } |
| 105351 | return 1; |
| 105352 | } |
| 105353 | |
| 105354 | /* |
| 105355 | ** Return TRUE if the double-quoted string mis-feature should be supported. |
| @@ -105478,11 +105941,11 @@ | |
| 105478 | NameContext *pNC, /* The name context used to resolve the name */ |
| 105479 | Expr *pExpr /* Make this EXPR node point to the selected column */ |
| 105480 | ){ |
| 105481 | int i, j; /* Loop counters */ |
| 105482 | int cnt = 0; /* Number of matching column names */ |
| 105483 | int cntTab = 0; /* Number of matching table names */ |
| 105484 | int nSubquery = 0; /* How many levels of subquery */ |
| 105485 | sqlite3 *db = pParse->db; /* The database connection */ |
| 105486 | SrcItem *pItem; /* Use for looping over pSrcList items */ |
| 105487 | SrcItem *pMatch = 0; /* The matching pSrcList item */ |
| 105488 | NameContext *pTopNC = pNC; /* First namecontext in the list */ |
| @@ -105555,43 +106018,53 @@ | |
| 105555 | assert( pItem->pSelect!=0 ); |
| 105556 | pEList = pItem->pSelect->pEList; |
| 105557 | assert( pEList!=0 ); |
| 105558 | assert( pEList->nExpr==pTab->nCol ); |
| 105559 | for(j=0; j<pEList->nExpr; j++){ |
| 105560 | if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ |
| 105561 | continue; |
| 105562 | } |
| 105563 | if( cnt>0 ){ |
| 105564 | if( pItem->fg.isUsing==0 |
| 105565 | || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 |
| 105566 | ){ |
| 105567 | /* Two or more tables have the same column name which is |
| 105568 | ** not joined by USING. This is an error. Signal as much |
| 105569 | ** by clearing pFJMatch and letting cnt go above 1. */ |
| 105570 | sqlite3ExprListDelete(db, pFJMatch); |
| 105571 | pFJMatch = 0; |
| 105572 | }else |
| 105573 | if( (pItem->fg.jointype & JT_RIGHT)==0 ){ |
| 105574 | /* An INNER or LEFT JOIN. Use the left-most table */ |
| 105575 | continue; |
| 105576 | }else |
| 105577 | if( (pItem->fg.jointype & JT_LEFT)==0 ){ |
| 105578 | /* A RIGHT JOIN. Use the right-most table */ |
| 105579 | cnt = 0; |
| 105580 | sqlite3ExprListDelete(db, pFJMatch); |
| 105581 | pFJMatch = 0; |
| 105582 | }else{ |
| 105583 | /* For a FULL JOIN, we must construct a coalesce() func */ |
| 105584 | extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); |
| 105585 | } |
| 105586 | } |
| 105587 | cnt++; |
| 105588 | cntTab = 2; |
| 105589 | pMatch = pItem; |
| 105590 | pExpr->iColumn = j; |
| 105591 | pEList->a[j].fg.bUsed = 1; |
| 105592 | hit = 1; |
| 105593 | if( pEList->a[j].fg.bUsingTerm ) break; |
| 105594 | } |
| 105595 | if( hit || zTab==0 ) continue; |
| 105596 | } |
| 105597 | assert( zDb==0 || zTab!=0 ); |
| @@ -105782,14 +106255,14 @@ | |
| 105782 | if( cnt==0 |
| 105783 | && cntTab==1 |
| 105784 | && pMatch |
| 105785 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 |
| 105786 | && sqlite3IsRowid(zCol) |
| 105787 | && ALWAYS(VisibleRowid(pMatch->pTab)) |
| 105788 | ){ |
| 105789 | cnt = 1; |
| 105790 | pExpr->iColumn = -1; |
| 105791 | pExpr->affExpr = SQLITE_AFF_INTEGER; |
| 105792 | } |
| 105793 | |
| 105794 | /* |
| 105795 | ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z |
| @@ -106238,10 +106711,11 @@ | |
| 106238 | int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin)); |
| 106239 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106240 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); |
| 106241 | #endif |
| 106242 | assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); |
| 106243 | zId = pExpr->u.zToken; |
| 106244 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 106245 | if( pDef==0 ){ |
| 106246 | pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| 106247 | if( pDef==0 ){ |
| @@ -106379,10 +106853,14 @@ | |
| 106379 | pExpr |
| 106380 | ); |
| 106381 | pNC->nNcErr++; |
| 106382 | } |
| 106383 | #endif |
| 106384 | if( is_agg ){ |
| 106385 | /* Window functions may not be arguments of aggregate functions. |
| 106386 | ** Or arguments of other window functions. But aggregate functions |
| 106387 | ** may be arguments for window functions. */ |
| 106388 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -106397,10 +106875,15 @@ | |
| 106397 | is_agg = 1; |
| 106398 | } |
| 106399 | #endif |
| 106400 | sqlite3WalkExprList(pWalker, pList); |
| 106401 | if( is_agg ){ |
| 106402 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106403 | if( pWin ){ |
| 106404 | Select *pSel = pNC->pWinSelect; |
| 106405 | assert( pWin==0 || (ExprUseYWin(pExpr) && pWin==pExpr->y.pWin) ); |
| 106406 | if( IN_RENAME_OBJECT==0 ){ |
| @@ -106960,13 +107443,11 @@ | |
| 106960 | nCompound = 0; |
| 106961 | pLeftmost = p; |
| 106962 | while( p ){ |
| 106963 | assert( (p->selFlags & SF_Expanded)!=0 ); |
| 106964 | assert( (p->selFlags & SF_Resolved)==0 ); |
| 106965 | assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */ |
| 106966 | p->selFlags |= SF_Resolved; |
| 106967 | |
| 106968 | |
| 106969 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These |
| 106970 | ** are not allowed to refer to any names, so pass an empty NameContext. |
| 106971 | */ |
| 106972 | memset(&sNC, 0, sizeof(sNC)); |
| @@ -107969,10 +108450,11 @@ | |
| 107969 | ** with the same pLeft pointer to the pVector, but only one of them |
| 107970 | ** will own the pVector. |
| 107971 | */ |
| 107972 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); |
| 107973 | if( pRet ){ |
| 107974 | pRet->iTable = nField; |
| 107975 | pRet->iColumn = iField; |
| 107976 | pRet->pLeft = pVector; |
| 107977 | } |
| 107978 | }else{ |
| @@ -108558,10 +109040,73 @@ | |
| 108558 | assert( ExprUseXList(pNew) ); |
| 108559 | sqlite3ExprSetHeightAndFlags(pParse, pNew); |
| 108560 | if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct); |
| 108561 | return pNew; |
| 108562 | } |
| 108563 | |
| 108564 | /* |
| 108565 | ** Check to see if a function is usable according to current access |
| 108566 | ** rules: |
| 108567 | ** |
| @@ -108812,15 +109357,11 @@ | |
| 108812 | static int dupedExprStructSize(const Expr *p, int flags){ |
| 108813 | int nSize; |
| 108814 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ |
| 108815 | assert( EXPR_FULLSIZE<=0xfff ); |
| 108816 | assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); |
| 108817 | if( 0==flags || p->op==TK_SELECT_COLUMN |
| 108818 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 108819 | || ExprHasProperty(p, EP_WinFunc) |
| 108820 | #endif |
| 108821 | ){ |
| 108822 | nSize = EXPR_FULLSIZE; |
| 108823 | }else{ |
| 108824 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| 108825 | assert( !ExprHasProperty(p, EP_OuterON) ); |
| 108826 | assert( !ExprHasVVAProperty(p, EP_NoReduce) ); |
| @@ -108847,84 +109388,123 @@ | |
| 108847 | return ROUND8(nByte); |
| 108848 | } |
| 108849 | |
| 108850 | /* |
| 108851 | ** Return the number of bytes required to create a duplicate of the |
| 108852 | ** expression passed as the first argument. The second argument is a |
| 108853 | ** mask containing EXPRDUP_XXX flags. |
| 108854 | ** |
| 108855 | ** 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. |
| 108857 | ** |
| 108858 | ** If the EXPRDUP_REDUCE flag is set, then the return value includes |
| 108859 | ** space to duplicate all Expr nodes in the tree formed by Expr.pLeft |
| 108860 | ** and Expr.pRight variables (but not for any structures pointed to or |
| 108861 | ** descended from the Expr.x.pList or Expr.x.pSelect variables). |
| 108862 | */ |
| 108863 | static int dupedExprSize(const Expr *p, int flags){ |
| 108864 | int nByte = 0; |
| 108865 | if( p ){ |
| 108866 | nByte = dupedExprNodeSize(p, flags); |
| 108867 | if( flags&EXPRDUP_REDUCE ){ |
| 108868 | nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags); |
| 108869 | } |
| 108870 | } |
| 108871 | return nByte; |
| 108872 | } |
| 108873 | |
| 108874 | /* |
| 108875 | ** This function is similar to sqlite3ExprDup(), except that if pzBuffer |
| 108876 | ** is not NULL then *pzBuffer is assumed to point to a buffer large enough |
| 108877 | ** to store the copy of expression p, the copies of p->u.zToken |
| 108878 | ** (if applicable), and the copies of the p->pLeft and p->pRight expressions, |
| 108879 | ** if any. Before returning, *pzBuffer is set to the first byte past the |
| 108880 | ** portion of the buffer copied into by this function. |
| 108881 | */ |
| 108882 | static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ |
| 108883 | Expr *pNew; /* Value to return */ |
| 108884 | u8 *zAlloc; /* Memory space from which to build Expr object */ |
| 108885 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ |
| 108886 | |
| 108887 | assert( db!=0 ); |
| 108888 | assert( p ); |
| 108889 | assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); |
| 108890 | assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE ); |
| 108891 | |
| 108892 | /* Figure out where to write the new Expr structure. */ |
| 108893 | if( pzBuffer ){ |
| 108894 | zAlloc = *pzBuffer; |
| 108895 | staticFlag = EP_Static; |
| 108896 | assert( zAlloc!=0 ); |
| 108897 | }else{ |
| 108898 | zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); |
| 108899 | staticFlag = 0; |
| 108900 | } |
| 108901 | pNew = (Expr *)zAlloc; |
| 108902 | |
| 108903 | if( pNew ){ |
| 108904 | /* Set nNewSize to the size allocated for the structure pointed to |
| 108905 | ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or |
| 108906 | ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed |
| 108907 | ** by the copy of the p->u.zToken string (if any). |
| 108908 | */ |
| 108909 | const unsigned nStructSize = dupedExprStructSize(p, dupFlags); |
| 108910 | const int nNewSize = nStructSize & 0xfff; |
| 108911 | int nToken; |
| 108912 | if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ |
| 108913 | nToken = sqlite3Strlen30(p->u.zToken) + 1; |
| 108914 | }else{ |
| 108915 | nToken = 0; |
| 108916 | } |
| 108917 | if( dupFlags ){ |
| 108918 | assert( ExprHasProperty(p, EP_Reduced)==0 ); |
| 108919 | memcpy(zAlloc, p, nNewSize); |
| 108920 | }else{ |
| 108921 | u32 nSize = (u32)exprStructSize(p); |
| 108922 | memcpy(zAlloc, p, nSize); |
| 108923 | if( nSize<EXPR_FULLSIZE ){ |
| 108924 | memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); |
| 108925 | } |
| 108926 | } |
| 108927 | |
| 108928 | /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ |
| 108929 | pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static); |
| 108930 | pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly); |
| @@ -108933,55 +109513,62 @@ | |
| 108933 | if( dupFlags ){ |
| 108934 | ExprSetVVAProperty(pNew, EP_Immutable); |
| 108935 | } |
| 108936 | |
| 108937 | /* Copy the p->u.zToken string, if any. */ |
| 108938 | if( nToken ){ |
| 108939 | char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; |
| 108940 | memcpy(zToken, p->u.zToken, nToken); |
| 108941 | } |
| 108942 | |
| 108943 | if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){ |
| 108944 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ |
| 108945 | if( ExprUseXSelect(p) ){ |
| 108946 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); |
| 108947 | }else{ |
| 108948 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); |
| 108949 | } |
| 108950 | } |
| 108951 | |
| 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 |
| 108962 | if( ExprHasProperty(p, EP_WinFunc) ){ |
| 108963 | pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); |
| 108964 | assert( ExprHasProperty(pNew, EP_WinFunc) ); |
| 108965 | } |
| 108966 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 108967 | if( pzBuffer ){ |
| 108968 | *pzBuffer = zAlloc; |
| 108969 | } |
| 108970 | }else{ |
| 108971 | if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ |
| 108972 | if( pNew->op==TK_SELECT_COLUMN ){ |
| 108973 | pNew->pLeft = p->pLeft; |
| 108974 | assert( p->pRight==0 || p->pRight==p->pLeft |
| 108975 | || ExprHasProperty(p->pLeft, EP_Subquery) ); |
| 108976 | }else{ |
| 108977 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 108978 | } |
| 108979 | pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); |
| 108980 | } |
| 108981 | } |
| 108982 | } |
| 108983 | return pNew; |
| 108984 | } |
| 108985 | |
| 108986 | /* |
| 108987 | ** Create and return a deep copy of the object passed as the second |
| @@ -109242,15 +109829,11 @@ | |
| 109242 | /* |
| 109243 | ** Add a new element to the end of an expression list. If pList is |
| 109244 | ** initially NULL, then create a new expression list. |
| 109245 | ** |
| 109246 | ** The pList argument must be either NULL or a pointer to an ExprList |
| 109247 | ** obtained from a prior call to sqlite3ExprListAppend(). This routine |
| 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 | ** |
| 109253 | ** 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 |
| 109255 | ** that the new entry was successfully appended. |
| 109256 | */ |
| @@ -110071,10 +110654,31 @@ | |
| 110071 | if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1; |
| 110072 | if( sqlite3StrICmp(z, "ROWID")==0 ) return 1; |
| 110073 | if( sqlite3StrICmp(z, "OID")==0 ) return 1; |
| 110074 | return 0; |
| 110075 | } |
| 110076 | |
| 110077 | /* |
| 110078 | ** 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 |
| 110080 | ** a pointer to the SELECT statement. If pX is not a SELECT statement, |
| @@ -111608,10 +112212,45 @@ | |
| 111608 | return target; |
| 111609 | } |
| 111610 | return -1; /* Not found */ |
| 111611 | } |
| 111612 | |
| 111613 | |
| 111614 | /* |
| 111615 | ** Generate code into the current Vdbe to evaluate the given |
| 111616 | ** expression. Attempt to store the results in register "target". |
| 111617 | ** Return the register where results are stored. |
| @@ -111645,10 +112284,11 @@ | |
| 111645 | return r1; |
| 111646 | }else{ |
| 111647 | assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); |
| 111648 | op = pExpr->op; |
| 111649 | } |
| 111650 | switch( op ){ |
| 111651 | case TK_AGG_COLUMN: { |
| 111652 | AggInfo *pAggInfo = pExpr->pAggInfo; |
| 111653 | struct AggInfo_col *pCol; |
| 111654 | assert( pAggInfo!=0 ); |
| @@ -111658,11 +112298,11 @@ | |
| 111658 | ** is using an expression index */ |
| 111659 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 111660 | #ifdef SQLITE_VDBE_COVERAGE |
| 111661 | /* Verify that the OP_Null above is exercised by tests |
| 111662 | ** tag-20230325-2 */ |
| 111663 | sqlite3VdbeAddOp2(v, OP_NotNull, target, 1); |
| 111664 | VdbeCoverageNeverTaken(v); |
| 111665 | #endif |
| 111666 | break; |
| 111667 | } |
| 111668 | pCol = &pAggInfo->aCol[pExpr->iAgg]; |
| @@ -111765,10 +112405,15 @@ | |
| 111765 | }else{ |
| 111766 | /* Coding an expression that is part of an index where column names |
| 111767 | ** in the index refer to the table to which the index belongs */ |
| 111768 | iTab = pParse->iSelfTab - 1; |
| 111769 | } |
| 111770 | } |
| 111771 | assert( ExprUseYTab(pExpr) ); |
| 111772 | assert( pExpr->y.pTab!=0 ); |
| 111773 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 111774 | pExpr->iColumn, iTab, target, |
| @@ -112426,11 +113071,11 @@ | |
| 112426 | ** If the expression uses functions (that might throw an exception) then |
| 112427 | ** guard them with an OP_Once opcode to ensure that the code is only executed |
| 112428 | ** 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. |
| 112430 | ** |
| 112431 | ** 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 |
| 112433 | ** store the value wherever it wants. The register where the expression |
| 112434 | ** is stored is returned. When regDest<0, two identical expressions might |
| 112435 | ** code to the same register, if they do not contain function calls and hence |
| 112436 | ** are factored out into the initialization section at the end of the |
| @@ -112441,10 +113086,11 @@ | |
| 112441 | Expr *pExpr, /* The expression to code when the VDBE initializes */ |
| 112442 | int regDest /* Store the value in this register */ |
| 112443 | ){ |
| 112444 | ExprList *p; |
| 112445 | assert( ConstFactorOk(pParse) ); |
| 112446 | p = pParse->pConstExpr; |
| 112447 | if( regDest<0 && p ){ |
| 112448 | struct ExprList_item *pItem; |
| 112449 | int i; |
| 112450 | for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){ |
| @@ -113725,10 +114371,16 @@ | |
| 113725 | x.db = pParse->db; |
| 113726 | x.pRef = pSrcList; |
| 113727 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 113728 | assert( ExprUseXList(pExpr) ); |
| 113729 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 113730 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 113731 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 113732 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 113733 | } |
| 113734 | #endif |
| @@ -113989,18 +114641,45 @@ | |
| 113989 | /* pExpr is original. Make a new entry in pAggInfo->aFunc[] |
| 113990 | */ |
| 113991 | u8 enc = ENC(pParse->db); |
| 113992 | i = addAggInfoFunc(pParse->db, pAggInfo); |
| 113993 | if( i>=0 ){ |
| 113994 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 113995 | pItem = &pAggInfo->aFunc[i]; |
| 113996 | pItem->pFExpr = pExpr; |
| 113997 | assert( ExprUseUToken(pExpr) ); |
| 113998 | pItem->pFunc = sqlite3FindFunction(pParse->db, |
| 113999 | pExpr->u.zToken, |
| 114000 | pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); |
| 114001 | if( pExpr->flags & EP_Distinct ){ |
| 114002 | pItem->iDistinct = pParse->nTab++; |
| 114003 | }else{ |
| 114004 | pItem->iDistinct = -1; |
| 114005 | } |
| 114006 | } |
| @@ -114632,18 +115311,23 @@ | |
| 114632 | renameReloadSchema(pParse, iDb, INITFLAG_AlterAdd); |
| 114633 | |
| 114634 | /* Verify that constraints are still satisfied */ |
| 114635 | if( pNew->pCheck!=0 |
| 114636 | || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) |
| 114637 | ){ |
| 114638 | sqlite3NestedParse(pParse, |
| 114639 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" |
| 114640 | " THEN raise(ABORT,'CHECK constraint failed')" |
| 114641 | " ELSE raise(ABORT,'NOT NULL constraint failed')" |
| 114642 | " END" |
| 114643 | " FROM pragma_quick_check(%Q,%Q)" |
| 114644 | " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", |
| 114645 | zTab, zDb |
| 114646 | ); |
| 114647 | } |
| 114648 | } |
| 114649 | } |
| @@ -119618,23 +120302,18 @@ | |
| 119618 | |
| 119619 | /* Initialize any AUTOINCREMENT data structures required. |
| 119620 | */ |
| 119621 | if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); |
| 119622 | |
| 119623 | /* Code constant expressions that where 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 | */ |
| 119630 | if( pParse->pConstExpr ){ |
| 119631 | ExprList *pEL = pParse->pConstExpr; |
| 119632 | pParse->okConstFactor = 0; |
| 119633 | for(i=0; i<pEL->nExpr; i++){ |
| 119634 | int iReg = pEL->a[i].u.iConstExprReg; |
| 119635 | sqlite3ExprCode(pParse, pEL->a[i].pExpr, iReg); |
| 119636 | } |
| 119637 | } |
| 119638 | |
| 119639 | if( pParse->bReturning ){ |
| 119640 | Returning *pRet = pParse->u1.pReturning; |
| @@ -122297,10 +122976,21 @@ | |
| 122297 | #endif |
| 122298 | |
| 122299 | /* Reparse everything to update our internal data structures */ |
| 122300 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 122301 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); |
| 122302 | } |
| 122303 | |
| 122304 | /* Add the table to the in-memory representation of the database. |
| 122305 | */ |
| 122306 | if( db->init.busy ){ |
| @@ -127899,11 +128589,12 @@ | |
| 127899 | unsigned char c = *pBlob; |
| 127900 | *(z++) = hexdigits[(c>>4)&0xf]; |
| 127901 | *(z++) = hexdigits[c&0xf]; |
| 127902 | } |
| 127903 | *z = 0; |
| 127904 | sqlite3_result_text(context, zHex, n*2, sqlite3_free); |
| 127905 | } |
| 127906 | } |
| 127907 | |
| 127908 | /* |
| 127909 | ** Buffer zStr contains nStr bytes of utf-8 encoded text. Return 1 if zStr |
| @@ -128192,10 +128883,85 @@ | |
| 128192 | sqlite3_free(azChar); |
| 128193 | } |
| 128194 | } |
| 128195 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); |
| 128196 | } |
| 128197 | |
| 128198 | |
| 128199 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 128200 | /* |
| 128201 | ** The "unknown" function is automatically substituted in place of |
| @@ -128614,10 +129380,11 @@ | |
| 128614 | minMaxValueFinalize(context, 0); |
| 128615 | } |
| 128616 | |
| 128617 | /* |
| 128618 | ** group_concat(EXPR, ?SEPARATOR?) |
| 128619 | ** |
| 128620 | ** The SEPARATOR goes before the EXPR string. This is tragic. The |
| 128621 | ** groupConcatInverse() implementation would have been easier if the |
| 128622 | ** SEPARATOR were appended after EXPR. And the order is undocumented, |
| 128623 | ** so we could change it, in theory. But the old behavior has been |
| @@ -129204,10 +129971,15 @@ | |
| 129204 | FUNCTION(upper, 1, 0, 0, upperFunc ), |
| 129205 | FUNCTION(lower, 1, 0, 0, lowerFunc ), |
| 129206 | FUNCTION(hex, 1, 0, 0, hexFunc ), |
| 129207 | FUNCTION(unhex, 1, 0, 0, unhexFunc ), |
| 129208 | FUNCTION(unhex, 2, 0, 0, unhexFunc ), |
| 129209 | INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), |
| 129210 | VFUNCTION(random, 0, 0, 0, randomFunc ), |
| 129211 | VFUNCTION(randomblob, 1, 0, 0, randomBlob ), |
| 129212 | FUNCTION(nullif, 2, 0, 1, nullifFunc ), |
| 129213 | DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ), |
| @@ -129232,10 +130004,12 @@ | |
| 129232 | WAGGREGATE(count, 1,0,0, countStep, |
| 129233 | countFinalize, countFinalize, countInverse, SQLITE_FUNC_ANYORDER ), |
| 129234 | WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep, |
| 129235 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 129236 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, |
| 129237 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 129238 | |
| 129239 | LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 129240 | #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 129241 | LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| @@ -130175,10 +130949,11 @@ | |
| 130175 | if( pTop->pTriggerPrg ){ |
| 130176 | Trigger *p = pTop->pTriggerPrg->pTrigger; |
| 130177 | if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) |
| 130178 | || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) |
| 130179 | ){ |
| 130180 | return 1; |
| 130181 | } |
| 130182 | } |
| 130183 | return 0; |
| 130184 | } |
| @@ -130369,10 +131144,12 @@ | |
| 130369 | if( regNew!=0 ){ |
| 130370 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1); |
| 130371 | } |
| 130372 | if( regOld!=0 ){ |
| 130373 | int eAction = pFKey->aAction[aChange!=0]; |
| 130374 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); |
| 130375 | /* If this is a deferred FK constraint, or a CASCADE or SET NULL |
| 130376 | ** action applies, then any foreign key violations caused by |
| 130377 | ** removing the parent key will be rectified by the action trigger. |
| 130378 | ** So do not set the "may-abort" flag in this case. |
| @@ -130484,11 +131261,15 @@ | |
| 130484 | } |
| 130485 | |
| 130486 | /* Check if any parent key columns are being modified. */ |
| 130487 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 130488 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 130489 | if( p->aAction[1]!=OE_None ) return 2; |
| 130490 | bHaveFK = 1; |
| 130491 | } |
| 130492 | } |
| 130493 | } |
| 130494 | } |
| @@ -130534,10 +131315,11 @@ | |
| 130534 | int action; /* One of OE_None, OE_Cascade etc. */ |
| 130535 | Trigger *pTrigger; /* Trigger definition to return */ |
| 130536 | int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ |
| 130537 | |
| 130538 | action = pFKey->aAction[iAction]; |
| 130539 | if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ |
| 130540 | return 0; |
| 130541 | } |
| 130542 | pTrigger = pFKey->apTrigger[iAction]; |
| 130543 | |
| @@ -135553,10 +136335,13 @@ | |
| 135553 | /* |
| 135554 | ** Enable or disable extension loading. Extension loading is disabled by |
| 135555 | ** default so as not to open security holes in older applications. |
| 135556 | */ |
| 135557 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
| 135558 | sqlite3_mutex_enter(db->mutex); |
| 135559 | if( onoff ){ |
| 135560 | db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; |
| 135561 | }else{ |
| 135562 | db->flags &= ~(u64)(SQLITE_LoadExtension|SQLITE_LoadExtFunc); |
| @@ -135602,10 +136387,13 @@ | |
| 135602 | */ |
| 135603 | SQLITE_API int sqlite3_auto_extension( |
| 135604 | void (*xInit)(void) |
| 135605 | ){ |
| 135606 | int rc = SQLITE_OK; |
| 135607 | #ifndef SQLITE_OMIT_AUTOINIT |
| 135608 | rc = sqlite3_initialize(); |
| 135609 | if( rc ){ |
| 135610 | return rc; |
| 135611 | }else |
| @@ -135654,10 +136442,13 @@ | |
| 135654 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MAIN); |
| 135655 | #endif |
| 135656 | int i; |
| 135657 | int n = 0; |
| 135658 | wsdAutoextInit; |
| 135659 | sqlite3_mutex_enter(mutex); |
| 135660 | for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ |
| 135661 | if( wsdAutoext.aExt[i]==xInit ){ |
| 135662 | wsdAutoext.nExt--; |
| 135663 | wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt]; |
| @@ -137523,11 +138314,15 @@ | |
| 137523 | mask &= ~(SQLITE_WriteSchema); |
| 137524 | } |
| 137525 | #endif |
| 137526 | |
| 137527 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 137528 | db->flags |= mask; |
| 137529 | }else{ |
| 137530 | db->flags &= ~mask; |
| 137531 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; |
| 137532 | if( (mask & SQLITE_WriteSchema)!=0 |
| 137533 | && sqlite3_stricmp(zRight, "reset")==0 |
| @@ -138156,12 +138951,33 @@ | |
| 138156 | int r1 = -1; |
| 138157 | int bStrict; /* True for a STRICT table */ |
| 138158 | int r2; /* Previous key for WITHOUT ROWID tables */ |
| 138159 | int mxCol; /* Maximum non-virtual column number */ |
| 138160 | |
| 138161 | if( !IsOrdinaryTable(pTab) ) continue; |
| 138162 | if( pObjTab && pObjTab!=pTab ) continue; |
| 138163 | if( isQuick || HasRowid(pTab) ){ |
| 138164 | pPk = 0; |
| 138165 | r2 = 0; |
| 138166 | }else{ |
| 138167 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| @@ -139283,11 +140099,12 @@ | |
| 139283 | 0, /* xFindFunction - function overloading */ |
| 139284 | 0, /* xRename - rename the table */ |
| 139285 | 0, /* xSavepoint */ |
| 139286 | 0, /* xRelease */ |
| 139287 | 0, /* xRollbackTo */ |
| 139288 | 0 /* xShadowName */ |
| 139289 | }; |
| 139290 | |
| 139291 | /* |
| 139292 | ** Check to see if zTabName is really the name of a pragma. If it is, |
| 139293 | ** then register an eponymous virtual table for that pragma and return |
| @@ -139907,12 +140724,10 @@ | |
| 139907 | assert( db->lookaside.bDisable >= pParse->disableLookaside ); |
| 139908 | db->lookaside.bDisable -= pParse->disableLookaside; |
| 139909 | db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; |
| 139910 | assert( pParse->db->pParse==pParse ); |
| 139911 | db->pParse = pParse->pOuterParse; |
| 139912 | pParse->db = 0; |
| 139913 | pParse->disableLookaside = 0; |
| 139914 | } |
| 139915 | |
| 139916 | /* |
| 139917 | ** Add a new cleanup operation to a Parser. The cleanup should happen when |
| 139918 | ** the parser object is destroyed. But, beware: the cleanup might happen |
| @@ -140846,10 +141661,11 @@ | |
| 140846 | if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){ |
| 140847 | ExprClearProperty(p, EP_CanBeNull); |
| 140848 | } |
| 140849 | if( p->op==TK_FUNCTION ){ |
| 140850 | assert( ExprUseXList(p) ); |
| 140851 | if( p->x.pList ){ |
| 140852 | int i; |
| 140853 | for(i=0; i<p->x.pList->nExpr; i++){ |
| 140854 | unsetJoinExpr(p->x.pList->a[i].pExpr, iTable, nullable); |
| 140855 | } |
| @@ -146506,10 +147322,11 @@ | |
| 146506 | ** expanded. */ |
| 146507 | int tableSeen = 0; /* Set to 1 when TABLE matches */ |
| 146508 | char *zTName = 0; /* text of name of TABLE */ |
| 146509 | int iErrOfst; |
| 146510 | if( pE->op==TK_DOT ){ |
| 146511 | assert( pE->pLeft!=0 ); |
| 146512 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 146513 | zTName = pE->pLeft->u.zToken; |
| 146514 | assert( ExprUseWOfst(pE->pLeft) ); |
| 146515 | iErrOfst = pE->pRight->w.iOfst; |
| @@ -146516,10 +147333,11 @@ | |
| 146516 | }else{ |
| 146517 | assert( ExprUseWOfst(pE) ); |
| 146518 | iErrOfst = pE->w.iOfst; |
| 146519 | } |
| 146520 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 146521 | Table *pTab = pFrom->pTab; /* Table for this data source */ |
| 146522 | ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ |
| 146523 | char *zTabName; /* AS name for this data source */ |
| 146524 | const char *zSchemaName = 0; /* Schema name for this data source */ |
| 146525 | int iDb; /* Schema index for this data src */ |
| @@ -146533,10 +147351,11 @@ | |
| 146533 | if( pFrom->fg.isNestedFrom ){ |
| 146534 | assert( pFrom->pSelect!=0 ); |
| 146535 | pNestedFrom = pFrom->pSelect->pEList; |
| 146536 | assert( pNestedFrom!=0 ); |
| 146537 | assert( pNestedFrom->nExpr==pTab->nCol ); |
| 146538 | }else{ |
| 146539 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 146540 | continue; |
| 146541 | } |
| 146542 | pNestedFrom = 0; |
| @@ -146563,37 +147382,52 @@ | |
| 146563 | } |
| 146564 | } |
| 146565 | }else{ |
| 146566 | pUsing = 0; |
| 146567 | } |
| 146568 | for(j=0; j<pTab->nCol; j++){ |
| 146569 | char *zName = pTab->aCol[j].zCnName; |
| 146570 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 146571 | |
| 146572 | assert( zName ); |
| 146573 | if( zTName |
| 146574 | && pNestedFrom |
| 146575 | && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0)==0 |
| 146576 | ){ |
| 146577 | continue; |
| 146578 | } |
| 146579 | |
| 146580 | /* If a column is marked as 'hidden', omit it from the expanded |
| 146581 | ** result-set list unless the SELECT has the SF_IncludeHidden |
| 146582 | ** bit set. |
| 146583 | */ |
| 146584 | if( (p->selFlags & SF_IncludeHidden)==0 |
| 146585 | && IsHiddenColumn(&pTab->aCol[j]) |
| 146586 | ){ |
| 146587 | continue; |
| 146588 | } |
| 146589 | if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 |
| 146590 | && zTName==0 |
| 146591 | && (selFlags & (SF_NestedFrom))==0 |
| 146592 | ){ |
| 146593 | continue; |
| 146594 | } |
| 146595 | tableSeen = 1; |
| 146596 | |
| 146597 | if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ |
| 146598 | if( pFrom->fg.isUsing |
| 146599 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0 |
| @@ -146639,15 +147473,15 @@ | |
| 146639 | }else{ |
| 146640 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 146641 | zSchemaName, zTabName, zName); |
| 146642 | testcase( pX->zEName==0 ); |
| 146643 | } |
| 146644 | pX->fg.eEName = ENAME_TAB; |
| 146645 | if( (pFrom->fg.isUsing |
| 146646 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) |
| 146647 | || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) |
| 146648 | || (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 |
| 146649 | ){ |
| 146650 | pX->fg.bNoExpand = 1; |
| 146651 | } |
| 146652 | }else if( longNames ){ |
| 146653 | pX->zEName = sqlite3MPrintf(db, "%s.%s", zTabName, zName); |
| @@ -146864,12 +147698,18 @@ | |
| 146864 | assert( pAggInfo!=0 ); |
| 146865 | assert( pAggInfo->iFirstReg==0 ); |
| 146866 | pNC->ncFlags |= NC_InAggFunc; |
| 146867 | for(i=0; i<pAggInfo->nFunc; i++){ |
| 146868 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; |
| 146869 | assert( ExprUseXList(pExpr) ); |
| 146870 | sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); |
| 146871 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 146872 | assert( !IsWindowFunc(pExpr) ); |
| 146873 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 146874 | sqlite3ExprAnalyzeAggregates(pNC, pExpr->y.pWin->pFilter); |
| 146875 | } |
| @@ -147020,10 +147860,36 @@ | |
| 147020 | pFunc->iDistinct, 0, 0, (char*)pKeyInfo, P4_KEYINFO); |
| 147021 | ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(DISTINCT)", |
| 147022 | pFunc->pFunc->zName)); |
| 147023 | } |
| 147024 | } |
| 147025 | } |
| 147026 | } |
| 147027 | |
| 147028 | /* |
| 147029 | ** Invoke the OP_AggFinalize opcode for every aggregate function |
| @@ -147035,25 +147901,65 @@ | |
| 147035 | struct AggInfo_func *pF; |
| 147036 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 147037 | ExprList *pList; |
| 147038 | assert( ExprUseXList(pF->pFExpr) ); |
| 147039 | pList = pF->pFExpr->x.pList; |
| 147040 | sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), |
| 147041 | pList ? pList->nExpr : 0); |
| 147042 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 147043 | } |
| 147044 | } |
| 147045 | |
| 147046 | |
| 147047 | /* |
| 147048 | ** Generate code that will update the accumulator memory cells for an |
| 147049 | ** aggregate based on the current cursor position. |
| 147050 | ** |
| 147051 | ** If regAcc is non-zero and there are no min() or max() aggregates |
| 147052 | ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator |
| 147053 | ** registers if register regAcc contains 0. The caller will take care |
| 147054 | ** of setting and clearing regAcc. |
| 147055 | */ |
| 147056 | static void updateAccumulator( |
| 147057 | Parse *pParse, |
| 147058 | int regAcc, |
| 147059 | AggInfo *pAggInfo, |
| @@ -147071,10 +147977,11 @@ | |
| 147071 | pAggInfo->directMode = 1; |
| 147072 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 147073 | int nArg; |
| 147074 | int addrNext = 0; |
| 147075 | int regAgg; |
| 147076 | ExprList *pList; |
| 147077 | assert( ExprUseXList(pF->pFExpr) ); |
| 147078 | assert( !IsWindowFunc(pF->pFExpr) ); |
| 147079 | pList = pF->pFExpr->x.pList; |
| 147080 | if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){ |
| @@ -147097,11 +148004,43 @@ | |
| 147097 | sqlite3VdbeAddOp2(v, OP_Copy, regAcc, regHit); |
| 147098 | } |
| 147099 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 147100 | sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); |
| 147101 | } |
| 147102 | if( pList ){ |
| 147103 | nArg = pList->nExpr; |
| 147104 | regAgg = sqlite3GetTempRange(pParse, nArg); |
| 147105 | sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); |
| 147106 | }else{ |
| 147107 | nArg = 0; |
| @@ -147112,28 +148051,39 @@ | |
| 147112 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 147113 | } |
| 147114 | pF->iDistinct = codeDistinct(pParse, eDistinctType, |
| 147115 | pF->iDistinct, addrNext, pList, regAgg); |
| 147116 | } |
| 147117 | if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 147118 | CollSeq *pColl = 0; |
| 147119 | struct ExprList_item *pItem; |
| 147120 | int j; |
| 147121 | assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ |
| 147122 | for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ |
| 147123 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); |
| 147124 | } |
| 147125 | if( !pColl ){ |
| 147126 | pColl = pParse->db->pDfltColl; |
| 147127 | } |
| 147128 | if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; |
| 147129 | sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ); |
| 147130 | } |
| 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 ){ |
| 147136 | sqlite3VdbeResolveLabel(v, addrNext); |
| 147137 | } |
| 147138 | } |
| 147139 | if( regHit==0 && pAggInfo->nAccumulator ){ |
| @@ -149189,10 +150139,14 @@ | |
| 149189 | goto trigger_orphan_error; |
| 149190 | } |
| 149191 | if( IsVirtual(pTab) ){ |
| 149192 | sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); |
| 149193 | goto trigger_orphan_error; |
| 149194 | } |
| 149195 | |
| 149196 | /* Check that the trigger name is not reserved and that no trigger of the |
| 149197 | ** specified name exists */ |
| 149198 | zName = sqlite3NameFromToken(db, pName); |
| @@ -153413,11 +154367,11 @@ | |
| 153413 | } |
| 153414 | #endif |
| 153415 | sqlite3_mutex_enter(db->mutex); |
| 153416 | pCtx = db->pVtabCtx; |
| 153417 | if( !pCtx || pCtx->bDeclared ){ |
| 153418 | sqlite3Error(db, SQLITE_MISUSE); |
| 153419 | sqlite3_mutex_leave(db->mutex); |
| 153420 | return SQLITE_MISUSE_BKPT; |
| 153421 | } |
| 153422 | pTab = pCtx->pTab; |
| 153423 | assert( IsVirtual(pTab) ); |
| @@ -154604,11 +155558,11 @@ | |
| 154604 | #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ |
| 154605 | #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ |
| 154606 | #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ |
| 154607 | #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ |
| 154608 | #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ |
| 154609 | #define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */ |
| 154610 | #define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ |
| 154611 | |
| 154612 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| 154613 | |
| 154614 | /************** End of whereInt.h ********************************************/ |
| @@ -160399,17 +161353,21 @@ | |
| 160399 | Parse *pParse = pWInfo->pParse; /* Parsing context */ |
| 160400 | Vdbe *v = pParse->pVdbe; /* VDBE under construction */ |
| 160401 | WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ |
| 160402 | int iCur; /* Cursor for table getting the filter */ |
| 160403 | IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ |
| 160404 | |
| 160405 | saved_pIdxEpr = pParse->pIdxEpr; |
| 160406 | pParse->pIdxEpr = 0; |
| 160407 | |
| 160408 | assert( pLoop!=0 ); |
| 160409 | assert( v!=0 ); |
| 160410 | assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); |
| 160411 | |
| 160412 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 160413 | do{ |
| 160414 | const SrcList *pTabList; |
| 160415 | const SrcItem *pItem; |
| @@ -160495,10 +161453,11 @@ | |
| 160495 | } |
| 160496 | } |
| 160497 | }while( iLevel < pWInfo->nLevel ); |
| 160498 | sqlite3VdbeJumpHere(v, addrOnce); |
| 160499 | pParse->pIdxEpr = saved_pIdxEpr; |
| 160500 | } |
| 160501 | |
| 160502 | |
| 160503 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 160504 | /* |
| @@ -162753,10 +163712,104 @@ | |
| 162753 | }else{ |
| 162754 | rc = WHERE_IDX_ONLY; |
| 162755 | } |
| 162756 | return rc; |
| 162757 | } |
| 162758 | |
| 162759 | /* |
| 162760 | ** 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 |
| 162762 | ** a b-tree table, not a virtual table. |
| @@ -162957,13 +164010,10 @@ | |
| 162957 | #ifdef SQLITE_ENABLE_STAT4 |
| 162958 | pNew->rRun = rSize + 16 - 2*((pTab->tabFlags & TF_HasStat4)!=0); |
| 162959 | #else |
| 162960 | pNew->rRun = rSize + 16; |
| 162961 | #endif |
| 162962 | if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){ |
| 162963 | pNew->wsFlags |= WHERE_VIEWSCAN; |
| 162964 | } |
| 162965 | ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 162966 | whereLoopOutputAdjust(pWC, pNew, rSize); |
| 162967 | rc = whereLoopInsert(pBuilder, pNew); |
| 162968 | pNew->nOut = rSize; |
| 162969 | if( rc ) break; |
| @@ -162972,10 +164022,15 @@ | |
| 162972 | if( pProbe->isCovering ){ |
| 162973 | m = 0; |
| 162974 | pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; |
| 162975 | }else{ |
| 162976 | m = pSrc->colUsed & pProbe->colNotIdxed; |
| 162977 | pNew->wsFlags = WHERE_INDEXED; |
| 162978 | if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ |
| 162979 | u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); |
| 162980 | if( isCov==0 ){ |
| 162981 | WHERETRACE(0x200, |
| @@ -163354,11 +164409,11 @@ | |
| 163354 | ){ |
| 163355 | HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 163356 | sqlite3_value *pVal = 0; |
| 163357 | int rc = SQLITE_OK; |
| 163358 | if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ |
| 163359 | rc = SQLITE_MISUSE; /* EV: R-30545-25046 */ |
| 163360 | }else{ |
| 163361 | if( pH->aRhs[iCons]==0 ){ |
| 163362 | WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; |
| 163363 | rc = sqlite3ValueFromExpr( |
| 163364 | pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db), |
| @@ -164378,18 +165433,10 @@ | |
| 164378 | }else{ |
| 164379 | rCost = rUnsorted; |
| 164380 | rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ |
| 164381 | } |
| 164382 | |
| 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 |
| 164392 | ** mxChoice best-so-far paths. |
| 164393 | ** |
| 164394 | ** First look for an existing path among best-so-far paths |
| 164395 | ** that covers the same set of loops and has the same isOrdered |
| @@ -164935,24 +165982,10 @@ | |
| 164935 | } |
| 164936 | nSearch += pLoop->nOut; |
| 164937 | } |
| 164938 | } |
| 164939 | |
| 164940 | /* |
| 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. |
| 164956 | ** 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 |
| 164958 | ** table. |
| @@ -165010,11 +166043,12 @@ | |
| 165010 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 165011 | p->zIdxName = pIdx->zName; |
| 165012 | #endif |
| 165013 | pParse->pIdxEpr = p; |
| 165014 | if( p->pIENext==0 ){ |
| 165015 | sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse); |
| 165016 | } |
| 165017 | } |
| 165018 | } |
| 165019 | |
| 165020 | /* |
| @@ -165400,10 +166434,20 @@ | |
| 165400 | if( db->mallocFailed ) goto whereBeginError; |
| 165401 | if( pWInfo->pOrderBy ){ |
| 165402 | wherePathSolver(pWInfo, pWInfo->nRowOut+1); |
| 165403 | if( db->mallocFailed ) goto whereBeginError; |
| 165404 | } |
| 165405 | } |
| 165406 | assert( pWInfo->pTabList!=0 ); |
| 165407 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ |
| 165408 | whereReverseScanOrder(pWInfo); |
| 165409 | } |
| @@ -165611,10 +166655,15 @@ | |
| 165611 | op = OP_ReopenIdx; |
| 165612 | }else{ |
| 165613 | iIndexCur = pParse->nTab++; |
| 165614 | if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ |
| 165615 | whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); |
| 165616 | } |
| 165617 | } |
| 165618 | pLevel->iIdxCur = iIndexCur; |
| 165619 | assert( pIx!=0 ); |
| 165620 | assert( pIx->pSchema==pTab->pSchema ); |
| @@ -167428,12 +168477,13 @@ | |
| 167428 | */ |
| 167429 | SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ |
| 167430 | if( p ){ |
| 167431 | assert( p->op==TK_FUNCTION ); |
| 167432 | assert( pWin ); |
| 167433 | p->y.pWin = pWin; |
| 167434 | ExprSetProperty(p, EP_WinFunc); |
| 167435 | pWin->pOwner = p; |
| 167436 | if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ |
| 167437 | sqlite3ErrorMsg(pParse, |
| 167438 | "DISTINCT is not supported for window functions" |
| 167439 | ); |
| @@ -169731,22 +170781,22 @@ | |
| 169731 | #define sqlite3ParserCTX_PDECL ,Parse *pParse |
| 169732 | #define sqlite3ParserCTX_PARAM ,pParse |
| 169733 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 169734 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 169735 | #define YYFALLBACK 1 |
| 169736 | #define YYNSTATE 575 |
| 169737 | #define YYNRULE 403 |
| 169738 | #define YYNRULE_WITH_ACTION 338 |
| 169739 | #define YYNTOKEN 185 |
| 169740 | #define YY_MAX_SHIFT 574 |
| 169741 | #define YY_MIN_SHIFTREDUCE 833 |
| 169742 | #define YY_MAX_SHIFTREDUCE 1235 |
| 169743 | #define YY_ERROR_ACTION 1236 |
| 169744 | #define YY_ACCEPT_ACTION 1237 |
| 169745 | #define YY_NO_ACTION 1238 |
| 169746 | #define YY_MIN_REDUCE 1239 |
| 169747 | #define YY_MAX_REDUCE 1641 |
| 169748 | /************* End control #defines *******************************************/ |
| 169749 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 169750 | |
| 169751 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 169752 | ** otherwise. |
| @@ -169809,222 +170859,222 @@ | |
| 169809 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 169810 | ** shifting non-terminals after a reduce. |
| 169811 | ** yy_default[] Default action for each state. |
| 169812 | ** |
| 169813 | *********** Begin parsing tables **********************************************/ |
| 169814 | #define YY_ACTTAB_COUNT (2096) |
| 169815 | static const YYACTIONTYPE yy_action[] = { |
| 169816 | /* 0 */ 568, 208, 568, 118, 115, 229, 568, 118, 115, 229, |
| 169817 | /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, |
| 169818 | /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, |
| 169819 | /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, |
| 169820 | /* 40 */ 397, 71, 71, 125, 126, 80, 1210, 1210, 1047, 1050, |
| 169821 | /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, |
| 169822 | /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, |
| 169823 | /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, |
| 169824 | /* 80 */ 417, 523, 142, 125, 126, 80, 1210, 1210, 1047, 1050, |
| 169825 | /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, |
| 169826 | /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, |
| 169827 | /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, |
| 169828 | /* 120 */ 442, 1559, 376, 1561, 1186, 375, 1157, 565, 1157, 565, |
| 169829 | /* 130 */ 409, 1559, 537, 259, 226, 444, 101, 145, 449, 316, |
| 169830 | /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, |
| 169831 | /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1210, 1210, 1047, |
| 169832 | /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, |
| 169833 | /* 170 */ 294, 1186, 339, 448, 120, 120, 120, 119, 116, 444, |
| 169834 | /* 180 */ 127, 1186, 1187, 1186, 148, 441, 440, 568, 119, 116, |
| 169835 | /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, |
| 169836 | /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, |
| 169837 | /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, |
| 169838 | /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1186, 1187, |
| 169839 | /* 230 */ 1186, 149, 1218, 409, 1218, 124, 124, 124, 124, 122, |
| 169840 | /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, |
| 169841 | /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, |
| 169842 | /* 260 */ 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, |
| 169843 | /* 270 */ 124, 124, 1275, 522, 222, 1186, 568, 409, 224, 514, |
| 169844 | /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, |
| 169845 | /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1186, 133, |
| 169846 | /* 300 */ 133, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, |
| 169847 | /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, |
| 169848 | /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, |
| 169849 | /* 330 */ 1186, 373, 1186, 1187, 1186, 252, 1429, 399, 504, 501, |
| 169850 | /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, |
| 169851 | /* 350 */ 460, 328, 360, 394, 1231, 1186, 1187, 1186, 563, 568, |
| 169852 | /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, |
| 169853 | /* 370 */ 116, 444, 284, 284, 369, 1572, 1598, 441, 440, 154, |
| 169854 | /* 380 */ 409, 445, 71, 71, 1282, 565, 1215, 1186, 1187, 1186, |
| 169855 | /* 390 */ 85, 1217, 271, 557, 543, 515, 515, 568, 98, 1216, |
| 169856 | /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1210, 1210, 1047, |
| 169857 | /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, |
| 169858 | /* 420 */ 13, 13, 1024, 507, 1218, 1186, 1218, 549, 109, 109, |
| 169859 | /* 430 */ 222, 568, 1232, 175, 568, 427, 110, 197, 445, 569, |
| 169860 | /* 440 */ 445, 430, 1546, 1014, 325, 551, 1186, 270, 287, 368, |
| 169861 | /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, |
| 169862 | /* 460 */ 316, 559, 1604, 122, 122, 122, 122, 121, 121, 120, |
| 169863 | /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, |
| 169864 | /* 480 */ 284, 284, 1186, 1187, 1186, 1152, 568, 1603, 409, 899, |
| 169865 | /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1152, 516, |
| 169866 | /* 500 */ 413, 1152, 552, 1186, 1187, 1186, 568, 544, 544, 51, |
| 169867 | /* 510 */ 51, 214, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, |
| 169868 | /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1186, 474, 135, |
| 169869 | /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, |
| 169870 | /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 541, |
| 169871 | /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1210, 1210, |
| 169872 | /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 169873 | /* 570 */ 1548, 122, 122, 122, 122, 121, 121, 120, 120, 120, |
| 169874 | /* 580 */ 119, 116, 444, 485, 1186, 1187, 1186, 482, 281, 1263, |
| 169875 | /* 590 */ 955, 252, 1186, 373, 504, 501, 500, 1186, 340, 570, |
| 169876 | /* 600 */ 1186, 570, 409, 292, 499, 955, 874, 191, 480, 316, |
| 169877 | /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, |
| 169878 | /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, |
| 169879 | /* 630 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169880 | /* 640 */ 124, 409, 394, 1132, 1186, 867, 100, 284, 284, 1186, |
| 169881 | /* 650 */ 1187, 1186, 373, 1089, 1186, 1187, 1186, 1186, 1187, 1186, |
| 169882 | /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1210, 1210, |
| 169883 | /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 169884 | /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, |
| 169885 | /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1152, 228, 1186, |
| 169886 | /* 700 */ 157, 1186, 1187, 1186, 1547, 13, 13, 301, 955, 1226, |
| 169887 | /* 710 */ 1152, 153, 409, 1152, 373, 1575, 1170, 5, 369, 1572, |
| 169888 | /* 720 */ 429, 1232, 3, 955, 122, 122, 122, 122, 121, 121, |
| 169889 | /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, |
| 169890 | /* 740 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169891 | /* 750 */ 124, 409, 208, 567, 1186, 1025, 1186, 1187, 1186, 1186, |
| 169892 | /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, |
| 169893 | /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1210, 1210, |
| 169894 | /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 169895 | /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, |
| 169896 | /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, |
| 169897 | /* 810 */ 528, 1186, 1187, 1186, 13, 13, 1186, 1187, 1186, 1293, |
| 169898 | /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, |
| 169899 | /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, |
| 169900 | /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, |
| 169901 | /* 850 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169902 | /* 860 */ 124, 409, 227, 1069, 1152, 284, 284, 419, 312, 278, |
| 169903 | /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1152, 565, 568, |
| 169904 | /* 880 */ 1152, 1189, 565, 1592, 565, 125, 126, 80, 1210, 1210, |
| 169905 | /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 169906 | /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, |
| 169907 | /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, |
| 169908 | /* 920 */ 1578, 574, 2, 1241, 838, 839, 840, 1554, 317, 1205, |
| 169909 | /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1189, |
| 169910 | /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, |
| 169911 | /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, |
| 169912 | /* 960 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169913 | /* 970 */ 124, 568, 284, 284, 568, 1206, 409, 573, 313, 1241, |
| 169914 | /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1635, |
| 169915 | /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, |
| 169916 | /* 1000 */ 1321, 104, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, |
| 169917 | /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, |
| 169918 | /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, |
| 169919 | /* 1030 */ 428, 448, 1519, 1206, 439, 284, 284, 1483, 1348, 311, |
| 169920 | /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, |
| 169921 | /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, |
| 169922 | /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, |
| 169923 | /* 1070 */ 444, 1015, 107, 71, 71, 1014, 13, 13, 910, 568, |
| 169924 | /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, |
| 169925 | /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, |
| 169926 | /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, |
| 169927 | /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1210, |
| 169928 | /* 1120 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169929 | /* 1130 */ 124, 347, 409, 862, 1528, 1206, 125, 126, 80, 1210, |
| 169930 | /* 1140 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169931 | /* 1150 */ 124, 1133, 1633, 474, 1633, 371, 125, 114, 80, 1210, |
| 169932 | /* 1160 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 169933 | /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, |
| 169934 | /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, |
| 169935 | /* 1190 */ 1290, 862, 464, 1206, 436, 122, 122, 122, 122, 121, |
| 169936 | /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1634, |
| 169937 | /* 1210 */ 539, 1634, 15, 15, 890, 122, 122, 122, 122, 121, |
| 169938 | /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, |
| 169939 | /* 1230 */ 1131, 1415, 1552, 1553, 1327, 409, 6, 6, 1163, 1264, |
| 169940 | /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, |
| 169941 | /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, |
| 169942 | /* 1260 */ 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, |
| 169943 | /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1186, 1415, |
| 169944 | /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1551, 847, |
| 169945 | /* 1290 */ 1163, 407, 6, 568, 321, 1152, 470, 44, 44, 1550, |
| 169946 | /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1152, 431, |
| 169947 | /* 1310 */ 568, 1152, 322, 17, 487, 1111, 58, 58, 122, 122, |
| 169948 | /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, |
| 169949 | /* 1330 */ 1112, 216, 481, 59, 59, 1186, 1187, 1186, 111, 560, |
| 169950 | /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, |
| 169951 | /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, |
| 169952 | /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, |
| 169953 | /* 1370 */ 235, 61, 61, 568, 414, 568, 414, 568, 445, 62, |
| 169954 | /* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49, |
| 169955 | /* 1390 */ 557, 568, 359, 568, 100, 486, 50, 50, 63, 63, |
| 169956 | /* 1400 */ 64, 64, 561, 415, 535, 410, 568, 1024, 568, 534, |
| 169957 | /* 1410 */ 316, 559, 316, 559, 65, 65, 14, 14, 568, 1024, |
| 169958 | /* 1420 */ 568, 512, 930, 870, 1015, 109, 109, 929, 1014, 66, |
| 169959 | /* 1430 */ 66, 131, 131, 110, 451, 445, 569, 445, 416, 177, |
| 169960 | /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, |
| 169961 | /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, |
| 169962 | /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, |
| 169963 | /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1577, 1174, 447, |
| 169964 | /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, |
| 169965 | /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, |
| 169966 | /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, |
| 169967 | /* 1510 */ 111, 560, 527, 4, 563, 53, 53, 322, 568, 163, |
| 169968 | /* 1520 */ 163, 568, 337, 468, 164, 164, 333, 563, 76, 76, |
| 169969 | /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, |
| 169970 | /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, |
| 169971 | /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, |
| 169972 | /* 1560 */ 161, 1566, 557, 535, 568, 319, 568, 348, 536, 1007, |
| 169973 | /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, |
| 169974 | /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, |
| 169975 | /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, |
| 169976 | /* 1600 */ 162, 162, 156, 156, 568, 110, 1076, 445, 569, 445, |
| 169977 | /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, |
| 169978 | /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, |
| 169979 | /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, |
| 169980 | /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1174, |
| 169981 | /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, |
| 169982 | /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, |
| 169983 | /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, |
| 169984 | /* 1680 */ 323, 111, 560, 927, 4, 113, 77, 77, 322, 74, |
| 169985 | /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, |
| 169986 | /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, |
| 169987 | /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, |
| 169988 | /* 1720 */ 1251, 445, 1585, 1339, 308, 276, 168, 309, 11, 141, |
| 169989 | /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, |
| 169990 | /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, |
| 169991 | /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, |
| 169992 | /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, |
| 169993 | /* 1770 */ 204, 1588, 1226, 558, 265, 218, 110, 205, 445, 569, |
| 169994 | /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, |
| 169995 | /* 1790 */ 1016, 1017, 27, 230, 1525, 1223, 79, 560, 85, 4, |
| 169996 | /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, |
| 169997 | /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, |
| 169998 | /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, |
| 169999 | /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, |
| 170000 | /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, |
| 170001 | /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, |
| 170002 | /* 1860 */ 1307, 1300, 93, 1602, 881, 1601, 224, 404, 434, 520, |
| 170003 | /* 1870 */ 263, 435, 1571, 563, 1279, 1278, 364, 1024, 306, 1277, |
| 170004 | /* 1880 */ 264, 1600, 1557, 109, 109, 370, 1299, 307, 1556, 438, |
| 170005 | /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, |
| 170006 | /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, |
| 170007 | /* 1910 */ 1180, 530, 272, 274, 379, 210, 1331, 547, 385, 386, |
| 170008 | /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, |
| 170009 | /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, |
| 170010 | /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, |
| 170011 | /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, |
| 170012 | /* 1960 */ 326, 180, 169, 1205, 182, 334, 238, 913, 241, 1100, |
| 170013 | /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, |
| 170014 | /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, |
| 170015 | /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1220, 489, |
| 170016 | /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, |
| 170017 | /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, |
| 170018 | /* 2020 */ 513, 39, 95, 1168, 160, 1053, 964, 1139, 96, 174, |
| 170019 | /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1158, 1154, 260, |
| 170020 | /* 2040 */ 21, 22, 23, 1156, 1162, 1161, 1143, 24, 33, 25, |
| 170021 | /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, |
| 170022 | /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, |
| 170023 | /* 2070 */ 861, 112, 29, 564, 1176, 1175, 268, 176, 143, 923, |
| 170024 | /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, |
| 170025 | /* 2090 */ 1238, 1238, 1238, 1238, 269, 1593, |
| 170026 | }; |
| 170027 | static const YYCODETYPE yy_lookahead[] = { |
| 170028 | /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, |
| 170029 | /* 10 */ 193, 223, 219, 225, 206, 210, 211, 212, 193, 19, |
| 170030 | /* 20 */ 219, 233, 216, 216, 217, 216, 217, 193, 295, 216, |
| @@ -170099,11 +171149,11 @@ | |
| 170099 | /* 710 */ 89, 241, 19, 92, 193, 193, 23, 22, 311, 312, |
| 170100 | /* 720 */ 231, 101, 22, 143, 102, 103, 104, 105, 106, 107, |
| 170101 | /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170102 | /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170103 | /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, |
| 170104 | /* 760 */ 201, 21, 241, 304, 22, 206, 127, 128, 129, 193, |
| 170105 | /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, |
| 170106 | /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 170107 | /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, |
| 170108 | /* 800 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 193, |
| 170109 | /* 810 */ 193, 116, 117, 118, 216, 217, 116, 117, 118, 226, |
| @@ -170110,133 +171160,133 @@ | |
| 170110 | /* 820 */ 80, 193, 19, 235, 236, 304, 23, 211, 212, 231, |
| 170111 | /* 830 */ 204, 216, 217, 205, 102, 103, 104, 105, 106, 107, |
| 170112 | /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170113 | /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170114 | /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, |
| 170115 | /* 870 */ 240, 239, 240, 193, 106, 107, 193, 89, 252, 193, |
| 170116 | /* 880 */ 92, 59, 252, 141, 252, 43, 44, 45, 46, 47, |
| 170117 | /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 170118 | /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, |
| 170119 | /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 16, |
| 170120 | /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 25, |
| 170121 | /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, |
| 170122 | /* 940 */ 24, 216, 217, 263, 102, 103, 104, 105, 106, 107, |
| 170123 | /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 170124 | /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170125 | /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, |
| 170126 | /* 980 */ 77, 226, 79, 193, 195, 252, 197, 193, 19, 301, |
| 170127 | /* 990 */ 302, 193, 193, 204, 216, 217, 226, 216, 217, 266, |
| 170128 | /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, |
| 170129 | /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, |
| 170130 | /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, |
| 170131 | /* 1030 */ 232, 298, 238, 117, 253, 239, 240, 238, 259, 260, |
| 170132 | /* 1040 */ 193, 252, 27, 31, 193, 193, 142, 204, 252, 193, |
| 170133 | /* 1050 */ 193, 39, 262, 193, 100, 266, 278, 42, 204, 102, |
| 170134 | /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 170135 | /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, |
| 170136 | /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 238, |
| 170137 | /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, |
| 170138 | /* 1100 */ 24, 193, 216, 217, 216, 217, 252, 153, 154, 155, |
| 170139 | /* 1110 */ 253, 16, 19, 144, 213, 268, 43, 44, 45, 46, |
| 170140 | /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170141 | /* 1130 */ 57, 238, 19, 59, 193, 59, 43, 44, 45, 46, |
| 170142 | /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170143 | /* 1150 */ 57, 22, 23, 193, 25, 193, 43, 44, 45, 46, |
| 170144 | /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 170145 | /* 1170 */ 57, 284, 77, 193, 79, 102, 103, 104, 105, 106, |
| 170146 | /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 193, 193, |
| 170147 | /* 1190 */ 193, 117, 291, 117, 232, 102, 103, 104, 105, 106, |
| 170148 | /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 22, 23, |
| 170149 | /* 1210 */ 66, 25, 216, 217, 35, 102, 103, 104, 105, 106, |
| 170150 | /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 268, 85, |
| 170151 | /* 1230 */ 101, 193, 309, 309, 240, 19, 313, 313, 94, 208, |
| 170152 | /* 1240 */ 209, 193, 239, 240, 193, 66, 252, 19, 268, 244, |
| 170153 | /* 1250 */ 216, 217, 193, 74, 213, 252, 161, 19, 263, 254, |
| 170154 | /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 170155 | /* 1270 */ 54, 55, 56, 57, 193, 216, 217, 5, 59, 193, |
| 170156 | /* 1280 */ 19, 244, 10, 11, 12, 13, 14, 101, 309, 17, |
| 170157 | /* 1290 */ 146, 254, 313, 193, 193, 76, 115, 216, 217, 309, |
| 170158 | /* 1300 */ 12, 263, 30, 313, 32, 46, 87, 46, 89, 130, |
| 170159 | /* 1310 */ 193, 92, 40, 22, 263, 27, 216, 217, 102, 103, |
| 170160 | /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 170161 | /* 1330 */ 42, 150, 291, 216, 217, 116, 117, 118, 19, 20, |
| 170162 | /* 1340 */ 193, 22, 70, 260, 116, 193, 24, 264, 193, 263, |
| 170163 | /* 1350 */ 78, 63, 61, 81, 116, 36, 193, 260, 193, 29, |
| 170164 | /* 1360 */ 193, 264, 193, 33, 145, 193, 59, 48, 216, 217, |
| 170165 | /* 1370 */ 98, 216, 217, 193, 115, 193, 115, 193, 59, 216, |
| 170166 | /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 255, 216, 217, |
| 170167 | /* 1390 */ 71, 193, 131, 193, 25, 65, 216, 217, 216, 217, |
| 170168 | /* 1400 */ 216, 217, 208, 209, 85, 133, 193, 100, 193, 90, |
| 170169 | /* 1410 */ 138, 139, 138, 139, 216, 217, 216, 217, 193, 100, |
| 170170 | /* 1420 */ 193, 108, 135, 116, 117, 106, 107, 140, 121, 216, |
| 170171 | /* 1430 */ 217, 216, 217, 114, 162, 116, 117, 118, 299, 300, |
| 170172 | /* 1440 */ 121, 216, 217, 216, 217, 193, 244, 193, 135, 244, |
| 170173 | /* 1450 */ 193, 256, 257, 140, 244, 193, 254, 193, 193, 254, |
| 170174 | /* 1460 */ 153, 154, 155, 141, 254, 149, 150, 258, 216, 217, |
| 170175 | /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, |
| 170176 | /* 1480 */ 216, 217, 5, 115, 158, 193, 160, 10, 11, 12, |
| 170177 | /* 1490 */ 13, 14, 193, 59, 17, 126, 193, 19, 20, 129, |
| 170178 | /* 1500 */ 22, 193, 22, 22, 24, 193, 23, 30, 25, 32, |
| 170179 | /* 1510 */ 19, 20, 144, 22, 36, 216, 217, 40, 193, 216, |
| 170180 | /* 1520 */ 217, 193, 152, 129, 216, 217, 193, 36, 216, 217, |
| 170181 | /* 1530 */ 193, 99, 193, 193, 53, 193, 193, 59, 23, 193, |
| 170182 | /* 1540 */ 25, 216, 217, 193, 216, 217, 152, 70, 59, 71, |
| 170183 | /* 1550 */ 59, 117, 193, 216, 217, 78, 216, 217, 81, 216, |
| 170184 | /* 1560 */ 217, 318, 71, 85, 193, 133, 193, 193, 90, 23, |
| 170185 | /* 1570 */ 23, 25, 25, 120, 121, 98, 85, 193, 100, 193, |
| 170186 | /* 1580 */ 23, 90, 25, 121, 106, 107, 19, 216, 217, 216, |
| 170187 | /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, |
| 170188 | /* 1600 */ 216, 217, 216, 217, 193, 114, 117, 116, 117, 118, |
| 170189 | /* 1610 */ 133, 193, 121, 193, 193, 138, 139, 193, 23, 193, |
| 170190 | /* 1620 */ 25, 23, 23, 25, 25, 7, 8, 216, 217, 193, |
| 170191 | /* 1630 */ 193, 153, 154, 155, 156, 157, 216, 217, 193, 162, |
| 170192 | /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, |
| 170193 | /* 1650 */ 2, 193, 193, 5, 19, 20, 59, 22, 10, 11, |
| 170194 | /* 1660 */ 12, 13, 14, 193, 97, 17, 193, 23, 193, 25, |
| 170195 | /* 1670 */ 288, 36, 193, 242, 216, 217, 236, 23, 30, 25, |
| 170196 | /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, |
| 170197 | /* 1690 */ 217, 216, 217, 193, 59, 216, 217, 193, 36, 83, |
| 170198 | /* 1700 */ 84, 153, 153, 155, 155, 23, 71, 25, 23, 193, |
| 170199 | /* 1710 */ 25, 193, 193, 193, 117, 193, 193, 193, 70, 193, |
| 170200 | /* 1720 */ 193, 59, 193, 255, 255, 287, 78, 255, 243, 81, |
| 170201 | /* 1730 */ 191, 255, 297, 71, 271, 100, 293, 245, 267, 214, |
| 170202 | /* 1740 */ 246, 106, 107, 108, 246, 271, 98, 245, 293, 114, |
| 170203 | /* 1750 */ 220, 116, 117, 118, 267, 271, 121, 271, 225, 219, |
| 170204 | /* 1760 */ 229, 219, 100, 219, 259, 259, 259, 259, 106, 107, |
| 170205 | /* 1770 */ 249, 196, 60, 280, 141, 243, 114, 249, 116, 117, |
| 170206 | /* 1780 */ 118, 133, 245, 121, 200, 297, 138, 139, 153, 154, |
| 170207 | /* 1790 */ 155, 156, 157, 297, 200, 38, 19, 20, 151, 22, |
| 170208 | /* 1800 */ 200, 150, 140, 294, 294, 22, 272, 43, 234, 18, |
| 170209 | /* 1810 */ 162, 270, 200, 36, 237, 153, 154, 155, 156, 157, |
| 170210 | /* 1820 */ 237, 283, 237, 237, 18, 199, 149, 246, 272, 270, |
| 170211 | /* 1830 */ 272, 200, 158, 246, 246, 234, 59, 234, 246, 199, |
| 170212 | /* 1840 */ 290, 62, 289, 200, 199, 22, 221, 115, 71, 200, |
| 170213 | /* 1850 */ 200, 199, 199, 221, 218, 218, 19, 20, 64, 22, |
| 170214 | /* 1860 */ 218, 227, 22, 224, 126, 224, 165, 221, 24, 305, |
| 170215 | /* 1870 */ 200, 113, 312, 36, 218, 220, 218, 100, 282, 218, |
| 170216 | /* 1880 */ 91, 218, 317, 106, 107, 221, 227, 282, 317, 82, |
| 170217 | /* 1890 */ 148, 114, 265, 116, 117, 118, 59, 145, 121, 22, |
| 170218 | /* 1900 */ 277, 158, 200, 265, 25, 202, 147, 250, 71, 279, |
| 170219 | /* 1910 */ 13, 146, 194, 194, 249, 248, 250, 140, 247, 246, |
| 170220 | /* 1920 */ 6, 192, 192, 192, 303, 303, 213, 207, 300, 213, |
| 170221 | /* 1930 */ 153, 154, 155, 156, 157, 213, 213, 100, 213, 222, |
| 170222 | /* 1940 */ 207, 214, 214, 106, 107, 4, 222, 207, 3, 22, |
| 170223 | /* 1950 */ 163, 114, 15, 116, 117, 118, 16, 23, 121, 23, |
| 170224 | /* 1960 */ 139, 151, 130, 25, 142, 16, 24, 20, 144, 1, |
| 170225 | /* 1970 */ 142, 130, 130, 61, 53, 53, 37, 151, 53, 53, |
| 170226 | /* 1980 */ 130, 116, 34, 1, 141, 5, 22, 115, 161, 141, |
| 170227 | /* 1990 */ 153, 154, 155, 156, 157, 25, 68, 68, 75, 41, |
| 170228 | /* 2000 */ 115, 24, 131, 20, 19, 125, 22, 96, 22, 22, |
| 170229 | /* 2010 */ 67, 23, 22, 67, 59, 24, 22, 28, 67, 23, |
| 170230 | /* 2020 */ 22, 22, 149, 23, 23, 23, 116, 23, 25, 37, |
| 170231 | /* 2030 */ 97, 141, 23, 23, 22, 143, 25, 75, 88, 34, |
| 170232 | /* 2040 */ 34, 34, 34, 86, 75, 93, 23, 34, 22, 34, |
| 170233 | /* 2050 */ 25, 24, 34, 25, 23, 142, 23, 142, 44, 23, |
| 170234 | /* 2060 */ 23, 23, 11, 23, 25, 22, 22, 22, 15, 23, |
| 170235 | /* 2070 */ 23, 22, 22, 25, 1, 1, 141, 25, 23, 135, |
| 170236 | /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170237 | /* 2090 */ 319, 319, 319, 319, 141, 141, 319, 319, 319, 319, |
| 170238 | /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170239 | /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170240 | /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170241 | /* 2130 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170242 | /* 2140 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| @@ -170251,180 +171301,181 @@ | |
| 170251 | /* 2230 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170252 | /* 2240 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170253 | /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170254 | /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170255 | /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 170256 | /* 2280 */ 319, |
| 170257 | }; |
| 170258 | #define YY_SHIFT_COUNT (574) |
| 170259 | #define YY_SHIFT_MIN (0) |
| 170260 | #define YY_SHIFT_MAX (2074) |
| 170261 | static const unsigned short int yy_shift_ofst[] = { |
| 170262 | /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, |
| 170263 | /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, |
| 170264 | /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170265 | /* 30 */ 271, 271, 1219, 1219, 216, 88, 1, 1, 1, 1, |
| 170266 | /* 40 */ 1, 40, 111, 258, 361, 469, 512, 583, 622, 693, |
| 170267 | /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, |
| 170268 | /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, |
| 170269 | /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662, |
| 170270 | /* 80 */ 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170271 | /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170272 | /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170273 | /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170274 | /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 170275 | /* 130 */ 137, 181, 181, 181, 181, 181, 181, 181, 94, 430, |
| 170276 | /* 140 */ 66, 65, 112, 366, 533, 533, 740, 1261, 533, 533, |
| 170277 | /* 150 */ 79, 79, 533, 412, 412, 412, 77, 412, 123, 113, |
| 170278 | /* 160 */ 113, 22, 22, 2096, 2096, 328, 328, 328, 239, 468, |
| 170279 | /* 170 */ 468, 468, 468, 1015, 1015, 409, 366, 1129, 1186, 533, |
| 170280 | /* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 170281 | /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 969, |
| 170282 | /* 200 */ 621, 621, 533, 642, 788, 788, 1228, 1228, 822, 822, |
| 170283 | /* 210 */ 67, 1274, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 1307, |
| 170284 | /* 220 */ 954, 954, 585, 472, 640, 387, 695, 538, 541, 700, |
| 170285 | /* 230 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 170286 | /* 240 */ 222, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 170287 | /* 250 */ 533, 533, 533, 1179, 1179, 1179, 533, 533, 533, 565, |
| 170288 | /* 260 */ 533, 533, 533, 916, 1144, 533, 533, 1288, 533, 533, |
| 170289 | /* 270 */ 533, 533, 533, 533, 533, 533, 639, 1330, 209, 1076, |
| 170290 | /* 280 */ 1076, 1076, 1076, 580, 209, 209, 1313, 768, 917, 649, |
| 170291 | /* 290 */ 1181, 1316, 405, 1316, 1238, 249, 1181, 1181, 249, 1181, |
| 170292 | /* 300 */ 405, 1238, 1369, 464, 1259, 1012, 1012, 1012, 1368, 1368, |
| 170293 | /* 310 */ 1368, 1368, 184, 184, 1326, 904, 1287, 1480, 1712, 1712, |
| 170294 | /* 320 */ 1633, 1633, 1757, 1757, 1633, 1647, 1651, 1783, 1764, 1791, |
| 170295 | /* 330 */ 1791, 1791, 1791, 1633, 1806, 1677, 1651, 1651, 1677, 1783, |
| 170296 | /* 340 */ 1764, 1677, 1764, 1677, 1633, 1806, 1674, 1779, 1633, 1806, |
| 170297 | /* 350 */ 1823, 1633, 1806, 1633, 1806, 1823, 1732, 1732, 1732, 1794, |
| 170298 | /* 360 */ 1840, 1840, 1823, 1732, 1738, 1732, 1794, 1732, 1732, 1701, |
| 170299 | /* 370 */ 1844, 1758, 1758, 1823, 1633, 1789, 1789, 1807, 1807, 1742, |
| 170300 | /* 380 */ 1752, 1877, 1633, 1743, 1742, 1759, 1765, 1677, 1879, 1897, |
| 170301 | /* 390 */ 1897, 1914, 1914, 1914, 2096, 2096, 2096, 2096, 2096, 2096, |
| 170302 | /* 400 */ 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 207, |
| 170303 | /* 410 */ 1095, 331, 620, 903, 806, 1074, 1483, 1432, 1481, 1322, |
| 170304 | /* 420 */ 1370, 1394, 1515, 1291, 1546, 1547, 1557, 1595, 1598, 1599, |
| 170305 | /* 430 */ 1434, 1453, 1618, 1462, 1567, 1489, 1644, 1654, 1616, 1660, |
| 170306 | /* 440 */ 1548, 1549, 1682, 1685, 1597, 742, 1941, 1945, 1927, 1787, |
| 170307 | /* 450 */ 1937, 1940, 1934, 1936, 1821, 1810, 1832, 1938, 1938, 1942, |
| 170308 | /* 460 */ 1822, 1947, 1824, 1949, 1968, 1828, 1841, 1938, 1842, 1912, |
| 170309 | /* 470 */ 1939, 1938, 1826, 1921, 1922, 1925, 1926, 1850, 1865, 1948, |
| 170310 | /* 480 */ 1843, 1982, 1980, 1964, 1872, 1827, 1928, 1970, 1929, 1923, |
| 170311 | /* 490 */ 1958, 1848, 1885, 1977, 1983, 1985, 1871, 1880, 1984, 1943, |
| 170312 | /* 500 */ 1986, 1987, 1988, 1990, 1946, 1955, 1991, 1911, 1989, 1994, |
| 170313 | /* 510 */ 1951, 1992, 1996, 1873, 1998, 2000, 2001, 2002, 2003, 2004, |
| 170314 | /* 520 */ 1999, 1933, 1890, 2009, 2010, 1910, 2005, 2012, 1892, 2011, |
| 170315 | /* 530 */ 2006, 2007, 2008, 2013, 1950, 1962, 1957, 2014, 1969, 1952, |
| 170316 | /* 540 */ 2015, 2023, 2026, 2027, 2025, 2028, 2018, 1913, 1915, 2031, |
| 170317 | /* 550 */ 2011, 2033, 2036, 2037, 2038, 2039, 2040, 2043, 2051, 2044, |
| 170318 | /* 560 */ 2045, 2046, 2047, 2049, 2050, 2048, 1944, 1935, 1953, 1954, |
| 170319 | /* 570 */ 2052, 2055, 2053, 2073, 2074, |
| 170320 | }; |
| 170321 | #define YY_REDUCE_COUNT (408) |
| 170322 | #define YY_REDUCE_MIN (-271) |
| 170323 | #define YY_REDUCE_MAX (1740) |
| 170324 | static const short yy_reduce_ofst[] = { |
| 170325 | /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, |
| 170326 | /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, |
| 170327 | /* 20 */ 576, -175, 598, 686, 615, 725, 860, 778, 781, 857, |
| 170328 | /* 30 */ 616, 887, 87, 240, -192, 408, 626, 796, 843, 854, |
| 170329 | /* 40 */ 1003, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170330 | /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170331 | /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170332 | /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, 80, 83, |
| 170333 | /* 80 */ 313, 886, 888, 996, 1034, 1059, 1081, 1100, 1117, 1152, |
| 170334 | /* 90 */ 1155, 1163, 1165, 1167, 1169, 1172, 1180, 1182, 1184, 1198, |
| 170335 | /* 100 */ 1200, 1213, 1215, 1225, 1227, 1252, 1254, 1264, 1299, 1303, |
| 170336 | /* 110 */ 1308, 1312, 1325, 1328, 1337, 1340, 1343, 1371, 1373, 1384, |
| 170337 | /* 120 */ 1386, 1411, 1420, 1424, 1426, 1458, 1470, 1473, 1475, 1479, |
| 170338 | /* 130 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 170339 | /* 140 */ -271, 138, 459, 396, -158, 470, 302, -212, 521, 201, |
| 170340 | /* 150 */ -195, -92, 559, 630, 632, 630, -271, 632, 901, 63, |
| 170341 | /* 160 */ 407, -271, -271, -271, -271, 161, 161, 161, 251, 335, |
| 170342 | /* 170 */ 847, 960, 980, 537, 588, 618, 628, 688, 688, -166, |
| 170343 | /* 180 */ -161, 674, 790, 794, 799, 851, 852, -122, 680, -120, |
| 170344 | /* 190 */ 995, 1038, 415, 1051, 893, 798, 962, 400, 1086, 779, |
| 170345 | /* 200 */ 923, 924, 263, 1041, 979, 990, 1083, 1097, 1031, 1194, |
| 170346 | /* 210 */ 362, 994, 1139, 1005, 1037, 1202, 1205, 1195, 1210, -194, |
| 170347 | /* 220 */ 56, 185, -135, 232, 522, 560, 601, 617, 669, 683, |
| 170348 | /* 230 */ 711, 856, 908, 941, 1048, 1101, 1147, 1257, 1262, 1265, |
| 170349 | /* 240 */ 392, 1292, 1333, 1339, 1342, 1346, 1350, 1359, 1374, 1418, |
| 170350 | /* 250 */ 1421, 1436, 1437, 593, 755, 770, 997, 1445, 1459, 1209, |
| 170351 | /* 260 */ 1500, 1504, 1516, 1132, 1243, 1518, 1519, 1440, 1520, 560, |
| 170352 | /* 270 */ 1522, 1523, 1524, 1526, 1527, 1529, 1382, 1438, 1431, 1468, |
| 170353 | /* 280 */ 1469, 1472, 1476, 1209, 1431, 1431, 1485, 1525, 1539, 1435, |
| 170354 | /* 290 */ 1463, 1471, 1492, 1487, 1443, 1494, 1474, 1484, 1498, 1486, |
| 170355 | /* 300 */ 1502, 1455, 1530, 1531, 1533, 1540, 1542, 1544, 1505, 1506, |
| 170356 | /* 310 */ 1507, 1508, 1521, 1528, 1493, 1537, 1532, 1575, 1488, 1496, |
| 170357 | /* 320 */ 1584, 1594, 1509, 1510, 1600, 1538, 1534, 1541, 1574, 1577, |
| 170358 | /* 330 */ 1583, 1585, 1586, 1612, 1626, 1581, 1556, 1558, 1587, 1559, |
| 170359 | /* 340 */ 1601, 1588, 1603, 1592, 1631, 1640, 1550, 1553, 1643, 1645, |
| 170360 | /* 350 */ 1625, 1649, 1652, 1650, 1653, 1632, 1636, 1637, 1642, 1634, |
| 170361 | /* 360 */ 1639, 1641, 1646, 1656, 1655, 1658, 1659, 1661, 1663, 1560, |
| 170362 | /* 370 */ 1564, 1596, 1605, 1664, 1670, 1565, 1571, 1627, 1638, 1657, |
| 170363 | /* 380 */ 1665, 1623, 1702, 1630, 1666, 1667, 1671, 1673, 1703, 1718, |
| 170364 | /* 390 */ 1719, 1729, 1730, 1731, 1621, 1622, 1628, 1720, 1713, 1716, |
| 170365 | /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, |
| 170366 | }; |
| 170367 | static const YYACTIONTYPE yy_default[] = { |
| 170368 | /* 0 */ 1639, 1639, 1639, 1469, 1236, 1347, 1236, 1236, 1236, 1469, |
| 170369 | /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, |
| 170370 | /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, |
| 170371 | /* 30 */ 1236, 1236, 1555, 1555, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170372 | /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, |
| 170373 | /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, |
| 170374 | /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, |
| 170375 | /* 70 */ 1617, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, |
| 170376 | /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170377 | /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170378 | /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170379 | /* 110 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170380 | /* 120 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170381 | /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, |
| 170382 | /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, |
| 170383 | /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, |
| 170384 | /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1591, 1590, 1487, 1236, |
| 170385 | /* 170 */ 1236, 1236, 1236, 1236, 1236, 1555, 1236, 1236, 1236, 1236, |
| 170386 | /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170387 | /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, |
| 170388 | /* 200 */ 1555, 1555, 1236, 1269, 1555, 1555, 1368, 1368, 1265, 1265, |
| 170389 | /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, |
| 170390 | /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170391 | /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, |
| 170392 | /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170393 | /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170394 | /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170395 | /* 270 */ 1236, 1236, 1236, 1236, 1236, 1584, 1236, 1499, 1325, 1343, |
| 170396 | /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1631, |
| 170397 | /* 290 */ 1403, 1392, 1344, 1392, 1628, 1390, 1403, 1403, 1390, 1403, |
| 170398 | /* 300 */ 1344, 1628, 1286, 1606, 1281, 1377, 1377, 1377, 1367, 1367, |
| 170399 | /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1631, 1631, |
| 170400 | /* 320 */ 1353, 1353, 1630, 1630, 1353, 1487, 1614, 1412, 1314, 1320, |
| 170401 | /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1614, 1614, 1390, 1412, |
| 170402 | /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1625, 1353, 1254, |
| 170403 | /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, |
| 170404 | /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1573, |
| 170405 | /* 370 */ 1236, 1481, 1481, 1477, 1353, 1565, 1565, 1380, 1380, 1385, |
| 170406 | /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1587, |
| 170407 | /* 390 */ 1587, 1583, 1583, 1583, 1636, 1636, 1536, 1599, 1269, 1269, |
| 170408 | /* 400 */ 1269, 1269, 1599, 1288, 1288, 1270, 1270, 1269, 1599, 1236, |
| 170409 | /* 410 */ 1236, 1236, 1236, 1236, 1236, 1594, 1236, 1531, 1488, 1357, |
| 170410 | /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170411 | /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, |
| 170412 | /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, |
| 170413 | /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, |
| 170414 | /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, |
| 170415 | /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170416 | /* 480 */ 1627, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, |
| 170417 | /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170418 | /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, |
| 170419 | /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170420 | /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, |
| 170421 | /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170422 | /* 540 */ 1236, 1236, 1236, 1236, 1570, 1372, 1236, 1236, 1236, 1236, |
| 170423 | /* 550 */ 1618, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 170424 | /* 560 */ 1236, 1236, 1236, 1236, 1236, 1610, 1328, 1418, 1236, 1421, |
| 170425 | /* 570 */ 1258, 1236, 1248, 1236, 1236, |
| 170426 | }; |
| 170427 | /********** End of lemon-generated parsing tables *****************************/ |
| 170428 | |
| 170429 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 170430 | ** If a construct like the following: |
| @@ -171227,225 +172278,227 @@ | |
| 171227 | /* 183 */ "term ::= INTEGER", |
| 171228 | /* 184 */ "expr ::= VARIABLE", |
| 171229 | /* 185 */ "expr ::= expr COLLATE ID|STRING", |
| 171230 | /* 186 */ "expr ::= CAST LP expr AS typetoken RP", |
| 171231 | /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", |
| 171232 | /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", |
| 171233 | /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", |
| 171234 | /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", |
| 171235 | /* 191 */ "term ::= CTIME_KW", |
| 171236 | /* 192 */ "expr ::= LP nexprlist COMMA expr RP", |
| 171237 | /* 193 */ "expr ::= expr AND expr", |
| 171238 | /* 194 */ "expr ::= expr OR expr", |
| 171239 | /* 195 */ "expr ::= expr LT|GT|GE|LE expr", |
| 171240 | /* 196 */ "expr ::= expr EQ|NE expr", |
| 171241 | /* 197 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 171242 | /* 198 */ "expr ::= expr PLUS|MINUS expr", |
| 171243 | /* 199 */ "expr ::= expr STAR|SLASH|REM expr", |
| 171244 | /* 200 */ "expr ::= expr CONCAT expr", |
| 171245 | /* 201 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 171246 | /* 202 */ "expr ::= expr likeop expr", |
| 171247 | /* 203 */ "expr ::= expr likeop expr ESCAPE expr", |
| 171248 | /* 204 */ "expr ::= expr ISNULL|NOTNULL", |
| 171249 | /* 205 */ "expr ::= expr NOT NULL", |
| 171250 | /* 206 */ "expr ::= expr IS expr", |
| 171251 | /* 207 */ "expr ::= expr IS NOT expr", |
| 171252 | /* 208 */ "expr ::= expr IS NOT DISTINCT FROM expr", |
| 171253 | /* 209 */ "expr ::= expr IS DISTINCT FROM expr", |
| 171254 | /* 210 */ "expr ::= NOT expr", |
| 171255 | /* 211 */ "expr ::= BITNOT expr", |
| 171256 | /* 212 */ "expr ::= PLUS|MINUS expr", |
| 171257 | /* 213 */ "expr ::= expr PTR expr", |
| 171258 | /* 214 */ "between_op ::= BETWEEN", |
| 171259 | /* 215 */ "between_op ::= NOT BETWEEN", |
| 171260 | /* 216 */ "expr ::= expr between_op expr AND expr", |
| 171261 | /* 217 */ "in_op ::= IN", |
| 171262 | /* 218 */ "in_op ::= NOT IN", |
| 171263 | /* 219 */ "expr ::= expr in_op LP exprlist RP", |
| 171264 | /* 220 */ "expr ::= LP select RP", |
| 171265 | /* 221 */ "expr ::= expr in_op LP select RP", |
| 171266 | /* 222 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 171267 | /* 223 */ "expr ::= EXISTS LP select RP", |
| 171268 | /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 171269 | /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 171270 | /* 226 */ "case_exprlist ::= WHEN expr THEN expr", |
| 171271 | /* 227 */ "case_else ::= ELSE expr", |
| 171272 | /* 228 */ "case_else ::=", |
| 171273 | /* 229 */ "case_operand ::=", |
| 171274 | /* 230 */ "exprlist ::=", |
| 171275 | /* 231 */ "nexprlist ::= nexprlist COMMA expr", |
| 171276 | /* 232 */ "nexprlist ::= expr", |
| 171277 | /* 233 */ "paren_exprlist ::=", |
| 171278 | /* 234 */ "paren_exprlist ::= LP exprlist RP", |
| 171279 | /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 171280 | /* 236 */ "uniqueflag ::= UNIQUE", |
| 171281 | /* 237 */ "uniqueflag ::=", |
| 171282 | /* 238 */ "eidlist_opt ::=", |
| 171283 | /* 239 */ "eidlist_opt ::= LP eidlist RP", |
| 171284 | /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 171285 | /* 241 */ "eidlist ::= nm collate sortorder", |
| 171286 | /* 242 */ "collate ::=", |
| 171287 | /* 243 */ "collate ::= COLLATE ID|STRING", |
| 171288 | /* 244 */ "cmd ::= DROP INDEX ifexists fullname", |
| 171289 | /* 245 */ "cmd ::= VACUUM vinto", |
| 171290 | /* 246 */ "cmd ::= VACUUM nm vinto", |
| 171291 | /* 247 */ "vinto ::= INTO expr", |
| 171292 | /* 248 */ "vinto ::=", |
| 171293 | /* 249 */ "cmd ::= PRAGMA nm dbnm", |
| 171294 | /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 171295 | /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 171296 | /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 171297 | /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 171298 | /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 171299 | /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 171300 | /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 171301 | /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 171302 | /* 258 */ "trigger_time ::= BEFORE|AFTER", |
| 171303 | /* 259 */ "trigger_time ::= INSTEAD OF", |
| 171304 | /* 260 */ "trigger_time ::=", |
| 171305 | /* 261 */ "trigger_event ::= DELETE|INSERT", |
| 171306 | /* 262 */ "trigger_event ::= UPDATE", |
| 171307 | /* 263 */ "trigger_event ::= UPDATE OF idlist", |
| 171308 | /* 264 */ "when_clause ::=", |
| 171309 | /* 265 */ "when_clause ::= WHEN expr", |
| 171310 | /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 171311 | /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 171312 | /* 268 */ "trnm ::= nm DOT nm", |
| 171313 | /* 269 */ "tridxby ::= INDEXED BY nm", |
| 171314 | /* 270 */ "tridxby ::= NOT INDEXED", |
| 171315 | /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 171316 | /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 171317 | /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 171318 | /* 274 */ "trigger_cmd ::= scanpt select scanpt", |
| 171319 | /* 275 */ "expr ::= RAISE LP IGNORE RP", |
| 171320 | /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 171321 | /* 277 */ "raisetype ::= ROLLBACK", |
| 171322 | /* 278 */ "raisetype ::= ABORT", |
| 171323 | /* 279 */ "raisetype ::= FAIL", |
| 171324 | /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 171325 | /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 171326 | /* 282 */ "cmd ::= DETACH database_kw_opt expr", |
| 171327 | /* 283 */ "key_opt ::=", |
| 171328 | /* 284 */ "key_opt ::= KEY expr", |
| 171329 | /* 285 */ "cmd ::= REINDEX", |
| 171330 | /* 286 */ "cmd ::= REINDEX nm dbnm", |
| 171331 | /* 287 */ "cmd ::= ANALYZE", |
| 171332 | /* 288 */ "cmd ::= ANALYZE nm dbnm", |
| 171333 | /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 171334 | /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 171335 | /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 171336 | /* 292 */ "add_column_fullname ::= fullname", |
| 171337 | /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 171338 | /* 294 */ "cmd ::= create_vtab", |
| 171339 | /* 295 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 171340 | /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 171341 | /* 297 */ "vtabarg ::=", |
| 171342 | /* 298 */ "vtabargtoken ::= ANY", |
| 171343 | /* 299 */ "vtabargtoken ::= lp anylist RP", |
| 171344 | /* 300 */ "lp ::= LP", |
| 171345 | /* 301 */ "with ::= WITH wqlist", |
| 171346 | /* 302 */ "with ::= WITH RECURSIVE wqlist", |
| 171347 | /* 303 */ "wqas ::= AS", |
| 171348 | /* 304 */ "wqas ::= AS MATERIALIZED", |
| 171349 | /* 305 */ "wqas ::= AS NOT MATERIALIZED", |
| 171350 | /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 171351 | /* 307 */ "wqlist ::= wqitem", |
| 171352 | /* 308 */ "wqlist ::= wqlist COMMA wqitem", |
| 171353 | /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 171354 | /* 310 */ "windowdefn ::= nm AS LP window RP", |
| 171355 | /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 171356 | /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 171357 | /* 313 */ "window ::= ORDER BY sortlist frame_opt", |
| 171358 | /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 171359 | /* 315 */ "window ::= nm frame_opt", |
| 171360 | /* 316 */ "frame_opt ::=", |
| 171361 | /* 317 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 171362 | /* 318 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 171363 | /* 319 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 171364 | /* 320 */ "frame_bound_s ::= frame_bound", |
| 171365 | /* 321 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 171366 | /* 322 */ "frame_bound_e ::= frame_bound", |
| 171367 | /* 323 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 171368 | /* 324 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 171369 | /* 325 */ "frame_bound ::= CURRENT ROW", |
| 171370 | /* 326 */ "frame_exclude_opt ::=", |
| 171371 | /* 327 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 171372 | /* 328 */ "frame_exclude ::= NO OTHERS", |
| 171373 | /* 329 */ "frame_exclude ::= CURRENT ROW", |
| 171374 | /* 330 */ "frame_exclude ::= GROUP|TIES", |
| 171375 | /* 331 */ "window_clause ::= WINDOW windowdefn_list", |
| 171376 | /* 332 */ "filter_over ::= filter_clause over_clause", |
| 171377 | /* 333 */ "filter_over ::= over_clause", |
| 171378 | /* 334 */ "filter_over ::= filter_clause", |
| 171379 | /* 335 */ "over_clause ::= OVER LP window RP", |
| 171380 | /* 336 */ "over_clause ::= OVER nm", |
| 171381 | /* 337 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 171382 | /* 338 */ "input ::= cmdlist", |
| 171383 | /* 339 */ "cmdlist ::= cmdlist ecmd", |
| 171384 | /* 340 */ "cmdlist ::= ecmd", |
| 171385 | /* 341 */ "ecmd ::= SEMI", |
| 171386 | /* 342 */ "ecmd ::= cmdx SEMI", |
| 171387 | /* 343 */ "ecmd ::= explain cmdx SEMI", |
| 171388 | /* 344 */ "trans_opt ::=", |
| 171389 | /* 345 */ "trans_opt ::= TRANSACTION", |
| 171390 | /* 346 */ "trans_opt ::= TRANSACTION nm", |
| 171391 | /* 347 */ "savepoint_opt ::= SAVEPOINT", |
| 171392 | /* 348 */ "savepoint_opt ::=", |
| 171393 | /* 349 */ "cmd ::= create_table create_table_args", |
| 171394 | /* 350 */ "table_option_set ::= table_option", |
| 171395 | /* 351 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 171396 | /* 352 */ "columnlist ::= columnname carglist", |
| 171397 | /* 353 */ "nm ::= ID|INDEXED|JOIN_KW", |
| 171398 | /* 354 */ "nm ::= STRING", |
| 171399 | /* 355 */ "typetoken ::= typename", |
| 171400 | /* 356 */ "typename ::= ID|STRING", |
| 171401 | /* 357 */ "signed ::= plus_num", |
| 171402 | /* 358 */ "signed ::= minus_num", |
| 171403 | /* 359 */ "carglist ::= carglist ccons", |
| 171404 | /* 360 */ "carglist ::=", |
| 171405 | /* 361 */ "ccons ::= NULL onconf", |
| 171406 | /* 362 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 171407 | /* 363 */ "ccons ::= AS generated", |
| 171408 | /* 364 */ "conslist_opt ::= COMMA conslist", |
| 171409 | /* 365 */ "conslist ::= conslist tconscomma tcons", |
| 171410 | /* 366 */ "conslist ::= tcons", |
| 171411 | /* 367 */ "tconscomma ::=", |
| 171412 | /* 368 */ "defer_subclause_opt ::= defer_subclause", |
| 171413 | /* 369 */ "resolvetype ::= raisetype", |
| 171414 | /* 370 */ "selectnowith ::= oneselect", |
| 171415 | /* 371 */ "oneselect ::= values", |
| 171416 | /* 372 */ "sclp ::= selcollist COMMA", |
| 171417 | /* 373 */ "as ::= ID|STRING", |
| 171418 | /* 374 */ "indexed_opt ::= indexed_by", |
| 171419 | /* 375 */ "returning ::=", |
| 171420 | /* 376 */ "expr ::= term", |
| 171421 | /* 377 */ "likeop ::= LIKE_KW|MATCH", |
| 171422 | /* 378 */ "case_operand ::= expr", |
| 171423 | /* 379 */ "exprlist ::= nexprlist", |
| 171424 | /* 380 */ "nmnum ::= plus_num", |
| 171425 | /* 381 */ "nmnum ::= nm", |
| 171426 | /* 382 */ "nmnum ::= ON", |
| 171427 | /* 383 */ "nmnum ::= DELETE", |
| 171428 | /* 384 */ "nmnum ::= DEFAULT", |
| 171429 | /* 385 */ "plus_num ::= INTEGER|FLOAT", |
| 171430 | /* 386 */ "foreach_clause ::=", |
| 171431 | /* 387 */ "foreach_clause ::= FOR EACH ROW", |
| 171432 | /* 388 */ "trnm ::= nm", |
| 171433 | /* 389 */ "tridxby ::=", |
| 171434 | /* 390 */ "database_kw_opt ::= DATABASE", |
| 171435 | /* 391 */ "database_kw_opt ::=", |
| 171436 | /* 392 */ "kwcolumn_opt ::=", |
| 171437 | /* 393 */ "kwcolumn_opt ::= COLUMNKW", |
| 171438 | /* 394 */ "vtabarglist ::= vtabarg", |
| 171439 | /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 171440 | /* 396 */ "vtabarg ::= vtabarg vtabargtoken", |
| 171441 | /* 397 */ "anylist ::=", |
| 171442 | /* 398 */ "anylist ::= anylist LP anylist RP", |
| 171443 | /* 399 */ "anylist ::= anylist ANY", |
| 171444 | /* 400 */ "with ::=", |
| 171445 | /* 401 */ "windowdefn_list ::= windowdefn", |
| 171446 | /* 402 */ "window ::= frame_opt", |
| 171447 | }; |
| 171448 | #endif /* NDEBUG */ |
| 171449 | |
| 171450 | |
| 171451 | #if YYSTACKDEPTH<=0 |
| @@ -172136,225 +173189,227 @@ | |
| 172136 | 216, /* (183) term ::= INTEGER */ |
| 172137 | 217, /* (184) expr ::= VARIABLE */ |
| 172138 | 217, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 172139 | 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 172140 | 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 172141 | 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 172142 | 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 172143 | 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 172144 | 216, /* (191) term ::= CTIME_KW */ |
| 172145 | 217, /* (192) expr ::= LP nexprlist COMMA expr RP */ |
| 172146 | 217, /* (193) expr ::= expr AND expr */ |
| 172147 | 217, /* (194) expr ::= expr OR expr */ |
| 172148 | 217, /* (195) expr ::= expr LT|GT|GE|LE expr */ |
| 172149 | 217, /* (196) expr ::= expr EQ|NE expr */ |
| 172150 | 217, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 172151 | 217, /* (198) expr ::= expr PLUS|MINUS expr */ |
| 172152 | 217, /* (199) expr ::= expr STAR|SLASH|REM expr */ |
| 172153 | 217, /* (200) expr ::= expr CONCAT expr */ |
| 172154 | 274, /* (201) likeop ::= NOT LIKE_KW|MATCH */ |
| 172155 | 217, /* (202) expr ::= expr likeop expr */ |
| 172156 | 217, /* (203) expr ::= expr likeop expr ESCAPE expr */ |
| 172157 | 217, /* (204) expr ::= expr ISNULL|NOTNULL */ |
| 172158 | 217, /* (205) expr ::= expr NOT NULL */ |
| 172159 | 217, /* (206) expr ::= expr IS expr */ |
| 172160 | 217, /* (207) expr ::= expr IS NOT expr */ |
| 172161 | 217, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ |
| 172162 | 217, /* (209) expr ::= expr IS DISTINCT FROM expr */ |
| 172163 | 217, /* (210) expr ::= NOT expr */ |
| 172164 | 217, /* (211) expr ::= BITNOT expr */ |
| 172165 | 217, /* (212) expr ::= PLUS|MINUS expr */ |
| 172166 | 217, /* (213) expr ::= expr PTR expr */ |
| 172167 | 275, /* (214) between_op ::= BETWEEN */ |
| 172168 | 275, /* (215) between_op ::= NOT BETWEEN */ |
| 172169 | 217, /* (216) expr ::= expr between_op expr AND expr */ |
| 172170 | 276, /* (217) in_op ::= IN */ |
| 172171 | 276, /* (218) in_op ::= NOT IN */ |
| 172172 | 217, /* (219) expr ::= expr in_op LP exprlist RP */ |
| 172173 | 217, /* (220) expr ::= LP select RP */ |
| 172174 | 217, /* (221) expr ::= expr in_op LP select RP */ |
| 172175 | 217, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 172176 | 217, /* (223) expr ::= EXISTS LP select RP */ |
| 172177 | 217, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ |
| 172178 | 279, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 172179 | 279, /* (226) case_exprlist ::= WHEN expr THEN expr */ |
| 172180 | 280, /* (227) case_else ::= ELSE expr */ |
| 172181 | 280, /* (228) case_else ::= */ |
| 172182 | 278, /* (229) case_operand ::= */ |
| 172183 | 261, /* (230) exprlist ::= */ |
| 172184 | 253, /* (231) nexprlist ::= nexprlist COMMA expr */ |
| 172185 | 253, /* (232) nexprlist ::= expr */ |
| 172186 | 277, /* (233) paren_exprlist ::= */ |
| 172187 | 277, /* (234) paren_exprlist ::= LP exprlist RP */ |
| 172188 | 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 172189 | 281, /* (236) uniqueflag ::= UNIQUE */ |
| 172190 | 281, /* (237) uniqueflag ::= */ |
| 172191 | 221, /* (238) eidlist_opt ::= */ |
| 172192 | 221, /* (239) eidlist_opt ::= LP eidlist RP */ |
| 172193 | 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 172194 | 232, /* (241) eidlist ::= nm collate sortorder */ |
| 172195 | 282, /* (242) collate ::= */ |
| 172196 | 282, /* (243) collate ::= COLLATE ID|STRING */ |
| 172197 | 190, /* (244) cmd ::= DROP INDEX ifexists fullname */ |
| 172198 | 190, /* (245) cmd ::= VACUUM vinto */ |
| 172199 | 190, /* (246) cmd ::= VACUUM nm vinto */ |
| 172200 | 283, /* (247) vinto ::= INTO expr */ |
| 172201 | 283, /* (248) vinto ::= */ |
| 172202 | 190, /* (249) cmd ::= PRAGMA nm dbnm */ |
| 172203 | 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 172204 | 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 172205 | 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 172206 | 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 172207 | 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ |
| 172208 | 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ |
| 172209 | 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 172210 | 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 172211 | 287, /* (258) trigger_time ::= BEFORE|AFTER */ |
| 172212 | 287, /* (259) trigger_time ::= INSTEAD OF */ |
| 172213 | 287, /* (260) trigger_time ::= */ |
| 172214 | 288, /* (261) trigger_event ::= DELETE|INSERT */ |
| 172215 | 288, /* (262) trigger_event ::= UPDATE */ |
| 172216 | 288, /* (263) trigger_event ::= UPDATE OF idlist */ |
| 172217 | 290, /* (264) when_clause ::= */ |
| 172218 | 290, /* (265) when_clause ::= WHEN expr */ |
| 172219 | 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 172220 | 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 172221 | 292, /* (268) trnm ::= nm DOT nm */ |
| 172222 | 293, /* (269) tridxby ::= INDEXED BY nm */ |
| 172223 | 293, /* (270) tridxby ::= NOT INDEXED */ |
| 172224 | 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 172225 | 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 172226 | 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 172227 | 291, /* (274) trigger_cmd ::= scanpt select scanpt */ |
| 172228 | 217, /* (275) expr ::= RAISE LP IGNORE RP */ |
| 172229 | 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 172230 | 236, /* (277) raisetype ::= ROLLBACK */ |
| 172231 | 236, /* (278) raisetype ::= ABORT */ |
| 172232 | 236, /* (279) raisetype ::= FAIL */ |
| 172233 | 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ |
| 172234 | 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 172235 | 190, /* (282) cmd ::= DETACH database_kw_opt expr */ |
| 172236 | 295, /* (283) key_opt ::= */ |
| 172237 | 295, /* (284) key_opt ::= KEY expr */ |
| 172238 | 190, /* (285) cmd ::= REINDEX */ |
| 172239 | 190, /* (286) cmd ::= REINDEX nm dbnm */ |
| 172240 | 190, /* (287) cmd ::= ANALYZE */ |
| 172241 | 190, /* (288) cmd ::= ANALYZE nm dbnm */ |
| 172242 | 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 172243 | 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 172244 | 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 172245 | 296, /* (292) add_column_fullname ::= fullname */ |
| 172246 | 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 172247 | 190, /* (294) cmd ::= create_vtab */ |
| 172248 | 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */ |
| 172249 | 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 172250 | 300, /* (297) vtabarg ::= */ |
| 172251 | 301, /* (298) vtabargtoken ::= ANY */ |
| 172252 | 301, /* (299) vtabargtoken ::= lp anylist RP */ |
| 172253 | 302, /* (300) lp ::= LP */ |
| 172254 | 266, /* (301) with ::= WITH wqlist */ |
| 172255 | 266, /* (302) with ::= WITH RECURSIVE wqlist */ |
| 172256 | 305, /* (303) wqas ::= AS */ |
| 172257 | 305, /* (304) wqas ::= AS MATERIALIZED */ |
| 172258 | 305, /* (305) wqas ::= AS NOT MATERIALIZED */ |
| 172259 | 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 172260 | 241, /* (307) wqlist ::= wqitem */ |
| 172261 | 241, /* (308) wqlist ::= wqlist COMMA wqitem */ |
| 172262 | 306, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 172263 | 307, /* (310) windowdefn ::= nm AS LP window RP */ |
| 172264 | 308, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172265 | 308, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172266 | 308, /* (313) window ::= ORDER BY sortlist frame_opt */ |
| 172267 | 308, /* (314) window ::= nm ORDER BY sortlist frame_opt */ |
| 172268 | 308, /* (315) window ::= nm frame_opt */ |
| 172269 | 309, /* (316) frame_opt ::= */ |
| 172270 | 309, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 172271 | 309, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 172272 | 313, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 172273 | 315, /* (320) frame_bound_s ::= frame_bound */ |
| 172274 | 315, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 172275 | 316, /* (322) frame_bound_e ::= frame_bound */ |
| 172276 | 316, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 172277 | 314, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 172278 | 314, /* (325) frame_bound ::= CURRENT ROW */ |
| 172279 | 317, /* (326) frame_exclude_opt ::= */ |
| 172280 | 317, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 172281 | 318, /* (328) frame_exclude ::= NO OTHERS */ |
| 172282 | 318, /* (329) frame_exclude ::= CURRENT ROW */ |
| 172283 | 318, /* (330) frame_exclude ::= GROUP|TIES */ |
| 172284 | 251, /* (331) window_clause ::= WINDOW windowdefn_list */ |
| 172285 | 273, /* (332) filter_over ::= filter_clause over_clause */ |
| 172286 | 273, /* (333) filter_over ::= over_clause */ |
| 172287 | 273, /* (334) filter_over ::= filter_clause */ |
| 172288 | 312, /* (335) over_clause ::= OVER LP window RP */ |
| 172289 | 312, /* (336) over_clause ::= OVER nm */ |
| 172290 | 311, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ |
| 172291 | 185, /* (338) input ::= cmdlist */ |
| 172292 | 186, /* (339) cmdlist ::= cmdlist ecmd */ |
| 172293 | 186, /* (340) cmdlist ::= ecmd */ |
| 172294 | 187, /* (341) ecmd ::= SEMI */ |
| 172295 | 187, /* (342) ecmd ::= cmdx SEMI */ |
| 172296 | 187, /* (343) ecmd ::= explain cmdx SEMI */ |
| 172297 | 192, /* (344) trans_opt ::= */ |
| 172298 | 192, /* (345) trans_opt ::= TRANSACTION */ |
| 172299 | 192, /* (346) trans_opt ::= TRANSACTION nm */ |
| 172300 | 194, /* (347) savepoint_opt ::= SAVEPOINT */ |
| 172301 | 194, /* (348) savepoint_opt ::= */ |
| 172302 | 190, /* (349) cmd ::= create_table create_table_args */ |
| 172303 | 203, /* (350) table_option_set ::= table_option */ |
| 172304 | 201, /* (351) columnlist ::= columnlist COMMA columnname carglist */ |
| 172305 | 201, /* (352) columnlist ::= columnname carglist */ |
| 172306 | 193, /* (353) nm ::= ID|INDEXED|JOIN_KW */ |
| 172307 | 193, /* (354) nm ::= STRING */ |
| 172308 | 208, /* (355) typetoken ::= typename */ |
| 172309 | 209, /* (356) typename ::= ID|STRING */ |
| 172310 | 210, /* (357) signed ::= plus_num */ |
| 172311 | 210, /* (358) signed ::= minus_num */ |
| 172312 | 207, /* (359) carglist ::= carglist ccons */ |
| 172313 | 207, /* (360) carglist ::= */ |
| 172314 | 215, /* (361) ccons ::= NULL onconf */ |
| 172315 | 215, /* (362) ccons ::= GENERATED ALWAYS AS generated */ |
| 172316 | 215, /* (363) ccons ::= AS generated */ |
| 172317 | 202, /* (364) conslist_opt ::= COMMA conslist */ |
| 172318 | 228, /* (365) conslist ::= conslist tconscomma tcons */ |
| 172319 | 228, /* (366) conslist ::= tcons */ |
| 172320 | 229, /* (367) tconscomma ::= */ |
| 172321 | 233, /* (368) defer_subclause_opt ::= defer_subclause */ |
| 172322 | 235, /* (369) resolvetype ::= raisetype */ |
| 172323 | 239, /* (370) selectnowith ::= oneselect */ |
| 172324 | 240, /* (371) oneselect ::= values */ |
| 172325 | 254, /* (372) sclp ::= selcollist COMMA */ |
| 172326 | 255, /* (373) as ::= ID|STRING */ |
| 172327 | 264, /* (374) indexed_opt ::= indexed_by */ |
| 172328 | 272, /* (375) returning ::= */ |
| 172329 | 217, /* (376) expr ::= term */ |
| 172330 | 274, /* (377) likeop ::= LIKE_KW|MATCH */ |
| 172331 | 278, /* (378) case_operand ::= expr */ |
| 172332 | 261, /* (379) exprlist ::= nexprlist */ |
| 172333 | 284, /* (380) nmnum ::= plus_num */ |
| 172334 | 284, /* (381) nmnum ::= nm */ |
| 172335 | 284, /* (382) nmnum ::= ON */ |
| 172336 | 284, /* (383) nmnum ::= DELETE */ |
| 172337 | 284, /* (384) nmnum ::= DEFAULT */ |
| 172338 | 211, /* (385) plus_num ::= INTEGER|FLOAT */ |
| 172339 | 289, /* (386) foreach_clause ::= */ |
| 172340 | 289, /* (387) foreach_clause ::= FOR EACH ROW */ |
| 172341 | 292, /* (388) trnm ::= nm */ |
| 172342 | 293, /* (389) tridxby ::= */ |
| 172343 | 294, /* (390) database_kw_opt ::= DATABASE */ |
| 172344 | 294, /* (391) database_kw_opt ::= */ |
| 172345 | 297, /* (392) kwcolumn_opt ::= */ |
| 172346 | 297, /* (393) kwcolumn_opt ::= COLUMNKW */ |
| 172347 | 299, /* (394) vtabarglist ::= vtabarg */ |
| 172348 | 299, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 172349 | 300, /* (396) vtabarg ::= vtabarg vtabargtoken */ |
| 172350 | 303, /* (397) anylist ::= */ |
| 172351 | 303, /* (398) anylist ::= anylist LP anylist RP */ |
| 172352 | 303, /* (399) anylist ::= anylist ANY */ |
| 172353 | 266, /* (400) with ::= */ |
| 172354 | 306, /* (401) windowdefn_list ::= windowdefn */ |
| 172355 | 308, /* (402) window ::= frame_opt */ |
| 172356 | }; |
| 172357 | |
| 172358 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| 172359 | ** of symbols on the right-hand side of that rule. */ |
| 172360 | static const signed char yyRuleInfoNRhs[] = { |
| @@ -172544,225 +173599,227 @@ | |
| 172544 | -1, /* (183) term ::= INTEGER */ |
| 172545 | -1, /* (184) expr ::= VARIABLE */ |
| 172546 | -3, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 172547 | -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 172548 | -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 172549 | -4, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 172550 | -6, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 172551 | -5, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 172552 | -1, /* (191) term ::= CTIME_KW */ |
| 172553 | -5, /* (192) expr ::= LP nexprlist COMMA expr RP */ |
| 172554 | -3, /* (193) expr ::= expr AND expr */ |
| 172555 | -3, /* (194) expr ::= expr OR expr */ |
| 172556 | -3, /* (195) expr ::= expr LT|GT|GE|LE expr */ |
| 172557 | -3, /* (196) expr ::= expr EQ|NE expr */ |
| 172558 | -3, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 172559 | -3, /* (198) expr ::= expr PLUS|MINUS expr */ |
| 172560 | -3, /* (199) expr ::= expr STAR|SLASH|REM expr */ |
| 172561 | -3, /* (200) expr ::= expr CONCAT expr */ |
| 172562 | -2, /* (201) likeop ::= NOT LIKE_KW|MATCH */ |
| 172563 | -3, /* (202) expr ::= expr likeop expr */ |
| 172564 | -5, /* (203) expr ::= expr likeop expr ESCAPE expr */ |
| 172565 | -2, /* (204) expr ::= expr ISNULL|NOTNULL */ |
| 172566 | -3, /* (205) expr ::= expr NOT NULL */ |
| 172567 | -3, /* (206) expr ::= expr IS expr */ |
| 172568 | -4, /* (207) expr ::= expr IS NOT expr */ |
| 172569 | -6, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ |
| 172570 | -5, /* (209) expr ::= expr IS DISTINCT FROM expr */ |
| 172571 | -2, /* (210) expr ::= NOT expr */ |
| 172572 | -2, /* (211) expr ::= BITNOT expr */ |
| 172573 | -2, /* (212) expr ::= PLUS|MINUS expr */ |
| 172574 | -3, /* (213) expr ::= expr PTR expr */ |
| 172575 | -1, /* (214) between_op ::= BETWEEN */ |
| 172576 | -2, /* (215) between_op ::= NOT BETWEEN */ |
| 172577 | -5, /* (216) expr ::= expr between_op expr AND expr */ |
| 172578 | -1, /* (217) in_op ::= IN */ |
| 172579 | -2, /* (218) in_op ::= NOT IN */ |
| 172580 | -5, /* (219) expr ::= expr in_op LP exprlist RP */ |
| 172581 | -3, /* (220) expr ::= LP select RP */ |
| 172582 | -5, /* (221) expr ::= expr in_op LP select RP */ |
| 172583 | -5, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 172584 | -4, /* (223) expr ::= EXISTS LP select RP */ |
| 172585 | -5, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ |
| 172586 | -5, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 172587 | -4, /* (226) case_exprlist ::= WHEN expr THEN expr */ |
| 172588 | -2, /* (227) case_else ::= ELSE expr */ |
| 172589 | 0, /* (228) case_else ::= */ |
| 172590 | 0, /* (229) case_operand ::= */ |
| 172591 | 0, /* (230) exprlist ::= */ |
| 172592 | -3, /* (231) nexprlist ::= nexprlist COMMA expr */ |
| 172593 | -1, /* (232) nexprlist ::= expr */ |
| 172594 | 0, /* (233) paren_exprlist ::= */ |
| 172595 | -3, /* (234) paren_exprlist ::= LP exprlist RP */ |
| 172596 | -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 172597 | -1, /* (236) uniqueflag ::= UNIQUE */ |
| 172598 | 0, /* (237) uniqueflag ::= */ |
| 172599 | 0, /* (238) eidlist_opt ::= */ |
| 172600 | -3, /* (239) eidlist_opt ::= LP eidlist RP */ |
| 172601 | -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 172602 | -3, /* (241) eidlist ::= nm collate sortorder */ |
| 172603 | 0, /* (242) collate ::= */ |
| 172604 | -2, /* (243) collate ::= COLLATE ID|STRING */ |
| 172605 | -4, /* (244) cmd ::= DROP INDEX ifexists fullname */ |
| 172606 | -2, /* (245) cmd ::= VACUUM vinto */ |
| 172607 | -3, /* (246) cmd ::= VACUUM nm vinto */ |
| 172608 | -2, /* (247) vinto ::= INTO expr */ |
| 172609 | 0, /* (248) vinto ::= */ |
| 172610 | -3, /* (249) cmd ::= PRAGMA nm dbnm */ |
| 172611 | -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 172612 | -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 172613 | -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 172614 | -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 172615 | -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ |
| 172616 | -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ |
| 172617 | -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 172618 | -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 172619 | -1, /* (258) trigger_time ::= BEFORE|AFTER */ |
| 172620 | -2, /* (259) trigger_time ::= INSTEAD OF */ |
| 172621 | 0, /* (260) trigger_time ::= */ |
| 172622 | -1, /* (261) trigger_event ::= DELETE|INSERT */ |
| 172623 | -1, /* (262) trigger_event ::= UPDATE */ |
| 172624 | -3, /* (263) trigger_event ::= UPDATE OF idlist */ |
| 172625 | 0, /* (264) when_clause ::= */ |
| 172626 | -2, /* (265) when_clause ::= WHEN expr */ |
| 172627 | -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 172628 | -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 172629 | -3, /* (268) trnm ::= nm DOT nm */ |
| 172630 | -3, /* (269) tridxby ::= INDEXED BY nm */ |
| 172631 | -2, /* (270) tridxby ::= NOT INDEXED */ |
| 172632 | -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 172633 | -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 172634 | -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 172635 | -3, /* (274) trigger_cmd ::= scanpt select scanpt */ |
| 172636 | -4, /* (275) expr ::= RAISE LP IGNORE RP */ |
| 172637 | -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 172638 | -1, /* (277) raisetype ::= ROLLBACK */ |
| 172639 | -1, /* (278) raisetype ::= ABORT */ |
| 172640 | -1, /* (279) raisetype ::= FAIL */ |
| 172641 | -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ |
| 172642 | -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 172643 | -3, /* (282) cmd ::= DETACH database_kw_opt expr */ |
| 172644 | 0, /* (283) key_opt ::= */ |
| 172645 | -2, /* (284) key_opt ::= KEY expr */ |
| 172646 | -1, /* (285) cmd ::= REINDEX */ |
| 172647 | -3, /* (286) cmd ::= REINDEX nm dbnm */ |
| 172648 | -1, /* (287) cmd ::= ANALYZE */ |
| 172649 | -3, /* (288) cmd ::= ANALYZE nm dbnm */ |
| 172650 | -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 172651 | -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 172652 | -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 172653 | -1, /* (292) add_column_fullname ::= fullname */ |
| 172654 | -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 172655 | -1, /* (294) cmd ::= create_vtab */ |
| 172656 | -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */ |
| 172657 | -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 172658 | 0, /* (297) vtabarg ::= */ |
| 172659 | -1, /* (298) vtabargtoken ::= ANY */ |
| 172660 | -3, /* (299) vtabargtoken ::= lp anylist RP */ |
| 172661 | -1, /* (300) lp ::= LP */ |
| 172662 | -2, /* (301) with ::= WITH wqlist */ |
| 172663 | -3, /* (302) with ::= WITH RECURSIVE wqlist */ |
| 172664 | -1, /* (303) wqas ::= AS */ |
| 172665 | -2, /* (304) wqas ::= AS MATERIALIZED */ |
| 172666 | -3, /* (305) wqas ::= AS NOT MATERIALIZED */ |
| 172667 | -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 172668 | -1, /* (307) wqlist ::= wqitem */ |
| 172669 | -3, /* (308) wqlist ::= wqlist COMMA wqitem */ |
| 172670 | -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 172671 | -5, /* (310) windowdefn ::= nm AS LP window RP */ |
| 172672 | -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172673 | -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172674 | -4, /* (313) window ::= ORDER BY sortlist frame_opt */ |
| 172675 | -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ |
| 172676 | -2, /* (315) window ::= nm frame_opt */ |
| 172677 | 0, /* (316) frame_opt ::= */ |
| 172678 | -3, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 172679 | -6, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 172680 | -1, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 172681 | -1, /* (320) frame_bound_s ::= frame_bound */ |
| 172682 | -2, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 172683 | -1, /* (322) frame_bound_e ::= frame_bound */ |
| 172684 | -2, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 172685 | -2, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 172686 | -2, /* (325) frame_bound ::= CURRENT ROW */ |
| 172687 | 0, /* (326) frame_exclude_opt ::= */ |
| 172688 | -2, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 172689 | -2, /* (328) frame_exclude ::= NO OTHERS */ |
| 172690 | -2, /* (329) frame_exclude ::= CURRENT ROW */ |
| 172691 | -1, /* (330) frame_exclude ::= GROUP|TIES */ |
| 172692 | -2, /* (331) window_clause ::= WINDOW windowdefn_list */ |
| 172693 | -2, /* (332) filter_over ::= filter_clause over_clause */ |
| 172694 | -1, /* (333) filter_over ::= over_clause */ |
| 172695 | -1, /* (334) filter_over ::= filter_clause */ |
| 172696 | -4, /* (335) over_clause ::= OVER LP window RP */ |
| 172697 | -2, /* (336) over_clause ::= OVER nm */ |
| 172698 | -5, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ |
| 172699 | -1, /* (338) input ::= cmdlist */ |
| 172700 | -2, /* (339) cmdlist ::= cmdlist ecmd */ |
| 172701 | -1, /* (340) cmdlist ::= ecmd */ |
| 172702 | -1, /* (341) ecmd ::= SEMI */ |
| 172703 | -2, /* (342) ecmd ::= cmdx SEMI */ |
| 172704 | -3, /* (343) ecmd ::= explain cmdx SEMI */ |
| 172705 | 0, /* (344) trans_opt ::= */ |
| 172706 | -1, /* (345) trans_opt ::= TRANSACTION */ |
| 172707 | -2, /* (346) trans_opt ::= TRANSACTION nm */ |
| 172708 | -1, /* (347) savepoint_opt ::= SAVEPOINT */ |
| 172709 | 0, /* (348) savepoint_opt ::= */ |
| 172710 | -2, /* (349) cmd ::= create_table create_table_args */ |
| 172711 | -1, /* (350) table_option_set ::= table_option */ |
| 172712 | -4, /* (351) columnlist ::= columnlist COMMA columnname carglist */ |
| 172713 | -2, /* (352) columnlist ::= columnname carglist */ |
| 172714 | -1, /* (353) nm ::= ID|INDEXED|JOIN_KW */ |
| 172715 | -1, /* (354) nm ::= STRING */ |
| 172716 | -1, /* (355) typetoken ::= typename */ |
| 172717 | -1, /* (356) typename ::= ID|STRING */ |
| 172718 | -1, /* (357) signed ::= plus_num */ |
| 172719 | -1, /* (358) signed ::= minus_num */ |
| 172720 | -2, /* (359) carglist ::= carglist ccons */ |
| 172721 | 0, /* (360) carglist ::= */ |
| 172722 | -2, /* (361) ccons ::= NULL onconf */ |
| 172723 | -4, /* (362) ccons ::= GENERATED ALWAYS AS generated */ |
| 172724 | -2, /* (363) ccons ::= AS generated */ |
| 172725 | -2, /* (364) conslist_opt ::= COMMA conslist */ |
| 172726 | -3, /* (365) conslist ::= conslist tconscomma tcons */ |
| 172727 | -1, /* (366) conslist ::= tcons */ |
| 172728 | 0, /* (367) tconscomma ::= */ |
| 172729 | -1, /* (368) defer_subclause_opt ::= defer_subclause */ |
| 172730 | -1, /* (369) resolvetype ::= raisetype */ |
| 172731 | -1, /* (370) selectnowith ::= oneselect */ |
| 172732 | -1, /* (371) oneselect ::= values */ |
| 172733 | -2, /* (372) sclp ::= selcollist COMMA */ |
| 172734 | -1, /* (373) as ::= ID|STRING */ |
| 172735 | -1, /* (374) indexed_opt ::= indexed_by */ |
| 172736 | 0, /* (375) returning ::= */ |
| 172737 | -1, /* (376) expr ::= term */ |
| 172738 | -1, /* (377) likeop ::= LIKE_KW|MATCH */ |
| 172739 | -1, /* (378) case_operand ::= expr */ |
| 172740 | -1, /* (379) exprlist ::= nexprlist */ |
| 172741 | -1, /* (380) nmnum ::= plus_num */ |
| 172742 | -1, /* (381) nmnum ::= nm */ |
| 172743 | -1, /* (382) nmnum ::= ON */ |
| 172744 | -1, /* (383) nmnum ::= DELETE */ |
| 172745 | -1, /* (384) nmnum ::= DEFAULT */ |
| 172746 | -1, /* (385) plus_num ::= INTEGER|FLOAT */ |
| 172747 | 0, /* (386) foreach_clause ::= */ |
| 172748 | -3, /* (387) foreach_clause ::= FOR EACH ROW */ |
| 172749 | -1, /* (388) trnm ::= nm */ |
| 172750 | 0, /* (389) tridxby ::= */ |
| 172751 | -1, /* (390) database_kw_opt ::= DATABASE */ |
| 172752 | 0, /* (391) database_kw_opt ::= */ |
| 172753 | 0, /* (392) kwcolumn_opt ::= */ |
| 172754 | -1, /* (393) kwcolumn_opt ::= COLUMNKW */ |
| 172755 | -1, /* (394) vtabarglist ::= vtabarg */ |
| 172756 | -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 172757 | -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ |
| 172758 | 0, /* (397) anylist ::= */ |
| 172759 | -4, /* (398) anylist ::= anylist LP anylist RP */ |
| 172760 | -2, /* (399) anylist ::= anylist ANY */ |
| 172761 | 0, /* (400) with ::= */ |
| 172762 | -1, /* (401) windowdefn_list ::= windowdefn */ |
| 172763 | -1, /* (402) window ::= frame_opt */ |
| 172764 | }; |
| 172765 | |
| 172766 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 172767 | |
| 172768 | /* |
| @@ -172818,11 +173875,11 @@ | |
| 172818 | {yymsp[1].minor.yy394 = TK_DEFERRED;} |
| 172819 | break; |
| 172820 | case 5: /* transtype ::= DEFERRED */ |
| 172821 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 172822 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 172823 | case 319: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==319); |
| 172824 | {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} |
| 172825 | break; |
| 172826 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 172827 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| 172828 | {sqlite3EndTransaction(pParse,yymsp[-1].major);} |
| @@ -172855,11 +173912,11 @@ | |
| 172855 | case 47: /* autoinc ::= */ yytestcase(yyruleno==47); |
| 172856 | case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62); |
| 172857 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 172858 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 172859 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); |
| 172860 | case 242: /* collate ::= */ yytestcase(yyruleno==242); |
| 172861 | {yymsp[1].minor.yy394 = 0;} |
| 172862 | break; |
| 172863 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 172864 | {yymsp[-2].minor.yy394 = 1;} |
| 172865 | break; |
| @@ -173039,13 +174096,13 @@ | |
| 173039 | case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171); |
| 173040 | {yymsp[-1].minor.yy394 = yymsp[0].minor.yy394;} |
| 173041 | break; |
| 173042 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 173043 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 173044 | case 215: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==215); |
| 173045 | case 218: /* in_op ::= NOT IN */ yytestcase(yyruleno==218); |
| 173046 | case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243); |
| 173047 | {yymsp[-1].minor.yy394 = 1;} |
| 173048 | break; |
| 173049 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 173050 | {yymsp[-1].minor.yy394 = 0;} |
| 173051 | break; |
| @@ -173190,13 +174247,13 @@ | |
| 173190 | {yymsp[0].minor.yy394 = SF_All;} |
| 173191 | break; |
| 173192 | case 99: /* sclp ::= */ |
| 173193 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); |
| 173194 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); |
| 173195 | case 230: /* exprlist ::= */ yytestcase(yyruleno==230); |
| 173196 | case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233); |
| 173197 | case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238); |
| 173198 | {yymsp[1].minor.yy322 = 0;} |
| 173199 | break; |
| 173200 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 173201 | { |
| 173202 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| @@ -173221,12 +174278,12 @@ | |
| 173221 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot); |
| 173222 | } |
| 173223 | break; |
| 173224 | case 103: /* as ::= AS nm */ |
| 173225 | case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); |
| 173226 | case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); |
| 173227 | case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); |
| 173228 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 173229 | break; |
| 173230 | case 105: /* from ::= */ |
| 173231 | case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108); |
| 173232 | {yymsp[1].minor.yy131 = 0;} |
| @@ -173394,20 +174451,20 @@ | |
| 173394 | break; |
| 173395 | case 144: /* having_opt ::= */ |
| 173396 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 173397 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 173398 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 173399 | case 228: /* case_else ::= */ yytestcase(yyruleno==228); |
| 173400 | case 229: /* case_operand ::= */ yytestcase(yyruleno==229); |
| 173401 | case 248: /* vinto ::= */ yytestcase(yyruleno==248); |
| 173402 | {yymsp[1].minor.yy528 = 0;} |
| 173403 | break; |
| 173404 | case 145: /* having_opt ::= HAVING expr */ |
| 173405 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 173406 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 173407 | case 227: /* case_else ::= ELSE expr */ yytestcase(yyruleno==227); |
| 173408 | case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); |
| 173409 | {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 173410 | break; |
| 173411 | case 147: /* limit_opt ::= LIMIT expr */ |
| 173412 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);} |
| 173413 | break; |
| @@ -173589,37 +174646,52 @@ | |
| 173589 | { |
| 173590 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy394); |
| 173591 | } |
| 173592 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 173593 | break; |
| 173594 | case 188: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 173595 | { |
| 173596 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 173597 | } |
| 173598 | yymsp[-3].minor.yy528 = yylhsminor.yy528; |
| 173599 | break; |
| 173600 | case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 173601 | { |
| 173602 | 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); |
| 173604 | } |
| 173605 | yymsp[-5].minor.yy528 = yylhsminor.yy528; |
| 173606 | break; |
| 173607 | case 190: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 173608 | { |
| 173609 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 173610 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 173611 | } |
| 173612 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 173613 | break; |
| 173614 | case 191: /* term ::= CTIME_KW */ |
| 173615 | { |
| 173616 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 173617 | } |
| 173618 | yymsp[0].minor.yy528 = yylhsminor.yy528; |
| 173619 | break; |
| 173620 | case 192: /* expr ::= LP nexprlist COMMA expr RP */ |
| 173621 | { |
| 173622 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); |
| 173623 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 173624 | if( yymsp[-4].minor.yy528 ){ |
| 173625 | yymsp[-4].minor.yy528->x.pList = pList; |
| @@ -173629,26 +174701,26 @@ | |
| 173629 | }else{ |
| 173630 | sqlite3ExprListDelete(pParse->db, pList); |
| 173631 | } |
| 173632 | } |
| 173633 | break; |
| 173634 | case 193: /* expr ::= expr AND expr */ |
| 173635 | {yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 173636 | break; |
| 173637 | case 194: /* expr ::= expr OR expr */ |
| 173638 | case 195: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==195); |
| 173639 | case 196: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==196); |
| 173640 | case 197: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==197); |
| 173641 | case 198: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==198); |
| 173642 | case 199: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==199); |
| 173643 | case 200: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==200); |
| 173644 | {yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 173645 | break; |
| 173646 | case 201: /* 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*/} |
| 173648 | break; |
| 173649 | case 202: /* expr ::= expr likeop expr */ |
| 173650 | { |
| 173651 | ExprList *pList; |
| 173652 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 173653 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 173654 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy528); |
| @@ -173656,11 +174728,11 @@ | |
| 173656 | yymsp[-2].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 173657 | if( bNot ) yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy528, 0); |
| 173658 | if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; |
| 173659 | } |
| 173660 | break; |
| 173661 | case 203: /* expr ::= expr likeop expr ESCAPE expr */ |
| 173662 | { |
| 173663 | ExprList *pList; |
| 173664 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 173665 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 173666 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| @@ -173669,63 +174741,63 @@ | |
| 173669 | yymsp[-4].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 173670 | if( bNot ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173671 | if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; |
| 173672 | } |
| 173673 | break; |
| 173674 | case 204: /* expr ::= expr ISNULL|NOTNULL */ |
| 173675 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} |
| 173676 | break; |
| 173677 | case 205: /* expr ::= expr NOT NULL */ |
| 173678 | {yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} |
| 173679 | break; |
| 173680 | case 206: /* expr ::= expr IS expr */ |
| 173681 | { |
| 173682 | 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); |
| 173684 | } |
| 173685 | break; |
| 173686 | case 207: /* expr ::= expr IS NOT expr */ |
| 173687 | { |
| 173688 | 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); |
| 173690 | } |
| 173691 | break; |
| 173692 | case 208: /* expr ::= expr IS NOT DISTINCT FROM expr */ |
| 173693 | { |
| 173694 | 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); |
| 173696 | } |
| 173697 | break; |
| 173698 | case 209: /* expr ::= expr IS DISTINCT FROM expr */ |
| 173699 | { |
| 173700 | 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); |
| 173702 | } |
| 173703 | break; |
| 173704 | case 210: /* expr ::= NOT expr */ |
| 173705 | case 211: /* expr ::= BITNOT expr */ yytestcase(yyruleno==211); |
| 173706 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} |
| 173707 | break; |
| 173708 | case 212: /* expr ::= PLUS|MINUS expr */ |
| 173709 | { |
| 173710 | yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); |
| 173711 | /*A-overwrites-B*/ |
| 173712 | } |
| 173713 | break; |
| 173714 | case 213: /* expr ::= expr PTR expr */ |
| 173715 | { |
| 173716 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); |
| 173717 | pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); |
| 173718 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 173719 | } |
| 173720 | yymsp[-2].minor.yy528 = yylhsminor.yy528; |
| 173721 | break; |
| 173722 | case 214: /* between_op ::= BETWEEN */ |
| 173723 | case 217: /* in_op ::= IN */ yytestcase(yyruleno==217); |
| 173724 | {yymsp[0].minor.yy394 = 0;} |
| 173725 | break; |
| 173726 | case 216: /* expr ::= expr between_op expr AND expr */ |
| 173727 | { |
| 173728 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 173729 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); |
| 173730 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy528, 0); |
| 173731 | if( yymsp[-4].minor.yy528 ){ |
| @@ -173734,11 +174806,11 @@ | |
| 173734 | sqlite3ExprListDelete(pParse->db, pList); |
| 173735 | } |
| 173736 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173737 | } |
| 173738 | break; |
| 173739 | case 219: /* expr ::= expr in_op LP exprlist RP */ |
| 173740 | { |
| 173741 | if( yymsp[-1].minor.yy322==0 ){ |
| 173742 | /* Expressions of the form |
| 173743 | ** |
| 173744 | ** expr1 IN () |
| @@ -173780,41 +174852,41 @@ | |
| 173780 | } |
| 173781 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173782 | } |
| 173783 | } |
| 173784 | break; |
| 173785 | case 220: /* expr ::= LP select RP */ |
| 173786 | { |
| 173787 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 173788 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); |
| 173789 | } |
| 173790 | break; |
| 173791 | case 221: /* expr ::= expr in_op LP select RP */ |
| 173792 | { |
| 173793 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 173794 | 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); |
| 173796 | } |
| 173797 | break; |
| 173798 | case 222: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 173799 | { |
| 173800 | 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); |
| 173802 | if( yymsp[0].minor.yy322 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322); |
| 173803 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 173804 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelect); |
| 173805 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 173806 | } |
| 173807 | break; |
| 173808 | case 223: /* expr ::= EXISTS LP select RP */ |
| 173809 | { |
| 173810 | Expr *p; |
| 173811 | p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 173812 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); |
| 173813 | } |
| 173814 | break; |
| 173815 | case 224: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 173816 | { |
| 173817 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); |
| 173818 | if( yymsp[-4].minor.yy528 ){ |
| 173819 | yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy528 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528) : yymsp[-2].minor.yy322; |
| 173820 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528); |
| @@ -173822,392 +174894,392 @@ | |
| 173822 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 173823 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| 173824 | } |
| 173825 | } |
| 173826 | break; |
| 173827 | case 225: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 173828 | { |
| 173829 | 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); |
| 173831 | } |
| 173832 | break; |
| 173833 | case 226: /* case_exprlist ::= WHEN expr THEN expr */ |
| 173834 | { |
| 173835 | 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); |
| 173837 | } |
| 173838 | break; |
| 173839 | case 231: /* nexprlist ::= nexprlist COMMA expr */ |
| 173840 | {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} |
| 173841 | break; |
| 173842 | case 232: /* nexprlist ::= expr */ |
| 173843 | {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} |
| 173844 | break; |
| 173845 | case 234: /* paren_exprlist ::= LP exprlist RP */ |
| 173846 | case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239); |
| 173847 | {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} |
| 173848 | break; |
| 173849 | case 235: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 173850 | { |
| 173851 | 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, |
| 173853 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF); |
| 173854 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 173855 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 173856 | } |
| 173857 | } |
| 173858 | break; |
| 173859 | case 236: /* uniqueflag ::= UNIQUE */ |
| 173860 | case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278); |
| 173861 | {yymsp[0].minor.yy394 = OE_Abort;} |
| 173862 | break; |
| 173863 | case 237: /* uniqueflag ::= */ |
| 173864 | {yymsp[1].minor.yy394 = OE_None;} |
| 173865 | break; |
| 173866 | case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 173867 | { |
| 173868 | yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); |
| 173869 | } |
| 173870 | break; |
| 173871 | case 241: /* eidlist ::= nm collate sortorder */ |
| 173872 | { |
| 173873 | yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ |
| 173874 | } |
| 173875 | break; |
| 173876 | case 244: /* cmd ::= DROP INDEX ifexists fullname */ |
| 173877 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} |
| 173878 | break; |
| 173879 | case 245: /* cmd ::= VACUUM vinto */ |
| 173880 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} |
| 173881 | break; |
| 173882 | case 246: /* cmd ::= VACUUM nm vinto */ |
| 173883 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} |
| 173884 | break; |
| 173885 | case 249: /* cmd ::= PRAGMA nm dbnm */ |
| 173886 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 173887 | break; |
| 173888 | case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 173889 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 173890 | break; |
| 173891 | case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 173892 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 173893 | break; |
| 173894 | case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 173895 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 173896 | break; |
| 173897 | case 253: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 173898 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 173899 | break; |
| 173900 | case 256: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 173901 | { |
| 173902 | Token all; |
| 173903 | all.z = yymsp[-3].minor.yy0.z; |
| 173904 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 173905 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); |
| 173906 | } |
| 173907 | break; |
| 173908 | case 257: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 173909 | { |
| 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); |
| 173911 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 173912 | } |
| 173913 | break; |
| 173914 | case 258: /* trigger_time ::= BEFORE|AFTER */ |
| 173915 | { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } |
| 173916 | break; |
| 173917 | case 259: /* trigger_time ::= INSTEAD OF */ |
| 173918 | { yymsp[-1].minor.yy394 = TK_INSTEAD;} |
| 173919 | break; |
| 173920 | case 260: /* trigger_time ::= */ |
| 173921 | { yymsp[1].minor.yy394 = TK_BEFORE; } |
| 173922 | break; |
| 173923 | case 261: /* trigger_event ::= DELETE|INSERT */ |
| 173924 | case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262); |
| 173925 | {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} |
| 173926 | break; |
| 173927 | case 263: /* trigger_event ::= UPDATE OF idlist */ |
| 173928 | {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} |
| 173929 | break; |
| 173930 | case 264: /* when_clause ::= */ |
| 173931 | case 283: /* key_opt ::= */ yytestcase(yyruleno==283); |
| 173932 | { yymsp[1].minor.yy528 = 0; } |
| 173933 | break; |
| 173934 | case 265: /* when_clause ::= WHEN expr */ |
| 173935 | case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284); |
| 173936 | { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } |
| 173937 | break; |
| 173938 | case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 173939 | { |
| 173940 | assert( yymsp[-2].minor.yy33!=0 ); |
| 173941 | yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; |
| 173942 | yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 173943 | } |
| 173944 | break; |
| 173945 | case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 173946 | { |
| 173947 | assert( yymsp[-1].minor.yy33!=0 ); |
| 173948 | yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 173949 | } |
| 173950 | break; |
| 173951 | case 268: /* trnm ::= nm DOT nm */ |
| 173952 | { |
| 173953 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 173954 | sqlite3ErrorMsg(pParse, |
| 173955 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 173956 | "statements within triggers"); |
| 173957 | } |
| 173958 | break; |
| 173959 | case 269: /* tridxby ::= INDEXED BY nm */ |
| 173960 | { |
| 173961 | sqlite3ErrorMsg(pParse, |
| 173962 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 173963 | "within triggers"); |
| 173964 | } |
| 173965 | break; |
| 173966 | case 270: /* tridxby ::= NOT INDEXED */ |
| 173967 | { |
| 173968 | sqlite3ErrorMsg(pParse, |
| 173969 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 173970 | "within triggers"); |
| 173971 | } |
| 173972 | break; |
| 173973 | case 271: /* 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);} |
| 173975 | yymsp[-8].minor.yy33 = yylhsminor.yy33; |
| 173976 | break; |
| 173977 | case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 173978 | { |
| 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*/ |
| 173980 | } |
| 173981 | yymsp[-7].minor.yy33 = yylhsminor.yy33; |
| 173982 | break; |
| 173983 | case 273: /* 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);} |
| 173985 | yymsp[-5].minor.yy33 = yylhsminor.yy33; |
| 173986 | break; |
| 173987 | case 274: /* 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*/} |
| 173989 | yymsp[-2].minor.yy33 = yylhsminor.yy33; |
| 173990 | break; |
| 173991 | case 275: /* expr ::= RAISE LP IGNORE RP */ |
| 173992 | { |
| 173993 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 173994 | if( yymsp[-3].minor.yy528 ){ |
| 173995 | yymsp[-3].minor.yy528->affExpr = OE_Ignore; |
| 173996 | } |
| 173997 | } |
| 173998 | break; |
| 173999 | case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 174000 | { |
| 174001 | yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 174002 | if( yymsp[-5].minor.yy528 ) { |
| 174003 | yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394; |
| 174004 | } |
| 174005 | } |
| 174006 | break; |
| 174007 | case 277: /* raisetype ::= ROLLBACK */ |
| 174008 | {yymsp[0].minor.yy394 = OE_Rollback;} |
| 174009 | break; |
| 174010 | case 279: /* raisetype ::= FAIL */ |
| 174011 | {yymsp[0].minor.yy394 = OE_Fail;} |
| 174012 | break; |
| 174013 | case 280: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 174014 | { |
| 174015 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); |
| 174016 | } |
| 174017 | break; |
| 174018 | case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 174019 | { |
| 174020 | sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); |
| 174021 | } |
| 174022 | break; |
| 174023 | case 282: /* cmd ::= DETACH database_kw_opt expr */ |
| 174024 | { |
| 174025 | sqlite3Detach(pParse, yymsp[0].minor.yy528); |
| 174026 | } |
| 174027 | break; |
| 174028 | case 285: /* cmd ::= REINDEX */ |
| 174029 | {sqlite3Reindex(pParse, 0, 0);} |
| 174030 | break; |
| 174031 | case 286: /* cmd ::= REINDEX nm dbnm */ |
| 174032 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 174033 | break; |
| 174034 | case 287: /* cmd ::= ANALYZE */ |
| 174035 | {sqlite3Analyze(pParse, 0, 0);} |
| 174036 | break; |
| 174037 | case 288: /* cmd ::= ANALYZE nm dbnm */ |
| 174038 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 174039 | break; |
| 174040 | case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 174041 | { |
| 174042 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); |
| 174043 | } |
| 174044 | break; |
| 174045 | case 290: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 174046 | { |
| 174047 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 174048 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 174049 | } |
| 174050 | break; |
| 174051 | case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 174052 | { |
| 174053 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); |
| 174054 | } |
| 174055 | break; |
| 174056 | case 292: /* add_column_fullname ::= fullname */ |
| 174057 | { |
| 174058 | disableLookaside(pParse); |
| 174059 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); |
| 174060 | } |
| 174061 | break; |
| 174062 | case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 174063 | { |
| 174064 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 174065 | } |
| 174066 | break; |
| 174067 | case 294: /* cmd ::= create_vtab */ |
| 174068 | {sqlite3VtabFinishParse(pParse,0);} |
| 174069 | break; |
| 174070 | case 295: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 174071 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 174072 | break; |
| 174073 | case 296: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 174074 | { |
| 174075 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); |
| 174076 | } |
| 174077 | break; |
| 174078 | case 297: /* vtabarg ::= */ |
| 174079 | {sqlite3VtabArgInit(pParse);} |
| 174080 | break; |
| 174081 | case 298: /* vtabargtoken ::= ANY */ |
| 174082 | case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299); |
| 174083 | case 300: /* lp ::= LP */ yytestcase(yyruleno==300); |
| 174084 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 174085 | break; |
| 174086 | case 301: /* with ::= WITH wqlist */ |
| 174087 | case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302); |
| 174088 | { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } |
| 174089 | break; |
| 174090 | case 303: /* wqas ::= AS */ |
| 174091 | {yymsp[0].minor.yy516 = M10d_Any;} |
| 174092 | break; |
| 174093 | case 304: /* wqas ::= AS MATERIALIZED */ |
| 174094 | {yymsp[-1].minor.yy516 = M10d_Yes;} |
| 174095 | break; |
| 174096 | case 305: /* wqas ::= AS NOT MATERIALIZED */ |
| 174097 | {yymsp[-2].minor.yy516 = M10d_No;} |
| 174098 | break; |
| 174099 | case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 174100 | { |
| 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*/ |
| 174102 | } |
| 174103 | break; |
| 174104 | case 307: /* wqlist ::= wqitem */ |
| 174105 | { |
| 174106 | yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ |
| 174107 | } |
| 174108 | break; |
| 174109 | case 308: /* wqlist ::= wqlist COMMA wqitem */ |
| 174110 | { |
| 174111 | yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); |
| 174112 | } |
| 174113 | break; |
| 174114 | case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 174115 | { |
| 174116 | assert( yymsp[0].minor.yy41!=0 ); |
| 174117 | sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); |
| 174118 | yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41; |
| 174119 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174120 | } |
| 174121 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 174122 | break; |
| 174123 | case 310: /* windowdefn ::= nm AS LP window RP */ |
| 174124 | { |
| 174125 | 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); |
| 174127 | } |
| 174128 | yylhsminor.yy41 = yymsp[-1].minor.yy41; |
| 174129 | } |
| 174130 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 174131 | break; |
| 174132 | case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 174133 | { |
| 174134 | yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); |
| 174135 | } |
| 174136 | break; |
| 174137 | case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 174138 | { |
| 174139 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); |
| 174140 | } |
| 174141 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 174142 | break; |
| 174143 | case 313: /* window ::= ORDER BY sortlist frame_opt */ |
| 174144 | { |
| 174145 | yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); |
| 174146 | } |
| 174147 | break; |
| 174148 | case 314: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 174149 | { |
| 174150 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| 174151 | } |
| 174152 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 174153 | break; |
| 174154 | case 315: /* window ::= nm frame_opt */ |
| 174155 | { |
| 174156 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); |
| 174157 | } |
| 174158 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 174159 | break; |
| 174160 | case 316: /* frame_opt ::= */ |
| 174161 | { |
| 174162 | yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 174163 | } |
| 174164 | break; |
| 174165 | case 317: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 174166 | { |
| 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); |
| 174168 | } |
| 174169 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 174170 | break; |
| 174171 | case 318: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 174172 | { |
| 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); |
| 174174 | } |
| 174175 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 174176 | break; |
| 174177 | case 320: /* frame_bound_s ::= frame_bound */ |
| 174178 | case 322: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==322); |
| 174179 | {yylhsminor.yy595 = yymsp[0].minor.yy595;} |
| 174180 | yymsp[0].minor.yy595 = yylhsminor.yy595; |
| 174181 | break; |
| 174182 | case 321: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 174183 | case 323: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==323); |
| 174184 | case 325: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==325); |
| 174185 | {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} |
| 174186 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 174187 | break; |
| 174188 | case 324: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 174189 | {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} |
| 174190 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 174191 | break; |
| 174192 | case 326: /* frame_exclude_opt ::= */ |
| 174193 | {yymsp[1].minor.yy516 = 0;} |
| 174194 | break; |
| 174195 | case 327: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 174196 | {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} |
| 174197 | break; |
| 174198 | case 328: /* frame_exclude ::= NO OTHERS */ |
| 174199 | case 329: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==329); |
| 174200 | {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} |
| 174201 | break; |
| 174202 | case 330: /* frame_exclude ::= GROUP|TIES */ |
| 174203 | {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} |
| 174204 | break; |
| 174205 | case 331: /* window_clause ::= WINDOW windowdefn_list */ |
| 174206 | { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } |
| 174207 | break; |
| 174208 | case 332: /* filter_over ::= filter_clause over_clause */ |
| 174209 | { |
| 174210 | if( yymsp[0].minor.yy41 ){ |
| 174211 | yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; |
| 174212 | }else{ |
| 174213 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| @@ -174214,17 +175286,17 @@ | |
| 174214 | } |
| 174215 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174216 | } |
| 174217 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 174218 | break; |
| 174219 | case 333: /* filter_over ::= over_clause */ |
| 174220 | { |
| 174221 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 174222 | } |
| 174223 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 174224 | break; |
| 174225 | case 334: /* filter_over ::= filter_clause */ |
| 174226 | { |
| 174227 | yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 174228 | if( yylhsminor.yy41 ){ |
| 174229 | yylhsminor.yy41->eFrmType = TK_FILTER; |
| 174230 | yylhsminor.yy41->pFilter = yymsp[0].minor.yy528; |
| @@ -174232,93 +175304,93 @@ | |
| 174232 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528); |
| 174233 | } |
| 174234 | } |
| 174235 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 174236 | break; |
| 174237 | case 335: /* over_clause ::= OVER LP window RP */ |
| 174238 | { |
| 174239 | yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; |
| 174240 | assert( yymsp[-3].minor.yy41!=0 ); |
| 174241 | } |
| 174242 | break; |
| 174243 | case 336: /* over_clause ::= OVER nm */ |
| 174244 | { |
| 174245 | yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 174246 | if( yymsp[-1].minor.yy41 ){ |
| 174247 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 174248 | } |
| 174249 | } |
| 174250 | break; |
| 174251 | case 337: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 174252 | { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } |
| 174253 | break; |
| 174254 | default: |
| 174255 | /* (338) input ::= cmdlist */ yytestcase(yyruleno==338); |
| 174256 | /* (339) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==339); |
| 174257 | /* (340) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=340); |
| 174258 | /* (341) ecmd ::= SEMI */ yytestcase(yyruleno==341); |
| 174259 | /* (342) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==342); |
| 174260 | /* (343) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=343); |
| 174261 | /* (344) trans_opt ::= */ yytestcase(yyruleno==344); |
| 174262 | /* (345) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==345); |
| 174263 | /* (346) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==346); |
| 174264 | /* (347) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==347); |
| 174265 | /* (348) savepoint_opt ::= */ yytestcase(yyruleno==348); |
| 174266 | /* (349) cmd ::= create_table create_table_args */ yytestcase(yyruleno==349); |
| 174267 | /* (350) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=350); |
| 174268 | /* (351) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==351); |
| 174269 | /* (352) columnlist ::= columnname carglist */ yytestcase(yyruleno==352); |
| 174270 | /* (353) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==353); |
| 174271 | /* (354) nm ::= STRING */ yytestcase(yyruleno==354); |
| 174272 | /* (355) typetoken ::= typename */ yytestcase(yyruleno==355); |
| 174273 | /* (356) typename ::= ID|STRING */ yytestcase(yyruleno==356); |
| 174274 | /* (357) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); |
| 174275 | /* (358) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=358); |
| 174276 | /* (359) carglist ::= carglist ccons */ yytestcase(yyruleno==359); |
| 174277 | /* (360) carglist ::= */ yytestcase(yyruleno==360); |
| 174278 | /* (361) ccons ::= NULL onconf */ yytestcase(yyruleno==361); |
| 174279 | /* (362) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==362); |
| 174280 | /* (363) ccons ::= AS generated */ yytestcase(yyruleno==363); |
| 174281 | /* (364) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==364); |
| 174282 | /* (365) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==365); |
| 174283 | /* (366) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=366); |
| 174284 | /* (367) tconscomma ::= */ yytestcase(yyruleno==367); |
| 174285 | /* (368) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=368); |
| 174286 | /* (369) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=369); |
| 174287 | /* (370) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=370); |
| 174288 | /* (371) oneselect ::= values */ yytestcase(yyruleno==371); |
| 174289 | /* (372) sclp ::= selcollist COMMA */ yytestcase(yyruleno==372); |
| 174290 | /* (373) as ::= ID|STRING */ yytestcase(yyruleno==373); |
| 174291 | /* (374) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=374); |
| 174292 | /* (375) returning ::= */ yytestcase(yyruleno==375); |
| 174293 | /* (376) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=376); |
| 174294 | /* (377) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==377); |
| 174295 | /* (378) case_operand ::= expr */ yytestcase(yyruleno==378); |
| 174296 | /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); |
| 174297 | /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); |
| 174298 | /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); |
| 174299 | /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); |
| 174300 | /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); |
| 174301 | /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); |
| 174302 | /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); |
| 174303 | /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); |
| 174304 | /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); |
| 174305 | /* (388) trnm ::= nm */ yytestcase(yyruleno==388); |
| 174306 | /* (389) tridxby ::= */ yytestcase(yyruleno==389); |
| 174307 | /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); |
| 174308 | /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); |
| 174309 | /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); |
| 174310 | /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); |
| 174311 | /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); |
| 174312 | /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); |
| 174313 | /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); |
| 174314 | /* (397) anylist ::= */ yytestcase(yyruleno==397); |
| 174315 | /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); |
| 174316 | /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); |
| 174317 | /* (400) with ::= */ yytestcase(yyruleno==400); |
| 174318 | /* (401) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=401); |
| 174319 | /* (402) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=402); |
| 174320 | break; |
| 174321 | /********** End reduce actions ************************************************/ |
| 174322 | }; |
| 174323 | assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) ); |
| 174324 | yygoto = yyRuleInfoLhs[yyruleno]; |
| @@ -176438,11 +177510,13 @@ | |
| 176438 | SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*); |
| 176439 | #endif |
| 176440 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 176441 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); |
| 176442 | #endif |
| 176443 | |
| 176444 | /* |
| 176445 | ** An array of pointers to extension initializer functions for |
| 176446 | ** built-in extensions. |
| 176447 | */ |
| 176448 | static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = { |
| @@ -176471,10 +177545,13 @@ | |
| 176471 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 176472 | sqlite3StmtVtabInit, |
| 176473 | #endif |
| 176474 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 176475 | sqlite3VdbeBytecodeVtabInit, |
| 176476 | #endif |
| 176477 | }; |
| 176478 | |
| 176479 | #ifndef SQLITE_AMALGAMATION |
| 176480 | /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant |
| @@ -176544,10 +177621,36 @@ | |
| 176544 | ** all database files specified with a relative pathname. |
| 176545 | ** |
| 176546 | ** See also the "PRAGMA data_store_directory" SQL command. |
| 176547 | */ |
| 176548 | SQLITE_API char *sqlite3_data_directory = 0; |
| 176549 | |
| 176550 | /* |
| 176551 | ** Initialize SQLite. |
| 176552 | ** |
| 176553 | ** This routine must be called to initialize the memory allocation, |
| @@ -176739,10 +177842,14 @@ | |
| 176739 | if( bRunExtraInit ){ |
| 176740 | int SQLITE_EXTRA_INIT(const char*); |
| 176741 | rc = SQLITE_EXTRA_INIT(0); |
| 176742 | } |
| 176743 | #endif |
| 176744 | |
| 176745 | return rc; |
| 176746 | } |
| 176747 | |
| 176748 | /* |
| @@ -177310,10 +178417,14 @@ | |
| 177310 | ** Configuration settings for an individual database connection |
| 177311 | */ |
| 177312 | SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ |
| 177313 | va_list ap; |
| 177314 | int rc; |
| 177315 | sqlite3_mutex_enter(db->mutex); |
| 177316 | va_start(ap, op); |
| 177317 | switch( op ){ |
| 177318 | case SQLITE_DBCONFIG_MAINDBNAME: { |
| 177319 | /* IMP: R-06824-28531 */ |
| @@ -177638,10 +178749,18 @@ | |
| 177638 | if( sqlite3GlobalConfig.xSqllog ){ |
| 177639 | /* Closing the handle. Fourth parameter is passed the value 2. */ |
| 177640 | sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2); |
| 177641 | } |
| 177642 | #endif |
| 177643 | |
| 177644 | /* Convert the connection into a zombie and then close it. |
| 177645 | */ |
| 177646 | db->eOpenState = SQLITE_STATE_ZOMBIE; |
| 177647 | sqlite3LeaveMutexAndCloseZombie(db); |
| @@ -178713,10 +179832,16 @@ | |
| 178713 | void(*xCallback)( /* Callback function */ |
| 178714 | void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64), |
| 178715 | void *pArg /* First callback argument */ |
| 178716 | ){ |
| 178717 | void *pRet; |
| 178718 | sqlite3_mutex_enter(db->mutex); |
| 178719 | pRet = db->pPreUpdateArg; |
| 178720 | db->xPreUpdateCallback = xCallback; |
| 178721 | db->pPreUpdateArg = pArg; |
| 178722 | sqlite3_mutex_leave(db->mutex); |
| @@ -178859,11 +179984,11 @@ | |
| 178859 | assert( SQLITE_CHECKPOINT_RESTART==2 ); |
| 178860 | assert( SQLITE_CHECKPOINT_TRUNCATE==3 ); |
| 178861 | if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){ |
| 178862 | /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint |
| 178863 | ** mode: */ |
| 178864 | return SQLITE_MISUSE; |
| 178865 | } |
| 178866 | |
| 178867 | sqlite3_mutex_enter(db->mutex); |
| 178868 | if( zDb && zDb[0] ){ |
| 178869 | iDb = sqlite3FindDbName(db, zDb); |
| @@ -180095,10 +181220,73 @@ | |
| 180095 | db->pCollNeededArg = pCollNeededArg; |
| 180096 | sqlite3_mutex_leave(db->mutex); |
| 180097 | return SQLITE_OK; |
| 180098 | } |
| 180099 | #endif /* SQLITE_OMIT_UTF16 */ |
| 180100 | |
| 180101 | #ifndef SQLITE_OMIT_DEPRECATED |
| 180102 | /* |
| 180103 | ** This function is now an anachronism. It used to be used to recover from a |
| 180104 | ** malloc() failure, but SQLite now does this automatically. |
| @@ -180444,10 +181632,32 @@ | |
| 180444 | sqlite3Config.iPrngSeed = x; |
| 180445 | sqlite3_randomness(0,0); |
| 180446 | break; |
| 180447 | } |
| 180448 | #endif |
| 180449 | |
| 180450 | /* |
| 180451 | ** sqlite3_test_control(BITVEC_TEST, size, program) |
| 180452 | ** |
| 180453 | ** Run a test against a Bitvec object of size. The program argument |
| @@ -180869,15 +182079,15 @@ | |
| 180869 | /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X); |
| 180870 | ** |
| 180871 | ** X<0 Make no changes to the bUseLongDouble. Just report value. |
| 180872 | ** X==0 Disable bUseLongDouble |
| 180873 | ** X==1 Enable bUseLongDouble |
| 180874 | ** X==2 Set bUseLongDouble to its default value for this platform |
| 180875 | */ |
| 180876 | case SQLITE_TESTCTRL_USELONGDOUBLE: { |
| 180877 | int b = va_arg(ap, int); |
| 180878 | if( b==2 ) b = sizeof(LONGDOUBLE_TYPE)>8; |
| 180879 | if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; |
| 180880 | rc = sqlite3Config.bUseLongDouble!=0; |
| 180881 | break; |
| 180882 | } |
| 180883 | #endif |
| @@ -181287,11 +182497,11 @@ | |
| 181287 | SQLITE_API int sqlite3_compileoption_used(const char *zOptName){ |
| 181288 | int i, n; |
| 181289 | int nOpt; |
| 181290 | const char **azCompileOpt; |
| 181291 | |
| 181292 | #if SQLITE_ENABLE_API_ARMOR |
| 181293 | if( zOptName==0 ){ |
| 181294 | (void)SQLITE_MISUSE_BKPT; |
| 181295 | return 0; |
| 181296 | } |
| 181297 | #endif |
| @@ -181482,10 +182692,13 @@ | |
| 181482 | void (*xNotify)(void **, int), |
| 181483 | void *pArg |
| 181484 | ){ |
| 181485 | int rc = SQLITE_OK; |
| 181486 | |
| 181487 | sqlite3_mutex_enter(db->mutex); |
| 181488 | enterMutex(); |
| 181489 | |
| 181490 | if( xNotify==0 ){ |
| 181491 | removeFromBlockedList(db); |
| @@ -182503,10 +183716,11 @@ | |
| 182503 | u8 bDescIdx; /* True if doclists are in reverse order */ |
| 182504 | u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */ |
| 182505 | int nPgsz; /* Page size for host database */ |
| 182506 | char *zSegmentsTbl; /* Name of %_segments table */ |
| 182507 | sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ |
| 182508 | |
| 182509 | /* |
| 182510 | ** The following array of hash tables is used to buffer pending index |
| 182511 | ** updates during transactions. All pending updates buffered at any one |
| 182512 | ** time must share a common language-id (see the FTS4 langid= feature). |
| @@ -183246,10 +184460,11 @@ | |
| 183246 | char *zCols; /* List of user defined columns */ |
| 183247 | const char *zLanguageid; |
| 183248 | |
| 183249 | zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); |
| 183250 | sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 183251 | |
| 183252 | /* Create a list of user columns for the virtual table */ |
| 183253 | zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); |
| 183254 | for(i=1; zCols && i<p->nColumn; i++){ |
| 183255 | zCols = sqlite3_mprintf("%z%Q, ", zCols, p->azColumn[i]); |
| @@ -186495,10 +187710,12 @@ | |
| 186495 | assert( p->nPendingData==0 ); |
| 186496 | if( rc==SQLITE_OK ){ |
| 186497 | rc = sqlite3Fts3PendingTermsFlush(p); |
| 186498 | } |
| 186499 | |
| 186500 | if( p->zContentTbl==0 ){ |
| 186501 | fts3DbExec(&rc, db, |
| 186502 | "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", |
| 186503 | p->zDb, p->zName, zName |
| 186504 | ); |
| @@ -186522,10 +187739,12 @@ | |
| 186522 | ); |
| 186523 | fts3DbExec(&rc, db, |
| 186524 | "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", |
| 186525 | p->zDb, p->zName, zName |
| 186526 | ); |
| 186527 | return rc; |
| 186528 | } |
| 186529 | |
| 186530 | /* |
| 186531 | ** The xSavepoint() method. |
| @@ -186532,16 +187751,32 @@ | |
| 186532 | ** |
| 186533 | ** Flush the contents of the pending-terms table to disk. |
| 186534 | */ |
| 186535 | static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186536 | int rc = SQLITE_OK; |
| 186537 | UNUSED_PARAMETER(iSavepoint); |
| 186538 | assert( ((Fts3Table *)pVtab)->inTransaction ); |
| 186539 | assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint ); |
| 186540 | TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint ); |
| 186541 | if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){ |
| 186542 | rc = fts3SyncMethod(pVtab); |
| 186543 | } |
| 186544 | return rc; |
| 186545 | } |
| 186546 | |
| 186547 | /* |
| @@ -186548,30 +187783,31 @@ | |
| 186548 | ** The xRelease() method. |
| 186549 | ** |
| 186550 | ** This is a no-op. |
| 186551 | */ |
| 186552 | static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186553 | TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 186554 | UNUSED_PARAMETER(iSavepoint); |
| 186555 | UNUSED_PARAMETER(pVtab); |
| 186556 | assert( p->inTransaction ); |
| 186557 | assert( p->mxSavepoint >= iSavepoint ); |
| 186558 | TESTONLY( p->mxSavepoint = iSavepoint-1 ); |
| 186559 | return SQLITE_OK; |
| 186560 | } |
| 186561 | |
| 186562 | /* |
| 186563 | ** The xRollbackTo() method. |
| 186564 | ** |
| 186565 | ** Discard the contents of the pending terms table. |
| 186566 | */ |
| 186567 | static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 186568 | Fts3Table *p = (Fts3Table*)pVtab; |
| 186569 | UNUSED_PARAMETER(iSavepoint); |
| 186570 | assert( p->inTransaction ); |
| 186571 | TESTONLY( p->mxSavepoint = iSavepoint ); |
| 186572 | sqlite3Fts3PendingTermsClear(p); |
| 186573 | return SQLITE_OK; |
| 186574 | } |
| 186575 | |
| 186576 | /* |
| 186577 | ** Return true if zName is the extension on one of the shadow tables used |
| @@ -186585,13 +187821,37 @@ | |
| 186585 | for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 186586 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 186587 | } |
| 186588 | return 0; |
| 186589 | } |
| 186590 | |
| 186591 | static const sqlite3_module fts3Module = { |
| 186592 | /* iVersion */ 3, |
| 186593 | /* xCreate */ fts3CreateMethod, |
| 186594 | /* xConnect */ fts3ConnectMethod, |
| 186595 | /* xBestIndex */ fts3BestIndexMethod, |
| 186596 | /* xDisconnect */ fts3DisconnectMethod, |
| 186597 | /* xDestroy */ fts3DestroyMethod, |
| @@ -186611,10 +187871,11 @@ | |
| 186611 | /* xRename */ fts3RenameMethod, |
| 186612 | /* xSavepoint */ fts3SavepointMethod, |
| 186613 | /* xRelease */ fts3ReleaseMethod, |
| 186614 | /* xRollbackTo */ fts3RollbackToMethod, |
| 186615 | /* xShadowName */ fts3ShadowName, |
| 186616 | }; |
| 186617 | |
| 186618 | /* |
| 186619 | ** This function is registered as the module destructor (called when an |
| 186620 | ** FTS3 enabled database connection is closed). It frees the memory |
| @@ -189286,11 +190547,12 @@ | |
| 189286 | 0, /* xFindFunction */ |
| 189287 | 0, /* xRename */ |
| 189288 | 0, /* xSavepoint */ |
| 189289 | 0, /* xRelease */ |
| 189290 | 0, /* xRollbackTo */ |
| 189291 | 0 /* xShadowName */ |
| 189292 | }; |
| 189293 | int rc; /* Return code */ |
| 189294 | |
| 189295 | rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0); |
| 189296 | return rc; |
| @@ -192852,11 +194114,12 @@ | |
| 192852 | 0, /* xFindFunction */ |
| 192853 | 0, /* xRename */ |
| 192854 | 0, /* xSavepoint */ |
| 192855 | 0, /* xRelease */ |
| 192856 | 0, /* xRollbackTo */ |
| 192857 | 0 /* xShadowName */ |
| 192858 | }; |
| 192859 | int rc; /* Return code */ |
| 192860 | |
| 192861 | rc = sqlite3_create_module_v2( |
| 192862 | db, "fts3tokenize", &fts3tok_module, (void*)pHash, xDestroy |
| @@ -196193,11 +197456,10 @@ | |
| 196193 | |
| 196194 | for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){ |
| 196195 | rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); |
| 196196 | if( rc==SQLITE_DONE ) rc = SQLITE_OK; |
| 196197 | } |
| 196198 | sqlite3Fts3PendingTermsClear(p); |
| 196199 | |
| 196200 | /* Determine the auto-incr-merge setting if unknown. If enabled, |
| 196201 | ** estimate the number of leaf blocks of content to be written |
| 196202 | */ |
| 196203 | if( rc==SQLITE_OK && p->bHasStat |
| @@ -196215,10 +197477,14 @@ | |
| 196215 | p->nAutoincrmerge = 0; |
| 196216 | } |
| 196217 | rc = sqlite3_reset(pStmt); |
| 196218 | } |
| 196219 | } |
| 196220 | return rc; |
| 196221 | } |
| 196222 | |
| 196223 | /* |
| 196224 | ** Encode N integers as varints into a blob. |
| @@ -196902,13 +198168,17 @@ | |
| 196902 | nSpace = sqlite3Fts3VarintLen(nPrefix); |
| 196903 | nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 196904 | nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 196905 | |
| 196906 | /* 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 |
| 196908 | ** bytes, write this block out to the database. */ |
| 196909 | if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){ |
| 196910 | rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); |
| 196911 | pWriter->nWork++; |
| 196912 | |
| 196913 | /* Add the current term to the parent node. The term added to the |
| 196914 | ** parent must: |
| @@ -197236,11 +198506,11 @@ | |
| 197236 | pNode = &pWriter->aNodeWriter[i-1]; |
| 197237 | pNode->iBlock = reader.iChild; |
| 197238 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); |
| 197239 | blobGrowBuffer(&pNode->block, |
| 197240 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc |
| 197241 | ); |
| 197242 | if( rc==SQLITE_OK ){ |
| 197243 | memcpy(pNode->block.a, aBlock, nBlock); |
| 197244 | pNode->block.n = nBlock; |
| 197245 | memset(&pNode->block.a[nBlock], 0, FTS3_NODE_PADDING); |
| 197246 | } |
| @@ -198301,12 +199571,15 @@ | |
| 198301 | rc = fts3DoIntegrityCheck(p); |
| 198302 | }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){ |
| 198303 | rc = fts3DoIncrmerge(p, &zVal[6]); |
| 198304 | }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ |
| 198305 | rc = fts3DoAutoincrmerge(p, &zVal[10]); |
| 198306 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| 198307 | }else{ |
| 198308 | int v; |
| 198309 | if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ |
| 198310 | v = atoi(&zVal[9]); |
| 198311 | if( v>=24 && v<=p->nPgsz-35 ) p->nNodeSize = v; |
| 198312 | rc = SQLITE_OK; |
| @@ -198320,12 +199593,12 @@ | |
| 198320 | }else if( nVal>11 && 0==sqlite3_strnicmp(zVal,"mergecount=",11) ){ |
| 198321 | v = atoi(&zVal[11]); |
| 198322 | if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; |
| 198323 | rc = SQLITE_OK; |
| 198324 | } |
| 198325 | #endif |
| 198326 | } |
| 198327 | return rc; |
| 198328 | } |
| 198329 | |
| 198330 | #ifndef SQLITE_DISABLE_FTS4_DEFERRED |
| 198331 | /* |
| @@ -201834,11 +203107,11 @@ | |
| 201834 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 201835 | SQLITE_TRANSIENT, SQLITE_UTF8); |
| 201836 | }else if( jsonForceRCStr(p) ){ |
| 201837 | sqlite3RCStrRef(p->zBuf); |
| 201838 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 201839 | (void(*)(void*))sqlite3RCStrUnref, |
| 201840 | SQLITE_UTF8); |
| 201841 | } |
| 201842 | } |
| 201843 | if( p->bErr==1 ){ |
| 201844 | sqlite3_result_error_nomem(p->pCtx); |
| @@ -203174,11 +204447,11 @@ | |
| 203174 | } |
| 203175 | |
| 203176 | /* The input JSON was not found anywhere in the cache. We will need |
| 203177 | ** to parse it ourselves and generate a new JsonParse object. |
| 203178 | */ |
| 203179 | bJsonRCStr = sqlite3ValueIsOfClass(pJson,(void(*)(void*))sqlite3RCStrUnref); |
| 203180 | p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); |
| 203181 | if( p==0 ){ |
| 203182 | sqlite3_result_error_nomem(pCtx); |
| 203183 | return 0; |
| 203184 | } |
| @@ -203388,10 +204661,11 @@ | |
| 203388 | && (i>0 || ((pRoot[j].jnFlags & JNODE_REMOVE)!=0 && pParse->useMod)) |
| 203389 | ){ |
| 203390 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; |
| 203391 | j += jsonNodeSize(&pRoot[j]); |
| 203392 | } |
| 203393 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
| 203394 | if( pParse->useMod==0 ) break; |
| 203395 | assert( pRoot->eU==2 ); |
| 203396 | iRoot = pRoot->u.iAppend; |
| 203397 | pRoot = &pParse->aNode[iRoot]; |
| @@ -204075,15 +205349,17 @@ | |
| 204075 | if( z==0 ){ |
| 204076 | p->oom = 1; |
| 204077 | break; |
| 204078 | } |
| 204079 | if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ |
| 204080 | char *zCopy = sqlite3DbStrDup(0, z); |
| 204081 | int k; |
| 204082 | if( zCopy ){ |
| 204083 | jsonParseAddCleanup(p, sqlite3_free, zCopy); |
| 204084 | }else{ |
| 204085 | p->oom = 1; |
| 204086 | sqlite3_result_error_nomem(pCtx); |
| 204087 | } |
| 204088 | k = jsonParseAddNode(p, JSON_STRING, n, zCopy); |
| 204089 | assert( k>0 || p->oom ); |
| @@ -204134,10 +205410,11 @@ | |
| 204134 | jsonWrongNumArgs(ctx, "replace"); |
| 204135 | return; |
| 204136 | } |
| 204137 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 204138 | if( pParse==0 ) return; |
| 204139 | for(i=1; i<(u32)argc; i+=2){ |
| 204140 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 204141 | pParse->useMod = 1; |
| 204142 | pNode = jsonLookup(pParse, zPath, 0, ctx); |
| 204143 | if( pParse->nErr ) goto replace_err; |
| @@ -204146,10 +205423,11 @@ | |
| 204146 | } |
| 204147 | } |
| 204148 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 204149 | replace_err: |
| 204150 | jsonDebugPrintParse(pParse); |
| 204151 | } |
| 204152 | |
| 204153 | |
| 204154 | /* |
| 204155 | ** json_set(JSON, PATH, VALUE, ...) |
| @@ -204180,10 +205458,11 @@ | |
| 204180 | jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); |
| 204181 | return; |
| 204182 | } |
| 204183 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 204184 | if( pParse==0 ) return; |
| 204185 | for(i=1; i<(u32)argc; i+=2){ |
| 204186 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 204187 | bApnd = 0; |
| 204188 | pParse->useMod = 1; |
| 204189 | pNode = jsonLookup(pParse, zPath, &bApnd, ctx); |
| @@ -204196,13 +205475,12 @@ | |
| 204196 | jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); |
| 204197 | } |
| 204198 | } |
| 204199 | jsonDebugPrintParse(pParse); |
| 204200 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 204201 | |
| 204202 | jsonSetDone: |
| 204203 | /* no cleanup required */; |
| 204204 | } |
| 204205 | |
| 204206 | /* |
| 204207 | ** json_type(JSON) |
| 204208 | ** json_type(JSON, PATH) |
| @@ -204354,11 +205632,11 @@ | |
| 204354 | if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); |
| 204355 | assert( pStr->bStatic ); |
| 204356 | }else if( isFinal ){ |
| 204357 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 204358 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 204359 | (void(*)(void*))sqlite3RCStrUnref); |
| 204360 | pStr->bStatic = 1; |
| 204361 | }else{ |
| 204362 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| 204363 | pStr->nUsed--; |
| 204364 | } |
| @@ -204463,11 +205741,11 @@ | |
| 204463 | if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); |
| 204464 | assert( pStr->bStatic ); |
| 204465 | }else if( isFinal ){ |
| 204466 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 204467 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 204468 | (void(*)(void*))sqlite3RCStrUnref); |
| 204469 | pStr->bStatic = 1; |
| 204470 | }else{ |
| 204471 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| 204472 | pStr->nUsed--; |
| 204473 | } |
| @@ -204895,11 +206173,11 @@ | |
| 204895 | if( idxNum==0 ) return SQLITE_OK; |
| 204896 | z = (const char*)sqlite3_value_text(argv[0]); |
| 204897 | if( z==0 ) return SQLITE_OK; |
| 204898 | memset(&p->sParse, 0, sizeof(p->sParse)); |
| 204899 | p->sParse.nJPRef = 1; |
| 204900 | if( sqlite3ValueIsOfClass(argv[0], (void(*)(void*))sqlite3RCStrUnref) ){ |
| 204901 | p->sParse.zJson = sqlite3RCStrRef((char*)z); |
| 204902 | }else{ |
| 204903 | n = sqlite3_value_bytes(argv[0]); |
| 204904 | p->sParse.zJson = sqlite3RCStrNew( n+1 ); |
| 204905 | if( p->sParse.zJson==0 ) return SQLITE_NOMEM; |
| @@ -204990,11 +206268,12 @@ | |
| 204990 | 0, /* xFindMethod */ |
| 204991 | 0, /* xRename */ |
| 204992 | 0, /* xSavepoint */ |
| 204993 | 0, /* xRelease */ |
| 204994 | 0, /* xRollbackTo */ |
| 204995 | 0 /* xShadowName */ |
| 204996 | }; |
| 204997 | |
| 204998 | /* The methods of the json_tree virtual table. */ |
| 204999 | static sqlite3_module jsonTreeModule = { |
| 205000 | 0, /* iVersion */ |
| @@ -205018,11 +206297,12 @@ | |
| 205018 | 0, /* xFindMethod */ |
| 205019 | 0, /* xRename */ |
| 205020 | 0, /* xSavepoint */ |
| 205021 | 0, /* xRelease */ |
| 205022 | 0, /* xRollbackTo */ |
| 205023 | 0 /* xShadowName */ |
| 205024 | }; |
| 205025 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 205026 | #endif /* !defined(SQLITE_OMIT_JSON) */ |
| 205027 | |
| 205028 | /* |
| @@ -205253,10 +206533,11 @@ | |
| 205253 | u8 bCorrupt; /* Shadow table corruption detected */ |
| 205254 | #endif |
| 205255 | int iDepth; /* Current depth of the r-tree structure */ |
| 205256 | char *zDb; /* Name of database containing r-tree table */ |
| 205257 | char *zName; /* Name of r-tree table */ |
| 205258 | u32 nBusy; /* Current number of users of this structure */ |
| 205259 | i64 nRowEst; /* Estimated number of rows in this table */ |
| 205260 | u32 nCursor; /* Number of open cursors */ |
| 205261 | u32 nNodeRef; /* Number RtreeNodes with positive nRef */ |
| 205262 | char *zReadAuxSql; /* SQL for statement to read aux data */ |
| @@ -205265,11 +206546,10 @@ | |
| 205265 | ** linked together via the pointer normally used for hash chains - |
| 205266 | ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree |
| 205267 | ** headed by the node (leaf nodes have RtreeNode.iNode==0). |
| 205268 | */ |
| 205269 | RtreeNode *pDeleted; |
| 205270 | int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */ |
| 205271 | |
| 205272 | /* Blob I/O on xxx_node */ |
| 205273 | sqlite3_blob *pNodeBlob; |
| 205274 | |
| 205275 | /* Statements to read/write/delete a record from xxx_node */ |
| @@ -205562,19 +206842,24 @@ | |
| 205562 | ** For best performance, an attempt is made to guess at the byte-order |
| 205563 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 205564 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 205565 | ** at run-time. |
| 205566 | */ |
| 205567 | #ifndef SQLITE_BYTEORDER |
| 205568 | # if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 205569 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 205570 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 205571 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 205572 | # define SQLITE_BYTEORDER 1234 |
| 205573 | # elif defined(sparc) || defined(__ppc__) || \ |
| 205574 | defined(__ARMEB__) || defined(__AARCH64EB__) |
| 205575 | # define SQLITE_BYTEORDER 4321 |
| 205576 | # else |
| 205577 | # define SQLITE_BYTEORDER 0 |
| 205578 | # endif |
| 205579 | #endif |
| 205580 | |
| @@ -205819,15 +207104,13 @@ | |
| 205819 | nodeBlobReset(pRtree); |
| 205820 | if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM; |
| 205821 | } |
| 205822 | } |
| 205823 | if( pRtree->pNodeBlob==0 ){ |
| 205824 | char *zTab = sqlite3_mprintf("%s_node", pRtree->zName); |
| 205825 | if( zTab==0 ) return SQLITE_NOMEM; |
| 205826 | rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0, |
| 205827 | &pRtree->pNodeBlob); |
| 205828 | sqlite3_free(zTab); |
| 205829 | } |
| 205830 | if( rc ){ |
| 205831 | nodeBlobReset(pRtree); |
| 205832 | *ppNode = 0; |
| 205833 | /* If unable to open an sqlite3_blob on the desired row, that can only |
| @@ -207164,12 +208447,16 @@ | |
| 207164 | } |
| 207165 | } |
| 207166 | |
| 207167 | pIdxInfo->idxNum = 2; |
| 207168 | pIdxInfo->needToFreeIdxStr = 1; |
| 207169 | if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ |
| 207170 | return SQLITE_NOMEM; |
| 207171 | } |
| 207172 | |
| 207173 | nRow = pRtree->nRowEst >> (iIdx/2); |
| 207174 | pIdxInfo->estimatedCost = (double)6.0 * (double)nRow; |
| 207175 | pIdxInfo->estimatedRows = nRow; |
| @@ -207244,35 +208531,26 @@ | |
| 207244 | ** Return true if the area covered by p2 is a subset of the area covered |
| 207245 | ** by p1. False otherwise. |
| 207246 | */ |
| 207247 | static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ |
| 207248 | int ii; |
| 207249 | int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); |
| 207250 | for(ii=0; ii<pRtree->nDim2; ii+=2){ |
| 207251 | RtreeCoord *a1 = &p1->aCoord[ii]; |
| 207252 | RtreeCoord *a2 = &p2->aCoord[ii]; |
| 207253 | if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) |
| 207254 | || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) |
| 207255 | ){ |
| 207256 | return 0; |
| 207257 | } |
| 207258 | } |
| 207259 | return 1; |
| 207260 | } |
| 207261 | |
| 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( |
| 207275 | Rtree *pRtree, |
| 207276 | RtreeCell *p, |
| 207277 | RtreeCell *aCell, |
| 207278 | int nCell |
| @@ -207315,42 +208593,56 @@ | |
| 207315 | rc = nodeAcquire(pRtree, 1, 0, &pNode); |
| 207316 | |
| 207317 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 207318 | int iCell; |
| 207319 | sqlite3_int64 iBest = 0; |
| 207320 | |
| 207321 | RtreeDValue fMinGrowth = RTREE_ZERO; |
| 207322 | RtreeDValue fMinArea = RTREE_ZERO; |
| 207323 | |
| 207324 | int nCell = NCELL(pNode); |
| 207325 | RtreeCell cell; |
| 207326 | RtreeNode *pChild = 0; |
| 207327 | |
| 207328 | RtreeCell *aCell = 0; |
| 207329 | |
| 207330 | /* Select the child node which will be enlarged the least if pCell |
| 207331 | ** is inserted into it. Resolve ties by choosing the entry with |
| 207332 | ** the smallest area. |
| 207333 | */ |
| 207334 | for(iCell=0; iCell<nCell; iCell++){ |
| 207335 | int bBest = 0; |
| 207336 | RtreeDValue growth; |
| 207337 | RtreeDValue area; |
| 207338 | nodeGetCell(pRtree, pNode, iCell, &cell); |
| 207339 | growth = cellGrowth(pRtree, &cell, pCell); |
| 207340 | area = cellArea(pRtree, &cell); |
| 207341 | if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){ |
| 207342 | bBest = 1; |
| 207343 | } |
| 207344 | if( bBest ){ |
| 207345 | fMinGrowth = growth; |
| 207346 | fMinArea = area; |
| 207347 | iBest = cell.iRowid; |
| 207348 | } |
| 207349 | } |
| 207350 | |
| 207351 | sqlite3_free(aCell); |
| 207352 | rc = nodeAcquire(pRtree, iBest, pNode, &pChild); |
| 207353 | nodeRelease(pRtree, pNode); |
| 207354 | pNode = pChild; |
| 207355 | } |
| 207356 | |
| @@ -207419,81 +208711,10 @@ | |
| 207419 | } |
| 207420 | |
| 207421 | static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); |
| 207422 | |
| 207423 | |
| 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 | |
| 207496 | /* |
| 207497 | ** Arguments aIdx, aCell and aSpare all point to arrays of size |
| 207498 | ** nIdx. The aIdx array contains the set of integers from 0 to |
| 207499 | ** (nIdx-1) in no particular order. This function sorts the values |
| @@ -207974,111 +209195,10 @@ | |
| 207974 | } |
| 207975 | |
| 207976 | return rc; |
| 207977 | } |
| 207978 | |
| 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 | /* |
| 208081 | ** Insert cell pCell into node pNode. Node pNode is the head of a |
| 208082 | ** subtree iHeight high (leaf nodes have iHeight==0). |
| 208083 | */ |
| 208084 | static int rtreeInsertCell( |
| @@ -208095,16 +209215,11 @@ | |
| 208095 | nodeReference(pNode); |
| 208096 | pChild->pParent = pNode; |
| 208097 | } |
| 208098 | } |
| 208099 | if( nodeInsertCell(pRtree, pNode, pCell) ){ |
| 208100 | if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){ |
| 208101 | rc = SplitNode(pRtree, pNode, pCell, iHeight); |
| 208102 | }else{ |
| 208103 | pRtree->iReinsertHeight = iHeight; |
| 208104 | rc = Reinsert(pRtree, pNode, pCell, iHeight); |
| 208105 | } |
| 208106 | }else{ |
| 208107 | rc = AdjustTree(pRtree, pNode, pCell); |
| 208108 | if( ALWAYS(rc==SQLITE_OK) ){ |
| 208109 | if( iHeight==0 ){ |
| 208110 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); |
| @@ -208443,11 +209558,10 @@ | |
| 208443 | if( rc==SQLITE_OK ){ |
| 208444 | rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); |
| 208445 | } |
| 208446 | if( rc==SQLITE_OK ){ |
| 208447 | int rc2; |
| 208448 | pRtree->iReinsertHeight = -1; |
| 208449 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 208450 | rc2 = nodeRelease(pRtree, pLeaf); |
| 208451 | if( rc==SQLITE_OK ){ |
| 208452 | rc = rc2; |
| 208453 | } |
| @@ -208584,12 +209698,15 @@ | |
| 208584 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 208585 | } |
| 208586 | return 0; |
| 208587 | } |
| 208588 | |
| 208589 | static sqlite3_module rtreeModule = { |
| 208590 | 3, /* iVersion */ |
| 208591 | rtreeCreate, /* xCreate - create a table */ |
| 208592 | rtreeConnect, /* xConnect - connect to an existing table */ |
| 208593 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ |
| 208594 | rtreeDisconnect, /* xDisconnect - Disconnect from a table */ |
| 208595 | rtreeDestroy, /* xDestroy - Drop a table */ |
| @@ -208608,11 +209725,12 @@ | |
| 208608 | 0, /* xFindFunction - function overloading */ |
| 208609 | rtreeRename, /* xRename - rename the table */ |
| 208610 | rtreeSavepoint, /* xSavepoint */ |
| 208611 | 0, /* xRelease */ |
| 208612 | 0, /* xRollbackTo */ |
| 208613 | rtreeShadowName /* xShadowName */ |
| 208614 | }; |
| 208615 | |
| 208616 | static int rtreeSqlInit( |
| 208617 | Rtree *pRtree, |
| 208618 | sqlite3 *db, |
| @@ -208864,26 +209982,31 @@ | |
| 208864 | *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]); |
| 208865 | return SQLITE_ERROR; |
| 208866 | } |
| 208867 | |
| 208868 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 208869 | |
| 208870 | /* Allocate the sqlite3_vtab structure */ |
| 208871 | nDb = (int)strlen(argv[1]); |
| 208872 | nName = (int)strlen(argv[2]); |
| 208873 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); |
| 208874 | if( !pRtree ){ |
| 208875 | return SQLITE_NOMEM; |
| 208876 | } |
| 208877 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); |
| 208878 | pRtree->nBusy = 1; |
| 208879 | pRtree->base.pModule = &rtreeModule; |
| 208880 | pRtree->zDb = (char *)&pRtree[1]; |
| 208881 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 208882 | pRtree->eCoordType = (u8)eCoordType; |
| 208883 | memcpy(pRtree->zDb, argv[1], nDb); |
| 208884 | memcpy(pRtree->zName, argv[2], nName); |
| 208885 | |
| 208886 | |
| 208887 | /* Create/Connect to the underlying relational database schema. If |
| 208888 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 208889 | ** the r-tree table schema. |
| @@ -209376,27 +210499,18 @@ | |
| 209376 | const char *zTab, /* Name of rtree table to check */ |
| 209377 | char **pzReport /* OUT: sqlite3_malloc'd report text */ |
| 209378 | ){ |
| 209379 | RtreeCheck check; /* Common context for various routines */ |
| 209380 | 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. */ |
| 209383 | |
| 209384 | /* Initialize the context object */ |
| 209385 | memset(&check, 0, sizeof(check)); |
| 209386 | check.db = db; |
| 209387 | check.zDb = zDb; |
| 209388 | check.zTab = zTab; |
| 209389 | |
| 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 */ |
| 209399 | if( check.rc==SQLITE_OK ){ |
| 209400 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); |
| 209401 | if( pStmt ){ |
| 209402 | nAux = sqlite3_column_count(pStmt) - 2; |
| @@ -209433,18 +210547,27 @@ | |
| 209433 | /* Finalize SQL statements used by the integrity-check */ |
| 209434 | sqlite3_finalize(check.pGetNode); |
| 209435 | sqlite3_finalize(check.aCheckMapping[0]); |
| 209436 | sqlite3_finalize(check.aCheckMapping[1]); |
| 209437 | |
| 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; |
| 209444 | return check.rc; |
| 209445 | } |
| 209446 | |
| 209447 | /* |
| 209448 | ** Usage: |
| 209449 | ** |
| 209450 | ** rtreecheck(<rtree-table>); |
| @@ -210763,28 +211886,32 @@ | |
| 210763 | char *zSql; |
| 210764 | int ii; |
| 210765 | (void)pAux; |
| 210766 | |
| 210767 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 210768 | |
| 210769 | /* Allocate the sqlite3_vtab structure */ |
| 210770 | nDb = strlen(argv[1]); |
| 210771 | nName = strlen(argv[2]); |
| 210772 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); |
| 210773 | if( !pRtree ){ |
| 210774 | return SQLITE_NOMEM; |
| 210775 | } |
| 210776 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); |
| 210777 | pRtree->nBusy = 1; |
| 210778 | pRtree->base.pModule = &rtreeModule; |
| 210779 | pRtree->zDb = (char *)&pRtree[1]; |
| 210780 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 210781 | pRtree->eCoordType = RTREE_COORD_REAL32; |
| 210782 | pRtree->nDim = 2; |
| 210783 | pRtree->nDim2 = 4; |
| 210784 | memcpy(pRtree->zDb, argv[1], nDb); |
| 210785 | memcpy(pRtree->zName, argv[2], nName); |
| 210786 | |
| 210787 | |
| 210788 | /* Create/Connect to the underlying relational database schema. If |
| 210789 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 210790 | ** the r-tree table schema. |
| @@ -211194,11 +212321,10 @@ | |
| 211194 | if( rc==SQLITE_OK ){ |
| 211195 | rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); |
| 211196 | } |
| 211197 | if( rc==SQLITE_OK ){ |
| 211198 | int rc2; |
| 211199 | pRtree->iReinsertHeight = -1; |
| 211200 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 211201 | rc2 = nodeRelease(pRtree, pLeaf); |
| 211202 | if( rc==SQLITE_OK ){ |
| 211203 | rc = rc2; |
| 211204 | } |
| @@ -211291,11 +212417,12 @@ | |
| 211291 | geopolyFindFunction, /* xFindFunction - function overloading */ |
| 211292 | rtreeRename, /* xRename - rename the table */ |
| 211293 | rtreeSavepoint, /* xSavepoint */ |
| 211294 | 0, /* xRelease */ |
| 211295 | 0, /* xRollbackTo */ |
| 211296 | rtreeShadowName /* xShadowName */ |
| 211297 | }; |
| 211298 | |
| 211299 | static int sqlite3_geopoly_init(sqlite3 *db){ |
| 211300 | int rc = SQLITE_OK; |
| 211301 | static const struct { |
| @@ -219305,11 +220432,12 @@ | |
| 219305 | 0, /* xFindMethod */ |
| 219306 | 0, /* xRename */ |
| 219307 | 0, /* xSavepoint */ |
| 219308 | 0, /* xRelease */ |
| 219309 | 0, /* xRollbackTo */ |
| 219310 | 0 /* xShadowName */ |
| 219311 | }; |
| 219312 | return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); |
| 219313 | } |
| 219314 | #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) |
| 219315 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } |
| @@ -219742,11 +220870,12 @@ | |
| 219742 | 0, /* xFindMethod */ |
| 219743 | 0, /* xRename */ |
| 219744 | 0, /* xSavepoint */ |
| 219745 | 0, /* xRelease */ |
| 219746 | 0, /* xRollbackTo */ |
| 219747 | 0 /* xShadowName */ |
| 219748 | }; |
| 219749 | return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); |
| 219750 | } |
| 219751 | #elif defined(SQLITE_ENABLE_DBPAGE_VTAB) |
| 219752 | SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; } |
| @@ -219873,22 +221002,36 @@ | |
| 219873 | ** table. |
| 219874 | ** |
| 219875 | ** 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 |
| 219877 | ** start of the session. Or no initial values if the row was inserted. |
| 219878 | */ |
| 219879 | struct SessionTable { |
| 219880 | SessionTable *pNext; |
| 219881 | char *zName; /* Local name of table */ |
| 219882 | int nCol; /* Number of columns in table zName */ |
| 219883 | int bStat1; /* True if this is sqlite_stat1 */ |
| 219884 | int bRowid; /* True if this table uses rowid for PK */ |
| 219885 | const char **azCol; /* Column names */ |
| 219886 | u8 *abPK; /* Array of primary key flags */ |
| 219887 | int nEntry; /* Total number of entries in hash table */ |
| 219888 | int nChange; /* Size of apChange[] array */ |
| 219889 | SessionChange **apChange; /* Hash table buckets */ |
| 219890 | }; |
| 219891 | |
| 219892 | /* |
| 219893 | ** RECORD FORMAT: |
| 219894 | ** |
| @@ -220053,10 +221196,11 @@ | |
| 220053 | ** this structure stored in a SessionTable.aChange[] hash table. |
| 220054 | */ |
| 220055 | struct SessionChange { |
| 220056 | u8 op; /* One of UPDATE, DELETE, INSERT */ |
| 220057 | u8 bIndirect; /* True if this change is "indirect" */ |
| 220058 | int nMaxSize; /* Max size of eventual changeset record */ |
| 220059 | int nRecord; /* Number of bytes in buffer aRecord[] */ |
| 220060 | u8 *aRecord; /* Buffer containing old.* record */ |
| 220061 | SessionChange *pNext; /* For hash-table collisions */ |
| 220062 | }; |
| @@ -220078,11 +221222,11 @@ | |
| 220078 | |
| 220079 | /* |
| 220080 | ** Read a varint value from aBuf[] into *piVal. Return the number of |
| 220081 | ** bytes read. |
| 220082 | */ |
| 220083 | static int sessionVarintGet(u8 *aBuf, int *piVal){ |
| 220084 | return getVarint32(aBuf, *piVal); |
| 220085 | } |
| 220086 | |
| 220087 | /* Load an unaligned and unsigned 32-bit integer */ |
| 220088 | #define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| @@ -220341,11 +221485,11 @@ | |
| 220341 | /* |
| 220342 | ** The buffer that the argument points to contains a serialized SQL value. |
| 220343 | ** Return the number of bytes of space occupied by the value (including |
| 220344 | ** the type byte). |
| 220345 | */ |
| 220346 | static int sessionSerialLen(u8 *a){ |
| 220347 | int e = *a; |
| 220348 | int n; |
| 220349 | if( e==0 || e==0xFF ) return 1; |
| 220350 | if( e==SQLITE_NULL ) return 1; |
| 220351 | if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; |
| @@ -220748,17 +221892,18 @@ | |
| 220748 | ** NULL) is set to point to an array of booleans - true if the corresponding |
| 220749 | ** column is part of the primary key. |
| 220750 | ** |
| 220751 | ** For example, if the table is declared as: |
| 220752 | ** |
| 220753 | ** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z)); |
| 220754 | ** |
| 220755 | ** Then the four output variables are populated as follows: |
| 220756 | ** |
| 220757 | ** *pnCol = 4 |
| 220758 | ** *pzTab = "tbl1" |
| 220759 | ** *pazCol = {"w", "x", "y", "z"} |
| 220760 | ** *pabPK = {1, 0, 0, 1} |
| 220761 | ** |
| 220762 | ** All returned buffers are part of the same single allocation, which must |
| 220763 | ** be freed using sqlite3_free() by the caller |
| 220764 | */ |
| @@ -220768,10 +221913,11 @@ | |
| 220768 | const char *zDb, /* Name of attached database (e.g. "main") */ |
| 220769 | const char *zThis, /* Table name */ |
| 220770 | int *pnCol, /* OUT: number of columns */ |
| 220771 | const char **pzTab, /* OUT: Copy of zThis */ |
| 220772 | const char ***pazCol, /* OUT: Array of column names for table */ |
| 220773 | u8 **pabPK, /* OUT: Array of booleans - true for PK col */ |
| 220774 | int *pbRowid /* OUT: True if only PK is a rowid */ |
| 220775 | ){ |
| 220776 | char *zPragma; |
| 220777 | sqlite3_stmt *pStmt; |
| @@ -220780,15 +221926,22 @@ | |
| 220780 | int nDbCol = 0; |
| 220781 | int nThis; |
| 220782 | int i; |
| 220783 | u8 *pAlloc = 0; |
| 220784 | char **azCol = 0; |
| 220785 | u8 *abPK = 0; |
| 220786 | int bRowid = 0; /* Set to true to use rowid as PK */ |
| 220787 | |
| 220788 | assert( pazCol && pabPK ); |
| 220789 | |
| 220790 | nThis = sqlite3Strlen30(zThis); |
| 220791 | if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ |
| 220792 | rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); |
| 220793 | if( rc==SQLITE_OK ){ |
| 220794 | /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ |
| @@ -220798,59 +221951,51 @@ | |
| 220798 | "SELECT 2, 'stat', '', 0, '', 0" |
| 220799 | ); |
| 220800 | }else if( rc==SQLITE_ERROR ){ |
| 220801 | zPragma = sqlite3_mprintf(""); |
| 220802 | }else{ |
| 220803 | *pazCol = 0; |
| 220804 | *pabPK = 0; |
| 220805 | *pnCol = 0; |
| 220806 | if( pzTab ) *pzTab = 0; |
| 220807 | return rc; |
| 220808 | } |
| 220809 | }else{ |
| 220810 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); |
| 220811 | } |
| 220812 | if( !zPragma ){ |
| 220813 | *pazCol = 0; |
| 220814 | *pabPK = 0; |
| 220815 | *pnCol = 0; |
| 220816 | if( pzTab ) *pzTab = 0; |
| 220817 | return SQLITE_NOMEM; |
| 220818 | } |
| 220819 | |
| 220820 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); |
| 220821 | sqlite3_free(zPragma); |
| 220822 | if( rc!=SQLITE_OK ){ |
| 220823 | *pazCol = 0; |
| 220824 | *pabPK = 0; |
| 220825 | *pnCol = 0; |
| 220826 | if( pzTab ) *pzTab = 0; |
| 220827 | return rc; |
| 220828 | } |
| 220829 | |
| 220830 | nByte = nThis + 1; |
| 220831 | bRowid = (pbRowid!=0); |
| 220832 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 220833 | nByte += sqlite3_column_bytes(pStmt, 1); |
| 220834 | nDbCol++; |
| 220835 | if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; |
| 220836 | } |
| 220837 | if( nDbCol==0 ) bRowid = 0; |
| 220838 | nDbCol += bRowid; |
| 220839 | nByte += strlen(SESSIONS_ROWID); |
| 220840 | rc = sqlite3_reset(pStmt); |
| 220841 | |
| 220842 | if( rc==SQLITE_OK ){ |
| 220843 | nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); |
| 220844 | pAlloc = sessionMalloc64(pSession, nByte); |
| 220845 | if( pAlloc==0 ){ |
| 220846 | rc = SQLITE_NOMEM; |
| 220847 | } |
| 220848 | } |
| 220849 | if( rc==SQLITE_OK ){ |
| 220850 | azCol = (char **)pAlloc; |
| 220851 | pAlloc = (u8 *)&azCol[nDbCol]; |
| 220852 | abPK = (u8 *)pAlloc; |
| 220853 | pAlloc = &abPK[nDbCol]; |
| 220854 | if( pzTab ){ |
| 220855 | memcpy(pAlloc, zThis, nThis+1); |
| 220856 | *pzTab = (char *)pAlloc; |
| @@ -220866,15 +222011,25 @@ | |
| 220866 | abPK[i] = 1; |
| 220867 | i++; |
| 220868 | } |
| 220869 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 220870 | int nName = sqlite3_column_bytes(pStmt, 1); |
| 220871 | const unsigned char *zName = sqlite3_column_text(pStmt, 1); |
| 220872 | if( zName==0 ) break; |
| 220873 | memcpy(pAlloc, zName, nName+1); |
| 220874 | azCol[i] = (char *)pAlloc; |
| 220875 | pAlloc += nName+1; |
| 220876 | abPK[i] = sqlite3_column_int(pStmt, 5); |
| 220877 | i++; |
| 220878 | } |
| 220879 | rc = sqlite3_reset(pStmt); |
| 220880 | } |
| @@ -220881,46 +222036,49 @@ | |
| 220881 | |
| 220882 | /* If successful, populate the output variables. Otherwise, zero them and |
| 220883 | ** free any allocation made. An error code will be returned in this case. |
| 220884 | */ |
| 220885 | if( rc==SQLITE_OK ){ |
| 220886 | *pazCol = (const char **)azCol; |
| 220887 | *pabPK = abPK; |
| 220888 | *pnCol = nDbCol; |
| 220889 | }else{ |
| 220890 | *pazCol = 0; |
| 220891 | *pabPK = 0; |
| 220892 | *pnCol = 0; |
| 220893 | if( pzTab ) *pzTab = 0; |
| 220894 | sessionFree(pSession, azCol); |
| 220895 | } |
| 220896 | if( pbRowid ) *pbRowid = bRowid; |
| 220897 | sqlite3_finalize(pStmt); |
| 220898 | return rc; |
| 220899 | } |
| 220900 | |
| 220901 | /* |
| 220902 | ** This function is only called from within a pre-update handler for a |
| 220903 | ** write to table pTab, part of session pSession. If this is the first |
| 220904 | ** write to this table, initalize the SessionTable.nCol, azCol[] and |
| 220905 | ** abPK[] arrays accordingly. |
| 220906 | ** |
| 220907 | ** 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 |
| 220909 | ** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to |
| 220910 | ** indicate that updates on this table should be ignored. SessionTable.abPK |
| 220911 | ** is set to NULL in this case. |
| 220912 | */ |
| 220913 | static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ |
| 220914 | if( pTab->nCol==0 ){ |
| 220915 | u8 *abPK; |
| 220916 | assert( pTab->azCol==0 || pTab->abPK==0 ); |
| 220917 | pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, |
| 220918 | pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK, |
| 220919 | (pSession->bImplicitPK ? &pTab->bRowid : 0) |
| 220920 | ); |
| 220921 | if( pSession->rc==SQLITE_OK ){ |
| 220922 | int i; |
| 220923 | for(i=0; i<pTab->nCol; i++){ |
| 220924 | if( abPK[i] ){ |
| 220925 | pTab->abPK = abPK; |
| 220926 | break; |
| @@ -220928,18 +222086,325 @@ | |
| 220928 | } |
| 220929 | if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ |
| 220930 | pTab->bStat1 = 1; |
| 220931 | } |
| 220932 | |
| 220933 | if( pSession->bEnableSize ){ |
| 220934 | pSession->nMaxChangesetSize += ( |
| 220935 | 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 |
| 220936 | ); |
| 220937 | } |
| 220938 | } |
| 220939 | } |
| 220940 | return (pSession->rc || pTab->abPK==0); |
| 220941 | } |
| 220942 | |
| 220943 | /* |
| 220944 | ** Versions of the four methods in object SessionHook for use with the |
| 220945 | ** sqlite_stat1 table. The purpose of this is to substitute a zero-length |
| @@ -221098,20 +222563,26 @@ | |
| 221098 | SessionTable *pTab /* Table that change applies to */ |
| 221099 | ){ |
| 221100 | int iHash; |
| 221101 | int bNull = 0; |
| 221102 | int rc = SQLITE_OK; |
| 221103 | SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; |
| 221104 | |
| 221105 | if( pSession->rc ) return; |
| 221106 | |
| 221107 | /* Load table details if required */ |
| 221108 | if( sessionInitTable(pSession, pTab) ) return; |
| 221109 | |
| 221110 | /* Check the number of columns in this xPreUpdate call matches the |
| 221111 | ** number of columns in the table. */ |
| 221112 | if( (pTab->nCol-pTab->bRowid)!=pSession->hook.xCount(pSession->hook.pCtx) ){ |
| 221113 | pSession->rc = SQLITE_SCHEMA; |
| 221114 | return; |
| 221115 | } |
| 221116 | |
| 221117 | /* Grow the hash table if required */ |
| @@ -221184,11 +222655,11 @@ | |
| 221184 | if( pTab->bRowid ){ |
| 221185 | nByte += 9; /* Size of rowid field - an integer */ |
| 221186 | } |
| 221187 | |
| 221188 | /* Allocate the change object */ |
| 221189 | pC = (SessionChange *)sessionMalloc64(pSession, nByte); |
| 221190 | if( !pC ){ |
| 221191 | rc = SQLITE_NOMEM; |
| 221192 | goto error_out; |
| 221193 | }else{ |
| 221194 | memset(pC, 0, sizeof(SessionChange)); |
| @@ -221217,10 +222688,11 @@ | |
| 221217 | |
| 221218 | /* Add the change to the hash-table */ |
| 221219 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ |
| 221220 | pC->bIndirect = 1; |
| 221221 | } |
| 221222 | pC->nRecord = nByte; |
| 221223 | pC->op = op; |
| 221224 | pC->pNext = pTab->apChange[iHash]; |
| 221225 | pTab->apChange[iHash] = pC; |
| 221226 | |
| @@ -221596,11 +223068,11 @@ | |
| 221596 | SessionTable *pTo; /* Table zTbl */ |
| 221597 | |
| 221598 | /* Locate and if necessary initialize the target table object */ |
| 221599 | rc = sessionFindTable(pSession, zTbl, &pTo); |
| 221600 | if( pTo==0 ) goto diff_out; |
| 221601 | if( sessionInitTable(pSession, pTo) ){ |
| 221602 | rc = pSession->rc; |
| 221603 | goto diff_out; |
| 221604 | } |
| 221605 | |
| 221606 | /* Check the table schemas match */ |
| @@ -221609,11 +223081,11 @@ | |
| 221609 | int bMismatch = 0; |
| 221610 | int nCol; /* Columns in zFrom.zTbl */ |
| 221611 | int bRowid = 0; |
| 221612 | u8 *abPK; |
| 221613 | const char **azCol = 0; |
| 221614 | rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK, |
| 221615 | pSession->bImplicitPK ? &bRowid : 0 |
| 221616 | ); |
| 221617 | if( rc==SQLITE_OK ){ |
| 221618 | if( pTo->nCol!=nCol ){ |
| 221619 | bMismatch = 1; |
| @@ -221724,10 +223196,11 @@ | |
| 221724 | for(p=pTab->apChange[i]; p; p=pNextChange){ |
| 221725 | pNextChange = p->pNext; |
| 221726 | sessionFree(pSession, p); |
| 221727 | } |
| 221728 | } |
| 221729 | sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ |
| 221730 | sessionFree(pSession, pTab->apChange); |
| 221731 | sessionFree(pSession, pTab); |
| 221732 | } |
| 221733 | } |
| @@ -221758,11 +223231,11 @@ | |
| 221758 | ** associated hash-tables. */ |
| 221759 | sessionDeleteTable(pSession, pSession->pTable); |
| 221760 | |
| 221761 | /* Assert that all allocations have been freed and then free the |
| 221762 | ** session object itself. */ |
| 221763 | assert( pSession->nMalloc==0 ); |
| 221764 | sqlite3_free(pSession); |
| 221765 | } |
| 221766 | |
| 221767 | /* |
| 221768 | ** Set a table filter on a Session Object. |
| @@ -221829,52 +223302,10 @@ | |
| 221829 | |
| 221830 | sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db)); |
| 221831 | return rc; |
| 221832 | } |
| 221833 | |
| 221834 | /* |
| 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 |
| 221878 | ** as the first. |
| 221879 | ** |
| 221880 | ** This function is a no-op if *pRc is non-zero when it is called. |
| @@ -221939,31 +223370,10 @@ | |
| 221939 | memcpy(&p->aBuf[p->nBuf], aBlob, nBlob); |
| 221940 | p->nBuf += nBlob; |
| 221941 | } |
| 221942 | } |
| 221943 | |
| 221944 | /* |
| 221945 | ** 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 |
| 221968 | ** to the buffer. No nul-terminator is written. |
| 221969 | ** |
| @@ -221978,31 +223388,10 @@ | |
| 221978 | char aBuf[24]; |
| 221979 | sqlite3_snprintf(sizeof(aBuf)-1, aBuf, "%d", iVal); |
| 221980 | sessionAppendStr(p, aBuf, pRc); |
| 221981 | } |
| 221982 | |
| 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 | /* |
| 222005 | ** 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 |
| 222007 | ** with any embedded quote characters escaped to the buffer. No |
| 222008 | ** nul-terminator byte is written. |
| @@ -222489,63 +223878,53 @@ | |
| 222489 | sqlite3_mutex_enter(sqlite3_db_mutex(db)); |
| 222490 | |
| 222491 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ |
| 222492 | if( pTab->nEntry ){ |
| 222493 | 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 */ |
| 222498 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ |
| 222499 | int nRewind = buf.nBuf; /* Initial size of write buffer */ |
| 222500 | int nNoop; /* Size of buffer after writing tbl header */ |
| 222501 | int bRowid = 0; |
| 222502 | |
| 222503 | /* Check the table schema is still Ok. */ |
| 222504 | rc = sessionTableInfo( |
| 222505 | 0, db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK, |
| 222506 | (pSession->bImplicitPK ? &bRowid : 0) |
| 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 | } |
| 222515 | |
| 222516 | /* Write a table header */ |
| 222517 | sessionAppendTableHdr(&buf, bPatchset, pTab, &rc); |
| 222518 | |
| 222519 | /* Build and compile a statement to execute: */ |
| 222520 | if( rc==SQLITE_OK ){ |
| 222521 | rc = sessionSelectStmt( |
| 222522 | db, 0, pSession->zDb, zName, bRowid, nCol, azCol, abPK, &pSel |
| 222523 | ); |
| 222524 | } |
| 222525 | |
| 222526 | nNoop = buf.nBuf; |
| 222527 | for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){ |
| 222528 | SessionChange *p; /* Used to iterate through changes */ |
| 222529 | |
| 222530 | for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ |
| 222531 | rc = sessionSelectBind(pSel, nCol, abPK, p); |
| 222532 | if( rc!=SQLITE_OK ) continue; |
| 222533 | if( sqlite3_step(pSel)==SQLITE_ROW ){ |
| 222534 | if( p->op==SQLITE_INSERT ){ |
| 222535 | int iCol; |
| 222536 | sessionAppendByte(&buf, SQLITE_INSERT, &rc); |
| 222537 | sessionAppendByte(&buf, p->bIndirect, &rc); |
| 222538 | for(iCol=0; iCol<nCol; iCol++){ |
| 222539 | sessionAppendCol(&buf, pSel, iCol, &rc); |
| 222540 | } |
| 222541 | }else{ |
| 222542 | assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */ |
| 222543 | rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); |
| 222544 | } |
| 222545 | }else if( p->op!=SQLITE_INSERT ){ |
| 222546 | rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK); |
| 222547 | } |
| 222548 | if( rc==SQLITE_OK ){ |
| 222549 | rc = sqlite3_reset(pSel); |
| 222550 | } |
| 222551 | |
| @@ -222566,11 +223945,10 @@ | |
| 222566 | |
| 222567 | sqlite3_finalize(pSel); |
| 222568 | if( buf.nBuf==nNoop ){ |
| 222569 | buf.nBuf = nRewind; |
| 222570 | } |
| 222571 | sqlite3_free((char*)azCol); /* cast works around VC++ bug */ |
| 222572 | } |
| 222573 | } |
| 222574 | |
| 222575 | if( rc==SQLITE_OK ){ |
| 222576 | if( xOutput==0 ){ |
| @@ -224695,11 +226073,11 @@ | |
| 224695 | int nMinCol = 0; |
| 224696 | int i; |
| 224697 | |
| 224698 | sqlite3changeset_pk(pIter, &abPK, 0); |
| 224699 | rc = sessionTableInfo(0, db, "main", zNew, |
| 224700 | &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK, &sApply.bRowid |
| 224701 | ); |
| 224702 | if( rc!=SQLITE_OK ) break; |
| 224703 | for(i=0; i<sApply.nCol; i++){ |
| 224704 | if( sApply.abPK[i] ) nMinCol = i+1; |
| 224705 | } |
| @@ -224827,15 +226205,28 @@ | |
| 224827 | int flags |
| 224828 | ){ |
| 224829 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ |
| 224830 | int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); |
| 224831 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); |
| 224832 | if( rc==SQLITE_OK ){ |
| 224833 | rc = sessionChangesetApply( |
| 224834 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags |
| 224835 | ); |
| 224836 | } |
| 224837 | return rc; |
| 224838 | } |
| 224839 | |
| 224840 | /* |
| 224841 | ** Apply the changeset passed via pChangeset/nChangeset to the main database |
| @@ -224919,10 +226310,13 @@ | |
| 224919 | */ |
| 224920 | struct sqlite3_changegroup { |
| 224921 | int rc; /* Error code */ |
| 224922 | int bPatch; /* True to accumulate patchsets */ |
| 224923 | SessionTable *pList; /* List of tables in current patch */ |
| 224924 | }; |
| 224925 | |
| 224926 | /* |
| 224927 | ** This function is called to merge two changes to the same row together as |
| 224928 | ** part of an sqlite3changeset_concat() operation. A new change object is |
| @@ -225103,10 +226497,118 @@ | |
| 225103 | } |
| 225104 | |
| 225105 | *ppNew = pNew; |
| 225106 | return rc; |
| 225107 | } |
| 225108 | |
| 225109 | /* |
| 225110 | ** Add all changes in the changeset traversed by the iterator passed as |
| 225111 | ** the first argument to the changegroup hash tables. |
| 225112 | */ |
| @@ -225117,10 +226619,11 @@ | |
| 225117 | ){ |
| 225118 | u8 *aRec; |
| 225119 | int nRec; |
| 225120 | int rc = SQLITE_OK; |
| 225121 | SessionTable *pTab = 0; |
| 225122 | |
| 225123 | while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ |
| 225124 | const char *zNew; |
| 225125 | int nCol; |
| 225126 | int op; |
| @@ -225128,10 +226631,13 @@ | |
| 225128 | int bIndirect; |
| 225129 | SessionChange *pChange; |
| 225130 | SessionChange *pExist = 0; |
| 225131 | SessionChange **pp; |
| 225132 | |
| 225133 | if( pGrp->pList==0 ){ |
| 225134 | pGrp->bPatch = pIter->bPatchset; |
| 225135 | }else if( pIter->bPatchset!=pGrp->bPatch ){ |
| 225136 | rc = SQLITE_ERROR; |
| 225137 | break; |
| @@ -225159,22 +226665,42 @@ | |
| 225159 | pTab->nCol = nCol; |
| 225160 | pTab->abPK = (u8*)&pTab[1]; |
| 225161 | memcpy(pTab->abPK, abPK, nCol); |
| 225162 | pTab->zName = (char*)&pTab->abPK[nCol]; |
| 225163 | memcpy(pTab->zName, zNew, nNew+1); |
| 225164 | |
| 225165 | /* 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 |
| 225167 | ** tables within the output of sqlite3changegroup_output() are in |
| 225168 | ** the right order. */ |
| 225169 | for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); |
| 225170 | *ppTab = pTab; |
| 225171 | }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){ |
| 225172 | rc = SQLITE_SCHEMA; |
| 225173 | break; |
| 225174 | } |
| 225175 | } |
| 225176 | |
| 225177 | if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 225178 | rc = SQLITE_NOMEM; |
| 225179 | break; |
| 225180 | } |
| @@ -225209,10 +226735,11 @@ | |
| 225209 | pTab->apChange[iHash] = pChange; |
| 225210 | pTab->nEntry++; |
| 225211 | } |
| 225212 | } |
| 225213 | |
| 225214 | if( rc==SQLITE_OK ) rc = pIter->rc; |
| 225215 | return rc; |
| 225216 | } |
| 225217 | |
| 225218 | /* |
| @@ -225294,10 +226821,35 @@ | |
| 225294 | memset(p, 0, sizeof(sqlite3_changegroup)); |
| 225295 | } |
| 225296 | *pp = p; |
| 225297 | return rc; |
| 225298 | } |
| 225299 | |
| 225300 | /* |
| 225301 | ** Add the changeset currently stored in buffer pData, size nData bytes, |
| 225302 | ** to changeset-group p. |
| 225303 | */ |
| @@ -225358,10 +226910,11 @@ | |
| 225358 | /* |
| 225359 | ** Delete a changegroup object. |
| 225360 | */ |
| 225361 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ |
| 225362 | if( pGrp ){ |
| 225363 | sessionDeleteTable(0, pGrp->pList); |
| 225364 | sqlite3_free(pGrp); |
| 225365 | } |
| 225366 | } |
| 225367 | |
| @@ -237534,11 +239087,10 @@ | |
| 237534 | if( res==0 ){ |
| 237535 | assert_nc( i2>i1 ); |
| 237536 | assert_nc( i2!=0 ); |
| 237537 | pRes->bTermEq = 1; |
| 237538 | if( p1->iRowid==p2->iRowid ){ |
| 237539 | p1->bDel = p2->bDel; |
| 237540 | return i2; |
| 237541 | } |
| 237542 | res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; |
| 237543 | } |
| 237544 | assert( res!=0 ); |
| @@ -237902,11 +239454,11 @@ | |
| 237902 | static Fts5Iter *fts5MultiIterAlloc( |
| 237903 | Fts5Index *p, /* FTS5 backend to iterate within */ |
| 237904 | int nSeg |
| 237905 | ){ |
| 237906 | Fts5Iter *pNew; |
| 237907 | int nSlot; /* Power of two >= nSeg */ |
| 237908 | |
| 237909 | for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2); |
| 237910 | pNew = fts5IdxMalloc(p, |
| 237911 | sizeof(Fts5Iter) + /* pNew */ |
| 237912 | sizeof(Fts5SegIter) * (nSlot-1) + /* pNew->aSeg[] */ |
| @@ -239678,19 +241230,17 @@ | |
| 239678 | u8 *aPg = pSeg->pLeaf->p; |
| 239679 | int nPg = pSeg->pLeaf->nn; |
| 239680 | int iPgIdx = pSeg->pLeaf->szLeaf; |
| 239681 | |
| 239682 | u64 iDelta = 0; |
| 239683 | u64 iNextDelta = 0; |
| 239684 | int iNextOff = 0; |
| 239685 | int iOff = 0; |
| 239686 | int nIdx = 0; |
| 239687 | u8 *aIdx = 0; |
| 239688 | int bLastInDoclist = 0; |
| 239689 | int iIdx = 0; |
| 239690 | int iStart = 0; |
| 239691 | int iKeyOff = 0; |
| 239692 | int iDelKeyOff = 0; /* Offset of deleted key, if any */ |
| 239693 | |
| 239694 | nIdx = nPg-iPgIdx; |
| 239695 | aIdx = sqlite3Fts5MallocZero(&p->rc, nIdx+16); |
| 239696 | if( p->rc ) return; |
| @@ -239711,14 +241261,25 @@ | |
| 239711 | ** pSeg->iLeafOffset - the rowid or delta rowid value. |
| 239712 | ** |
| 239713 | ** This block sets the following variables: |
| 239714 | ** |
| 239715 | ** iStart: |
| 239716 | ** iDelta: |
| 239717 | */ |
| 239718 | { |
| 239719 | int iSOP; |
| 239720 | if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ |
| 239721 | iStart = pSeg->iTermLeafOffset; |
| 239722 | }else{ |
| 239723 | iStart = fts5GetU16(&aPg[0]); |
| 239724 | } |
| @@ -239750,51 +241311,79 @@ | |
| 239750 | iNextOff = pSeg->iLeafOffset + pSeg->nPos; |
| 239751 | } |
| 239752 | } |
| 239753 | |
| 239754 | iOff = iStart; |
| 239755 | if( iNextOff>=iPgIdx ){ |
| 239756 | int pgno = pSeg->iLeafPgno+1; |
| 239757 | fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); |
| 239758 | iNextOff = iPgIdx; |
| 239759 | }else{ |
| 239760 | /* Set bLastInDoclist to true if the entry being removed is the last |
| 239761 | ** in its doclist. */ |
| 239762 | for(iIdx=0, iKeyOff=0; iIdx<nIdx; /* no-op */){ |
| 239763 | u32 iVal = 0; |
| 239764 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 239765 | iKeyOff += iVal; |
| 239766 | if( iKeyOff==iNextOff ){ |
| 239767 | bLastInDoclist = 1; |
| 239768 | } |
| 239769 | } |
| 239770 | } |
| 239771 | |
| 239772 | if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist||iNextOff==iPgIdx) ){ |
| 239773 | fts5PutU16(&aPg[0], 0); |
| 239774 | } |
| 239775 | |
| 239776 | if( bLastInDoclist==0 ){ |
| 239777 | if( iNextOff!=iPgIdx ){ |
| 239778 | iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); |
| 239779 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); |
| 239780 | } |
| 239781 | }else if( |
| 239782 | iStart==pSeg->iTermLeafOffset && pSeg->iLeafPgno==pSeg->iTermLeafPgno |
| 239783 | ){ |
| 239784 | /* The entry being removed was the only position list in its |
| 239785 | ** doclist. Therefore the term needs to be removed as well. */ |
| 239786 | int iKey = 0; |
| 239787 | for(iIdx=0, iKeyOff=0; iIdx<nIdx; iKey++){ |
| 239788 | u32 iVal = 0; |
| 239789 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 239790 | if( (iKeyOff+iVal)>(u32)iStart ) break; |
| 239791 | iKeyOff += iVal; |
| 239792 | } |
| 239793 | |
| 239794 | iDelKeyOff = iOff = iKeyOff; |
| 239795 | if( iNextOff!=iPgIdx ){ |
| 239796 | int nPrefix = 0; |
| 239797 | int nSuffix = 0; |
| 239798 | int nPrefix2 = 0; |
| 239799 | int nSuffix2 = 0; |
| 239800 | |
| @@ -239869,10 +241458,19 @@ | |
| 239869 | } |
| 239870 | fts5DataRelease(pTerm); |
| 239871 | } |
| 239872 | } |
| 239873 | |
| 239874 | if( p->rc==SQLITE_OK ){ |
| 239875 | const int nMove = nPg - iNextOff; /* Number of bytes to move */ |
| 239876 | int nShift = iNextOff - iOff; /* Distance to move them */ |
| 239877 | |
| 239878 | int iPrevKeyOut = 0; |
| @@ -240069,14 +241667,20 @@ | |
| 240069 | } |
| 240070 | if( (pBuf->n + pPgidx->n)>=pgsz ){ |
| 240071 | fts5WriteFlushLeaf(p, &writer); |
| 240072 | } |
| 240073 | }else{ |
| 240074 | int bDummy; |
| 240075 | int nPos; |
| 240076 | int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); |
| 240077 | nCopy += nPos; |
| 240078 | if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ |
| 240079 | /* The entire poslist will fit on the current leaf. So copy |
| 240080 | ** it in one go. */ |
| 240081 | fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); |
| 240082 | }else{ |
| @@ -240110,11 +241714,10 @@ | |
| 240110 | /* TODO2: Doclist terminator written here. */ |
| 240111 | /* pBuf->p[pBuf->n++] = '\0'; */ |
| 240112 | assert( pBuf->n<=pBuf->nSpace ); |
| 240113 | if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); |
| 240114 | } |
| 240115 | sqlite3Fts5HashClear(pHash); |
| 240116 | fts5WriteFinish(p, &writer, &pgnoLast); |
| 240117 | |
| 240118 | assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); |
| 240119 | if( pgnoLast>0 ){ |
| 240120 | /* Update the Fts5Structure. It is written back to the database by the |
| @@ -240143,11 +241746,10 @@ | |
| 240143 | |
| 240144 | fts5IndexAutomerge(p, &pStruct, pgnoLast + p->nContentlessDelete); |
| 240145 | fts5IndexCrisismerge(p, &pStruct); |
| 240146 | fts5StructureWrite(p, pStruct); |
| 240147 | fts5StructureRelease(pStruct); |
| 240148 | p->nContentlessDelete = 0; |
| 240149 | } |
| 240150 | |
| 240151 | /* |
| 240152 | ** Flush any data stored in the in-memory hash tables to the database. |
| 240153 | */ |
| @@ -240154,12 +241756,16 @@ | |
| 240154 | static void fts5IndexFlush(Fts5Index *p){ |
| 240155 | /* Unless it is empty, flush the hash table to disk */ |
| 240156 | if( p->nPendingData || p->nContentlessDelete ){ |
| 240157 | assert( p->pHash ); |
| 240158 | fts5FlushOneHash(p); |
| 240159 | p->nPendingData = 0; |
| 240160 | p->nPendingRow = 0; |
| 240161 | } |
| 240162 | } |
| 240163 | |
| 240164 | static Fts5Structure *fts5IndexOptimizeStruct( |
| 240165 | Fts5Index *p, |
| @@ -242897,11 +244503,12 @@ | |
| 242897 | 0, /* xFindFunction */ |
| 242898 | 0, /* xRename */ |
| 242899 | 0, /* xSavepoint */ |
| 242900 | 0, /* xRelease */ |
| 242901 | 0, /* xRollbackTo */ |
| 242902 | 0 /* xShadowName */ |
| 242903 | }; |
| 242904 | rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); |
| 242905 | } |
| 242906 | return rc; |
| 242907 | #else |
| @@ -243036,10 +244643,12 @@ | |
| 243036 | struct Fts5FullTable { |
| 243037 | Fts5Table p; /* Public class members from fts5Int.h */ |
| 243038 | Fts5Storage *pStorage; /* Document store */ |
| 243039 | Fts5Global *pGlobal; /* Global (connection wide) data */ |
| 243040 | Fts5Cursor *pSortCsr; /* Sort data from this cursor */ |
| 243041 | #ifdef SQLITE_DEBUG |
| 243042 | struct Fts5TransactionState ts; |
| 243043 | #endif |
| 243044 | }; |
| 243045 | |
| @@ -243323,10 +244932,17 @@ | |
| 243323 | pConfig->pzErrmsg = pzErr; |
| 243324 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 243325 | sqlite3Fts5IndexRollback(pTab->p.pIndex); |
| 243326 | pConfig->pzErrmsg = 0; |
| 243327 | } |
| 243328 | |
| 243329 | if( rc!=SQLITE_OK ){ |
| 243330 | fts5FreeVtab(pTab); |
| 243331 | pTab = 0; |
| 243332 | }else if( bCreate ){ |
| @@ -244248,10 +245864,13 @@ | |
| 244248 | }else{ |
| 244249 | pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); |
| 244250 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); |
| 244251 | } |
| 244252 | |
| 244253 | if( pTab->pSortCsr ){ |
| 244254 | /* If pSortCsr is non-NULL, then this call is being made as part of |
| 244255 | ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is |
| 244256 | ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will |
| 244257 | ** return results to the user for this query. The current cursor |
| @@ -244270,10 +245889,11 @@ | |
| 244270 | } |
| 244271 | pCsr->ePlan = FTS5_PLAN_SOURCE; |
| 244272 | pCsr->pExpr = pTab->pSortCsr->pExpr; |
| 244273 | rc = fts5CursorFirst(pTab, pCsr, bDesc); |
| 244274 | }else if( pCsr->pExpr ){ |
| 244275 | rc = fts5CursorParseRank(pConfig, pCsr, pRank); |
| 244276 | if( rc==SQLITE_OK ){ |
| 244277 | if( bOrderByRank ){ |
| 244278 | pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; |
| 244279 | rc = fts5CursorFirstSorted(pTab, pCsr, bDesc); |
| @@ -244441,10 +246061,11 @@ | |
| 244441 | sqlite3_value *pVal /* Value inserted into rank column */ |
| 244442 | ){ |
| 244443 | Fts5Config *pConfig = pTab->p.pConfig; |
| 244444 | int rc = SQLITE_OK; |
| 244445 | int bError = 0; |
| 244446 | |
| 244447 | if( 0==sqlite3_stricmp("delete-all", zCmd) ){ |
| 244448 | if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
| 244449 | fts5SetVtabError(pTab, |
| 244450 | "'delete-all' may only be used with a " |
| @@ -244452,19 +246073,21 @@ | |
| 244452 | ); |
| 244453 | rc = SQLITE_ERROR; |
| 244454 | }else{ |
| 244455 | rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); |
| 244456 | } |
| 244457 | }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ |
| 244458 | if( pConfig->eContent==FTS5_CONTENT_NONE ){ |
| 244459 | fts5SetVtabError(pTab, |
| 244460 | "'rebuild' may not be used with a contentless fts5 table" |
| 244461 | ); |
| 244462 | rc = SQLITE_ERROR; |
| 244463 | }else{ |
| 244464 | rc = sqlite3Fts5StorageRebuild(pTab->pStorage); |
| 244465 | } |
| 244466 | }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ |
| 244467 | rc = sqlite3Fts5StorageOptimize(pTab->pStorage); |
| 244468 | }else if( 0==sqlite3_stricmp("merge", zCmd) ){ |
| 244469 | int nMerge = sqlite3_value_int(pVal); |
| 244470 | rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge); |
| @@ -244473,10 +246096,12 @@ | |
| 244473 | rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, iArg); |
| 244474 | #ifdef SQLITE_DEBUG |
| 244475 | }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ |
| 244476 | pConfig->bPrefixIndex = sqlite3_value_int(pVal); |
| 244477 | #endif |
| 244478 | }else{ |
| 244479 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 244480 | if( rc==SQLITE_OK ){ |
| 244481 | rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError); |
| 244482 | } |
| @@ -244486,10 +246111,16 @@ | |
| 244486 | }else{ |
| 244487 | rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0); |
| 244488 | } |
| 244489 | } |
| 244490 | } |
| 244491 | return rc; |
| 244492 | } |
| 244493 | |
| 244494 | static int fts5SpecialDelete( |
| 244495 | Fts5FullTable *pTab, |
| @@ -244604,11 +246235,11 @@ | |
| 244604 | |
| 244605 | assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); |
| 244606 | assert( nArg!=1 || eType0==SQLITE_INTEGER ); |
| 244607 | |
| 244608 | /* Filter out attempts to run UPDATE or DELETE on contentless tables. |
| 244609 | ** This is not suported. Except - DELETE is supported if the CREATE |
| 244610 | ** VIRTUAL TABLE statement contained "contentless_delete=1". */ |
| 244611 | if( eType0==SQLITE_INTEGER |
| 244612 | && pConfig->eContent==FTS5_CONTENT_NONE |
| 244613 | && pConfig->bContentlessDelete==0 |
| 244614 | ){ |
| @@ -244633,11 +246264,12 @@ | |
| 244633 | if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ |
| 244634 | rc = SQLITE_MISMATCH; |
| 244635 | } |
| 244636 | |
| 244637 | else if( eType0!=SQLITE_INTEGER ){ |
| 244638 | /* If this is a REPLACE, first remove the current entry (if any) */ |
| 244639 | if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ |
| 244640 | i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ |
| 244641 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); |
| 244642 | bUpdateOrDelete = 1; |
| 244643 | } |
| @@ -245507,12 +247139,16 @@ | |
| 245507 | */ |
| 245508 | static int fts5RenameMethod( |
| 245509 | sqlite3_vtab *pVtab, /* Virtual table handle */ |
| 245510 | const char *zName /* New name of table */ |
| 245511 | ){ |
| 245512 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245513 | return sqlite3Fts5StorageRename(pTab->pStorage, zName); |
| 245514 | } |
| 245515 | |
| 245516 | static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ |
| 245517 | fts5TripCursors((Fts5FullTable*)pTab); |
| 245518 | return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage); |
| @@ -245522,38 +247158,68 @@ | |
| 245522 | ** The xSavepoint() method. |
| 245523 | ** |
| 245524 | ** Flush the contents of the pending-terms table to disk. |
| 245525 | */ |
| 245526 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245527 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 245528 | fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint); |
| 245529 | return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); |
| 245530 | } |
| 245531 | |
| 245532 | /* |
| 245533 | ** The xRelease() method. |
| 245534 | ** |
| 245535 | ** This is a no-op. |
| 245536 | */ |
| 245537 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245538 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 245539 | fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint); |
| 245540 | return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); |
| 245541 | } |
| 245542 | |
| 245543 | /* |
| 245544 | ** The xRollbackTo() method. |
| 245545 | ** |
| 245546 | ** Discard the contents of the pending terms table. |
| 245547 | */ |
| 245548 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 245549 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 245550 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 245551 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); |
| 245552 | fts5TripCursors(pTab); |
| 245553 | pTab->p.pConfig->pgsz = 0; |
| 245554 | return sqlite3Fts5StorageRollback(pTab->pStorage); |
| 245555 | } |
| 245556 | |
| 245557 | /* |
| 245558 | ** Register a new auxiliary function with global context pGlobal. |
| 245559 | */ |
| @@ -245751,11 +247417,11 @@ | |
| 245751 | int nArg, /* Number of args */ |
| 245752 | sqlite3_value **apUnused /* Function arguments */ |
| 245753 | ){ |
| 245754 | assert( nArg==0 ); |
| 245755 | UNUSED_PARAM2(nArg, apUnused); |
| 245756 | sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); |
| 245757 | } |
| 245758 | |
| 245759 | /* |
| 245760 | ** Return true if zName is the extension on one of the shadow tables used |
| 245761 | ** by this module. |
| @@ -245768,14 +247434,38 @@ | |
| 245768 | for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 245769 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 245770 | } |
| 245771 | return 0; |
| 245772 | } |
| 245773 | |
| 245774 | static int fts5Init(sqlite3 *db){ |
| 245775 | static const sqlite3_module fts5Mod = { |
| 245776 | /* iVersion */ 3, |
| 245777 | /* xCreate */ fts5CreateMethod, |
| 245778 | /* xConnect */ fts5ConnectMethod, |
| 245779 | /* xBestIndex */ fts5BestIndexMethod, |
| 245780 | /* xDisconnect */ fts5DisconnectMethod, |
| 245781 | /* xDestroy */ fts5DestroyMethod, |
| @@ -245794,11 +247484,12 @@ | |
| 245794 | /* xFindFunction */ fts5FindFunctionMethod, |
| 245795 | /* xRename */ fts5RenameMethod, |
| 245796 | /* xSavepoint */ fts5SavepointMethod, |
| 245797 | /* xRelease */ fts5ReleaseMethod, |
| 245798 | /* xRollbackTo */ fts5RollbackToMethod, |
| 245799 | /* xShadowName */ fts5ShadowName |
| 245800 | }; |
| 245801 | |
| 245802 | int rc; |
| 245803 | Fts5Global *pGlobal = 0; |
| 245804 | |
| @@ -247071,11 +248762,13 @@ | |
| 247071 | static int sqlite3Fts5StorageSync(Fts5Storage *p){ |
| 247072 | int rc = SQLITE_OK; |
| 247073 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 247074 | if( p->bTotalsValid ){ |
| 247075 | rc = fts5StorageSaveTotals(p); |
| 247076 | p->bTotalsValid = 0; |
| 247077 | } |
| 247078 | if( rc==SQLITE_OK ){ |
| 247079 | rc = sqlite3Fts5IndexSync(p->pIndex); |
| 247080 | } |
| 247081 | sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid); |
| @@ -250439,11 +252132,12 @@ | |
| 250439 | /* xFindFunction */ 0, |
| 250440 | /* xRename */ 0, |
| 250441 | /* xSavepoint */ 0, |
| 250442 | /* xRelease */ 0, |
| 250443 | /* xRollbackTo */ 0, |
| 250444 | /* xShadowName */ 0 |
| 250445 | }; |
| 250446 | void *p = (void*)pGlobal; |
| 250447 | |
| 250448 | return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0); |
| 250449 | } |
| @@ -250768,10 +252462,11 @@ | |
| 250768 | 0, /* xRename */ |
| 250769 | 0, /* xSavepoint */ |
| 250770 | 0, /* xRelease */ |
| 250771 | 0, /* xRollbackTo */ |
| 250772 | 0, /* xShadowName */ |
| 250773 | }; |
| 250774 | |
| 250775 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 250776 | |
| 250777 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){ |
| 250778 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 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 |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -16,11 +16,11 @@ | |
| 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | ** |
| 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | ** 23a9dbe83c0042e9d500e3ae6c0592a4689. |
| 22 | */ |
| 23 | #define SQLITE_CORE 1 |
| 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | #ifndef SQLITE_PRIVATE |
| 26 | # define SQLITE_PRIVATE static |
| @@ -457,13 +457,13 @@ | |
| 457 | ** |
| 458 | ** See also: [sqlite3_libversion()], |
| 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | */ |
| 462 | #define SQLITE_VERSION "3.44.0" |
| 463 | #define SQLITE_VERSION_NUMBER 3044000 |
| 464 | #define SQLITE_SOURCE_ID "2023-10-21 20:34:57 023a9dbe83c0042e9d500e3ae6c0592a468982e4ac278d08c9201967506c7555" |
| 465 | |
| 466 | /* |
| 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | ** |
| @@ -5635,10 +5635,11 @@ | |
| 5635 | ** |
| 5636 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 5637 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 5638 | */ |
| 5639 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5640 | |
| 5641 | |
| 5642 | /* |
| 5643 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5644 | ** KEYWORDS: {function creation routines} |
| 5645 | ** METHOD: sqlite3 |
| @@ -6190,36 +6191,36 @@ | |
| 6191 | /* |
| 6192 | ** CAPI3REF: Function Auxiliary Data |
| 6193 | ** METHOD: sqlite3_context |
| 6194 | ** |
| 6195 | ** These functions may be used by (non-aggregate) SQL functions to |
| 6196 | ** associate auxiliary data with argument values. If the same argument |
| 6197 | ** value is passed to multiple invocations of the same SQL function during |
| 6198 | ** query execution, under some circumstances the associated auxiliary data |
| 6199 | ** might be preserved. An example of where this might be useful is in a |
| 6200 | ** regular-expression matching function. The compiled version of the regular |
| 6201 | ** expression can be stored as auxiliary data associated with the pattern string. |
| 6202 | ** Then as long as the pattern string remains the same, |
| 6203 | ** the compiled regular expression can be reused on multiple |
| 6204 | ** invocations of the same function. |
| 6205 | ** |
| 6206 | ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data |
| 6207 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 6208 | ** value to the application-defined function. ^N is zero for the left-most |
| 6209 | ** function argument. ^If there is no auxiliary data |
| 6210 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 6211 | ** returns a NULL pointer. |
| 6212 | ** |
| 6213 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the |
| 6214 | ** N-th argument of the application-defined function. ^Subsequent |
| 6215 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| 6216 | ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or |
| 6217 | ** NULL if the auxiliary data has been discarded. |
| 6218 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 6219 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 6220 | ** once, when the auxiliary data is discarded. |
| 6221 | ** SQLite is free to discard the auxiliary data at any time, including: <ul> |
| 6222 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 6223 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 6224 | ** SQL statement)^, or |
| 6225 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 6226 | ** parameter)^, or |
| @@ -6231,24 +6232,81 @@ | |
| 6232 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 6233 | ** should be called near the end of the function implementation and the |
| 6234 | ** function implementation should not make any use of P after |
| 6235 | ** sqlite3_set_auxdata() has been called. |
| 6236 | ** |
| 6237 | ** ^(In practice, auxiliary data is preserved between function calls for |
| 6238 | ** function parameters that are compile-time constants, including literal |
| 6239 | ** values and [parameters] and expressions composed from the same.)^ |
| 6240 | ** |
| 6241 | ** The value of the N parameter to these interfaces should be non-negative. |
| 6242 | ** Future enhancements may make use of negative N values to define new |
| 6243 | ** kinds of function caching behavior. |
| 6244 | ** |
| 6245 | ** These routines must be called from the same thread in which |
| 6246 | ** the SQL function is running. |
| 6247 | ** |
| 6248 | ** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. |
| 6249 | */ |
| 6250 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 6251 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 6252 | |
| 6253 | /* |
| 6254 | ** CAPI3REF: Database Connection Client Data |
| 6255 | ** METHOD: sqlite3 |
| 6256 | ** |
| 6257 | ** These functions are used to associate one or more named pointers |
| 6258 | ** with a [database connection]. |
| 6259 | ** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P |
| 6260 | ** to be attached to [database connection] D using name N. Subsequent |
| 6261 | ** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P |
| 6262 | ** or a NULL pointer if there were no prior calls to |
| 6263 | ** sqlite3_set_clientdata() with the same values of D and N. |
| 6264 | ** Names are compared using strcmp() and are thus case sensitive. |
| 6265 | ** |
| 6266 | ** If P and X are both non-NULL, then the destructor X is invoked with |
| 6267 | ** argument P on the first of the following occurrences: |
| 6268 | ** <ul> |
| 6269 | ** <li> An out-of-memory error occurs during the call to |
| 6270 | ** sqlite3_set_clientdata() which attempts to register pointer P. |
| 6271 | ** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made |
| 6272 | ** with the same D and N parameters. |
| 6273 | ** <li> The database connection closes. SQLite does not make any guarantees |
| 6274 | ** about the order in which destructors are called, only that all |
| 6275 | ** destructors will be called exactly once at some point during the |
| 6276 | ** database connection closingi process. |
| 6277 | ** </ul> |
| 6278 | ** |
| 6279 | ** SQLite does not do anything with client data other than invoke |
| 6280 | ** destructors on the client data at the appropriate time. The intended |
| 6281 | ** use for client data is to provide a mechanism for wrapper libraries |
| 6282 | ** to store additional information about an SQLite database connection. |
| 6283 | ** |
| 6284 | ** There is no limit (other than available memory) on the number of different |
| 6285 | ** client data pointers (with different names) that can be attached to a |
| 6286 | ** single database connection. However, the implementation is optimized |
| 6287 | ** for the case of having only one or two different client data names. |
| 6288 | ** Applications and wrapper libraries are discouraged from using more than |
| 6289 | ** one client data name each. |
| 6290 | ** |
| 6291 | ** There is no way to enumerate the client data pointers |
| 6292 | ** associated with a database connection. The N parameter can be thought |
| 6293 | ** of as a secret key such that only code that knows the secret key is able |
| 6294 | ** to access the associated data. |
| 6295 | ** |
| 6296 | ** Security Warning: These interfaces should not be exposed in scripting |
| 6297 | ** languages or in other circumstances where it might be possible for an |
| 6298 | ** an attacker to invoke them. Any agent that can invoke these interfaces |
| 6299 | ** can probably also take control of the process. |
| 6300 | ** |
| 6301 | ** Database connection client data is only available for SQLite |
| 6302 | ** version 3.44.0 ([dateof:3.44.0]) and later. |
| 6303 | ** |
| 6304 | ** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. |
| 6305 | */ |
| 6306 | SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); |
| 6307 | SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); |
| 6308 | |
| 6309 | /* |
| 6310 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 6311 | ** |
| 6312 | ** These are special values for the destructor that is passed in as the |
| @@ -7528,10 +7586,13 @@ | |
| 7586 | int (*xRelease)(sqlite3_vtab *pVTab, int); |
| 7587 | int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
| 7588 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7589 | ** Those below are for version 3 and greater. */ |
| 7590 | int (*xShadowName)(const char*); |
| 7591 | /* The methods above are in versions 1 through 3 of the sqlite_module object. |
| 7592 | ** Those below are for version 4 and greater. */ |
| 7593 | int (*xIntegrity)(sqlite3_vtab *pVTab, char**); |
| 7594 | }; |
| 7595 | |
| 7596 | /* |
| 7597 | ** CAPI3REF: Virtual Table Indexing Information |
| 7598 | ** KEYWORDS: sqlite3_index_info |
| @@ -8495,10 +8556,11 @@ | |
| 8556 | */ |
| 8557 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8558 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8559 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8560 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8561 | #define SQLITE_TESTCTRL_FK_NO_ACTION 7 |
| 8562 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8563 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8564 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8565 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8566 | #define SQLITE_TESTCTRL_ASSERT 12 |
| @@ -10859,10 +10921,17 @@ | |
| 10921 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 10922 | ** values of D and S. |
| 10923 | ** The size of the database is written into *P even if the |
| 10924 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10925 | ** of the database exists. |
| 10926 | ** |
| 10927 | ** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, |
| 10928 | ** the returned buffer content will remain accessible and unchanged |
| 10929 | ** until either the next write operation on the connection or when |
| 10930 | ** the connection is closed, and applications must not modify the |
| 10931 | ** buffer. If the bit had been clear, the returned buffer will not |
| 10932 | ** be accessed by SQLite after the call. |
| 10933 | ** |
| 10934 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10935 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10936 | ** allocation error occurs. |
| 10937 | ** |
| @@ -10907,18 +10976,28 @@ | |
| 10976 | ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will |
| 10977 | ** invoke sqlite3_free() on the serialization buffer when the database |
| 10978 | ** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then |
| 10979 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() |
| 10980 | ** if writes on the database cause it to grow larger than M bytes. |
| 10981 | ** |
| 10982 | ** Applications must not modify the buffer P or invalidate it before |
| 10983 | ** the database connection D is closed. |
| 10984 | ** |
| 10985 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 10986 | ** database is currently in a read transaction or is involved in a backup |
| 10987 | ** operation. |
| 10988 | ** |
| 10989 | ** It is not possible to deserialized into the TEMP database. If the |
| 10990 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10991 | ** function returns SQLITE_ERROR. |
| 10992 | ** |
| 10993 | ** The deserialized database should not be in [WAL mode]. If the database |
| 10994 | ** is in WAL mode, then any attempt to use the database file will result |
| 10995 | ** in an [SQLITE_CANTOPEN] error. The application can set the |
| 10996 | ** [file format version numbers] (bytes 18 and 19) of the input database P |
| 10997 | ** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the |
| 10998 | ** database file into rollback mode and work around this limitation. |
| 10999 | ** |
| 11000 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 11001 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 11002 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 11003 | ** |
| @@ -11987,10 +12066,22 @@ | |
| 12066 | void *pB, /* Pointer to buffer containing changeset B */ |
| 12067 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| 12068 | void **ppOut /* OUT: Buffer containing output changeset */ |
| 12069 | ); |
| 12070 | |
| 12071 | |
| 12072 | /* |
| 12073 | ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset |
| 12074 | */ |
| 12075 | SQLITE_API int sqlite3changeset_upgrade( |
| 12076 | sqlite3 *db, |
| 12077 | const char *zDb, |
| 12078 | int nIn, const void *pIn, /* Input changeset */ |
| 12079 | int *pnOut, void **ppOut /* OUT: Inverse of input */ |
| 12080 | ); |
| 12081 | |
| 12082 | |
| 12083 | |
| 12084 | /* |
| 12085 | ** CAPI3REF: Changegroup Handle |
| 12086 | ** |
| 12087 | ** A changegroup is an object used to combine two or more |
| @@ -12034,10 +12125,42 @@ | |
| 12125 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 12126 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 12127 | */ |
| 12128 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 12129 | |
| 12130 | /* |
| 12131 | ** CAPI3REF: Add a Schema to a Changegroup |
| 12132 | ** METHOD: sqlite3_changegroup_schema |
| 12133 | ** |
| 12134 | ** This method may be used to optionally enforce the rule that the changesets |
| 12135 | ** added to the changegroup handle must match the schema of database zDb |
| 12136 | ** ("main", "temp", or the name of an attached database). If |
| 12137 | ** sqlite3changegroup_add() is called to add a changeset that is not compatible |
| 12138 | ** with the configured schema, SQLITE_SCHEMA is returned and the changegroup |
| 12139 | ** object is left in an undefined state. |
| 12140 | ** |
| 12141 | ** A changeset schema is considered compatible with the database schema in |
| 12142 | ** the same way as for sqlite3changeset_apply(). Specifically, for each |
| 12143 | ** table in the changeset, there exists a database table with: |
| 12144 | ** |
| 12145 | ** <ul> |
| 12146 | ** <li> The name identified by the changeset, and |
| 12147 | ** <li> at least as many columns as recorded in the changeset, and |
| 12148 | ** <li> the primary key columns in the same position as recorded in |
| 12149 | ** the changeset. |
| 12150 | ** </ul> |
| 12151 | ** |
| 12152 | ** The output of the changegroup object always has the same schema as the |
| 12153 | ** database nominated using this function. In cases where changesets passed |
| 12154 | ** to sqlite3changegroup_add() have fewer columns than the corresponding table |
| 12155 | ** in the database schema, these are filled in using the default column |
| 12156 | ** values from the database schema. This makes it possible to combined |
| 12157 | ** changesets that have different numbers of columns for a single table |
| 12158 | ** within a changegroup, provided that they are otherwise compatible. |
| 12159 | */ |
| 12160 | SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); |
| 12161 | |
| 12162 | /* |
| 12163 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 12164 | ** METHOD: sqlite3_changegroup |
| 12165 | ** |
| 12166 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| @@ -12102,17 +12225,22 @@ | |
| 12225 | ** </table> |
| 12226 | ** |
| 12227 | ** If the new changeset contains changes to a table that is already present |
| 12228 | ** in the changegroup, then the number of columns and the position of the |
| 12229 | ** primary key columns for the table must be consistent. If this is not the |
| 12230 | ** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup |
| 12231 | ** object has been configured with a database schema using the |
| 12232 | ** sqlite3changegroup_schema() API, then it is possible to combine changesets |
| 12233 | ** with different numbers of columns for a single table, provided that |
| 12234 | ** they are otherwise compatible. |
| 12235 | ** |
| 12236 | ** If the input changeset appears to be corrupt and the corruption is |
| 12237 | ** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition |
| 12238 | ** occurs during processing, this function returns SQLITE_NOMEM. |
| 12239 | ** |
| 12240 | ** In all cases, if an error occurs the state of the final contents of the |
| 12241 | ** changegroup is undefined. If no error occurs, SQLITE_OK is returned. |
| 12242 | */ |
| 12243 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 12244 | |
| 12245 | /* |
| 12246 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| @@ -12373,14 +12501,21 @@ | |
| 12501 | ** <li>an update change if the modified fields are already set to |
| 12502 | ** their new values in the conflicting row, or |
| 12503 | ** <li>an insert change if all fields of the conflicting row match |
| 12504 | ** the row being inserted. |
| 12505 | ** </ul> |
| 12506 | ** |
| 12507 | ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd> |
| 12508 | ** If this flag it set, then all foreign key constraints in the target |
| 12509 | ** database behave as if they were declared with "ON UPDATE NO ACTION ON |
| 12510 | ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL |
| 12511 | ** or SET DEFAULT. |
| 12512 | */ |
| 12513 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12514 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12515 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12516 | #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 |
| 12517 | |
| 12518 | /* |
| 12519 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| 12520 | ** |
| 12521 | ** Values that may be passed as the second argument to a conflict-handler. |
| @@ -13767,10 +13902,20 @@ | |
| 13902 | # include <cmnintrin.h> |
| 13903 | # endif |
| 13904 | # endif |
| 13905 | #endif |
| 13906 | |
| 13907 | /* |
| 13908 | ** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit |
| 13909 | ** SEH support if the -DSQLITE_OMIT_SEH option is given. |
| 13910 | */ |
| 13911 | #if defined(_MSC_VER) && !defined(SQLITE_OMIT_SEH) |
| 13912 | # define SQLITE_USE_SEH 1 |
| 13913 | #else |
| 13914 | # undef SQLITE_USE_SEH |
| 13915 | #endif |
| 13916 | |
| 13917 | /* |
| 13918 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
| 13919 | ** 0 means mutexes are permanently disable and the library is never |
| 13920 | ** threadsafe. 1 means the library is serialized which is the highest |
| 13921 | ** level of threadsafety. 2 means the library is multithreaded - multiple |
| @@ -14660,20 +14805,37 @@ | |
| 14805 | ** |
| 14806 | ** For best performance, an attempt is made to guess at the byte-order |
| 14807 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 14808 | ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined |
| 14809 | ** at run-time. |
| 14810 | ** |
| 14811 | ** If you are building SQLite on some obscure platform for which the |
| 14812 | ** following ifdef magic does not work, you can always include either: |
| 14813 | ** |
| 14814 | ** -DSQLITE_BYTEORDER=1234 |
| 14815 | ** |
| 14816 | ** or |
| 14817 | ** |
| 14818 | ** -DSQLITE_BYTEORDER=4321 |
| 14819 | ** |
| 14820 | ** to cause the build to work for little-endian or big-endian processors, |
| 14821 | ** respectively. |
| 14822 | */ |
| 14823 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 14824 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 14825 | # define SQLITE_BYTEORDER 4321 |
| 14826 | # elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ |
| 14827 | # define SQLITE_BYTEORDER 1234 |
| 14828 | # elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 |
| 14829 | # define SQLITE_BYTEORDER 4321 |
| 14830 | # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 14831 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 14832 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 14833 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 14834 | # define SQLITE_BYTEORDER 1234 |
| 14835 | # elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) |
| 14836 | # define SQLITE_BYTEORDER 4321 |
| 14837 | # else |
| 14838 | # define SQLITE_BYTEORDER 0 |
| 14839 | # endif |
| 14840 | #endif |
| 14841 | #if SQLITE_BYTEORDER==4321 |
| @@ -14993,10 +15155,11 @@ | |
| 15155 | typedef struct CollSeq CollSeq; |
| 15156 | typedef struct Column Column; |
| 15157 | typedef struct Cte Cte; |
| 15158 | typedef struct CteUse CteUse; |
| 15159 | typedef struct Db Db; |
| 15160 | typedef struct DbClientData DbClientData; |
| 15161 | typedef struct DbFixer DbFixer; |
| 15162 | typedef struct Schema Schema; |
| 15163 | typedef struct Expr Expr; |
| 15164 | typedef struct ExprList ExprList; |
| 15165 | typedef struct FKey FKey; |
| @@ -16433,23 +16596,24 @@ | |
| 16596 | #define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 16597 | #define OP_VBegin 170 |
| 16598 | #define OP_VCreate 171 |
| 16599 | #define OP_VDestroy 172 |
| 16600 | #define OP_VOpen 173 |
| 16601 | #define OP_VCheck 174 |
| 16602 | #define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */ |
| 16603 | #define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */ |
| 16604 | #define OP_VRename 177 |
| 16605 | #define OP_Pagecount 178 |
| 16606 | #define OP_MaxPgcnt 179 |
| 16607 | #define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */ |
| 16608 | #define OP_FilterAdd 181 /* synopsis: filter(P1) += key(P3@P4) */ |
| 16609 | #define OP_Trace 182 |
| 16610 | #define OP_CursorHint 183 |
| 16611 | #define OP_ReleaseReg 184 /* synopsis: release r[P1@P2] mask P3 */ |
| 16612 | #define OP_Noop 185 |
| 16613 | #define OP_Explain 186 |
| 16614 | #define OP_Abortable 187 |
| 16615 | |
| 16616 | /* Properties such as "out2" or "jump" that are specified in |
| 16617 | ** comments following the "case" for each opcode in the vdbe.c |
| 16618 | ** are encoded into bitvectors as follows: |
| 16619 | */ |
| @@ -16480,13 +16644,13 @@ | |
| 16644 | /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\ |
| 16645 | /* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\ |
| 16646 | /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 16647 | /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 16648 | /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16649 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ |
| 16650 | /* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00,\ |
| 16651 | /* 184 */ 0x00, 0x00, 0x00, 0x00,} |
| 16652 | |
| 16653 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 16654 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 16655 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 16656 | ** generated this include file strives to group all JUMP opcodes |
| @@ -17391,10 +17555,11 @@ | |
| 17555 | int nSavepoint; /* Number of non-transaction savepoints */ |
| 17556 | int nStatement; /* Number of nested statement-transactions */ |
| 17557 | i64 nDeferredCons; /* Net deferred constraints this transaction. */ |
| 17558 | i64 nDeferredImmCons; /* Net deferred immediate constraints */ |
| 17559 | int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ |
| 17560 | DbClientData *pDbData; /* sqlite3_set_clientdata() content */ |
| 17561 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 17562 | /* The following variables are all protected by the STATIC_MAIN |
| 17563 | ** mutex, not by sqlite3.mutex. They are used by code in notify.c. |
| 17564 | ** |
| 17565 | ** When X.pUnlockConnection==Y, that means that X is waiting for Y to |
| @@ -17473,10 +17638,11 @@ | |
| 17638 | #define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ |
| 17639 | /* DELETE, or UPDATE and return */ |
| 17640 | /* the count using a callback. */ |
| 17641 | #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ |
| 17642 | #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ |
| 17643 | #define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */ |
| 17644 | |
| 17645 | /* Flags used only if debugging */ |
| 17646 | #ifdef SQLITE_DEBUG |
| 17647 | #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */ |
| 17648 | #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */ |
| @@ -18488,10 +18654,13 @@ | |
| 18654 | struct AggInfo_func { /* For each aggregate function */ |
| 18655 | Expr *pFExpr; /* Expression encoding the function */ |
| 18656 | FuncDef *pFunc; /* The aggregate function implementation */ |
| 18657 | int iDistinct; /* Ephemeral table used to enforce DISTINCT */ |
| 18658 | int iDistAddr; /* Address of OP_OpenEphemeral */ |
| 18659 | int iOBTab; /* Ephemeral table to implement ORDER BY */ |
| 18660 | u8 bOBPayload; /* iOBTab has payload columns separate from key */ |
| 18661 | u8 bOBUnique; /* Enforce uniqueness on iOBTab keys */ |
| 18662 | } *aFunc; |
| 18663 | int nFunc; /* Number of entries in aFunc[] */ |
| 18664 | u32 selId; /* Select to which this AggInfo belongs */ |
| 18665 | #ifdef SQLITE_DEBUG |
| 18666 | Select *pSelect; /* SELECT statement that this AggInfo supports */ |
| @@ -18672,11 +18841,11 @@ | |
| 18841 | #define EP_xIsSelect 0x001000 /* x.pSelect is valid (otherwise x.pList is) */ |
| 18842 | #define EP_Skip 0x002000 /* Operator does not contribute to affinity */ |
| 18843 | #define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
| 18844 | #define EP_Win 0x008000 /* Contains window functions */ |
| 18845 | #define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| 18846 | #define EP_FullSize 0x020000 /* Expr structure must remain full sized */ |
| 18847 | #define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ |
| 18848 | #define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ |
| 18849 | #define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| 18850 | #define EP_CanBeNull 0x200000 /* Can be null despite NOT NULL constraint */ |
| 18851 | #define EP_Subquery 0x400000 /* Tree contains a TK_SELECT operator */ |
| @@ -18702,10 +18871,11 @@ | |
| 18871 | #define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P)) |
| 18872 | #define ExprSetProperty(E,P) (E)->flags|=(P) |
| 18873 | #define ExprClearProperty(E,P) (E)->flags&=~(P) |
| 18874 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) |
| 18875 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) |
| 18876 | #define ExprIsFullSize(E) (((E)->flags&(EP_Reduced|EP_TokenOnly))==0) |
| 18877 | |
| 18878 | /* Macros used to ensure that the correct members of unions are accessed |
| 18879 | ** in Expr. |
| 18880 | */ |
| 18881 | #define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0) |
| @@ -18819,10 +18989,11 @@ | |
| 18989 | ** Allowed values for Expr.a.eEName |
| 18990 | */ |
| 18991 | #define ENAME_NAME 0 /* The AS clause of a result set */ |
| 18992 | #define ENAME_SPAN 1 /* Complete text of the result set expression */ |
| 18993 | #define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ |
| 18994 | #define ENAME_ROWID 3 /* "DB.TABLE._rowid_" for * expansion of rowid */ |
| 18995 | |
| 18996 | /* |
| 18997 | ** An instance of this structure can hold a simple list of identifiers, |
| 18998 | ** such as the list "a,b,c" in the following statements: |
| 18999 | ** |
| @@ -19427,10 +19598,11 @@ | |
| 19598 | int nLabel; /* The *negative* of the number of labels used */ |
| 19599 | int nLabelAlloc; /* Number of slots in aLabel */ |
| 19600 | int *aLabel; /* Space to hold the labels */ |
| 19601 | ExprList *pConstExpr;/* Constant expressions */ |
| 19602 | IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ |
| 19603 | IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */ |
| 19604 | Token constraintName;/* Name of the constraint currently being parsed */ |
| 19605 | yDbMask writeMask; /* Start a write transaction on these databases */ |
| 19606 | yDbMask cookieMask; /* Bitmask of schema verified databases */ |
| 19607 | int regRowid; /* Register holding rowid of CREATE TABLE entry */ |
| 19608 | int regRoot; /* Register holding root page number for new objects */ |
| @@ -19997,10 +20169,20 @@ | |
| 20169 | int iCur; /* Ephemeral table holding the materialization */ |
| 20170 | LogEst nRowEst; /* Estimated number of rows in the table */ |
| 20171 | u8 eM10d; /* The MATERIALIZED flag */ |
| 20172 | }; |
| 20173 | |
| 20174 | |
| 20175 | /* Client data associated with sqlite3_set_clientdata() and |
| 20176 | ** sqlite3_get_clientdata(). |
| 20177 | */ |
| 20178 | struct DbClientData { |
| 20179 | DbClientData *pNext; /* Next in a linked list */ |
| 20180 | void *pData; /* The data */ |
| 20181 | void (*xDestructor)(void*); /* Destructor. Might be NULL */ |
| 20182 | char zName[1]; /* Name of this client data. MUST BE LAST */ |
| 20183 | }; |
| 20184 | |
| 20185 | #ifdef SQLITE_DEBUG |
| 20186 | /* |
| 20187 | ** An instance of the TreeView object is used for printing the content of |
| 20188 | ** data structures on sqlite3DebugPrintf() using a tree-like view. |
| @@ -20402,10 +20584,12 @@ | |
| 20584 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*); |
| 20585 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 20586 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 20587 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 20588 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); |
| 20589 | SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy(Parse*,Expr*,ExprList*); |
| 20590 | SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); |
| 20591 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 20592 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 20593 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 20594 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20595 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| @@ -20638,10 +20822,11 @@ | |
| 20822 | #endif |
| 20823 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20824 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 20825 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 20826 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 20827 | SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab); |
| 20828 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( |
| 20829 | Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); |
| 20830 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); |
| 20831 | SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); |
| 20832 | SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int); |
| @@ -20909,11 +21094,12 @@ | |
| 21094 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| 21095 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 21096 | const struct ExprList_item*, |
| 21097 | const char*, |
| 21098 | const char*, |
| 21099 | const char*, |
| 21100 | int* |
| 21101 | ); |
| 21102 | SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); |
| 21103 | SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); |
| 21104 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 21105 | SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*); |
| @@ -20966,11 +21152,11 @@ | |
| 21152 | SQLITE_PRIVATE void sqlite3OomClear(sqlite3*); |
| 21153 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 21154 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 21155 | |
| 21156 | SQLITE_PRIVATE char *sqlite3RCStrRef(char*); |
| 21157 | SQLITE_PRIVATE void sqlite3RCStrUnref(void*); |
| 21158 | SQLITE_PRIVATE char *sqlite3RCStrNew(u64); |
| 21159 | SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); |
| 21160 | |
| 21161 | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); |
| 21162 | SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64); |
| @@ -21802,10 +21988,13 @@ | |
| 21988 | "ENABLE_ZIPVFS", |
| 21989 | #endif |
| 21990 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS |
| 21991 | "EXPLAIN_ESTIMATED_ROWS", |
| 21992 | #endif |
| 21993 | #ifdef SQLITE_EXTRA_AUTOEXT |
| 21994 | "EXTRA_AUTOEXT=" CTIMEOPT_VAL(SQLITE_EXTRA_AUTOEXT), |
| 21995 | #endif |
| 21996 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 21997 | "EXTRA_IFNULLROW", |
| 21998 | #endif |
| 21999 | #ifdef SQLITE_EXTRA_INIT |
| 22000 | "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT), |
| @@ -22082,10 +22271,13 @@ | |
| 22271 | #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS |
| 22272 | "OMIT_SCHEMA_PRAGMAS", |
| 22273 | #endif |
| 22274 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS |
| 22275 | "OMIT_SCHEMA_VERSION_PRAGMAS", |
| 22276 | #endif |
| 22277 | #ifdef SQLITE_OMIT_SEH |
| 22278 | "OMIT_SEH", |
| 22279 | #endif |
| 22280 | #ifdef SQLITE_OMIT_SHARED_CACHE |
| 22281 | "OMIT_SHARED_CACHE", |
| 22282 | #endif |
| 22283 | #ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES |
| @@ -25042,27 +25234,43 @@ | |
| 25234 | sqlite3StrAccumInit(&sRes, 0, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]); |
| 25235 | |
| 25236 | computeJD(&x); |
| 25237 | computeYMD_HMS(&x); |
| 25238 | for(i=j=0; zFmt[i]; i++){ |
| 25239 | char cf; |
| 25240 | if( zFmt[i]!='%' ) continue; |
| 25241 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); |
| 25242 | i++; |
| 25243 | j = i + 1; |
| 25244 | cf = zFmt[i]; |
| 25245 | switch( cf ){ |
| 25246 | case 'd': /* Fall thru */ |
| 25247 | case 'e': { |
| 25248 | sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D); |
| 25249 | break; |
| 25250 | } |
| 25251 | case 'f': { |
| 25252 | double s = x.s; |
| 25253 | if( s>59.999 ) s = 59.999; |
| 25254 | sqlite3_str_appendf(&sRes, "%06.3f", s); |
| 25255 | break; |
| 25256 | } |
| 25257 | case 'F': { |
| 25258 | sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D); |
| 25259 | break; |
| 25260 | } |
| 25261 | case 'H': |
| 25262 | case 'k': { |
| 25263 | sqlite3_str_appendf(&sRes, cf=='H' ? "%02d" : "%2d", x.h); |
| 25264 | break; |
| 25265 | } |
| 25266 | case 'I': /* Fall thru */ |
| 25267 | case 'l': { |
| 25268 | int h = x.h; |
| 25269 | if( h>12 ) h -= 12; |
| 25270 | if( h==0 ) h = 12; |
| 25271 | sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h); |
| 25272 | break; |
| 25273 | } |
| 25274 | case 'W': /* Fall thru */ |
| 25275 | case 'j': { |
| 25276 | int nDay; /* Number of days since 1st day of year */ |
| @@ -25070,11 +25278,11 @@ | |
| 25278 | y.validJD = 0; |
| 25279 | y.M = 1; |
| 25280 | y.D = 1; |
| 25281 | computeJD(&y); |
| 25282 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); |
| 25283 | if( cf=='W' ){ |
| 25284 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ |
| 25285 | wd = (int)(((x.iJD+43200000)/86400000)%7); |
| 25286 | sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); |
| 25287 | }else{ |
| 25288 | sqlite3_str_appendf(&sRes,"%03d",nDay+1); |
| @@ -25090,10 +25298,23 @@ | |
| 25298 | break; |
| 25299 | } |
| 25300 | case 'M': { |
| 25301 | sqlite3_str_appendf(&sRes,"%02d",x.m); |
| 25302 | break; |
| 25303 | } |
| 25304 | case 'p': /* Fall thru */ |
| 25305 | case 'P': { |
| 25306 | if( x.h>=12 ){ |
| 25307 | sqlite3_str_append(&sRes, cf=='p' ? "PM" : "pm", 2); |
| 25308 | }else{ |
| 25309 | sqlite3_str_append(&sRes, cf=='p' ? "AM" : "am", 2); |
| 25310 | } |
| 25311 | break; |
| 25312 | } |
| 25313 | case 'R': { |
| 25314 | sqlite3_str_appendf(&sRes, "%02d:%02d", x.h, x.m); |
| 25315 | break; |
| 25316 | } |
| 25317 | case 's': { |
| 25318 | if( x.useSubsec ){ |
| 25319 | sqlite3_str_appendf(&sRes,"%.3f", |
| 25320 | (x.iJD - 21086676*(i64)10000000)/1000.0); |
| @@ -25105,13 +25326,19 @@ | |
| 25326 | } |
| 25327 | case 'S': { |
| 25328 | sqlite3_str_appendf(&sRes,"%02d",(int)x.s); |
| 25329 | break; |
| 25330 | } |
| 25331 | case 'T': { |
| 25332 | sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s); |
| 25333 | break; |
| 25334 | } |
| 25335 | case 'u': /* Fall thru */ |
| 25336 | case 'w': { |
| 25337 | char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; |
| 25338 | if( c=='0' && cf=='u' ) c = '7'; |
| 25339 | sqlite3_str_appendchar(&sRes, 1, c); |
| 25340 | break; |
| 25341 | } |
| 25342 | case 'Y': { |
| 25343 | sqlite3_str_appendf(&sRes,"%04d",x.Y); |
| 25344 | break; |
| @@ -28196,11 +28423,11 @@ | |
| 28423 | static void checkMutexFree(sqlite3_mutex *p){ |
| 28424 | assert( SQLITE_MUTEX_RECURSIVE<2 ); |
| 28425 | assert( SQLITE_MUTEX_FAST<2 ); |
| 28426 | assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); |
| 28427 | |
| 28428 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 28429 | if( ((CheckMutex*)p)->iType<2 ) |
| 28430 | #endif |
| 28431 | { |
| 28432 | CheckMutex *pCheck = (CheckMutex*)p; |
| 28433 | pGlobalMutexMethods->xMutexFree(pCheck->mutex); |
| @@ -28868,11 +29095,11 @@ | |
| 29095 | ** allocated mutex. SQLite is careful to deallocate every |
| 29096 | ** mutex that it allocates. |
| 29097 | */ |
| 29098 | static void pthreadMutexFree(sqlite3_mutex *p){ |
| 29099 | assert( p->nRef==0 ); |
| 29100 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 29101 | if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) |
| 29102 | #endif |
| 29103 | { |
| 29104 | pthread_mutex_destroy(&p->mutex); |
| 29105 | sqlite3_free(p); |
| @@ -30432,11 +30659,11 @@ | |
| 30659 | assert( db!=0 ); |
| 30660 | assert( sqlite3_mutex_held(db->mutex) ); |
| 30661 | if( db->mallocFailed || rc ){ |
| 30662 | return apiHandleError(db, rc); |
| 30663 | } |
| 30664 | return 0; |
| 30665 | } |
| 30666 | |
| 30667 | /************** End of malloc.c **********************************************/ |
| 30668 | /************** Begin file printf.c ******************************************/ |
| 30669 | /* |
| @@ -31828,11 +32055,11 @@ | |
| 32055 | |
| 32056 | /* |
| 32057 | ** Decrease the reference count by one. Free the string when the |
| 32058 | ** reference count reaches zero. |
| 32059 | */ |
| 32060 | SQLITE_PRIVATE void sqlite3RCStrUnref(void *z){ |
| 32061 | RCStr *p = (RCStr*)z; |
| 32062 | assert( p!=0 ); |
| 32063 | p--; |
| 32064 | assert( p->nRCRef>0 ); |
| 32065 | if( p->nRCRef>=2 ){ |
| @@ -32291,20 +32518,21 @@ | |
| 32518 | if( pWin==0 ) return; |
| 32519 | if( pWin->pFilter ){ |
| 32520 | sqlite3TreeViewItem(pView, "FILTER", 1); |
| 32521 | sqlite3TreeViewExpr(pView, pWin->pFilter, 0); |
| 32522 | sqlite3TreeViewPop(&pView); |
| 32523 | if( pWin->eFrmType==TK_FILTER ) return; |
| 32524 | } |
| 32525 | sqlite3TreeViewPush(&pView, more); |
| 32526 | if( pWin->zName ){ |
| 32527 | sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin); |
| 32528 | }else{ |
| 32529 | sqlite3TreeViewLine(pView, "OVER (%p)", pWin); |
| 32530 | } |
| 32531 | if( pWin->zBase ) nElement++; |
| 32532 | if( pWin->pOrderBy ) nElement++; |
| 32533 | if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ) nElement++; |
| 32534 | if( pWin->eExclude ) nElement++; |
| 32535 | if( pWin->zBase ){ |
| 32536 | sqlite3TreeViewPush(&pView, (--nElement)>0); |
| 32537 | sqlite3TreeViewLine(pView, "window: %s", pWin->zBase); |
| 32538 | sqlite3TreeViewPop(&pView); |
| @@ -32313,11 +32541,11 @@ | |
| 32541 | sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY"); |
| 32542 | } |
| 32543 | if( pWin->pOrderBy ){ |
| 32544 | sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); |
| 32545 | } |
| 32546 | if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ){ |
| 32547 | char zBuf[30]; |
| 32548 | const char *zFrmType = "ROWS"; |
| 32549 | if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; |
| 32550 | if( pWin->eFrmType==TK_GROUPS ) zFrmType = "GROUPS"; |
| 32551 | sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType, |
| @@ -32561,11 +32789,11 @@ | |
| 32789 | pWin = 0; |
| 32790 | }else{ |
| 32791 | assert( ExprUseXList(pExpr) ); |
| 32792 | pFarg = pExpr->x.pList; |
| 32793 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32794 | pWin = IsWindowFunc(pExpr) ? pExpr->y.pWin : 0; |
| 32795 | #else |
| 32796 | pWin = 0; |
| 32797 | #endif |
| 32798 | } |
| 32799 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| @@ -32587,18 +32815,28 @@ | |
| 32815 | pExpr->u.zToken, zFlgs, zOp2); |
| 32816 | }else{ |
| 32817 | sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); |
| 32818 | } |
| 32819 | if( pFarg ){ |
| 32820 | sqlite3TreeViewExprList(pView, pFarg, pWin!=0 || pExpr->pLeft, 0); |
| 32821 | if( pExpr->pLeft ){ |
| 32822 | Expr *pOB = pExpr->pLeft; |
| 32823 | assert( pOB->op==TK_ORDER ); |
| 32824 | assert( ExprUseXList(pOB) ); |
| 32825 | sqlite3TreeViewExprList(pView, pOB->x.pList, pWin!=0, "ORDERBY"); |
| 32826 | } |
| 32827 | } |
| 32828 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 32829 | if( pWin ){ |
| 32830 | sqlite3TreeViewWindow(pView, pWin, 0); |
| 32831 | } |
| 32832 | #endif |
| 32833 | break; |
| 32834 | } |
| 32835 | case TK_ORDER: { |
| 32836 | sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, "ORDERBY"); |
| 32837 | break; |
| 32838 | } |
| 32839 | #ifndef SQLITE_OMIT_SUBQUERY |
| 32840 | case TK_EXISTS: { |
| 32841 | assert( ExprUseXSelect(pExpr) ); |
| 32842 | sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags); |
| @@ -34360,16 +34598,20 @@ | |
| 34598 | if( AtomicLoad(&db->u1.isInterrupted) ){ |
| 34599 | p->nErr++; |
| 34600 | p->rc = SQLITE_INTERRUPT; |
| 34601 | } |
| 34602 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 34603 | if( db->xProgress ){ |
| 34604 | if( p->rc==SQLITE_INTERRUPT ){ |
| 34605 | p->nProgressSteps = 0; |
| 34606 | }else if( (++p->nProgressSteps)>=db->nProgressOps ){ |
| 34607 | if( db->xProgress(db->pProgressArg) ){ |
| 34608 | p->nErr++; |
| 34609 | p->rc = SQLITE_INTERRUPT; |
| 34610 | } |
| 34611 | p->nProgressSteps = 0; |
| 34612 | } |
| 34613 | } |
| 34614 | #endif |
| 34615 | } |
| 34616 | |
| 34617 | /* |
| @@ -35183,33 +35425,33 @@ | |
| 35425 | ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); |
| 35426 | */ |
| 35427 | double rr[2]; |
| 35428 | rr[0] = r; |
| 35429 | rr[1] = 0.0; |
| 35430 | if( rr[0]>9.223372036854774784e+18 ){ |
| 35431 | while( rr[0]>9.223372036854774784e+118 ){ |
| 35432 | exp += 100; |
| 35433 | dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); |
| 35434 | } |
| 35435 | while( rr[0]>9.223372036854774784e+28 ){ |
| 35436 | exp += 10; |
| 35437 | dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); |
| 35438 | } |
| 35439 | while( rr[0]>9.223372036854774784e+18 ){ |
| 35440 | exp += 1; |
| 35441 | dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); |
| 35442 | } |
| 35443 | }else{ |
| 35444 | while( rr[0]<9.223372036854774784e-83 ){ |
| 35445 | exp -= 100; |
| 35446 | dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); |
| 35447 | } |
| 35448 | while( rr[0]<9.223372036854774784e+07 ){ |
| 35449 | exp -= 10; |
| 35450 | dekkerMul2(rr, 1.0e+10, 0.0); |
| 35451 | } |
| 35452 | while( rr[0]<9.22337203685477478e+17 ){ |
| 35453 | exp -= 1; |
| 35454 | dekkerMul2(rr, 1.0e+01, 0.0); |
| 35455 | } |
| 35456 | } |
| 35457 | v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1]; |
| @@ -35521,125 +35763,36 @@ | |
| 35763 | ** A MACRO version, getVarint32, is provided which inlines the |
| 35764 | ** single-byte case. All code should use the MACRO version as |
| 35765 | ** this function assumes the single-byte case has already been handled. |
| 35766 | */ |
| 35767 | SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ |
| 35768 | u64 v64; |
| 35769 | u8 n; |
| 35770 | |
| 35771 | /* Assume that the single-byte case has already been handled by |
| 35772 | ** the getVarint32() macro */ |
| 35773 | assert( (p[0] & 0x80)!=0 ); |
| 35774 | |
| 35775 | if( (p[1] & 0x80)==0 ){ |
| 35776 | /* This is the two-byte case */ |
| 35777 | *v = ((p[0]&0x7f)<<7) | p[1]; |
| 35778 | return 2; |
| 35779 | } |
| 35780 | if( (p[2] & 0x80)==0 ){ |
| 35781 | /* This is the three-byte case */ |
| 35782 | *v = ((p[0]&0x7f)<<14) | ((p[1]&0x7f)<<7) | p[2]; |
| 35783 | return 3; |
| 35784 | } |
| 35785 | /* four or more bytes */ |
| 35786 | n = sqlite3GetVarint(p, &v64); |
| 35787 | assert( n>3 && n<=9 ); |
| 35788 | if( (v64 & SQLITE_MAX_U32)!=v64 ){ |
| 35789 | *v = 0xffffffff; |
| 35790 | }else{ |
| 35791 | *v = (u32)v64; |
| 35792 | } |
| 35793 | return n; |
| 35794 | } |
| 35795 | |
| 35796 | /* |
| 35797 | ** Return the number of bytes that will be needed to store the given |
| 35798 | ** 64-bit integer. |
| @@ -36631,23 +36784,24 @@ | |
| 36784 | /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 36785 | /* 170 */ "VBegin" OpHelp(""), |
| 36786 | /* 171 */ "VCreate" OpHelp(""), |
| 36787 | /* 172 */ "VDestroy" OpHelp(""), |
| 36788 | /* 173 */ "VOpen" OpHelp(""), |
| 36789 | /* 174 */ "VCheck" OpHelp(""), |
| 36790 | /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), |
| 36791 | /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 36792 | /* 177 */ "VRename" OpHelp(""), |
| 36793 | /* 178 */ "Pagecount" OpHelp(""), |
| 36794 | /* 179 */ "MaxPgcnt" OpHelp(""), |
| 36795 | /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), |
| 36796 | /* 181 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), |
| 36797 | /* 182 */ "Trace" OpHelp(""), |
| 36798 | /* 183 */ "CursorHint" OpHelp(""), |
| 36799 | /* 184 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 36800 | /* 185 */ "Noop" OpHelp(""), |
| 36801 | /* 186 */ "Explain" OpHelp(""), |
| 36802 | /* 187 */ "Abortable" OpHelp(""), |
| 36803 | }; |
| 36804 | return azName[i]; |
| 36805 | } |
| 36806 | #endif |
| 36807 | |
| @@ -57726,14 +57880,37 @@ | |
| 57880 | memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic)); |
| 57881 | put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff); |
| 57882 | }else{ |
| 57883 | memset(zHeader, 0, sizeof(aJournalMagic)+4); |
| 57884 | } |
| 57885 | |
| 57886 | |
| 57887 | |
| 57888 | /* The random check-hash initializer */ |
| 57889 | if( pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){ |
| 57890 | sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); |
| 57891 | } |
| 57892 | #ifdef SQLITE_DEBUG |
| 57893 | else{ |
| 57894 | /* The Pager.cksumInit variable is usually randomized above to protect |
| 57895 | ** against there being existing records in the journal file. This is |
| 57896 | ** dangerous, as following a crash they may be mistaken for records |
| 57897 | ** written by the current transaction and rolled back into the database |
| 57898 | ** file, causing corruption. The following assert statements verify |
| 57899 | ** that this is not required in "journal_mode=memory" mode, as in that |
| 57900 | ** case the journal file is always 0 bytes in size at this point. |
| 57901 | ** It is advantageous to avoid the sqlite3_randomness() call if possible |
| 57902 | ** as it takes the global PRNG mutex. */ |
| 57903 | i64 sz = 0; |
| 57904 | sqlite3OsFileSize(pPager->jfd, &sz); |
| 57905 | assert( sz==0 ); |
| 57906 | assert( pPager->journalOff==journalHdrOffset(pPager) ); |
| 57907 | assert( sqlite3JournalIsInMemory(pPager->jfd) ); |
| 57908 | } |
| 57909 | #endif |
| 57910 | put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); |
| 57911 | |
| 57912 | /* The initial database size */ |
| 57913 | put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); |
| 57914 | /* The assumed sector size for this process */ |
| 57915 | put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize); |
| 57916 | |
| @@ -58373,10 +58550,13 @@ | |
| 58550 | pPager->setSuper = 0; |
| 58551 | |
| 58552 | return (rc==SQLITE_OK?rc2:rc); |
| 58553 | } |
| 58554 | |
| 58555 | /* Forward reference */ |
| 58556 | static int pager_playback(Pager *pPager, int isHot); |
| 58557 | |
| 58558 | /* |
| 58559 | ** Execute a rollback if a transaction is active and unlock the |
| 58560 | ** database file. |
| 58561 | ** |
| 58562 | ** If the pager has already entered the ERROR state, do not attempt |
| @@ -58401,10 +58581,25 @@ | |
| 58581 | sqlite3EndBenignMalloc(); |
| 58582 | }else if( !pPager->exclusiveMode ){ |
| 58583 | assert( pPager->eState==PAGER_READER ); |
| 58584 | pager_end_transaction(pPager, 0, 0); |
| 58585 | } |
| 58586 | }else if( pPager->eState==PAGER_ERROR |
| 58587 | && pPager->journalMode==PAGER_JOURNALMODE_MEMORY |
| 58588 | && isOpen(pPager->jfd) |
| 58589 | ){ |
| 58590 | /* Special case for a ROLLBACK due to I/O error with an in-memory |
| 58591 | ** journal: We have to rollback immediately, before the journal is |
| 58592 | ** closed, because once it is closed, all content is forgotten. */ |
| 58593 | int errCode = pPager->errCode; |
| 58594 | u8 eLock = pPager->eLock; |
| 58595 | pPager->eState = PAGER_OPEN; |
| 58596 | pPager->errCode = SQLITE_OK; |
| 58597 | pPager->eLock = EXCLUSIVE_LOCK; |
| 58598 | pager_playback(pPager, 1); |
| 58599 | pPager->errCode = errCode; |
| 58600 | pPager->eLock = eLock; |
| 58601 | } |
| 58602 | pager_unlock(pPager); |
| 58603 | } |
| 58604 | |
| 58605 | /* |
| @@ -61893,12 +62088,24 @@ | |
| 62088 | Pager *pPager, /* The pager open on the database file */ |
| 62089 | Pgno pgno, /* Page number to fetch */ |
| 62090 | DbPage **ppPage, /* Write a pointer to the page here */ |
| 62091 | int flags /* PAGER_GET_XXX flags */ |
| 62092 | ){ |
| 62093 | #if 0 /* Trace page fetch by setting to 1 */ |
| 62094 | int rc; |
| 62095 | printf("PAGE %u\n", pgno); |
| 62096 | fflush(stdout); |
| 62097 | rc = pPager->xGet(pPager, pgno, ppPage, flags); |
| 62098 | if( rc ){ |
| 62099 | printf("PAGE %u failed with 0x%02x\n", pgno, rc); |
| 62100 | fflush(stdout); |
| 62101 | } |
| 62102 | return rc; |
| 62103 | #else |
| 62104 | /* Normal, high-speed version of sqlite3PagerGet() */ |
| 62105 | return pPager->xGet(pPager, pgno, ppPage, flags); |
| 62106 | #endif |
| 62107 | } |
| 62108 | |
| 62109 | /* |
| 62110 | ** Acquire a page if it is already in the in-memory cache. Do |
| 62111 | ** not read the page from disk. Return a pointer to the page, |
| @@ -63581,11 +63788,11 @@ | |
| 63788 | }else if( state==PAGER_OPEN ){ |
| 63789 | pager_unlock(pPager); |
| 63790 | } |
| 63791 | assert( state==pPager->eState ); |
| 63792 | } |
| 63793 | }else if( eMode==PAGER_JOURNALMODE_OFF || eMode==PAGER_JOURNALMODE_MEMORY ){ |
| 63794 | sqlite3OsClose(pPager->jfd); |
| 63795 | } |
| 63796 | } |
| 63797 | |
| 63798 | /* Return the new journal mode */ |
| @@ -69194,11 +69401,11 @@ | |
| 69401 | typedef struct IntegrityCk IntegrityCk; |
| 69402 | struct IntegrityCk { |
| 69403 | BtShared *pBt; /* The tree being checked out */ |
| 69404 | Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ |
| 69405 | u8 *aPgRef; /* 1 bit per page in the db (see above) */ |
| 69406 | Pgno nCkPage; /* Pages in the database. 0 for partial check */ |
| 69407 | int mxErr; /* Stop accumulating errors when this reaches zero */ |
| 69408 | int nErr; /* Number of messages written to zErrMsg so far */ |
| 69409 | int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ |
| 69410 | u32 nStep; /* Number of steps into the integrity_check process */ |
| 69411 | const char *zPfx; /* Error message prefix */ |
| @@ -69527,11 +69734,10 @@ | |
| 69734 | |
| 69735 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 69736 | |
| 69737 | /************** End of btmutex.c *********************************************/ |
| 69738 | /************** Begin file btree.c *******************************************/ |
| 69739 | /* |
| 69740 | ** 2004 April 6 |
| 69741 | ** |
| 69742 | ** The author disclaims copyright to this source code. In place of |
| 69743 | ** a legal notice, here is a blessing: |
| @@ -77022,13 +77228,14 @@ | |
| 77228 | u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager); |
| 77229 | u8 *pData; |
| 77230 | int k; /* Current slot in pCArray->apEnd[] */ |
| 77231 | u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ |
| 77232 | |
| 77233 | assert( nCell>0 ); |
| 77234 | assert( i<iEnd ); |
| 77235 | j = get2byte(&aData[hdr+5]); |
| 77236 | if( j>(u32)usableSize ){ j = 0; } |
| 77237 | memcpy(&pTmp[j], &aData[j], usableSize - j); |
| 77238 | |
| 77239 | for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} |
| 77240 | pSrcEnd = pCArray->apEnd[k]; |
| 77241 | |
| @@ -77328,10 +77535,11 @@ | |
| 77535 | #endif |
| 77536 | |
| 77537 | return SQLITE_OK; |
| 77538 | editpage_fail: |
| 77539 | /* Unable to edit this page. Rebuild it from scratch instead. */ |
| 77540 | if( nNew<1 ) return SQLITE_CORRUPT_BKPT; |
| 77541 | populateCellCache(pCArray, iNew, nNew); |
| 77542 | return rebuildPage(pCArray, iNew, nNew, pPg); |
| 77543 | } |
| 77544 | |
| 77545 | |
| @@ -79987,19 +80195,19 @@ | |
| 80195 | /* |
| 80196 | ** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that |
| 80197 | ** corresponds to page iPg is already set. |
| 80198 | */ |
| 80199 | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80200 | assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); |
| 80201 | return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); |
| 80202 | } |
| 80203 | |
| 80204 | /* |
| 80205 | ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. |
| 80206 | */ |
| 80207 | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80208 | assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); |
| 80209 | pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); |
| 80210 | } |
| 80211 | |
| 80212 | |
| 80213 | /* |
| @@ -80009,11 +80217,12 @@ | |
| 80217 | ** if this is the first reference to the page. |
| 80218 | ** |
| 80219 | ** Also check that the page number is in bounds. |
| 80220 | */ |
| 80221 | static int checkRef(IntegrityCk *pCheck, Pgno iPage){ |
| 80222 | if( iPage>pCheck->nCkPage || iPage==0 ){ |
| 80223 | if( pCheck->nCkPage==0 ) return 0; /* omit reference counting */ |
| 80224 | checkAppendMsg(pCheck, "invalid page number %u", iPage); |
| 80225 | return 1; |
| 80226 | } |
| 80227 | if( getPageReferenced(pCheck, iPage) ){ |
| 80228 | checkAppendMsg(pCheck, "2nd reference to page %u", iPage); |
| @@ -80236,10 +80445,11 @@ | |
| 80445 | pCheck->zPfx = "Tree %u page %u: "; |
| 80446 | pCheck->v1 = iPage; |
| 80447 | if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ |
| 80448 | checkAppendMsg(pCheck, |
| 80449 | "unable to get the page. error code=%d", rc); |
| 80450 | if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM; |
| 80451 | goto end_of_check; |
| 80452 | } |
| 80453 | |
| 80454 | /* Clear MemPage.isInit to make sure the corruption detection code in |
| 80455 | ** btreeInitPage() is executed. */ |
| @@ -80506,31 +80716,36 @@ | |
| 80716 | assert( nRef>=0 ); |
| 80717 | memset(&sCheck, 0, sizeof(sCheck)); |
| 80718 | sCheck.db = db; |
| 80719 | sCheck.pBt = pBt; |
| 80720 | sCheck.pPager = pBt->pPager; |
| 80721 | sCheck.nCkPage = btreePagecount(sCheck.pBt); |
| 80722 | sCheck.mxErr = mxErr; |
| 80723 | sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); |
| 80724 | sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; |
| 80725 | if( sCheck.nCkPage==0 ){ |
| 80726 | goto integrity_ck_cleanup; |
| 80727 | } |
| 80728 | |
| 80729 | if( bPartial ){ |
| 80730 | sCheck.nCkPage = 0; |
| 80731 | sCheck.aPgRef = 0; |
| 80732 | }else{ |
| 80733 | sCheck.aPgRef = sqlite3MallocZero((sCheck.nCkPage / 8)+ 1); |
| 80734 | if( !sCheck.aPgRef ){ |
| 80735 | checkOom(&sCheck); |
| 80736 | goto integrity_ck_cleanup; |
| 80737 | } |
| 80738 | } |
| 80739 | sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize ); |
| 80740 | if( sCheck.heap==0 ){ |
| 80741 | checkOom(&sCheck); |
| 80742 | goto integrity_ck_cleanup; |
| 80743 | } |
| 80744 | |
| 80745 | i = PENDING_BYTE_PAGE(pBt); |
| 80746 | if( i<=sCheck.nCkPage ) setPageReferenced(&sCheck, i); |
| 80747 | |
| 80748 | /* Check the integrity of the freelist |
| 80749 | */ |
| 80750 | if( bCkFreelist ){ |
| 80751 | sCheck.zPfx = "Freelist: "; |
| @@ -80577,11 +80792,11 @@ | |
| 80792 | pBt->db->flags = savedDbFlags; |
| 80793 | |
| 80794 | /* Make sure every page in the file is referenced |
| 80795 | */ |
| 80796 | if( !bPartial ){ |
| 80797 | for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){ |
| 80798 | #ifdef SQLITE_OMIT_AUTOVACUUM |
| 80799 | if( getPageReferenced(&sCheck, i)==0 ){ |
| 80800 | checkAppendMsg(&sCheck, "Page %u: never used", i); |
| 80801 | } |
| 80802 | #else |
| @@ -82018,11 +82233,11 @@ | |
| 82233 | ){ |
| 82234 | pMem->z[pMem->n] = 0; |
| 82235 | pMem->flags |= MEM_Term; |
| 82236 | return; |
| 82237 | } |
| 82238 | if( pMem->xDel==sqlite3RCStrUnref ){ |
| 82239 | /* Blindly assume that all RCStr objects are zero-terminated */ |
| 82240 | pMem->flags |= MEM_Term; |
| 82241 | return; |
| 82242 | } |
| 82243 | }else if( pMem->szMalloc >= pMem->n+1 ){ |
| @@ -83398,10 +83613,11 @@ | |
| 83613 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 83614 | pVal = valueNew(db, pCtx); |
| 83615 | if( pVal ){ |
| 83616 | pVal->flags = MEM_Int; |
| 83617 | pVal->u.i = pExpr->u.zToken[4]==0; |
| 83618 | sqlite3ValueApplyAffinity(pVal, affinity, enc); |
| 83619 | } |
| 83620 | } |
| 83621 | |
| 83622 | *ppVal = pVal; |
| 83623 | return rc; |
| @@ -84711,10 +84927,14 @@ | |
| 84927 | for(i=iFirst; i<=iLast; i++, pOp++){ |
| 84928 | if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ){ |
| 84929 | int iDest = pOp->p2; /* Jump destination */ |
| 84930 | if( iDest==0 ) continue; |
| 84931 | if( pOp->opcode==OP_Gosub ) continue; |
| 84932 | if( pOp->p3==20230325 && pOp->opcode==OP_NotNull ){ |
| 84933 | /* This is a deliberately taken illegal branch. tag-20230325-2 */ |
| 84934 | continue; |
| 84935 | } |
| 84936 | if( iDest<0 ){ |
| 84937 | int j = ADDR(iDest); |
| 84938 | assert( j>=0 ); |
| 84939 | if( j>=-pParse->nLabel || pParse->aLabel[j]<0 ){ |
| 84940 | continue; |
| @@ -88170,36 +88390,45 @@ | |
| 88390 | c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1); |
| 88391 | if( c ) return c; |
| 88392 | return n1 - n2; |
| 88393 | } |
| 88394 | |
| 88395 | /* The following two functions are used only within testcase() to prove |
| 88396 | ** test coverage. These functions do no exist for production builds. |
| 88397 | ** We must use separate SQLITE_NOINLINE functions here, since otherwise |
| 88398 | ** optimizer code movement causes gcov to become very confused. |
| 88399 | */ |
| 88400 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) |
| 88401 | static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; } |
| 88402 | static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; } |
| 88403 | #endif |
| 88404 | |
| 88405 | /* |
| 88406 | ** Do a comparison between a 64-bit signed integer and a 64-bit floating-point |
| 88407 | ** number. Return negative, zero, or positive if the first (i64) is less than, |
| 88408 | ** equal to, or greater than the second (double). |
| 88409 | */ |
| 88410 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ |
| 88411 | if( sqlite3Config.bUseLongDouble ){ |
| 88412 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; |
| 88413 | testcase( x<r ); |
| 88414 | testcase( x>r ); |
| 88415 | testcase( x==r ); |
| 88416 | return (x<r) ? -1 : (x>r); |
| 88417 | }else{ |
| 88418 | i64 y; |
| 88419 | double s; |
| 88420 | if( r<-9223372036854775808.0 ) return +1; |
| 88421 | if( r>=9223372036854775808.0 ) return -1; |
| 88422 | y = (i64)r; |
| 88423 | if( i<y ) return -1; |
| 88424 | if( i>y ) return +1; |
| 88425 | s = (double)i; |
| 88426 | testcase( doubleLt(s,r) ); |
| 88427 | testcase( doubleLt(r,s) ); |
| 88428 | testcase( doubleEq(r,s) ); |
| 88429 | return (s<r) ? -1 : (s>r); |
| 88430 | } |
| 88431 | } |
| 88432 | |
| 88433 | /* |
| 88434 | ** Compare the values contained by the two memory cells, returning |
| @@ -89563,11 +89792,11 @@ | |
| 89792 | ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the |
| 89793 | ** result as a string or blob. Appropriate errors are set if the string/blob |
| 89794 | ** is too big or if an OOM occurs. |
| 89795 | ** |
| 89796 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() |
| 89797 | ** on value P if P is not going to be used and need to be destroyed. |
| 89798 | */ |
| 89799 | static void setResultStrOrError( |
| 89800 | sqlite3_context *pCtx, /* Function context */ |
| 89801 | const char *z, /* String pointer */ |
| 89802 | int n, /* Bytes in string, or negative */ |
| @@ -89593,29 +89822,42 @@ | |
| 89822 | } |
| 89823 | } |
| 89824 | static int invokeValueDestructor( |
| 89825 | const void *p, /* Value to destroy */ |
| 89826 | void (*xDel)(void*), /* The destructor */ |
| 89827 | sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if not NULL */ |
| 89828 | ){ |
| 89829 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89830 | if( xDel==0 ){ |
| 89831 | /* noop */ |
| 89832 | }else if( xDel==SQLITE_TRANSIENT ){ |
| 89833 | /* noop */ |
| 89834 | }else{ |
| 89835 | xDel((void*)p); |
| 89836 | } |
| 89837 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89838 | if( pCtx!=0 ){ |
| 89839 | sqlite3_result_error_toobig(pCtx); |
| 89840 | } |
| 89841 | #else |
| 89842 | assert( pCtx!=0 ); |
| 89843 | sqlite3_result_error_toobig(pCtx); |
| 89844 | #endif |
| 89845 | return SQLITE_TOOBIG; |
| 89846 | } |
| 89847 | SQLITE_API void sqlite3_result_blob( |
| 89848 | sqlite3_context *pCtx, |
| 89849 | const void *z, |
| 89850 | int n, |
| 89851 | void (*xDel)(void *) |
| 89852 | ){ |
| 89853 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89854 | if( pCtx==0 || n<0 ){ |
| 89855 | invokeValueDestructor(z, xDel, pCtx); |
| 89856 | return; |
| 89857 | } |
| 89858 | #endif |
| 89859 | assert( n>=0 ); |
| 89860 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89861 | setResultStrOrError(pCtx, z, n, 0, xDel); |
| 89862 | } |
| 89863 | SQLITE_API void sqlite3_result_blob64( |
| @@ -89622,60 +89864,95 @@ | |
| 89864 | sqlite3_context *pCtx, |
| 89865 | const void *z, |
| 89866 | sqlite3_uint64 n, |
| 89867 | void (*xDel)(void *) |
| 89868 | ){ |
| 89869 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89870 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89871 | if( pCtx==0 ){ |
| 89872 | invokeValueDestructor(z, xDel, 0); |
| 89873 | return; |
| 89874 | } |
| 89875 | #endif |
| 89876 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89877 | if( n>0x7fffffff ){ |
| 89878 | (void)invokeValueDestructor(z, xDel, pCtx); |
| 89879 | }else{ |
| 89880 | setResultStrOrError(pCtx, z, (int)n, 0, xDel); |
| 89881 | } |
| 89882 | } |
| 89883 | SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ |
| 89884 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89885 | if( pCtx==0 ) return; |
| 89886 | #endif |
| 89887 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89888 | sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); |
| 89889 | } |
| 89890 | SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ |
| 89891 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89892 | if( pCtx==0 ) return; |
| 89893 | #endif |
| 89894 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89895 | pCtx->isError = SQLITE_ERROR; |
| 89896 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); |
| 89897 | } |
| 89898 | #ifndef SQLITE_OMIT_UTF16 |
| 89899 | SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ |
| 89900 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89901 | if( pCtx==0 ) return; |
| 89902 | #endif |
| 89903 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89904 | pCtx->isError = SQLITE_ERROR; |
| 89905 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); |
| 89906 | } |
| 89907 | #endif |
| 89908 | SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ |
| 89909 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89910 | if( pCtx==0 ) return; |
| 89911 | #endif |
| 89912 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89913 | sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); |
| 89914 | } |
| 89915 | SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ |
| 89916 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89917 | if( pCtx==0 ) return; |
| 89918 | #endif |
| 89919 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89920 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 89921 | } |
| 89922 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 89923 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89924 | if( pCtx==0 ) return; |
| 89925 | #endif |
| 89926 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89927 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 89928 | } |
| 89929 | SQLITE_API void sqlite3_result_pointer( |
| 89930 | sqlite3_context *pCtx, |
| 89931 | void *pPtr, |
| 89932 | const char *zPType, |
| 89933 | void (*xDestructor)(void*) |
| 89934 | ){ |
| 89935 | Mem *pOut; |
| 89936 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89937 | if( pCtx==0 ){ |
| 89938 | invokeValueDestructor(pPtr, xDestructor, 0); |
| 89939 | return; |
| 89940 | } |
| 89941 | #endif |
| 89942 | pOut = pCtx->pOut; |
| 89943 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89944 | sqlite3VdbeMemRelease(pOut); |
| 89945 | pOut->flags = MEM_Null; |
| 89946 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); |
| 89947 | } |
| 89948 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 89949 | Mem *pOut; |
| 89950 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89951 | if( pCtx==0 ) return; |
| 89952 | #endif |
| 89953 | pOut = pCtx->pOut; |
| 89954 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 89955 | pOut->eSubtype = eSubtype & 0xff; |
| 89956 | pOut->flags |= MEM_Subtype; |
| 89957 | } |
| 89958 | SQLITE_API void sqlite3_result_text( |
| @@ -89682,10 +89959,16 @@ | |
| 89959 | sqlite3_context *pCtx, |
| 89960 | const char *z, |
| 89961 | int n, |
| 89962 | void (*xDel)(void *) |
| 89963 | ){ |
| 89964 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89965 | if( pCtx==0 ){ |
| 89966 | invokeValueDestructor(z, xDel, 0); |
| 89967 | return; |
| 89968 | } |
| 89969 | #endif |
| 89970 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89971 | setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); |
| 89972 | } |
| 89973 | SQLITE_API void sqlite3_result_text64( |
| 89974 | sqlite3_context *pCtx, |
| @@ -89692,10 +89975,16 @@ | |
| 89975 | const char *z, |
| 89976 | sqlite3_uint64 n, |
| 89977 | void (*xDel)(void *), |
| 89978 | unsigned char enc |
| 89979 | ){ |
| 89980 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 89981 | if( pCtx==0 ){ |
| 89982 | invokeValueDestructor(z, xDel, 0); |
| 89983 | return; |
| 89984 | } |
| 89985 | #endif |
| 89986 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 89987 | assert( xDel!=SQLITE_DYNAMIC ); |
| 89988 | if( enc!=SQLITE_UTF8 ){ |
| 89989 | if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 89990 | n &= ~(u64)1; |
| @@ -89735,11 +90024,20 @@ | |
| 90024 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90025 | setResultStrOrError(pCtx, z, n & ~(u64)1, SQLITE_UTF16LE, xDel); |
| 90026 | } |
| 90027 | #endif /* SQLITE_OMIT_UTF16 */ |
| 90028 | SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ |
| 90029 | Mem *pOut; |
| 90030 | |
| 90031 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90032 | if( pCtx==0 ) return; |
| 90033 | if( pValue==0 ){ |
| 90034 | sqlite3_result_null(pCtx); |
| 90035 | return; |
| 90036 | } |
| 90037 | #endif |
| 90038 | pOut = pCtx->pOut; |
| 90039 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90040 | sqlite3VdbeMemCopy(pOut, pValue); |
| 90041 | sqlite3VdbeChangeEncoding(pOut, pCtx->enc); |
| 90042 | if( sqlite3VdbeMemTooBig(pOut) ){ |
| 90043 | sqlite3_result_error_toobig(pCtx); |
| @@ -89747,11 +90045,16 @@ | |
| 90045 | } |
| 90046 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ |
| 90047 | sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); |
| 90048 | } |
| 90049 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ |
| 90050 | Mem *pOut; |
| 90051 | |
| 90052 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90053 | if( pCtx==0 ) return SQLITE_MISUSE_BKPT; |
| 90054 | #endif |
| 90055 | pOut = pCtx->pOut; |
| 90056 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 90057 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 90058 | sqlite3_result_error_toobig(pCtx); |
| 90059 | return SQLITE_TOOBIG; |
| 90060 | } |
| @@ -89761,10 +90064,13 @@ | |
| 90064 | #else |
| 90065 | return sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 90066 | #endif |
| 90067 | } |
| 90068 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 90069 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90070 | if( pCtx==0 ) return; |
| 90071 | #endif |
| 90072 | pCtx->isError = errCode ? errCode : -1; |
| 90073 | #ifdef SQLITE_DEBUG |
| 90074 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| 90075 | #endif |
| 90076 | if( pCtx->pOut->flags & MEM_Null ){ |
| @@ -89773,18 +90079,24 @@ | |
| 90079 | } |
| 90080 | } |
| 90081 | |
| 90082 | /* Force an SQLITE_TOOBIG error. */ |
| 90083 | SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ |
| 90084 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90085 | if( pCtx==0 ) return; |
| 90086 | #endif |
| 90087 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90088 | pCtx->isError = SQLITE_TOOBIG; |
| 90089 | sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, |
| 90090 | SQLITE_UTF8, SQLITE_STATIC); |
| 90091 | } |
| 90092 | |
| 90093 | /* An SQLITE_NOMEM error. */ |
| 90094 | SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ |
| 90095 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90096 | if( pCtx==0 ) return; |
| 90097 | #endif |
| 90098 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90099 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 90100 | pCtx->isError = SQLITE_NOMEM_BKPT; |
| 90101 | sqlite3OomFault(pCtx->pOut->db); |
| 90102 | } |
| @@ -90033,11 +90345,15 @@ | |
| 90345 | /* |
| 90346 | ** Extract the user data from a sqlite3_context structure and return a |
| 90347 | ** pointer to it. |
| 90348 | */ |
| 90349 | SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ |
| 90350 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90351 | if( p==0 ) return 0; |
| 90352 | #else |
| 90353 | assert( p && p->pFunc ); |
| 90354 | #endif |
| 90355 | return p->pFunc->pUserData; |
| 90356 | } |
| 90357 | |
| 90358 | /* |
| 90359 | ** Extract the user data from a sqlite3_context structure and return a |
| @@ -90048,11 +90364,15 @@ | |
| 90364 | ** parameter) of the sqlite3_create_function() and |
| 90365 | ** sqlite3_create_function16() routines that originally registered the |
| 90366 | ** application defined function. |
| 90367 | */ |
| 90368 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ |
| 90369 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90370 | if( p==0 ) return 0; |
| 90371 | #else |
| 90372 | assert( p && p->pOut ); |
| 90373 | #endif |
| 90374 | return p->pOut->db; |
| 90375 | } |
| 90376 | |
| 90377 | /* |
| 90378 | ** If this routine is invoked from within an xColumn method of a virtual |
| @@ -90067,11 +90387,15 @@ | |
| 90387 | ** Virtual table implements might use this routine to optimize their |
| 90388 | ** performance by substituting a NULL result, or some other light-weight |
| 90389 | ** value, as a signal to the xUpdate routine that the column is unchanged. |
| 90390 | */ |
| 90391 | SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ |
| 90392 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90393 | if( p==0 ) return 0; |
| 90394 | #else |
| 90395 | assert( p ); |
| 90396 | #endif |
| 90397 | return sqlite3_value_nochange(p->pOut); |
| 90398 | } |
| 90399 | |
| 90400 | /* |
| 90401 | ** The destructor function for a ValueList object. This needs to be |
| @@ -90095,11 +90419,11 @@ | |
| 90419 | ){ |
| 90420 | int rc; |
| 90421 | ValueList *pRhs; |
| 90422 | |
| 90423 | *ppOut = 0; |
| 90424 | if( pVal==0 ) return SQLITE_MISUSE_BKPT; |
| 90425 | if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ |
| 90426 | return SQLITE_ERROR; |
| 90427 | }else{ |
| 90428 | assert( (pVal->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) == |
| 90429 | (MEM_Null|MEM_Term|MEM_Subtype) ); |
| @@ -90226,10 +90550,13 @@ | |
| 90550 | ** single prepared statement. The iArg values must match. |
| 90551 | */ |
| 90552 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 90553 | AuxData *pAuxData; |
| 90554 | |
| 90555 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90556 | if( pCtx==0 ) return 0; |
| 90557 | #endif |
| 90558 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90559 | #if SQLITE_ENABLE_STAT4 |
| 90560 | if( pCtx->pVdbe==0 ) return 0; |
| 90561 | #else |
| 90562 | assert( pCtx->pVdbe!=0 ); |
| @@ -90258,12 +90585,16 @@ | |
| 90585 | int iArg, |
| 90586 | void *pAux, |
| 90587 | void (*xDelete)(void*) |
| 90588 | ){ |
| 90589 | AuxData *pAuxData; |
| 90590 | Vdbe *pVdbe; |
| 90591 | |
| 90592 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 90593 | if( pCtx==0 ) return; |
| 90594 | #endif |
| 90595 | pVdbe= pCtx->pVdbe; |
| 90596 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 90597 | #ifdef SQLITE_ENABLE_STAT4 |
| 90598 | if( pVdbe==0 ) goto failed; |
| 90599 | #else |
| 90600 | assert( pVdbe!=0 ); |
| @@ -90696,11 +91027,11 @@ | |
| 91027 | if( vdbeSafetyNotNull(p) ){ |
| 91028 | return SQLITE_MISUSE_BKPT; |
| 91029 | } |
| 91030 | sqlite3_mutex_enter(p->db->mutex); |
| 91031 | if( p->eVdbeState!=VDBE_READY_STATE ){ |
| 91032 | sqlite3Error(p->db, SQLITE_MISUSE_BKPT); |
| 91033 | sqlite3_mutex_leave(p->db->mutex); |
| 91034 | sqlite3_log(SQLITE_MISUSE, |
| 91035 | "bind on a busy prepared statement: [%s]", p->zSql); |
| 91036 | return SQLITE_MISUSE_BKPT; |
| 91037 | } |
| @@ -90925,10 +91256,13 @@ | |
| 91256 | return rc; |
| 91257 | } |
| 91258 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| 91259 | int rc; |
| 91260 | Vdbe *p = (Vdbe *)pStmt; |
| 91261 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91262 | if( p==0 ) return SQLITE_MISUSE_BKPT; |
| 91263 | #endif |
| 91264 | sqlite3_mutex_enter(p->db->mutex); |
| 91265 | if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 91266 | rc = SQLITE_TOOBIG; |
| 91267 | }else{ |
| 91268 | assert( (n & 0x7FFFFFFF)==n ); |
| @@ -91051,10 +91385,13 @@ | |
| 91385 | ** Set the explain mode for a statement. |
| 91386 | */ |
| 91387 | SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ |
| 91388 | Vdbe *v = (Vdbe*)pStmt; |
| 91389 | int rc; |
| 91390 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91391 | if( pStmt==0 ) return SQLITE_MISUSE_BKPT; |
| 91392 | #endif |
| 91393 | sqlite3_mutex_enter(v->db->mutex); |
| 91394 | if( ((int)v->explain)==eMode ){ |
| 91395 | rc = SQLITE_OK; |
| 91396 | }else if( eMode<0 || eMode>2 ){ |
| 91397 | rc = SQLITE_ERROR; |
| @@ -91217,14 +91554,20 @@ | |
| 91554 | /* |
| 91555 | ** This function is called from within a pre-update callback to retrieve |
| 91556 | ** a field of the row currently being updated or deleted. |
| 91557 | */ |
| 91558 | SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91559 | PreUpdate *p; |
| 91560 | Mem *pMem; |
| 91561 | int rc = SQLITE_OK; |
| 91562 | |
| 91563 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91564 | if( db==0 || ppValue==0 ){ |
| 91565 | return SQLITE_MISUSE_BKPT; |
| 91566 | } |
| 91567 | #endif |
| 91568 | p = db->pPreUpdate; |
| 91569 | /* Test that this call is being made from within an SQLITE_DELETE or |
| 91570 | ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ |
| 91571 | if( !p || p->op==SQLITE_INSERT ){ |
| 91572 | rc = SQLITE_MISUSE_BKPT; |
| 91573 | goto preupdate_old_out; |
| @@ -91281,11 +91624,16 @@ | |
| 91624 | /* |
| 91625 | ** This function is called from within a pre-update callback to retrieve |
| 91626 | ** the number of columns in the row being updated, deleted or inserted. |
| 91627 | */ |
| 91628 | SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ |
| 91629 | PreUpdate *p; |
| 91630 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91631 | p = db!=0 ? db->pPreUpdate : 0; |
| 91632 | #else |
| 91633 | p = db->pPreUpdate; |
| 91634 | #endif |
| 91635 | return (p ? p->keyinfo.nKeyField : 0); |
| 91636 | } |
| 91637 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 91638 | |
| 91639 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91299,11 +91647,16 @@ | |
| 91647 | ** |
| 91648 | ** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL |
| 91649 | ** or SET DEFAULT action is considered a trigger. |
| 91650 | */ |
| 91651 | SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ |
| 91652 | PreUpdate *p; |
| 91653 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91654 | p = db!=0 ? db->pPreUpdate : 0; |
| 91655 | #else |
| 91656 | p = db->pPreUpdate; |
| 91657 | #endif |
| 91658 | return (p ? p->v->nFrame : 0); |
| 91659 | } |
| 91660 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 91661 | |
| 91662 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91310,11 +91663,16 @@ | |
| 91663 | /* |
| 91664 | ** This function is designed to be called from within a pre-update callback |
| 91665 | ** only. |
| 91666 | */ |
| 91667 | SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ |
| 91668 | PreUpdate *p; |
| 91669 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91670 | p = db!=0 ? db->pPreUpdate : 0; |
| 91671 | #else |
| 91672 | p = db->pPreUpdate; |
| 91673 | #endif |
| 91674 | return (p ? p->iBlobWrite : -1); |
| 91675 | } |
| 91676 | #endif |
| 91677 | |
| 91678 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91321,14 +91679,20 @@ | |
| 91679 | /* |
| 91680 | ** This function is called from within a pre-update callback to retrieve |
| 91681 | ** a field of the row currently being updated or inserted. |
| 91682 | */ |
| 91683 | SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ |
| 91684 | PreUpdate *p; |
| 91685 | int rc = SQLITE_OK; |
| 91686 | Mem *pMem; |
| 91687 | |
| 91688 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91689 | if( db==0 || ppValue==0 ){ |
| 91690 | return SQLITE_MISUSE_BKPT; |
| 91691 | } |
| 91692 | #endif |
| 91693 | p = db->pPreUpdate; |
| 91694 | if( !p || p->op==SQLITE_DELETE ){ |
| 91695 | rc = SQLITE_MISUSE_BKPT; |
| 91696 | goto preupdate_new_out; |
| 91697 | } |
| 91698 | if( p->pPk && p->op!=SQLITE_UPDATE ){ |
| @@ -91403,15 +91767,24 @@ | |
| 91767 | int iScanStatusOp, /* Which metric to return */ |
| 91768 | int flags, |
| 91769 | void *pOut /* OUT: Write the answer here */ |
| 91770 | ){ |
| 91771 | Vdbe *p = (Vdbe*)pStmt; |
| 91772 | VdbeOp *aOp; |
| 91773 | int nOp; |
| 91774 | ScanStatus *pScan = 0; |
| 91775 | int idx; |
| 91776 | |
| 91777 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 91778 | if( p==0 || pOut==0 |
| 91779 | || iScanStatusOp<SQLITE_SCANSTAT_NLOOP |
| 91780 | || iScanStatusOp>SQLITE_SCANSTAT_NCYCLE ){ |
| 91781 | return 1; |
| 91782 | } |
| 91783 | #endif |
| 91784 | aOp = p->aOp; |
| 91785 | nOp = p->nOp; |
| 91786 | if( p->pFrame ){ |
| 91787 | VdbeFrame *pFrame; |
| 91788 | for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); |
| 91789 | aOp = pFrame->aOp; |
| 91790 | nOp = pFrame->nOp; |
| @@ -91554,11 +91927,11 @@ | |
| 91927 | ** Zero all counters associated with the sqlite3_stmt_scanstatus() data. |
| 91928 | */ |
| 91929 | SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ |
| 91930 | Vdbe *p = (Vdbe*)pStmt; |
| 91931 | int ii; |
| 91932 | for(ii=0; p!=0 && ii<p->nOp; ii++){ |
| 91933 | Op *pOp = &p->aOp[ii]; |
| 91934 | pOp->nExec = 0; |
| 91935 | pOp->nCycle = 0; |
| 91936 | } |
| 91937 | } |
| @@ -92523,15 +92896,15 @@ | |
| 92896 | } |
| 92897 | assert( t>=12 ); |
| 92898 | sqlite3RCStrRef(pBuf); |
| 92899 | if( t&1 ){ |
| 92900 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, |
| 92901 | sqlite3RCStrUnref); |
| 92902 | pDest->flags |= MEM_Term; |
| 92903 | }else{ |
| 92904 | rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, |
| 92905 | sqlite3RCStrUnref); |
| 92906 | } |
| 92907 | }else{ |
| 92908 | rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); |
| 92909 | if( rc ) return rc; |
| 92910 | sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); |
| @@ -95402,24 +95775,28 @@ | |
| 95775 | *(zHdr++) = serial_type; |
| 95776 | if( serial_type==0 ){ |
| 95777 | /* NULL value. No change in zPayload */ |
| 95778 | }else{ |
| 95779 | u64 v; |
| 95780 | if( serial_type==7 ){ |
| 95781 | assert( sizeof(v)==sizeof(pRec->u.r) ); |
| 95782 | memcpy(&v, &pRec->u.r, sizeof(v)); |
| 95783 | swapMixedEndianFloat(v); |
| 95784 | }else{ |
| 95785 | v = pRec->u.i; |
| 95786 | } |
| 95787 | len = sqlite3SmallTypeSizes[serial_type]; |
| 95788 | assert( len>=1 && len<=8 && len!=5 && len!=7 ); |
| 95789 | switch( len ){ |
| 95790 | default: zPayload[7] = (u8)(v&0xff); v >>= 8; |
| 95791 | zPayload[6] = (u8)(v&0xff); v >>= 8; |
| 95792 | case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; |
| 95793 | zPayload[4] = (u8)(v&0xff); v >>= 8; |
| 95794 | case 4: zPayload[3] = (u8)(v&0xff); v >>= 8; |
| 95795 | case 3: zPayload[2] = (u8)(v&0xff); v >>= 8; |
| 95796 | case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; |
| 95797 | case 1: zPayload[0] = (u8)(v&0xff); |
| 95798 | } |
| 95799 | zPayload += len; |
| 95800 | } |
| 95801 | }else if( serial_type<0x80 ){ |
| 95802 | *(zHdr++) = serial_type; |
| @@ -97532,12 +97909,17 @@ | |
| 97909 | ** delete is one of several associated with deleting a table row and |
| 97910 | ** all its associated index entries. Exactly one of those deletes is |
| 97911 | ** the "primary" delete. The others are all on OPFLAG_FORDELETE |
| 97912 | ** cursors or else are marked with the AUXDELETE flag. |
| 97913 | ** |
| 97914 | ** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then |
| 97915 | ** the row change count is incremented (otherwise not). |
| 97916 | ** |
| 97917 | ** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the |
| 97918 | ** pre-update-hook for deletes is run, but the btree is otherwise unchanged. |
| 97919 | ** This happens when the OP_Delete is to be shortly followed by an OP_Insert |
| 97920 | ** with the same key, causing the btree entry to be overwritten. |
| 97921 | ** |
| 97922 | ** P1 must not be pseudo-table. It has to be a real table with |
| 97923 | ** multiple rows. |
| 97924 | ** |
| 97925 | ** If P4 is not NULL then it points to a Table object. In this case either |
| @@ -98658,17 +99040,37 @@ | |
| 99040 | } |
| 99041 | |
| 99042 | /* Opcode: SqlExec * * * P4 * |
| 99043 | ** |
| 99044 | ** Run the SQL statement or statements specified in the P4 string. |
| 99045 | ** Disable Auth and Trace callbacks while those statements are running if |
| 99046 | ** P1 is true. |
| 99047 | */ |
| 99048 | case OP_SqlExec: { |
| 99049 | char *zErr; |
| 99050 | sqlite3_xauth xAuth; |
| 99051 | u8 mTrace; |
| 99052 | |
| 99053 | sqlite3VdbeIncrWriteCounter(p, 0); |
| 99054 | db->nSqlExec++; |
| 99055 | zErr = 0; |
| 99056 | xAuth = db->xAuth; |
| 99057 | mTrace = db->mTrace; |
| 99058 | if( pOp->p1 ){ |
| 99059 | db->xAuth = 0; |
| 99060 | db->mTrace = 0; |
| 99061 | } |
| 99062 | rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr); |
| 99063 | db->nSqlExec--; |
| 99064 | db->xAuth = xAuth; |
| 99065 | db->mTrace = mTrace; |
| 99066 | if( zErr || rc ){ |
| 99067 | sqlite3VdbeError(p, "%s", zErr); |
| 99068 | sqlite3_free(zErr); |
| 99069 | if( rc==SQLITE_NOMEM ) goto no_mem; |
| 99070 | goto abort_due_to_error; |
| 99071 | } |
| 99072 | break; |
| 99073 | } |
| 99074 | |
| 99075 | /* Opcode: ParseSchema P1 * * P4 * |
| 99076 | ** |
| @@ -99885,10 +100287,54 @@ | |
| 100287 | } |
| 100288 | break; |
| 100289 | } |
| 100290 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 100291 | |
| 100292 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 100293 | /* Opcode: VCheck * P2 * P4 * |
| 100294 | ** |
| 100295 | ** P4 is a pointer to a Table object that is a virtual table that |
| 100296 | ** supports the xIntegrity() method. This opcode runs the xIntegrity() |
| 100297 | ** method for that virtual table. If an error is reported back, the error |
| 100298 | ** message is stored in register P2. If no errors are seen, register P2 |
| 100299 | ** is set to NULL. |
| 100300 | */ |
| 100301 | case OP_VCheck: { /* out2 */ |
| 100302 | Table *pTab; |
| 100303 | sqlite3_vtab *pVtab; |
| 100304 | const sqlite3_module *pModule; |
| 100305 | char *zErr = 0; |
| 100306 | |
| 100307 | pOut = &aMem[pOp->p2]; |
| 100308 | sqlite3VdbeMemSetNull(pOut); /* Innocent until proven guilty */ |
| 100309 | assert( pOp->p4type==P4_TABLE ); |
| 100310 | pTab = pOp->p4.pTab; |
| 100311 | assert( pTab!=0 ); |
| 100312 | assert( IsVirtual(pTab) ); |
| 100313 | assert( pTab->u.vtab.p!=0 ); |
| 100314 | pVtab = pTab->u.vtab.p->pVtab; |
| 100315 | assert( pVtab!=0 ); |
| 100316 | pModule = pVtab->pModule; |
| 100317 | assert( pModule!=0 ); |
| 100318 | assert( pModule->iVersion>=4 ); |
| 100319 | assert( pModule->xIntegrity!=0 ); |
| 100320 | pTab->nTabRef++; |
| 100321 | sqlite3VtabLock(pTab->u.vtab.p); |
| 100322 | rc = pModule->xIntegrity(pVtab, &zErr); |
| 100323 | sqlite3VtabUnlock(pTab->u.vtab.p); |
| 100324 | sqlite3DeleteTable(db, pTab); |
| 100325 | if( rc ){ |
| 100326 | sqlite3_free(zErr); |
| 100327 | goto abort_due_to_error; |
| 100328 | } |
| 100329 | if( zErr ){ |
| 100330 | sqlite3VdbeMemSetStr(pOut, zErr, -1, SQLITE_UTF8, sqlite3_free); |
| 100331 | } |
| 100332 | break; |
| 100333 | } |
| 100334 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 100335 | |
| 100336 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 100337 | /* Opcode: VInitIn P1 P2 P3 * * |
| 100338 | ** Synopsis: r[P2]=ValueList(P1,P3) |
| 100339 | ** |
| 100340 | ** Set register P2 to be a pointer to a ValueList object for cursor P1 |
| @@ -100831,12 +101277,11 @@ | |
| 101277 | Vdbe *v = (Vdbe *)p->pStmt; |
| 101278 | |
| 101279 | /* Set the value of register r[1] in the SQL statement to integer iRow. |
| 101280 | ** This is done directly as a performance optimization |
| 101281 | */ |
| 101282 | sqlite3VdbeMemSetInt64(&v->aMem[1], iRow); |
| 101283 | |
| 101284 | /* If the statement has been run before (and is paused at the OP_ResultRow) |
| 101285 | ** then back it up to the point where it does the OP_NotExists. This could |
| 101286 | ** have been down with an extra OP_Goto, but simply setting the program |
| 101287 | ** counter is faster. */ |
| @@ -100915,11 +101360,11 @@ | |
| 101360 | return SQLITE_MISUSE_BKPT; |
| 101361 | } |
| 101362 | #endif |
| 101363 | *ppBlob = 0; |
| 101364 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 101365 | if( !sqlite3SafetyCheckOk(db) || zTable==0 || zColumn==0 ){ |
| 101366 | return SQLITE_MISUSE_BKPT; |
| 101367 | } |
| 101368 | #endif |
| 101369 | wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */ |
| 101370 | |
| @@ -101477,11 +101922,11 @@ | |
| 101922 | ** are connected using SorterRecord.u.iNext. |
| 101923 | */ |
| 101924 | struct SorterList { |
| 101925 | SorterRecord *pList; /* Linked list of records */ |
| 101926 | u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ |
| 101927 | i64 szPMA; /* Size of pList as PMA in bytes */ |
| 101928 | }; |
| 101929 | |
| 101930 | /* |
| 101931 | ** The MergeEngine object is used to combine two or more smaller PMAs into |
| 101932 | ** one big PMA using a merge operation. Separate PMAs all need to be |
| @@ -101586,14 +102031,14 @@ | |
| 102031 | */ |
| 102032 | typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int); |
| 102033 | struct SortSubtask { |
| 102034 | SQLiteThread *pThread; /* Background thread, if any */ |
| 102035 | int bDone; /* Set if thread is finished but not joined */ |
| 102036 | int nPMA; /* Number of PMAs currently in file */ |
| 102037 | VdbeSorter *pSorter; /* Sorter that owns this sub-task */ |
| 102038 | UnpackedRecord *pUnpacked; /* Space to unpack a record */ |
| 102039 | SorterList list; /* List for thread to write to a PMA */ |
| 102040 | SorterCompare xCompare; /* Compare function to use */ |
| 102041 | SorterFile file; /* Temp file for level-0 PMAs */ |
| 102042 | SorterFile file2; /* Space for other PMAs */ |
| 102043 | }; |
| 102044 | |
| @@ -103063,12 +103508,12 @@ | |
| 103508 | ){ |
| 103509 | VdbeSorter *pSorter; |
| 103510 | int rc = SQLITE_OK; /* Return Code */ |
| 103511 | SorterRecord *pNew; /* New list element */ |
| 103512 | int bFlush; /* True to flush contents of memory to PMA */ |
| 103513 | i64 nReq; /* Bytes of memory required */ |
| 103514 | i64 nPMA; /* Bytes of PMA space required */ |
| 103515 | int t; /* serial type of first record field */ |
| 103516 | |
| 103517 | assert( pCsr->eCurType==CURTYPE_SORTER ); |
| 103518 | pSorter = pCsr->uc.pSorter; |
| 103519 | getVarint32NR((const u8*)&pVal->z[1], t); |
| @@ -104488,11 +104933,12 @@ | |
| 104933 | /* xFindMethod */ 0, |
| 104934 | /* xRename */ 0, |
| 104935 | /* xSavepoint */ 0, |
| 104936 | /* xRelease */ 0, |
| 104937 | /* xRollbackTo */ 0, |
| 104938 | /* xShadowName */ 0, |
| 104939 | /* xIntegrity */ 0 |
| 104940 | }; |
| 104941 | |
| 104942 | |
| 104943 | SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3 *db){ |
| 104944 | int rc; |
| @@ -105317,25 +105763,40 @@ | |
| 105763 | sqlite3ExprDeferredDelete(pParse, pDup); |
| 105764 | } |
| 105765 | } |
| 105766 | |
| 105767 | /* |
| 105768 | ** Subqueries store the original database, table and column names for their |
| 105769 | ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN", |
| 105770 | ** and mark the expression-list item by setting ExprList.a[].fg.eEName |
| 105771 | ** to ENAME_TAB. |
| 105772 | ** |
| 105773 | ** Check to see if the zSpan/eEName of the expression-list item passed to this |
| 105774 | ** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are |
| 105775 | ** NULL then those fields will match anything. Return true if there is a match, |
| 105776 | ** or false otherwise. |
| 105777 | ** |
| 105778 | ** SF_NestedFrom subqueries also store an entry for the implicit rowid (or |
| 105779 | ** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID, |
| 105780 | ** and setting zSpan to "DATABASE.TABLE.<rowid-alias>". This type of pItem |
| 105781 | ** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid) |
| 105782 | ** is set to 1 if there is this kind of match. |
| 105783 | */ |
| 105784 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 105785 | const struct ExprList_item *pItem, |
| 105786 | const char *zCol, |
| 105787 | const char *zTab, |
| 105788 | const char *zDb, |
| 105789 | int *pbRowid |
| 105790 | ){ |
| 105791 | int n; |
| 105792 | const char *zSpan; |
| 105793 | int eEName = pItem->fg.eEName; |
| 105794 | if( eEName!=ENAME_TAB && (eEName!=ENAME_ROWID || NEVER(pbRowid==0)) ){ |
| 105795 | return 0; |
| 105796 | } |
| 105797 | assert( pbRowid==0 || *pbRowid==0 ); |
| 105798 | zSpan = pItem->zEName; |
| 105799 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105800 | if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ |
| 105801 | return 0; |
| 105802 | } |
| @@ -105343,13 +105804,15 @@ | |
| 105804 | for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} |
| 105805 | if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){ |
| 105806 | return 0; |
| 105807 | } |
| 105808 | zSpan += n+1; |
| 105809 | if( zCol ){ |
| 105810 | if( eEName==ENAME_TAB && sqlite3StrICmp(zSpan, zCol)!=0 ) return 0; |
| 105811 | if( eEName==ENAME_ROWID && sqlite3IsRowid(zCol)==0 ) return 0; |
| 105812 | } |
| 105813 | if( eEName==ENAME_ROWID ) *pbRowid = 1; |
| 105814 | return 1; |
| 105815 | } |
| 105816 | |
| 105817 | /* |
| 105818 | ** Return TRUE if the double-quoted string mis-feature should be supported. |
| @@ -105478,11 +105941,11 @@ | |
| 105941 | NameContext *pNC, /* The name context used to resolve the name */ |
| 105942 | Expr *pExpr /* Make this EXPR node point to the selected column */ |
| 105943 | ){ |
| 105944 | int i, j; /* Loop counters */ |
| 105945 | int cnt = 0; /* Number of matching column names */ |
| 105946 | int cntTab = 0; /* Number of potential "rowid" matches */ |
| 105947 | int nSubquery = 0; /* How many levels of subquery */ |
| 105948 | sqlite3 *db = pParse->db; /* The database connection */ |
| 105949 | SrcItem *pItem; /* Use for looping over pSrcList items */ |
| 105950 | SrcItem *pMatch = 0; /* The matching pSrcList item */ |
| 105951 | NameContext *pTopNC = pNC; /* First namecontext in the list */ |
| @@ -105555,43 +106018,53 @@ | |
| 106018 | assert( pItem->pSelect!=0 ); |
| 106019 | pEList = pItem->pSelect->pEList; |
| 106020 | assert( pEList!=0 ); |
| 106021 | assert( pEList->nExpr==pTab->nCol ); |
| 106022 | for(j=0; j<pEList->nExpr; j++){ |
| 106023 | int bRowid = 0; /* True if possible rowid match */ |
| 106024 | if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb, &bRowid) ){ |
| 106025 | continue; |
| 106026 | } |
| 106027 | if( bRowid==0 ){ |
| 106028 | if( cnt>0 ){ |
| 106029 | if( pItem->fg.isUsing==0 |
| 106030 | || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 |
| 106031 | ){ |
| 106032 | /* Two or more tables have the same column name which is |
| 106033 | ** not joined by USING. This is an error. Signal as much |
| 106034 | ** by clearing pFJMatch and letting cnt go above 1. */ |
| 106035 | sqlite3ExprListDelete(db, pFJMatch); |
| 106036 | pFJMatch = 0; |
| 106037 | }else |
| 106038 | if( (pItem->fg.jointype & JT_RIGHT)==0 ){ |
| 106039 | /* An INNER or LEFT JOIN. Use the left-most table */ |
| 106040 | continue; |
| 106041 | }else |
| 106042 | if( (pItem->fg.jointype & JT_LEFT)==0 ){ |
| 106043 | /* A RIGHT JOIN. Use the right-most table */ |
| 106044 | cnt = 0; |
| 106045 | sqlite3ExprListDelete(db, pFJMatch); |
| 106046 | pFJMatch = 0; |
| 106047 | }else{ |
| 106048 | /* For a FULL JOIN, we must construct a coalesce() func */ |
| 106049 | extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); |
| 106050 | } |
| 106051 | } |
| 106052 | cnt++; |
| 106053 | hit = 1; |
| 106054 | }else if( cnt>0 ){ |
| 106055 | /* This is a potential rowid match, but there has already been |
| 106056 | ** a real match found. So this can be ignored. */ |
| 106057 | continue; |
| 106058 | } |
| 106059 | cntTab++; |
| 106060 | pMatch = pItem; |
| 106061 | pExpr->iColumn = j; |
| 106062 | pEList->a[j].fg.bUsed = 1; |
| 106063 | |
| 106064 | /* rowid cannot be part of a USING clause - assert() this. */ |
| 106065 | assert( bRowid==0 || pEList->a[j].fg.bUsingTerm==0 ); |
| 106066 | if( pEList->a[j].fg.bUsingTerm ) break; |
| 106067 | } |
| 106068 | if( hit || zTab==0 ) continue; |
| 106069 | } |
| 106070 | assert( zDb==0 || zTab!=0 ); |
| @@ -105782,14 +106255,14 @@ | |
| 106255 | if( cnt==0 |
| 106256 | && cntTab==1 |
| 106257 | && pMatch |
| 106258 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 |
| 106259 | && sqlite3IsRowid(zCol) |
| 106260 | && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) |
| 106261 | ){ |
| 106262 | cnt = 1; |
| 106263 | if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; |
| 106264 | pExpr->affExpr = SQLITE_AFF_INTEGER; |
| 106265 | } |
| 106266 | |
| 106267 | /* |
| 106268 | ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z |
| @@ -106238,10 +106711,11 @@ | |
| 106711 | int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin)); |
| 106712 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106713 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); |
| 106714 | #endif |
| 106715 | assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); |
| 106716 | assert( pExpr->pLeft==0 || pExpr->pLeft->op==TK_ORDER ); |
| 106717 | zId = pExpr->u.zToken; |
| 106718 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 106719 | if( pDef==0 ){ |
| 106720 | pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| 106721 | if( pDef==0 ){ |
| @@ -106379,10 +106853,14 @@ | |
| 106853 | pExpr |
| 106854 | ); |
| 106855 | pNC->nNcErr++; |
| 106856 | } |
| 106857 | #endif |
| 106858 | else if( is_agg==0 && pExpr->pLeft ){ |
| 106859 | sqlite3ExprOrderByAggregateError(pParse, pExpr); |
| 106860 | pNC->nNcErr++; |
| 106861 | } |
| 106862 | if( is_agg ){ |
| 106863 | /* Window functions may not be arguments of aggregate functions. |
| 106864 | ** Or arguments of other window functions. But aggregate functions |
| 106865 | ** may be arguments for window functions. */ |
| 106866 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -106397,10 +106875,15 @@ | |
| 106875 | is_agg = 1; |
| 106876 | } |
| 106877 | #endif |
| 106878 | sqlite3WalkExprList(pWalker, pList); |
| 106879 | if( is_agg ){ |
| 106880 | if( pExpr->pLeft ){ |
| 106881 | assert( pExpr->pLeft->op==TK_ORDER ); |
| 106882 | assert( ExprUseXList(pExpr->pLeft) ); |
| 106883 | sqlite3WalkExprList(pWalker, pExpr->pLeft->x.pList); |
| 106884 | } |
| 106885 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 106886 | if( pWin ){ |
| 106887 | Select *pSel = pNC->pWinSelect; |
| 106888 | assert( pWin==0 || (ExprUseYWin(pExpr) && pWin==pExpr->y.pWin) ); |
| 106889 | if( IN_RENAME_OBJECT==0 ){ |
| @@ -106960,13 +107443,11 @@ | |
| 107443 | nCompound = 0; |
| 107444 | pLeftmost = p; |
| 107445 | while( p ){ |
| 107446 | assert( (p->selFlags & SF_Expanded)!=0 ); |
| 107447 | assert( (p->selFlags & SF_Resolved)==0 ); |
| 107448 | p->selFlags |= SF_Resolved; |
| 107449 | |
| 107450 | /* Resolve the expressions in the LIMIT and OFFSET clauses. These |
| 107451 | ** are not allowed to refer to any names, so pass an empty NameContext. |
| 107452 | */ |
| 107453 | memset(&sNC, 0, sizeof(sNC)); |
| @@ -107969,10 +108450,11 @@ | |
| 108450 | ** with the same pLeft pointer to the pVector, but only one of them |
| 108451 | ** will own the pVector. |
| 108452 | */ |
| 108453 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); |
| 108454 | if( pRet ){ |
| 108455 | ExprSetProperty(pRet, EP_FullSize); |
| 108456 | pRet->iTable = nField; |
| 108457 | pRet->iColumn = iField; |
| 108458 | pRet->pLeft = pVector; |
| 108459 | } |
| 108460 | }else{ |
| @@ -108558,10 +109040,73 @@ | |
| 109040 | assert( ExprUseXList(pNew) ); |
| 109041 | sqlite3ExprSetHeightAndFlags(pParse, pNew); |
| 109042 | if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct); |
| 109043 | return pNew; |
| 109044 | } |
| 109045 | |
| 109046 | /* |
| 109047 | ** Report an error when attempting to use an ORDER BY clause within |
| 109048 | ** the arguments of a non-aggregate function. |
| 109049 | */ |
| 109050 | SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse *pParse, Expr *p){ |
| 109051 | sqlite3ErrorMsg(pParse, |
| 109052 | "ORDER BY may not be used with non-aggregate %#T()", p |
| 109053 | ); |
| 109054 | } |
| 109055 | |
| 109056 | /* |
| 109057 | ** Attach an ORDER BY clause to a function call. |
| 109058 | ** |
| 109059 | ** functionname( arguments ORDER BY sortlist ) |
| 109060 | ** \_____________________/ \______/ |
| 109061 | ** pExpr pOrderBy |
| 109062 | ** |
| 109063 | ** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER |
| 109064 | ** and added to the Expr.pLeft field of the parent TK_FUNCTION node. |
| 109065 | */ |
| 109066 | SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy( |
| 109067 | Parse *pParse, /* Parsing context */ |
| 109068 | Expr *pExpr, /* The function call to which ORDER BY is to be added */ |
| 109069 | ExprList *pOrderBy /* The ORDER BY clause to add */ |
| 109070 | ){ |
| 109071 | Expr *pOB; |
| 109072 | sqlite3 *db = pParse->db; |
| 109073 | if( NEVER(pOrderBy==0) ){ |
| 109074 | assert( db->mallocFailed ); |
| 109075 | return; |
| 109076 | } |
| 109077 | if( pExpr==0 ){ |
| 109078 | assert( db->mallocFailed ); |
| 109079 | sqlite3ExprListDelete(db, pOrderBy); |
| 109080 | return; |
| 109081 | } |
| 109082 | assert( pExpr->op==TK_FUNCTION ); |
| 109083 | assert( pExpr->pLeft==0 ); |
| 109084 | assert( ExprUseXList(pExpr) ); |
| 109085 | if( pExpr->x.pList==0 || NEVER(pExpr->x.pList->nExpr==0) ){ |
| 109086 | /* Ignore ORDER BY on zero-argument aggregates */ |
| 109087 | sqlite3ParserAddCleanup(pParse, |
| 109088 | (void(*)(sqlite3*,void*))sqlite3ExprListDelete, |
| 109089 | pOrderBy); |
| 109090 | return; |
| 109091 | } |
| 109092 | if( IsWindowFunc(pExpr) ){ |
| 109093 | sqlite3ExprOrderByAggregateError(pParse, pExpr); |
| 109094 | sqlite3ExprListDelete(db, pOrderBy); |
| 109095 | return; |
| 109096 | } |
| 109097 | |
| 109098 | pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0); |
| 109099 | if( pOB==0 ){ |
| 109100 | sqlite3ExprListDelete(db, pOrderBy); |
| 109101 | return; |
| 109102 | } |
| 109103 | pOB->x.pList = pOrderBy; |
| 109104 | assert( ExprUseXList(pOB) ); |
| 109105 | pExpr->pLeft = pOB; |
| 109106 | ExprSetProperty(pOB, EP_FullSize); |
| 109107 | } |
| 109108 | |
| 109109 | /* |
| 109110 | ** Check to see if a function is usable according to current access |
| 109111 | ** rules: |
| 109112 | ** |
| @@ -108812,15 +109357,11 @@ | |
| 109357 | static int dupedExprStructSize(const Expr *p, int flags){ |
| 109358 | int nSize; |
| 109359 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ |
| 109360 | assert( EXPR_FULLSIZE<=0xfff ); |
| 109361 | assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); |
| 109362 | if( 0==flags || ExprHasProperty(p, EP_FullSize) ){ |
| 109363 | nSize = EXPR_FULLSIZE; |
| 109364 | }else{ |
| 109365 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| 109366 | assert( !ExprHasProperty(p, EP_OuterON) ); |
| 109367 | assert( !ExprHasVVAProperty(p, EP_NoReduce) ); |
| @@ -108847,84 +109388,123 @@ | |
| 109388 | return ROUND8(nByte); |
| 109389 | } |
| 109390 | |
| 109391 | /* |
| 109392 | ** Return the number of bytes required to create a duplicate of the |
| 109393 | ** expression passed as the first argument. |
| 109394 | ** |
| 109395 | ** The value returned includes space to create a copy of the Expr struct |
| 109396 | ** itself and the buffer referred to by Expr.u.zToken, if any. |
| 109397 | ** |
| 109398 | ** The return value includes space to duplicate all Expr nodes in the |
| 109399 | ** tree formed by Expr.pLeft and Expr.pRight, but not any other |
| 109400 | ** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin. |
| 109401 | */ |
| 109402 | static int dupedExprSize(const Expr *p){ |
| 109403 | int nByte; |
| 109404 | assert( p!=0 ); |
| 109405 | nByte = dupedExprNodeSize(p, EXPRDUP_REDUCE); |
| 109406 | if( p->pLeft ) nByte += dupedExprSize(p->pLeft); |
| 109407 | if( p->pRight ) nByte += dupedExprSize(p->pRight); |
| 109408 | return nByte; |
| 109409 | } |
| 109410 | |
| 109411 | /* |
| 109412 | ** An EdupBuf is a memory allocation used to stored multiple Expr objects |
| 109413 | ** together with their Expr.zToken content. This is used to help implement |
| 109414 | ** compression while doing sqlite3ExprDup(). The top-level Expr does the |
| 109415 | ** allocation for itself and many of its decendents, then passes an instance |
| 109416 | ** of the structure down into exprDup() so that they decendents can have |
| 109417 | ** access to that memory. |
| 109418 | */ |
| 109419 | typedef struct EdupBuf EdupBuf; |
| 109420 | struct EdupBuf { |
| 109421 | u8 *zAlloc; /* Memory space available for storage */ |
| 109422 | #ifdef SQLITE_DEBUG |
| 109423 | u8 *zEnd; /* First byte past the end of memory */ |
| 109424 | #endif |
| 109425 | }; |
| 109426 | |
| 109427 | /* |
| 109428 | ** This function is similar to sqlite3ExprDup(), except that if pEdupBuf |
| 109429 | ** is not NULL then it points to memory that can be used to store a copy |
| 109430 | ** of the input Expr p together with its p->u.zToken (if any). pEdupBuf |
| 109431 | ** is updated with the new buffer tail prior to returning. |
| 109432 | */ |
| 109433 | static Expr *exprDup( |
| 109434 | sqlite3 *db, /* Database connection (for memory allocation) */ |
| 109435 | const Expr *p, /* Expr tree to be duplicated */ |
| 109436 | int dupFlags, /* EXPRDUP_REDUCE for compression. 0 if not */ |
| 109437 | EdupBuf *pEdupBuf /* Preallocated storage space, or NULL */ |
| 109438 | ){ |
| 109439 | Expr *pNew; /* Value to return */ |
| 109440 | EdupBuf sEdupBuf; /* Memory space from which to build Expr object */ |
| 109441 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ |
| 109442 | int nToken = -1; /* Space needed for p->u.zToken. -1 means unknown */ |
| 109443 | |
| 109444 | assert( db!=0 ); |
| 109445 | assert( p ); |
| 109446 | assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); |
| 109447 | assert( pEdupBuf==0 || dupFlags==EXPRDUP_REDUCE ); |
| 109448 | |
| 109449 | /* Figure out where to write the new Expr structure. */ |
| 109450 | if( pEdupBuf ){ |
| 109451 | sEdupBuf.zAlloc = pEdupBuf->zAlloc; |
| 109452 | #ifdef SQLITE_DEBUG |
| 109453 | sEdupBuf.zEnd = pEdupBuf->zEnd; |
| 109454 | #endif |
| 109455 | staticFlag = EP_Static; |
| 109456 | assert( sEdupBuf.zAlloc!=0 ); |
| 109457 | assert( dupFlags==EXPRDUP_REDUCE ); |
| 109458 | }else{ |
| 109459 | int nAlloc; |
| 109460 | if( dupFlags ){ |
| 109461 | nAlloc = dupedExprSize(p); |
| 109462 | }else if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ |
| 109463 | nToken = sqlite3Strlen30NN(p->u.zToken)+1; |
| 109464 | nAlloc = EXPR_FULLSIZE + nToken; |
| 109465 | }else{ |
| 109466 | nToken = 0; |
| 109467 | nAlloc = EXPR_FULLSIZE; |
| 109468 | } |
| 109469 | sEdupBuf.zAlloc = sqlite3DbMallocRawNN(db, nAlloc); |
| 109470 | #ifdef SQLITE_DEBUG |
| 109471 | sEdupBuf.zEnd = sEdupBuf.zAlloc ? sEdupBuf.zAlloc+nAlloc : 0; |
| 109472 | #endif |
| 109473 | |
| 109474 | staticFlag = 0; |
| 109475 | } |
| 109476 | pNew = (Expr *)sEdupBuf.zAlloc; |
| 109477 | |
| 109478 | if( pNew ){ |
| 109479 | /* Set nNewSize to the size allocated for the structure pointed to |
| 109480 | ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or |
| 109481 | ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed |
| 109482 | ** by the copy of the p->u.zToken string (if any). |
| 109483 | */ |
| 109484 | const unsigned nStructSize = dupedExprStructSize(p, dupFlags); |
| 109485 | const int nNewSize = nStructSize & 0xfff; |
| 109486 | if( nToken<0 ){ |
| 109487 | if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ |
| 109488 | nToken = sqlite3Strlen30(p->u.zToken) + 1; |
| 109489 | }else{ |
| 109490 | nToken = 0; |
| 109491 | } |
| 109492 | } |
| 109493 | if( dupFlags ){ |
| 109494 | assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= nNewSize+nToken ); |
| 109495 | assert( ExprHasProperty(p, EP_Reduced)==0 ); |
| 109496 | memcpy(sEdupBuf.zAlloc, p, nNewSize); |
| 109497 | sEdupBuf.zAlloc += nNewSize; |
| 109498 | }else{ |
| 109499 | u32 nSize = (u32)exprStructSize(p); |
| 109500 | assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= EXPR_FULLSIZE+nToken ); |
| 109501 | memcpy(sEdupBuf.zAlloc, p, nSize); |
| 109502 | if( nSize<EXPR_FULLSIZE ){ |
| 109503 | memset(&sEdupBuf.zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); |
| 109504 | } |
| 109505 | sEdupBuf.zAlloc += EXPR_FULLSIZE; |
| 109506 | } |
| 109507 | |
| 109508 | /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ |
| 109509 | pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static); |
| 109510 | pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly); |
| @@ -108933,55 +109513,62 @@ | |
| 109513 | if( dupFlags ){ |
| 109514 | ExprSetVVAProperty(pNew, EP_Immutable); |
| 109515 | } |
| 109516 | |
| 109517 | /* Copy the p->u.zToken string, if any. */ |
| 109518 | assert( nToken>=0 ); |
| 109519 | if( nToken>0 ){ |
| 109520 | char *zToken = pNew->u.zToken = (char*)sEdupBuf.zAlloc; |
| 109521 | memcpy(zToken, p->u.zToken, nToken); |
| 109522 | sEdupBuf.zAlloc += nToken; |
| 109523 | } |
| 109524 | |
| 109525 | if( ((p->flags|pNew->flags)&(EP_TokenOnly|EP_Leaf))==0 ){ |
| 109526 | |
| 109527 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ |
| 109528 | if( ExprUseXSelect(p) ){ |
| 109529 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); |
| 109530 | }else{ |
| 109531 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, |
| 109532 | p->op!=TK_ORDER ? dupFlags : 0); |
| 109533 | } |
| 109534 | |
| 109535 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 109536 | if( ExprHasProperty(p, EP_WinFunc) ){ |
| 109537 | pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); |
| 109538 | assert( ExprHasProperty(pNew, EP_WinFunc) ); |
| 109539 | } |
| 109540 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 109541 | |
| 109542 | /* Fill in pNew->pLeft and pNew->pRight. */ |
| 109543 | if( dupFlags ){ |
| 109544 | if( p->op==TK_SELECT_COLUMN ){ |
| 109545 | pNew->pLeft = p->pLeft; |
| 109546 | assert( p->pRight==0 |
| 109547 | || p->pRight==p->pLeft |
| 109548 | || ExprHasProperty(p->pLeft, EP_Subquery) ); |
| 109549 | }else{ |
| 109550 | pNew->pLeft = p->pLeft ? |
| 109551 | exprDup(db, p->pLeft, EXPRDUP_REDUCE, &sEdupBuf) : 0; |
| 109552 | } |
| 109553 | pNew->pRight = p->pRight ? |
| 109554 | exprDup(db, p->pRight, EXPRDUP_REDUCE, &sEdupBuf) : 0; |
| 109555 | }else{ |
| 109556 | if( p->op==TK_SELECT_COLUMN ){ |
| 109557 | pNew->pLeft = p->pLeft; |
| 109558 | assert( p->pRight==0 |
| 109559 | || p->pRight==p->pLeft |
| 109560 | || ExprHasProperty(p->pLeft, EP_Subquery) ); |
| 109561 | }else{ |
| 109562 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 109563 | } |
| 109564 | pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); |
| 109565 | } |
| 109566 | } |
| 109567 | } |
| 109568 | if( pEdupBuf ) memcpy(pEdupBuf, &sEdupBuf, sizeof(sEdupBuf)); |
| 109569 | assert( sEdupBuf.zAlloc <= sEdupBuf.zEnd ); |
| 109570 | return pNew; |
| 109571 | } |
| 109572 | |
| 109573 | /* |
| 109574 | ** Create and return a deep copy of the object passed as the second |
| @@ -109242,15 +109829,11 @@ | |
| 109829 | /* |
| 109830 | ** Add a new element to the end of an expression list. If pList is |
| 109831 | ** initially NULL, then create a new expression list. |
| 109832 | ** |
| 109833 | ** The pList argument must be either NULL or a pointer to an ExprList |
| 109834 | ** obtained from a prior call to sqlite3ExprListAppend(). |
| 109835 | ** |
| 109836 | ** If a memory allocation error occurs, the entire list is freed and |
| 109837 | ** NULL is returned. If non-NULL is returned, then it is guaranteed |
| 109838 | ** that the new entry was successfully appended. |
| 109839 | */ |
| @@ -110071,10 +110654,31 @@ | |
| 110654 | if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1; |
| 110655 | if( sqlite3StrICmp(z, "ROWID")==0 ) return 1; |
| 110656 | if( sqlite3StrICmp(z, "OID")==0 ) return 1; |
| 110657 | return 0; |
| 110658 | } |
| 110659 | |
| 110660 | /* |
| 110661 | ** Return a pointer to a buffer containing a usable rowid alias for table |
| 110662 | ** pTab. An alias is usable if there is not an explicit user-defined column |
| 110663 | ** of the same name. |
| 110664 | */ |
| 110665 | SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){ |
| 110666 | const char *azOpt[] = {"_ROWID_", "ROWID", "OID"}; |
| 110667 | int ii; |
| 110668 | assert( VisibleRowid(pTab) ); |
| 110669 | for(ii=0; ii<ArraySize(azOpt); ii++){ |
| 110670 | int iCol; |
| 110671 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 110672 | if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break; |
| 110673 | } |
| 110674 | if( iCol==pTab->nCol ){ |
| 110675 | return azOpt[ii]; |
| 110676 | } |
| 110677 | } |
| 110678 | return 0; |
| 110679 | } |
| 110680 | |
| 110681 | /* |
| 110682 | ** pX is the RHS of an IN operator. If pX is a SELECT statement |
| 110683 | ** that can be simplified to a direct table access, then return |
| 110684 | ** a pointer to the SELECT statement. If pX is not a SELECT statement, |
| @@ -111608,10 +112212,45 @@ | |
| 112212 | return target; |
| 112213 | } |
| 112214 | return -1; /* Not found */ |
| 112215 | } |
| 112216 | |
| 112217 | |
| 112218 | /* |
| 112219 | ** Expresion pExpr is guaranteed to be a TK_COLUMN or equivalent. This |
| 112220 | ** function checks the Parse.pIdxPartExpr list to see if this column |
| 112221 | ** can be replaced with a constant value. If so, it generates code to |
| 112222 | ** put the constant value in a register (ideally, but not necessarily, |
| 112223 | ** register iTarget) and returns the register number. |
| 112224 | ** |
| 112225 | ** Or, if the TK_COLUMN cannot be replaced by a constant, zero is |
| 112226 | ** returned. |
| 112227 | */ |
| 112228 | static int exprPartidxExprLookup(Parse *pParse, Expr *pExpr, int iTarget){ |
| 112229 | IndexedExpr *p; |
| 112230 | for(p=pParse->pIdxPartExpr; p; p=p->pIENext){ |
| 112231 | if( pExpr->iColumn==p->iIdxCol && pExpr->iTable==p->iDataCur ){ |
| 112232 | Vdbe *v = pParse->pVdbe; |
| 112233 | int addr = 0; |
| 112234 | int ret; |
| 112235 | |
| 112236 | if( p->bMaybeNullRow ){ |
| 112237 | addr = sqlite3VdbeAddOp1(v, OP_IfNullRow, p->iIdxCur); |
| 112238 | } |
| 112239 | ret = sqlite3ExprCodeTarget(pParse, p->pExpr, iTarget); |
| 112240 | sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, ret, 1, 0, |
| 112241 | (const char*)&p->aff, 1); |
| 112242 | if( addr ){ |
| 112243 | sqlite3VdbeJumpHere(v, addr); |
| 112244 | sqlite3VdbeChangeP3(v, addr, ret); |
| 112245 | } |
| 112246 | return ret; |
| 112247 | } |
| 112248 | } |
| 112249 | return 0; |
| 112250 | } |
| 112251 | |
| 112252 | |
| 112253 | /* |
| 112254 | ** Generate code into the current Vdbe to evaluate the given |
| 112255 | ** expression. Attempt to store the results in register "target". |
| 112256 | ** Return the register where results are stored. |
| @@ -111645,10 +112284,11 @@ | |
| 112284 | return r1; |
| 112285 | }else{ |
| 112286 | assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); |
| 112287 | op = pExpr->op; |
| 112288 | } |
| 112289 | assert( op!=TK_ORDER ); |
| 112290 | switch( op ){ |
| 112291 | case TK_AGG_COLUMN: { |
| 112292 | AggInfo *pAggInfo = pExpr->pAggInfo; |
| 112293 | struct AggInfo_col *pCol; |
| 112294 | assert( pAggInfo!=0 ); |
| @@ -111658,11 +112298,11 @@ | |
| 112298 | ** is using an expression index */ |
| 112299 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 112300 | #ifdef SQLITE_VDBE_COVERAGE |
| 112301 | /* Verify that the OP_Null above is exercised by tests |
| 112302 | ** tag-20230325-2 */ |
| 112303 | sqlite3VdbeAddOp3(v, OP_NotNull, target, 1, 20230325); |
| 112304 | VdbeCoverageNeverTaken(v); |
| 112305 | #endif |
| 112306 | break; |
| 112307 | } |
| 112308 | pCol = &pAggInfo->aCol[pExpr->iAgg]; |
| @@ -111765,10 +112405,15 @@ | |
| 112405 | }else{ |
| 112406 | /* Coding an expression that is part of an index where column names |
| 112407 | ** in the index refer to the table to which the index belongs */ |
| 112408 | iTab = pParse->iSelfTab - 1; |
| 112409 | } |
| 112410 | } |
| 112411 | else if( pParse->pIdxPartExpr |
| 112412 | && 0!=(r1 = exprPartidxExprLookup(pParse, pExpr, target)) |
| 112413 | ){ |
| 112414 | return r1; |
| 112415 | } |
| 112416 | assert( ExprUseYTab(pExpr) ); |
| 112417 | assert( pExpr->y.pTab!=0 ); |
| 112418 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 112419 | pExpr->iColumn, iTab, target, |
| @@ -112426,11 +113071,11 @@ | |
| 113071 | ** If the expression uses functions (that might throw an exception) then |
| 113072 | ** guard them with an OP_Once opcode to ensure that the code is only executed |
| 113073 | ** once. If no functions are involved, then factor the code out and put it at |
| 113074 | ** the end of the prepared statement in the initialization section. |
| 113075 | ** |
| 113076 | ** If regDest>0 then the result is always stored in that register and the |
| 113077 | ** result is not reusable. If regDest<0 then this routine is free to |
| 113078 | ** store the value wherever it wants. The register where the expression |
| 113079 | ** is stored is returned. When regDest<0, two identical expressions might |
| 113080 | ** code to the same register, if they do not contain function calls and hence |
| 113081 | ** are factored out into the initialization section at the end of the |
| @@ -112441,10 +113086,11 @@ | |
| 113086 | Expr *pExpr, /* The expression to code when the VDBE initializes */ |
| 113087 | int regDest /* Store the value in this register */ |
| 113088 | ){ |
| 113089 | ExprList *p; |
| 113090 | assert( ConstFactorOk(pParse) ); |
| 113091 | assert( regDest!=0 ); |
| 113092 | p = pParse->pConstExpr; |
| 113093 | if( regDest<0 && p ){ |
| 113094 | struct ExprList_item *pItem; |
| 113095 | int i; |
| 113096 | for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){ |
| @@ -113725,10 +114371,16 @@ | |
| 114371 | x.db = pParse->db; |
| 114372 | x.pRef = pSrcList; |
| 114373 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 114374 | assert( ExprUseXList(pExpr) ); |
| 114375 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 114376 | if( pExpr->pLeft ){ |
| 114377 | assert( pExpr->pLeft->op==TK_ORDER ); |
| 114378 | assert( ExprUseXList(pExpr->pLeft) ); |
| 114379 | assert( pExpr->pLeft->x.pList!=0 ); |
| 114380 | sqlite3WalkExprList(&w, pExpr->pLeft->x.pList); |
| 114381 | } |
| 114382 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 114383 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 114384 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 114385 | } |
| 114386 | #endif |
| @@ -113989,18 +114641,45 @@ | |
| 114641 | /* pExpr is original. Make a new entry in pAggInfo->aFunc[] |
| 114642 | */ |
| 114643 | u8 enc = ENC(pParse->db); |
| 114644 | i = addAggInfoFunc(pParse->db, pAggInfo); |
| 114645 | if( i>=0 ){ |
| 114646 | int nArg; |
| 114647 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 114648 | pItem = &pAggInfo->aFunc[i]; |
| 114649 | pItem->pFExpr = pExpr; |
| 114650 | assert( ExprUseUToken(pExpr) ); |
| 114651 | nArg = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; |
| 114652 | pItem->pFunc = sqlite3FindFunction(pParse->db, |
| 114653 | pExpr->u.zToken, nArg, enc, 0); |
| 114654 | assert( pItem->bOBUnique==0 ); |
| 114655 | if( pExpr->pLeft |
| 114656 | && (pItem->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)==0 |
| 114657 | ){ |
| 114658 | /* The NEEDCOLL test above causes any ORDER BY clause on |
| 114659 | ** aggregate min() or max() to be ignored. */ |
| 114660 | ExprList *pOBList; |
| 114661 | assert( nArg>0 ); |
| 114662 | assert( pExpr->pLeft->op==TK_ORDER ); |
| 114663 | assert( ExprUseXList(pExpr->pLeft) ); |
| 114664 | pItem->iOBTab = pParse->nTab++; |
| 114665 | pOBList = pExpr->pLeft->x.pList; |
| 114666 | assert( pOBList->nExpr>0 ); |
| 114667 | if( pOBList->nExpr==1 |
| 114668 | && nArg==1 |
| 114669 | && sqlite3ExprCompare(0,pOBList->a[0].pExpr, |
| 114670 | pExpr->x.pList->a[0].pExpr,0)==0 |
| 114671 | ){ |
| 114672 | pItem->bOBPayload = 0; |
| 114673 | }else{ |
| 114674 | pItem->bOBPayload = 1; |
| 114675 | } |
| 114676 | pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); |
| 114677 | }else{ |
| 114678 | pItem->iOBTab = -1; |
| 114679 | } |
| 114680 | if( ExprHasProperty(pExpr, EP_Distinct) && !pItem->bOBUnique ){ |
| 114681 | pItem->iDistinct = pParse->nTab++; |
| 114682 | }else{ |
| 114683 | pItem->iDistinct = -1; |
| 114684 | } |
| 114685 | } |
| @@ -114632,18 +115311,23 @@ | |
| 115311 | renameReloadSchema(pParse, iDb, INITFLAG_AlterAdd); |
| 115312 | |
| 115313 | /* Verify that constraints are still satisfied */ |
| 115314 | if( pNew->pCheck!=0 |
| 115315 | || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) |
| 115316 | || (pTab->tabFlags & TF_Strict)!=0 |
| 115317 | ){ |
| 115318 | sqlite3NestedParse(pParse, |
| 115319 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" |
| 115320 | " THEN raise(ABORT,'CHECK constraint failed')" |
| 115321 | " WHEN quick_check GLOB 'non-* value in*'" |
| 115322 | " THEN raise(ABORT,'type mismatch on DEFAULT')" |
| 115323 | " ELSE raise(ABORT,'NOT NULL constraint failed')" |
| 115324 | " END" |
| 115325 | " FROM pragma_quick_check(%Q,%Q)" |
| 115326 | " WHERE quick_check GLOB 'CHECK*'" |
| 115327 | " OR quick_check GLOB 'NULL*'" |
| 115328 | " OR quick_check GLOB 'non-* value in*'", |
| 115329 | zTab, zDb |
| 115330 | ); |
| 115331 | } |
| 115332 | } |
| 115333 | } |
| @@ -119618,23 +120302,18 @@ | |
| 120302 | |
| 120303 | /* Initialize any AUTOINCREMENT data structures required. |
| 120304 | */ |
| 120305 | if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); |
| 120306 | |
| 120307 | /* Code constant expressions that were factored out of inner loops. |
| 120308 | */ |
| 120309 | if( pParse->pConstExpr ){ |
| 120310 | ExprList *pEL = pParse->pConstExpr; |
| 120311 | pParse->okConstFactor = 0; |
| 120312 | for(i=0; i<pEL->nExpr; i++){ |
| 120313 | assert( pEL->a[i].u.iConstExprReg>0 ); |
| 120314 | sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg); |
| 120315 | } |
| 120316 | } |
| 120317 | |
| 120318 | if( pParse->bReturning ){ |
| 120319 | Returning *pRet = pParse->u1.pReturning; |
| @@ -122297,10 +122976,21 @@ | |
| 122976 | #endif |
| 122977 | |
| 122978 | /* Reparse everything to update our internal data structures */ |
| 122979 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 122980 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); |
| 122981 | |
| 122982 | /* Test for cycles in generated columns and illegal expressions |
| 122983 | ** in CHECK constraints and in DEFAULT clauses. */ |
| 122984 | if( p->tabFlags & TF_HasGenerated ){ |
| 122985 | sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, |
| 122986 | sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", |
| 122987 | db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); |
| 122988 | } |
| 122989 | sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, |
| 122990 | sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", |
| 122991 | db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); |
| 122992 | } |
| 122993 | |
| 122994 | /* Add the table to the in-memory representation of the database. |
| 122995 | */ |
| 122996 | if( db->init.busy ){ |
| @@ -127899,11 +128589,12 @@ | |
| 128589 | unsigned char c = *pBlob; |
| 128590 | *(z++) = hexdigits[(c>>4)&0xf]; |
| 128591 | *(z++) = hexdigits[c&0xf]; |
| 128592 | } |
| 128593 | *z = 0; |
| 128594 | sqlite3_result_text64(context, zHex, (u64)(z-zHex), |
| 128595 | sqlite3_free, SQLITE_UTF8); |
| 128596 | } |
| 128597 | } |
| 128598 | |
| 128599 | /* |
| 128600 | ** Buffer zStr contains nStr bytes of utf-8 encoded text. Return 1 if zStr |
| @@ -128192,10 +128883,85 @@ | |
| 128883 | sqlite3_free(azChar); |
| 128884 | } |
| 128885 | } |
| 128886 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); |
| 128887 | } |
| 128888 | |
| 128889 | /* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) |
| 128890 | ** functions. |
| 128891 | ** |
| 128892 | ** Return a string value that is the concatenation of all non-null |
| 128893 | ** entries in argv[]. Use zSep as the separator. |
| 128894 | */ |
| 128895 | static void concatFuncCore( |
| 128896 | sqlite3_context *context, |
| 128897 | int argc, |
| 128898 | sqlite3_value **argv, |
| 128899 | int nSep, |
| 128900 | const char *zSep |
| 128901 | ){ |
| 128902 | i64 j, k, n = 0; |
| 128903 | int i; |
| 128904 | char *z; |
| 128905 | for(i=0; i<argc; i++){ |
| 128906 | n += sqlite3_value_bytes(argv[i]); |
| 128907 | } |
| 128908 | n += (argc-1)*nSep; |
| 128909 | z = sqlite3_malloc64(n+1); |
| 128910 | if( z==0 ){ |
| 128911 | sqlite3_result_error_nomem(context); |
| 128912 | return; |
| 128913 | } |
| 128914 | j = 0; |
| 128915 | for(i=0; i<argc; i++){ |
| 128916 | k = sqlite3_value_bytes(argv[i]); |
| 128917 | if( k>0 ){ |
| 128918 | const char *v = (const char*)sqlite3_value_text(argv[i]); |
| 128919 | if( v!=0 ){ |
| 128920 | if( j>0 && nSep>0 ){ |
| 128921 | memcpy(&z[j], zSep, nSep); |
| 128922 | j += nSep; |
| 128923 | } |
| 128924 | memcpy(&z[j], v, k); |
| 128925 | j += k; |
| 128926 | } |
| 128927 | } |
| 128928 | } |
| 128929 | z[j] = 0; |
| 128930 | assert( j<=n ); |
| 128931 | sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8); |
| 128932 | } |
| 128933 | |
| 128934 | /* |
| 128935 | ** The CONCAT(...) function. Generate a string result that is the |
| 128936 | ** concatentation of all non-null arguments. |
| 128937 | */ |
| 128938 | static void concatFunc( |
| 128939 | sqlite3_context *context, |
| 128940 | int argc, |
| 128941 | sqlite3_value **argv |
| 128942 | ){ |
| 128943 | concatFuncCore(context, argc, argv, 0, ""); |
| 128944 | } |
| 128945 | |
| 128946 | /* |
| 128947 | ** The CONCAT_WS(separator, ...) function. |
| 128948 | ** |
| 128949 | ** Generate a string that is the concatenation of 2nd through the Nth |
| 128950 | ** argument. Use the first argument (which must be non-NULL) as the |
| 128951 | ** separator. |
| 128952 | */ |
| 128953 | static void concatwsFunc( |
| 128954 | sqlite3_context *context, |
| 128955 | int argc, |
| 128956 | sqlite3_value **argv |
| 128957 | ){ |
| 128958 | int nSep = sqlite3_value_bytes(argv[0]); |
| 128959 | const char *zSep = (const char*)sqlite3_value_text(argv[0]); |
| 128960 | if( zSep==0 ) return; |
| 128961 | concatFuncCore(context, argc-1, argv+1, nSep, zSep); |
| 128962 | } |
| 128963 | |
| 128964 | |
| 128965 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 128966 | /* |
| 128967 | ** The "unknown" function is automatically substituted in place of |
| @@ -128614,10 +129380,11 @@ | |
| 129380 | minMaxValueFinalize(context, 0); |
| 129381 | } |
| 129382 | |
| 129383 | /* |
| 129384 | ** group_concat(EXPR, ?SEPARATOR?) |
| 129385 | ** string_agg(EXPR, SEPARATOR) |
| 129386 | ** |
| 129387 | ** The SEPARATOR goes before the EXPR string. This is tragic. The |
| 129388 | ** groupConcatInverse() implementation would have been easier if the |
| 129389 | ** SEPARATOR were appended after EXPR. And the order is undocumented, |
| 129390 | ** so we could change it, in theory. But the old behavior has been |
| @@ -129204,10 +129971,15 @@ | |
| 129971 | FUNCTION(upper, 1, 0, 0, upperFunc ), |
| 129972 | FUNCTION(lower, 1, 0, 0, lowerFunc ), |
| 129973 | FUNCTION(hex, 1, 0, 0, hexFunc ), |
| 129974 | FUNCTION(unhex, 1, 0, 0, unhexFunc ), |
| 129975 | FUNCTION(unhex, 2, 0, 0, unhexFunc ), |
| 129976 | FUNCTION(concat, -1, 0, 0, concatFunc ), |
| 129977 | FUNCTION(concat, 0, 0, 0, 0 ), |
| 129978 | FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), |
| 129979 | FUNCTION(concat_ws, 0, 0, 0, 0 ), |
| 129980 | FUNCTION(concat_ws, 1, 0, 0, 0 ), |
| 129981 | INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), |
| 129982 | VFUNCTION(random, 0, 0, 0, randomFunc ), |
| 129983 | VFUNCTION(randomblob, 1, 0, 0, randomBlob ), |
| 129984 | FUNCTION(nullif, 2, 0, 1, nullifFunc ), |
| 129985 | DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ), |
| @@ -129232,10 +130004,12 @@ | |
| 130004 | WAGGREGATE(count, 1,0,0, countStep, |
| 130005 | countFinalize, countFinalize, countInverse, SQLITE_FUNC_ANYORDER ), |
| 130006 | WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep, |
| 130007 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 130008 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, |
| 130009 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 130010 | WAGGREGATE(string_agg, 2, 0, 0, groupConcatStep, |
| 130011 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 130012 | |
| 130013 | LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 130014 | #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 130015 | LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| @@ -130175,10 +130949,11 @@ | |
| 130949 | if( pTop->pTriggerPrg ){ |
| 130950 | Trigger *p = pTop->pTriggerPrg->pTrigger; |
| 130951 | if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) |
| 130952 | || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) |
| 130953 | ){ |
| 130954 | assert( (pTop->db->flags & SQLITE_FkNoAction)==0 ); |
| 130955 | return 1; |
| 130956 | } |
| 130957 | } |
| 130958 | return 0; |
| 130959 | } |
| @@ -130369,10 +131144,12 @@ | |
| 131144 | if( regNew!=0 ){ |
| 131145 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1); |
| 131146 | } |
| 131147 | if( regOld!=0 ){ |
| 131148 | int eAction = pFKey->aAction[aChange!=0]; |
| 131149 | if( (db->flags & SQLITE_FkNoAction) ) eAction = OE_None; |
| 131150 | |
| 131151 | fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); |
| 131152 | /* If this is a deferred FK constraint, or a CASCADE or SET NULL |
| 131153 | ** action applies, then any foreign key violations caused by |
| 131154 | ** removing the parent key will be rectified by the action trigger. |
| 131155 | ** So do not set the "may-abort" flag in this case. |
| @@ -130484,11 +131261,15 @@ | |
| 131261 | } |
| 131262 | |
| 131263 | /* Check if any parent key columns are being modified. */ |
| 131264 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 131265 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 131266 | if( (pParse->db->flags & SQLITE_FkNoAction)==0 |
| 131267 | && p->aAction[1]!=OE_None |
| 131268 | ){ |
| 131269 | return 2; |
| 131270 | } |
| 131271 | bHaveFK = 1; |
| 131272 | } |
| 131273 | } |
| 131274 | } |
| 131275 | } |
| @@ -130534,10 +131315,11 @@ | |
| 131315 | int action; /* One of OE_None, OE_Cascade etc. */ |
| 131316 | Trigger *pTrigger; /* Trigger definition to return */ |
| 131317 | int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ |
| 131318 | |
| 131319 | action = pFKey->aAction[iAction]; |
| 131320 | if( (db->flags & SQLITE_FkNoAction) ) action = OE_None; |
| 131321 | if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ |
| 131322 | return 0; |
| 131323 | } |
| 131324 | pTrigger = pFKey->apTrigger[iAction]; |
| 131325 | |
| @@ -135553,10 +136335,13 @@ | |
| 136335 | /* |
| 136336 | ** Enable or disable extension loading. Extension loading is disabled by |
| 136337 | ** default so as not to open security holes in older applications. |
| 136338 | */ |
| 136339 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
| 136340 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 136341 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 136342 | #endif |
| 136343 | sqlite3_mutex_enter(db->mutex); |
| 136344 | if( onoff ){ |
| 136345 | db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; |
| 136346 | }else{ |
| 136347 | db->flags &= ~(u64)(SQLITE_LoadExtension|SQLITE_LoadExtFunc); |
| @@ -135602,10 +136387,13 @@ | |
| 136387 | */ |
| 136388 | SQLITE_API int sqlite3_auto_extension( |
| 136389 | void (*xInit)(void) |
| 136390 | ){ |
| 136391 | int rc = SQLITE_OK; |
| 136392 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 136393 | if( xInit==0 ) return SQLITE_MISUSE_BKPT; |
| 136394 | #endif |
| 136395 | #ifndef SQLITE_OMIT_AUTOINIT |
| 136396 | rc = sqlite3_initialize(); |
| 136397 | if( rc ){ |
| 136398 | return rc; |
| 136399 | }else |
| @@ -135654,10 +136442,13 @@ | |
| 136442 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MAIN); |
| 136443 | #endif |
| 136444 | int i; |
| 136445 | int n = 0; |
| 136446 | wsdAutoextInit; |
| 136447 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 136448 | if( xInit==0 ) return 0; |
| 136449 | #endif |
| 136450 | sqlite3_mutex_enter(mutex); |
| 136451 | for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ |
| 136452 | if( wsdAutoext.aExt[i]==xInit ){ |
| 136453 | wsdAutoext.nExt--; |
| 136454 | wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt]; |
| @@ -137523,11 +138314,15 @@ | |
| 138314 | mask &= ~(SQLITE_WriteSchema); |
| 138315 | } |
| 138316 | #endif |
| 138317 | |
| 138318 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 138319 | if( (mask & SQLITE_WriteSchema)==0 |
| 138320 | || (db->flags & SQLITE_Defensive)==0 |
| 138321 | ){ |
| 138322 | db->flags |= mask; |
| 138323 | } |
| 138324 | }else{ |
| 138325 | db->flags &= ~mask; |
| 138326 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; |
| 138327 | if( (mask & SQLITE_WriteSchema)!=0 |
| 138328 | && sqlite3_stricmp(zRight, "reset")==0 |
| @@ -138156,12 +138951,33 @@ | |
| 138951 | int r1 = -1; |
| 138952 | int bStrict; /* True for a STRICT table */ |
| 138953 | int r2; /* Previous key for WITHOUT ROWID tables */ |
| 138954 | int mxCol; /* Maximum non-virtual column number */ |
| 138955 | |
| 138956 | if( pObjTab && pObjTab!=pTab ) continue; |
| 138957 | if( !IsOrdinaryTable(pTab) ){ |
| 138958 | sqlite3_vtab *pVTab; |
| 138959 | int a1; |
| 138960 | if( !IsVirtual(pTab) ) continue; |
| 138961 | if( pTab->nCol<=0 ){ |
| 138962 | const char *zMod = pTab->u.vtab.azArg[0]; |
| 138963 | if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue; |
| 138964 | } |
| 138965 | sqlite3ViewGetColumnNames(pParse, pTab); |
| 138966 | if( pTab->u.vtab.p==0 ) continue; |
| 138967 | pVTab = pTab->u.vtab.p->pVtab; |
| 138968 | if( NEVER(pVTab==0) ) continue; |
| 138969 | if( NEVER(pVTab->pModule==0) ) continue; |
| 138970 | if( pVTab->pModule->iVersion<4 ) continue; |
| 138971 | if( pVTab->pModule->xIntegrity==0 ) continue; |
| 138972 | sqlite3VdbeAddOp2(v, OP_VCheck, 0, 3); |
| 138973 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); |
| 138974 | a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); |
| 138975 | integrityCheckResultRow(v); |
| 138976 | sqlite3VdbeJumpHere(v, a1); |
| 138977 | continue; |
| 138978 | } |
| 138979 | if( isQuick || HasRowid(pTab) ){ |
| 138980 | pPk = 0; |
| 138981 | r2 = 0; |
| 138982 | }else{ |
| 138983 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| @@ -139283,11 +140099,12 @@ | |
| 140099 | 0, /* xFindFunction - function overloading */ |
| 140100 | 0, /* xRename - rename the table */ |
| 140101 | 0, /* xSavepoint */ |
| 140102 | 0, /* xRelease */ |
| 140103 | 0, /* xRollbackTo */ |
| 140104 | 0, /* xShadowName */ |
| 140105 | 0 /* xIntegrity */ |
| 140106 | }; |
| 140107 | |
| 140108 | /* |
| 140109 | ** Check to see if zTabName is really the name of a pragma. If it is, |
| 140110 | ** then register an eponymous virtual table for that pragma and return |
| @@ -139907,12 +140724,10 @@ | |
| 140724 | assert( db->lookaside.bDisable >= pParse->disableLookaside ); |
| 140725 | db->lookaside.bDisable -= pParse->disableLookaside; |
| 140726 | db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; |
| 140727 | assert( pParse->db->pParse==pParse ); |
| 140728 | db->pParse = pParse->pOuterParse; |
| 140729 | } |
| 140730 | |
| 140731 | /* |
| 140732 | ** Add a new cleanup operation to a Parser. The cleanup should happen when |
| 140733 | ** the parser object is destroyed. But, beware: the cleanup might happen |
| @@ -140846,10 +141661,11 @@ | |
| 141661 | if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){ |
| 141662 | ExprClearProperty(p, EP_CanBeNull); |
| 141663 | } |
| 141664 | if( p->op==TK_FUNCTION ){ |
| 141665 | assert( ExprUseXList(p) ); |
| 141666 | assert( p->pLeft==0 ); |
| 141667 | if( p->x.pList ){ |
| 141668 | int i; |
| 141669 | for(i=0; i<p->x.pList->nExpr; i++){ |
| 141670 | unsetJoinExpr(p->x.pList->a[i].pExpr, iTable, nullable); |
| 141671 | } |
| @@ -146506,10 +147322,11 @@ | |
| 147322 | ** expanded. */ |
| 147323 | int tableSeen = 0; /* Set to 1 when TABLE matches */ |
| 147324 | char *zTName = 0; /* text of name of TABLE */ |
| 147325 | int iErrOfst; |
| 147326 | if( pE->op==TK_DOT ){ |
| 147327 | assert( (selFlags & SF_NestedFrom)==0 ); |
| 147328 | assert( pE->pLeft!=0 ); |
| 147329 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 147330 | zTName = pE->pLeft->u.zToken; |
| 147331 | assert( ExprUseWOfst(pE->pLeft) ); |
| 147332 | iErrOfst = pE->pRight->w.iOfst; |
| @@ -146516,10 +147333,11 @@ | |
| 147333 | }else{ |
| 147334 | assert( ExprUseWOfst(pE) ); |
| 147335 | iErrOfst = pE->w.iOfst; |
| 147336 | } |
| 147337 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 147338 | int nAdd; /* Number of cols including rowid */ |
| 147339 | Table *pTab = pFrom->pTab; /* Table for this data source */ |
| 147340 | ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ |
| 147341 | char *zTabName; /* AS name for this data source */ |
| 147342 | const char *zSchemaName = 0; /* Schema name for this data source */ |
| 147343 | int iDb; /* Schema index for this data src */ |
| @@ -146533,10 +147351,11 @@ | |
| 147351 | if( pFrom->fg.isNestedFrom ){ |
| 147352 | assert( pFrom->pSelect!=0 ); |
| 147353 | pNestedFrom = pFrom->pSelect->pEList; |
| 147354 | assert( pNestedFrom!=0 ); |
| 147355 | assert( pNestedFrom->nExpr==pTab->nCol ); |
| 147356 | assert( VisibleRowid(pTab)==0 ); |
| 147357 | }else{ |
| 147358 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 147359 | continue; |
| 147360 | } |
| 147361 | pNestedFrom = 0; |
| @@ -146563,37 +147382,52 @@ | |
| 147382 | } |
| 147383 | } |
| 147384 | }else{ |
| 147385 | pUsing = 0; |
| 147386 | } |
| 147387 | |
| 147388 | nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom)); |
| 147389 | for(j=0; j<nAdd; j++){ |
| 147390 | const char *zName; |
| 147391 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 147392 | |
| 147393 | if( j==pTab->nCol ){ |
| 147394 | zName = sqlite3RowidAlias(pTab); |
| 147395 | if( zName==0 ) continue; |
| 147396 | }else{ |
| 147397 | zName = pTab->aCol[j].zCnName; |
| 147398 | |
| 147399 | /* If pTab is actually an SF_NestedFrom sub-select, do not |
| 147400 | ** expand any ENAME_ROWID columns. */ |
| 147401 | if( pNestedFrom && pNestedFrom->a[j].fg.eEName==ENAME_ROWID ){ |
| 147402 | continue; |
| 147403 | } |
| 147404 | |
| 147405 | if( zTName |
| 147406 | && pNestedFrom |
| 147407 | && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0, 0)==0 |
| 147408 | ){ |
| 147409 | continue; |
| 147410 | } |
| 147411 | |
| 147412 | /* If a column is marked as 'hidden', omit it from the expanded |
| 147413 | ** result-set list unless the SELECT has the SF_IncludeHidden |
| 147414 | ** bit set. |
| 147415 | */ |
| 147416 | if( (p->selFlags & SF_IncludeHidden)==0 |
| 147417 | && IsHiddenColumn(&pTab->aCol[j]) |
| 147418 | ){ |
| 147419 | continue; |
| 147420 | } |
| 147421 | if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 |
| 147422 | && zTName==0 |
| 147423 | && (selFlags & (SF_NestedFrom))==0 |
| 147424 | ){ |
| 147425 | continue; |
| 147426 | } |
| 147427 | } |
| 147428 | assert( zName ); |
| 147429 | tableSeen = 1; |
| 147430 | |
| 147431 | if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ |
| 147432 | if( pFrom->fg.isUsing |
| 147433 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0 |
| @@ -146639,15 +147473,15 @@ | |
| 147473 | }else{ |
| 147474 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 147475 | zSchemaName, zTabName, zName); |
| 147476 | testcase( pX->zEName==0 ); |
| 147477 | } |
| 147478 | pX->fg.eEName = (j==pTab->nCol ? ENAME_ROWID : ENAME_TAB); |
| 147479 | if( (pFrom->fg.isUsing |
| 147480 | && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) |
| 147481 | || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) |
| 147482 | || (j<pTab->nCol && (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)) |
| 147483 | ){ |
| 147484 | pX->fg.bNoExpand = 1; |
| 147485 | } |
| 147486 | }else if( longNames ){ |
| 147487 | pX->zEName = sqlite3MPrintf(db, "%s.%s", zTabName, zName); |
| @@ -146864,12 +147698,18 @@ | |
| 147698 | assert( pAggInfo!=0 ); |
| 147699 | assert( pAggInfo->iFirstReg==0 ); |
| 147700 | pNC->ncFlags |= NC_InAggFunc; |
| 147701 | for(i=0; i<pAggInfo->nFunc; i++){ |
| 147702 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; |
| 147703 | assert( pExpr->op==TK_FUNCTION || pExpr->op==TK_AGG_FUNCTION ); |
| 147704 | assert( ExprUseXList(pExpr) ); |
| 147705 | sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); |
| 147706 | if( pExpr->pLeft ){ |
| 147707 | assert( pExpr->pLeft->op==TK_ORDER ); |
| 147708 | assert( ExprUseXList(pExpr->pLeft) ); |
| 147709 | sqlite3ExprAnalyzeAggList(pNC, pExpr->pLeft->x.pList); |
| 147710 | } |
| 147711 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 147712 | assert( !IsWindowFunc(pExpr) ); |
| 147713 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 147714 | sqlite3ExprAnalyzeAggregates(pNC, pExpr->y.pWin->pFilter); |
| 147715 | } |
| @@ -147020,10 +147860,36 @@ | |
| 147860 | pFunc->iDistinct, 0, 0, (char*)pKeyInfo, P4_KEYINFO); |
| 147861 | ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(DISTINCT)", |
| 147862 | pFunc->pFunc->zName)); |
| 147863 | } |
| 147864 | } |
| 147865 | if( pFunc->iOBTab>=0 ){ |
| 147866 | ExprList *pOBList; |
| 147867 | KeyInfo *pKeyInfo; |
| 147868 | int nExtra = 0; |
| 147869 | assert( pFunc->pFExpr->pLeft!=0 ); |
| 147870 | assert( pFunc->pFExpr->pLeft->op==TK_ORDER ); |
| 147871 | assert( ExprUseXList(pFunc->pFExpr->pLeft) ); |
| 147872 | pOBList = pFunc->pFExpr->pLeft->x.pList; |
| 147873 | if( !pFunc->bOBUnique ){ |
| 147874 | nExtra++; /* One extra column for the OP_Sequence */ |
| 147875 | } |
| 147876 | if( pFunc->bOBPayload ){ |
| 147877 | /* extra columns for the function arguments */ |
| 147878 | assert( ExprUseXList(pFunc->pFExpr) ); |
| 147879 | nExtra += pFunc->pFExpr->x.pList->nExpr; |
| 147880 | } |
| 147881 | pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOBList, 0, nExtra); |
| 147882 | if( !pFunc->bOBUnique && pParse->nErr==0 ){ |
| 147883 | pKeyInfo->nKeyField++; |
| 147884 | } |
| 147885 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, |
| 147886 | pFunc->iOBTab, pOBList->nExpr+nExtra, 0, |
| 147887 | (char*)pKeyInfo, P4_KEYINFO); |
| 147888 | ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(ORDER BY)", |
| 147889 | pFunc->pFunc->zName)); |
| 147890 | } |
| 147891 | } |
| 147892 | } |
| 147893 | |
| 147894 | /* |
| 147895 | ** Invoke the OP_AggFinalize opcode for every aggregate function |
| @@ -147035,25 +147901,65 @@ | |
| 147901 | struct AggInfo_func *pF; |
| 147902 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 147903 | ExprList *pList; |
| 147904 | assert( ExprUseXList(pF->pFExpr) ); |
| 147905 | pList = pF->pFExpr->x.pList; |
| 147906 | if( pF->iOBTab>=0 ){ |
| 147907 | /* For an ORDER BY aggregate, calls to OP_AggStep where deferred and |
| 147908 | ** all content was stored in emphermal table pF->iOBTab. Extract that |
| 147909 | ** content now (in ORDER BY order) and make all calls to OP_AggStep |
| 147910 | ** before doing the OP_AggFinal call. */ |
| 147911 | int iTop; /* Start of loop for extracting columns */ |
| 147912 | int nArg; /* Number of columns to extract */ |
| 147913 | int nKey; /* Key columns to be skipped */ |
| 147914 | int regAgg; /* Extract into this array */ |
| 147915 | int j; /* Loop counter */ |
| 147916 | |
| 147917 | nArg = pList->nExpr; |
| 147918 | regAgg = sqlite3GetTempRange(pParse, nArg); |
| 147919 | |
| 147920 | if( pF->bOBPayload==0 ){ |
| 147921 | nKey = 0; |
| 147922 | }else{ |
| 147923 | assert( pF->pFExpr->pLeft!=0 ); |
| 147924 | assert( ExprUseXList(pF->pFExpr->pLeft) ); |
| 147925 | assert( pF->pFExpr->pLeft->x.pList!=0 ); |
| 147926 | nKey = pF->pFExpr->pLeft->x.pList->nExpr; |
| 147927 | if( !pF->bOBUnique ) nKey++; |
| 147928 | } |
| 147929 | iTop = sqlite3VdbeAddOp1(v, OP_Rewind, pF->iOBTab); VdbeCoverage(v); |
| 147930 | for(j=nArg-1; j>=0; j--){ |
| 147931 | sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, nKey+j, regAgg+j); |
| 147932 | } |
| 147933 | sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); |
| 147934 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 147935 | sqlite3VdbeChangeP5(v, (u8)nArg); |
| 147936 | sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v); |
| 147937 | sqlite3VdbeJumpHere(v, iTop); |
| 147938 | sqlite3ReleaseTempRange(pParse, regAgg, nArg); |
| 147939 | } |
| 147940 | sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), |
| 147941 | pList ? pList->nExpr : 0); |
| 147942 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 147943 | } |
| 147944 | } |
| 147945 | |
| 147946 | /* |
| 147947 | ** Generate code that will update the accumulator memory cells for an |
| 147948 | ** aggregate based on the current cursor position. |
| 147949 | ** |
| 147950 | ** If regAcc is non-zero and there are no min() or max() aggregates |
| 147951 | ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator |
| 147952 | ** registers if register regAcc contains 0. The caller will take care |
| 147953 | ** of setting and clearing regAcc. |
| 147954 | ** |
| 147955 | ** For an ORDER BY aggregate, the actually accumulator memory cell update |
| 147956 | ** is deferred until after all input rows have been received, so that they |
| 147957 | ** can be run in the requested order. In that case, instead of invoking |
| 147958 | ** OP_AggStep to update accumulator, just add the arguments that would |
| 147959 | ** have been passed into OP_AggStep into the sorting ephemeral table |
| 147960 | ** (along with the appropriate sort key). |
| 147961 | */ |
| 147962 | static void updateAccumulator( |
| 147963 | Parse *pParse, |
| 147964 | int regAcc, |
| 147965 | AggInfo *pAggInfo, |
| @@ -147071,10 +147977,11 @@ | |
| 147977 | pAggInfo->directMode = 1; |
| 147978 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 147979 | int nArg; |
| 147980 | int addrNext = 0; |
| 147981 | int regAgg; |
| 147982 | int regAggSz = 0; |
| 147983 | ExprList *pList; |
| 147984 | assert( ExprUseXList(pF->pFExpr) ); |
| 147985 | assert( !IsWindowFunc(pF->pFExpr) ); |
| 147986 | pList = pF->pFExpr->x.pList; |
| 147987 | if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){ |
| @@ -147097,11 +148004,43 @@ | |
| 148004 | sqlite3VdbeAddOp2(v, OP_Copy, regAcc, regHit); |
| 148005 | } |
| 148006 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 148007 | sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); |
| 148008 | } |
| 148009 | if( pF->iOBTab>=0 ){ |
| 148010 | /* Instead of invoking AggStep, we must push the arguments that would |
| 148011 | ** have been passed to AggStep onto the sorting table. */ |
| 148012 | int jj; /* Registered used so far in building the record */ |
| 148013 | ExprList *pOBList; /* The ORDER BY clause */ |
| 148014 | assert( pList!=0 ); |
| 148015 | nArg = pList->nExpr; |
| 148016 | assert( nArg>0 ); |
| 148017 | assert( pF->pFExpr->pLeft!=0 ); |
| 148018 | assert( pF->pFExpr->pLeft->op==TK_ORDER ); |
| 148019 | assert( ExprUseXList(pF->pFExpr->pLeft) ); |
| 148020 | pOBList = pF->pFExpr->pLeft->x.pList; |
| 148021 | assert( pOBList!=0 ); |
| 148022 | assert( pOBList->nExpr>0 ); |
| 148023 | regAggSz = pOBList->nExpr; |
| 148024 | if( !pF->bOBUnique ){ |
| 148025 | regAggSz++; /* One register for OP_Sequence */ |
| 148026 | } |
| 148027 | if( pF->bOBPayload ){ |
| 148028 | regAggSz += nArg; |
| 148029 | } |
| 148030 | regAggSz++; /* One extra register to hold result of MakeRecord */ |
| 148031 | regAgg = sqlite3GetTempRange(pParse, regAggSz); |
| 148032 | sqlite3ExprCodeExprList(pParse, pOBList, regAgg, 0, SQLITE_ECEL_DUP); |
| 148033 | jj = pOBList->nExpr; |
| 148034 | if( !pF->bOBUnique ){ |
| 148035 | sqlite3VdbeAddOp2(v, OP_Sequence, pF->iOBTab, regAgg+jj); |
| 148036 | jj++; |
| 148037 | } |
| 148038 | if( pF->bOBPayload ){ |
| 148039 | sqlite3ExprCodeExprList(pParse, pList, regAgg+jj, 0, SQLITE_ECEL_DUP); |
| 148040 | } |
| 148041 | }else if( pList ){ |
| 148042 | nArg = pList->nExpr; |
| 148043 | regAgg = sqlite3GetTempRange(pParse, nArg); |
| 148044 | sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); |
| 148045 | }else{ |
| 148046 | nArg = 0; |
| @@ -147112,28 +148051,39 @@ | |
| 148051 | addrNext = sqlite3VdbeMakeLabel(pParse); |
| 148052 | } |
| 148053 | pF->iDistinct = codeDistinct(pParse, eDistinctType, |
| 148054 | pF->iDistinct, addrNext, pList, regAgg); |
| 148055 | } |
| 148056 | if( pF->iOBTab>=0 ){ |
| 148057 | /* Insert a new record into the ORDER BY table */ |
| 148058 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regAgg, regAggSz-1, |
| 148059 | regAgg+regAggSz-1); |
| 148060 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pF->iOBTab, regAgg+regAggSz-1, |
| 148061 | regAgg, regAggSz-1); |
| 148062 | sqlite3ReleaseTempRange(pParse, regAgg, regAggSz); |
| 148063 | }else{ |
| 148064 | /* Invoke the AggStep function */ |
| 148065 | if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 148066 | CollSeq *pColl = 0; |
| 148067 | struct ExprList_item *pItem; |
| 148068 | int j; |
| 148069 | assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ |
| 148070 | for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ |
| 148071 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); |
| 148072 | } |
| 148073 | if( !pColl ){ |
| 148074 | pColl = pParse->db->pDfltColl; |
| 148075 | } |
| 148076 | if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; |
| 148077 | sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, |
| 148078 | (char *)pColl, P4_COLLSEQ); |
| 148079 | } |
| 148080 | sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); |
| 148081 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 148082 | sqlite3VdbeChangeP5(v, (u8)nArg); |
| 148083 | sqlite3ReleaseTempRange(pParse, regAgg, nArg); |
| 148084 | } |
| 148085 | if( addrNext ){ |
| 148086 | sqlite3VdbeResolveLabel(v, addrNext); |
| 148087 | } |
| 148088 | } |
| 148089 | if( regHit==0 && pAggInfo->nAccumulator ){ |
| @@ -149189,10 +150139,14 @@ | |
| 150139 | goto trigger_orphan_error; |
| 150140 | } |
| 150141 | if( IsVirtual(pTab) ){ |
| 150142 | sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); |
| 150143 | goto trigger_orphan_error; |
| 150144 | } |
| 150145 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ |
| 150146 | sqlite3ErrorMsg(pParse, "cannot create triggers on shadow tables"); |
| 150147 | goto trigger_orphan_error; |
| 150148 | } |
| 150149 | |
| 150150 | /* Check that the trigger name is not reserved and that no trigger of the |
| 150151 | ** specified name exists */ |
| 150152 | zName = sqlite3NameFromToken(db, pName); |
| @@ -153413,11 +154367,11 @@ | |
| 154367 | } |
| 154368 | #endif |
| 154369 | sqlite3_mutex_enter(db->mutex); |
| 154370 | pCtx = db->pVtabCtx; |
| 154371 | if( !pCtx || pCtx->bDeclared ){ |
| 154372 | sqlite3Error(db, SQLITE_MISUSE_BKPT); |
| 154373 | sqlite3_mutex_leave(db->mutex); |
| 154374 | return SQLITE_MISUSE_BKPT; |
| 154375 | } |
| 154376 | pTab = pCtx->pTab; |
| 154377 | assert( IsVirtual(pTab) ); |
| @@ -154604,11 +155558,11 @@ | |
| 155558 | #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ |
| 155559 | #define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */ |
| 155560 | #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ |
| 155561 | #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ |
| 155562 | #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ |
| 155563 | /* 0x02000000 -- available for reuse */ |
| 155564 | #define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ |
| 155565 | |
| 155566 | #endif /* !defined(SQLITE_WHEREINT_H) */ |
| 155567 | |
| 155568 | /************** End of whereInt.h ********************************************/ |
| @@ -160399,17 +161353,21 @@ | |
| 161353 | Parse *pParse = pWInfo->pParse; /* Parsing context */ |
| 161354 | Vdbe *v = pParse->pVdbe; /* VDBE under construction */ |
| 161355 | WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ |
| 161356 | int iCur; /* Cursor for table getting the filter */ |
| 161357 | IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ |
| 161358 | IndexedExpr *saved_pIdxPartExpr; /* saved copy of Parse.pIdxPartExpr */ |
| 161359 | |
| 161360 | saved_pIdxEpr = pParse->pIdxEpr; |
| 161361 | saved_pIdxPartExpr = pParse->pIdxPartExpr; |
| 161362 | pParse->pIdxEpr = 0; |
| 161363 | pParse->pIdxPartExpr = 0; |
| 161364 | |
| 161365 | assert( pLoop!=0 ); |
| 161366 | assert( v!=0 ); |
| 161367 | assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); |
| 161368 | assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ); |
| 161369 | |
| 161370 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 161371 | do{ |
| 161372 | const SrcList *pTabList; |
| 161373 | const SrcItem *pItem; |
| @@ -160495,10 +161453,11 @@ | |
| 161453 | } |
| 161454 | } |
| 161455 | }while( iLevel < pWInfo->nLevel ); |
| 161456 | sqlite3VdbeJumpHere(v, addrOnce); |
| 161457 | pParse->pIdxEpr = saved_pIdxEpr; |
| 161458 | pParse->pIdxPartExpr = saved_pIdxPartExpr; |
| 161459 | } |
| 161460 | |
| 161461 | |
| 161462 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 161463 | /* |
| @@ -162753,10 +163712,104 @@ | |
| 163712 | }else{ |
| 163713 | rc = WHERE_IDX_ONLY; |
| 163714 | } |
| 163715 | return rc; |
| 163716 | } |
| 163717 | |
| 163718 | /* |
| 163719 | ** This is an sqlite3ParserAddCleanup() callback that is invoked to |
| 163720 | ** free the Parse->pIdxEpr list when the Parse object is destroyed. |
| 163721 | */ |
| 163722 | static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){ |
| 163723 | IndexedExpr **pp = (IndexedExpr**)pObject; |
| 163724 | while( *pp!=0 ){ |
| 163725 | IndexedExpr *p = *pp; |
| 163726 | *pp = p->pIENext; |
| 163727 | sqlite3ExprDelete(db, p->pExpr); |
| 163728 | sqlite3DbFreeNN(db, p); |
| 163729 | } |
| 163730 | } |
| 163731 | |
| 163732 | /* |
| 163733 | ** This function is called for a partial index - one with a WHERE clause - in |
| 163734 | ** two scenarios. In both cases, it determines whether or not the WHERE |
| 163735 | ** clause on the index implies that a column of the table may be safely |
| 163736 | ** replaced by a constant expression. For example, in the following |
| 163737 | ** SELECT: |
| 163738 | ** |
| 163739 | ** CREATE INDEX i1 ON t1(b, c) WHERE a=<expr>; |
| 163740 | ** SELECT a, b, c FROM t1 WHERE a=<expr> AND b=?; |
| 163741 | ** |
| 163742 | ** The "a" in the select-list may be replaced by <expr>, iff: |
| 163743 | ** |
| 163744 | ** (a) <expr> is a constant expression, and |
| 163745 | ** (b) The (a=<expr>) comparison uses the BINARY collation sequence, and |
| 163746 | ** (c) Column "a" has an affinity other than NONE or BLOB. |
| 163747 | ** |
| 163748 | ** If argument pItem is NULL, then pMask must not be NULL. In this case this |
| 163749 | ** function is being called as part of determining whether or not pIdx |
| 163750 | ** is a covering index. This function clears any bits in (*pMask) |
| 163751 | ** corresponding to columns that may be replaced by constants as described |
| 163752 | ** above. |
| 163753 | ** |
| 163754 | ** Otherwise, if pItem is not NULL, then this function is being called |
| 163755 | ** as part of coding a loop that uses index pIdx. In this case, add entries |
| 163756 | ** to the Parse.pIdxPartExpr list for each column that can be replaced |
| 163757 | ** by a constant. |
| 163758 | */ |
| 163759 | static void wherePartIdxExpr( |
| 163760 | Parse *pParse, /* Parse context */ |
| 163761 | Index *pIdx, /* Partial index being processed */ |
| 163762 | Expr *pPart, /* WHERE clause being processed */ |
| 163763 | Bitmask *pMask, /* Mask to clear bits in */ |
| 163764 | int iIdxCur, /* Cursor number for index */ |
| 163765 | SrcItem *pItem /* The FROM clause entry for the table */ |
| 163766 | ){ |
| 163767 | assert( pItem==0 || (pItem->fg.jointype & JT_RIGHT)==0 ); |
| 163768 | assert( (pItem==0 || pMask==0) && (pMask!=0 || pItem!=0) ); |
| 163769 | |
| 163770 | if( pPart->op==TK_AND ){ |
| 163771 | wherePartIdxExpr(pParse, pIdx, pPart->pRight, pMask, iIdxCur, pItem); |
| 163772 | pPart = pPart->pLeft; |
| 163773 | } |
| 163774 | |
| 163775 | if( (pPart->op==TK_EQ || pPart->op==TK_IS) ){ |
| 163776 | Expr *pLeft = pPart->pLeft; |
| 163777 | Expr *pRight = pPart->pRight; |
| 163778 | u8 aff; |
| 163779 | |
| 163780 | if( pLeft->op!=TK_COLUMN ) return; |
| 163781 | if( !sqlite3ExprIsConstant(pRight) ) return; |
| 163782 | if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return; |
| 163783 | if( pLeft->iColumn<0 ) return; |
| 163784 | aff = pIdx->pTable->aCol[pLeft->iColumn].affinity; |
| 163785 | if( aff>=SQLITE_AFF_TEXT ){ |
| 163786 | if( pItem ){ |
| 163787 | sqlite3 *db = pParse->db; |
| 163788 | IndexedExpr *p = (IndexedExpr*)sqlite3DbMallocRaw(db, sizeof(*p)); |
| 163789 | if( p ){ |
| 163790 | int bNullRow = (pItem->fg.jointype&(JT_LEFT|JT_LTORJ))!=0; |
| 163791 | p->pExpr = sqlite3ExprDup(db, pRight, 0); |
| 163792 | p->iDataCur = pItem->iCursor; |
| 163793 | p->iIdxCur = iIdxCur; |
| 163794 | p->iIdxCol = pLeft->iColumn; |
| 163795 | p->bMaybeNullRow = bNullRow; |
| 163796 | p->pIENext = pParse->pIdxPartExpr; |
| 163797 | p->aff = aff; |
| 163798 | pParse->pIdxPartExpr = p; |
| 163799 | if( p->pIENext==0 ){ |
| 163800 | void *pArg = (void*)&pParse->pIdxPartExpr; |
| 163801 | sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); |
| 163802 | } |
| 163803 | } |
| 163804 | }else if( pLeft->iColumn<(BMS-1) ){ |
| 163805 | *pMask &= ~((Bitmask)1 << pLeft->iColumn); |
| 163806 | } |
| 163807 | } |
| 163808 | } |
| 163809 | } |
| 163810 | |
| 163811 | |
| 163812 | /* |
| 163813 | ** Add all WhereLoop objects for a single table of the join where the table |
| 163814 | ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be |
| 163815 | ** a b-tree table, not a virtual table. |
| @@ -162957,13 +164010,10 @@ | |
| 164010 | #ifdef SQLITE_ENABLE_STAT4 |
| 164011 | pNew->rRun = rSize + 16 - 2*((pTab->tabFlags & TF_HasStat4)!=0); |
| 164012 | #else |
| 164013 | pNew->rRun = rSize + 16; |
| 164014 | #endif |
| 164015 | ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 164016 | whereLoopOutputAdjust(pWC, pNew, rSize); |
| 164017 | rc = whereLoopInsert(pBuilder, pNew); |
| 164018 | pNew->nOut = rSize; |
| 164019 | if( rc ) break; |
| @@ -162972,10 +164022,15 @@ | |
| 164022 | if( pProbe->isCovering ){ |
| 164023 | m = 0; |
| 164024 | pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; |
| 164025 | }else{ |
| 164026 | m = pSrc->colUsed & pProbe->colNotIdxed; |
| 164027 | if( pProbe->pPartIdxWhere ){ |
| 164028 | wherePartIdxExpr( |
| 164029 | pWInfo->pParse, pProbe, pProbe->pPartIdxWhere, &m, 0, 0 |
| 164030 | ); |
| 164031 | } |
| 164032 | pNew->wsFlags = WHERE_INDEXED; |
| 164033 | if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ |
| 164034 | u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); |
| 164035 | if( isCov==0 ){ |
| 164036 | WHERETRACE(0x200, |
| @@ -163354,11 +164409,11 @@ | |
| 164409 | ){ |
| 164410 | HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 164411 | sqlite3_value *pVal = 0; |
| 164412 | int rc = SQLITE_OK; |
| 164413 | if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ |
| 164414 | rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */ |
| 164415 | }else{ |
| 164416 | if( pH->aRhs[iCons]==0 ){ |
| 164417 | WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; |
| 164418 | rc = sqlite3ValueFromExpr( |
| 164419 | pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db), |
| @@ -164378,18 +165433,10 @@ | |
| 165433 | }else{ |
| 165434 | rCost = rUnsorted; |
| 165435 | rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ |
| 165436 | } |
| 165437 | |
| 165438 | /* Check to see if pWLoop should be added to the set of |
| 165439 | ** mxChoice best-so-far paths. |
| 165440 | ** |
| 165441 | ** First look for an existing path among best-so-far paths |
| 165442 | ** that covers the same set of loops and has the same isOrdered |
| @@ -164935,24 +165982,10 @@ | |
| 165982 | } |
| 165983 | nSearch += pLoop->nOut; |
| 165984 | } |
| 165985 | } |
| 165986 | |
| 165987 | /* |
| 165988 | ** The index pIdx is used by a query and contains one or more expressions. |
| 165989 | ** In other words pIdx is an index on an expression. iIdxCur is the cursor |
| 165990 | ** number for the index and iDataCur is the cursor number for the corresponding |
| 165991 | ** table. |
| @@ -165010,11 +166043,12 @@ | |
| 166043 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 166044 | p->zIdxName = pIdx->zName; |
| 166045 | #endif |
| 166046 | pParse->pIdxEpr = p; |
| 166047 | if( p->pIENext==0 ){ |
| 166048 | void *pArg = (void*)&pParse->pIdxEpr; |
| 166049 | sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); |
| 166050 | } |
| 166051 | } |
| 166052 | } |
| 166053 | |
| 166054 | /* |
| @@ -165400,10 +166434,20 @@ | |
| 166434 | if( db->mallocFailed ) goto whereBeginError; |
| 166435 | if( pWInfo->pOrderBy ){ |
| 166436 | wherePathSolver(pWInfo, pWInfo->nRowOut+1); |
| 166437 | if( db->mallocFailed ) goto whereBeginError; |
| 166438 | } |
| 166439 | |
| 166440 | /* TUNING: Assume that a DISTINCT clause on a subquery reduces |
| 166441 | ** the output size by a factor of 8 (LogEst -30). |
| 166442 | */ |
| 166443 | if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 ){ |
| 166444 | WHERETRACE(0x0080,("nRowOut reduced from %d to %d due to DISTINCT\n", |
| 166445 | pWInfo->nRowOut, pWInfo->nRowOut-30)); |
| 166446 | pWInfo->nRowOut -= 30; |
| 166447 | } |
| 166448 | |
| 166449 | } |
| 166450 | assert( pWInfo->pTabList!=0 ); |
| 166451 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ |
| 166452 | whereReverseScanOrder(pWInfo); |
| 166453 | } |
| @@ -165611,10 +166655,15 @@ | |
| 166655 | op = OP_ReopenIdx; |
| 166656 | }else{ |
| 166657 | iIndexCur = pParse->nTab++; |
| 166658 | if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ |
| 166659 | whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); |
| 166660 | } |
| 166661 | if( pIx->pPartIdxWhere && (pTabItem->fg.jointype & JT_RIGHT)==0 ){ |
| 166662 | wherePartIdxExpr( |
| 166663 | pParse, pIx, pIx->pPartIdxWhere, 0, iIndexCur, pTabItem |
| 166664 | ); |
| 166665 | } |
| 166666 | } |
| 166667 | pLevel->iIdxCur = iIndexCur; |
| 166668 | assert( pIx!=0 ); |
| 166669 | assert( pIx->pSchema==pTab->pSchema ); |
| @@ -167428,12 +168477,13 @@ | |
| 168477 | */ |
| 168478 | SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ |
| 168479 | if( p ){ |
| 168480 | assert( p->op==TK_FUNCTION ); |
| 168481 | assert( pWin ); |
| 168482 | assert( ExprIsFullSize(p) ); |
| 168483 | p->y.pWin = pWin; |
| 168484 | ExprSetProperty(p, EP_WinFunc|EP_FullSize); |
| 168485 | pWin->pOwner = p; |
| 168486 | if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ |
| 168487 | sqlite3ErrorMsg(pParse, |
| 168488 | "DISTINCT is not supported for window functions" |
| 168489 | ); |
| @@ -169731,22 +170781,22 @@ | |
| 170781 | #define sqlite3ParserCTX_PDECL ,Parse *pParse |
| 170782 | #define sqlite3ParserCTX_PARAM ,pParse |
| 170783 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 170784 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 170785 | #define YYFALLBACK 1 |
| 170786 | #define YYNSTATE 579 |
| 170787 | #define YYNRULE 405 |
| 170788 | #define YYNRULE_WITH_ACTION 340 |
| 170789 | #define YYNTOKEN 185 |
| 170790 | #define YY_MAX_SHIFT 578 |
| 170791 | #define YY_MIN_SHIFTREDUCE 838 |
| 170792 | #define YY_MAX_SHIFTREDUCE 1242 |
| 170793 | #define YY_ERROR_ACTION 1243 |
| 170794 | #define YY_ACCEPT_ACTION 1244 |
| 170795 | #define YY_NO_ACTION 1245 |
| 170796 | #define YY_MIN_REDUCE 1246 |
| 170797 | #define YY_MAX_REDUCE 1650 |
| 170798 | /************* End control #defines *******************************************/ |
| 170799 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 170800 | |
| 170801 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 170802 | ** otherwise. |
| @@ -169809,222 +170859,222 @@ | |
| 170859 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 170860 | ** shifting non-terminals after a reduce. |
| 170861 | ** yy_default[] Default action for each state. |
| 170862 | ** |
| 170863 | *********** Begin parsing tables **********************************************/ |
| 170864 | #define YY_ACTTAB_COUNT (2100) |
| 170865 | static const YYACTIONTYPE yy_action[] = { |
| 170866 | /* 0 */ 572, 210, 572, 119, 116, 231, 572, 119, 116, 231, |
| 170867 | /* 10 */ 572, 1317, 379, 1296, 410, 566, 566, 566, 572, 411, |
| 170868 | /* 20 */ 380, 1317, 1279, 42, 42, 42, 42, 210, 1529, 72, |
| 170869 | /* 30 */ 72, 974, 421, 42, 42, 495, 305, 281, 305, 975, |
| 170870 | /* 40 */ 399, 72, 72, 126, 127, 81, 1217, 1217, 1054, 1057, |
| 170871 | /* 50 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 480, 411, |
| 170872 | /* 60 */ 1244, 1, 1, 578, 2, 1248, 554, 119, 116, 231, |
| 170873 | /* 70 */ 319, 484, 147, 484, 528, 119, 116, 231, 533, 1330, |
| 170874 | /* 80 */ 419, 527, 143, 126, 127, 81, 1217, 1217, 1054, 1057, |
| 170875 | /* 90 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 119, 116, |
| 170876 | /* 100 */ 231, 329, 123, 123, 123, 123, 122, 122, 121, 121, |
| 170877 | /* 110 */ 121, 120, 117, 448, 286, 286, 286, 286, 446, 446, |
| 170878 | /* 120 */ 446, 1568, 378, 1570, 1193, 377, 1164, 569, 1164, 569, |
| 170879 | /* 130 */ 411, 1568, 541, 261, 228, 448, 102, 146, 453, 318, |
| 170880 | /* 140 */ 563, 242, 123, 123, 123, 123, 122, 122, 121, 121, |
| 170881 | /* 150 */ 121, 120, 117, 448, 126, 127, 81, 1217, 1217, 1054, |
| 170882 | /* 160 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 143, |
| 170883 | /* 170 */ 296, 1193, 341, 452, 121, 121, 121, 120, 117, 448, |
| 170884 | /* 180 */ 128, 1193, 1194, 1193, 149, 445, 444, 572, 120, 117, |
| 170885 | /* 190 */ 448, 125, 125, 125, 125, 118, 123, 123, 123, 123, |
| 170886 | /* 200 */ 122, 122, 121, 121, 121, 120, 117, 448, 458, 114, |
| 170887 | /* 210 */ 13, 13, 550, 123, 123, 123, 123, 122, 122, 121, |
| 170888 | /* 220 */ 121, 121, 120, 117, 448, 424, 318, 563, 1193, 1194, |
| 170889 | /* 230 */ 1193, 150, 1225, 411, 1225, 125, 125, 125, 125, 123, |
| 170890 | /* 240 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, |
| 170891 | /* 250 */ 448, 469, 344, 1041, 1041, 1055, 1058, 126, 127, 81, |
| 170892 | /* 260 */ 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, |
| 170893 | /* 270 */ 125, 125, 1282, 526, 224, 1193, 572, 411, 226, 519, |
| 170894 | /* 280 */ 177, 83, 84, 123, 123, 123, 123, 122, 122, 121, |
| 170895 | /* 290 */ 121, 121, 120, 117, 448, 1010, 16, 16, 1193, 134, |
| 170896 | /* 300 */ 134, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, |
| 170897 | /* 310 */ 124, 124, 125, 125, 125, 125, 123, 123, 123, 123, |
| 170898 | /* 320 */ 122, 122, 121, 121, 121, 120, 117, 448, 1045, 550, |
| 170899 | /* 330 */ 1193, 375, 1193, 1194, 1193, 254, 1438, 401, 508, 505, |
| 170900 | /* 340 */ 504, 112, 564, 570, 4, 929, 929, 435, 503, 342, |
| 170901 | /* 350 */ 464, 330, 362, 396, 1238, 1193, 1194, 1193, 567, 572, |
| 170902 | /* 360 */ 123, 123, 123, 123, 122, 122, 121, 121, 121, 120, |
| 170903 | /* 370 */ 117, 448, 286, 286, 371, 1581, 1607, 445, 444, 155, |
| 170904 | /* 380 */ 411, 449, 72, 72, 1289, 569, 1222, 1193, 1194, 1193, |
| 170905 | /* 390 */ 86, 1224, 273, 561, 547, 520, 520, 572, 99, 1223, |
| 170906 | /* 400 */ 6, 1281, 476, 143, 126, 127, 81, 1217, 1217, 1054, |
| 170907 | /* 410 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 554, |
| 170908 | /* 420 */ 13, 13, 1031, 511, 1225, 1193, 1225, 553, 110, 110, |
| 170909 | /* 430 */ 224, 572, 1239, 177, 572, 429, 111, 199, 449, 573, |
| 170910 | /* 440 */ 449, 432, 1555, 1019, 327, 555, 1193, 272, 289, 370, |
| 170911 | /* 450 */ 514, 365, 513, 259, 72, 72, 547, 72, 72, 361, |
| 170912 | /* 460 */ 318, 563, 1613, 123, 123, 123, 123, 122, 122, 121, |
| 170913 | /* 470 */ 121, 121, 120, 117, 448, 1019, 1019, 1021, 1022, 28, |
| 170914 | /* 480 */ 286, 286, 1193, 1194, 1193, 1159, 572, 1612, 411, 904, |
| 170915 | /* 490 */ 192, 554, 358, 569, 554, 940, 537, 521, 1159, 437, |
| 170916 | /* 500 */ 415, 1159, 556, 1193, 1194, 1193, 572, 548, 548, 52, |
| 170917 | /* 510 */ 52, 216, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, |
| 170918 | /* 520 */ 1044, 124, 124, 125, 125, 125, 125, 1193, 478, 136, |
| 170919 | /* 530 */ 136, 411, 286, 286, 1493, 509, 122, 122, 121, 121, |
| 170920 | /* 540 */ 121, 120, 117, 448, 1010, 569, 522, 219, 545, 545, |
| 170921 | /* 550 */ 318, 563, 143, 6, 536, 126, 127, 81, 1217, 1217, |
| 170922 | /* 560 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 170923 | /* 570 */ 1557, 123, 123, 123, 123, 122, 122, 121, 121, 121, |
| 170924 | /* 580 */ 120, 117, 448, 489, 1193, 1194, 1193, 486, 283, 1270, |
| 170925 | /* 590 */ 960, 254, 1193, 375, 508, 505, 504, 1193, 342, 574, |
| 170926 | /* 600 */ 1193, 574, 411, 294, 503, 960, 879, 193, 484, 318, |
| 170927 | /* 610 */ 563, 386, 292, 382, 123, 123, 123, 123, 122, 122, |
| 170928 | /* 620 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 170929 | /* 630 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170930 | /* 640 */ 125, 411, 396, 1139, 1193, 872, 101, 286, 286, 1193, |
| 170931 | /* 650 */ 1194, 1193, 375, 1096, 1193, 1194, 1193, 1193, 1194, 1193, |
| 170932 | /* 660 */ 569, 459, 33, 375, 235, 126, 127, 81, 1217, 1217, |
| 170933 | /* 670 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 170934 | /* 680 */ 1437, 962, 572, 230, 961, 123, 123, 123, 123, 122, |
| 170935 | /* 690 */ 122, 121, 121, 121, 120, 117, 448, 1159, 230, 1193, |
| 170936 | /* 700 */ 158, 1193, 1194, 1193, 1556, 13, 13, 303, 960, 1233, |
| 170937 | /* 710 */ 1159, 154, 411, 1159, 375, 1584, 1177, 5, 371, 1581, |
| 170938 | /* 720 */ 431, 1239, 3, 960, 123, 123, 123, 123, 122, 122, |
| 170939 | /* 730 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 170940 | /* 740 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170941 | /* 750 */ 125, 411, 210, 571, 1193, 1032, 1193, 1194, 1193, 1193, |
| 170942 | /* 760 */ 390, 855, 156, 1555, 376, 404, 1101, 1101, 492, 572, |
| 170943 | /* 770 */ 469, 344, 1322, 1322, 1555, 126, 127, 81, 1217, 1217, |
| 170944 | /* 780 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 170945 | /* 790 */ 130, 572, 13, 13, 532, 123, 123, 123, 123, 122, |
| 170946 | /* 800 */ 122, 121, 121, 121, 120, 117, 448, 304, 572, 457, |
| 170947 | /* 810 */ 229, 1193, 1194, 1193, 13, 13, 1193, 1194, 1193, 1300, |
| 170948 | /* 820 */ 467, 1270, 411, 1320, 1320, 1555, 1015, 457, 456, 436, |
| 170949 | /* 830 */ 301, 72, 72, 1268, 123, 123, 123, 123, 122, 122, |
| 170950 | /* 840 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 170951 | /* 850 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170952 | /* 860 */ 125, 411, 384, 1076, 1159, 286, 286, 421, 314, 280, |
| 170953 | /* 870 */ 280, 287, 287, 461, 408, 407, 1539, 1159, 569, 572, |
| 170954 | /* 880 */ 1159, 1196, 569, 409, 569, 126, 127, 81, 1217, 1217, |
| 170955 | /* 890 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, |
| 170956 | /* 900 */ 457, 1485, 13, 13, 1541, 123, 123, 123, 123, 122, |
| 170957 | /* 910 */ 122, 121, 121, 121, 120, 117, 448, 202, 572, 462, |
| 170958 | /* 920 */ 1587, 578, 2, 1248, 843, 844, 845, 1563, 319, 409, |
| 170959 | /* 930 */ 147, 6, 411, 257, 256, 255, 208, 1330, 9, 1196, |
| 170960 | /* 940 */ 264, 72, 72, 1436, 123, 123, 123, 123, 122, 122, |
| 170961 | /* 950 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, |
| 170962 | /* 960 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170963 | /* 970 */ 125, 572, 286, 286, 572, 1213, 411, 577, 315, 1248, |
| 170964 | /* 980 */ 421, 371, 1581, 356, 319, 569, 147, 495, 529, 1644, |
| 170965 | /* 990 */ 397, 935, 495, 1330, 71, 71, 934, 72, 72, 242, |
| 170966 | /* 1000 */ 1328, 105, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, |
| 170967 | /* 1010 */ 124, 125, 125, 125, 125, 123, 123, 123, 123, 122, |
| 170968 | /* 1020 */ 122, 121, 121, 121, 120, 117, 448, 1117, 286, 286, |
| 170969 | /* 1030 */ 1422, 452, 1528, 1213, 443, 286, 286, 1492, 1355, 313, |
| 170970 | /* 1040 */ 478, 569, 1118, 454, 351, 495, 354, 1266, 569, 209, |
| 170971 | /* 1050 */ 572, 418, 179, 572, 1031, 242, 385, 1119, 523, 123, |
| 170972 | /* 1060 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, |
| 170973 | /* 1070 */ 448, 1020, 108, 72, 72, 1019, 13, 13, 915, 572, |
| 170974 | /* 1080 */ 1498, 572, 286, 286, 98, 530, 1537, 452, 916, 1334, |
| 170975 | /* 1090 */ 1329, 203, 411, 286, 286, 569, 152, 211, 1498, 1500, |
| 170976 | /* 1100 */ 426, 569, 56, 56, 57, 57, 569, 1019, 1019, 1021, |
| 170977 | /* 1110 */ 447, 572, 411, 531, 12, 297, 126, 127, 81, 1217, |
| 170978 | /* 1120 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170979 | /* 1130 */ 125, 572, 411, 867, 15, 15, 126, 127, 81, 1217, |
| 170980 | /* 1140 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170981 | /* 1150 */ 125, 373, 529, 264, 44, 44, 126, 115, 81, 1217, |
| 170982 | /* 1160 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, |
| 170983 | /* 1170 */ 125, 1498, 478, 1271, 417, 123, 123, 123, 123, 122, |
| 170984 | /* 1180 */ 122, 121, 121, 121, 120, 117, 448, 205, 1213, 495, |
| 170985 | /* 1190 */ 430, 867, 468, 322, 495, 123, 123, 123, 123, 122, |
| 170986 | /* 1200 */ 122, 121, 121, 121, 120, 117, 448, 572, 557, 1140, |
| 170987 | /* 1210 */ 1642, 1422, 1642, 543, 572, 123, 123, 123, 123, 122, |
| 170988 | /* 1220 */ 122, 121, 121, 121, 120, 117, 448, 572, 1422, 572, |
| 170989 | /* 1230 */ 13, 13, 542, 323, 1325, 411, 334, 58, 58, 349, |
| 170990 | /* 1240 */ 1422, 1170, 326, 286, 286, 549, 1213, 300, 895, 530, |
| 170991 | /* 1250 */ 45, 45, 59, 59, 1140, 1643, 569, 1643, 565, 417, |
| 170992 | /* 1260 */ 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, |
| 170993 | /* 1270 */ 125, 125, 125, 125, 1367, 373, 500, 290, 1193, 512, |
| 170994 | /* 1280 */ 1366, 427, 394, 394, 393, 275, 391, 896, 1138, 852, |
| 170995 | /* 1290 */ 478, 258, 1422, 1170, 463, 1159, 12, 331, 428, 333, |
| 170996 | /* 1300 */ 1117, 460, 236, 258, 325, 460, 544, 1544, 1159, 1098, |
| 170997 | /* 1310 */ 491, 1159, 324, 1098, 440, 1118, 335, 516, 123, 123, |
| 170998 | /* 1320 */ 123, 123, 122, 122, 121, 121, 121, 120, 117, 448, |
| 170999 | /* 1330 */ 1119, 318, 563, 1138, 572, 1193, 1194, 1193, 112, 564, |
| 171000 | /* 1340 */ 201, 4, 238, 433, 935, 490, 285, 228, 1517, 934, |
| 171001 | /* 1350 */ 170, 560, 572, 142, 1516, 567, 572, 60, 60, 572, |
| 171002 | /* 1360 */ 416, 572, 441, 572, 535, 302, 875, 8, 487, 572, |
| 171003 | /* 1370 */ 237, 572, 416, 572, 485, 61, 61, 572, 449, 62, |
| 171004 | /* 1380 */ 62, 332, 63, 63, 46, 46, 47, 47, 361, 572, |
| 171005 | /* 1390 */ 561, 572, 48, 48, 50, 50, 51, 51, 572, 295, |
| 171006 | /* 1400 */ 64, 64, 482, 295, 539, 412, 471, 1031, 572, 538, |
| 171007 | /* 1410 */ 318, 563, 65, 65, 66, 66, 409, 475, 572, 1031, |
| 171008 | /* 1420 */ 572, 14, 14, 875, 1020, 110, 110, 409, 1019, 572, |
| 171009 | /* 1430 */ 474, 67, 67, 111, 455, 449, 573, 449, 98, 317, |
| 171010 | /* 1440 */ 1019, 132, 132, 133, 133, 572, 1561, 572, 974, 409, |
| 171011 | /* 1450 */ 6, 1562, 68, 68, 1560, 6, 975, 572, 6, 1559, |
| 171012 | /* 1460 */ 1019, 1019, 1021, 6, 346, 218, 101, 531, 53, 53, |
| 171013 | /* 1470 */ 69, 69, 1019, 1019, 1021, 1022, 28, 1586, 1181, 451, |
| 171014 | /* 1480 */ 70, 70, 290, 87, 215, 31, 1363, 394, 394, 393, |
| 171015 | /* 1490 */ 275, 391, 350, 109, 852, 107, 572, 112, 564, 483, |
| 171016 | /* 1500 */ 4, 1212, 572, 239, 153, 572, 39, 236, 1299, 325, |
| 171017 | /* 1510 */ 112, 564, 1298, 4, 567, 572, 32, 324, 572, 54, |
| 171018 | /* 1520 */ 54, 572, 1135, 353, 398, 165, 165, 567, 166, 166, |
| 171019 | /* 1530 */ 572, 291, 355, 572, 17, 357, 572, 449, 77, 77, |
| 171020 | /* 1540 */ 1313, 55, 55, 1297, 73, 73, 572, 238, 470, 561, |
| 171021 | /* 1550 */ 449, 472, 364, 135, 135, 170, 74, 74, 142, 163, |
| 171022 | /* 1560 */ 163, 374, 561, 539, 572, 321, 572, 886, 540, 137, |
| 171023 | /* 1570 */ 137, 339, 1353, 422, 298, 237, 539, 572, 1031, 572, |
| 171024 | /* 1580 */ 340, 538, 101, 369, 110, 110, 162, 131, 131, 164, |
| 171025 | /* 1590 */ 164, 1031, 111, 368, 449, 573, 449, 110, 110, 1019, |
| 171026 | /* 1600 */ 157, 157, 141, 141, 572, 111, 572, 449, 573, 449, |
| 171027 | /* 1610 */ 412, 288, 1019, 572, 882, 318, 563, 572, 219, 572, |
| 171028 | /* 1620 */ 241, 1012, 477, 263, 263, 894, 893, 140, 140, 138, |
| 171029 | /* 1630 */ 138, 1019, 1019, 1021, 1022, 28, 139, 139, 525, 455, |
| 171030 | /* 1640 */ 76, 76, 78, 78, 1019, 1019, 1021, 1022, 28, 1181, |
| 171031 | /* 1650 */ 451, 572, 1083, 290, 112, 564, 1575, 4, 394, 394, |
| 171032 | /* 1660 */ 393, 275, 391, 572, 1023, 852, 572, 479, 345, 263, |
| 171033 | /* 1670 */ 101, 567, 882, 1376, 75, 75, 1421, 501, 236, 260, |
| 171034 | /* 1680 */ 325, 112, 564, 359, 4, 101, 43, 43, 324, 49, |
| 171035 | /* 1690 */ 49, 901, 902, 161, 449, 101, 977, 978, 567, 1079, |
| 171036 | /* 1700 */ 1349, 260, 965, 932, 263, 114, 561, 1095, 517, 1095, |
| 171037 | /* 1710 */ 1083, 1094, 865, 1094, 151, 933, 1144, 114, 238, 1361, |
| 171038 | /* 1720 */ 558, 449, 1023, 559, 1426, 1278, 170, 1269, 1257, 142, |
| 171039 | /* 1730 */ 1601, 1256, 1258, 561, 1594, 1031, 496, 278, 213, 1346, |
| 171040 | /* 1740 */ 310, 110, 110, 939, 311, 312, 237, 11, 234, 111, |
| 171041 | /* 1750 */ 221, 449, 573, 449, 293, 395, 1019, 1408, 337, 1403, |
| 171042 | /* 1760 */ 1396, 338, 1031, 299, 343, 1413, 1412, 481, 110, 110, |
| 171043 | /* 1770 */ 506, 402, 225, 1296, 206, 367, 111, 1358, 449, 573, |
| 171044 | /* 1780 */ 449, 412, 1359, 1019, 1489, 1488, 318, 563, 1019, 1019, |
| 171045 | /* 1790 */ 1021, 1022, 28, 562, 207, 220, 80, 564, 389, 4, |
| 171046 | /* 1800 */ 1597, 1357, 552, 1356, 1233, 181, 267, 232, 1536, 1534, |
| 171047 | /* 1810 */ 455, 1230, 420, 567, 82, 1019, 1019, 1021, 1022, 28, |
| 171048 | /* 1820 */ 86, 217, 85, 1494, 190, 175, 183, 465, 185, 466, |
| 171049 | /* 1830 */ 36, 1409, 186, 187, 188, 499, 449, 244, 37, 99, |
| 171050 | /* 1840 */ 400, 1415, 1414, 488, 1417, 194, 473, 403, 561, 1483, |
| 171051 | /* 1850 */ 248, 92, 1505, 494, 198, 279, 112, 564, 250, 4, |
| 171052 | /* 1860 */ 348, 497, 405, 352, 1259, 251, 252, 515, 1316, 434, |
| 171053 | /* 1870 */ 1315, 1314, 94, 567, 1307, 886, 1306, 1031, 226, 406, |
| 171054 | /* 1880 */ 1611, 1610, 438, 110, 110, 1580, 1286, 524, 439, 308, |
| 171055 | /* 1890 */ 266, 111, 1285, 449, 573, 449, 449, 309, 1019, 366, |
| 171056 | /* 1900 */ 1284, 1609, 265, 1566, 1565, 442, 372, 1381, 561, 129, |
| 171057 | /* 1910 */ 550, 1380, 10, 1470, 383, 106, 316, 551, 100, 35, |
| 171058 | /* 1920 */ 534, 575, 212, 1339, 381, 387, 1187, 1338, 274, 276, |
| 171059 | /* 1930 */ 1019, 1019, 1021, 1022, 28, 277, 413, 1031, 576, 1254, |
| 171060 | /* 1940 */ 388, 1521, 1249, 110, 110, 167, 1522, 168, 148, 1520, |
| 171061 | /* 1950 */ 1519, 111, 306, 449, 573, 449, 222, 223, 1019, 839, |
| 171062 | /* 1960 */ 169, 79, 450, 214, 414, 233, 320, 145, 1093, 1091, |
| 171063 | /* 1970 */ 328, 182, 171, 1212, 918, 184, 240, 336, 243, 1107, |
| 171064 | /* 1980 */ 189, 172, 173, 423, 425, 88, 180, 191, 89, 90, |
| 171065 | /* 1990 */ 1019, 1019, 1021, 1022, 28, 91, 174, 1110, 245, 1106, |
| 171066 | /* 2000 */ 246, 159, 18, 247, 347, 1099, 263, 195, 1227, 493, |
| 171067 | /* 2010 */ 249, 196, 38, 854, 498, 368, 253, 360, 897, 197, |
| 171068 | /* 2020 */ 502, 93, 19, 20, 507, 884, 363, 510, 95, 307, |
| 171069 | /* 2030 */ 160, 96, 518, 97, 1175, 1060, 1146, 40, 21, 227, |
| 171070 | /* 2040 */ 176, 1145, 282, 284, 969, 200, 963, 114, 262, 1165, |
| 171071 | /* 2050 */ 22, 23, 24, 1161, 1169, 25, 1163, 1150, 34, 26, |
| 171072 | /* 2060 */ 1168, 546, 27, 204, 101, 103, 104, 1074, 7, 1061, |
| 171073 | /* 2070 */ 1059, 1063, 1116, 1064, 1115, 268, 269, 29, 41, 270, |
| 171074 | /* 2080 */ 1024, 866, 113, 30, 568, 392, 1183, 144, 178, 1182, |
| 171075 | /* 2090 */ 271, 928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602, |
| 171076 | }; |
| 171077 | static const YYCODETYPE yy_lookahead[] = { |
| 171078 | /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, |
| 171079 | /* 10 */ 193, 223, 219, 225, 206, 210, 211, 212, 193, 19, |
| 171080 | /* 20 */ 219, 233, 216, 216, 217, 216, 217, 193, 295, 216, |
| @@ -170099,11 +171149,11 @@ | |
| 171149 | /* 710 */ 89, 241, 19, 92, 193, 193, 23, 22, 311, 312, |
| 171150 | /* 720 */ 231, 101, 22, 143, 102, 103, 104, 105, 106, 107, |
| 171151 | /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 171152 | /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 171153 | /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, |
| 171154 | /* 760 */ 201, 21, 241, 304, 193, 206, 127, 128, 129, 193, |
| 171155 | /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, |
| 171156 | /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 171157 | /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, |
| 171158 | /* 800 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 193, |
| 171159 | /* 810 */ 193, 116, 117, 118, 216, 217, 116, 117, 118, 226, |
| @@ -170110,133 +171160,133 @@ | |
| 171160 | /* 820 */ 80, 193, 19, 235, 236, 304, 23, 211, 212, 231, |
| 171161 | /* 830 */ 204, 216, 217, 205, 102, 103, 104, 105, 106, 107, |
| 171162 | /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 171163 | /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 171164 | /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, |
| 171165 | /* 870 */ 240, 239, 240, 244, 106, 107, 193, 89, 252, 193, |
| 171166 | /* 880 */ 92, 59, 252, 254, 252, 43, 44, 45, 46, 47, |
| 171167 | /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 171168 | /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, |
| 171169 | /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 244, |
| 171170 | /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 254, |
| 171171 | /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, |
| 171172 | /* 940 */ 24, 216, 217, 273, 102, 103, 104, 105, 106, 107, |
| 171173 | /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 171174 | /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 171175 | /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, |
| 171176 | /* 980 */ 193, 311, 312, 16, 195, 252, 197, 193, 19, 301, |
| 171177 | /* 990 */ 302, 135, 193, 204, 216, 217, 140, 216, 217, 266, |
| 171178 | /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, |
| 171179 | /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, |
| 171180 | /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, |
| 171181 | /* 1030 */ 193, 298, 238, 117, 253, 239, 240, 238, 259, 260, |
| 171182 | /* 1040 */ 193, 252, 27, 193, 77, 193, 79, 204, 252, 262, |
| 171183 | /* 1050 */ 193, 299, 300, 193, 100, 266, 278, 42, 204, 102, |
| 171184 | /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 171185 | /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, |
| 171186 | /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 240, |
| 171187 | /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, |
| 171188 | /* 1100 */ 263, 252, 216, 217, 216, 217, 252, 153, 154, 155, |
| 171189 | /* 1110 */ 253, 193, 19, 144, 213, 268, 43, 44, 45, 46, |
| 171190 | /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 171191 | /* 1130 */ 57, 193, 19, 59, 216, 217, 43, 44, 45, 46, |
| 171192 | /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 171193 | /* 1150 */ 57, 193, 19, 24, 216, 217, 43, 44, 45, 46, |
| 171194 | /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 171195 | /* 1170 */ 57, 284, 193, 208, 209, 102, 103, 104, 105, 106, |
| 171196 | /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 59, 193, |
| 171197 | /* 1190 */ 232, 117, 291, 193, 193, 102, 103, 104, 105, 106, |
| 171198 | /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 193, 204, 22, |
| 171199 | /* 1210 */ 23, 193, 25, 66, 193, 102, 103, 104, 105, 106, |
| 171200 | /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 193, 193, |
| 171201 | /* 1230 */ 216, 217, 85, 193, 238, 19, 16, 216, 217, 238, |
| 171202 | /* 1240 */ 193, 94, 193, 239, 240, 231, 117, 268, 35, 116, |
| 171203 | /* 1250 */ 216, 217, 216, 217, 22, 23, 252, 25, 208, 209, |
| 171204 | /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 171205 | /* 1270 */ 54, 55, 56, 57, 193, 193, 19, 5, 59, 66, |
| 171206 | /* 1280 */ 193, 263, 10, 11, 12, 13, 14, 74, 101, 17, |
| 171207 | /* 1290 */ 193, 46, 193, 146, 193, 76, 213, 77, 263, 79, |
| 171208 | /* 1300 */ 12, 260, 30, 46, 32, 264, 87, 193, 89, 29, |
| 171209 | /* 1310 */ 263, 92, 40, 33, 232, 27, 193, 108, 102, 103, |
| 171210 | /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 171211 | /* 1330 */ 42, 138, 139, 101, 193, 116, 117, 118, 19, 20, |
| 171212 | /* 1340 */ 255, 22, 70, 130, 135, 65, 256, 257, 193, 140, |
| 171213 | /* 1350 */ 78, 63, 193, 81, 193, 36, 193, 216, 217, 193, |
| 171214 | /* 1360 */ 115, 193, 263, 193, 145, 268, 59, 48, 193, 193, |
| 171215 | /* 1370 */ 98, 193, 115, 193, 291, 216, 217, 193, 59, 216, |
| 171216 | /* 1380 */ 217, 161, 216, 217, 216, 217, 216, 217, 131, 193, |
| 171217 | /* 1390 */ 71, 193, 216, 217, 216, 217, 216, 217, 193, 260, |
| 171218 | /* 1400 */ 216, 217, 19, 264, 85, 133, 244, 100, 193, 90, |
| 171219 | /* 1410 */ 138, 139, 216, 217, 216, 217, 254, 244, 193, 100, |
| 171220 | /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 254, 121, 193, |
| 171221 | /* 1430 */ 115, 216, 217, 114, 162, 116, 117, 118, 115, 244, |
| 171222 | /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 193, 31, 254, |
| 171223 | /* 1450 */ 313, 309, 216, 217, 309, 313, 39, 193, 313, 309, |
| 171224 | /* 1460 */ 153, 154, 155, 313, 193, 150, 25, 144, 216, 217, |
| 171225 | /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, |
| 171226 | /* 1480 */ 216, 217, 5, 149, 150, 22, 193, 10, 11, 12, |
| 171227 | /* 1490 */ 13, 14, 193, 158, 17, 160, 193, 19, 20, 116, |
| 171228 | /* 1500 */ 22, 25, 193, 24, 22, 193, 24, 30, 226, 32, |
| 171229 | /* 1510 */ 19, 20, 226, 22, 36, 193, 53, 40, 193, 216, |
| 171230 | /* 1520 */ 217, 193, 23, 193, 25, 216, 217, 36, 216, 217, |
| 171231 | /* 1530 */ 193, 99, 193, 193, 22, 193, 193, 59, 216, 217, |
| 171232 | /* 1540 */ 193, 216, 217, 193, 216, 217, 193, 70, 129, 71, |
| 171233 | /* 1550 */ 59, 129, 193, 216, 217, 78, 216, 217, 81, 216, |
| 171234 | /* 1560 */ 217, 193, 71, 85, 193, 133, 193, 126, 90, 216, |
| 171235 | /* 1570 */ 217, 152, 258, 61, 152, 98, 85, 193, 100, 193, |
| 171236 | /* 1580 */ 23, 90, 25, 121, 106, 107, 23, 216, 217, 216, |
| 171237 | /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, |
| 171238 | /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118, |
| 171239 | /* 1610 */ 133, 22, 121, 193, 59, 138, 139, 193, 142, 193, |
| 171240 | /* 1620 */ 141, 23, 23, 25, 25, 120, 121, 216, 217, 216, |
| 171241 | /* 1630 */ 217, 153, 154, 155, 156, 157, 216, 217, 19, 162, |
| 171242 | /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, |
| 171243 | /* 1650 */ 2, 193, 59, 5, 19, 20, 318, 22, 10, 11, |
| 171244 | /* 1660 */ 12, 13, 14, 193, 59, 17, 193, 23, 23, 25, |
| 171245 | /* 1670 */ 25, 36, 117, 193, 216, 217, 193, 23, 30, 25, |
| 171246 | /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, |
| 171247 | /* 1690 */ 217, 7, 8, 23, 59, 25, 83, 84, 36, 23, |
| 171248 | /* 1700 */ 193, 25, 23, 23, 25, 25, 71, 153, 145, 155, |
| 171249 | /* 1710 */ 117, 153, 23, 155, 25, 23, 97, 25, 70, 193, |
| 171250 | /* 1720 */ 193, 59, 117, 236, 193, 193, 78, 193, 193, 81, |
| 171251 | /* 1730 */ 141, 193, 193, 71, 193, 100, 288, 287, 242, 255, |
| 171252 | /* 1740 */ 255, 106, 107, 108, 255, 255, 98, 243, 297, 114, |
| 171253 | /* 1750 */ 214, 116, 117, 118, 245, 191, 121, 271, 293, 267, |
| 171254 | /* 1760 */ 267, 246, 100, 246, 245, 271, 271, 293, 106, 107, |
| 171255 | /* 1770 */ 220, 271, 229, 225, 249, 219, 114, 259, 116, 117, |
| 171256 | /* 1780 */ 118, 133, 259, 121, 219, 219, 138, 139, 153, 154, |
| 171257 | /* 1790 */ 155, 156, 157, 280, 249, 243, 19, 20, 245, 22, |
| 171258 | /* 1800 */ 196, 259, 140, 259, 60, 297, 141, 297, 200, 200, |
| 171259 | /* 1810 */ 162, 38, 200, 36, 294, 153, 154, 155, 156, 157, |
| 171260 | /* 1820 */ 151, 150, 294, 283, 22, 43, 234, 18, 237, 200, |
| 171261 | /* 1830 */ 270, 272, 237, 237, 237, 18, 59, 199, 270, 149, |
| 171262 | /* 1840 */ 246, 272, 272, 200, 234, 234, 246, 246, 71, 246, |
| 171263 | /* 1850 */ 199, 158, 290, 62, 22, 200, 19, 20, 199, 22, |
| 171264 | /* 1860 */ 289, 221, 221, 200, 200, 199, 199, 115, 218, 64, |
| 171265 | /* 1870 */ 218, 218, 22, 36, 227, 126, 227, 100, 165, 221, |
| 171266 | /* 1880 */ 224, 224, 24, 106, 107, 312, 218, 305, 113, 282, |
| 171267 | /* 1890 */ 91, 114, 220, 116, 117, 118, 59, 282, 121, 218, |
| 171268 | /* 1900 */ 218, 218, 200, 317, 317, 82, 221, 265, 71, 148, |
| 171269 | /* 1910 */ 145, 265, 22, 277, 200, 158, 279, 140, 147, 25, |
| 171270 | /* 1920 */ 146, 202, 248, 250, 249, 247, 13, 250, 194, 194, |
| 171271 | /* 1930 */ 153, 154, 155, 156, 157, 6, 303, 100, 192, 192, |
| 171272 | /* 1940 */ 246, 213, 192, 106, 107, 207, 213, 207, 222, 213, |
| 171273 | /* 1950 */ 213, 114, 222, 116, 117, 118, 214, 214, 121, 4, |
| 171274 | /* 1960 */ 207, 213, 3, 22, 303, 15, 163, 16, 23, 23, |
| 171275 | /* 1970 */ 139, 151, 130, 25, 20, 142, 24, 16, 144, 1, |
| 171276 | /* 1980 */ 142, 130, 130, 61, 37, 53, 300, 151, 53, 53, |
| 171277 | /* 1990 */ 153, 154, 155, 156, 157, 53, 130, 116, 34, 1, |
| 171278 | /* 2000 */ 141, 5, 22, 115, 161, 68, 25, 68, 75, 41, |
| 171279 | /* 2010 */ 141, 115, 24, 20, 19, 131, 125, 23, 28, 22, |
| 171280 | /* 2020 */ 67, 22, 22, 22, 67, 59, 24, 96, 22, 67, |
| 171281 | /* 2030 */ 23, 149, 22, 25, 23, 23, 23, 22, 34, 141, |
| 171282 | /* 2040 */ 37, 97, 23, 23, 116, 22, 143, 25, 34, 75, |
| 171283 | /* 2050 */ 34, 34, 34, 88, 75, 34, 86, 23, 22, 34, |
| 171284 | /* 2060 */ 93, 24, 34, 25, 25, 142, 142, 23, 44, 23, |
| 171285 | /* 2070 */ 23, 23, 23, 11, 23, 25, 22, 22, 22, 141, |
| 171286 | /* 2080 */ 23, 23, 22, 22, 25, 15, 1, 23, 25, 1, |
| 171287 | /* 2090 */ 141, 135, 319, 319, 319, 319, 319, 319, 319, 141, |
| 171288 | /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171289 | /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171290 | /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171291 | /* 2130 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171292 | /* 2140 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| @@ -170251,180 +171301,181 @@ | |
| 171301 | /* 2230 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171302 | /* 2240 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171303 | /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171304 | /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171305 | /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 171306 | /* 2280 */ 319, 319, 319, 319, 319, |
| 171307 | }; |
| 171308 | #define YY_SHIFT_COUNT (578) |
| 171309 | #define YY_SHIFT_MIN (0) |
| 171310 | #define YY_SHIFT_MAX (2088) |
| 171311 | static const unsigned short int yy_shift_ofst[] = { |
| 171312 | /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, |
| 171313 | /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, |
| 171314 | /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 171315 | /* 30 */ 1837, 271, 271, 1219, 1219, 216, 88, 1, 1, 1, |
| 171316 | /* 40 */ 1, 1, 40, 111, 258, 361, 469, 512, 583, 622, |
| 171317 | /* 50 */ 693, 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, |
| 171318 | /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, |
| 171319 | /* 70 */ 1093, 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, |
| 171320 | /* 80 */ 1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 171321 | /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 171322 | /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 171323 | /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 171324 | /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, |
| 171325 | /* 130 */ 1837, 137, 181, 181, 181, 181, 181, 181, 181, 94, |
| 171326 | /* 140 */ 430, 66, 65, 112, 366, 533, 533, 740, 1257, 533, |
| 171327 | /* 150 */ 533, 79, 79, 533, 412, 412, 412, 77, 412, 123, |
| 171328 | /* 160 */ 113, 113, 113, 22, 22, 2100, 2100, 328, 328, 328, |
| 171329 | /* 170 */ 239, 468, 468, 468, 468, 1015, 1015, 409, 366, 1187, |
| 171330 | /* 180 */ 1232, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 171331 | /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 171332 | /* 200 */ 533, 969, 621, 621, 533, 642, 788, 788, 1133, 1133, |
| 171333 | /* 210 */ 822, 822, 67, 1193, 2100, 2100, 2100, 2100, 2100, 2100, |
| 171334 | /* 220 */ 2100, 1307, 954, 954, 585, 472, 640, 387, 695, 538, |
| 171335 | /* 230 */ 541, 700, 533, 533, 533, 533, 533, 533, 533, 533, |
| 171336 | /* 240 */ 533, 533, 222, 533, 533, 533, 533, 533, 533, 533, |
| 171337 | /* 250 */ 533, 533, 533, 533, 533, 1213, 1213, 1213, 533, 533, |
| 171338 | /* 260 */ 533, 565, 533, 533, 533, 916, 1147, 533, 533, 1288, |
| 171339 | /* 270 */ 533, 533, 533, 533, 533, 533, 533, 533, 639, 1280, |
| 171340 | /* 280 */ 209, 1129, 1129, 1129, 1129, 580, 209, 209, 1209, 768, |
| 171341 | /* 290 */ 917, 649, 1315, 1334, 405, 1334, 1383, 249, 1315, 1315, |
| 171342 | /* 300 */ 249, 1315, 405, 1383, 1441, 464, 1245, 1417, 1417, 1417, |
| 171343 | /* 310 */ 1323, 1323, 1323, 1323, 184, 184, 1335, 1476, 856, 1482, |
| 171344 | /* 320 */ 1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802, |
| 171345 | /* 330 */ 1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671, |
| 171346 | /* 340 */ 1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791, |
| 171347 | /* 350 */ 1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752, |
| 171348 | /* 360 */ 1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752, |
| 171349 | /* 370 */ 1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823, |
| 171350 | /* 380 */ 1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690, |
| 171351 | /* 390 */ 1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100, |
| 171352 | /* 400 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, |
| 171353 | /* 410 */ 2100, 207, 1220, 331, 620, 967, 806, 1074, 1499, 1432, |
| 171354 | /* 420 */ 1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645, |
| 171355 | /* 430 */ 1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593, |
| 171356 | /* 440 */ 1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589, |
| 171357 | /* 450 */ 1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820, |
| 171358 | /* 460 */ 1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838, |
| 171359 | /* 470 */ 1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936, |
| 171360 | /* 480 */ 1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843, |
| 171361 | /* 490 */ 1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995, |
| 171362 | /* 500 */ 1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966, |
| 171363 | /* 510 */ 2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010, |
| 171364 | /* 520 */ 2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928, |
| 171365 | /* 530 */ 2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974, |
| 171366 | /* 540 */ 1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039, |
| 171367 | /* 550 */ 2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050, |
| 171368 | /* 560 */ 2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059, |
| 171369 | /* 570 */ 1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088, |
| 171370 | }; |
| 171371 | #define YY_REDUCE_COUNT (410) |
| 171372 | #define YY_REDUCE_MIN (-271) |
| 171373 | #define YY_REDUCE_MAX (1753) |
| 171374 | static const short yy_reduce_ofst[] = { |
| 171375 | /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, |
| 171376 | /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, |
| 171377 | /* 20 */ 576, 598, -175, 686, 860, 615, 725, 1014, 778, 781, |
| 171378 | /* 30 */ 857, 616, 887, 87, 240, -192, 408, 626, 796, 843, |
| 171379 | /* 40 */ 854, 1004, -271, -271, -271, -271, -271, -271, -271, -271, |
| 171380 | /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 171381 | /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 171382 | /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, 80, |
| 171383 | /* 80 */ 83, 313, 886, 888, 918, 938, 1021, 1034, 1036, 1141, |
| 171384 | /* 90 */ 1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196, |
| 171385 | /* 100 */ 1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303, |
| 171386 | /* 110 */ 1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371, |
| 171387 | /* 120 */ 1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470, |
| 171388 | /* 130 */ 1473, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 171389 | /* 140 */ -271, -271, 138, 459, 396, -158, 470, 302, -212, 521, |
| 171390 | /* 150 */ 201, -195, -92, 559, 630, 632, 630, -271, 632, 901, |
| 171391 | /* 160 */ 63, 407, 670, -271, -271, -271, -271, 161, 161, 161, |
| 171392 | /* 170 */ 251, 335, 847, 979, 1097, 537, 588, 618, 628, 688, |
| 171393 | /* 180 */ 688, -166, -161, 674, 787, 794, 799, 852, 996, -122, |
| 171394 | /* 190 */ 837, -120, 1018, 1035, 415, 1047, 1001, 958, 1082, 400, |
| 171395 | /* 200 */ 1099, 779, 1137, 1142, 263, 1083, 1145, 1150, 1041, 1139, |
| 171396 | /* 210 */ 965, 1050, 362, 849, 752, 629, 675, 1162, 1173, 1090, |
| 171397 | /* 220 */ 1195, -194, 56, 185, -135, 232, 522, 560, 571, 601, |
| 171398 | /* 230 */ 617, 669, 683, 711, 850, 893, 1000, 1040, 1049, 1081, |
| 171399 | /* 240 */ 1087, 1101, 392, 1114, 1123, 1155, 1161, 1175, 1271, 1293, |
| 171400 | /* 250 */ 1299, 1330, 1339, 1342, 1347, 593, 1282, 1286, 1350, 1359, |
| 171401 | /* 260 */ 1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487, |
| 171402 | /* 270 */ 1531, 560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450, |
| 171403 | /* 280 */ 1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536, |
| 171404 | /* 290 */ 1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495, |
| 171405 | /* 300 */ 1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566, |
| 171406 | /* 310 */ 1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604, |
| 171407 | /* 320 */ 1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560, |
| 171408 | /* 330 */ 1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570, |
| 171409 | /* 340 */ 1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571, |
| 171410 | /* 350 */ 1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652, |
| 171411 | /* 360 */ 1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682, |
| 171412 | /* 370 */ 1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642, |
| 171413 | /* 380 */ 1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694, |
| 171414 | /* 390 */ 1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738, |
| 171415 | /* 400 */ 1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748, |
| 171416 | /* 410 */ 1753, |
| 171417 | }; |
| 171418 | static const YYACTIONTYPE yy_default[] = { |
| 171419 | /* 0 */ 1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478, |
| 171420 | /* 10 */ 1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243, |
| 171421 | /* 20 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243, |
| 171422 | /* 30 */ 1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243, |
| 171423 | /* 40 */ 1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243, |
| 171424 | /* 50 */ 1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407, |
| 171425 | /* 60 */ 1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475, |
| 171426 | /* 70 */ 1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243, |
| 171427 | /* 80 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171428 | /* 90 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171429 | /* 100 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171430 | /* 110 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171431 | /* 120 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171432 | /* 130 */ 1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443, |
| 171433 | /* 140 */ 1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243, |
| 171434 | /* 150 */ 1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276, |
| 171435 | /* 160 */ 1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599, |
| 171436 | /* 170 */ 1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243, |
| 171437 | /* 180 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171438 | /* 190 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171439 | /* 200 */ 1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375, |
| 171440 | /* 210 */ 1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354, |
| 171441 | /* 220 */ 1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171442 | /* 230 */ 1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243, |
| 171443 | /* 240 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171444 | /* 250 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171445 | /* 260 */ 1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243, |
| 171446 | /* 270 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508, |
| 171447 | /* 280 */ 1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277, |
| 171448 | /* 290 */ 1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410, |
| 171449 | /* 300 */ 1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384, |
| 171450 | /* 310 */ 1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243, |
| 171451 | /* 320 */ 1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419, |
| 171452 | /* 330 */ 1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623, |
| 171453 | /* 340 */ 1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634, |
| 171454 | /* 350 */ 1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319, |
| 171455 | /* 360 */ 1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319, |
| 171456 | /* 370 */ 1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387, |
| 171457 | /* 380 */ 1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397, |
| 171458 | /* 390 */ 1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608, |
| 171459 | /* 400 */ 1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276, |
| 171460 | /* 410 */ 1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540, |
| 171461 | /* 420 */ 1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171462 | /* 430 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243, |
| 171463 | /* 440 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424, |
| 171464 | /* 450 */ 1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171465 | /* 460 */ 1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171466 | /* 470 */ 1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243, |
| 171467 | /* 480 */ 1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243, |
| 171468 | /* 490 */ 1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243, |
| 171469 | /* 500 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291, |
| 171470 | /* 510 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171471 | /* 520 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171472 | /* 530 */ 1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243, |
| 171473 | /* 540 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379, |
| 171474 | /* 550 */ 1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243, |
| 171475 | /* 560 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619, |
| 171476 | /* 570 */ 1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243, |
| 171477 | }; |
| 171478 | /********** End of lemon-generated parsing tables *****************************/ |
| 171479 | |
| 171480 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 171481 | ** If a construct like the following: |
| @@ -171227,225 +172278,227 @@ | |
| 172278 | /* 183 */ "term ::= INTEGER", |
| 172279 | /* 184 */ "expr ::= VARIABLE", |
| 172280 | /* 185 */ "expr ::= expr COLLATE ID|STRING", |
| 172281 | /* 186 */ "expr ::= CAST LP expr AS typetoken RP", |
| 172282 | /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", |
| 172283 | /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP", |
| 172284 | /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", |
| 172285 | /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", |
| 172286 | /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over", |
| 172287 | /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", |
| 172288 | /* 193 */ "term ::= CTIME_KW", |
| 172289 | /* 194 */ "expr ::= LP nexprlist COMMA expr RP", |
| 172290 | /* 195 */ "expr ::= expr AND expr", |
| 172291 | /* 196 */ "expr ::= expr OR expr", |
| 172292 | /* 197 */ "expr ::= expr LT|GT|GE|LE expr", |
| 172293 | /* 198 */ "expr ::= expr EQ|NE expr", |
| 172294 | /* 199 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 172295 | /* 200 */ "expr ::= expr PLUS|MINUS expr", |
| 172296 | /* 201 */ "expr ::= expr STAR|SLASH|REM expr", |
| 172297 | /* 202 */ "expr ::= expr CONCAT expr", |
| 172298 | /* 203 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 172299 | /* 204 */ "expr ::= expr likeop expr", |
| 172300 | /* 205 */ "expr ::= expr likeop expr ESCAPE expr", |
| 172301 | /* 206 */ "expr ::= expr ISNULL|NOTNULL", |
| 172302 | /* 207 */ "expr ::= expr NOT NULL", |
| 172303 | /* 208 */ "expr ::= expr IS expr", |
| 172304 | /* 209 */ "expr ::= expr IS NOT expr", |
| 172305 | /* 210 */ "expr ::= expr IS NOT DISTINCT FROM expr", |
| 172306 | /* 211 */ "expr ::= expr IS DISTINCT FROM expr", |
| 172307 | /* 212 */ "expr ::= NOT expr", |
| 172308 | /* 213 */ "expr ::= BITNOT expr", |
| 172309 | /* 214 */ "expr ::= PLUS|MINUS expr", |
| 172310 | /* 215 */ "expr ::= expr PTR expr", |
| 172311 | /* 216 */ "between_op ::= BETWEEN", |
| 172312 | /* 217 */ "between_op ::= NOT BETWEEN", |
| 172313 | /* 218 */ "expr ::= expr between_op expr AND expr", |
| 172314 | /* 219 */ "in_op ::= IN", |
| 172315 | /* 220 */ "in_op ::= NOT IN", |
| 172316 | /* 221 */ "expr ::= expr in_op LP exprlist RP", |
| 172317 | /* 222 */ "expr ::= LP select RP", |
| 172318 | /* 223 */ "expr ::= expr in_op LP select RP", |
| 172319 | /* 224 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 172320 | /* 225 */ "expr ::= EXISTS LP select RP", |
| 172321 | /* 226 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 172322 | /* 227 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 172323 | /* 228 */ "case_exprlist ::= WHEN expr THEN expr", |
| 172324 | /* 229 */ "case_else ::= ELSE expr", |
| 172325 | /* 230 */ "case_else ::=", |
| 172326 | /* 231 */ "case_operand ::=", |
| 172327 | /* 232 */ "exprlist ::=", |
| 172328 | /* 233 */ "nexprlist ::= nexprlist COMMA expr", |
| 172329 | /* 234 */ "nexprlist ::= expr", |
| 172330 | /* 235 */ "paren_exprlist ::=", |
| 172331 | /* 236 */ "paren_exprlist ::= LP exprlist RP", |
| 172332 | /* 237 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 172333 | /* 238 */ "uniqueflag ::= UNIQUE", |
| 172334 | /* 239 */ "uniqueflag ::=", |
| 172335 | /* 240 */ "eidlist_opt ::=", |
| 172336 | /* 241 */ "eidlist_opt ::= LP eidlist RP", |
| 172337 | /* 242 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 172338 | /* 243 */ "eidlist ::= nm collate sortorder", |
| 172339 | /* 244 */ "collate ::=", |
| 172340 | /* 245 */ "collate ::= COLLATE ID|STRING", |
| 172341 | /* 246 */ "cmd ::= DROP INDEX ifexists fullname", |
| 172342 | /* 247 */ "cmd ::= VACUUM vinto", |
| 172343 | /* 248 */ "cmd ::= VACUUM nm vinto", |
| 172344 | /* 249 */ "vinto ::= INTO expr", |
| 172345 | /* 250 */ "vinto ::=", |
| 172346 | /* 251 */ "cmd ::= PRAGMA nm dbnm", |
| 172347 | /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 172348 | /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 172349 | /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 172350 | /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 172351 | /* 256 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 172352 | /* 257 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 172353 | /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 172354 | /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 172355 | /* 260 */ "trigger_time ::= BEFORE|AFTER", |
| 172356 | /* 261 */ "trigger_time ::= INSTEAD OF", |
| 172357 | /* 262 */ "trigger_time ::=", |
| 172358 | /* 263 */ "trigger_event ::= DELETE|INSERT", |
| 172359 | /* 264 */ "trigger_event ::= UPDATE", |
| 172360 | /* 265 */ "trigger_event ::= UPDATE OF idlist", |
| 172361 | /* 266 */ "when_clause ::=", |
| 172362 | /* 267 */ "when_clause ::= WHEN expr", |
| 172363 | /* 268 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 172364 | /* 269 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 172365 | /* 270 */ "trnm ::= nm DOT nm", |
| 172366 | /* 271 */ "tridxby ::= INDEXED BY nm", |
| 172367 | /* 272 */ "tridxby ::= NOT INDEXED", |
| 172368 | /* 273 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 172369 | /* 274 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 172370 | /* 275 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 172371 | /* 276 */ "trigger_cmd ::= scanpt select scanpt", |
| 172372 | /* 277 */ "expr ::= RAISE LP IGNORE RP", |
| 172373 | /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 172374 | /* 279 */ "raisetype ::= ROLLBACK", |
| 172375 | /* 280 */ "raisetype ::= ABORT", |
| 172376 | /* 281 */ "raisetype ::= FAIL", |
| 172377 | /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 172378 | /* 283 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 172379 | /* 284 */ "cmd ::= DETACH database_kw_opt expr", |
| 172380 | /* 285 */ "key_opt ::=", |
| 172381 | /* 286 */ "key_opt ::= KEY expr", |
| 172382 | /* 287 */ "cmd ::= REINDEX", |
| 172383 | /* 288 */ "cmd ::= REINDEX nm dbnm", |
| 172384 | /* 289 */ "cmd ::= ANALYZE", |
| 172385 | /* 290 */ "cmd ::= ANALYZE nm dbnm", |
| 172386 | /* 291 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 172387 | /* 292 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 172388 | /* 293 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 172389 | /* 294 */ "add_column_fullname ::= fullname", |
| 172390 | /* 295 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 172391 | /* 296 */ "cmd ::= create_vtab", |
| 172392 | /* 297 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 172393 | /* 298 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 172394 | /* 299 */ "vtabarg ::=", |
| 172395 | /* 300 */ "vtabargtoken ::= ANY", |
| 172396 | /* 301 */ "vtabargtoken ::= lp anylist RP", |
| 172397 | /* 302 */ "lp ::= LP", |
| 172398 | /* 303 */ "with ::= WITH wqlist", |
| 172399 | /* 304 */ "with ::= WITH RECURSIVE wqlist", |
| 172400 | /* 305 */ "wqas ::= AS", |
| 172401 | /* 306 */ "wqas ::= AS MATERIALIZED", |
| 172402 | /* 307 */ "wqas ::= AS NOT MATERIALIZED", |
| 172403 | /* 308 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 172404 | /* 309 */ "wqlist ::= wqitem", |
| 172405 | /* 310 */ "wqlist ::= wqlist COMMA wqitem", |
| 172406 | /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 172407 | /* 312 */ "windowdefn ::= nm AS LP window RP", |
| 172408 | /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 172409 | /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 172410 | /* 315 */ "window ::= ORDER BY sortlist frame_opt", |
| 172411 | /* 316 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 172412 | /* 317 */ "window ::= nm frame_opt", |
| 172413 | /* 318 */ "frame_opt ::=", |
| 172414 | /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 172415 | /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 172416 | /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 172417 | /* 322 */ "frame_bound_s ::= frame_bound", |
| 172418 | /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 172419 | /* 324 */ "frame_bound_e ::= frame_bound", |
| 172420 | /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 172421 | /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 172422 | /* 327 */ "frame_bound ::= CURRENT ROW", |
| 172423 | /* 328 */ "frame_exclude_opt ::=", |
| 172424 | /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 172425 | /* 330 */ "frame_exclude ::= NO OTHERS", |
| 172426 | /* 331 */ "frame_exclude ::= CURRENT ROW", |
| 172427 | /* 332 */ "frame_exclude ::= GROUP|TIES", |
| 172428 | /* 333 */ "window_clause ::= WINDOW windowdefn_list", |
| 172429 | /* 334 */ "filter_over ::= filter_clause over_clause", |
| 172430 | /* 335 */ "filter_over ::= over_clause", |
| 172431 | /* 336 */ "filter_over ::= filter_clause", |
| 172432 | /* 337 */ "over_clause ::= OVER LP window RP", |
| 172433 | /* 338 */ "over_clause ::= OVER nm", |
| 172434 | /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 172435 | /* 340 */ "input ::= cmdlist", |
| 172436 | /* 341 */ "cmdlist ::= cmdlist ecmd", |
| 172437 | /* 342 */ "cmdlist ::= ecmd", |
| 172438 | /* 343 */ "ecmd ::= SEMI", |
| 172439 | /* 344 */ "ecmd ::= cmdx SEMI", |
| 172440 | /* 345 */ "ecmd ::= explain cmdx SEMI", |
| 172441 | /* 346 */ "trans_opt ::=", |
| 172442 | /* 347 */ "trans_opt ::= TRANSACTION", |
| 172443 | /* 348 */ "trans_opt ::= TRANSACTION nm", |
| 172444 | /* 349 */ "savepoint_opt ::= SAVEPOINT", |
| 172445 | /* 350 */ "savepoint_opt ::=", |
| 172446 | /* 351 */ "cmd ::= create_table create_table_args", |
| 172447 | /* 352 */ "table_option_set ::= table_option", |
| 172448 | /* 353 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 172449 | /* 354 */ "columnlist ::= columnname carglist", |
| 172450 | /* 355 */ "nm ::= ID|INDEXED|JOIN_KW", |
| 172451 | /* 356 */ "nm ::= STRING", |
| 172452 | /* 357 */ "typetoken ::= typename", |
| 172453 | /* 358 */ "typename ::= ID|STRING", |
| 172454 | /* 359 */ "signed ::= plus_num", |
| 172455 | /* 360 */ "signed ::= minus_num", |
| 172456 | /* 361 */ "carglist ::= carglist ccons", |
| 172457 | /* 362 */ "carglist ::=", |
| 172458 | /* 363 */ "ccons ::= NULL onconf", |
| 172459 | /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 172460 | /* 365 */ "ccons ::= AS generated", |
| 172461 | /* 366 */ "conslist_opt ::= COMMA conslist", |
| 172462 | /* 367 */ "conslist ::= conslist tconscomma tcons", |
| 172463 | /* 368 */ "conslist ::= tcons", |
| 172464 | /* 369 */ "tconscomma ::=", |
| 172465 | /* 370 */ "defer_subclause_opt ::= defer_subclause", |
| 172466 | /* 371 */ "resolvetype ::= raisetype", |
| 172467 | /* 372 */ "selectnowith ::= oneselect", |
| 172468 | /* 373 */ "oneselect ::= values", |
| 172469 | /* 374 */ "sclp ::= selcollist COMMA", |
| 172470 | /* 375 */ "as ::= ID|STRING", |
| 172471 | /* 376 */ "indexed_opt ::= indexed_by", |
| 172472 | /* 377 */ "returning ::=", |
| 172473 | /* 378 */ "expr ::= term", |
| 172474 | /* 379 */ "likeop ::= LIKE_KW|MATCH", |
| 172475 | /* 380 */ "case_operand ::= expr", |
| 172476 | /* 381 */ "exprlist ::= nexprlist", |
| 172477 | /* 382 */ "nmnum ::= plus_num", |
| 172478 | /* 383 */ "nmnum ::= nm", |
| 172479 | /* 384 */ "nmnum ::= ON", |
| 172480 | /* 385 */ "nmnum ::= DELETE", |
| 172481 | /* 386 */ "nmnum ::= DEFAULT", |
| 172482 | /* 387 */ "plus_num ::= INTEGER|FLOAT", |
| 172483 | /* 388 */ "foreach_clause ::=", |
| 172484 | /* 389 */ "foreach_clause ::= FOR EACH ROW", |
| 172485 | /* 390 */ "trnm ::= nm", |
| 172486 | /* 391 */ "tridxby ::=", |
| 172487 | /* 392 */ "database_kw_opt ::= DATABASE", |
| 172488 | /* 393 */ "database_kw_opt ::=", |
| 172489 | /* 394 */ "kwcolumn_opt ::=", |
| 172490 | /* 395 */ "kwcolumn_opt ::= COLUMNKW", |
| 172491 | /* 396 */ "vtabarglist ::= vtabarg", |
| 172492 | /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 172493 | /* 398 */ "vtabarg ::= vtabarg vtabargtoken", |
| 172494 | /* 399 */ "anylist ::=", |
| 172495 | /* 400 */ "anylist ::= anylist LP anylist RP", |
| 172496 | /* 401 */ "anylist ::= anylist ANY", |
| 172497 | /* 402 */ "with ::=", |
| 172498 | /* 403 */ "windowdefn_list ::= windowdefn", |
| 172499 | /* 404 */ "window ::= frame_opt", |
| 172500 | }; |
| 172501 | #endif /* NDEBUG */ |
| 172502 | |
| 172503 | |
| 172504 | #if YYSTACKDEPTH<=0 |
| @@ -172136,225 +173189,227 @@ | |
| 173189 | 216, /* (183) term ::= INTEGER */ |
| 173190 | 217, /* (184) expr ::= VARIABLE */ |
| 173191 | 217, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 173192 | 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 173193 | 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 173194 | 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 173195 | 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 173196 | 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 173197 | 217, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 173198 | 217, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 173199 | 216, /* (193) term ::= CTIME_KW */ |
| 173200 | 217, /* (194) expr ::= LP nexprlist COMMA expr RP */ |
| 173201 | 217, /* (195) expr ::= expr AND expr */ |
| 173202 | 217, /* (196) expr ::= expr OR expr */ |
| 173203 | 217, /* (197) expr ::= expr LT|GT|GE|LE expr */ |
| 173204 | 217, /* (198) expr ::= expr EQ|NE expr */ |
| 173205 | 217, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 173206 | 217, /* (200) expr ::= expr PLUS|MINUS expr */ |
| 173207 | 217, /* (201) expr ::= expr STAR|SLASH|REM expr */ |
| 173208 | 217, /* (202) expr ::= expr CONCAT expr */ |
| 173209 | 274, /* (203) likeop ::= NOT LIKE_KW|MATCH */ |
| 173210 | 217, /* (204) expr ::= expr likeop expr */ |
| 173211 | 217, /* (205) expr ::= expr likeop expr ESCAPE expr */ |
| 173212 | 217, /* (206) expr ::= expr ISNULL|NOTNULL */ |
| 173213 | 217, /* (207) expr ::= expr NOT NULL */ |
| 173214 | 217, /* (208) expr ::= expr IS expr */ |
| 173215 | 217, /* (209) expr ::= expr IS NOT expr */ |
| 173216 | 217, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ |
| 173217 | 217, /* (211) expr ::= expr IS DISTINCT FROM expr */ |
| 173218 | 217, /* (212) expr ::= NOT expr */ |
| 173219 | 217, /* (213) expr ::= BITNOT expr */ |
| 173220 | 217, /* (214) expr ::= PLUS|MINUS expr */ |
| 173221 | 217, /* (215) expr ::= expr PTR expr */ |
| 173222 | 275, /* (216) between_op ::= BETWEEN */ |
| 173223 | 275, /* (217) between_op ::= NOT BETWEEN */ |
| 173224 | 217, /* (218) expr ::= expr between_op expr AND expr */ |
| 173225 | 276, /* (219) in_op ::= IN */ |
| 173226 | 276, /* (220) in_op ::= NOT IN */ |
| 173227 | 217, /* (221) expr ::= expr in_op LP exprlist RP */ |
| 173228 | 217, /* (222) expr ::= LP select RP */ |
| 173229 | 217, /* (223) expr ::= expr in_op LP select RP */ |
| 173230 | 217, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 173231 | 217, /* (225) expr ::= EXISTS LP select RP */ |
| 173232 | 217, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ |
| 173233 | 279, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 173234 | 279, /* (228) case_exprlist ::= WHEN expr THEN expr */ |
| 173235 | 280, /* (229) case_else ::= ELSE expr */ |
| 173236 | 280, /* (230) case_else ::= */ |
| 173237 | 278, /* (231) case_operand ::= */ |
| 173238 | 261, /* (232) exprlist ::= */ |
| 173239 | 253, /* (233) nexprlist ::= nexprlist COMMA expr */ |
| 173240 | 253, /* (234) nexprlist ::= expr */ |
| 173241 | 277, /* (235) paren_exprlist ::= */ |
| 173242 | 277, /* (236) paren_exprlist ::= LP exprlist RP */ |
| 173243 | 190, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 173244 | 281, /* (238) uniqueflag ::= UNIQUE */ |
| 173245 | 281, /* (239) uniqueflag ::= */ |
| 173246 | 221, /* (240) eidlist_opt ::= */ |
| 173247 | 221, /* (241) eidlist_opt ::= LP eidlist RP */ |
| 173248 | 232, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 173249 | 232, /* (243) eidlist ::= nm collate sortorder */ |
| 173250 | 282, /* (244) collate ::= */ |
| 173251 | 282, /* (245) collate ::= COLLATE ID|STRING */ |
| 173252 | 190, /* (246) cmd ::= DROP INDEX ifexists fullname */ |
| 173253 | 190, /* (247) cmd ::= VACUUM vinto */ |
| 173254 | 190, /* (248) cmd ::= VACUUM nm vinto */ |
| 173255 | 283, /* (249) vinto ::= INTO expr */ |
| 173256 | 283, /* (250) vinto ::= */ |
| 173257 | 190, /* (251) cmd ::= PRAGMA nm dbnm */ |
| 173258 | 190, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 173259 | 190, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 173260 | 190, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 173261 | 190, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 173262 | 211, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ |
| 173263 | 212, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ |
| 173264 | 190, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 173265 | 285, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 173266 | 287, /* (260) trigger_time ::= BEFORE|AFTER */ |
| 173267 | 287, /* (261) trigger_time ::= INSTEAD OF */ |
| 173268 | 287, /* (262) trigger_time ::= */ |
| 173269 | 288, /* (263) trigger_event ::= DELETE|INSERT */ |
| 173270 | 288, /* (264) trigger_event ::= UPDATE */ |
| 173271 | 288, /* (265) trigger_event ::= UPDATE OF idlist */ |
| 173272 | 290, /* (266) when_clause ::= */ |
| 173273 | 290, /* (267) when_clause ::= WHEN expr */ |
| 173274 | 286, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 173275 | 286, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 173276 | 292, /* (270) trnm ::= nm DOT nm */ |
| 173277 | 293, /* (271) tridxby ::= INDEXED BY nm */ |
| 173278 | 293, /* (272) tridxby ::= NOT INDEXED */ |
| 173279 | 291, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 173280 | 291, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 173281 | 291, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 173282 | 291, /* (276) trigger_cmd ::= scanpt select scanpt */ |
| 173283 | 217, /* (277) expr ::= RAISE LP IGNORE RP */ |
| 173284 | 217, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 173285 | 236, /* (279) raisetype ::= ROLLBACK */ |
| 173286 | 236, /* (280) raisetype ::= ABORT */ |
| 173287 | 236, /* (281) raisetype ::= FAIL */ |
| 173288 | 190, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ |
| 173289 | 190, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 173290 | 190, /* (284) cmd ::= DETACH database_kw_opt expr */ |
| 173291 | 295, /* (285) key_opt ::= */ |
| 173292 | 295, /* (286) key_opt ::= KEY expr */ |
| 173293 | 190, /* (287) cmd ::= REINDEX */ |
| 173294 | 190, /* (288) cmd ::= REINDEX nm dbnm */ |
| 173295 | 190, /* (289) cmd ::= ANALYZE */ |
| 173296 | 190, /* (290) cmd ::= ANALYZE nm dbnm */ |
| 173297 | 190, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 173298 | 190, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 173299 | 190, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 173300 | 296, /* (294) add_column_fullname ::= fullname */ |
| 173301 | 190, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 173302 | 190, /* (296) cmd ::= create_vtab */ |
| 173303 | 190, /* (297) cmd ::= create_vtab LP vtabarglist RP */ |
| 173304 | 298, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 173305 | 300, /* (299) vtabarg ::= */ |
| 173306 | 301, /* (300) vtabargtoken ::= ANY */ |
| 173307 | 301, /* (301) vtabargtoken ::= lp anylist RP */ |
| 173308 | 302, /* (302) lp ::= LP */ |
| 173309 | 266, /* (303) with ::= WITH wqlist */ |
| 173310 | 266, /* (304) with ::= WITH RECURSIVE wqlist */ |
| 173311 | 305, /* (305) wqas ::= AS */ |
| 173312 | 305, /* (306) wqas ::= AS MATERIALIZED */ |
| 173313 | 305, /* (307) wqas ::= AS NOT MATERIALIZED */ |
| 173314 | 304, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 173315 | 241, /* (309) wqlist ::= wqitem */ |
| 173316 | 241, /* (310) wqlist ::= wqlist COMMA wqitem */ |
| 173317 | 306, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 173318 | 307, /* (312) windowdefn ::= nm AS LP window RP */ |
| 173319 | 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 173320 | 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 173321 | 308, /* (315) window ::= ORDER BY sortlist frame_opt */ |
| 173322 | 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */ |
| 173323 | 308, /* (317) window ::= nm frame_opt */ |
| 173324 | 309, /* (318) frame_opt ::= */ |
| 173325 | 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 173326 | 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 173327 | 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 173328 | 315, /* (322) frame_bound_s ::= frame_bound */ |
| 173329 | 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 173330 | 316, /* (324) frame_bound_e ::= frame_bound */ |
| 173331 | 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 173332 | 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 173333 | 314, /* (327) frame_bound ::= CURRENT ROW */ |
| 173334 | 317, /* (328) frame_exclude_opt ::= */ |
| 173335 | 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 173336 | 318, /* (330) frame_exclude ::= NO OTHERS */ |
| 173337 | 318, /* (331) frame_exclude ::= CURRENT ROW */ |
| 173338 | 318, /* (332) frame_exclude ::= GROUP|TIES */ |
| 173339 | 251, /* (333) window_clause ::= WINDOW windowdefn_list */ |
| 173340 | 273, /* (334) filter_over ::= filter_clause over_clause */ |
| 173341 | 273, /* (335) filter_over ::= over_clause */ |
| 173342 | 273, /* (336) filter_over ::= filter_clause */ |
| 173343 | 312, /* (337) over_clause ::= OVER LP window RP */ |
| 173344 | 312, /* (338) over_clause ::= OVER nm */ |
| 173345 | 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ |
| 173346 | 185, /* (340) input ::= cmdlist */ |
| 173347 | 186, /* (341) cmdlist ::= cmdlist ecmd */ |
| 173348 | 186, /* (342) cmdlist ::= ecmd */ |
| 173349 | 187, /* (343) ecmd ::= SEMI */ |
| 173350 | 187, /* (344) ecmd ::= cmdx SEMI */ |
| 173351 | 187, /* (345) ecmd ::= explain cmdx SEMI */ |
| 173352 | 192, /* (346) trans_opt ::= */ |
| 173353 | 192, /* (347) trans_opt ::= TRANSACTION */ |
| 173354 | 192, /* (348) trans_opt ::= TRANSACTION nm */ |
| 173355 | 194, /* (349) savepoint_opt ::= SAVEPOINT */ |
| 173356 | 194, /* (350) savepoint_opt ::= */ |
| 173357 | 190, /* (351) cmd ::= create_table create_table_args */ |
| 173358 | 203, /* (352) table_option_set ::= table_option */ |
| 173359 | 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */ |
| 173360 | 201, /* (354) columnlist ::= columnname carglist */ |
| 173361 | 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */ |
| 173362 | 193, /* (356) nm ::= STRING */ |
| 173363 | 208, /* (357) typetoken ::= typename */ |
| 173364 | 209, /* (358) typename ::= ID|STRING */ |
| 173365 | 210, /* (359) signed ::= plus_num */ |
| 173366 | 210, /* (360) signed ::= minus_num */ |
| 173367 | 207, /* (361) carglist ::= carglist ccons */ |
| 173368 | 207, /* (362) carglist ::= */ |
| 173369 | 215, /* (363) ccons ::= NULL onconf */ |
| 173370 | 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 173371 | 215, /* (365) ccons ::= AS generated */ |
| 173372 | 202, /* (366) conslist_opt ::= COMMA conslist */ |
| 173373 | 228, /* (367) conslist ::= conslist tconscomma tcons */ |
| 173374 | 228, /* (368) conslist ::= tcons */ |
| 173375 | 229, /* (369) tconscomma ::= */ |
| 173376 | 233, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 173377 | 235, /* (371) resolvetype ::= raisetype */ |
| 173378 | 239, /* (372) selectnowith ::= oneselect */ |
| 173379 | 240, /* (373) oneselect ::= values */ |
| 173380 | 254, /* (374) sclp ::= selcollist COMMA */ |
| 173381 | 255, /* (375) as ::= ID|STRING */ |
| 173382 | 264, /* (376) indexed_opt ::= indexed_by */ |
| 173383 | 272, /* (377) returning ::= */ |
| 173384 | 217, /* (378) expr ::= term */ |
| 173385 | 274, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 173386 | 278, /* (380) case_operand ::= expr */ |
| 173387 | 261, /* (381) exprlist ::= nexprlist */ |
| 173388 | 284, /* (382) nmnum ::= plus_num */ |
| 173389 | 284, /* (383) nmnum ::= nm */ |
| 173390 | 284, /* (384) nmnum ::= ON */ |
| 173391 | 284, /* (385) nmnum ::= DELETE */ |
| 173392 | 284, /* (386) nmnum ::= DEFAULT */ |
| 173393 | 211, /* (387) plus_num ::= INTEGER|FLOAT */ |
| 173394 | 289, /* (388) foreach_clause ::= */ |
| 173395 | 289, /* (389) foreach_clause ::= FOR EACH ROW */ |
| 173396 | 292, /* (390) trnm ::= nm */ |
| 173397 | 293, /* (391) tridxby ::= */ |
| 173398 | 294, /* (392) database_kw_opt ::= DATABASE */ |
| 173399 | 294, /* (393) database_kw_opt ::= */ |
| 173400 | 297, /* (394) kwcolumn_opt ::= */ |
| 173401 | 297, /* (395) kwcolumn_opt ::= COLUMNKW */ |
| 173402 | 299, /* (396) vtabarglist ::= vtabarg */ |
| 173403 | 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 173404 | 300, /* (398) vtabarg ::= vtabarg vtabargtoken */ |
| 173405 | 303, /* (399) anylist ::= */ |
| 173406 | 303, /* (400) anylist ::= anylist LP anylist RP */ |
| 173407 | 303, /* (401) anylist ::= anylist ANY */ |
| 173408 | 266, /* (402) with ::= */ |
| 173409 | 306, /* (403) windowdefn_list ::= windowdefn */ |
| 173410 | 308, /* (404) window ::= frame_opt */ |
| 173411 | }; |
| 173412 | |
| 173413 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| 173414 | ** of symbols on the right-hand side of that rule. */ |
| 173415 | static const signed char yyRuleInfoNRhs[] = { |
| @@ -172544,225 +173599,227 @@ | |
| 173599 | -1, /* (183) term ::= INTEGER */ |
| 173600 | -1, /* (184) expr ::= VARIABLE */ |
| 173601 | -3, /* (185) expr ::= expr COLLATE ID|STRING */ |
| 173602 | -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ |
| 173603 | -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ |
| 173604 | -8, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 173605 | -4, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 173606 | -6, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 173607 | -9, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 173608 | -5, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 173609 | -1, /* (193) term ::= CTIME_KW */ |
| 173610 | -5, /* (194) expr ::= LP nexprlist COMMA expr RP */ |
| 173611 | -3, /* (195) expr ::= expr AND expr */ |
| 173612 | -3, /* (196) expr ::= expr OR expr */ |
| 173613 | -3, /* (197) expr ::= expr LT|GT|GE|LE expr */ |
| 173614 | -3, /* (198) expr ::= expr EQ|NE expr */ |
| 173615 | -3, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 173616 | -3, /* (200) expr ::= expr PLUS|MINUS expr */ |
| 173617 | -3, /* (201) expr ::= expr STAR|SLASH|REM expr */ |
| 173618 | -3, /* (202) expr ::= expr CONCAT expr */ |
| 173619 | -2, /* (203) likeop ::= NOT LIKE_KW|MATCH */ |
| 173620 | -3, /* (204) expr ::= expr likeop expr */ |
| 173621 | -5, /* (205) expr ::= expr likeop expr ESCAPE expr */ |
| 173622 | -2, /* (206) expr ::= expr ISNULL|NOTNULL */ |
| 173623 | -3, /* (207) expr ::= expr NOT NULL */ |
| 173624 | -3, /* (208) expr ::= expr IS expr */ |
| 173625 | -4, /* (209) expr ::= expr IS NOT expr */ |
| 173626 | -6, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ |
| 173627 | -5, /* (211) expr ::= expr IS DISTINCT FROM expr */ |
| 173628 | -2, /* (212) expr ::= NOT expr */ |
| 173629 | -2, /* (213) expr ::= BITNOT expr */ |
| 173630 | -2, /* (214) expr ::= PLUS|MINUS expr */ |
| 173631 | -3, /* (215) expr ::= expr PTR expr */ |
| 173632 | -1, /* (216) between_op ::= BETWEEN */ |
| 173633 | -2, /* (217) between_op ::= NOT BETWEEN */ |
| 173634 | -5, /* (218) expr ::= expr between_op expr AND expr */ |
| 173635 | -1, /* (219) in_op ::= IN */ |
| 173636 | -2, /* (220) in_op ::= NOT IN */ |
| 173637 | -5, /* (221) expr ::= expr in_op LP exprlist RP */ |
| 173638 | -3, /* (222) expr ::= LP select RP */ |
| 173639 | -5, /* (223) expr ::= expr in_op LP select RP */ |
| 173640 | -5, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 173641 | -4, /* (225) expr ::= EXISTS LP select RP */ |
| 173642 | -5, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ |
| 173643 | -5, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 173644 | -4, /* (228) case_exprlist ::= WHEN expr THEN expr */ |
| 173645 | -2, /* (229) case_else ::= ELSE expr */ |
| 173646 | 0, /* (230) case_else ::= */ |
| 173647 | 0, /* (231) case_operand ::= */ |
| 173648 | 0, /* (232) exprlist ::= */ |
| 173649 | -3, /* (233) nexprlist ::= nexprlist COMMA expr */ |
| 173650 | -1, /* (234) nexprlist ::= expr */ |
| 173651 | 0, /* (235) paren_exprlist ::= */ |
| 173652 | -3, /* (236) paren_exprlist ::= LP exprlist RP */ |
| 173653 | -12, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 173654 | -1, /* (238) uniqueflag ::= UNIQUE */ |
| 173655 | 0, /* (239) uniqueflag ::= */ |
| 173656 | 0, /* (240) eidlist_opt ::= */ |
| 173657 | -3, /* (241) eidlist_opt ::= LP eidlist RP */ |
| 173658 | -5, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 173659 | -3, /* (243) eidlist ::= nm collate sortorder */ |
| 173660 | 0, /* (244) collate ::= */ |
| 173661 | -2, /* (245) collate ::= COLLATE ID|STRING */ |
| 173662 | -4, /* (246) cmd ::= DROP INDEX ifexists fullname */ |
| 173663 | -2, /* (247) cmd ::= VACUUM vinto */ |
| 173664 | -3, /* (248) cmd ::= VACUUM nm vinto */ |
| 173665 | -2, /* (249) vinto ::= INTO expr */ |
| 173666 | 0, /* (250) vinto ::= */ |
| 173667 | -3, /* (251) cmd ::= PRAGMA nm dbnm */ |
| 173668 | -5, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 173669 | -6, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 173670 | -5, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 173671 | -6, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 173672 | -2, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ |
| 173673 | -2, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ |
| 173674 | -5, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 173675 | -11, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 173676 | -1, /* (260) trigger_time ::= BEFORE|AFTER */ |
| 173677 | -2, /* (261) trigger_time ::= INSTEAD OF */ |
| 173678 | 0, /* (262) trigger_time ::= */ |
| 173679 | -1, /* (263) trigger_event ::= DELETE|INSERT */ |
| 173680 | -1, /* (264) trigger_event ::= UPDATE */ |
| 173681 | -3, /* (265) trigger_event ::= UPDATE OF idlist */ |
| 173682 | 0, /* (266) when_clause ::= */ |
| 173683 | -2, /* (267) when_clause ::= WHEN expr */ |
| 173684 | -3, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 173685 | -2, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 173686 | -3, /* (270) trnm ::= nm DOT nm */ |
| 173687 | -3, /* (271) tridxby ::= INDEXED BY nm */ |
| 173688 | -2, /* (272) tridxby ::= NOT INDEXED */ |
| 173689 | -9, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 173690 | -8, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 173691 | -6, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 173692 | -3, /* (276) trigger_cmd ::= scanpt select scanpt */ |
| 173693 | -4, /* (277) expr ::= RAISE LP IGNORE RP */ |
| 173694 | -6, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 173695 | -1, /* (279) raisetype ::= ROLLBACK */ |
| 173696 | -1, /* (280) raisetype ::= ABORT */ |
| 173697 | -1, /* (281) raisetype ::= FAIL */ |
| 173698 | -4, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ |
| 173699 | -6, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 173700 | -3, /* (284) cmd ::= DETACH database_kw_opt expr */ |
| 173701 | 0, /* (285) key_opt ::= */ |
| 173702 | -2, /* (286) key_opt ::= KEY expr */ |
| 173703 | -1, /* (287) cmd ::= REINDEX */ |
| 173704 | -3, /* (288) cmd ::= REINDEX nm dbnm */ |
| 173705 | -1, /* (289) cmd ::= ANALYZE */ |
| 173706 | -3, /* (290) cmd ::= ANALYZE nm dbnm */ |
| 173707 | -6, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 173708 | -7, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 173709 | -6, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 173710 | -1, /* (294) add_column_fullname ::= fullname */ |
| 173711 | -8, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 173712 | -1, /* (296) cmd ::= create_vtab */ |
| 173713 | -4, /* (297) cmd ::= create_vtab LP vtabarglist RP */ |
| 173714 | -8, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 173715 | 0, /* (299) vtabarg ::= */ |
| 173716 | -1, /* (300) vtabargtoken ::= ANY */ |
| 173717 | -3, /* (301) vtabargtoken ::= lp anylist RP */ |
| 173718 | -1, /* (302) lp ::= LP */ |
| 173719 | -2, /* (303) with ::= WITH wqlist */ |
| 173720 | -3, /* (304) with ::= WITH RECURSIVE wqlist */ |
| 173721 | -1, /* (305) wqas ::= AS */ |
| 173722 | -2, /* (306) wqas ::= AS MATERIALIZED */ |
| 173723 | -3, /* (307) wqas ::= AS NOT MATERIALIZED */ |
| 173724 | -6, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 173725 | -1, /* (309) wqlist ::= wqitem */ |
| 173726 | -3, /* (310) wqlist ::= wqlist COMMA wqitem */ |
| 173727 | -3, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 173728 | -5, /* (312) windowdefn ::= nm AS LP window RP */ |
| 173729 | -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 173730 | -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 173731 | -4, /* (315) window ::= ORDER BY sortlist frame_opt */ |
| 173732 | -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */ |
| 173733 | -2, /* (317) window ::= nm frame_opt */ |
| 173734 | 0, /* (318) frame_opt ::= */ |
| 173735 | -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 173736 | -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 173737 | -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 173738 | -1, /* (322) frame_bound_s ::= frame_bound */ |
| 173739 | -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 173740 | -1, /* (324) frame_bound_e ::= frame_bound */ |
| 173741 | -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 173742 | -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 173743 | -2, /* (327) frame_bound ::= CURRENT ROW */ |
| 173744 | 0, /* (328) frame_exclude_opt ::= */ |
| 173745 | -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 173746 | -2, /* (330) frame_exclude ::= NO OTHERS */ |
| 173747 | -2, /* (331) frame_exclude ::= CURRENT ROW */ |
| 173748 | -1, /* (332) frame_exclude ::= GROUP|TIES */ |
| 173749 | -2, /* (333) window_clause ::= WINDOW windowdefn_list */ |
| 173750 | -2, /* (334) filter_over ::= filter_clause over_clause */ |
| 173751 | -1, /* (335) filter_over ::= over_clause */ |
| 173752 | -1, /* (336) filter_over ::= filter_clause */ |
| 173753 | -4, /* (337) over_clause ::= OVER LP window RP */ |
| 173754 | -2, /* (338) over_clause ::= OVER nm */ |
| 173755 | -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ |
| 173756 | -1, /* (340) input ::= cmdlist */ |
| 173757 | -2, /* (341) cmdlist ::= cmdlist ecmd */ |
| 173758 | -1, /* (342) cmdlist ::= ecmd */ |
| 173759 | -1, /* (343) ecmd ::= SEMI */ |
| 173760 | -2, /* (344) ecmd ::= cmdx SEMI */ |
| 173761 | -3, /* (345) ecmd ::= explain cmdx SEMI */ |
| 173762 | 0, /* (346) trans_opt ::= */ |
| 173763 | -1, /* (347) trans_opt ::= TRANSACTION */ |
| 173764 | -2, /* (348) trans_opt ::= TRANSACTION nm */ |
| 173765 | -1, /* (349) savepoint_opt ::= SAVEPOINT */ |
| 173766 | 0, /* (350) savepoint_opt ::= */ |
| 173767 | -2, /* (351) cmd ::= create_table create_table_args */ |
| 173768 | -1, /* (352) table_option_set ::= table_option */ |
| 173769 | -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */ |
| 173770 | -2, /* (354) columnlist ::= columnname carglist */ |
| 173771 | -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */ |
| 173772 | -1, /* (356) nm ::= STRING */ |
| 173773 | -1, /* (357) typetoken ::= typename */ |
| 173774 | -1, /* (358) typename ::= ID|STRING */ |
| 173775 | -1, /* (359) signed ::= plus_num */ |
| 173776 | -1, /* (360) signed ::= minus_num */ |
| 173777 | -2, /* (361) carglist ::= carglist ccons */ |
| 173778 | 0, /* (362) carglist ::= */ |
| 173779 | -2, /* (363) ccons ::= NULL onconf */ |
| 173780 | -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 173781 | -2, /* (365) ccons ::= AS generated */ |
| 173782 | -2, /* (366) conslist_opt ::= COMMA conslist */ |
| 173783 | -3, /* (367) conslist ::= conslist tconscomma tcons */ |
| 173784 | -1, /* (368) conslist ::= tcons */ |
| 173785 | 0, /* (369) tconscomma ::= */ |
| 173786 | -1, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 173787 | -1, /* (371) resolvetype ::= raisetype */ |
| 173788 | -1, /* (372) selectnowith ::= oneselect */ |
| 173789 | -1, /* (373) oneselect ::= values */ |
| 173790 | -2, /* (374) sclp ::= selcollist COMMA */ |
| 173791 | -1, /* (375) as ::= ID|STRING */ |
| 173792 | -1, /* (376) indexed_opt ::= indexed_by */ |
| 173793 | 0, /* (377) returning ::= */ |
| 173794 | -1, /* (378) expr ::= term */ |
| 173795 | -1, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 173796 | -1, /* (380) case_operand ::= expr */ |
| 173797 | -1, /* (381) exprlist ::= nexprlist */ |
| 173798 | -1, /* (382) nmnum ::= plus_num */ |
| 173799 | -1, /* (383) nmnum ::= nm */ |
| 173800 | -1, /* (384) nmnum ::= ON */ |
| 173801 | -1, /* (385) nmnum ::= DELETE */ |
| 173802 | -1, /* (386) nmnum ::= DEFAULT */ |
| 173803 | -1, /* (387) plus_num ::= INTEGER|FLOAT */ |
| 173804 | 0, /* (388) foreach_clause ::= */ |
| 173805 | -3, /* (389) foreach_clause ::= FOR EACH ROW */ |
| 173806 | -1, /* (390) trnm ::= nm */ |
| 173807 | 0, /* (391) tridxby ::= */ |
| 173808 | -1, /* (392) database_kw_opt ::= DATABASE */ |
| 173809 | 0, /* (393) database_kw_opt ::= */ |
| 173810 | 0, /* (394) kwcolumn_opt ::= */ |
| 173811 | -1, /* (395) kwcolumn_opt ::= COLUMNKW */ |
| 173812 | -1, /* (396) vtabarglist ::= vtabarg */ |
| 173813 | -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 173814 | -2, /* (398) vtabarg ::= vtabarg vtabargtoken */ |
| 173815 | 0, /* (399) anylist ::= */ |
| 173816 | -4, /* (400) anylist ::= anylist LP anylist RP */ |
| 173817 | -2, /* (401) anylist ::= anylist ANY */ |
| 173818 | 0, /* (402) with ::= */ |
| 173819 | -1, /* (403) windowdefn_list ::= windowdefn */ |
| 173820 | -1, /* (404) window ::= frame_opt */ |
| 173821 | }; |
| 173822 | |
| 173823 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 173824 | |
| 173825 | /* |
| @@ -172818,11 +173875,11 @@ | |
| 173875 | {yymsp[1].minor.yy394 = TK_DEFERRED;} |
| 173876 | break; |
| 173877 | case 5: /* transtype ::= DEFERRED */ |
| 173878 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 173879 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 173880 | case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321); |
| 173881 | {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} |
| 173882 | break; |
| 173883 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 173884 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| 173885 | {sqlite3EndTransaction(pParse,yymsp[-1].major);} |
| @@ -172855,11 +173912,11 @@ | |
| 173912 | case 47: /* autoinc ::= */ yytestcase(yyruleno==47); |
| 173913 | case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62); |
| 173914 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 173915 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 173916 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); |
| 173917 | case 244: /* collate ::= */ yytestcase(yyruleno==244); |
| 173918 | {yymsp[1].minor.yy394 = 0;} |
| 173919 | break; |
| 173920 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 173921 | {yymsp[-2].minor.yy394 = 1;} |
| 173922 | break; |
| @@ -173039,13 +174096,13 @@ | |
| 174096 | case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171); |
| 174097 | {yymsp[-1].minor.yy394 = yymsp[0].minor.yy394;} |
| 174098 | break; |
| 174099 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 174100 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 174101 | case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217); |
| 174102 | case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220); |
| 174103 | case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245); |
| 174104 | {yymsp[-1].minor.yy394 = 1;} |
| 174105 | break; |
| 174106 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 174107 | {yymsp[-1].minor.yy394 = 0;} |
| 174108 | break; |
| @@ -173190,13 +174247,13 @@ | |
| 174247 | {yymsp[0].minor.yy394 = SF_All;} |
| 174248 | break; |
| 174249 | case 99: /* sclp ::= */ |
| 174250 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); |
| 174251 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); |
| 174252 | case 232: /* exprlist ::= */ yytestcase(yyruleno==232); |
| 174253 | case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235); |
| 174254 | case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240); |
| 174255 | {yymsp[1].minor.yy322 = 0;} |
| 174256 | break; |
| 174257 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 174258 | { |
| 174259 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| @@ -173221,12 +174278,12 @@ | |
| 174278 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot); |
| 174279 | } |
| 174280 | break; |
| 174281 | case 103: /* as ::= AS nm */ |
| 174282 | case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); |
| 174283 | case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256); |
| 174284 | case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257); |
| 174285 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 174286 | break; |
| 174287 | case 105: /* from ::= */ |
| 174288 | case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108); |
| 174289 | {yymsp[1].minor.yy131 = 0;} |
| @@ -173394,20 +174451,20 @@ | |
| 174451 | break; |
| 174452 | case 144: /* having_opt ::= */ |
| 174453 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 174454 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 174455 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 174456 | case 230: /* case_else ::= */ yytestcase(yyruleno==230); |
| 174457 | case 231: /* case_operand ::= */ yytestcase(yyruleno==231); |
| 174458 | case 250: /* vinto ::= */ yytestcase(yyruleno==250); |
| 174459 | {yymsp[1].minor.yy528 = 0;} |
| 174460 | break; |
| 174461 | case 145: /* having_opt ::= HAVING expr */ |
| 174462 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 174463 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 174464 | case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229); |
| 174465 | case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249); |
| 174466 | {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 174467 | break; |
| 174468 | case 147: /* limit_opt ::= LIMIT expr */ |
| 174469 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);} |
| 174470 | break; |
| @@ -173589,37 +174646,52 @@ | |
| 174646 | { |
| 174647 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy394); |
| 174648 | } |
| 174649 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 174650 | break; |
| 174651 | case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ |
| 174652 | { |
| 174653 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394); |
| 174654 | sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322); |
| 174655 | } |
| 174656 | yymsp[-7].minor.yy528 = yylhsminor.yy528; |
| 174657 | break; |
| 174658 | case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ |
| 174659 | { |
| 174660 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 174661 | } |
| 174662 | yymsp[-3].minor.yy528 = yylhsminor.yy528; |
| 174663 | break; |
| 174664 | case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ |
| 174665 | { |
| 174666 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394); |
| 174667 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 174668 | } |
| 174669 | yymsp[-5].minor.yy528 = yylhsminor.yy528; |
| 174670 | break; |
| 174671 | case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ |
| 174672 | { |
| 174673 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394); |
| 174674 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 174675 | sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322); |
| 174676 | } |
| 174677 | yymsp[-8].minor.yy528 = yylhsminor.yy528; |
| 174678 | break; |
| 174679 | case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ |
| 174680 | { |
| 174681 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 174682 | sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); |
| 174683 | } |
| 174684 | yymsp[-4].minor.yy528 = yylhsminor.yy528; |
| 174685 | break; |
| 174686 | case 193: /* term ::= CTIME_KW */ |
| 174687 | { |
| 174688 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 174689 | } |
| 174690 | yymsp[0].minor.yy528 = yylhsminor.yy528; |
| 174691 | break; |
| 174692 | case 194: /* expr ::= LP nexprlist COMMA expr RP */ |
| 174693 | { |
| 174694 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); |
| 174695 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 174696 | if( yymsp[-4].minor.yy528 ){ |
| 174697 | yymsp[-4].minor.yy528->x.pList = pList; |
| @@ -173629,26 +174701,26 @@ | |
| 174701 | }else{ |
| 174702 | sqlite3ExprListDelete(pParse->db, pList); |
| 174703 | } |
| 174704 | } |
| 174705 | break; |
| 174706 | case 195: /* expr ::= expr AND expr */ |
| 174707 | {yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 174708 | break; |
| 174709 | case 196: /* expr ::= expr OR expr */ |
| 174710 | case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197); |
| 174711 | case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198); |
| 174712 | case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199); |
| 174713 | case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200); |
| 174714 | case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201); |
| 174715 | case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202); |
| 174716 | {yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| 174717 | break; |
| 174718 | case 203: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 174719 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 174720 | break; |
| 174721 | case 204: /* expr ::= expr likeop expr */ |
| 174722 | { |
| 174723 | ExprList *pList; |
| 174724 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 174725 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 174726 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy528); |
| @@ -173656,11 +174728,11 @@ | |
| 174728 | yymsp[-2].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 174729 | if( bNot ) yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy528, 0); |
| 174730 | if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; |
| 174731 | } |
| 174732 | break; |
| 174733 | case 205: /* expr ::= expr likeop expr ESCAPE expr */ |
| 174734 | { |
| 174735 | ExprList *pList; |
| 174736 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 174737 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 174738 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| @@ -173669,63 +174741,63 @@ | |
| 174741 | yymsp[-4].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 174742 | if( bNot ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 174743 | if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; |
| 174744 | } |
| 174745 | break; |
| 174746 | case 206: /* expr ::= expr ISNULL|NOTNULL */ |
| 174747 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} |
| 174748 | break; |
| 174749 | case 207: /* expr ::= expr NOT NULL */ |
| 174750 | {yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} |
| 174751 | break; |
| 174752 | case 208: /* expr ::= expr IS expr */ |
| 174753 | { |
| 174754 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528); |
| 174755 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL); |
| 174756 | } |
| 174757 | break; |
| 174758 | case 209: /* expr ::= expr IS NOT expr */ |
| 174759 | { |
| 174760 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528); |
| 174761 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL); |
| 174762 | } |
| 174763 | break; |
| 174764 | case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */ |
| 174765 | { |
| 174766 | yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528); |
| 174767 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL); |
| 174768 | } |
| 174769 | break; |
| 174770 | case 211: /* expr ::= expr IS DISTINCT FROM expr */ |
| 174771 | { |
| 174772 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528); |
| 174773 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL); |
| 174774 | } |
| 174775 | break; |
| 174776 | case 212: /* expr ::= NOT expr */ |
| 174777 | case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213); |
| 174778 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} |
| 174779 | break; |
| 174780 | case 214: /* expr ::= PLUS|MINUS expr */ |
| 174781 | { |
| 174782 | yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); |
| 174783 | /*A-overwrites-B*/ |
| 174784 | } |
| 174785 | break; |
| 174786 | case 215: /* expr ::= expr PTR expr */ |
| 174787 | { |
| 174788 | ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); |
| 174789 | pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); |
| 174790 | yylhsminor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 174791 | } |
| 174792 | yymsp[-2].minor.yy528 = yylhsminor.yy528; |
| 174793 | break; |
| 174794 | case 216: /* between_op ::= BETWEEN */ |
| 174795 | case 219: /* in_op ::= IN */ yytestcase(yyruleno==219); |
| 174796 | {yymsp[0].minor.yy394 = 0;} |
| 174797 | break; |
| 174798 | case 218: /* expr ::= expr between_op expr AND expr */ |
| 174799 | { |
| 174800 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 174801 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); |
| 174802 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy528, 0); |
| 174803 | if( yymsp[-4].minor.yy528 ){ |
| @@ -173734,11 +174806,11 @@ | |
| 174806 | sqlite3ExprListDelete(pParse->db, pList); |
| 174807 | } |
| 174808 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 174809 | } |
| 174810 | break; |
| 174811 | case 221: /* expr ::= expr in_op LP exprlist RP */ |
| 174812 | { |
| 174813 | if( yymsp[-1].minor.yy322==0 ){ |
| 174814 | /* Expressions of the form |
| 174815 | ** |
| 174816 | ** expr1 IN () |
| @@ -173780,41 +174852,41 @@ | |
| 174852 | } |
| 174853 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 174854 | } |
| 174855 | } |
| 174856 | break; |
| 174857 | case 222: /* expr ::= LP select RP */ |
| 174858 | { |
| 174859 | yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 174860 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); |
| 174861 | } |
| 174862 | break; |
| 174863 | case 223: /* expr ::= expr in_op LP select RP */ |
| 174864 | { |
| 174865 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 174866 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47); |
| 174867 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 174868 | } |
| 174869 | break; |
| 174870 | case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 174871 | { |
| 174872 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 174873 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 174874 | if( yymsp[0].minor.yy322 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322); |
| 174875 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); |
| 174876 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelect); |
| 174877 | if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); |
| 174878 | } |
| 174879 | break; |
| 174880 | case 225: /* expr ::= EXISTS LP select RP */ |
| 174881 | { |
| 174882 | Expr *p; |
| 174883 | p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 174884 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); |
| 174885 | } |
| 174886 | break; |
| 174887 | case 226: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 174888 | { |
| 174889 | yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); |
| 174890 | if( yymsp[-4].minor.yy528 ){ |
| 174891 | yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy528 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528) : yymsp[-2].minor.yy322; |
| 174892 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528); |
| @@ -173822,392 +174894,392 @@ | |
| 174894 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 174895 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| 174896 | } |
| 174897 | } |
| 174898 | break; |
| 174899 | case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 174900 | { |
| 174901 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| 174902 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528); |
| 174903 | } |
| 174904 | break; |
| 174905 | case 228: /* case_exprlist ::= WHEN expr THEN expr */ |
| 174906 | { |
| 174907 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 174908 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); |
| 174909 | } |
| 174910 | break; |
| 174911 | case 233: /* nexprlist ::= nexprlist COMMA expr */ |
| 174912 | {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} |
| 174913 | break; |
| 174914 | case 234: /* nexprlist ::= expr */ |
| 174915 | {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} |
| 174916 | break; |
| 174917 | case 236: /* paren_exprlist ::= LP exprlist RP */ |
| 174918 | case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241); |
| 174919 | {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} |
| 174920 | break; |
| 174921 | case 237: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 174922 | { |
| 174923 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 174924 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, |
| 174925 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF); |
| 174926 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 174927 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 174928 | } |
| 174929 | } |
| 174930 | break; |
| 174931 | case 238: /* uniqueflag ::= UNIQUE */ |
| 174932 | case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280); |
| 174933 | {yymsp[0].minor.yy394 = OE_Abort;} |
| 174934 | break; |
| 174935 | case 239: /* uniqueflag ::= */ |
| 174936 | {yymsp[1].minor.yy394 = OE_None;} |
| 174937 | break; |
| 174938 | case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 174939 | { |
| 174940 | yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); |
| 174941 | } |
| 174942 | break; |
| 174943 | case 243: /* eidlist ::= nm collate sortorder */ |
| 174944 | { |
| 174945 | yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ |
| 174946 | } |
| 174947 | break; |
| 174948 | case 246: /* cmd ::= DROP INDEX ifexists fullname */ |
| 174949 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} |
| 174950 | break; |
| 174951 | case 247: /* cmd ::= VACUUM vinto */ |
| 174952 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} |
| 174953 | break; |
| 174954 | case 248: /* cmd ::= VACUUM nm vinto */ |
| 174955 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} |
| 174956 | break; |
| 174957 | case 251: /* cmd ::= PRAGMA nm dbnm */ |
| 174958 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 174959 | break; |
| 174960 | case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 174961 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 174962 | break; |
| 174963 | case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 174964 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 174965 | break; |
| 174966 | case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 174967 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 174968 | break; |
| 174969 | case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 174970 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 174971 | break; |
| 174972 | case 258: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 174973 | { |
| 174974 | Token all; |
| 174975 | all.z = yymsp[-3].minor.yy0.z; |
| 174976 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 174977 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); |
| 174978 | } |
| 174979 | break; |
| 174980 | case 259: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 174981 | { |
| 174982 | 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); |
| 174983 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 174984 | } |
| 174985 | break; |
| 174986 | case 260: /* trigger_time ::= BEFORE|AFTER */ |
| 174987 | { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } |
| 174988 | break; |
| 174989 | case 261: /* trigger_time ::= INSTEAD OF */ |
| 174990 | { yymsp[-1].minor.yy394 = TK_INSTEAD;} |
| 174991 | break; |
| 174992 | case 262: /* trigger_time ::= */ |
| 174993 | { yymsp[1].minor.yy394 = TK_BEFORE; } |
| 174994 | break; |
| 174995 | case 263: /* trigger_event ::= DELETE|INSERT */ |
| 174996 | case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264); |
| 174997 | {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} |
| 174998 | break; |
| 174999 | case 265: /* trigger_event ::= UPDATE OF idlist */ |
| 175000 | {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} |
| 175001 | break; |
| 175002 | case 266: /* when_clause ::= */ |
| 175003 | case 285: /* key_opt ::= */ yytestcase(yyruleno==285); |
| 175004 | { yymsp[1].minor.yy528 = 0; } |
| 175005 | break; |
| 175006 | case 267: /* when_clause ::= WHEN expr */ |
| 175007 | case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286); |
| 175008 | { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } |
| 175009 | break; |
| 175010 | case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 175011 | { |
| 175012 | assert( yymsp[-2].minor.yy33!=0 ); |
| 175013 | yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; |
| 175014 | yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 175015 | } |
| 175016 | break; |
| 175017 | case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 175018 | { |
| 175019 | assert( yymsp[-1].minor.yy33!=0 ); |
| 175020 | yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 175021 | } |
| 175022 | break; |
| 175023 | case 270: /* trnm ::= nm DOT nm */ |
| 175024 | { |
| 175025 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 175026 | sqlite3ErrorMsg(pParse, |
| 175027 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 175028 | "statements within triggers"); |
| 175029 | } |
| 175030 | break; |
| 175031 | case 271: /* tridxby ::= INDEXED BY nm */ |
| 175032 | { |
| 175033 | sqlite3ErrorMsg(pParse, |
| 175034 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 175035 | "within triggers"); |
| 175036 | } |
| 175037 | break; |
| 175038 | case 272: /* tridxby ::= NOT INDEXED */ |
| 175039 | { |
| 175040 | sqlite3ErrorMsg(pParse, |
| 175041 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 175042 | "within triggers"); |
| 175043 | } |
| 175044 | break; |
| 175045 | case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 175046 | {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);} |
| 175047 | yymsp[-8].minor.yy33 = yylhsminor.yy33; |
| 175048 | break; |
| 175049 | case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 175050 | { |
| 175051 | 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*/ |
| 175052 | } |
| 175053 | yymsp[-7].minor.yy33 = yylhsminor.yy33; |
| 175054 | break; |
| 175055 | case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 175056 | {yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} |
| 175057 | yymsp[-5].minor.yy33 = yylhsminor.yy33; |
| 175058 | break; |
| 175059 | case 276: /* trigger_cmd ::= scanpt select scanpt */ |
| 175060 | {yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/} |
| 175061 | yymsp[-2].minor.yy33 = yylhsminor.yy33; |
| 175062 | break; |
| 175063 | case 277: /* expr ::= RAISE LP IGNORE RP */ |
| 175064 | { |
| 175065 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 175066 | if( yymsp[-3].minor.yy528 ){ |
| 175067 | yymsp[-3].minor.yy528->affExpr = OE_Ignore; |
| 175068 | } |
| 175069 | } |
| 175070 | break; |
| 175071 | case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 175072 | { |
| 175073 | yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 175074 | if( yymsp[-5].minor.yy528 ) { |
| 175075 | yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394; |
| 175076 | } |
| 175077 | } |
| 175078 | break; |
| 175079 | case 279: /* raisetype ::= ROLLBACK */ |
| 175080 | {yymsp[0].minor.yy394 = OE_Rollback;} |
| 175081 | break; |
| 175082 | case 281: /* raisetype ::= FAIL */ |
| 175083 | {yymsp[0].minor.yy394 = OE_Fail;} |
| 175084 | break; |
| 175085 | case 282: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 175086 | { |
| 175087 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); |
| 175088 | } |
| 175089 | break; |
| 175090 | case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 175091 | { |
| 175092 | sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); |
| 175093 | } |
| 175094 | break; |
| 175095 | case 284: /* cmd ::= DETACH database_kw_opt expr */ |
| 175096 | { |
| 175097 | sqlite3Detach(pParse, yymsp[0].minor.yy528); |
| 175098 | } |
| 175099 | break; |
| 175100 | case 287: /* cmd ::= REINDEX */ |
| 175101 | {sqlite3Reindex(pParse, 0, 0);} |
| 175102 | break; |
| 175103 | case 288: /* cmd ::= REINDEX nm dbnm */ |
| 175104 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 175105 | break; |
| 175106 | case 289: /* cmd ::= ANALYZE */ |
| 175107 | {sqlite3Analyze(pParse, 0, 0);} |
| 175108 | break; |
| 175109 | case 290: /* cmd ::= ANALYZE nm dbnm */ |
| 175110 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 175111 | break; |
| 175112 | case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 175113 | { |
| 175114 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); |
| 175115 | } |
| 175116 | break; |
| 175117 | case 292: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 175118 | { |
| 175119 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 175120 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 175121 | } |
| 175122 | break; |
| 175123 | case 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 175124 | { |
| 175125 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); |
| 175126 | } |
| 175127 | break; |
| 175128 | case 294: /* add_column_fullname ::= fullname */ |
| 175129 | { |
| 175130 | disableLookaside(pParse); |
| 175131 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); |
| 175132 | } |
| 175133 | break; |
| 175134 | case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 175135 | { |
| 175136 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 175137 | } |
| 175138 | break; |
| 175139 | case 296: /* cmd ::= create_vtab */ |
| 175140 | {sqlite3VtabFinishParse(pParse,0);} |
| 175141 | break; |
| 175142 | case 297: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 175143 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 175144 | break; |
| 175145 | case 298: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 175146 | { |
| 175147 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); |
| 175148 | } |
| 175149 | break; |
| 175150 | case 299: /* vtabarg ::= */ |
| 175151 | {sqlite3VtabArgInit(pParse);} |
| 175152 | break; |
| 175153 | case 300: /* vtabargtoken ::= ANY */ |
| 175154 | case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301); |
| 175155 | case 302: /* lp ::= LP */ yytestcase(yyruleno==302); |
| 175156 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 175157 | break; |
| 175158 | case 303: /* with ::= WITH wqlist */ |
| 175159 | case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304); |
| 175160 | { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } |
| 175161 | break; |
| 175162 | case 305: /* wqas ::= AS */ |
| 175163 | {yymsp[0].minor.yy516 = M10d_Any;} |
| 175164 | break; |
| 175165 | case 306: /* wqas ::= AS MATERIALIZED */ |
| 175166 | {yymsp[-1].minor.yy516 = M10d_Yes;} |
| 175167 | break; |
| 175168 | case 307: /* wqas ::= AS NOT MATERIALIZED */ |
| 175169 | {yymsp[-2].minor.yy516 = M10d_No;} |
| 175170 | break; |
| 175171 | case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 175172 | { |
| 175173 | 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*/ |
| 175174 | } |
| 175175 | break; |
| 175176 | case 309: /* wqlist ::= wqitem */ |
| 175177 | { |
| 175178 | yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ |
| 175179 | } |
| 175180 | break; |
| 175181 | case 310: /* wqlist ::= wqlist COMMA wqitem */ |
| 175182 | { |
| 175183 | yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); |
| 175184 | } |
| 175185 | break; |
| 175186 | case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 175187 | { |
| 175188 | assert( yymsp[0].minor.yy41!=0 ); |
| 175189 | sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); |
| 175190 | yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41; |
| 175191 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 175192 | } |
| 175193 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 175194 | break; |
| 175195 | case 312: /* windowdefn ::= nm AS LP window RP */ |
| 175196 | { |
| 175197 | if( ALWAYS(yymsp[-1].minor.yy41) ){ |
| 175198 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 175199 | } |
| 175200 | yylhsminor.yy41 = yymsp[-1].minor.yy41; |
| 175201 | } |
| 175202 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 175203 | break; |
| 175204 | case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 175205 | { |
| 175206 | yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); |
| 175207 | } |
| 175208 | break; |
| 175209 | case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 175210 | { |
| 175211 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); |
| 175212 | } |
| 175213 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 175214 | break; |
| 175215 | case 315: /* window ::= ORDER BY sortlist frame_opt */ |
| 175216 | { |
| 175217 | yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); |
| 175218 | } |
| 175219 | break; |
| 175220 | case 316: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 175221 | { |
| 175222 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| 175223 | } |
| 175224 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 175225 | break; |
| 175226 | case 317: /* window ::= nm frame_opt */ |
| 175227 | { |
| 175228 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); |
| 175229 | } |
| 175230 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 175231 | break; |
| 175232 | case 318: /* frame_opt ::= */ |
| 175233 | { |
| 175234 | yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 175235 | } |
| 175236 | break; |
| 175237 | case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 175238 | { |
| 175239 | 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); |
| 175240 | } |
| 175241 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 175242 | break; |
| 175243 | case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 175244 | { |
| 175245 | 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); |
| 175246 | } |
| 175247 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 175248 | break; |
| 175249 | case 322: /* frame_bound_s ::= frame_bound */ |
| 175250 | case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324); |
| 175251 | {yylhsminor.yy595 = yymsp[0].minor.yy595;} |
| 175252 | yymsp[0].minor.yy595 = yylhsminor.yy595; |
| 175253 | break; |
| 175254 | case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 175255 | case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325); |
| 175256 | case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327); |
| 175257 | {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} |
| 175258 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 175259 | break; |
| 175260 | case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 175261 | {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} |
| 175262 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 175263 | break; |
| 175264 | case 328: /* frame_exclude_opt ::= */ |
| 175265 | {yymsp[1].minor.yy516 = 0;} |
| 175266 | break; |
| 175267 | case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 175268 | {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} |
| 175269 | break; |
| 175270 | case 330: /* frame_exclude ::= NO OTHERS */ |
| 175271 | case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331); |
| 175272 | {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} |
| 175273 | break; |
| 175274 | case 332: /* frame_exclude ::= GROUP|TIES */ |
| 175275 | {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} |
| 175276 | break; |
| 175277 | case 333: /* window_clause ::= WINDOW windowdefn_list */ |
| 175278 | { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } |
| 175279 | break; |
| 175280 | case 334: /* filter_over ::= filter_clause over_clause */ |
| 175281 | { |
| 175282 | if( yymsp[0].minor.yy41 ){ |
| 175283 | yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; |
| 175284 | }else{ |
| 175285 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| @@ -174214,17 +175286,17 @@ | |
| 175286 | } |
| 175287 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 175288 | } |
| 175289 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 175290 | break; |
| 175291 | case 335: /* filter_over ::= over_clause */ |
| 175292 | { |
| 175293 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 175294 | } |
| 175295 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 175296 | break; |
| 175297 | case 336: /* filter_over ::= filter_clause */ |
| 175298 | { |
| 175299 | yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 175300 | if( yylhsminor.yy41 ){ |
| 175301 | yylhsminor.yy41->eFrmType = TK_FILTER; |
| 175302 | yylhsminor.yy41->pFilter = yymsp[0].minor.yy528; |
| @@ -174232,93 +175304,93 @@ | |
| 175304 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528); |
| 175305 | } |
| 175306 | } |
| 175307 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 175308 | break; |
| 175309 | case 337: /* over_clause ::= OVER LP window RP */ |
| 175310 | { |
| 175311 | yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; |
| 175312 | assert( yymsp[-3].minor.yy41!=0 ); |
| 175313 | } |
| 175314 | break; |
| 175315 | case 338: /* over_clause ::= OVER nm */ |
| 175316 | { |
| 175317 | yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 175318 | if( yymsp[-1].minor.yy41 ){ |
| 175319 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 175320 | } |
| 175321 | } |
| 175322 | break; |
| 175323 | case 339: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 175324 | { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } |
| 175325 | break; |
| 175326 | default: |
| 175327 | /* (340) input ::= cmdlist */ yytestcase(yyruleno==340); |
| 175328 | /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341); |
| 175329 | /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342); |
| 175330 | /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343); |
| 175331 | /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344); |
| 175332 | /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345); |
| 175333 | /* (346) trans_opt ::= */ yytestcase(yyruleno==346); |
| 175334 | /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347); |
| 175335 | /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348); |
| 175336 | /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349); |
| 175337 | /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350); |
| 175338 | /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351); |
| 175339 | /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352); |
| 175340 | /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353); |
| 175341 | /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354); |
| 175342 | /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355); |
| 175343 | /* (356) nm ::= STRING */ yytestcase(yyruleno==356); |
| 175344 | /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); |
| 175345 | /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); |
| 175346 | /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); |
| 175347 | /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); |
| 175348 | /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); |
| 175349 | /* (362) carglist ::= */ yytestcase(yyruleno==362); |
| 175350 | /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); |
| 175351 | /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); |
| 175352 | /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); |
| 175353 | /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); |
| 175354 | /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); |
| 175355 | /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); |
| 175356 | /* (369) tconscomma ::= */ yytestcase(yyruleno==369); |
| 175357 | /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); |
| 175358 | /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); |
| 175359 | /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); |
| 175360 | /* (373) oneselect ::= values */ yytestcase(yyruleno==373); |
| 175361 | /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); |
| 175362 | /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); |
| 175363 | /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376); |
| 175364 | /* (377) returning ::= */ yytestcase(yyruleno==377); |
| 175365 | /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); |
| 175366 | /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); |
| 175367 | /* (380) case_operand ::= expr */ yytestcase(yyruleno==380); |
| 175368 | /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); |
| 175369 | /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); |
| 175370 | /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); |
| 175371 | /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); |
| 175372 | /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); |
| 175373 | /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386); |
| 175374 | /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387); |
| 175375 | /* (388) foreach_clause ::= */ yytestcase(yyruleno==388); |
| 175376 | /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389); |
| 175377 | /* (390) trnm ::= nm */ yytestcase(yyruleno==390); |
| 175378 | /* (391) tridxby ::= */ yytestcase(yyruleno==391); |
| 175379 | /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392); |
| 175380 | /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393); |
| 175381 | /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394); |
| 175382 | /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395); |
| 175383 | /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396); |
| 175384 | /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397); |
| 175385 | /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398); |
| 175386 | /* (399) anylist ::= */ yytestcase(yyruleno==399); |
| 175387 | /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400); |
| 175388 | /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401); |
| 175389 | /* (402) with ::= */ yytestcase(yyruleno==402); |
| 175390 | /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403); |
| 175391 | /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404); |
| 175392 | break; |
| 175393 | /********** End reduce actions ************************************************/ |
| 175394 | }; |
| 175395 | assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) ); |
| 175396 | yygoto = yyRuleInfoLhs[yyruleno]; |
| @@ -176438,11 +177510,13 @@ | |
| 177510 | SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*); |
| 177511 | #endif |
| 177512 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 177513 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); |
| 177514 | #endif |
| 177515 | #ifdef SQLITE_EXTRA_AUTOEXT |
| 177516 | int SQLITE_EXTRA_AUTOEXT(sqlite3*); |
| 177517 | #endif |
| 177518 | /* |
| 177519 | ** An array of pointers to extension initializer functions for |
| 177520 | ** built-in extensions. |
| 177521 | */ |
| 177522 | static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = { |
| @@ -176471,10 +177545,13 @@ | |
| 177545 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 177546 | sqlite3StmtVtabInit, |
| 177547 | #endif |
| 177548 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 177549 | sqlite3VdbeBytecodeVtabInit, |
| 177550 | #endif |
| 177551 | #ifdef SQLITE_EXTRA_AUTOEXT |
| 177552 | SQLITE_EXTRA_AUTOEXT, |
| 177553 | #endif |
| 177554 | }; |
| 177555 | |
| 177556 | #ifndef SQLITE_AMALGAMATION |
| 177557 | /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant |
| @@ -176544,10 +177621,36 @@ | |
| 177621 | ** all database files specified with a relative pathname. |
| 177622 | ** |
| 177623 | ** See also the "PRAGMA data_store_directory" SQL command. |
| 177624 | */ |
| 177625 | SQLITE_API char *sqlite3_data_directory = 0; |
| 177626 | |
| 177627 | /* |
| 177628 | ** Determine whether or not high-precision (long double) floating point |
| 177629 | ** math works correctly on CPU currently running. |
| 177630 | */ |
| 177631 | static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){ |
| 177632 | if( sizeof(LONGDOUBLE_TYPE)<=8 ){ |
| 177633 | /* If the size of "long double" is not more than 8, then |
| 177634 | ** high-precision math is not possible. */ |
| 177635 | return 0; |
| 177636 | }else{ |
| 177637 | /* Just because sizeof(long double)>8 does not mean that the underlying |
| 177638 | ** hardware actually supports high-precision floating point. For example, |
| 177639 | ** clearing the 0x100 bit in the floating-point control word on Intel |
| 177640 | ** processors will make long double work like double, even though long |
| 177641 | ** double takes up more space. The only way to determine if long double |
| 177642 | ** actually works is to run an experiment. */ |
| 177643 | LONGDOUBLE_TYPE a, b, c; |
| 177644 | rc++; |
| 177645 | a = 1.0+rc*0.1; |
| 177646 | b = 1.0e+18+rc*25.0; |
| 177647 | c = a+b; |
| 177648 | return b!=c; |
| 177649 | } |
| 177650 | } |
| 177651 | |
| 177652 | |
| 177653 | /* |
| 177654 | ** Initialize SQLite. |
| 177655 | ** |
| 177656 | ** This routine must be called to initialize the memory allocation, |
| @@ -176739,10 +177842,14 @@ | |
| 177842 | if( bRunExtraInit ){ |
| 177843 | int SQLITE_EXTRA_INIT(const char*); |
| 177844 | rc = SQLITE_EXTRA_INIT(0); |
| 177845 | } |
| 177846 | #endif |
| 177847 | |
| 177848 | /* Experimentally determine if high-precision floating point is |
| 177849 | ** available. */ |
| 177850 | sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc); |
| 177851 | |
| 177852 | return rc; |
| 177853 | } |
| 177854 | |
| 177855 | /* |
| @@ -177310,10 +178417,14 @@ | |
| 178417 | ** Configuration settings for an individual database connection |
| 178418 | */ |
| 178419 | SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ |
| 178420 | va_list ap; |
| 178421 | int rc; |
| 178422 | |
| 178423 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 178424 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 178425 | #endif |
| 178426 | sqlite3_mutex_enter(db->mutex); |
| 178427 | va_start(ap, op); |
| 178428 | switch( op ){ |
| 178429 | case SQLITE_DBCONFIG_MAINDBNAME: { |
| 178430 | /* IMP: R-06824-28531 */ |
| @@ -177638,10 +178749,18 @@ | |
| 178749 | if( sqlite3GlobalConfig.xSqllog ){ |
| 178750 | /* Closing the handle. Fourth parameter is passed the value 2. */ |
| 178751 | sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2); |
| 178752 | } |
| 178753 | #endif |
| 178754 | |
| 178755 | while( db->pDbData ){ |
| 178756 | DbClientData *p = db->pDbData; |
| 178757 | db->pDbData = p->pNext; |
| 178758 | assert( p->pData!=0 ); |
| 178759 | if( p->xDestructor ) p->xDestructor(p->pData); |
| 178760 | sqlite3_free(p); |
| 178761 | } |
| 178762 | |
| 178763 | /* Convert the connection into a zombie and then close it. |
| 178764 | */ |
| 178765 | db->eOpenState = SQLITE_STATE_ZOMBIE; |
| 178766 | sqlite3LeaveMutexAndCloseZombie(db); |
| @@ -178713,10 +179832,16 @@ | |
| 179832 | void(*xCallback)( /* Callback function */ |
| 179833 | void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64), |
| 179834 | void *pArg /* First callback argument */ |
| 179835 | ){ |
| 179836 | void *pRet; |
| 179837 | |
| 179838 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 179839 | if( db==0 || xCallback==0 ){ |
| 179840 | return 0; |
| 179841 | } |
| 179842 | #endif |
| 179843 | sqlite3_mutex_enter(db->mutex); |
| 179844 | pRet = db->pPreUpdateArg; |
| 179845 | db->xPreUpdateCallback = xCallback; |
| 179846 | db->pPreUpdateArg = pArg; |
| 179847 | sqlite3_mutex_leave(db->mutex); |
| @@ -178859,11 +179984,11 @@ | |
| 179984 | assert( SQLITE_CHECKPOINT_RESTART==2 ); |
| 179985 | assert( SQLITE_CHECKPOINT_TRUNCATE==3 ); |
| 179986 | if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){ |
| 179987 | /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint |
| 179988 | ** mode: */ |
| 179989 | return SQLITE_MISUSE_BKPT; |
| 179990 | } |
| 179991 | |
| 179992 | sqlite3_mutex_enter(db->mutex); |
| 179993 | if( zDb && zDb[0] ){ |
| 179994 | iDb = sqlite3FindDbName(db, zDb); |
| @@ -180095,10 +181220,73 @@ | |
| 181220 | db->pCollNeededArg = pCollNeededArg; |
| 181221 | sqlite3_mutex_leave(db->mutex); |
| 181222 | return SQLITE_OK; |
| 181223 | } |
| 181224 | #endif /* SQLITE_OMIT_UTF16 */ |
| 181225 | |
| 181226 | /* |
| 181227 | ** Find existing client data. |
| 181228 | */ |
| 181229 | SQLITE_API void *sqlite3_get_clientdata(sqlite3 *db, const char *zName){ |
| 181230 | DbClientData *p; |
| 181231 | sqlite3_mutex_enter(db->mutex); |
| 181232 | for(p=db->pDbData; p; p=p->pNext){ |
| 181233 | if( strcmp(p->zName, zName)==0 ){ |
| 181234 | void *pResult = p->pData; |
| 181235 | sqlite3_mutex_leave(db->mutex); |
| 181236 | return pResult; |
| 181237 | } |
| 181238 | } |
| 181239 | sqlite3_mutex_leave(db->mutex); |
| 181240 | return 0; |
| 181241 | } |
| 181242 | |
| 181243 | /* |
| 181244 | ** Add new client data to a database connection. |
| 181245 | */ |
| 181246 | SQLITE_API int sqlite3_set_clientdata( |
| 181247 | sqlite3 *db, /* Attach client data to this connection */ |
| 181248 | const char *zName, /* Name of the client data */ |
| 181249 | void *pData, /* The client data itself */ |
| 181250 | void (*xDestructor)(void*) /* Destructor */ |
| 181251 | ){ |
| 181252 | DbClientData *p, **pp; |
| 181253 | sqlite3_mutex_enter(db->mutex); |
| 181254 | pp = &db->pDbData; |
| 181255 | for(p=db->pDbData; p && strcmp(p->zName,zName); p=p->pNext){ |
| 181256 | pp = &p->pNext; |
| 181257 | } |
| 181258 | if( p ){ |
| 181259 | assert( p->pData!=0 ); |
| 181260 | if( p->xDestructor ) p->xDestructor(p->pData); |
| 181261 | if( pData==0 ){ |
| 181262 | *pp = p->pNext; |
| 181263 | sqlite3_free(p); |
| 181264 | sqlite3_mutex_leave(db->mutex); |
| 181265 | return SQLITE_OK; |
| 181266 | } |
| 181267 | }else if( pData==0 ){ |
| 181268 | sqlite3_mutex_leave(db->mutex); |
| 181269 | return SQLITE_OK; |
| 181270 | }else{ |
| 181271 | size_t n = strlen(zName); |
| 181272 | p = sqlite3_malloc64( sizeof(DbClientData)+n+1 ); |
| 181273 | if( p==0 ){ |
| 181274 | if( xDestructor ) xDestructor(pData); |
| 181275 | sqlite3_mutex_leave(db->mutex); |
| 181276 | return SQLITE_NOMEM; |
| 181277 | } |
| 181278 | memcpy(p->zName, zName, n+1); |
| 181279 | p->pNext = db->pDbData; |
| 181280 | db->pDbData = p; |
| 181281 | } |
| 181282 | p->pData = pData; |
| 181283 | p->xDestructor = xDestructor; |
| 181284 | sqlite3_mutex_leave(db->mutex); |
| 181285 | return SQLITE_OK; |
| 181286 | } |
| 181287 | |
| 181288 | |
| 181289 | #ifndef SQLITE_OMIT_DEPRECATED |
| 181290 | /* |
| 181291 | ** This function is now an anachronism. It used to be used to recover from a |
| 181292 | ** malloc() failure, but SQLite now does this automatically. |
| @@ -180444,10 +181632,32 @@ | |
| 181632 | sqlite3Config.iPrngSeed = x; |
| 181633 | sqlite3_randomness(0,0); |
| 181634 | break; |
| 181635 | } |
| 181636 | #endif |
| 181637 | |
| 181638 | /* sqlite3_test_control(SQLITE_TESTCTRL_FK_NO_ACTION, sqlite3 *db, int b); |
| 181639 | ** |
| 181640 | ** If b is true, then activate the SQLITE_FkNoAction setting. If b is |
| 181641 | ** false then clearn that setting. If the SQLITE_FkNoAction setting is |
| 181642 | ** abled, all foreign key ON DELETE and ON UPDATE actions behave as if |
| 181643 | ** they were NO ACTION, regardless of how they are defined. |
| 181644 | ** |
| 181645 | ** NB: One must usually run "PRAGMA writable_schema=RESET" after |
| 181646 | ** using this test-control, before it will take full effect. failing |
| 181647 | ** to reset the schema can result in some unexpected behavior. |
| 181648 | */ |
| 181649 | case SQLITE_TESTCTRL_FK_NO_ACTION: { |
| 181650 | sqlite3 *db = va_arg(ap, sqlite3*); |
| 181651 | int b = va_arg(ap, int); |
| 181652 | if( b ){ |
| 181653 | db->flags |= SQLITE_FkNoAction; |
| 181654 | }else{ |
| 181655 | db->flags &= ~SQLITE_FkNoAction; |
| 181656 | } |
| 181657 | break; |
| 181658 | } |
| 181659 | |
| 181660 | /* |
| 181661 | ** sqlite3_test_control(BITVEC_TEST, size, program) |
| 181662 | ** |
| 181663 | ** Run a test against a Bitvec object of size. The program argument |
| @@ -180869,15 +182079,15 @@ | |
| 182079 | /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X); |
| 182080 | ** |
| 182081 | ** X<0 Make no changes to the bUseLongDouble. Just report value. |
| 182082 | ** X==0 Disable bUseLongDouble |
| 182083 | ** X==1 Enable bUseLongDouble |
| 182084 | ** X>=2 Set bUseLongDouble to its default value for this platform |
| 182085 | */ |
| 182086 | case SQLITE_TESTCTRL_USELONGDOUBLE: { |
| 182087 | int b = va_arg(ap, int); |
| 182088 | if( b>=2 ) b = hasHighPrecisionDouble(b); |
| 182089 | if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; |
| 182090 | rc = sqlite3Config.bUseLongDouble!=0; |
| 182091 | break; |
| 182092 | } |
| 182093 | #endif |
| @@ -181287,11 +182497,11 @@ | |
| 182497 | SQLITE_API int sqlite3_compileoption_used(const char *zOptName){ |
| 182498 | int i, n; |
| 182499 | int nOpt; |
| 182500 | const char **azCompileOpt; |
| 182501 | |
| 182502 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 182503 | if( zOptName==0 ){ |
| 182504 | (void)SQLITE_MISUSE_BKPT; |
| 182505 | return 0; |
| 182506 | } |
| 182507 | #endif |
| @@ -181482,10 +182692,13 @@ | |
| 182692 | void (*xNotify)(void **, int), |
| 182693 | void *pArg |
| 182694 | ){ |
| 182695 | int rc = SQLITE_OK; |
| 182696 | |
| 182697 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 182698 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 182699 | #endif |
| 182700 | sqlite3_mutex_enter(db->mutex); |
| 182701 | enterMutex(); |
| 182702 | |
| 182703 | if( xNotify==0 ){ |
| 182704 | removeFromBlockedList(db); |
| @@ -182503,10 +183716,11 @@ | |
| 183716 | u8 bDescIdx; /* True if doclists are in reverse order */ |
| 183717 | u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */ |
| 183718 | int nPgsz; /* Page size for host database */ |
| 183719 | char *zSegmentsTbl; /* Name of %_segments table */ |
| 183720 | sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ |
| 183721 | int iSavepoint; |
| 183722 | |
| 183723 | /* |
| 183724 | ** The following array of hash tables is used to buffer pending index |
| 183725 | ** updates during transactions. All pending updates buffered at any one |
| 183726 | ** time must share a common language-id (see the FTS4 langid= feature). |
| @@ -183246,10 +184460,11 @@ | |
| 184460 | char *zCols; /* List of user defined columns */ |
| 184461 | const char *zLanguageid; |
| 184462 | |
| 184463 | zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); |
| 184464 | sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 184465 | sqlite3_vtab_config(p->db, SQLITE_VTAB_INNOCUOUS); |
| 184466 | |
| 184467 | /* Create a list of user columns for the virtual table */ |
| 184468 | zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); |
| 184469 | for(i=1; zCols && i<p->nColumn; i++){ |
| 184470 | zCols = sqlite3_mprintf("%z%Q, ", zCols, p->azColumn[i]); |
| @@ -186495,10 +187710,12 @@ | |
| 187710 | assert( p->nPendingData==0 ); |
| 187711 | if( rc==SQLITE_OK ){ |
| 187712 | rc = sqlite3Fts3PendingTermsFlush(p); |
| 187713 | } |
| 187714 | |
| 187715 | p->bIgnoreSavepoint = 1; |
| 187716 | |
| 187717 | if( p->zContentTbl==0 ){ |
| 187718 | fts3DbExec(&rc, db, |
| 187719 | "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", |
| 187720 | p->zDb, p->zName, zName |
| 187721 | ); |
| @@ -186522,10 +187739,12 @@ | |
| 187739 | ); |
| 187740 | fts3DbExec(&rc, db, |
| 187741 | "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", |
| 187742 | p->zDb, p->zName, zName |
| 187743 | ); |
| 187744 | |
| 187745 | p->bIgnoreSavepoint = 0; |
| 187746 | return rc; |
| 187747 | } |
| 187748 | |
| 187749 | /* |
| 187750 | ** The xSavepoint() method. |
| @@ -186532,16 +187751,32 @@ | |
| 187751 | ** |
| 187752 | ** Flush the contents of the pending-terms table to disk. |
| 187753 | */ |
| 187754 | static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 187755 | int rc = SQLITE_OK; |
| 187756 | Fts3Table *pTab = (Fts3Table*)pVtab; |
| 187757 | assert( pTab->inTransaction ); |
| 187758 | assert( pTab->mxSavepoint<=iSavepoint ); |
| 187759 | TESTONLY( pTab->mxSavepoint = iSavepoint ); |
| 187760 | |
| 187761 | if( pTab->bIgnoreSavepoint==0 ){ |
| 187762 | if( fts3HashCount(&pTab->aIndex[0].hPending)>0 ){ |
| 187763 | char *zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", |
| 187764 | pTab->zDb, pTab->zName, pTab->zName |
| 187765 | ); |
| 187766 | if( zSql ){ |
| 187767 | pTab->bIgnoreSavepoint = 1; |
| 187768 | rc = sqlite3_exec(pTab->db, zSql, 0, 0, 0); |
| 187769 | pTab->bIgnoreSavepoint = 0; |
| 187770 | sqlite3_free(zSql); |
| 187771 | }else{ |
| 187772 | rc = SQLITE_NOMEM; |
| 187773 | } |
| 187774 | } |
| 187775 | if( rc==SQLITE_OK ){ |
| 187776 | pTab->iSavepoint = iSavepoint+1; |
| 187777 | } |
| 187778 | } |
| 187779 | return rc; |
| 187780 | } |
| 187781 | |
| 187782 | /* |
| @@ -186548,30 +187783,31 @@ | |
| 187783 | ** The xRelease() method. |
| 187784 | ** |
| 187785 | ** This is a no-op. |
| 187786 | */ |
| 187787 | static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 187788 | Fts3Table *pTab = (Fts3Table*)pVtab; |
| 187789 | assert( pTab->inTransaction ); |
| 187790 | assert( pTab->mxSavepoint >= iSavepoint ); |
| 187791 | TESTONLY( pTab->mxSavepoint = iSavepoint-1 ); |
| 187792 | pTab->iSavepoint = iSavepoint; |
| 187793 | return SQLITE_OK; |
| 187794 | } |
| 187795 | |
| 187796 | /* |
| 187797 | ** The xRollbackTo() method. |
| 187798 | ** |
| 187799 | ** Discard the contents of the pending terms table. |
| 187800 | */ |
| 187801 | static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 187802 | Fts3Table *pTab = (Fts3Table*)pVtab; |
| 187803 | UNUSED_PARAMETER(iSavepoint); |
| 187804 | assert( pTab->inTransaction ); |
| 187805 | TESTONLY( pTab->mxSavepoint = iSavepoint ); |
| 187806 | if( (iSavepoint+1)<=pTab->iSavepoint ){ |
| 187807 | sqlite3Fts3PendingTermsClear(pTab); |
| 187808 | } |
| 187809 | return SQLITE_OK; |
| 187810 | } |
| 187811 | |
| 187812 | /* |
| 187813 | ** Return true if zName is the extension on one of the shadow tables used |
| @@ -186585,13 +187821,37 @@ | |
| 187821 | for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 187822 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 187823 | } |
| 187824 | return 0; |
| 187825 | } |
| 187826 | |
| 187827 | /* |
| 187828 | ** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual |
| 187829 | ** table. |
| 187830 | */ |
| 187831 | static int fts3Integrity(sqlite3_vtab *pVtab, char **pzErr){ |
| 187832 | Fts3Table *p = (Fts3Table*)pVtab; |
| 187833 | char *zSql; |
| 187834 | int rc; |
| 187835 | |
| 187836 | zSql = sqlite3_mprintf( |
| 187837 | "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", |
| 187838 | p->zDb, p->zName, p->zName); |
| 187839 | rc = sqlite3_exec(p->db, zSql, 0, 0, 0); |
| 187840 | sqlite3_free(zSql); |
| 187841 | if( (rc&0xff)==SQLITE_CORRUPT ){ |
| 187842 | *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", |
| 187843 | p->bFts4 ? 4 : 3, p->zDb, p->zName); |
| 187844 | rc = SQLITE_OK; |
| 187845 | } |
| 187846 | return rc; |
| 187847 | } |
| 187848 | |
| 187849 | |
| 187850 | |
| 187851 | static const sqlite3_module fts3Module = { |
| 187852 | /* iVersion */ 4, |
| 187853 | /* xCreate */ fts3CreateMethod, |
| 187854 | /* xConnect */ fts3ConnectMethod, |
| 187855 | /* xBestIndex */ fts3BestIndexMethod, |
| 187856 | /* xDisconnect */ fts3DisconnectMethod, |
| 187857 | /* xDestroy */ fts3DestroyMethod, |
| @@ -186611,10 +187871,11 @@ | |
| 187871 | /* xRename */ fts3RenameMethod, |
| 187872 | /* xSavepoint */ fts3SavepointMethod, |
| 187873 | /* xRelease */ fts3ReleaseMethod, |
| 187874 | /* xRollbackTo */ fts3RollbackToMethod, |
| 187875 | /* xShadowName */ fts3ShadowName, |
| 187876 | /* xIntegrity */ fts3Integrity, |
| 187877 | }; |
| 187878 | |
| 187879 | /* |
| 187880 | ** This function is registered as the module destructor (called when an |
| 187881 | ** FTS3 enabled database connection is closed). It frees the memory |
| @@ -189286,11 +190547,12 @@ | |
| 190547 | 0, /* xFindFunction */ |
| 190548 | 0, /* xRename */ |
| 190549 | 0, /* xSavepoint */ |
| 190550 | 0, /* xRelease */ |
| 190551 | 0, /* xRollbackTo */ |
| 190552 | 0, /* xShadowName */ |
| 190553 | 0 /* xIntegrity */ |
| 190554 | }; |
| 190555 | int rc; /* Return code */ |
| 190556 | |
| 190557 | rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0); |
| 190558 | return rc; |
| @@ -192852,11 +194114,12 @@ | |
| 194114 | 0, /* xFindFunction */ |
| 194115 | 0, /* xRename */ |
| 194116 | 0, /* xSavepoint */ |
| 194117 | 0, /* xRelease */ |
| 194118 | 0, /* xRollbackTo */ |
| 194119 | 0, /* xShadowName */ |
| 194120 | 0 /* xIntegrity */ |
| 194121 | }; |
| 194122 | int rc; /* Return code */ |
| 194123 | |
| 194124 | rc = sqlite3_create_module_v2( |
| 194125 | db, "fts3tokenize", &fts3tok_module, (void*)pHash, xDestroy |
| @@ -196193,11 +197456,10 @@ | |
| 197456 | |
| 197457 | for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){ |
| 197458 | rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); |
| 197459 | if( rc==SQLITE_DONE ) rc = SQLITE_OK; |
| 197460 | } |
| 197461 | |
| 197462 | /* Determine the auto-incr-merge setting if unknown. If enabled, |
| 197463 | ** estimate the number of leaf blocks of content to be written |
| 197464 | */ |
| 197465 | if( rc==SQLITE_OK && p->bHasStat |
| @@ -196215,10 +197477,14 @@ | |
| 197477 | p->nAutoincrmerge = 0; |
| 197478 | } |
| 197479 | rc = sqlite3_reset(pStmt); |
| 197480 | } |
| 197481 | } |
| 197482 | |
| 197483 | if( rc==SQLITE_OK ){ |
| 197484 | sqlite3Fts3PendingTermsClear(p); |
| 197485 | } |
| 197486 | return rc; |
| 197487 | } |
| 197488 | |
| 197489 | /* |
| 197490 | ** Encode N integers as varints into a blob. |
| @@ -196902,13 +198168,17 @@ | |
| 198168 | nSpace = sqlite3Fts3VarintLen(nPrefix); |
| 198169 | nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 198170 | nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 198171 | |
| 198172 | /* If the current block is not empty, and if adding this term/doclist |
| 198173 | ** to the current block would make it larger than Fts3Table.nNodeSize bytes, |
| 198174 | ** and if there is still room for another leaf page, write this block out to |
| 198175 | ** the database. */ |
| 198176 | if( pLeaf->block.n>0 |
| 198177 | && (pLeaf->block.n + nSpace)>p->nNodeSize |
| 198178 | && pLeaf->iBlock < (pWriter->iStart + pWriter->nLeafEst) |
| 198179 | ){ |
| 198180 | rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); |
| 198181 | pWriter->nWork++; |
| 198182 | |
| 198183 | /* Add the current term to the parent node. The term added to the |
| 198184 | ** parent must: |
| @@ -197236,11 +198506,11 @@ | |
| 198506 | pNode = &pWriter->aNodeWriter[i-1]; |
| 198507 | pNode->iBlock = reader.iChild; |
| 198508 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); |
| 198509 | blobGrowBuffer(&pNode->block, |
| 198510 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc |
| 198511 | ); |
| 198512 | if( rc==SQLITE_OK ){ |
| 198513 | memcpy(pNode->block.a, aBlock, nBlock); |
| 198514 | pNode->block.n = nBlock; |
| 198515 | memset(&pNode->block.a[nBlock], 0, FTS3_NODE_PADDING); |
| 198516 | } |
| @@ -198301,12 +199571,15 @@ | |
| 199571 | rc = fts3DoIntegrityCheck(p); |
| 199572 | }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){ |
| 199573 | rc = fts3DoIncrmerge(p, &zVal[6]); |
| 199574 | }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ |
| 199575 | rc = fts3DoAutoincrmerge(p, &zVal[10]); |
| 199576 | }else if( nVal==5 && 0==sqlite3_strnicmp(zVal, "flush", 5) ){ |
| 199577 | rc = sqlite3Fts3PendingTermsFlush(p); |
| 199578 | } |
| 199579 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| 199580 | else{ |
| 199581 | int v; |
| 199582 | if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ |
| 199583 | v = atoi(&zVal[9]); |
| 199584 | if( v>=24 && v<=p->nPgsz-35 ) p->nNodeSize = v; |
| 199585 | rc = SQLITE_OK; |
| @@ -198320,12 +199593,12 @@ | |
| 199593 | }else if( nVal>11 && 0==sqlite3_strnicmp(zVal,"mergecount=",11) ){ |
| 199594 | v = atoi(&zVal[11]); |
| 199595 | if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; |
| 199596 | rc = SQLITE_OK; |
| 199597 | } |
| 199598 | } |
| 199599 | #endif |
| 199600 | return rc; |
| 199601 | } |
| 199602 | |
| 199603 | #ifndef SQLITE_DISABLE_FTS4_DEFERRED |
| 199604 | /* |
| @@ -201834,11 +203107,11 @@ | |
| 203107 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 203108 | SQLITE_TRANSIENT, SQLITE_UTF8); |
| 203109 | }else if( jsonForceRCStr(p) ){ |
| 203110 | sqlite3RCStrRef(p->zBuf); |
| 203111 | sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, |
| 203112 | sqlite3RCStrUnref, |
| 203113 | SQLITE_UTF8); |
| 203114 | } |
| 203115 | } |
| 203116 | if( p->bErr==1 ){ |
| 203117 | sqlite3_result_error_nomem(p->pCtx); |
| @@ -203174,11 +204447,11 @@ | |
| 204447 | } |
| 204448 | |
| 204449 | /* The input JSON was not found anywhere in the cache. We will need |
| 204450 | ** to parse it ourselves and generate a new JsonParse object. |
| 204451 | */ |
| 204452 | bJsonRCStr = sqlite3ValueIsOfClass(pJson,sqlite3RCStrUnref); |
| 204453 | p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); |
| 204454 | if( p==0 ){ |
| 204455 | sqlite3_result_error_nomem(pCtx); |
| 204456 | return 0; |
| 204457 | } |
| @@ -203388,10 +204661,11 @@ | |
| 204661 | && (i>0 || ((pRoot[j].jnFlags & JNODE_REMOVE)!=0 && pParse->useMod)) |
| 204662 | ){ |
| 204663 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; |
| 204664 | j += jsonNodeSize(&pRoot[j]); |
| 204665 | } |
| 204666 | if( i==0 && j<=pRoot->n ) break; |
| 204667 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
| 204668 | if( pParse->useMod==0 ) break; |
| 204669 | assert( pRoot->eU==2 ); |
| 204670 | iRoot = pRoot->u.iAppend; |
| 204671 | pRoot = &pParse->aNode[iRoot]; |
| @@ -204075,15 +205349,17 @@ | |
| 205349 | if( z==0 ){ |
| 205350 | p->oom = 1; |
| 205351 | break; |
| 205352 | } |
| 205353 | if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ |
| 205354 | char *zCopy = sqlite3_malloc64( n+1 ); |
| 205355 | int k; |
| 205356 | if( zCopy ){ |
| 205357 | memcpy(zCopy, z, n); |
| 205358 | zCopy[n] = 0; |
| 205359 | jsonParseAddCleanup(p, sqlite3_free, zCopy); |
| 205360 | }else{ |
| 205361 | p->oom = 1; |
| 205362 | sqlite3_result_error_nomem(pCtx); |
| 205363 | } |
| 205364 | k = jsonParseAddNode(p, JSON_STRING, n, zCopy); |
| 205365 | assert( k>0 || p->oom ); |
| @@ -204134,10 +205410,11 @@ | |
| 205410 | jsonWrongNumArgs(ctx, "replace"); |
| 205411 | return; |
| 205412 | } |
| 205413 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 205414 | if( pParse==0 ) return; |
| 205415 | pParse->nJPRef++; |
| 205416 | for(i=1; i<(u32)argc; i+=2){ |
| 205417 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 205418 | pParse->useMod = 1; |
| 205419 | pNode = jsonLookup(pParse, zPath, 0, ctx); |
| 205420 | if( pParse->nErr ) goto replace_err; |
| @@ -204146,10 +205423,11 @@ | |
| 205423 | } |
| 205424 | } |
| 205425 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 205426 | replace_err: |
| 205427 | jsonDebugPrintParse(pParse); |
| 205428 | jsonParseFree(pParse); |
| 205429 | } |
| 205430 | |
| 205431 | |
| 205432 | /* |
| 205433 | ** json_set(JSON, PATH, VALUE, ...) |
| @@ -204180,10 +205458,11 @@ | |
| 205458 | jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); |
| 205459 | return; |
| 205460 | } |
| 205461 | pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); |
| 205462 | if( pParse==0 ) return; |
| 205463 | pParse->nJPRef++; |
| 205464 | for(i=1; i<(u32)argc; i+=2){ |
| 205465 | zPath = (const char*)sqlite3_value_text(argv[i]); |
| 205466 | bApnd = 0; |
| 205467 | pParse->useMod = 1; |
| 205468 | pNode = jsonLookup(pParse, zPath, &bApnd, ctx); |
| @@ -204196,13 +205475,12 @@ | |
| 205475 | jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); |
| 205476 | } |
| 205477 | } |
| 205478 | jsonDebugPrintParse(pParse); |
| 205479 | jsonReturnJson(pParse, pParse->aNode, ctx, 1); |
| 205480 | jsonSetDone: |
| 205481 | jsonParseFree(pParse); |
| 205482 | } |
| 205483 | |
| 205484 | /* |
| 205485 | ** json_type(JSON) |
| 205486 | ** json_type(JSON, PATH) |
| @@ -204354,11 +205632,11 @@ | |
| 205632 | if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); |
| 205633 | assert( pStr->bStatic ); |
| 205634 | }else if( isFinal ){ |
| 205635 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 205636 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 205637 | sqlite3RCStrUnref); |
| 205638 | pStr->bStatic = 1; |
| 205639 | }else{ |
| 205640 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| 205641 | pStr->nUsed--; |
| 205642 | } |
| @@ -204463,11 +205741,11 @@ | |
| 205741 | if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); |
| 205742 | assert( pStr->bStatic ); |
| 205743 | }else if( isFinal ){ |
| 205744 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, |
| 205745 | pStr->bStatic ? SQLITE_TRANSIENT : |
| 205746 | sqlite3RCStrUnref); |
| 205747 | pStr->bStatic = 1; |
| 205748 | }else{ |
| 205749 | sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); |
| 205750 | pStr->nUsed--; |
| 205751 | } |
| @@ -204895,11 +206173,11 @@ | |
| 206173 | if( idxNum==0 ) return SQLITE_OK; |
| 206174 | z = (const char*)sqlite3_value_text(argv[0]); |
| 206175 | if( z==0 ) return SQLITE_OK; |
| 206176 | memset(&p->sParse, 0, sizeof(p->sParse)); |
| 206177 | p->sParse.nJPRef = 1; |
| 206178 | if( sqlite3ValueIsOfClass(argv[0], sqlite3RCStrUnref) ){ |
| 206179 | p->sParse.zJson = sqlite3RCStrRef((char*)z); |
| 206180 | }else{ |
| 206181 | n = sqlite3_value_bytes(argv[0]); |
| 206182 | p->sParse.zJson = sqlite3RCStrNew( n+1 ); |
| 206183 | if( p->sParse.zJson==0 ) return SQLITE_NOMEM; |
| @@ -204990,11 +206268,12 @@ | |
| 206268 | 0, /* xFindMethod */ |
| 206269 | 0, /* xRename */ |
| 206270 | 0, /* xSavepoint */ |
| 206271 | 0, /* xRelease */ |
| 206272 | 0, /* xRollbackTo */ |
| 206273 | 0, /* xShadowName */ |
| 206274 | 0 /* xIntegrity */ |
| 206275 | }; |
| 206276 | |
| 206277 | /* The methods of the json_tree virtual table. */ |
| 206278 | static sqlite3_module jsonTreeModule = { |
| 206279 | 0, /* iVersion */ |
| @@ -205018,11 +206297,12 @@ | |
| 206297 | 0, /* xFindMethod */ |
| 206298 | 0, /* xRename */ |
| 206299 | 0, /* xSavepoint */ |
| 206300 | 0, /* xRelease */ |
| 206301 | 0, /* xRollbackTo */ |
| 206302 | 0, /* xShadowName */ |
| 206303 | 0 /* xIntegrity */ |
| 206304 | }; |
| 206305 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 206306 | #endif /* !defined(SQLITE_OMIT_JSON) */ |
| 206307 | |
| 206308 | /* |
| @@ -205253,10 +206533,11 @@ | |
| 206533 | u8 bCorrupt; /* Shadow table corruption detected */ |
| 206534 | #endif |
| 206535 | int iDepth; /* Current depth of the r-tree structure */ |
| 206536 | char *zDb; /* Name of database containing r-tree table */ |
| 206537 | char *zName; /* Name of r-tree table */ |
| 206538 | char *zNodeName; /* Name of the %_node table */ |
| 206539 | u32 nBusy; /* Current number of users of this structure */ |
| 206540 | i64 nRowEst; /* Estimated number of rows in this table */ |
| 206541 | u32 nCursor; /* Number of open cursors */ |
| 206542 | u32 nNodeRef; /* Number RtreeNodes with positive nRef */ |
| 206543 | char *zReadAuxSql; /* SQL for statement to read aux data */ |
| @@ -205265,11 +206546,10 @@ | |
| 206546 | ** linked together via the pointer normally used for hash chains - |
| 206547 | ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree |
| 206548 | ** headed by the node (leaf nodes have RtreeNode.iNode==0). |
| 206549 | */ |
| 206550 | RtreeNode *pDeleted; |
| 206551 | |
| 206552 | /* Blob I/O on xxx_node */ |
| 206553 | sqlite3_blob *pNodeBlob; |
| 206554 | |
| 206555 | /* Statements to read/write/delete a record from xxx_node */ |
| @@ -205562,19 +206842,24 @@ | |
| 206842 | ** For best performance, an attempt is made to guess at the byte-order |
| 206843 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 206844 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 206845 | ** at run-time. |
| 206846 | */ |
| 206847 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 206848 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 206849 | # define SQLITE_BYTEORDER 4321 |
| 206850 | # elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ |
| 206851 | # define SQLITE_BYTEORDER 1234 |
| 206852 | # elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 |
| 206853 | # define SQLITE_BYTEORDER 4321 |
| 206854 | # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 206855 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 206856 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 206857 | defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 206858 | # define SQLITE_BYTEORDER 1234 |
| 206859 | # elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) |
| 206860 | # define SQLITE_BYTEORDER 4321 |
| 206861 | # else |
| 206862 | # define SQLITE_BYTEORDER 0 |
| 206863 | # endif |
| 206864 | #endif |
| 206865 | |
| @@ -205819,15 +207104,13 @@ | |
| 207104 | nodeBlobReset(pRtree); |
| 207105 | if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM; |
| 207106 | } |
| 207107 | } |
| 207108 | if( pRtree->pNodeBlob==0 ){ |
| 207109 | rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, pRtree->zNodeName, |
| 207110 | "data", iNode, 0, |
| 207111 | &pRtree->pNodeBlob); |
| 207112 | } |
| 207113 | if( rc ){ |
| 207114 | nodeBlobReset(pRtree); |
| 207115 | *ppNode = 0; |
| 207116 | /* If unable to open an sqlite3_blob on the desired row, that can only |
| @@ -207164,12 +208447,16 @@ | |
| 208447 | } |
| 208448 | } |
| 208449 | |
| 208450 | pIdxInfo->idxNum = 2; |
| 208451 | pIdxInfo->needToFreeIdxStr = 1; |
| 208452 | if( iIdx>0 ){ |
| 208453 | pIdxInfo->idxStr = sqlite3_malloc( iIdx+1 ); |
| 208454 | if( pIdxInfo->idxStr==0 ){ |
| 208455 | return SQLITE_NOMEM; |
| 208456 | } |
| 208457 | memcpy(pIdxInfo->idxStr, zIdxStr, iIdx+1); |
| 208458 | } |
| 208459 | |
| 208460 | nRow = pRtree->nRowEst >> (iIdx/2); |
| 208461 | pIdxInfo->estimatedCost = (double)6.0 * (double)nRow; |
| 208462 | pIdxInfo->estimatedRows = nRow; |
| @@ -207244,35 +208531,26 @@ | |
| 208531 | ** Return true if the area covered by p2 is a subset of the area covered |
| 208532 | ** by p1. False otherwise. |
| 208533 | */ |
| 208534 | static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ |
| 208535 | int ii; |
| 208536 | if( pRtree->eCoordType==RTREE_COORD_INT32 ){ |
| 208537 | for(ii=0; ii<pRtree->nDim2; ii+=2){ |
| 208538 | RtreeCoord *a1 = &p1->aCoord[ii]; |
| 208539 | RtreeCoord *a2 = &p2->aCoord[ii]; |
| 208540 | if( a2[0].i<a1[0].i || a2[1].i>a1[1].i ) return 0; |
| 208541 | } |
| 208542 | }else{ |
| 208543 | for(ii=0; ii<pRtree->nDim2; ii+=2){ |
| 208544 | RtreeCoord *a1 = &p1->aCoord[ii]; |
| 208545 | RtreeCoord *a2 = &p2->aCoord[ii]; |
| 208546 | if( a2[0].f<a1[0].f || a2[1].f>a1[1].f ) return 0; |
| 208547 | } |
| 208548 | } |
| 208549 | return 1; |
| 208550 | } |
| 208551 | |
| 208552 | static RtreeDValue cellOverlap( |
| 208553 | Rtree *pRtree, |
| 208554 | RtreeCell *p, |
| 208555 | RtreeCell *aCell, |
| 208556 | int nCell |
| @@ -207315,42 +208593,56 @@ | |
| 208593 | rc = nodeAcquire(pRtree, 1, 0, &pNode); |
| 208594 | |
| 208595 | for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ |
| 208596 | int iCell; |
| 208597 | sqlite3_int64 iBest = 0; |
| 208598 | int bFound = 0; |
| 208599 | RtreeDValue fMinGrowth = RTREE_ZERO; |
| 208600 | RtreeDValue fMinArea = RTREE_ZERO; |
| 208601 | int nCell = NCELL(pNode); |
| 208602 | RtreeNode *pChild = 0; |
| 208603 | |
| 208604 | /* First check to see if there is are any cells in pNode that completely |
| 208605 | ** contains pCell. If two or more cells in pNode completely contain pCell |
| 208606 | ** then pick the smallest. |
| 208607 | */ |
| 208608 | for(iCell=0; iCell<nCell; iCell++){ |
| 208609 | RtreeCell cell; |
| 208610 | nodeGetCell(pRtree, pNode, iCell, &cell); |
| 208611 | if( cellContains(pRtree, &cell, pCell) ){ |
| 208612 | RtreeDValue area = cellArea(pRtree, &cell); |
| 208613 | if( bFound==0 || area<fMinArea ){ |
| 208614 | iBest = cell.iRowid; |
| 208615 | fMinArea = area; |
| 208616 | bFound = 1; |
| 208617 | } |
| 208618 | } |
| 208619 | } |
| 208620 | if( !bFound ){ |
| 208621 | /* No cells of pNode will completely contain pCell. So pick the |
| 208622 | ** cell of pNode that grows by the least amount when pCell is added. |
| 208623 | ** Break ties by selecting the smaller cell. |
| 208624 | */ |
| 208625 | for(iCell=0; iCell<nCell; iCell++){ |
| 208626 | RtreeCell cell; |
| 208627 | RtreeDValue growth; |
| 208628 | RtreeDValue area; |
| 208629 | nodeGetCell(pRtree, pNode, iCell, &cell); |
| 208630 | area = cellArea(pRtree, &cell); |
| 208631 | cellUnion(pRtree, &cell, pCell); |
| 208632 | growth = cellArea(pRtree, &cell)-area; |
| 208633 | if( iCell==0 |
| 208634 | || growth<fMinGrowth |
| 208635 | || (growth==fMinGrowth && area<fMinArea) |
| 208636 | ){ |
| 208637 | fMinGrowth = growth; |
| 208638 | fMinArea = area; |
| 208639 | iBest = cell.iRowid; |
| 208640 | } |
| 208641 | } |
| 208642 | } |
| 208643 | |
| 208644 | rc = nodeAcquire(pRtree, iBest, pNode, &pChild); |
| 208645 | nodeRelease(pRtree, pNode); |
| 208646 | pNode = pChild; |
| 208647 | } |
| 208648 | |
| @@ -207419,81 +208711,10 @@ | |
| 208711 | } |
| 208712 | |
| 208713 | static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); |
| 208714 | |
| 208715 | |
| 208716 | |
| 208717 | /* |
| 208718 | ** Arguments aIdx, aCell and aSpare all point to arrays of size |
| 208719 | ** nIdx. The aIdx array contains the set of integers from 0 to |
| 208720 | ** (nIdx-1) in no particular order. This function sorts the values |
| @@ -207974,111 +209195,10 @@ | |
| 209195 | } |
| 209196 | |
| 209197 | return rc; |
| 209198 | } |
| 209199 | |
| 209200 | /* |
| 209201 | ** Insert cell pCell into node pNode. Node pNode is the head of a |
| 209202 | ** subtree iHeight high (leaf nodes have iHeight==0). |
| 209203 | */ |
| 209204 | static int rtreeInsertCell( |
| @@ -208095,16 +209215,11 @@ | |
| 209215 | nodeReference(pNode); |
| 209216 | pChild->pParent = pNode; |
| 209217 | } |
| 209218 | } |
| 209219 | if( nodeInsertCell(pRtree, pNode, pCell) ){ |
| 209220 | rc = SplitNode(pRtree, pNode, pCell, iHeight); |
| 209221 | }else{ |
| 209222 | rc = AdjustTree(pRtree, pNode, pCell); |
| 209223 | if( ALWAYS(rc==SQLITE_OK) ){ |
| 209224 | if( iHeight==0 ){ |
| 209225 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); |
| @@ -208443,11 +209558,10 @@ | |
| 209558 | if( rc==SQLITE_OK ){ |
| 209559 | rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); |
| 209560 | } |
| 209561 | if( rc==SQLITE_OK ){ |
| 209562 | int rc2; |
| 209563 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 209564 | rc2 = nodeRelease(pRtree, pLeaf); |
| 209565 | if( rc==SQLITE_OK ){ |
| 209566 | rc = rc2; |
| 209567 | } |
| @@ -208584,12 +209698,15 @@ | |
| 209698 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 209699 | } |
| 209700 | return 0; |
| 209701 | } |
| 209702 | |
| 209703 | /* Forward declaration */ |
| 209704 | static int rtreeIntegrity(sqlite3_vtab*, char**); |
| 209705 | |
| 209706 | static sqlite3_module rtreeModule = { |
| 209707 | 4, /* iVersion */ |
| 209708 | rtreeCreate, /* xCreate - create a table */ |
| 209709 | rtreeConnect, /* xConnect - connect to an existing table */ |
| 209710 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ |
| 209711 | rtreeDisconnect, /* xDisconnect - Disconnect from a table */ |
| 209712 | rtreeDestroy, /* xDestroy - Drop a table */ |
| @@ -208608,11 +209725,12 @@ | |
| 209725 | 0, /* xFindFunction - function overloading */ |
| 209726 | rtreeRename, /* xRename - rename the table */ |
| 209727 | rtreeSavepoint, /* xSavepoint */ |
| 209728 | 0, /* xRelease */ |
| 209729 | 0, /* xRollbackTo */ |
| 209730 | rtreeShadowName, /* xShadowName */ |
| 209731 | rtreeIntegrity /* xIntegrity */ |
| 209732 | }; |
| 209733 | |
| 209734 | static int rtreeSqlInit( |
| 209735 | Rtree *pRtree, |
| 209736 | sqlite3 *db, |
| @@ -208864,26 +209982,31 @@ | |
| 209982 | *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]); |
| 209983 | return SQLITE_ERROR; |
| 209984 | } |
| 209985 | |
| 209986 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 209987 | sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); |
| 209988 | |
| 209989 | |
| 209990 | /* Allocate the sqlite3_vtab structure */ |
| 209991 | nDb = (int)strlen(argv[1]); |
| 209992 | nName = (int)strlen(argv[2]); |
| 209993 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); |
| 209994 | if( !pRtree ){ |
| 209995 | return SQLITE_NOMEM; |
| 209996 | } |
| 209997 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); |
| 209998 | pRtree->nBusy = 1; |
| 209999 | pRtree->base.pModule = &rtreeModule; |
| 210000 | pRtree->zDb = (char *)&pRtree[1]; |
| 210001 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 210002 | pRtree->zNodeName = &pRtree->zName[nName+1]; |
| 210003 | pRtree->eCoordType = (u8)eCoordType; |
| 210004 | memcpy(pRtree->zDb, argv[1], nDb); |
| 210005 | memcpy(pRtree->zName, argv[2], nName); |
| 210006 | memcpy(pRtree->zNodeName, argv[2], nName); |
| 210007 | memcpy(&pRtree->zNodeName[nName], "_node", 6); |
| 210008 | |
| 210009 | |
| 210010 | /* Create/Connect to the underlying relational database schema. If |
| 210011 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 210012 | ** the r-tree table schema. |
| @@ -209376,27 +210499,18 @@ | |
| 210499 | const char *zTab, /* Name of rtree table to check */ |
| 210500 | char **pzReport /* OUT: sqlite3_malloc'd report text */ |
| 210501 | ){ |
| 210502 | RtreeCheck check; /* Common context for various routines */ |
| 210503 | sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ |
| 210504 | int nAux = 0; /* Number of extra columns. */ |
| 210505 | |
| 210506 | /* Initialize the context object */ |
| 210507 | memset(&check, 0, sizeof(check)); |
| 210508 | check.db = db; |
| 210509 | check.zDb = zDb; |
| 210510 | check.zTab = zTab; |
| 210511 | |
| 210512 | /* Find the number of auxiliary columns */ |
| 210513 | if( check.rc==SQLITE_OK ){ |
| 210514 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); |
| 210515 | if( pStmt ){ |
| 210516 | nAux = sqlite3_column_count(pStmt) - 2; |
| @@ -209433,18 +210547,27 @@ | |
| 210547 | /* Finalize SQL statements used by the integrity-check */ |
| 210548 | sqlite3_finalize(check.pGetNode); |
| 210549 | sqlite3_finalize(check.aCheckMapping[0]); |
| 210550 | sqlite3_finalize(check.aCheckMapping[1]); |
| 210551 | |
| 210552 | *pzReport = check.zReport; |
| 210553 | return check.rc; |
| 210554 | } |
| 210555 | |
| 210556 | /* |
| 210557 | ** Implementation of the xIntegrity method for Rtree. |
| 210558 | */ |
| 210559 | static int rtreeIntegrity(sqlite3_vtab *pVtab, char **pzErr){ |
| 210560 | Rtree *pRtree = (Rtree*)pVtab; |
| 210561 | int rc; |
| 210562 | rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr); |
| 210563 | if( rc==SQLITE_OK && *pzErr ){ |
| 210564 | *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z", |
| 210565 | pRtree->zDb, pRtree->zName, *pzErr); |
| 210566 | } |
| 210567 | return rc; |
| 210568 | } |
| 210569 | |
| 210570 | /* |
| 210571 | ** Usage: |
| 210572 | ** |
| 210573 | ** rtreecheck(<rtree-table>); |
| @@ -210763,28 +211886,32 @@ | |
| 211886 | char *zSql; |
| 211887 | int ii; |
| 211888 | (void)pAux; |
| 211889 | |
| 211890 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 211891 | sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); |
| 211892 | |
| 211893 | /* Allocate the sqlite3_vtab structure */ |
| 211894 | nDb = strlen(argv[1]); |
| 211895 | nName = strlen(argv[2]); |
| 211896 | pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); |
| 211897 | if( !pRtree ){ |
| 211898 | return SQLITE_NOMEM; |
| 211899 | } |
| 211900 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); |
| 211901 | pRtree->nBusy = 1; |
| 211902 | pRtree->base.pModule = &rtreeModule; |
| 211903 | pRtree->zDb = (char *)&pRtree[1]; |
| 211904 | pRtree->zName = &pRtree->zDb[nDb+1]; |
| 211905 | pRtree->zNodeName = &pRtree->zName[nName+1]; |
| 211906 | pRtree->eCoordType = RTREE_COORD_REAL32; |
| 211907 | pRtree->nDim = 2; |
| 211908 | pRtree->nDim2 = 4; |
| 211909 | memcpy(pRtree->zDb, argv[1], nDb); |
| 211910 | memcpy(pRtree->zName, argv[2], nName); |
| 211911 | memcpy(pRtree->zNodeName, argv[2], nName); |
| 211912 | memcpy(&pRtree->zNodeName[nName], "_node", 6); |
| 211913 | |
| 211914 | |
| 211915 | /* Create/Connect to the underlying relational database schema. If |
| 211916 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 211917 | ** the r-tree table schema. |
| @@ -211194,11 +212321,10 @@ | |
| 212321 | if( rc==SQLITE_OK ){ |
| 212322 | rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf); |
| 212323 | } |
| 212324 | if( rc==SQLITE_OK ){ |
| 212325 | int rc2; |
| 212326 | rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); |
| 212327 | rc2 = nodeRelease(pRtree, pLeaf); |
| 212328 | if( rc==SQLITE_OK ){ |
| 212329 | rc = rc2; |
| 212330 | } |
| @@ -211291,11 +212417,12 @@ | |
| 212417 | geopolyFindFunction, /* xFindFunction - function overloading */ |
| 212418 | rtreeRename, /* xRename - rename the table */ |
| 212419 | rtreeSavepoint, /* xSavepoint */ |
| 212420 | 0, /* xRelease */ |
| 212421 | 0, /* xRollbackTo */ |
| 212422 | rtreeShadowName, /* xShadowName */ |
| 212423 | rtreeIntegrity /* xIntegrity */ |
| 212424 | }; |
| 212425 | |
| 212426 | static int sqlite3_geopoly_init(sqlite3 *db){ |
| 212427 | int rc = SQLITE_OK; |
| 212428 | static const struct { |
| @@ -219305,11 +220432,12 @@ | |
| 220432 | 0, /* xFindMethod */ |
| 220433 | 0, /* xRename */ |
| 220434 | 0, /* xSavepoint */ |
| 220435 | 0, /* xRelease */ |
| 220436 | 0, /* xRollbackTo */ |
| 220437 | 0, /* xShadowName */ |
| 220438 | 0 /* xIntegrity */ |
| 220439 | }; |
| 220440 | return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); |
| 220441 | } |
| 220442 | #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) |
| 220443 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } |
| @@ -219742,11 +220870,12 @@ | |
| 220870 | 0, /* xFindMethod */ |
| 220871 | 0, /* xRename */ |
| 220872 | 0, /* xSavepoint */ |
| 220873 | 0, /* xRelease */ |
| 220874 | 0, /* xRollbackTo */ |
| 220875 | 0, /* xShadowName */ |
| 220876 | 0 /* xIntegrity */ |
| 220877 | }; |
| 220878 | return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); |
| 220879 | } |
| 220880 | #elif defined(SQLITE_ENABLE_DBPAGE_VTAB) |
| 220881 | SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; } |
| @@ -219873,22 +221002,36 @@ | |
| 221002 | ** table. |
| 221003 | ** |
| 221004 | ** The data associated with each hash-table entry is a structure containing |
| 221005 | ** a subset of the initial values that the modified row contained at the |
| 221006 | ** start of the session. Or no initial values if the row was inserted. |
| 221007 | ** |
| 221008 | ** pDfltStmt: |
| 221009 | ** This is only used by the sqlite3changegroup_xxx() APIs, not by |
| 221010 | ** regular sqlite3_session objects. It is a SELECT statement that |
| 221011 | ** selects the default value for each table column. For example, |
| 221012 | ** if the table is |
| 221013 | ** |
| 221014 | ** CREATE TABLE xx(a DEFAULT 1, b, c DEFAULT 'abc') |
| 221015 | ** |
| 221016 | ** then this variable is the compiled version of: |
| 221017 | ** |
| 221018 | ** SELECT 1, NULL, 'abc' |
| 221019 | */ |
| 221020 | struct SessionTable { |
| 221021 | SessionTable *pNext; |
| 221022 | char *zName; /* Local name of table */ |
| 221023 | int nCol; /* Number of columns in table zName */ |
| 221024 | int bStat1; /* True if this is sqlite_stat1 */ |
| 221025 | int bRowid; /* True if this table uses rowid for PK */ |
| 221026 | const char **azCol; /* Column names */ |
| 221027 | const char **azDflt; /* Default value expressions */ |
| 221028 | u8 *abPK; /* Array of primary key flags */ |
| 221029 | int nEntry; /* Total number of entries in hash table */ |
| 221030 | int nChange; /* Size of apChange[] array */ |
| 221031 | SessionChange **apChange; /* Hash table buckets */ |
| 221032 | sqlite3_stmt *pDfltStmt; |
| 221033 | }; |
| 221034 | |
| 221035 | /* |
| 221036 | ** RECORD FORMAT: |
| 221037 | ** |
| @@ -220053,10 +221196,11 @@ | |
| 221196 | ** this structure stored in a SessionTable.aChange[] hash table. |
| 221197 | */ |
| 221198 | struct SessionChange { |
| 221199 | u8 op; /* One of UPDATE, DELETE, INSERT */ |
| 221200 | u8 bIndirect; /* True if this change is "indirect" */ |
| 221201 | u16 nRecordField; /* Number of fields in aRecord[] */ |
| 221202 | int nMaxSize; /* Max size of eventual changeset record */ |
| 221203 | int nRecord; /* Number of bytes in buffer aRecord[] */ |
| 221204 | u8 *aRecord; /* Buffer containing old.* record */ |
| 221205 | SessionChange *pNext; /* For hash-table collisions */ |
| 221206 | }; |
| @@ -220078,11 +221222,11 @@ | |
| 221222 | |
| 221223 | /* |
| 221224 | ** Read a varint value from aBuf[] into *piVal. Return the number of |
| 221225 | ** bytes read. |
| 221226 | */ |
| 221227 | static int sessionVarintGet(const u8 *aBuf, int *piVal){ |
| 221228 | return getVarint32(aBuf, *piVal); |
| 221229 | } |
| 221230 | |
| 221231 | /* Load an unaligned and unsigned 32-bit integer */ |
| 221232 | #define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| @@ -220341,11 +221485,11 @@ | |
| 221485 | /* |
| 221486 | ** The buffer that the argument points to contains a serialized SQL value. |
| 221487 | ** Return the number of bytes of space occupied by the value (including |
| 221488 | ** the type byte). |
| 221489 | */ |
| 221490 | static int sessionSerialLen(const u8 *a){ |
| 221491 | int e = *a; |
| 221492 | int n; |
| 221493 | if( e==0 || e==0xFF ) return 1; |
| 221494 | if( e==SQLITE_NULL ) return 1; |
| 221495 | if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; |
| @@ -220748,17 +221892,18 @@ | |
| 221892 | ** NULL) is set to point to an array of booleans - true if the corresponding |
| 221893 | ** column is part of the primary key. |
| 221894 | ** |
| 221895 | ** For example, if the table is declared as: |
| 221896 | ** |
| 221897 | ** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z)); |
| 221898 | ** |
| 221899 | ** Then the five output variables are populated as follows: |
| 221900 | ** |
| 221901 | ** *pnCol = 4 |
| 221902 | ** *pzTab = "tbl1" |
| 221903 | ** *pazCol = {"w", "x", "y", "z"} |
| 221904 | ** *pazDflt = {NULL, 'abc', NULL, NULL} |
| 221905 | ** *pabPK = {1, 0, 0, 1} |
| 221906 | ** |
| 221907 | ** All returned buffers are part of the same single allocation, which must |
| 221908 | ** be freed using sqlite3_free() by the caller |
| 221909 | */ |
| @@ -220768,10 +221913,11 @@ | |
| 221913 | const char *zDb, /* Name of attached database (e.g. "main") */ |
| 221914 | const char *zThis, /* Table name */ |
| 221915 | int *pnCol, /* OUT: number of columns */ |
| 221916 | const char **pzTab, /* OUT: Copy of zThis */ |
| 221917 | const char ***pazCol, /* OUT: Array of column names for table */ |
| 221918 | const char ***pazDflt, /* OUT: Array of default value expressions */ |
| 221919 | u8 **pabPK, /* OUT: Array of booleans - true for PK col */ |
| 221920 | int *pbRowid /* OUT: True if only PK is a rowid */ |
| 221921 | ){ |
| 221922 | char *zPragma; |
| 221923 | sqlite3_stmt *pStmt; |
| @@ -220780,15 +221926,22 @@ | |
| 221926 | int nDbCol = 0; |
| 221927 | int nThis; |
| 221928 | int i; |
| 221929 | u8 *pAlloc = 0; |
| 221930 | char **azCol = 0; |
| 221931 | char **azDflt = 0; |
| 221932 | u8 *abPK = 0; |
| 221933 | int bRowid = 0; /* Set to true to use rowid as PK */ |
| 221934 | |
| 221935 | assert( pazCol && pabPK ); |
| 221936 | |
| 221937 | *pazCol = 0; |
| 221938 | *pabPK = 0; |
| 221939 | *pnCol = 0; |
| 221940 | if( pzTab ) *pzTab = 0; |
| 221941 | if( pazDflt ) *pazDflt = 0; |
| 221942 | |
| 221943 | nThis = sqlite3Strlen30(zThis); |
| 221944 | if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ |
| 221945 | rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); |
| 221946 | if( rc==SQLITE_OK ){ |
| 221947 | /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ |
| @@ -220798,59 +221951,51 @@ | |
| 221951 | "SELECT 2, 'stat', '', 0, '', 0" |
| 221952 | ); |
| 221953 | }else if( rc==SQLITE_ERROR ){ |
| 221954 | zPragma = sqlite3_mprintf(""); |
| 221955 | }else{ |
| 221956 | return rc; |
| 221957 | } |
| 221958 | }else{ |
| 221959 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); |
| 221960 | } |
| 221961 | if( !zPragma ){ |
| 221962 | return SQLITE_NOMEM; |
| 221963 | } |
| 221964 | |
| 221965 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); |
| 221966 | sqlite3_free(zPragma); |
| 221967 | if( rc!=SQLITE_OK ){ |
| 221968 | return rc; |
| 221969 | } |
| 221970 | |
| 221971 | nByte = nThis + 1; |
| 221972 | bRowid = (pbRowid!=0); |
| 221973 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 221974 | nByte += sqlite3_column_bytes(pStmt, 1); /* name */ |
| 221975 | nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */ |
| 221976 | nDbCol++; |
| 221977 | if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */ |
| 221978 | } |
| 221979 | if( nDbCol==0 ) bRowid = 0; |
| 221980 | nDbCol += bRowid; |
| 221981 | nByte += strlen(SESSIONS_ROWID); |
| 221982 | rc = sqlite3_reset(pStmt); |
| 221983 | |
| 221984 | if( rc==SQLITE_OK ){ |
| 221985 | nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1); |
| 221986 | pAlloc = sessionMalloc64(pSession, nByte); |
| 221987 | if( pAlloc==0 ){ |
| 221988 | rc = SQLITE_NOMEM; |
| 221989 | }else{ |
| 221990 | memset(pAlloc, 0, nByte); |
| 221991 | } |
| 221992 | } |
| 221993 | if( rc==SQLITE_OK ){ |
| 221994 | azCol = (char **)pAlloc; |
| 221995 | azDflt = (char**)&azCol[nDbCol]; |
| 221996 | pAlloc = (u8 *)&azDflt[nDbCol]; |
| 221997 | abPK = (u8 *)pAlloc; |
| 221998 | pAlloc = &abPK[nDbCol]; |
| 221999 | if( pzTab ){ |
| 222000 | memcpy(pAlloc, zThis, nThis+1); |
| 222001 | *pzTab = (char *)pAlloc; |
| @@ -220866,15 +222011,25 @@ | |
| 222011 | abPK[i] = 1; |
| 222012 | i++; |
| 222013 | } |
| 222014 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 222015 | int nName = sqlite3_column_bytes(pStmt, 1); |
| 222016 | int nDflt = sqlite3_column_bytes(pStmt, 4); |
| 222017 | const unsigned char *zName = sqlite3_column_text(pStmt, 1); |
| 222018 | const unsigned char *zDflt = sqlite3_column_text(pStmt, 4); |
| 222019 | |
| 222020 | if( zName==0 ) break; |
| 222021 | memcpy(pAlloc, zName, nName+1); |
| 222022 | azCol[i] = (char *)pAlloc; |
| 222023 | pAlloc += nName+1; |
| 222024 | if( zDflt ){ |
| 222025 | memcpy(pAlloc, zDflt, nDflt+1); |
| 222026 | azDflt[i] = (char *)pAlloc; |
| 222027 | pAlloc += nDflt+1; |
| 222028 | }else{ |
| 222029 | azDflt[i] = 0; |
| 222030 | } |
| 222031 | abPK[i] = sqlite3_column_int(pStmt, 5); |
| 222032 | i++; |
| 222033 | } |
| 222034 | rc = sqlite3_reset(pStmt); |
| 222035 | } |
| @@ -220881,46 +222036,49 @@ | |
| 222036 | |
| 222037 | /* If successful, populate the output variables. Otherwise, zero them and |
| 222038 | ** free any allocation made. An error code will be returned in this case. |
| 222039 | */ |
| 222040 | if( rc==SQLITE_OK ){ |
| 222041 | *pazCol = (const char**)azCol; |
| 222042 | if( pazDflt ) *pazDflt = (const char**)azDflt; |
| 222043 | *pabPK = abPK; |
| 222044 | *pnCol = nDbCol; |
| 222045 | }else{ |
| 222046 | sessionFree(pSession, azCol); |
| 222047 | } |
| 222048 | if( pbRowid ) *pbRowid = bRowid; |
| 222049 | sqlite3_finalize(pStmt); |
| 222050 | return rc; |
| 222051 | } |
| 222052 | |
| 222053 | /* |
| 222054 | ** This function is called to initialize the SessionTable.nCol, azCol[] |
| 222055 | ** abPK[] and azDflt[] members of SessionTable object pTab. If these |
| 222056 | ** fields are already initilialized, this function is a no-op. |
| 222057 | ** |
| 222058 | ** If an error occurs, an error code is stored in sqlite3_session.rc and |
| 222059 | ** non-zero returned. Or, if no error occurs but the table has no primary |
| 222060 | ** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to |
| 222061 | ** indicate that updates on this table should be ignored. SessionTable.abPK |
| 222062 | ** is set to NULL in this case. |
| 222063 | */ |
| 222064 | static int sessionInitTable( |
| 222065 | sqlite3_session *pSession, /* Optional session handle */ |
| 222066 | SessionTable *pTab, /* Table object to initialize */ |
| 222067 | sqlite3 *db, /* Database handle to read schema from */ |
| 222068 | const char *zDb /* Name of db - "main", "temp" etc. */ |
| 222069 | ){ |
| 222070 | int rc = SQLITE_OK; |
| 222071 | |
| 222072 | if( pTab->nCol==0 ){ |
| 222073 | u8 *abPK; |
| 222074 | assert( pTab->azCol==0 || pTab->abPK==0 ); |
| 222075 | rc = sessionTableInfo(pSession, db, zDb, |
| 222076 | pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK, |
| 222077 | ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0) |
| 222078 | ); |
| 222079 | if( rc==SQLITE_OK ){ |
| 222080 | int i; |
| 222081 | for(i=0; i<pTab->nCol; i++){ |
| 222082 | if( abPK[i] ){ |
| 222083 | pTab->abPK = abPK; |
| 222084 | break; |
| @@ -220928,18 +222086,325 @@ | |
| 222086 | } |
| 222087 | if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ |
| 222088 | pTab->bStat1 = 1; |
| 222089 | } |
| 222090 | |
| 222091 | if( pSession && pSession->bEnableSize ){ |
| 222092 | pSession->nMaxChangesetSize += ( |
| 222093 | 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 |
| 222094 | ); |
| 222095 | } |
| 222096 | } |
| 222097 | } |
| 222098 | |
| 222099 | if( pSession ){ |
| 222100 | pSession->rc = rc; |
| 222101 | return (rc || pTab->abPK==0); |
| 222102 | } |
| 222103 | return rc; |
| 222104 | } |
| 222105 | |
| 222106 | /* |
| 222107 | ** Re-initialize table object pTab. |
| 222108 | */ |
| 222109 | static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){ |
| 222110 | int nCol = 0; |
| 222111 | const char **azCol = 0; |
| 222112 | const char **azDflt = 0; |
| 222113 | u8 *abPK = 0; |
| 222114 | int bRowid = 0; |
| 222115 | |
| 222116 | assert( pSession->rc==SQLITE_OK ); |
| 222117 | |
| 222118 | pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, |
| 222119 | pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK, |
| 222120 | (pSession->bImplicitPK ? &bRowid : 0) |
| 222121 | ); |
| 222122 | if( pSession->rc==SQLITE_OK ){ |
| 222123 | if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){ |
| 222124 | pSession->rc = SQLITE_SCHEMA; |
| 222125 | }else{ |
| 222126 | int ii; |
| 222127 | int nOldCol = pTab->nCol; |
| 222128 | for(ii=0; ii<nCol; ii++){ |
| 222129 | if( ii<pTab->nCol ){ |
| 222130 | if( pTab->abPK[ii]!=abPK[ii] ){ |
| 222131 | pSession->rc = SQLITE_SCHEMA; |
| 222132 | } |
| 222133 | }else if( abPK[ii] ){ |
| 222134 | pSession->rc = SQLITE_SCHEMA; |
| 222135 | } |
| 222136 | } |
| 222137 | |
| 222138 | if( pSession->rc==SQLITE_OK ){ |
| 222139 | const char **a = pTab->azCol; |
| 222140 | pTab->azCol = azCol; |
| 222141 | pTab->nCol = nCol; |
| 222142 | pTab->azDflt = azDflt; |
| 222143 | pTab->abPK = abPK; |
| 222144 | azCol = a; |
| 222145 | } |
| 222146 | if( pSession->bEnableSize ){ |
| 222147 | pSession->nMaxChangesetSize += (nCol - nOldCol); |
| 222148 | pSession->nMaxChangesetSize += sessionVarintLen(nCol); |
| 222149 | pSession->nMaxChangesetSize -= sessionVarintLen(nOldCol); |
| 222150 | } |
| 222151 | } |
| 222152 | } |
| 222153 | |
| 222154 | sqlite3_free(azCol); |
| 222155 | return pSession->rc; |
| 222156 | } |
| 222157 | |
| 222158 | /* |
| 222159 | ** Session-change object (*pp) contains an old.* record with fewer than |
| 222160 | ** nCol fields. This function updates it with the default values for |
| 222161 | ** the missing fields. |
| 222162 | */ |
| 222163 | static void sessionUpdateOneChange( |
| 222164 | sqlite3_session *pSession, /* For memory accounting */ |
| 222165 | int *pRc, /* IN/OUT: Error code */ |
| 222166 | SessionChange **pp, /* IN/OUT: Change object to update */ |
| 222167 | int nCol, /* Number of columns now in table */ |
| 222168 | sqlite3_stmt *pDflt /* SELECT <default-values...> */ |
| 222169 | ){ |
| 222170 | SessionChange *pOld = *pp; |
| 222171 | |
| 222172 | while( pOld->nRecordField<nCol ){ |
| 222173 | SessionChange *pNew = 0; |
| 222174 | int nByte = 0; |
| 222175 | int nIncr = 0; |
| 222176 | int iField = pOld->nRecordField; |
| 222177 | int eType = sqlite3_column_type(pDflt, iField); |
| 222178 | switch( eType ){ |
| 222179 | case SQLITE_NULL: |
| 222180 | nIncr = 1; |
| 222181 | break; |
| 222182 | case SQLITE_INTEGER: |
| 222183 | case SQLITE_FLOAT: |
| 222184 | nIncr = 9; |
| 222185 | break; |
| 222186 | default: { |
| 222187 | int n = sqlite3_column_bytes(pDflt, iField); |
| 222188 | nIncr = 1 + sessionVarintLen(n) + n; |
| 222189 | assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); |
| 222190 | break; |
| 222191 | } |
| 222192 | } |
| 222193 | |
| 222194 | nByte = nIncr + (sizeof(SessionChange) + pOld->nRecord); |
| 222195 | pNew = sessionMalloc64(pSession, nByte); |
| 222196 | if( pNew==0 ){ |
| 222197 | *pRc = SQLITE_NOMEM; |
| 222198 | return; |
| 222199 | }else{ |
| 222200 | memcpy(pNew, pOld, sizeof(SessionChange)); |
| 222201 | pNew->aRecord = (u8*)&pNew[1]; |
| 222202 | memcpy(pNew->aRecord, pOld->aRecord, pOld->nRecord); |
| 222203 | pNew->aRecord[pNew->nRecord++] = (u8)eType; |
| 222204 | switch( eType ){ |
| 222205 | case SQLITE_INTEGER: { |
| 222206 | i64 iVal = sqlite3_column_int64(pDflt, iField); |
| 222207 | sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); |
| 222208 | pNew->nRecord += 8; |
| 222209 | break; |
| 222210 | } |
| 222211 | |
| 222212 | case SQLITE_FLOAT: { |
| 222213 | double rVal = sqlite3_column_double(pDflt, iField); |
| 222214 | i64 iVal = 0; |
| 222215 | memcpy(&iVal, &rVal, sizeof(rVal)); |
| 222216 | sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); |
| 222217 | pNew->nRecord += 8; |
| 222218 | break; |
| 222219 | } |
| 222220 | |
| 222221 | case SQLITE_TEXT: { |
| 222222 | int n = sqlite3_column_bytes(pDflt, iField); |
| 222223 | const char *z = (const char*)sqlite3_column_text(pDflt, iField); |
| 222224 | pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); |
| 222225 | memcpy(&pNew->aRecord[pNew->nRecord], z, n); |
| 222226 | pNew->nRecord += n; |
| 222227 | break; |
| 222228 | } |
| 222229 | |
| 222230 | case SQLITE_BLOB: { |
| 222231 | int n = sqlite3_column_bytes(pDflt, iField); |
| 222232 | const u8 *z = (const u8*)sqlite3_column_blob(pDflt, iField); |
| 222233 | pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); |
| 222234 | memcpy(&pNew->aRecord[pNew->nRecord], z, n); |
| 222235 | pNew->nRecord += n; |
| 222236 | break; |
| 222237 | } |
| 222238 | |
| 222239 | default: |
| 222240 | assert( eType==SQLITE_NULL ); |
| 222241 | break; |
| 222242 | } |
| 222243 | |
| 222244 | sessionFree(pSession, pOld); |
| 222245 | *pp = pOld = pNew; |
| 222246 | pNew->nRecordField++; |
| 222247 | pNew->nMaxSize += nIncr; |
| 222248 | if( pSession ){ |
| 222249 | pSession->nMaxChangesetSize += nIncr; |
| 222250 | } |
| 222251 | } |
| 222252 | } |
| 222253 | } |
| 222254 | |
| 222255 | /* |
| 222256 | ** Ensure that there is room in the buffer to append nByte bytes of data. |
| 222257 | ** If not, use sqlite3_realloc() to grow the buffer so that there is. |
| 222258 | ** |
| 222259 | ** If successful, return zero. Otherwise, if an OOM condition is encountered, |
| 222260 | ** set *pRc to SQLITE_NOMEM and return non-zero. |
| 222261 | */ |
| 222262 | static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ |
| 222263 | #define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) |
| 222264 | i64 nReq = p->nBuf + nByte; |
| 222265 | if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ |
| 222266 | u8 *aNew; |
| 222267 | i64 nNew = p->nAlloc ? p->nAlloc : 128; |
| 222268 | |
| 222269 | do { |
| 222270 | nNew = nNew*2; |
| 222271 | }while( nNew<nReq ); |
| 222272 | |
| 222273 | /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation |
| 222274 | ** of sqlite3_realloc64(). Allocations greater than this size in bytes |
| 222275 | ** always fail. It is used here to ensure that this routine can always |
| 222276 | ** allocate up to this limit - instead of up to the largest power of |
| 222277 | ** two smaller than the limit. */ |
| 222278 | if( nNew>SESSION_MAX_BUFFER_SZ ){ |
| 222279 | nNew = SESSION_MAX_BUFFER_SZ; |
| 222280 | if( nNew<nReq ){ |
| 222281 | *pRc = SQLITE_NOMEM; |
| 222282 | return 1; |
| 222283 | } |
| 222284 | } |
| 222285 | |
| 222286 | aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew); |
| 222287 | if( 0==aNew ){ |
| 222288 | *pRc = SQLITE_NOMEM; |
| 222289 | }else{ |
| 222290 | p->aBuf = aNew; |
| 222291 | p->nAlloc = nNew; |
| 222292 | } |
| 222293 | } |
| 222294 | return (*pRc!=SQLITE_OK); |
| 222295 | } |
| 222296 | |
| 222297 | |
| 222298 | /* |
| 222299 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 222300 | ** called. Otherwise, append a string to the buffer. All bytes in the string |
| 222301 | ** up to (but not including) the nul-terminator are written to the buffer. |
| 222302 | ** |
| 222303 | ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before |
| 222304 | ** returning. |
| 222305 | */ |
| 222306 | static void sessionAppendStr( |
| 222307 | SessionBuffer *p, |
| 222308 | const char *zStr, |
| 222309 | int *pRc |
| 222310 | ){ |
| 222311 | int nStr = sqlite3Strlen30(zStr); |
| 222312 | if( 0==sessionBufferGrow(p, nStr+1, pRc) ){ |
| 222313 | memcpy(&p->aBuf[p->nBuf], zStr, nStr); |
| 222314 | p->nBuf += nStr; |
| 222315 | p->aBuf[p->nBuf] = 0x00; |
| 222316 | } |
| 222317 | } |
| 222318 | |
| 222319 | /* |
| 222320 | ** Format a string using printf() style formatting and then append it to the |
| 222321 | ** buffer using sessionAppendString(). |
| 222322 | */ |
| 222323 | static void sessionAppendPrintf( |
| 222324 | SessionBuffer *p, /* Buffer to append to */ |
| 222325 | int *pRc, |
| 222326 | const char *zFmt, |
| 222327 | ... |
| 222328 | ){ |
| 222329 | if( *pRc==SQLITE_OK ){ |
| 222330 | char *zApp = 0; |
| 222331 | va_list ap; |
| 222332 | va_start(ap, zFmt); |
| 222333 | zApp = sqlite3_vmprintf(zFmt, ap); |
| 222334 | if( zApp==0 ){ |
| 222335 | *pRc = SQLITE_NOMEM; |
| 222336 | }else{ |
| 222337 | sessionAppendStr(p, zApp, pRc); |
| 222338 | } |
| 222339 | va_end(ap); |
| 222340 | sqlite3_free(zApp); |
| 222341 | } |
| 222342 | } |
| 222343 | |
| 222344 | /* |
| 222345 | ** Prepare a statement against database handle db that SELECTs a single |
| 222346 | ** row containing the default values for each column in table pTab. For |
| 222347 | ** example, if pTab is declared as: |
| 222348 | ** |
| 222349 | ** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd'); |
| 222350 | ** |
| 222351 | ** Then this function prepares and returns the SQL statement: |
| 222352 | ** |
| 222353 | ** SELECT NULL, 123, 'abcd'; |
| 222354 | */ |
| 222355 | static int sessionPrepareDfltStmt( |
| 222356 | sqlite3 *db, /* Database handle */ |
| 222357 | SessionTable *pTab, /* Table to prepare statement for */ |
| 222358 | sqlite3_stmt **ppStmt /* OUT: Statement handle */ |
| 222359 | ){ |
| 222360 | SessionBuffer sql = {0,0,0}; |
| 222361 | int rc = SQLITE_OK; |
| 222362 | const char *zSep = " "; |
| 222363 | int ii = 0; |
| 222364 | |
| 222365 | *ppStmt = 0; |
| 222366 | sessionAppendPrintf(&sql, &rc, "SELECT"); |
| 222367 | for(ii=0; ii<pTab->nCol; ii++){ |
| 222368 | const char *zDflt = pTab->azDflt[ii] ? pTab->azDflt[ii] : "NULL"; |
| 222369 | sessionAppendPrintf(&sql, &rc, "%s%s", zSep, zDflt); |
| 222370 | zSep = ", "; |
| 222371 | } |
| 222372 | if( rc==SQLITE_OK ){ |
| 222373 | rc = sqlite3_prepare_v2(db, (const char*)sql.aBuf, -1, ppStmt, 0); |
| 222374 | } |
| 222375 | sqlite3_free(sql.aBuf); |
| 222376 | |
| 222377 | return rc; |
| 222378 | } |
| 222379 | |
| 222380 | /* |
| 222381 | ** Table pTab has one or more existing change-records with old.* records |
| 222382 | ** with fewer than pTab->nCol columns. This function updates all such |
| 222383 | ** change-records with the default values for the missing columns. |
| 222384 | */ |
| 222385 | static int sessionUpdateChanges(sqlite3_session *pSession, SessionTable *pTab){ |
| 222386 | sqlite3_stmt *pStmt = 0; |
| 222387 | int rc = pSession->rc; |
| 222388 | |
| 222389 | rc = sessionPrepareDfltStmt(pSession->db, pTab, &pStmt); |
| 222390 | if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 222391 | int ii = 0; |
| 222392 | SessionChange **pp = 0; |
| 222393 | for(ii=0; ii<pTab->nChange; ii++){ |
| 222394 | for(pp=&pTab->apChange[ii]; *pp; pp=&((*pp)->pNext)){ |
| 222395 | if( (*pp)->nRecordField!=pTab->nCol ){ |
| 222396 | sessionUpdateOneChange(pSession, &rc, pp, pTab->nCol, pStmt); |
| 222397 | } |
| 222398 | } |
| 222399 | } |
| 222400 | } |
| 222401 | |
| 222402 | pSession->rc = rc; |
| 222403 | rc = sqlite3_finalize(pStmt); |
| 222404 | if( pSession->rc==SQLITE_OK ) pSession->rc = rc; |
| 222405 | return pSession->rc; |
| 222406 | } |
| 222407 | |
| 222408 | /* |
| 222409 | ** Versions of the four methods in object SessionHook for use with the |
| 222410 | ** sqlite_stat1 table. The purpose of this is to substitute a zero-length |
| @@ -221098,20 +222563,26 @@ | |
| 222563 | SessionTable *pTab /* Table that change applies to */ |
| 222564 | ){ |
| 222565 | int iHash; |
| 222566 | int bNull = 0; |
| 222567 | int rc = SQLITE_OK; |
| 222568 | int nExpect = 0; |
| 222569 | SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; |
| 222570 | |
| 222571 | if( pSession->rc ) return; |
| 222572 | |
| 222573 | /* Load table details if required */ |
| 222574 | if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return; |
| 222575 | |
| 222576 | /* Check the number of columns in this xPreUpdate call matches the |
| 222577 | ** number of columns in the table. */ |
| 222578 | nExpect = pSession->hook.xCount(pSession->hook.pCtx); |
| 222579 | if( (pTab->nCol-pTab->bRowid)<nExpect ){ |
| 222580 | if( sessionReinitTable(pSession, pTab) ) return; |
| 222581 | if( sessionUpdateChanges(pSession, pTab) ) return; |
| 222582 | } |
| 222583 | if( (pTab->nCol-pTab->bRowid)!=nExpect ){ |
| 222584 | pSession->rc = SQLITE_SCHEMA; |
| 222585 | return; |
| 222586 | } |
| 222587 | |
| 222588 | /* Grow the hash table if required */ |
| @@ -221184,11 +222655,11 @@ | |
| 222655 | if( pTab->bRowid ){ |
| 222656 | nByte += 9; /* Size of rowid field - an integer */ |
| 222657 | } |
| 222658 | |
| 222659 | /* Allocate the change object */ |
| 222660 | pC = (SessionChange*)sessionMalloc64(pSession, nByte); |
| 222661 | if( !pC ){ |
| 222662 | rc = SQLITE_NOMEM; |
| 222663 | goto error_out; |
| 222664 | }else{ |
| 222665 | memset(pC, 0, sizeof(SessionChange)); |
| @@ -221217,10 +222688,11 @@ | |
| 222688 | |
| 222689 | /* Add the change to the hash-table */ |
| 222690 | if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ |
| 222691 | pC->bIndirect = 1; |
| 222692 | } |
| 222693 | pC->nRecordField = pTab->nCol; |
| 222694 | pC->nRecord = nByte; |
| 222695 | pC->op = op; |
| 222696 | pC->pNext = pTab->apChange[iHash]; |
| 222697 | pTab->apChange[iHash] = pC; |
| 222698 | |
| @@ -221596,11 +223068,11 @@ | |
| 223068 | SessionTable *pTo; /* Table zTbl */ |
| 223069 | |
| 223070 | /* Locate and if necessary initialize the target table object */ |
| 223071 | rc = sessionFindTable(pSession, zTbl, &pTo); |
| 223072 | if( pTo==0 ) goto diff_out; |
| 223073 | if( sessionInitTable(pSession, pTo, pSession->db, pSession->zDb) ){ |
| 223074 | rc = pSession->rc; |
| 223075 | goto diff_out; |
| 223076 | } |
| 223077 | |
| 223078 | /* Check the table schemas match */ |
| @@ -221609,11 +223081,11 @@ | |
| 223081 | int bMismatch = 0; |
| 223082 | int nCol; /* Columns in zFrom.zTbl */ |
| 223083 | int bRowid = 0; |
| 223084 | u8 *abPK; |
| 223085 | const char **azCol = 0; |
| 223086 | rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK, |
| 223087 | pSession->bImplicitPK ? &bRowid : 0 |
| 223088 | ); |
| 223089 | if( rc==SQLITE_OK ){ |
| 223090 | if( pTo->nCol!=nCol ){ |
| 223091 | bMismatch = 1; |
| @@ -221724,10 +223196,11 @@ | |
| 223196 | for(p=pTab->apChange[i]; p; p=pNextChange){ |
| 223197 | pNextChange = p->pNext; |
| 223198 | sessionFree(pSession, p); |
| 223199 | } |
| 223200 | } |
| 223201 | sqlite3_finalize(pTab->pDfltStmt); |
| 223202 | sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ |
| 223203 | sessionFree(pSession, pTab->apChange); |
| 223204 | sessionFree(pSession, pTab); |
| 223205 | } |
| 223206 | } |
| @@ -221758,11 +223231,11 @@ | |
| 223231 | ** associated hash-tables. */ |
| 223232 | sessionDeleteTable(pSession, pSession->pTable); |
| 223233 | |
| 223234 | /* Assert that all allocations have been freed and then free the |
| 223235 | ** session object itself. */ |
| 223236 | // assert( pSession->nMalloc==0 ); |
| 223237 | sqlite3_free(pSession); |
| 223238 | } |
| 223239 | |
| 223240 | /* |
| 223241 | ** Set a table filter on a Session Object. |
| @@ -221829,52 +223302,10 @@ | |
| 223302 | |
| 223303 | sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db)); |
| 223304 | return rc; |
| 223305 | } |
| 223306 | |
| 223307 | /* |
| 223308 | ** Append the value passed as the second argument to the buffer passed |
| 223309 | ** as the first. |
| 223310 | ** |
| 223311 | ** This function is a no-op if *pRc is non-zero when it is called. |
| @@ -221939,31 +223370,10 @@ | |
| 223370 | memcpy(&p->aBuf[p->nBuf], aBlob, nBlob); |
| 223371 | p->nBuf += nBlob; |
| 223372 | } |
| 223373 | } |
| 223374 | |
| 223375 | /* |
| 223376 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 223377 | ** called. Otherwise, append the string representation of integer iVal |
| 223378 | ** to the buffer. No nul-terminator is written. |
| 223379 | ** |
| @@ -221978,31 +223388,10 @@ | |
| 223388 | char aBuf[24]; |
| 223389 | sqlite3_snprintf(sizeof(aBuf)-1, aBuf, "%d", iVal); |
| 223390 | sessionAppendStr(p, aBuf, pRc); |
| 223391 | } |
| 223392 | |
| 223393 | /* |
| 223394 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is |
| 223395 | ** called. Otherwise, append the string zStr enclosed in quotes (") and |
| 223396 | ** with any embedded quote characters escaped to the buffer. No |
| 223397 | ** nul-terminator byte is written. |
| @@ -222489,63 +223878,53 @@ | |
| 223878 | sqlite3_mutex_enter(sqlite3_db_mutex(db)); |
| 223879 | |
| 223880 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ |
| 223881 | if( pTab->nEntry ){ |
| 223882 | const char *zName = pTab->zName; |
| 223883 | int i; /* Used to iterate through hash buckets */ |
| 223884 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ |
| 223885 | int nRewind = buf.nBuf; /* Initial size of write buffer */ |
| 223886 | int nNoop; /* Size of buffer after writing tbl header */ |
| 223887 | int nOldCol = pTab->nCol; |
| 223888 | |
| 223889 | /* Check the table schema is still Ok. */ |
| 223890 | rc = sessionReinitTable(pSession, pTab); |
| 223891 | if( rc==SQLITE_OK && pTab->nCol!=nOldCol ){ |
| 223892 | rc = sessionUpdateChanges(pSession, pTab); |
| 223893 | } |
| 223894 | |
| 223895 | /* Write a table header */ |
| 223896 | sessionAppendTableHdr(&buf, bPatchset, pTab, &rc); |
| 223897 | |
| 223898 | /* Build and compile a statement to execute: */ |
| 223899 | if( rc==SQLITE_OK ){ |
| 223900 | rc = sessionSelectStmt(db, 0, pSession->zDb, |
| 223901 | zName, pTab->bRowid, pTab->nCol, pTab->azCol, pTab->abPK, &pSel |
| 223902 | ); |
| 223903 | } |
| 223904 | |
| 223905 | nNoop = buf.nBuf; |
| 223906 | for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){ |
| 223907 | SessionChange *p; /* Used to iterate through changes */ |
| 223908 | |
| 223909 | for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ |
| 223910 | rc = sessionSelectBind(pSel, pTab->nCol, pTab->abPK, p); |
| 223911 | if( rc!=SQLITE_OK ) continue; |
| 223912 | if( sqlite3_step(pSel)==SQLITE_ROW ){ |
| 223913 | if( p->op==SQLITE_INSERT ){ |
| 223914 | int iCol; |
| 223915 | sessionAppendByte(&buf, SQLITE_INSERT, &rc); |
| 223916 | sessionAppendByte(&buf, p->bIndirect, &rc); |
| 223917 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 223918 | sessionAppendCol(&buf, pSel, iCol, &rc); |
| 223919 | } |
| 223920 | }else{ |
| 223921 | assert( pTab->abPK!=0 ); |
| 223922 | rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, pTab->abPK); |
| 223923 | } |
| 223924 | }else if( p->op!=SQLITE_INSERT ){ |
| 223925 | rc = sessionAppendDelete(&buf, bPatchset, p, pTab->nCol,pTab->abPK); |
| 223926 | } |
| 223927 | if( rc==SQLITE_OK ){ |
| 223928 | rc = sqlite3_reset(pSel); |
| 223929 | } |
| 223930 | |
| @@ -222566,11 +223945,10 @@ | |
| 223945 | |
| 223946 | sqlite3_finalize(pSel); |
| 223947 | if( buf.nBuf==nNoop ){ |
| 223948 | buf.nBuf = nRewind; |
| 223949 | } |
| 223950 | } |
| 223951 | } |
| 223952 | |
| 223953 | if( rc==SQLITE_OK ){ |
| 223954 | if( xOutput==0 ){ |
| @@ -224695,11 +226073,11 @@ | |
| 226073 | int nMinCol = 0; |
| 226074 | int i; |
| 226075 | |
| 226076 | sqlite3changeset_pk(pIter, &abPK, 0); |
| 226077 | rc = sessionTableInfo(0, db, "main", zNew, |
| 226078 | &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid |
| 226079 | ); |
| 226080 | if( rc!=SQLITE_OK ) break; |
| 226081 | for(i=0; i<sApply.nCol; i++){ |
| 226082 | if( sApply.abPK[i] ) nMinCol = i+1; |
| 226083 | } |
| @@ -224827,15 +226205,28 @@ | |
| 226205 | int flags |
| 226206 | ){ |
| 226207 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ |
| 226208 | int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); |
| 226209 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); |
| 226210 | u64 savedFlag = db->flags & SQLITE_FkNoAction; |
| 226211 | |
| 226212 | if( flags & SQLITE_CHANGESETAPPLY_FKNOACTION ){ |
| 226213 | db->flags |= ((u64)SQLITE_FkNoAction); |
| 226214 | db->aDb[0].pSchema->schema_cookie -= 32; |
| 226215 | } |
| 226216 | |
| 226217 | if( rc==SQLITE_OK ){ |
| 226218 | rc = sessionChangesetApply( |
| 226219 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags |
| 226220 | ); |
| 226221 | } |
| 226222 | |
| 226223 | if( (flags & SQLITE_CHANGESETAPPLY_FKNOACTION) && savedFlag==0 ){ |
| 226224 | assert( db->flags & SQLITE_FkNoAction ); |
| 226225 | db->flags &= ~((u64)SQLITE_FkNoAction); |
| 226226 | db->aDb[0].pSchema->schema_cookie -= 32; |
| 226227 | } |
| 226228 | return rc; |
| 226229 | } |
| 226230 | |
| 226231 | /* |
| 226232 | ** Apply the changeset passed via pChangeset/nChangeset to the main database |
| @@ -224919,10 +226310,13 @@ | |
| 226310 | */ |
| 226311 | struct sqlite3_changegroup { |
| 226312 | int rc; /* Error code */ |
| 226313 | int bPatch; /* True to accumulate patchsets */ |
| 226314 | SessionTable *pList; /* List of tables in current patch */ |
| 226315 | |
| 226316 | sqlite3 *db; /* Configured by changegroup_schema() */ |
| 226317 | char *zDb; /* Configured by changegroup_schema() */ |
| 226318 | }; |
| 226319 | |
| 226320 | /* |
| 226321 | ** This function is called to merge two changes to the same row together as |
| 226322 | ** part of an sqlite3changeset_concat() operation. A new change object is |
| @@ -225103,10 +226497,118 @@ | |
| 226497 | } |
| 226498 | |
| 226499 | *ppNew = pNew; |
| 226500 | return rc; |
| 226501 | } |
| 226502 | |
| 226503 | /* |
| 226504 | ** Check if a changeset entry with nCol columns and the PK array passed |
| 226505 | ** as the final argument to this function is compatible with SessionTable |
| 226506 | ** pTab. If so, return 1. Otherwise, if they are incompatible in some way, |
| 226507 | ** return 0. |
| 226508 | */ |
| 226509 | static int sessionChangesetCheckCompat( |
| 226510 | SessionTable *pTab, |
| 226511 | int nCol, |
| 226512 | u8 *abPK |
| 226513 | ){ |
| 226514 | if( pTab->azCol && nCol<pTab->nCol ){ |
| 226515 | int ii; |
| 226516 | for(ii=0; ii<pTab->nCol; ii++){ |
| 226517 | u8 bPK = (ii < nCol) ? abPK[ii] : 0; |
| 226518 | if( pTab->abPK[ii]!=bPK ) return 0; |
| 226519 | } |
| 226520 | return 1; |
| 226521 | } |
| 226522 | return (pTab->nCol==nCol && 0==memcmp(abPK, pTab->abPK, nCol)); |
| 226523 | } |
| 226524 | |
| 226525 | static int sessionChangesetExtendRecord( |
| 226526 | sqlite3_changegroup *pGrp, |
| 226527 | SessionTable *pTab, |
| 226528 | int nCol, |
| 226529 | int op, |
| 226530 | const u8 *aRec, |
| 226531 | int nRec, |
| 226532 | SessionBuffer *pOut |
| 226533 | ){ |
| 226534 | int rc = SQLITE_OK; |
| 226535 | int ii = 0; |
| 226536 | |
| 226537 | assert( pTab->azCol ); |
| 226538 | assert( nCol<pTab->nCol ); |
| 226539 | |
| 226540 | pOut->nBuf = 0; |
| 226541 | if( op==SQLITE_INSERT || (op==SQLITE_DELETE && pGrp->bPatch==0) ){ |
| 226542 | /* Append the missing default column values to the record. */ |
| 226543 | sessionAppendBlob(pOut, aRec, nRec, &rc); |
| 226544 | if( rc==SQLITE_OK && pTab->pDfltStmt==0 ){ |
| 226545 | rc = sessionPrepareDfltStmt(pGrp->db, pTab, &pTab->pDfltStmt); |
| 226546 | } |
| 226547 | for(ii=nCol; rc==SQLITE_OK && ii<pTab->nCol; ii++){ |
| 226548 | int eType = sqlite3_column_type(pTab->pDfltStmt, ii); |
| 226549 | sessionAppendByte(pOut, eType, &rc); |
| 226550 | switch( eType ){ |
| 226551 | case SQLITE_FLOAT: |
| 226552 | case SQLITE_INTEGER: { |
| 226553 | i64 iVal; |
| 226554 | if( eType==SQLITE_INTEGER ){ |
| 226555 | iVal = sqlite3_column_int64(pTab->pDfltStmt, ii); |
| 226556 | }else{ |
| 226557 | double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii); |
| 226558 | memcpy(&iVal, &rVal, sizeof(i64)); |
| 226559 | } |
| 226560 | if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){ |
| 226561 | sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal); |
| 226562 | } |
| 226563 | break; |
| 226564 | } |
| 226565 | |
| 226566 | case SQLITE_BLOB: |
| 226567 | case SQLITE_TEXT: { |
| 226568 | int n = sqlite3_column_bytes(pTab->pDfltStmt, ii); |
| 226569 | sessionAppendVarint(pOut, n, &rc); |
| 226570 | if( eType==SQLITE_TEXT ){ |
| 226571 | const u8 *z = (const u8*)sqlite3_column_text(pTab->pDfltStmt, ii); |
| 226572 | sessionAppendBlob(pOut, z, n, &rc); |
| 226573 | }else{ |
| 226574 | const u8 *z = (const u8*)sqlite3_column_blob(pTab->pDfltStmt, ii); |
| 226575 | sessionAppendBlob(pOut, z, n, &rc); |
| 226576 | } |
| 226577 | break; |
| 226578 | } |
| 226579 | |
| 226580 | default: |
| 226581 | assert( eType==SQLITE_NULL ); |
| 226582 | break; |
| 226583 | } |
| 226584 | } |
| 226585 | }else if( op==SQLITE_UPDATE ){ |
| 226586 | /* Append missing "undefined" entries to the old.* record. And, if this |
| 226587 | ** is an UPDATE, to the new.* record as well. */ |
| 226588 | int iOff = 0; |
| 226589 | if( pGrp->bPatch==0 ){ |
| 226590 | for(ii=0; ii<nCol; ii++){ |
| 226591 | iOff += sessionSerialLen(&aRec[iOff]); |
| 226592 | } |
| 226593 | sessionAppendBlob(pOut, aRec, iOff, &rc); |
| 226594 | for(ii=0; ii<(pTab->nCol-nCol); ii++){ |
| 226595 | sessionAppendByte(pOut, 0x00, &rc); |
| 226596 | } |
| 226597 | } |
| 226598 | |
| 226599 | sessionAppendBlob(pOut, &aRec[iOff], nRec-iOff, &rc); |
| 226600 | for(ii=0; ii<(pTab->nCol-nCol); ii++){ |
| 226601 | sessionAppendByte(pOut, 0x00, &rc); |
| 226602 | } |
| 226603 | }else{ |
| 226604 | assert( op==SQLITE_DELETE && pGrp->bPatch ); |
| 226605 | sessionAppendBlob(pOut, aRec, nRec, &rc); |
| 226606 | } |
| 226607 | |
| 226608 | return rc; |
| 226609 | } |
| 226610 | |
| 226611 | /* |
| 226612 | ** Add all changes in the changeset traversed by the iterator passed as |
| 226613 | ** the first argument to the changegroup hash tables. |
| 226614 | */ |
| @@ -225117,10 +226619,11 @@ | |
| 226619 | ){ |
| 226620 | u8 *aRec; |
| 226621 | int nRec; |
| 226622 | int rc = SQLITE_OK; |
| 226623 | SessionTable *pTab = 0; |
| 226624 | SessionBuffer rec = {0, 0, 0}; |
| 226625 | |
| 226626 | while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ |
| 226627 | const char *zNew; |
| 226628 | int nCol; |
| 226629 | int op; |
| @@ -225128,10 +226631,13 @@ | |
| 226631 | int bIndirect; |
| 226632 | SessionChange *pChange; |
| 226633 | SessionChange *pExist = 0; |
| 226634 | SessionChange **pp; |
| 226635 | |
| 226636 | /* Ensure that only changesets, or only patchsets, but not a mixture |
| 226637 | ** of both, are being combined. It is an error to try to combine a |
| 226638 | ** changeset and a patchset. */ |
| 226639 | if( pGrp->pList==0 ){ |
| 226640 | pGrp->bPatch = pIter->bPatchset; |
| 226641 | }else if( pIter->bPatchset!=pGrp->bPatch ){ |
| 226642 | rc = SQLITE_ERROR; |
| 226643 | break; |
| @@ -225159,22 +226665,42 @@ | |
| 226665 | pTab->nCol = nCol; |
| 226666 | pTab->abPK = (u8*)&pTab[1]; |
| 226667 | memcpy(pTab->abPK, abPK, nCol); |
| 226668 | pTab->zName = (char*)&pTab->abPK[nCol]; |
| 226669 | memcpy(pTab->zName, zNew, nNew+1); |
| 226670 | |
| 226671 | if( pGrp->db ){ |
| 226672 | pTab->nCol = 0; |
| 226673 | rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); |
| 226674 | if( rc ){ |
| 226675 | assert( pTab->azCol==0 ); |
| 226676 | sqlite3_free(pTab); |
| 226677 | break; |
| 226678 | } |
| 226679 | } |
| 226680 | |
| 226681 | /* The new object must be linked on to the end of the list, not |
| 226682 | ** simply added to the start of it. This is to ensure that the |
| 226683 | ** tables within the output of sqlite3changegroup_output() are in |
| 226684 | ** the right order. */ |
| 226685 | for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); |
| 226686 | *ppTab = pTab; |
| 226687 | } |
| 226688 | |
| 226689 | if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ |
| 226690 | rc = SQLITE_SCHEMA; |
| 226691 | break; |
| 226692 | } |
| 226693 | } |
| 226694 | |
| 226695 | if( nCol<pTab->nCol ){ |
| 226696 | assert( pGrp->db ); |
| 226697 | rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec); |
| 226698 | if( rc ) break; |
| 226699 | aRec = rec.aBuf; |
| 226700 | nRec = rec.nBuf; |
| 226701 | } |
| 226702 | |
| 226703 | if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 226704 | rc = SQLITE_NOMEM; |
| 226705 | break; |
| 226706 | } |
| @@ -225209,10 +226735,11 @@ | |
| 226735 | pTab->apChange[iHash] = pChange; |
| 226736 | pTab->nEntry++; |
| 226737 | } |
| 226738 | } |
| 226739 | |
| 226740 | sqlite3_free(rec.aBuf); |
| 226741 | if( rc==SQLITE_OK ) rc = pIter->rc; |
| 226742 | return rc; |
| 226743 | } |
| 226744 | |
| 226745 | /* |
| @@ -225294,10 +226821,35 @@ | |
| 226821 | memset(p, 0, sizeof(sqlite3_changegroup)); |
| 226822 | } |
| 226823 | *pp = p; |
| 226824 | return rc; |
| 226825 | } |
| 226826 | |
| 226827 | /* |
| 226828 | ** Provide a database schema to the changegroup object. |
| 226829 | */ |
| 226830 | SQLITE_API int sqlite3changegroup_schema( |
| 226831 | sqlite3_changegroup *pGrp, |
| 226832 | sqlite3 *db, |
| 226833 | const char *zDb |
| 226834 | ){ |
| 226835 | int rc = SQLITE_OK; |
| 226836 | |
| 226837 | if( pGrp->pList || pGrp->db ){ |
| 226838 | /* Cannot add a schema after one or more calls to sqlite3changegroup_add(), |
| 226839 | ** or after sqlite3changegroup_schema() has already been called. */ |
| 226840 | rc = SQLITE_MISUSE; |
| 226841 | }else{ |
| 226842 | pGrp->zDb = sqlite3_mprintf("%s", zDb); |
| 226843 | if( pGrp->zDb==0 ){ |
| 226844 | rc = SQLITE_NOMEM; |
| 226845 | }else{ |
| 226846 | pGrp->db = db; |
| 226847 | } |
| 226848 | } |
| 226849 | return rc; |
| 226850 | } |
| 226851 | |
| 226852 | /* |
| 226853 | ** Add the changeset currently stored in buffer pData, size nData bytes, |
| 226854 | ** to changeset-group p. |
| 226855 | */ |
| @@ -225358,10 +226910,11 @@ | |
| 226910 | /* |
| 226911 | ** Delete a changegroup object. |
| 226912 | */ |
| 226913 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ |
| 226914 | if( pGrp ){ |
| 226915 | sqlite3_free(pGrp->zDb); |
| 226916 | sessionDeleteTable(0, pGrp->pList); |
| 226917 | sqlite3_free(pGrp); |
| 226918 | } |
| 226919 | } |
| 226920 | |
| @@ -237534,11 +239087,10 @@ | |
| 239087 | if( res==0 ){ |
| 239088 | assert_nc( i2>i1 ); |
| 239089 | assert_nc( i2!=0 ); |
| 239090 | pRes->bTermEq = 1; |
| 239091 | if( p1->iRowid==p2->iRowid ){ |
| 239092 | return i2; |
| 239093 | } |
| 239094 | res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; |
| 239095 | } |
| 239096 | assert( res!=0 ); |
| @@ -237902,11 +239454,11 @@ | |
| 239454 | static Fts5Iter *fts5MultiIterAlloc( |
| 239455 | Fts5Index *p, /* FTS5 backend to iterate within */ |
| 239456 | int nSeg |
| 239457 | ){ |
| 239458 | Fts5Iter *pNew; |
| 239459 | i64 nSlot; /* Power of two >= nSeg */ |
| 239460 | |
| 239461 | for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2); |
| 239462 | pNew = fts5IdxMalloc(p, |
| 239463 | sizeof(Fts5Iter) + /* pNew */ |
| 239464 | sizeof(Fts5SegIter) * (nSlot-1) + /* pNew->aSeg[] */ |
| @@ -239678,19 +241230,17 @@ | |
| 241230 | u8 *aPg = pSeg->pLeaf->p; |
| 241231 | int nPg = pSeg->pLeaf->nn; |
| 241232 | int iPgIdx = pSeg->pLeaf->szLeaf; |
| 241233 | |
| 241234 | u64 iDelta = 0; |
| 241235 | int iNextOff = 0; |
| 241236 | int iOff = 0; |
| 241237 | int nIdx = 0; |
| 241238 | u8 *aIdx = 0; |
| 241239 | int bLastInDoclist = 0; |
| 241240 | int iIdx = 0; |
| 241241 | int iStart = 0; |
| 241242 | int iDelKeyOff = 0; /* Offset of deleted key, if any */ |
| 241243 | |
| 241244 | nIdx = nPg-iPgIdx; |
| 241245 | aIdx = sqlite3Fts5MallocZero(&p->rc, nIdx+16); |
| 241246 | if( p->rc ) return; |
| @@ -239711,14 +241261,25 @@ | |
| 241261 | ** pSeg->iLeafOffset - the rowid or delta rowid value. |
| 241262 | ** |
| 241263 | ** This block sets the following variables: |
| 241264 | ** |
| 241265 | ** iStart: |
| 241266 | ** The offset of the first byte of the rowid or delta-rowid |
| 241267 | ** value for the doclist entry being removed. |
| 241268 | ** |
| 241269 | ** iDelta: |
| 241270 | ** The value of the rowid or delta-rowid value for the doclist |
| 241271 | ** entry being removed. |
| 241272 | ** |
| 241273 | ** iNextOff: |
| 241274 | ** The offset of the next entry following the position list |
| 241275 | ** for the one being removed. If the position list for this |
| 241276 | ** entry overflows onto the next leaf page, this value will be |
| 241277 | ** greater than pLeaf->szLeaf. |
| 241278 | */ |
| 241279 | { |
| 241280 | int iSOP; /* Start-Of-Position-list */ |
| 241281 | if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ |
| 241282 | iStart = pSeg->iTermLeafOffset; |
| 241283 | }else{ |
| 241284 | iStart = fts5GetU16(&aPg[0]); |
| 241285 | } |
| @@ -239750,51 +241311,79 @@ | |
| 241311 | iNextOff = pSeg->iLeafOffset + pSeg->nPos; |
| 241312 | } |
| 241313 | } |
| 241314 | |
| 241315 | iOff = iStart; |
| 241316 | |
| 241317 | /* Set variable bLastInDoclist to true if this entry happens to be |
| 241318 | ** the last rowid in the doclist for its term. */ |
| 241319 | if( pSeg->bDel==0 ){ |
| 241320 | if( iNextOff>=iPgIdx ){ |
| 241321 | int pgno = pSeg->iLeafPgno+1; |
| 241322 | fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); |
| 241323 | iNextOff = iPgIdx; |
| 241324 | }else{ |
| 241325 | /* Loop through the page-footer. If iNextOff (offset of the |
| 241326 | ** entry following the one we are removing) is equal to the |
| 241327 | ** offset of a key on this page, then the entry is the last |
| 241328 | ** in its doclist. */ |
| 241329 | int iKeyOff = 0; |
| 241330 | for(iIdx=0; iIdx<nIdx; /* no-op */){ |
| 241331 | u32 iVal = 0; |
| 241332 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 241333 | iKeyOff += iVal; |
| 241334 | if( iKeyOff==iNextOff ){ |
| 241335 | bLastInDoclist = 1; |
| 241336 | } |
| 241337 | } |
| 241338 | } |
| 241339 | |
| 241340 | /* If this is (a) the first rowid on a page and (b) is not followed by |
| 241341 | ** another position list on the same page, set the "first-rowid" field |
| 241342 | ** of the header to 0. */ |
| 241343 | if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist || iNextOff==iPgIdx) ){ |
| 241344 | fts5PutU16(&aPg[0], 0); |
| 241345 | } |
| 241346 | } |
| 241347 | |
| 241348 | if( pSeg->bDel ){ |
| 241349 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta); |
| 241350 | aPg[iOff++] = 0x01; |
| 241351 | }else if( bLastInDoclist==0 ){ |
| 241352 | if( iNextOff!=iPgIdx ){ |
| 241353 | u64 iNextDelta = 0; |
| 241354 | iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); |
| 241355 | iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); |
| 241356 | } |
| 241357 | }else if( |
| 241358 | pSeg->iLeafPgno==pSeg->iTermLeafPgno |
| 241359 | && iStart==pSeg->iTermLeafOffset |
| 241360 | ){ |
| 241361 | /* The entry being removed was the only position list in its |
| 241362 | ** doclist. Therefore the term needs to be removed as well. */ |
| 241363 | int iKey = 0; |
| 241364 | int iKeyOff = 0; |
| 241365 | |
| 241366 | /* Set iKeyOff to the offset of the term that will be removed - the |
| 241367 | ** last offset in the footer that is not greater than iStart. */ |
| 241368 | for(iIdx=0; iIdx<nIdx; iKey++){ |
| 241369 | u32 iVal = 0; |
| 241370 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 241371 | if( (iKeyOff+iVal)>(u32)iStart ) break; |
| 241372 | iKeyOff += iVal; |
| 241373 | } |
| 241374 | assert_nc( iKey>=1 ); |
| 241375 | |
| 241376 | /* Set iDelKeyOff to the value of the footer entry to remove from |
| 241377 | ** the page. */ |
| 241378 | iDelKeyOff = iOff = iKeyOff; |
| 241379 | |
| 241380 | if( iNextOff!=iPgIdx ){ |
| 241381 | /* This is the only position-list associated with the term, and there |
| 241382 | ** is another term following it on this page. So the subsequent term |
| 241383 | ** needs to be moved to replace the term associated with the entry |
| 241384 | ** being removed. */ |
| 241385 | int nPrefix = 0; |
| 241386 | int nSuffix = 0; |
| 241387 | int nPrefix2 = 0; |
| 241388 | int nSuffix2 = 0; |
| 241389 | |
| @@ -239869,10 +241458,19 @@ | |
| 241458 | } |
| 241459 | fts5DataRelease(pTerm); |
| 241460 | } |
| 241461 | } |
| 241462 | |
| 241463 | /* Assuming no error has occurred, this block does final edits to the |
| 241464 | ** leaf page before writing it back to disk. Input variables are: |
| 241465 | ** |
| 241466 | ** nPg: Total initial size of leaf page. |
| 241467 | ** iPgIdx: Initial offset of page footer. |
| 241468 | ** |
| 241469 | ** iOff: Offset to move data to |
| 241470 | ** iNextOff: Offset to move data from |
| 241471 | */ |
| 241472 | if( p->rc==SQLITE_OK ){ |
| 241473 | const int nMove = nPg - iNextOff; /* Number of bytes to move */ |
| 241474 | int nShift = iNextOff - iOff; /* Distance to move them */ |
| 241475 | |
| 241476 | int iPrevKeyOut = 0; |
| @@ -240069,14 +241667,20 @@ | |
| 241667 | } |
| 241668 | if( (pBuf->n + pPgidx->n)>=pgsz ){ |
| 241669 | fts5WriteFlushLeaf(p, &writer); |
| 241670 | } |
| 241671 | }else{ |
| 241672 | int bDel = 0; |
| 241673 | int nPos = 0; |
| 241674 | int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDel); |
| 241675 | if( bDel && bSecureDelete ){ |
| 241676 | fts5BufferAppendVarint(&p->rc, pBuf, nPos*2); |
| 241677 | iOff += nCopy; |
| 241678 | nCopy = nPos; |
| 241679 | }else{ |
| 241680 | nCopy += nPos; |
| 241681 | } |
| 241682 | if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ |
| 241683 | /* The entire poslist will fit on the current leaf. So copy |
| 241684 | ** it in one go. */ |
| 241685 | fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); |
| 241686 | }else{ |
| @@ -240110,11 +241714,10 @@ | |
| 241714 | /* TODO2: Doclist terminator written here. */ |
| 241715 | /* pBuf->p[pBuf->n++] = '\0'; */ |
| 241716 | assert( pBuf->n<=pBuf->nSpace ); |
| 241717 | if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); |
| 241718 | } |
| 241719 | fts5WriteFinish(p, &writer, &pgnoLast); |
| 241720 | |
| 241721 | assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); |
| 241722 | if( pgnoLast>0 ){ |
| 241723 | /* Update the Fts5Structure. It is written back to the database by the |
| @@ -240143,11 +241746,10 @@ | |
| 241746 | |
| 241747 | fts5IndexAutomerge(p, &pStruct, pgnoLast + p->nContentlessDelete); |
| 241748 | fts5IndexCrisismerge(p, &pStruct); |
| 241749 | fts5StructureWrite(p, pStruct); |
| 241750 | fts5StructureRelease(pStruct); |
| 241751 | } |
| 241752 | |
| 241753 | /* |
| 241754 | ** Flush any data stored in the in-memory hash tables to the database. |
| 241755 | */ |
| @@ -240154,12 +241756,16 @@ | |
| 241756 | static void fts5IndexFlush(Fts5Index *p){ |
| 241757 | /* Unless it is empty, flush the hash table to disk */ |
| 241758 | if( p->nPendingData || p->nContentlessDelete ){ |
| 241759 | assert( p->pHash ); |
| 241760 | fts5FlushOneHash(p); |
| 241761 | if( p->rc==SQLITE_OK ){ |
| 241762 | sqlite3Fts5HashClear(p->pHash); |
| 241763 | p->nPendingData = 0; |
| 241764 | p->nPendingRow = 0; |
| 241765 | p->nContentlessDelete = 0; |
| 241766 | } |
| 241767 | } |
| 241768 | } |
| 241769 | |
| 241770 | static Fts5Structure *fts5IndexOptimizeStruct( |
| 241771 | Fts5Index *p, |
| @@ -242897,11 +244503,12 @@ | |
| 244503 | 0, /* xFindFunction */ |
| 244504 | 0, /* xRename */ |
| 244505 | 0, /* xSavepoint */ |
| 244506 | 0, /* xRelease */ |
| 244507 | 0, /* xRollbackTo */ |
| 244508 | 0, /* xShadowName */ |
| 244509 | 0 /* xIntegrity */ |
| 244510 | }; |
| 244511 | rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); |
| 244512 | } |
| 244513 | return rc; |
| 244514 | #else |
| @@ -243036,10 +244643,12 @@ | |
| 244643 | struct Fts5FullTable { |
| 244644 | Fts5Table p; /* Public class members from fts5Int.h */ |
| 244645 | Fts5Storage *pStorage; /* Document store */ |
| 244646 | Fts5Global *pGlobal; /* Global (connection wide) data */ |
| 244647 | Fts5Cursor *pSortCsr; /* Sort data from this cursor */ |
| 244648 | int iSavepoint; /* Successful xSavepoint()+1 */ |
| 244649 | int bInSavepoint; |
| 244650 | #ifdef SQLITE_DEBUG |
| 244651 | struct Fts5TransactionState ts; |
| 244652 | #endif |
| 244653 | }; |
| 244654 | |
| @@ -243323,10 +244932,17 @@ | |
| 244932 | pConfig->pzErrmsg = pzErr; |
| 244933 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 244934 | sqlite3Fts5IndexRollback(pTab->p.pIndex); |
| 244935 | pConfig->pzErrmsg = 0; |
| 244936 | } |
| 244937 | |
| 244938 | if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
| 244939 | rc = sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, (int)1); |
| 244940 | } |
| 244941 | if( rc==SQLITE_OK ){ |
| 244942 | rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); |
| 244943 | } |
| 244944 | |
| 244945 | if( rc!=SQLITE_OK ){ |
| 244946 | fts5FreeVtab(pTab); |
| 244947 | pTab = 0; |
| 244948 | }else if( bCreate ){ |
| @@ -244248,10 +245864,13 @@ | |
| 245864 | }else{ |
| 245865 | pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); |
| 245866 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); |
| 245867 | } |
| 245868 | |
| 245869 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 245870 | if( rc!=SQLITE_OK ) goto filter_out; |
| 245871 | |
| 245872 | if( pTab->pSortCsr ){ |
| 245873 | /* If pSortCsr is non-NULL, then this call is being made as part of |
| 245874 | ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is |
| 245875 | ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will |
| 245876 | ** return results to the user for this query. The current cursor |
| @@ -244270,10 +245889,11 @@ | |
| 245889 | } |
| 245890 | pCsr->ePlan = FTS5_PLAN_SOURCE; |
| 245891 | pCsr->pExpr = pTab->pSortCsr->pExpr; |
| 245892 | rc = fts5CursorFirst(pTab, pCsr, bDesc); |
| 245893 | }else if( pCsr->pExpr ){ |
| 245894 | assert( rc==SQLITE_OK ); |
| 245895 | rc = fts5CursorParseRank(pConfig, pCsr, pRank); |
| 245896 | if( rc==SQLITE_OK ){ |
| 245897 | if( bOrderByRank ){ |
| 245898 | pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; |
| 245899 | rc = fts5CursorFirstSorted(pTab, pCsr, bDesc); |
| @@ -244441,10 +246061,11 @@ | |
| 246061 | sqlite3_value *pVal /* Value inserted into rank column */ |
| 246062 | ){ |
| 246063 | Fts5Config *pConfig = pTab->p.pConfig; |
| 246064 | int rc = SQLITE_OK; |
| 246065 | int bError = 0; |
| 246066 | int bLoadConfig = 0; |
| 246067 | |
| 246068 | if( 0==sqlite3_stricmp("delete-all", zCmd) ){ |
| 246069 | if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
| 246070 | fts5SetVtabError(pTab, |
| 246071 | "'delete-all' may only be used with a " |
| @@ -244452,19 +246073,21 @@ | |
| 246073 | ); |
| 246074 | rc = SQLITE_ERROR; |
| 246075 | }else{ |
| 246076 | rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); |
| 246077 | } |
| 246078 | bLoadConfig = 1; |
| 246079 | }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ |
| 246080 | if( pConfig->eContent==FTS5_CONTENT_NONE ){ |
| 246081 | fts5SetVtabError(pTab, |
| 246082 | "'rebuild' may not be used with a contentless fts5 table" |
| 246083 | ); |
| 246084 | rc = SQLITE_ERROR; |
| 246085 | }else{ |
| 246086 | rc = sqlite3Fts5StorageRebuild(pTab->pStorage); |
| 246087 | } |
| 246088 | bLoadConfig = 1; |
| 246089 | }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ |
| 246090 | rc = sqlite3Fts5StorageOptimize(pTab->pStorage); |
| 246091 | }else if( 0==sqlite3_stricmp("merge", zCmd) ){ |
| 246092 | int nMerge = sqlite3_value_int(pVal); |
| 246093 | rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge); |
| @@ -244473,10 +246096,12 @@ | |
| 246096 | rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, iArg); |
| 246097 | #ifdef SQLITE_DEBUG |
| 246098 | }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ |
| 246099 | pConfig->bPrefixIndex = sqlite3_value_int(pVal); |
| 246100 | #endif |
| 246101 | }else if( 0==sqlite3_stricmp("flush", zCmd) ){ |
| 246102 | rc = sqlite3Fts5FlushToDisk(&pTab->p); |
| 246103 | }else{ |
| 246104 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 246105 | if( rc==SQLITE_OK ){ |
| 246106 | rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError); |
| 246107 | } |
| @@ -244486,10 +246111,16 @@ | |
| 246111 | }else{ |
| 246112 | rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0); |
| 246113 | } |
| 246114 | } |
| 246115 | } |
| 246116 | |
| 246117 | if( rc==SQLITE_OK && bLoadConfig ){ |
| 246118 | pTab->p.pConfig->iCookie--; |
| 246119 | rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 246120 | } |
| 246121 | |
| 246122 | return rc; |
| 246123 | } |
| 246124 | |
| 246125 | static int fts5SpecialDelete( |
| 246126 | Fts5FullTable *pTab, |
| @@ -244604,11 +246235,11 @@ | |
| 246235 | |
| 246236 | assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); |
| 246237 | assert( nArg!=1 || eType0==SQLITE_INTEGER ); |
| 246238 | |
| 246239 | /* Filter out attempts to run UPDATE or DELETE on contentless tables. |
| 246240 | ** This is not suported. Except - they are both supported if the CREATE |
| 246241 | ** VIRTUAL TABLE statement contained "contentless_delete=1". */ |
| 246242 | if( eType0==SQLITE_INTEGER |
| 246243 | && pConfig->eContent==FTS5_CONTENT_NONE |
| 246244 | && pConfig->bContentlessDelete==0 |
| 246245 | ){ |
| @@ -244633,11 +246264,12 @@ | |
| 246264 | if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ |
| 246265 | rc = SQLITE_MISMATCH; |
| 246266 | } |
| 246267 | |
| 246268 | else if( eType0!=SQLITE_INTEGER ){ |
| 246269 | /* An INSERT statement. If the conflict-mode is REPLACE, first remove |
| 246270 | ** the current entry (if any). */ |
| 246271 | if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ |
| 246272 | i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ |
| 246273 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); |
| 246274 | bUpdateOrDelete = 1; |
| 246275 | } |
| @@ -245507,12 +247139,16 @@ | |
| 247139 | */ |
| 247140 | static int fts5RenameMethod( |
| 247141 | sqlite3_vtab *pVtab, /* Virtual table handle */ |
| 247142 | const char *zName /* New name of table */ |
| 247143 | ){ |
| 247144 | int rc; |
| 247145 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 247146 | pTab->bInSavepoint = 1; |
| 247147 | rc = sqlite3Fts5StorageRename(pTab->pStorage, zName); |
| 247148 | pTab->bInSavepoint = 0; |
| 247149 | return rc; |
| 247150 | } |
| 247151 | |
| 247152 | static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ |
| 247153 | fts5TripCursors((Fts5FullTable*)pTab); |
| 247154 | return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage); |
| @@ -245522,38 +247158,68 @@ | |
| 247158 | ** The xSavepoint() method. |
| 247159 | ** |
| 247160 | ** Flush the contents of the pending-terms table to disk. |
| 247161 | */ |
| 247162 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 247163 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 247164 | int rc = SQLITE_OK; |
| 247165 | char *zSql = 0; |
| 247166 | fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); |
| 247167 | |
| 247168 | if( pTab->bInSavepoint==0 ){ |
| 247169 | zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", |
| 247170 | pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName |
| 247171 | ); |
| 247172 | if( zSql ){ |
| 247173 | pTab->bInSavepoint = 1; |
| 247174 | rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0); |
| 247175 | pTab->bInSavepoint = 0; |
| 247176 | sqlite3_free(zSql); |
| 247177 | }else{ |
| 247178 | rc = SQLITE_NOMEM; |
| 247179 | } |
| 247180 | if( rc==SQLITE_OK ){ |
| 247181 | pTab->iSavepoint = iSavepoint+1; |
| 247182 | } |
| 247183 | } |
| 247184 | |
| 247185 | return rc; |
| 247186 | } |
| 247187 | |
| 247188 | /* |
| 247189 | ** The xRelease() method. |
| 247190 | ** |
| 247191 | ** This is a no-op. |
| 247192 | */ |
| 247193 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 247194 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 247195 | int rc = SQLITE_OK; |
| 247196 | fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); |
| 247197 | if( (iSavepoint+1)<pTab->iSavepoint ){ |
| 247198 | rc = sqlite3Fts5FlushToDisk(&pTab->p); |
| 247199 | if( rc==SQLITE_OK ){ |
| 247200 | pTab->iSavepoint = iSavepoint; |
| 247201 | } |
| 247202 | } |
| 247203 | return rc; |
| 247204 | } |
| 247205 | |
| 247206 | /* |
| 247207 | ** The xRollbackTo() method. |
| 247208 | ** |
| 247209 | ** Discard the contents of the pending terms table. |
| 247210 | */ |
| 247211 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 247212 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 247213 | int rc = SQLITE_OK; |
| 247214 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); |
| 247215 | fts5TripCursors(pTab); |
| 247216 | pTab->p.pConfig->pgsz = 0; |
| 247217 | if( (iSavepoint+1)<=pTab->iSavepoint ){ |
| 247218 | rc = sqlite3Fts5StorageRollback(pTab->pStorage); |
| 247219 | } |
| 247220 | return rc; |
| 247221 | } |
| 247222 | |
| 247223 | /* |
| 247224 | ** Register a new auxiliary function with global context pGlobal. |
| 247225 | */ |
| @@ -245751,11 +247417,11 @@ | |
| 247417 | int nArg, /* Number of args */ |
| 247418 | sqlite3_value **apUnused /* Function arguments */ |
| 247419 | ){ |
| 247420 | assert( nArg==0 ); |
| 247421 | UNUSED_PARAM2(nArg, apUnused); |
| 247422 | sqlite3_result_text(pCtx, "fts5: 2023-10-21 18:12:07 7f41d7006db4225cf9b3d197d3a76842778669ac079e76361214a8023c9976e6", -1, SQLITE_TRANSIENT); |
| 247423 | } |
| 247424 | |
| 247425 | /* |
| 247426 | ** Return true if zName is the extension on one of the shadow tables used |
| 247427 | ** by this module. |
| @@ -245768,14 +247434,38 @@ | |
| 247434 | for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){ |
| 247435 | if( sqlite3_stricmp(zName, azName[i])==0 ) return 1; |
| 247436 | } |
| 247437 | return 0; |
| 247438 | } |
| 247439 | |
| 247440 | /* |
| 247441 | ** Run an integrity check on the FTS5 data structures. Return a string |
| 247442 | ** if anything is found amiss. Return a NULL pointer if everything is |
| 247443 | ** OK. |
| 247444 | */ |
| 247445 | static int fts5Integrity(sqlite3_vtab *pVtab, char **pzErr){ |
| 247446 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 247447 | Fts5Config *pConfig = pTab->p.pConfig; |
| 247448 | char *zSql; |
| 247449 | int rc; |
| 247450 | zSql = sqlite3_mprintf( |
| 247451 | "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", |
| 247452 | pConfig->zDb, pConfig->zName, pConfig->zName); |
| 247453 | rc = sqlite3_exec(pConfig->db, zSql, 0, 0, 0); |
| 247454 | sqlite3_free(zSql); |
| 247455 | if( (rc&0xff)==SQLITE_CORRUPT ){ |
| 247456 | *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", |
| 247457 | pConfig->zDb, pConfig->zName); |
| 247458 | rc = SQLITE_OK; |
| 247459 | } |
| 247460 | return rc; |
| 247461 | |
| 247462 | } |
| 247463 | |
| 247464 | static int fts5Init(sqlite3 *db){ |
| 247465 | static const sqlite3_module fts5Mod = { |
| 247466 | /* iVersion */ 4, |
| 247467 | /* xCreate */ fts5CreateMethod, |
| 247468 | /* xConnect */ fts5ConnectMethod, |
| 247469 | /* xBestIndex */ fts5BestIndexMethod, |
| 247470 | /* xDisconnect */ fts5DisconnectMethod, |
| 247471 | /* xDestroy */ fts5DestroyMethod, |
| @@ -245794,11 +247484,12 @@ | |
| 247484 | /* xFindFunction */ fts5FindFunctionMethod, |
| 247485 | /* xRename */ fts5RenameMethod, |
| 247486 | /* xSavepoint */ fts5SavepointMethod, |
| 247487 | /* xRelease */ fts5ReleaseMethod, |
| 247488 | /* xRollbackTo */ fts5RollbackToMethod, |
| 247489 | /* xShadowName */ fts5ShadowName, |
| 247490 | /* xIntegrity */ fts5Integrity |
| 247491 | }; |
| 247492 | |
| 247493 | int rc; |
| 247494 | Fts5Global *pGlobal = 0; |
| 247495 | |
| @@ -247071,11 +248762,13 @@ | |
| 248762 | static int sqlite3Fts5StorageSync(Fts5Storage *p){ |
| 248763 | int rc = SQLITE_OK; |
| 248764 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 248765 | if( p->bTotalsValid ){ |
| 248766 | rc = fts5StorageSaveTotals(p); |
| 248767 | if( rc==SQLITE_OK ){ |
| 248768 | p->bTotalsValid = 0; |
| 248769 | } |
| 248770 | } |
| 248771 | if( rc==SQLITE_OK ){ |
| 248772 | rc = sqlite3Fts5IndexSync(p->pIndex); |
| 248773 | } |
| 248774 | sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid); |
| @@ -250439,11 +252132,12 @@ | |
| 252132 | /* xFindFunction */ 0, |
| 252133 | /* xRename */ 0, |
| 252134 | /* xSavepoint */ 0, |
| 252135 | /* xRelease */ 0, |
| 252136 | /* xRollbackTo */ 0, |
| 252137 | /* xShadowName */ 0, |
| 252138 | /* xIntegrity */ 0 |
| 252139 | }; |
| 252140 | void *p = (void*)pGlobal; |
| 252141 | |
| 252142 | return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0); |
| 252143 | } |
| @@ -250768,10 +252462,11 @@ | |
| 252462 | 0, /* xRename */ |
| 252463 | 0, /* xSavepoint */ |
| 252464 | 0, /* xRelease */ |
| 252465 | 0, /* xRollbackTo */ |
| 252466 | 0, /* xShadowName */ |
| 252467 | 0 /* xIntegrity */ |
| 252468 | }; |
| 252469 | |
| 252470 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 252471 | |
| 252472 | SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){ |
| 252473 |
+159
-24
| --- extsrc/sqlite3.h | ||
| +++ extsrc/sqlite3.h | ||
| @@ -144,13 +144,13 @@ | ||
| 144 | 144 | ** |
| 145 | 145 | ** See also: [sqlite3_libversion()], |
| 146 | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | 148 | */ |
| 149 | -#define SQLITE_VERSION "3.43.1" | |
| 150 | -#define SQLITE_VERSION_NUMBER 3043001 | |
| 151 | -#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" | |
| 149 | +#define SQLITE_VERSION "3.44.0" | |
| 150 | +#define SQLITE_VERSION_NUMBER 3044000 | |
| 151 | +#define SQLITE_SOURCE_ID "2023-10-21 20:34:57 023a9dbe83c0042e9d500e3ae6c0592a468982e4ac278d08c9201967506c7555" | |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | 156 | ** |
| @@ -5322,10 +5322,11 @@ | ||
| 5322 | 5322 | ** |
| 5323 | 5323 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 5324 | 5324 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 5325 | 5325 | */ |
| 5326 | 5326 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5327 | + | |
| 5327 | 5328 | |
| 5328 | 5329 | /* |
| 5329 | 5330 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5330 | 5331 | ** KEYWORDS: {function creation routines} |
| 5331 | 5332 | ** METHOD: sqlite3 |
| @@ -5877,36 +5878,36 @@ | ||
| 5877 | 5878 | /* |
| 5878 | 5879 | ** CAPI3REF: Function Auxiliary Data |
| 5879 | 5880 | ** METHOD: sqlite3_context |
| 5880 | 5881 | ** |
| 5881 | 5882 | ** These functions may be used by (non-aggregate) SQL functions to |
| 5882 | -** associate metadata with argument values. If the same value is passed to | |
| 5883 | -** multiple invocations of the same SQL function during query execution, under | |
| 5884 | -** some circumstances the associated metadata may be preserved. An example | |
| 5885 | -** of where this might be useful is in a regular-expression matching | |
| 5886 | -** function. The compiled version of the regular expression can be stored as | |
| 5887 | -** metadata associated with the pattern string. | |
| 5883 | +** associate auxiliary data with argument values. If the same argument | |
| 5884 | +** value is passed to multiple invocations of the same SQL function during | |
| 5885 | +** query execution, under some circumstances the associated auxiliary data | |
| 5886 | +** might be preserved. An example of where this might be useful is in a | |
| 5887 | +** regular-expression matching function. The compiled version of the regular | |
| 5888 | +** expression can be stored as auxiliary data associated with the pattern string. | |
| 5888 | 5889 | ** Then as long as the pattern string remains the same, |
| 5889 | 5890 | ** the compiled regular expression can be reused on multiple |
| 5890 | 5891 | ** invocations of the same function. |
| 5891 | 5892 | ** |
| 5892 | -** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata | |
| 5893 | +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data | |
| 5893 | 5894 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 5894 | 5895 | ** value to the application-defined function. ^N is zero for the left-most |
| 5895 | -** function argument. ^If there is no metadata | |
| 5896 | +** function argument. ^If there is no auxiliary data | |
| 5896 | 5897 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 5897 | 5898 | ** returns a NULL pointer. |
| 5898 | 5899 | ** |
| 5899 | -** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th | |
| 5900 | -** argument of the application-defined function. ^Subsequent | |
| 5900 | +** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the | |
| 5901 | +** N-th argument of the application-defined function. ^Subsequent | |
| 5901 | 5902 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| 5902 | -** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or | |
| 5903 | -** NULL if the metadata has been discarded. | |
| 5903 | +** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or | |
| 5904 | +** NULL if the auxiliary data has been discarded. | |
| 5904 | 5905 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 5905 | 5906 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 5906 | -** once, when the metadata is discarded. | |
| 5907 | -** SQLite is free to discard the metadata at any time, including: <ul> | |
| 5907 | +** once, when the auxiliary data is discarded. | |
| 5908 | +** SQLite is free to discard the auxiliary data at any time, including: <ul> | |
| 5908 | 5909 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 5909 | 5910 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 5910 | 5911 | ** SQL statement)^, or |
| 5911 | 5912 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 5912 | 5913 | ** parameter)^, or |
| @@ -5918,24 +5919,81 @@ | ||
| 5918 | 5919 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 5919 | 5920 | ** should be called near the end of the function implementation and the |
| 5920 | 5921 | ** function implementation should not make any use of P after |
| 5921 | 5922 | ** sqlite3_set_auxdata() has been called. |
| 5922 | 5923 | ** |
| 5923 | -** ^(In practice, metadata is preserved between function calls for | |
| 5924 | +** ^(In practice, auxiliary data is preserved between function calls for | |
| 5924 | 5925 | ** function parameters that are compile-time constants, including literal |
| 5925 | 5926 | ** values and [parameters] and expressions composed from the same.)^ |
| 5926 | 5927 | ** |
| 5927 | 5928 | ** The value of the N parameter to these interfaces should be non-negative. |
| 5928 | 5929 | ** Future enhancements may make use of negative N values to define new |
| 5929 | 5930 | ** kinds of function caching behavior. |
| 5930 | 5931 | ** |
| 5931 | 5932 | ** These routines must be called from the same thread in which |
| 5932 | 5933 | ** the SQL function is running. |
| 5934 | +** | |
| 5935 | +** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. | |
| 5933 | 5936 | */ |
| 5934 | 5937 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 5935 | 5938 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 5936 | 5939 | |
| 5940 | +/* | |
| 5941 | +** CAPI3REF: Database Connection Client Data | |
| 5942 | +** METHOD: sqlite3 | |
| 5943 | +** | |
| 5944 | +** These functions are used to associate one or more named pointers | |
| 5945 | +** with a [database connection]. | |
| 5946 | +** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P | |
| 5947 | +** to be attached to [database connection] D using name N. Subsequent | |
| 5948 | +** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P | |
| 5949 | +** or a NULL pointer if there were no prior calls to | |
| 5950 | +** sqlite3_set_clientdata() with the same values of D and N. | |
| 5951 | +** Names are compared using strcmp() and are thus case sensitive. | |
| 5952 | +** | |
| 5953 | +** If P and X are both non-NULL, then the destructor X is invoked with | |
| 5954 | +** argument P on the first of the following occurrences: | |
| 5955 | +** <ul> | |
| 5956 | +** <li> An out-of-memory error occurs during the call to | |
| 5957 | +** sqlite3_set_clientdata() which attempts to register pointer P. | |
| 5958 | +** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made | |
| 5959 | +** with the same D and N parameters. | |
| 5960 | +** <li> The database connection closes. SQLite does not make any guarantees | |
| 5961 | +** about the order in which destructors are called, only that all | |
| 5962 | +** destructors will be called exactly once at some point during the | |
| 5963 | +** database connection closingi process. | |
| 5964 | +** </ul> | |
| 5965 | +** | |
| 5966 | +** SQLite does not do anything with client data other than invoke | |
| 5967 | +** destructors on the client data at the appropriate time. The intended | |
| 5968 | +** use for client data is to provide a mechanism for wrapper libraries | |
| 5969 | +** to store additional information about an SQLite database connection. | |
| 5970 | +** | |
| 5971 | +** There is no limit (other than available memory) on the number of different | |
| 5972 | +** client data pointers (with different names) that can be attached to a | |
| 5973 | +** single database connection. However, the implementation is optimized | |
| 5974 | +** for the case of having only one or two different client data names. | |
| 5975 | +** Applications and wrapper libraries are discouraged from using more than | |
| 5976 | +** one client data name each. | |
| 5977 | +** | |
| 5978 | +** There is no way to enumerate the client data pointers | |
| 5979 | +** associated with a database connection. The N parameter can be thought | |
| 5980 | +** of as a secret key such that only code that knows the secret key is able | |
| 5981 | +** to access the associated data. | |
| 5982 | +** | |
| 5983 | +** Security Warning: These interfaces should not be exposed in scripting | |
| 5984 | +** languages or in other circumstances where it might be possible for an | |
| 5985 | +** an attacker to invoke them. Any agent that can invoke these interfaces | |
| 5986 | +** can probably also take control of the process. | |
| 5987 | +** | |
| 5988 | +** Database connection client data is only available for SQLite | |
| 5989 | +** version 3.44.0 ([dateof:3.44.0]) and later. | |
| 5990 | +** | |
| 5991 | +** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. | |
| 5992 | +*/ | |
| 5993 | +SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); | |
| 5994 | +SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); | |
| 5937 | 5995 | |
| 5938 | 5996 | /* |
| 5939 | 5997 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 5940 | 5998 | ** |
| 5941 | 5999 | ** These are special values for the destructor that is passed in as the |
| @@ -7215,10 +7273,13 @@ | ||
| 7215 | 7273 | int (*xRelease)(sqlite3_vtab *pVTab, int); |
| 7216 | 7274 | int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
| 7217 | 7275 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7218 | 7276 | ** Those below are for version 3 and greater. */ |
| 7219 | 7277 | int (*xShadowName)(const char*); |
| 7278 | + /* The methods above are in versions 1 through 3 of the sqlite_module object. | |
| 7279 | + ** Those below are for version 4 and greater. */ | |
| 7280 | + int (*xIntegrity)(sqlite3_vtab *pVTab, char**); | |
| 7220 | 7281 | }; |
| 7221 | 7282 | |
| 7222 | 7283 | /* |
| 7223 | 7284 | ** CAPI3REF: Virtual Table Indexing Information |
| 7224 | 7285 | ** KEYWORDS: sqlite3_index_info |
| @@ -8182,10 +8243,11 @@ | ||
| 8182 | 8243 | */ |
| 8183 | 8244 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8184 | 8245 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8185 | 8246 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8186 | 8247 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8248 | +#define SQLITE_TESTCTRL_FK_NO_ACTION 7 | |
| 8187 | 8249 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8188 | 8250 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8189 | 8251 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8190 | 8252 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8191 | 8253 | #define SQLITE_TESTCTRL_ASSERT 12 |
| @@ -10546,10 +10608,17 @@ | ||
| 10546 | 10608 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 10547 | 10609 | ** values of D and S. |
| 10548 | 10610 | ** The size of the database is written into *P even if the |
| 10549 | 10611 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10550 | 10612 | ** of the database exists. |
| 10613 | +** | |
| 10614 | +** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, | |
| 10615 | +** the returned buffer content will remain accessible and unchanged | |
| 10616 | +** until either the next write operation on the connection or when | |
| 10617 | +** the connection is closed, and applications must not modify the | |
| 10618 | +** buffer. If the bit had been clear, the returned buffer will not | |
| 10619 | +** be accessed by SQLite after the call. | |
| 10551 | 10620 | ** |
| 10552 | 10621 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10553 | 10622 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10554 | 10623 | ** allocation error occurs. |
| 10555 | 10624 | ** |
| @@ -10594,18 +10663,28 @@ | ||
| 10594 | 10663 | ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will |
| 10595 | 10664 | ** invoke sqlite3_free() on the serialization buffer when the database |
| 10596 | 10665 | ** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then |
| 10597 | 10666 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() |
| 10598 | 10667 | ** if writes on the database cause it to grow larger than M bytes. |
| 10668 | +** | |
| 10669 | +** Applications must not modify the buffer P or invalidate it before | |
| 10670 | +** the database connection D is closed. | |
| 10599 | 10671 | ** |
| 10600 | 10672 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 10601 | 10673 | ** database is currently in a read transaction or is involved in a backup |
| 10602 | 10674 | ** operation. |
| 10603 | 10675 | ** |
| 10604 | 10676 | ** It is not possible to deserialized into the TEMP database. If the |
| 10605 | 10677 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10606 | 10678 | ** function returns SQLITE_ERROR. |
| 10679 | +** | |
| 10680 | +** The deserialized database should not be in [WAL mode]. If the database | |
| 10681 | +** is in WAL mode, then any attempt to use the database file will result | |
| 10682 | +** in an [SQLITE_CANTOPEN] error. The application can set the | |
| 10683 | +** [file format version numbers] (bytes 18 and 19) of the input database P | |
| 10684 | +** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the | |
| 10685 | +** database file into rollback mode and work around this limitation. | |
| 10607 | 10686 | ** |
| 10608 | 10687 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10609 | 10688 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10610 | 10689 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10611 | 10690 | ** |
| @@ -11674,10 +11753,22 @@ | ||
| 11674 | 11753 | void *pB, /* Pointer to buffer containing changeset B */ |
| 11675 | 11754 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| 11676 | 11755 | void **ppOut /* OUT: Buffer containing output changeset */ |
| 11677 | 11756 | ); |
| 11678 | 11757 | |
| 11758 | + | |
| 11759 | +/* | |
| 11760 | +** CAPI3REF: Upgrade the Schema of a Changeset/Patchset | |
| 11761 | +*/ | |
| 11762 | +SQLITE_API int sqlite3changeset_upgrade( | |
| 11763 | + sqlite3 *db, | |
| 11764 | + const char *zDb, | |
| 11765 | + int nIn, const void *pIn, /* Input changeset */ | |
| 11766 | + int *pnOut, void **ppOut /* OUT: Inverse of input */ | |
| 11767 | +); | |
| 11768 | + | |
| 11769 | + | |
| 11679 | 11770 | |
| 11680 | 11771 | /* |
| 11681 | 11772 | ** CAPI3REF: Changegroup Handle |
| 11682 | 11773 | ** |
| 11683 | 11774 | ** A changegroup is an object used to combine two or more |
| @@ -11721,10 +11812,42 @@ | ||
| 11721 | 11812 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 11722 | 11813 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 11723 | 11814 | */ |
| 11724 | 11815 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 11725 | 11816 | |
| 11817 | +/* | |
| 11818 | +** CAPI3REF: Add a Schema to a Changegroup | |
| 11819 | +** METHOD: sqlite3_changegroup_schema | |
| 11820 | +** | |
| 11821 | +** This method may be used to optionally enforce the rule that the changesets | |
| 11822 | +** added to the changegroup handle must match the schema of database zDb | |
| 11823 | +** ("main", "temp", or the name of an attached database). If | |
| 11824 | +** sqlite3changegroup_add() is called to add a changeset that is not compatible | |
| 11825 | +** with the configured schema, SQLITE_SCHEMA is returned and the changegroup | |
| 11826 | +** object is left in an undefined state. | |
| 11827 | +** | |
| 11828 | +** A changeset schema is considered compatible with the database schema in | |
| 11829 | +** the same way as for sqlite3changeset_apply(). Specifically, for each | |
| 11830 | +** table in the changeset, there exists a database table with: | |
| 11831 | +** | |
| 11832 | +** <ul> | |
| 11833 | +** <li> The name identified by the changeset, and | |
| 11834 | +** <li> at least as many columns as recorded in the changeset, and | |
| 11835 | +** <li> the primary key columns in the same position as recorded in | |
| 11836 | +** the changeset. | |
| 11837 | +** </ul> | |
| 11838 | +** | |
| 11839 | +** The output of the changegroup object always has the same schema as the | |
| 11840 | +** database nominated using this function. In cases where changesets passed | |
| 11841 | +** to sqlite3changegroup_add() have fewer columns than the corresponding table | |
| 11842 | +** in the database schema, these are filled in using the default column | |
| 11843 | +** values from the database schema. This makes it possible to combined | |
| 11844 | +** changesets that have different numbers of columns for a single table | |
| 11845 | +** within a changegroup, provided that they are otherwise compatible. | |
| 11846 | +*/ | |
| 11847 | +SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); | |
| 11848 | + | |
| 11726 | 11849 | /* |
| 11727 | 11850 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 11728 | 11851 | ** METHOD: sqlite3_changegroup |
| 11729 | 11852 | ** |
| 11730 | 11853 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| @@ -11789,17 +11912,22 @@ | ||
| 11789 | 11912 | ** </table> |
| 11790 | 11913 | ** |
| 11791 | 11914 | ** If the new changeset contains changes to a table that is already present |
| 11792 | 11915 | ** in the changegroup, then the number of columns and the position of the |
| 11793 | 11916 | ** primary key columns for the table must be consistent. If this is not the |
| 11794 | -** case, this function fails with SQLITE_SCHEMA. If the input changeset | |
| 11795 | -** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is | |
| 11796 | -** returned. Or, if an out-of-memory condition occurs during processing, this | |
| 11797 | -** function returns SQLITE_NOMEM. In all cases, if an error occurs the state | |
| 11798 | -** of the final contents of the changegroup is undefined. | |
| 11917 | +** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup | |
| 11918 | +** object has been configured with a database schema using the | |
| 11919 | +** sqlite3changegroup_schema() API, then it is possible to combine changesets | |
| 11920 | +** with different numbers of columns for a single table, provided that | |
| 11921 | +** they are otherwise compatible. | |
| 11799 | 11922 | ** |
| 11800 | -** If no error occurs, SQLITE_OK is returned. | |
| 11923 | +** If the input changeset appears to be corrupt and the corruption is | |
| 11924 | +** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition | |
| 11925 | +** occurs during processing, this function returns SQLITE_NOMEM. | |
| 11926 | +** | |
| 11927 | +** In all cases, if an error occurs the state of the final contents of the | |
| 11928 | +** changegroup is undefined. If no error occurs, SQLITE_OK is returned. | |
| 11801 | 11929 | */ |
| 11802 | 11930 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 11803 | 11931 | |
| 11804 | 11932 | /* |
| 11805 | 11933 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| @@ -12060,14 +12188,21 @@ | ||
| 12060 | 12188 | ** <li>an update change if the modified fields are already set to |
| 12061 | 12189 | ** their new values in the conflicting row, or |
| 12062 | 12190 | ** <li>an insert change if all fields of the conflicting row match |
| 12063 | 12191 | ** the row being inserted. |
| 12064 | 12192 | ** </ul> |
| 12193 | +** | |
| 12194 | +** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd> | |
| 12195 | +** If this flag it set, then all foreign key constraints in the target | |
| 12196 | +** database behave as if they were declared with "ON UPDATE NO ACTION ON | |
| 12197 | +** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL | |
| 12198 | +** or SET DEFAULT. | |
| 12065 | 12199 | */ |
| 12066 | 12200 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12067 | 12201 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12068 | 12202 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12203 | +#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 | |
| 12069 | 12204 | |
| 12070 | 12205 | /* |
| 12071 | 12206 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| 12072 | 12207 | ** |
| 12073 | 12208 | ** Values that may be passed as the second argument to a conflict-handler. |
| 12074 | 12209 |
| --- extsrc/sqlite3.h | |
| +++ extsrc/sqlite3.h | |
| @@ -144,13 +144,13 @@ | |
| 144 | ** |
| 145 | ** See also: [sqlite3_libversion()], |
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ |
| 149 | #define SQLITE_VERSION "3.43.1" |
| 150 | #define SQLITE_VERSION_NUMBER 3043001 |
| 151 | #define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| @@ -5322,10 +5322,11 @@ | |
| 5322 | ** |
| 5323 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 5324 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 5325 | */ |
| 5326 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5327 | |
| 5328 | /* |
| 5329 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5330 | ** KEYWORDS: {function creation routines} |
| 5331 | ** METHOD: sqlite3 |
| @@ -5877,36 +5878,36 @@ | |
| 5877 | /* |
| 5878 | ** CAPI3REF: Function Auxiliary Data |
| 5879 | ** METHOD: sqlite3_context |
| 5880 | ** |
| 5881 | ** These functions may be used by (non-aggregate) SQL functions to |
| 5882 | ** associate metadata with argument values. If the same value is passed to |
| 5883 | ** multiple invocations of the same SQL function during query execution, under |
| 5884 | ** some circumstances the associated metadata may be preserved. An example |
| 5885 | ** of where this might be useful is in a regular-expression matching |
| 5886 | ** function. The compiled version of the regular expression can be stored as |
| 5887 | ** metadata associated with the pattern string. |
| 5888 | ** Then as long as the pattern string remains the same, |
| 5889 | ** the compiled regular expression can be reused on multiple |
| 5890 | ** invocations of the same function. |
| 5891 | ** |
| 5892 | ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata |
| 5893 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 5894 | ** value to the application-defined function. ^N is zero for the left-most |
| 5895 | ** function argument. ^If there is no metadata |
| 5896 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 5897 | ** returns a NULL pointer. |
| 5898 | ** |
| 5899 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th |
| 5900 | ** argument of the application-defined function. ^Subsequent |
| 5901 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| 5902 | ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or |
| 5903 | ** NULL if the metadata has been discarded. |
| 5904 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 5905 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 5906 | ** once, when the metadata is discarded. |
| 5907 | ** SQLite is free to discard the metadata at any time, including: <ul> |
| 5908 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 5909 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 5910 | ** SQL statement)^, or |
| 5911 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 5912 | ** parameter)^, or |
| @@ -5918,24 +5919,81 @@ | |
| 5918 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 5919 | ** should be called near the end of the function implementation and the |
| 5920 | ** function implementation should not make any use of P after |
| 5921 | ** sqlite3_set_auxdata() has been called. |
| 5922 | ** |
| 5923 | ** ^(In practice, metadata is preserved between function calls for |
| 5924 | ** function parameters that are compile-time constants, including literal |
| 5925 | ** values and [parameters] and expressions composed from the same.)^ |
| 5926 | ** |
| 5927 | ** The value of the N parameter to these interfaces should be non-negative. |
| 5928 | ** Future enhancements may make use of negative N values to define new |
| 5929 | ** kinds of function caching behavior. |
| 5930 | ** |
| 5931 | ** These routines must be called from the same thread in which |
| 5932 | ** the SQL function is running. |
| 5933 | */ |
| 5934 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 5935 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 5936 | |
| 5937 | |
| 5938 | /* |
| 5939 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 5940 | ** |
| 5941 | ** These are special values for the destructor that is passed in as the |
| @@ -7215,10 +7273,13 @@ | |
| 7215 | int (*xRelease)(sqlite3_vtab *pVTab, int); |
| 7216 | int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
| 7217 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7218 | ** Those below are for version 3 and greater. */ |
| 7219 | int (*xShadowName)(const char*); |
| 7220 | }; |
| 7221 | |
| 7222 | /* |
| 7223 | ** CAPI3REF: Virtual Table Indexing Information |
| 7224 | ** KEYWORDS: sqlite3_index_info |
| @@ -8182,10 +8243,11 @@ | |
| 8182 | */ |
| 8183 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8184 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8185 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8186 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8187 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8188 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8189 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8190 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8191 | #define SQLITE_TESTCTRL_ASSERT 12 |
| @@ -10546,10 +10608,17 @@ | |
| 10546 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 10547 | ** values of D and S. |
| 10548 | ** The size of the database is written into *P even if the |
| 10549 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10550 | ** of the database exists. |
| 10551 | ** |
| 10552 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10553 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10554 | ** allocation error occurs. |
| 10555 | ** |
| @@ -10594,18 +10663,28 @@ | |
| 10594 | ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will |
| 10595 | ** invoke sqlite3_free() on the serialization buffer when the database |
| 10596 | ** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then |
| 10597 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() |
| 10598 | ** if writes on the database cause it to grow larger than M bytes. |
| 10599 | ** |
| 10600 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 10601 | ** database is currently in a read transaction or is involved in a backup |
| 10602 | ** operation. |
| 10603 | ** |
| 10604 | ** It is not possible to deserialized into the TEMP database. If the |
| 10605 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10606 | ** function returns SQLITE_ERROR. |
| 10607 | ** |
| 10608 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10609 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10610 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10611 | ** |
| @@ -11674,10 +11753,22 @@ | |
| 11674 | void *pB, /* Pointer to buffer containing changeset B */ |
| 11675 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| 11676 | void **ppOut /* OUT: Buffer containing output changeset */ |
| 11677 | ); |
| 11678 | |
| 11679 | |
| 11680 | /* |
| 11681 | ** CAPI3REF: Changegroup Handle |
| 11682 | ** |
| 11683 | ** A changegroup is an object used to combine two or more |
| @@ -11721,10 +11812,42 @@ | |
| 11721 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 11722 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 11723 | */ |
| 11724 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 11725 | |
| 11726 | /* |
| 11727 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 11728 | ** METHOD: sqlite3_changegroup |
| 11729 | ** |
| 11730 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| @@ -11789,17 +11912,22 @@ | |
| 11789 | ** </table> |
| 11790 | ** |
| 11791 | ** If the new changeset contains changes to a table that is already present |
| 11792 | ** in the changegroup, then the number of columns and the position of the |
| 11793 | ** primary key columns for the table must be consistent. If this is not the |
| 11794 | ** case, this function fails with SQLITE_SCHEMA. If the input changeset |
| 11795 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is |
| 11796 | ** returned. Or, if an out-of-memory condition occurs during processing, this |
| 11797 | ** function returns SQLITE_NOMEM. In all cases, if an error occurs the state |
| 11798 | ** of the final contents of the changegroup is undefined. |
| 11799 | ** |
| 11800 | ** If no error occurs, SQLITE_OK is returned. |
| 11801 | */ |
| 11802 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 11803 | |
| 11804 | /* |
| 11805 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| @@ -12060,14 +12188,21 @@ | |
| 12060 | ** <li>an update change if the modified fields are already set to |
| 12061 | ** their new values in the conflicting row, or |
| 12062 | ** <li>an insert change if all fields of the conflicting row match |
| 12063 | ** the row being inserted. |
| 12064 | ** </ul> |
| 12065 | */ |
| 12066 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12067 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12068 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12069 | |
| 12070 | /* |
| 12071 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| 12072 | ** |
| 12073 | ** Values that may be passed as the second argument to a conflict-handler. |
| 12074 |
| --- extsrc/sqlite3.h | |
| +++ extsrc/sqlite3.h | |
| @@ -144,13 +144,13 @@ | |
| 144 | ** |
| 145 | ** See also: [sqlite3_libversion()], |
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ |
| 149 | #define SQLITE_VERSION "3.44.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3044000 |
| 151 | #define SQLITE_SOURCE_ID "2023-10-21 20:34:57 023a9dbe83c0042e9d500e3ae6c0592a468982e4ac278d08c9201967506c7555" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| @@ -5322,10 +5322,11 @@ | |
| 5322 | ** |
| 5323 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 5324 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 5325 | */ |
| 5326 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5327 | |
| 5328 | |
| 5329 | /* |
| 5330 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5331 | ** KEYWORDS: {function creation routines} |
| 5332 | ** METHOD: sqlite3 |
| @@ -5877,36 +5878,36 @@ | |
| 5878 | /* |
| 5879 | ** CAPI3REF: Function Auxiliary Data |
| 5880 | ** METHOD: sqlite3_context |
| 5881 | ** |
| 5882 | ** These functions may be used by (non-aggregate) SQL functions to |
| 5883 | ** associate auxiliary data with argument values. If the same argument |
| 5884 | ** value is passed to multiple invocations of the same SQL function during |
| 5885 | ** query execution, under some circumstances the associated auxiliary data |
| 5886 | ** might be preserved. An example of where this might be useful is in a |
| 5887 | ** regular-expression matching function. The compiled version of the regular |
| 5888 | ** expression can be stored as auxiliary data associated with the pattern string. |
| 5889 | ** Then as long as the pattern string remains the same, |
| 5890 | ** the compiled regular expression can be reused on multiple |
| 5891 | ** invocations of the same function. |
| 5892 | ** |
| 5893 | ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data |
| 5894 | ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument |
| 5895 | ** value to the application-defined function. ^N is zero for the left-most |
| 5896 | ** function argument. ^If there is no auxiliary data |
| 5897 | ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface |
| 5898 | ** returns a NULL pointer. |
| 5899 | ** |
| 5900 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the |
| 5901 | ** N-th argument of the application-defined function. ^Subsequent |
| 5902 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| 5903 | ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or |
| 5904 | ** NULL if the auxiliary data has been discarded. |
| 5905 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 5906 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 5907 | ** once, when the auxiliary data is discarded. |
| 5908 | ** SQLite is free to discard the auxiliary data at any time, including: <ul> |
| 5909 | ** <li> ^(when the corresponding function parameter changes)^, or |
| 5910 | ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 5911 | ** SQL statement)^, or |
| 5912 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 5913 | ** parameter)^, or |
| @@ -5918,24 +5919,81 @@ | |
| 5919 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 5920 | ** should be called near the end of the function implementation and the |
| 5921 | ** function implementation should not make any use of P after |
| 5922 | ** sqlite3_set_auxdata() has been called. |
| 5923 | ** |
| 5924 | ** ^(In practice, auxiliary data is preserved between function calls for |
| 5925 | ** function parameters that are compile-time constants, including literal |
| 5926 | ** values and [parameters] and expressions composed from the same.)^ |
| 5927 | ** |
| 5928 | ** The value of the N parameter to these interfaces should be non-negative. |
| 5929 | ** Future enhancements may make use of negative N values to define new |
| 5930 | ** kinds of function caching behavior. |
| 5931 | ** |
| 5932 | ** These routines must be called from the same thread in which |
| 5933 | ** the SQL function is running. |
| 5934 | ** |
| 5935 | ** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. |
| 5936 | */ |
| 5937 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 5938 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 5939 | |
| 5940 | /* |
| 5941 | ** CAPI3REF: Database Connection Client Data |
| 5942 | ** METHOD: sqlite3 |
| 5943 | ** |
| 5944 | ** These functions are used to associate one or more named pointers |
| 5945 | ** with a [database connection]. |
| 5946 | ** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P |
| 5947 | ** to be attached to [database connection] D using name N. Subsequent |
| 5948 | ** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P |
| 5949 | ** or a NULL pointer if there were no prior calls to |
| 5950 | ** sqlite3_set_clientdata() with the same values of D and N. |
| 5951 | ** Names are compared using strcmp() and are thus case sensitive. |
| 5952 | ** |
| 5953 | ** If P and X are both non-NULL, then the destructor X is invoked with |
| 5954 | ** argument P on the first of the following occurrences: |
| 5955 | ** <ul> |
| 5956 | ** <li> An out-of-memory error occurs during the call to |
| 5957 | ** sqlite3_set_clientdata() which attempts to register pointer P. |
| 5958 | ** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made |
| 5959 | ** with the same D and N parameters. |
| 5960 | ** <li> The database connection closes. SQLite does not make any guarantees |
| 5961 | ** about the order in which destructors are called, only that all |
| 5962 | ** destructors will be called exactly once at some point during the |
| 5963 | ** database connection closingi process. |
| 5964 | ** </ul> |
| 5965 | ** |
| 5966 | ** SQLite does not do anything with client data other than invoke |
| 5967 | ** destructors on the client data at the appropriate time. The intended |
| 5968 | ** use for client data is to provide a mechanism for wrapper libraries |
| 5969 | ** to store additional information about an SQLite database connection. |
| 5970 | ** |
| 5971 | ** There is no limit (other than available memory) on the number of different |
| 5972 | ** client data pointers (with different names) that can be attached to a |
| 5973 | ** single database connection. However, the implementation is optimized |
| 5974 | ** for the case of having only one or two different client data names. |
| 5975 | ** Applications and wrapper libraries are discouraged from using more than |
| 5976 | ** one client data name each. |
| 5977 | ** |
| 5978 | ** There is no way to enumerate the client data pointers |
| 5979 | ** associated with a database connection. The N parameter can be thought |
| 5980 | ** of as a secret key such that only code that knows the secret key is able |
| 5981 | ** to access the associated data. |
| 5982 | ** |
| 5983 | ** Security Warning: These interfaces should not be exposed in scripting |
| 5984 | ** languages or in other circumstances where it might be possible for an |
| 5985 | ** an attacker to invoke them. Any agent that can invoke these interfaces |
| 5986 | ** can probably also take control of the process. |
| 5987 | ** |
| 5988 | ** Database connection client data is only available for SQLite |
| 5989 | ** version 3.44.0 ([dateof:3.44.0]) and later. |
| 5990 | ** |
| 5991 | ** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. |
| 5992 | */ |
| 5993 | SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); |
| 5994 | SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); |
| 5995 | |
| 5996 | /* |
| 5997 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 5998 | ** |
| 5999 | ** These are special values for the destructor that is passed in as the |
| @@ -7215,10 +7273,13 @@ | |
| 7273 | int (*xRelease)(sqlite3_vtab *pVTab, int); |
| 7274 | int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
| 7275 | /* The methods above are in versions 1 and 2 of the sqlite_module object. |
| 7276 | ** Those below are for version 3 and greater. */ |
| 7277 | int (*xShadowName)(const char*); |
| 7278 | /* The methods above are in versions 1 through 3 of the sqlite_module object. |
| 7279 | ** Those below are for version 4 and greater. */ |
| 7280 | int (*xIntegrity)(sqlite3_vtab *pVTab, char**); |
| 7281 | }; |
| 7282 | |
| 7283 | /* |
| 7284 | ** CAPI3REF: Virtual Table Indexing Information |
| 7285 | ** KEYWORDS: sqlite3_index_info |
| @@ -8182,10 +8243,11 @@ | |
| 8243 | */ |
| 8244 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8245 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8246 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8247 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8248 | #define SQLITE_TESTCTRL_FK_NO_ACTION 7 |
| 8249 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8250 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8251 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8252 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8253 | #define SQLITE_TESTCTRL_ASSERT 12 |
| @@ -10546,10 +10608,17 @@ | |
| 10608 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 10609 | ** values of D and S. |
| 10610 | ** The size of the database is written into *P even if the |
| 10611 | ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy |
| 10612 | ** of the database exists. |
| 10613 | ** |
| 10614 | ** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, |
| 10615 | ** the returned buffer content will remain accessible and unchanged |
| 10616 | ** until either the next write operation on the connection or when |
| 10617 | ** the connection is closed, and applications must not modify the |
| 10618 | ** buffer. If the bit had been clear, the returned buffer will not |
| 10619 | ** be accessed by SQLite after the call. |
| 10620 | ** |
| 10621 | ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the |
| 10622 | ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory |
| 10623 | ** allocation error occurs. |
| 10624 | ** |
| @@ -10594,18 +10663,28 @@ | |
| 10663 | ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will |
| 10664 | ** invoke sqlite3_free() on the serialization buffer when the database |
| 10665 | ** connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then |
| 10666 | ** SQLite will try to increase the buffer size using sqlite3_realloc64() |
| 10667 | ** if writes on the database cause it to grow larger than M bytes. |
| 10668 | ** |
| 10669 | ** Applications must not modify the buffer P or invalidate it before |
| 10670 | ** the database connection D is closed. |
| 10671 | ** |
| 10672 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 10673 | ** database is currently in a read transaction or is involved in a backup |
| 10674 | ** operation. |
| 10675 | ** |
| 10676 | ** It is not possible to deserialized into the TEMP database. If the |
| 10677 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 10678 | ** function returns SQLITE_ERROR. |
| 10679 | ** |
| 10680 | ** The deserialized database should not be in [WAL mode]. If the database |
| 10681 | ** is in WAL mode, then any attempt to use the database file will result |
| 10682 | ** in an [SQLITE_CANTOPEN] error. The application can set the |
| 10683 | ** [file format version numbers] (bytes 18 and 19) of the input database P |
| 10684 | ** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the |
| 10685 | ** database file into rollback mode and work around this limitation. |
| 10686 | ** |
| 10687 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10688 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10689 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| 10690 | ** |
| @@ -11674,10 +11753,22 @@ | |
| 11753 | void *pB, /* Pointer to buffer containing changeset B */ |
| 11754 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| 11755 | void **ppOut /* OUT: Buffer containing output changeset */ |
| 11756 | ); |
| 11757 | |
| 11758 | |
| 11759 | /* |
| 11760 | ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset |
| 11761 | */ |
| 11762 | SQLITE_API int sqlite3changeset_upgrade( |
| 11763 | sqlite3 *db, |
| 11764 | const char *zDb, |
| 11765 | int nIn, const void *pIn, /* Input changeset */ |
| 11766 | int *pnOut, void **ppOut /* OUT: Inverse of input */ |
| 11767 | ); |
| 11768 | |
| 11769 | |
| 11770 | |
| 11771 | /* |
| 11772 | ** CAPI3REF: Changegroup Handle |
| 11773 | ** |
| 11774 | ** A changegroup is an object used to combine two or more |
| @@ -11721,10 +11812,42 @@ | |
| 11812 | ** sqlite3changegroup_output() functions, also available are the streaming |
| 11813 | ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). |
| 11814 | */ |
| 11815 | SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); |
| 11816 | |
| 11817 | /* |
| 11818 | ** CAPI3REF: Add a Schema to a Changegroup |
| 11819 | ** METHOD: sqlite3_changegroup_schema |
| 11820 | ** |
| 11821 | ** This method may be used to optionally enforce the rule that the changesets |
| 11822 | ** added to the changegroup handle must match the schema of database zDb |
| 11823 | ** ("main", "temp", or the name of an attached database). If |
| 11824 | ** sqlite3changegroup_add() is called to add a changeset that is not compatible |
| 11825 | ** with the configured schema, SQLITE_SCHEMA is returned and the changegroup |
| 11826 | ** object is left in an undefined state. |
| 11827 | ** |
| 11828 | ** A changeset schema is considered compatible with the database schema in |
| 11829 | ** the same way as for sqlite3changeset_apply(). Specifically, for each |
| 11830 | ** table in the changeset, there exists a database table with: |
| 11831 | ** |
| 11832 | ** <ul> |
| 11833 | ** <li> The name identified by the changeset, and |
| 11834 | ** <li> at least as many columns as recorded in the changeset, and |
| 11835 | ** <li> the primary key columns in the same position as recorded in |
| 11836 | ** the changeset. |
| 11837 | ** </ul> |
| 11838 | ** |
| 11839 | ** The output of the changegroup object always has the same schema as the |
| 11840 | ** database nominated using this function. In cases where changesets passed |
| 11841 | ** to sqlite3changegroup_add() have fewer columns than the corresponding table |
| 11842 | ** in the database schema, these are filled in using the default column |
| 11843 | ** values from the database schema. This makes it possible to combined |
| 11844 | ** changesets that have different numbers of columns for a single table |
| 11845 | ** within a changegroup, provided that they are otherwise compatible. |
| 11846 | */ |
| 11847 | SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); |
| 11848 | |
| 11849 | /* |
| 11850 | ** CAPI3REF: Add A Changeset To A Changegroup |
| 11851 | ** METHOD: sqlite3_changegroup |
| 11852 | ** |
| 11853 | ** Add all changes within the changeset (or patchset) in buffer pData (size |
| @@ -11789,17 +11912,22 @@ | |
| 11912 | ** </table> |
| 11913 | ** |
| 11914 | ** If the new changeset contains changes to a table that is already present |
| 11915 | ** in the changegroup, then the number of columns and the position of the |
| 11916 | ** primary key columns for the table must be consistent. If this is not the |
| 11917 | ** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup |
| 11918 | ** object has been configured with a database schema using the |
| 11919 | ** sqlite3changegroup_schema() API, then it is possible to combine changesets |
| 11920 | ** with different numbers of columns for a single table, provided that |
| 11921 | ** they are otherwise compatible. |
| 11922 | ** |
| 11923 | ** If the input changeset appears to be corrupt and the corruption is |
| 11924 | ** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition |
| 11925 | ** occurs during processing, this function returns SQLITE_NOMEM. |
| 11926 | ** |
| 11927 | ** In all cases, if an error occurs the state of the final contents of the |
| 11928 | ** changegroup is undefined. If no error occurs, SQLITE_OK is returned. |
| 11929 | */ |
| 11930 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 11931 | |
| 11932 | /* |
| 11933 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| @@ -12060,14 +12188,21 @@ | |
| 12188 | ** <li>an update change if the modified fields are already set to |
| 12189 | ** their new values in the conflicting row, or |
| 12190 | ** <li>an insert change if all fields of the conflicting row match |
| 12191 | ** the row being inserted. |
| 12192 | ** </ul> |
| 12193 | ** |
| 12194 | ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd> |
| 12195 | ** If this flag it set, then all foreign key constraints in the target |
| 12196 | ** database behave as if they were declared with "ON UPDATE NO ACTION ON |
| 12197 | ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL |
| 12198 | ** or SET DEFAULT. |
| 12199 | */ |
| 12200 | #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 |
| 12201 | #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 |
| 12202 | #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 |
| 12203 | #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 |
| 12204 | |
| 12205 | /* |
| 12206 | ** CAPI3REF: Constants Passed To The Conflict Handler |
| 12207 | ** |
| 12208 | ** Values that may be passed as the second argument to a conflict-handler. |
| 12209 |