| | @@ -1165,11 +1165,11 @@ |
| 1165 | 1165 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1166 | 1166 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1167 | 1167 | */ |
| 1168 | 1168 | #define SQLITE_VERSION "3.31.0" |
| 1169 | 1169 | #define SQLITE_VERSION_NUMBER 3031000 |
| 1170 | | -#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b" |
| 1170 | +#define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3" |
| 1171 | 1171 | |
| 1172 | 1172 | /* |
| 1173 | 1173 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1174 | 1174 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1175 | 1175 | ** |
| | @@ -1581,10 +1581,11 @@ |
| 1581 | 1581 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) |
| 1582 | 1582 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) |
| 1583 | 1583 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) |
| 1584 | 1584 | #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) |
| 1585 | 1585 | #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) |
| 1586 | +#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) |
| 1586 | 1587 | |
| 1587 | 1588 | /* |
| 1588 | 1589 | ** CAPI3REF: Flags For File Open Operations |
| 1589 | 1590 | ** |
| 1590 | 1591 | ** These bit values are intended for use in the |
| | @@ -2021,20 +2022,20 @@ |
| 2021 | 2022 | ** |
| 2022 | 2023 | ** <li>[[SQLITE_FCNTL_BUSYHANDLER]] |
| 2023 | 2024 | ** ^The [SQLITE_FCNTL_BUSYHANDLER] |
| 2024 | 2025 | ** file-control may be invoked by SQLite on the database file handle |
| 2025 | 2026 | ** shortly after it is opened in order to provide a custom VFS with access |
| 2026 | | -** to the connections busy-handler callback. The argument is of type (void **) |
| 2027 | +** to the connection's busy-handler callback. The argument is of type (void**) |
| 2027 | 2028 | ** - an array of two (void *) values. The first (void *) actually points |
| 2028 | | -** to a function of type (int (*)(void *)). In order to invoke the connections |
| 2029 | +** to a function of type (int (*)(void *)). In order to invoke the connection's |
| 2029 | 2030 | ** busy-handler, this function should be invoked with the second (void *) in |
| 2030 | 2031 | ** the array as the only argument. If it returns non-zero, then the operation |
| 2031 | 2032 | ** should be retried. If it returns zero, the custom VFS should abandon the |
| 2032 | 2033 | ** current operation. |
| 2033 | 2034 | ** |
| 2034 | 2035 | ** <li>[[SQLITE_FCNTL_TEMPFILENAME]] |
| 2035 | | -** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
| 2036 | +** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
| 2036 | 2037 | ** to have SQLite generate a |
| 2037 | 2038 | ** temporary filename using the same algorithm that is followed to generate |
| 2038 | 2039 | ** temporary filenames for TEMP tables and other internal uses. The |
| 2039 | 2040 | ** argument should be a char** which will be filled with the filename |
| 2040 | 2041 | ** written into memory obtained from [sqlite3_malloc()]. The caller should |
| | @@ -2143,11 +2144,11 @@ |
| 2143 | 2144 | ** interface can be used to find if any database on the connection has changed, |
| 2144 | 2145 | ** but that interface responds to changes on TEMP as well as MAIN and does |
| 2145 | 2146 | ** not provide a mechanism to detect changes to MAIN only. Also, the |
| 2146 | 2147 | ** [sqlite3_total_changes()] interface responds to internal changes only and |
| 2147 | 2148 | ** omits changes made by other database connections. The |
| 2148 | | -** [PRAGMA data_version] command provide a mechanism to detect changes to |
| 2149 | +** [PRAGMA data_version] command provides a mechanism to detect changes to |
| 2149 | 2150 | ** a single attached database that occur due to other database connections, |
| 2150 | 2151 | ** but omits changes implemented by the database connection on which it is |
| 2151 | 2152 | ** called. This file control is the only mechanism to detect changes that |
| 2152 | 2153 | ** happen either internally or externally and that are associated with |
| 2153 | 2154 | ** a particular attached database. |
| | @@ -2231,14 +2232,14 @@ |
| 2231 | 2232 | ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 |
| 2232 | 2233 | ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased |
| 2233 | 2234 | ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields |
| 2234 | 2235 | ** may be appended to the sqlite3_vfs object and the iVersion value |
| 2235 | 2236 | ** may increase again in future versions of SQLite. |
| 2236 | | -** Note that the structure |
| 2237 | | -** of the sqlite3_vfs object changes in the transition from |
| 2237 | +** Note that due to an oversight, the structure |
| 2238 | +** of the sqlite3_vfs object changed in the transition from |
| 2238 | 2239 | ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] |
| 2239 | | -** and yet the iVersion field was not modified. |
| 2240 | +** and yet the iVersion field was not increased. |
| 2240 | 2241 | ** |
| 2241 | 2242 | ** The szOsFile field is the size of the subclassed [sqlite3_file] |
| 2242 | 2243 | ** structure used by this VFS. mxPathname is the maximum length of |
| 2243 | 2244 | ** a pathname in this VFS. |
| 2244 | 2245 | ** |
| | @@ -2325,11 +2326,11 @@ |
| 2325 | 2326 | ** be created, and that it is an error if it already exists. |
| 2326 | 2327 | ** It is <i>not</i> used to indicate the file should be opened |
| 2327 | 2328 | ** for exclusive access. |
| 2328 | 2329 | ** |
| 2329 | 2330 | ** ^At least szOsFile bytes of memory are allocated by SQLite |
| 2330 | | -** to hold the [sqlite3_file] structure passed as the third |
| 2331 | +** to hold the [sqlite3_file] structure passed as the third |
| 2331 | 2332 | ** argument to xOpen. The xOpen method does not have to |
| 2332 | 2333 | ** allocate the structure; it should just fill it in. Note that |
| 2333 | 2334 | ** the xOpen method must set the sqlite3_file.pMethods to either |
| 2334 | 2335 | ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do |
| 2335 | 2336 | ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods |
| | @@ -2448,11 +2449,10 @@ |
| 2448 | 2449 | ** SQLite. |
| 2449 | 2450 | */ |
| 2450 | 2451 | #define SQLITE_ACCESS_EXISTS 0 |
| 2451 | 2452 | #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ |
| 2452 | 2453 | #define SQLITE_ACCESS_READ 2 /* Unused */ |
| 2453 | | -#define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */ |
| 2454 | 2454 | |
| 2455 | 2455 | /* |
| 2456 | 2456 | ** CAPI3REF: Flags for the xShmLock VFS method |
| 2457 | 2457 | ** |
| 2458 | 2458 | ** These integer constants define the various locking operations |
| | @@ -2663,11 +2663,11 @@ |
| 2663 | 2663 | ** Every memory allocation request coming in through [sqlite3_malloc()] |
| 2664 | 2664 | ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, |
| 2665 | 2665 | ** that causes the corresponding memory allocation to fail. |
| 2666 | 2666 | ** |
| 2667 | 2667 | ** The xInit method initializes the memory allocator. For example, |
| 2668 | | -** it might allocate any require mutexes or initialize internal data |
| 2668 | +** it might allocate any required mutexes or initialize internal data |
| 2669 | 2669 | ** structures. The xShutdown method is invoked (indirectly) by |
| 2670 | 2670 | ** [sqlite3_shutdown()] and should deallocate any resources acquired |
| 2671 | 2671 | ** by xInit. The pAppData pointer is used as the only parameter to |
| 2672 | 2672 | ** xInit and xShutdown. |
| 2673 | 2673 | ** |
| | @@ -2804,11 +2804,11 @@ |
| 2804 | 2804 | ** |
| 2805 | 2805 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 2806 | 2806 | ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool |
| 2807 | 2807 | ** that SQLite can use for the database page cache with the default page |
| 2808 | 2808 | ** cache implementation. |
| 2809 | | -** This configuration option is a no-op if an application-define page |
| 2809 | +** This configuration option is a no-op if an application-defined page |
| 2810 | 2810 | ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]. |
| 2811 | 2811 | ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to |
| 2812 | 2812 | ** 8-byte aligned memory (pMem), the size of each page cache line (sz), |
| 2813 | 2813 | ** and the number of cache lines (N). |
| 2814 | 2814 | ** The sz argument should be the size of the largest database page |
| | @@ -3289,11 +3289,11 @@ |
| 3289 | 3289 | ** </dd> |
| 3290 | 3290 | ** |
| 3291 | 3291 | ** [[SQLITE_DBCONFIG_DQS_DML]] |
| 3292 | 3292 | ** <dt>SQLITE_DBCONFIG_DQS_DML</td> |
| 3293 | 3293 | ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates |
| 3294 | | -** the legacy [double-quoted string literal] misfeature for DML statement |
| 3294 | +** the legacy [double-quoted string literal] misfeature for DML statements |
| 3295 | 3295 | ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The |
| 3296 | 3296 | ** default value of this setting is determined by the [-DSQLITE_DQS] |
| 3297 | 3297 | ** compile-time option. |
| 3298 | 3298 | ** </dd> |
| 3299 | 3299 | ** |
| | @@ -3550,11 +3550,11 @@ |
| 3550 | 3550 | ** will be rolled back automatically. |
| 3551 | 3551 | ** |
| 3552 | 3552 | ** ^The sqlite3_interrupt(D) call is in effect until all currently running |
| 3553 | 3553 | ** SQL statements on [database connection] D complete. ^Any new SQL statements |
| 3554 | 3554 | ** that are started after the sqlite3_interrupt() call and before the |
| 3555 | | -** running statements reaches zero are interrupted as if they had been |
| 3555 | +** running statement count reaches zero are interrupted as if they had been |
| 3556 | 3556 | ** running prior to the sqlite3_interrupt() call. ^New SQL statements |
| 3557 | 3557 | ** that are started after the running statement count reaches zero are |
| 3558 | 3558 | ** not effected by the sqlite3_interrupt(). |
| 3559 | 3559 | ** ^A call to sqlite3_interrupt(D) that occurs when there are no running |
| 3560 | 3560 | ** SQL statements is a no-op and has no effect on SQL statements |
| | @@ -3718,13 +3718,13 @@ |
| 3718 | 3718 | ** Alice | 43 |
| 3719 | 3719 | ** Bob | 28 |
| 3720 | 3720 | ** Cindy | 21 |
| 3721 | 3721 | ** </pre></blockquote> |
| 3722 | 3722 | ** |
| 3723 | | -** There are two column (M==2) and three rows (N==3). Thus the |
| 3723 | +** There are two columns (M==2) and three rows (N==3). Thus the |
| 3724 | 3724 | ** result table has 8 entries. Suppose the result table is stored |
| 3725 | | -** in an array names azResult. Then azResult holds this content: |
| 3725 | +** in an array named azResult. Then azResult holds this content: |
| 3726 | 3726 | ** |
| 3727 | 3727 | ** <blockquote><pre> |
| 3728 | 3728 | ** azResult[0] = "Name"; |
| 3729 | 3729 | ** azResult[1] = "Age"; |
| 3730 | 3730 | ** azResult[2] = "Alice"; |
| | @@ -3874,23 +3874,10 @@ |
| 3874 | 3874 | ** sqlite3_malloc64(), and sqlite3_realloc64() |
| 3875 | 3875 | ** is always aligned to at least an 8 byte boundary, or to a |
| 3876 | 3876 | ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time |
| 3877 | 3877 | ** option is used. |
| 3878 | 3878 | ** |
| 3879 | | -** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
| 3880 | | -** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in |
| 3881 | | -** implementation of these routines to be omitted. That capability |
| 3882 | | -** is no longer provided. Only built-in memory allocators can be used. |
| 3883 | | -** |
| 3884 | | -** Prior to SQLite version 3.7.10, the Windows OS interface layer called |
| 3885 | | -** the system malloc() and free() directly when converting |
| 3886 | | -** filenames between the UTF-8 encoding used by SQLite |
| 3887 | | -** and whatever filename encoding is used by the particular Windows |
| 3888 | | -** installation. Memory allocation errors were detected, but |
| 3889 | | -** they were reported back as [SQLITE_CANTOPEN] or |
| 3890 | | -** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. |
| 3891 | | -** |
| 3892 | 3879 | ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
| 3893 | 3880 | ** must be either NULL or else pointers obtained from a prior |
| 3894 | 3881 | ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have |
| 3895 | 3882 | ** not yet been released. |
| 3896 | 3883 | ** |
| | @@ -3935,11 +3922,11 @@ |
| 3935 | 3922 | ** CAPI3REF: Pseudo-Random Number Generator |
| 3936 | 3923 | ** |
| 3937 | 3924 | ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
| 3938 | 3925 | ** select random [ROWID | ROWIDs] when inserting new records into a table that |
| 3939 | 3926 | ** already uses the largest possible [ROWID]. The PRNG is also used for |
| 3940 | | -** the build-in random() and randomblob() SQL functions. This interface allows |
| 3927 | +** the built-in random() and randomblob() SQL functions. This interface allows |
| 3941 | 3928 | ** applications to access the same PRNG for other purposes. |
| 3942 | 3929 | ** |
| 3943 | 3930 | ** ^A call to this routine stores N bytes of randomness into buffer P. |
| 3944 | 3931 | ** ^The P parameter can be a NULL pointer. |
| 3945 | 3932 | ** |
| | @@ -4536,11 +4523,11 @@ |
| 4536 | 4523 | ** a VFS implementation when the flags parameter to xOpen() has one or |
| 4537 | 4524 | ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and |
| 4538 | 4525 | ** P is the name of the query parameter, then |
| 4539 | 4526 | ** sqlite3_uri_parameter(F,P) returns the value of the P |
| 4540 | 4527 | ** parameter if it exists or a NULL pointer if P does not appear as a |
| 4541 | | -** query parameter on F. If P is a query parameter of F |
| 4528 | +** query parameter on F. If P is a query parameter of F and it |
| 4542 | 4529 | ** has no explicit value, then sqlite3_uri_parameter(F,P) returns |
| 4543 | 4530 | ** a pointer to an empty string. |
| 4544 | 4531 | ** |
| 4545 | 4532 | ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean |
| 4546 | 4533 | ** parameter and returns true (1) or false (0) according to the value |
| | @@ -4548,11 +4535,11 @@ |
| 4548 | 4535 | ** value of query parameter P is one of "yes", "true", or "on" in any |
| 4549 | 4536 | ** case or if the value begins with a non-zero number. The |
| 4550 | 4537 | ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of |
| 4551 | 4538 | ** query parameter P is one of "no", "false", or "off" in any case or |
| 4552 | 4539 | ** if the value begins with a numeric zero. If P is not a query |
| 4553 | | -** parameter on F or if the value of P is does not match any of the |
| 4540 | +** parameter on F or if the value of P does not match any of the |
| 4554 | 4541 | ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). |
| 4555 | 4542 | ** |
| 4556 | 4543 | ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a |
| 4557 | 4544 | ** 64-bit signed integer and returns that integer, or D if P does not |
| 4558 | 4545 | ** exist. If the value of P is something other than an integer, then |
| | @@ -4885,16 +4872,16 @@ |
| 4885 | 4872 | ** in order to find the underlying cause of the problem. With the "v2" prepare |
| 4886 | 4873 | ** interfaces, the underlying reason for the error is returned immediately. |
| 4887 | 4874 | ** </li> |
| 4888 | 4875 | ** |
| 4889 | 4876 | ** <li> |
| 4890 | | -** ^If the specific value bound to [parameter | host parameter] in the |
| 4877 | +** ^If the specific value bound to a [parameter | host parameter] in the |
| 4891 | 4878 | ** WHERE clause might influence the choice of query plan for a statement, |
| 4892 | 4879 | ** then the statement will be automatically recompiled, as if there had been |
| 4893 | | -** a schema change, on the first [sqlite3_step()] call following any change |
| 4880 | +** a schema change, on the first [sqlite3_step()] call following any change |
| 4894 | 4881 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 4895 | | -** ^The specific value of WHERE-clause [parameter] might influence the |
| 4882 | +** ^The specific value of a WHERE-clause [parameter] might influence the |
| 4896 | 4883 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 4897 | 4884 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 4898 | 4885 | ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. |
| 4899 | 4886 | ** </li> |
| 4900 | 4887 | ** </ol> |
| | @@ -5399,24 +5386,20 @@ |
| 5399 | 5386 | ** the statement, where N is the second function argument. |
| 5400 | 5387 | ** ^The left-most column is column 0 for these routines. |
| 5401 | 5388 | ** |
| 5402 | 5389 | ** ^If the Nth column returned by the statement is an expression or |
| 5403 | 5390 | ** subquery and is not a column value, then all of these functions return |
| 5404 | | -** NULL. ^These routine might also return NULL if a memory allocation error |
| 5391 | +** NULL. ^These routines might also return NULL if a memory allocation error |
| 5405 | 5392 | ** occurs. ^Otherwise, they return the name of the attached database, table, |
| 5406 | 5393 | ** or column that query result column was extracted from. |
| 5407 | 5394 | ** |
| 5408 | 5395 | ** ^As with all other SQLite APIs, those whose names end with "16" return |
| 5409 | 5396 | ** UTF-16 encoded strings and the other functions return UTF-8. |
| 5410 | 5397 | ** |
| 5411 | 5398 | ** ^These APIs are only available if the library was compiled with the |
| 5412 | 5399 | ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. |
| 5413 | 5400 | ** |
| 5414 | | -** If two or more threads call one or more of these routines against the same |
| 5415 | | -** prepared statement and column at the same time then the results are |
| 5416 | | -** undefined. |
| 5417 | | -** |
| 5418 | 5401 | ** If two or more threads call one or more |
| 5419 | 5402 | ** [sqlite3_column_database_name | column metadata interfaces] |
| 5420 | 5403 | ** for the same [prepared statement] and result column |
| 5421 | 5404 | ** at the same time then the results are undefined. |
| 5422 | 5405 | */ |
| | @@ -5549,11 +5532,11 @@ |
| 5549 | 5532 | ** METHOD: sqlite3_stmt |
| 5550 | 5533 | ** |
| 5551 | 5534 | ** ^The sqlite3_data_count(P) interface returns the number of columns in the |
| 5552 | 5535 | ** current row of the result set of [prepared statement] P. |
| 5553 | 5536 | ** ^If prepared statement P does not have results ready to return |
| 5554 | | -** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 5537 | +** (via calls to the [sqlite3_column_int | sqlite3_column()] family of |
| 5555 | 5538 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 5556 | 5539 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 5557 | 5540 | ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to |
| 5558 | 5541 | ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) |
| 5559 | 5542 | ** will return non-zero if previous call to [sqlite3_step](P) returned |
| | @@ -6051,13 +6034,16 @@ |
| 6051 | 6034 | ** These constants may be ORed together with the |
| 6052 | 6035 | ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument |
| 6053 | 6036 | ** to [sqlite3_create_function()], [sqlite3_create_function16()], or |
| 6054 | 6037 | ** [sqlite3_create_function_v2()]. |
| 6055 | 6038 | ** |
| 6056 | | -** The SQLITE_DETERMINISTIC flag means that the new function will always |
| 6057 | | -** maps the same inputs into the same output. The abs() function is |
| 6058 | | -** deterministic, for example, but randomblob() is not. |
| 6039 | +** The SQLITE_DETERMINISTIC flag means that the new function always gives |
| 6040 | +** the same output when the input parameters are the same. The abs() function |
| 6041 | +** is deterministic, for example, but randomblob() is not. Functions must |
| 6042 | +** be deterministic in order to be used in certain contexts such as |
| 6043 | +** [CHECK constraints] or [generated columns]. SQLite might also optimize |
| 6044 | +** deterministic functions by factoring them out of inner loops. |
| 6059 | 6045 | ** |
| 6060 | 6046 | ** The SQLITE_DIRECTONLY flag means that the function may only be invoked |
| 6061 | 6047 | ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is |
| 6062 | 6048 | ** a security feature which is recommended for all |
| 6063 | 6049 | ** [application-defined SQL functions] that have side-effects. This flag |
| | @@ -6132,12 +6118,12 @@ |
| 6132 | 6118 | ** |
| 6133 | 6119 | ** <b>Details:</b> |
| 6134 | 6120 | ** |
| 6135 | 6121 | ** These routines extract type, size, and content information from |
| 6136 | 6122 | ** [protected sqlite3_value] objects. Protected sqlite3_value objects |
| 6137 | | -** are used to pass parameter information into implementation of |
| 6138 | | -** [application-defined SQL functions] and [virtual tables]. |
| 6123 | +** are used to pass parameter information into the functions that |
| 6124 | +** implement [application-defined SQL functions] and [virtual tables]. |
| 6139 | 6125 | ** |
| 6140 | 6126 | ** These routines work only with [protected sqlite3_value] objects. |
| 6141 | 6127 | ** Any attempt to use these routines on an [unprotected sqlite3_value] |
| 6142 | 6128 | ** is not threadsafe. |
| 6143 | 6129 | ** |
| | @@ -6190,11 +6176,11 @@ |
| 6190 | 6176 | ** the return value is arbitrary and meaningless. |
| 6191 | 6177 | ** |
| 6192 | 6178 | ** ^The sqlite3_value_frombind(X) interface returns non-zero if the |
| 6193 | 6179 | ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] |
| 6194 | 6180 | ** interfaces. ^If X comes from an SQL literal value, or a table column, |
| 6195 | | -** and expression, then sqlite3_value_frombind(X) returns zero. |
| 6181 | +** or an expression, then sqlite3_value_frombind(X) returns zero. |
| 6196 | 6182 | ** |
| 6197 | 6183 | ** Please pay particular attention to the fact that the pointer returned |
| 6198 | 6184 | ** from [sqlite3_value_blob()], [sqlite3_value_text()], or |
| 6199 | 6185 | ** [sqlite3_value_text16()] can be invalidated by a subsequent call to |
| 6200 | 6186 | ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], |
| | @@ -6276,12 +6262,12 @@ |
| 6276 | 6262 | ** |
| 6277 | 6263 | ** Implementations of aggregate SQL functions use this |
| 6278 | 6264 | ** routine to allocate memory for storing their state. |
| 6279 | 6265 | ** |
| 6280 | 6266 | ** ^The first time the sqlite3_aggregate_context(C,N) routine is called |
| 6281 | | -** for a particular aggregate function, SQLite |
| 6282 | | -** allocates N of memory, zeroes out that memory, and returns a pointer |
| 6267 | +** for a particular aggregate function, SQLite allocates |
| 6268 | +** N bytes of memory, zeroes out that memory, and returns a pointer |
| 6283 | 6269 | ** to the new memory. ^On second and subsequent calls to |
| 6284 | 6270 | ** sqlite3_aggregate_context() for the same aggregate function instance, |
| 6285 | 6271 | ** the same buffer is returned. Sqlite3_aggregate_context() is normally |
| 6286 | 6272 | ** called once for each invocation of the xStep callback and then one |
| 6287 | 6273 | ** last time when the xFinal callback is invoked. ^(When no rows match |
| | @@ -6294,11 +6280,11 @@ |
| 6294 | 6280 | ** when first called if N is less than or equal to zero or if a memory |
| 6295 | 6281 | ** allocate error occurs. |
| 6296 | 6282 | ** |
| 6297 | 6283 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 6298 | 6284 | ** determined by the N parameter on first successful call. Changing the |
| 6299 | | -** value of N in subsequent call to sqlite3_aggregate_context() within |
| 6285 | +** value of N in any subsequents call to sqlite3_aggregate_context() within |
| 6300 | 6286 | ** the same aggregate function instance will not resize the memory |
| 6301 | 6287 | ** allocation.)^ Within the xFinal callback, it is customary to set |
| 6302 | 6288 | ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
| 6303 | 6289 | ** pointless memory allocations occur. |
| 6304 | 6290 | ** |
| | @@ -6642,11 +6628,11 @@ |
| 6642 | 6628 | ** <li> If A<B THEN B>A. |
| 6643 | 6629 | ** <li> If A<B and B<C then A<C. |
| 6644 | 6630 | ** </ol> |
| 6645 | 6631 | ** |
| 6646 | 6632 | ** If a collating function fails any of the above constraints and that |
| 6647 | | -** collating function is registered and used, then the behavior of SQLite |
| 6633 | +** collating function is registered and used, then the behavior of SQLite |
| 6648 | 6634 | ** is undefined. |
| 6649 | 6635 | ** |
| 6650 | 6636 | ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() |
| 6651 | 6637 | ** with the addition that the xDestroy callback is invoked on pArg when |
| 6652 | 6638 | ** the collating function is deleted. |
| | @@ -6969,15 +6955,19 @@ |
| 6969 | 6955 | |
| 6970 | 6956 | /* |
| 6971 | 6957 | ** CAPI3REF: Return The Filename For A Database Connection |
| 6972 | 6958 | ** METHOD: sqlite3 |
| 6973 | 6959 | ** |
| 6974 | | -** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename |
| 6975 | | -** associated with database N of connection D. ^The main database file |
| 6976 | | -** has the name "main". If there is no attached database N on the database |
| 6960 | +** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename |
| 6961 | +** associated with database N of connection D. |
| 6962 | +** ^If there is no attached database N on the database |
| 6977 | 6963 | ** connection D, or if database N is a temporary or in-memory database, then |
| 6978 | 6964 | ** this function will return either a NULL pointer or an empty string. |
| 6965 | +** |
| 6966 | +** ^The string value returned by this routine is owned and managed by |
| 6967 | +** the database connection. ^The value will be valid until the database N |
| 6968 | +** is [DETACH]-ed or until the database connection closes. |
| 6979 | 6969 | ** |
| 6980 | 6970 | ** ^The filename returned by this function is the output of the |
| 6981 | 6971 | ** xFullPathname method of the [VFS]. ^In other words, the filename |
| 6982 | 6972 | ** will be an absolute pathname, even if the filename used |
| 6983 | 6973 | ** to open the database originally was a URI or relative pathname. |
| | @@ -7128,19 +7118,23 @@ |
| 7128 | 7118 | ** In prior versions of SQLite, |
| 7129 | 7119 | ** sharing was enabled or disabled for each thread separately. |
| 7130 | 7120 | ** |
| 7131 | 7121 | ** ^(The cache sharing mode set by this interface effects all subsequent |
| 7132 | 7122 | ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. |
| 7133 | | -** Existing database connections continue use the sharing mode |
| 7123 | +** Existing database connections continue to use the sharing mode |
| 7134 | 7124 | ** that was in effect at the time they were opened.)^ |
| 7135 | 7125 | ** |
| 7136 | 7126 | ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled |
| 7137 | 7127 | ** successfully. An [error code] is returned otherwise.)^ |
| 7138 | 7128 | ** |
| 7139 | | -** ^Shared cache is disabled by default. But this might change in |
| 7140 | | -** future releases of SQLite. Applications that care about shared |
| 7141 | | -** cache setting should set it explicitly. |
| 7129 | +** ^Shared cache is disabled by default. It is recommended that it stay |
| 7130 | +** that way. In other words, do not use this routine. This interface |
| 7131 | +** continues to be provided for historical compatibility, but its use is |
| 7132 | +** discouraged. Any use of shared cache is discouraged. If shared cache |
| 7133 | +** must be used, it is recommended that shared cache only be enabled for |
| 7134 | +** individual database connections using the [sqlite3_open_v2()] interface |
| 7135 | +** with the [SQLITE_OPEN_SHAREDCACHE] flag. |
| 7142 | 7136 | ** |
| 7143 | 7137 | ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 |
| 7144 | 7138 | ** and will always return SQLITE_MISUSE. On those systems, |
| 7145 | 7139 | ** shared cache mode should be enabled per-database connection via |
| 7146 | 7140 | ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. |
| | @@ -7269,11 +7263,11 @@ |
| 7269 | 7263 | ** information about column C of table T in database D |
| 7270 | 7264 | ** on [database connection] X.)^ ^The sqlite3_table_column_metadata() |
| 7271 | 7265 | ** interface returns SQLITE_OK and fills in the non-NULL pointers in |
| 7272 | 7266 | ** the final five arguments with appropriate values if the specified |
| 7273 | 7267 | ** column exists. ^The sqlite3_table_column_metadata() interface returns |
| 7274 | | -** SQLITE_ERROR and if the specified column does not exist. |
| 7268 | +** SQLITE_ERROR if the specified column does not exist. |
| 7275 | 7269 | ** ^If the column-name parameter to sqlite3_table_column_metadata() is a |
| 7276 | 7270 | ** NULL pointer, then this routine simply checks for the existence of the |
| 7277 | 7271 | ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it |
| 7278 | 7272 | ** does not. If the table name parameter T in a call to |
| 7279 | 7273 | ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is |
| | @@ -7411,11 +7405,11 @@ |
| 7411 | 7405 | ** [sqlite3_load_extension()] and the SQL function [load_extension()]. |
| 7412 | 7406 | ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) |
| 7413 | 7407 | ** to enable or disable only the C-API.)^ |
| 7414 | 7408 | ** |
| 7415 | 7409 | ** <b>Security warning:</b> It is recommended that extension loading |
| 7416 | | -** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 7410 | +** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 7417 | 7411 | ** rather than this interface, so the [load_extension()] SQL function |
| 7418 | 7412 | ** remains disabled. This will prevent SQL injections from giving attackers |
| 7419 | 7413 | ** access to extension loading capabilities. |
| 7420 | 7414 | */ |
| 7421 | 7415 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| | @@ -7498,11 +7492,11 @@ |
| 7498 | 7492 | /* |
| 7499 | 7493 | ** CAPI3REF: Virtual Table Object |
| 7500 | 7494 | ** KEYWORDS: sqlite3_module {virtual table module} |
| 7501 | 7495 | ** |
| 7502 | 7496 | ** This structure, sometimes called a "virtual table module", |
| 7503 | | -** defines the implementation of a [virtual tables]. |
| 7497 | +** defines the implementation of a [virtual table]. |
| 7504 | 7498 | ** This structure consists mostly of methods for the module. |
| 7505 | 7499 | ** |
| 7506 | 7500 | ** ^A virtual table module is created by filling in a persistent |
| 7507 | 7501 | ** instance of this structure and passing a pointer to that instance |
| 7508 | 7502 | ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. |
| | @@ -7595,11 +7589,17 @@ |
| 7595 | 7589 | ** The [xBestIndex] method must fill aConstraintUsage[] with information |
| 7596 | 7590 | ** about what parameters to pass to xFilter. ^If argvIndex>0 then |
| 7597 | 7591 | ** the right-hand side of the corresponding aConstraint[] is evaluated |
| 7598 | 7592 | ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit |
| 7599 | 7593 | ** is true, then the constraint is assumed to be fully handled by the |
| 7600 | | -** virtual table and is not checked again by SQLite.)^ |
| 7594 | +** virtual table and might not be checked again by the byte code.)^ ^(The |
| 7595 | +** aConstraintUsage[].omit flag is an optimization hint. When the omit flag |
| 7596 | +** is left in its default setting of false, the constraint will always be |
| 7597 | +** checked separately in byte code. If the omit flag is change to true, then |
| 7598 | +** the constraint may or may not be checked in byte code. In other words, |
| 7599 | +** when the omit flag is true there is no guarantee that the constraint will |
| 7600 | +** not be checked again using byte code.)^ |
| 7601 | 7601 | ** |
| 7602 | 7602 | ** ^The idxNum and idxPtr values are recorded and passed into the |
| 7603 | 7603 | ** [xFilter] method. |
| 7604 | 7604 | ** ^[sqlite3_free()] is used to free idxPtr if and only if |
| 7605 | 7605 | ** needToFreeIdxPtr is true. |
| | @@ -7635,11 +7635,11 @@ |
| 7635 | 7635 | ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info |
| 7636 | 7636 | ** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). |
| 7637 | 7637 | ** If a virtual table extension is |
| 7638 | 7638 | ** used with an SQLite version earlier than 3.8.2, the results of attempting |
| 7639 | 7639 | ** to read or write the estimatedRows field are undefined (but are likely |
| 7640 | | -** to included crashing the application). The estimatedRows field should |
| 7640 | +** to include crashing the application). The estimatedRows field should |
| 7641 | 7641 | ** therefore only be used if [sqlite3_libversion_number()] returns a |
| 7642 | 7642 | ** value greater than or equal to 3008002. Similarly, the idxFlags field |
| 7643 | 7643 | ** was added for [version 3.9.0] ([dateof:3.9.0]). |
| 7644 | 7644 | ** It may therefore only be used if |
| 7645 | 7645 | ** sqlite3_libversion_number() returns a value greater than or equal to |
| | @@ -7687,11 +7687,11 @@ |
| 7687 | 7687 | #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */ |
| 7688 | 7688 | |
| 7689 | 7689 | /* |
| 7690 | 7690 | ** CAPI3REF: Virtual Table Constraint Operator Codes |
| 7691 | 7691 | ** |
| 7692 | | -** These macros defined the allowed values for the |
| 7692 | +** These macros define the allowed values for the |
| 7693 | 7693 | ** [sqlite3_index_info].aConstraint[].op field. Each value represents |
| 7694 | 7694 | ** an operator that is part of a constraint term in the wHERE clause of |
| 7695 | 7695 | ** a query that uses a [virtual table]. |
| 7696 | 7696 | */ |
| 7697 | 7697 | #define SQLITE_INDEX_CONSTRAINT_EQ 2 |
| | @@ -8297,11 +8297,11 @@ |
| 8297 | 8297 | ** </ul>)^ |
| 8298 | 8298 | ** |
| 8299 | 8299 | ** The only difference is that the public sqlite3_XXX functions enumerated |
| 8300 | 8300 | ** above silently ignore any invocations that pass a NULL pointer instead |
| 8301 | 8301 | ** of a valid mutex handle. The implementations of the methods defined |
| 8302 | | -** by this structure are not required to handle this case, the results |
| 8302 | +** by this structure are not required to handle this case. The results |
| 8303 | 8303 | ** of passing a NULL pointer instead of a valid mutex handle are undefined |
| 8304 | 8304 | ** (i.e. it is acceptable to provide an implementation that segfaults if |
| 8305 | 8305 | ** it is passed a NULL pointer). |
| 8306 | 8306 | ** |
| 8307 | 8307 | ** The xMutexInit() method must be threadsafe. It must be harmless to |
| | @@ -8770,11 +8770,11 @@ |
| 8770 | 8770 | ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because |
| 8771 | 8771 | ** no space was left in the page cache.</dd>)^ |
| 8772 | 8772 | ** |
| 8773 | 8773 | ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
| 8774 | 8774 | ** <dd>This parameter records the largest memory allocation request |
| 8775 | | -** handed to [pagecache memory allocator]. Only the value returned in the |
| 8775 | +** handed to the [pagecache memory allocator]. Only the value returned in the |
| 8776 | 8776 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 8777 | 8777 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 8778 | 8778 | ** |
| 8779 | 8779 | ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt> |
| 8780 | 8780 | ** <dd>No longer used.</dd> |
| | @@ -8846,11 +8846,11 @@ |
| 8846 | 8846 | ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 8847 | 8847 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 8848 | 8848 | ** checked out.</dd>)^ |
| 8849 | 8849 | ** |
| 8850 | 8850 | ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 8851 | | -** <dd>This parameter returns the number malloc attempts that were |
| 8851 | +** <dd>This parameter returns the number of malloc attempts that were |
| 8852 | 8852 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 8853 | 8853 | ** the current value is always zero.)^ |
| 8854 | 8854 | ** |
| 8855 | 8855 | ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] |
| 8856 | 8856 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| | @@ -8928,11 +8928,11 @@ |
| 8928 | 8928 | ** <dd>This parameter returns the number of dirty cache entries that have |
| 8929 | 8929 | ** been written to disk in the middle of a transaction due to the page |
| 8930 | 8930 | ** cache overflowing. Transactions are more efficient if they are written |
| 8931 | 8931 | ** to disk all at once. When pages spill mid-transaction, that introduces |
| 8932 | 8932 | ** additional overhead. This parameter can be used help identify |
| 8933 | | -** inefficiencies that can be resolve by increasing the cache size. |
| 8933 | +** inefficiencies that can be resolved by increasing the cache size. |
| 8934 | 8934 | ** </dd> |
| 8935 | 8935 | ** |
| 8936 | 8936 | ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt> |
| 8937 | 8937 | ** <dd>This parameter returns zero for the current value if and only if |
| 8938 | 8938 | ** all foreign key constraints (deferred or immediate) have been |
| | @@ -9017,11 +9017,11 @@ |
| 9017 | 9017 | ** If the number of virtual machine operations exceeds 2147483647 |
| 9018 | 9018 | ** then the value returned by this statement status code is undefined. |
| 9019 | 9019 | ** |
| 9020 | 9020 | ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt> |
| 9021 | 9021 | ** <dd>^This is the number of times that the prepare statement has been |
| 9022 | | -** automatically regenerated due to schema changes or change to |
| 9022 | +** automatically regenerated due to schema changes or changes to |
| 9023 | 9023 | ** [bound parameters] that might affect the query plan. |
| 9024 | 9024 | ** |
| 9025 | 9025 | ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> |
| 9026 | 9026 | ** <dd>^This is the number of times that the prepared statement has |
| 9027 | 9027 | ** been run. A single "run" for the purposes of this counter is one |
| | @@ -9188,11 +9188,11 @@ |
| 9188 | 9188 | ** NULL if allocating a new page is effectively impossible. |
| 9189 | 9189 | ** </table> |
| 9190 | 9190 | ** |
| 9191 | 9191 | ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite |
| 9192 | 9192 | ** will only use a createFlag of 2 after a prior call with a createFlag of 1 |
| 9193 | | -** failed.)^ In between the to xFetch() calls, SQLite may |
| 9193 | +** failed.)^ In between the xFetch() calls, SQLite may |
| 9194 | 9194 | ** attempt to unpin one or more cache pages by spilling the content of |
| 9195 | 9195 | ** pinned pages to disk and synching the operating system disk cache. |
| 9196 | 9196 | ** |
| 9197 | 9197 | ** [[the xUnpin() page cache method]] |
| 9198 | 9198 | ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page |
| | @@ -9506,11 +9506,11 @@ |
| 9506 | 9506 | ** application receives an SQLITE_LOCKED error, it may call the |
| 9507 | 9507 | ** sqlite3_unlock_notify() method with the blocked connection handle as |
| 9508 | 9508 | ** the first argument to register for a callback that will be invoked |
| 9509 | 9509 | ** when the blocking connections current transaction is concluded. ^The |
| 9510 | 9510 | ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] |
| 9511 | | -** call that concludes the blocking connections transaction. |
| 9511 | +** call that concludes the blocking connection's transaction. |
| 9512 | 9512 | ** |
| 9513 | 9513 | ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, |
| 9514 | 9514 | ** there is a chance that the blocking connection will have already |
| 9515 | 9515 | ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. |
| 9516 | 9516 | ** If this happens, then the specified callback is invoked immediately, |
| | @@ -9544,11 +9544,11 @@ |
| 9544 | 9544 | ** However, the signature of the callback function allows SQLite to pass |
| 9545 | 9545 | ** it an array of void* context pointers. The first argument passed to |
| 9546 | 9546 | ** an unlock-notify callback is a pointer to an array of void* pointers, |
| 9547 | 9547 | ** and the second is the number of entries in the array. |
| 9548 | 9548 | ** |
| 9549 | | -** When a blocking connections transaction is concluded, there may be |
| 9549 | +** When a blocking connection's transaction is concluded, there may be |
| 9550 | 9550 | ** more than one blocked connection that has registered for an unlock-notify |
| 9551 | 9551 | ** callback. ^If two or more such blocked connections have specified the |
| 9552 | 9552 | ** same callback function, then instead of invoking the callback function |
| 9553 | 9553 | ** multiple times, it is invoked once with the set of void* context pointers |
| 9554 | 9554 | ** specified by the blocked connections bundled together into an array. |
| | @@ -10018,37 +10018,37 @@ |
| 10018 | 10018 | ** managed by the prepared statement S and will be automatically freed when |
| 10019 | 10019 | ** S is finalized. |
| 10020 | 10020 | ** |
| 10021 | 10021 | ** <dl> |
| 10022 | 10022 | ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt> |
| 10023 | | -** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be |
| 10023 | +** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be |
| 10024 | 10024 | ** set to the total number of times that the X-th loop has run.</dd> |
| 10025 | 10025 | ** |
| 10026 | 10026 | ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt> |
| 10027 | | -** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set |
| 10027 | +** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be set |
| 10028 | 10028 | ** to the total number of rows examined by all iterations of the X-th loop.</dd> |
| 10029 | 10029 | ** |
| 10030 | 10030 | ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt> |
| 10031 | | -** <dd>^The "double" variable pointed to by the T parameter will be set to the |
| 10031 | +** <dd>^The "double" variable pointed to by the V parameter will be set to the |
| 10032 | 10032 | ** query planner's estimate for the average number of rows output from each |
| 10033 | 10033 | ** iteration of the X-th loop. If the query planner's estimates was accurate, |
| 10034 | 10034 | ** then this value will approximate the quotient NVISIT/NLOOP and the |
| 10035 | 10035 | ** product of this value for all prior loops with the same SELECTID will |
| 10036 | 10036 | ** be the NLOOP value for the current loop. |
| 10037 | 10037 | ** |
| 10038 | 10038 | ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt> |
| 10039 | | -** <dd>^The "const char *" variable pointed to by the T parameter will be set |
| 10039 | +** <dd>^The "const char *" variable pointed to by the V parameter will be set |
| 10040 | 10040 | ** to a zero-terminated UTF-8 string containing the name of the index or table |
| 10041 | 10041 | ** used for the X-th loop. |
| 10042 | 10042 | ** |
| 10043 | 10043 | ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt> |
| 10044 | | -** <dd>^The "const char *" variable pointed to by the T parameter will be set |
| 10044 | +** <dd>^The "const char *" variable pointed to by the V parameter will be set |
| 10045 | 10045 | ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] |
| 10046 | 10046 | ** description for the X-th loop. |
| 10047 | 10047 | ** |
| 10048 | 10048 | ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt> |
| 10049 | | -** <dd>^The "int" variable pointed to by the T parameter will be set to the |
| 10049 | +** <dd>^The "int" variable pointed to by the V parameter will be set to the |
| 10050 | 10050 | ** "select-id" for the X-th loop. The select-id identifies which query or |
| 10051 | 10051 | ** subquery the loop is part of. The main query has a select-id of zero. |
| 10052 | 10052 | ** The select-id is the same value as is output in the first column |
| 10053 | 10053 | ** of an [EXPLAIN QUERY PLAN] query. |
| 10054 | 10054 | ** </dl> |
| | @@ -10899,11 +10899,11 @@ |
| 10899 | 10899 | ** METHOD: sqlite3_session |
| 10900 | 10900 | ** |
| 10901 | 10901 | ** The second argument (xFilter) is the "filter callback". For changes to rows |
| 10902 | 10902 | ** in tables that are not attached to the Session object, the filter is called |
| 10903 | 10903 | ** to determine whether changes to the table's rows should be tracked or not. |
| 10904 | | -** If xFilter returns 0, changes is not tracked. Note that once a table is |
| 10904 | +** If xFilter returns 0, changes are not tracked. Note that once a table is |
| 10905 | 10905 | ** attached, xFilter will not be called again. |
| 10906 | 10906 | */ |
| 10907 | 10907 | SQLITE_API void sqlite3session_table_filter( |
| 10908 | 10908 | sqlite3_session *pSession, /* Session object */ |
| 10909 | 10909 | int(*xFilter)( |
| | @@ -11073,11 +11073,11 @@ |
| 11073 | 11073 | ** identical. |
| 11074 | 11074 | ** |
| 11075 | 11075 | ** It an error if database zFrom does not exist or does not contain the |
| 11076 | 11076 | ** required compatible table. |
| 11077 | 11077 | ** |
| 11078 | | -** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite |
| 11078 | +** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite |
| 11079 | 11079 | ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg |
| 11080 | 11080 | ** may be set to point to a buffer containing an English language error |
| 11081 | 11081 | ** message. It is the responsibility of the caller to free this buffer using |
| 11082 | 11082 | ** sqlite3_free(). |
| 11083 | 11083 | */ |
| | @@ -11210,11 +11210,11 @@ |
| 11210 | 11210 | |
| 11211 | 11211 | /* |
| 11212 | 11212 | ** CAPI3REF: Advance A Changeset Iterator |
| 11213 | 11213 | ** METHOD: sqlite3_changeset_iter |
| 11214 | 11214 | ** |
| 11215 | | -** This function may only be used with iterators created by function |
| 11215 | +** This function may only be used with iterators created by the function |
| 11216 | 11216 | ** [sqlite3changeset_start()]. If it is called on an iterator passed to |
| 11217 | 11217 | ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE |
| 11218 | 11218 | ** is returned and the call has no effect. |
| 11219 | 11219 | ** |
| 11220 | 11220 | ** Immediately after an iterator is created by sqlite3changeset_start(), it |
| | @@ -11626,12 +11626,12 @@ |
| 11626 | 11626 | ** in the changegroup, then the number of columns and the position of the |
| 11627 | 11627 | ** primary key columns for the table must be consistent. If this is not the |
| 11628 | 11628 | ** case, this function fails with SQLITE_SCHEMA. If the input changeset |
| 11629 | 11629 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is |
| 11630 | 11630 | ** returned. Or, if an out-of-memory condition occurs during processing, this |
| 11631 | | -** function returns SQLITE_NOMEM. In all cases, if an error occurs the |
| 11632 | | -** final contents of the changegroup is undefined. |
| 11631 | +** function returns SQLITE_NOMEM. In all cases, if an error occurs the state |
| 11632 | +** of the final contents of the changegroup is undefined. |
| 11633 | 11633 | ** |
| 11634 | 11634 | ** If no error occurs, SQLITE_OK is returned. |
| 11635 | 11635 | */ |
| 11636 | 11636 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 11637 | 11637 | |
| | @@ -11802,11 +11802,11 @@ |
| 11802 | 11802 | ** [SQLITE_CHANGESET_REPLACE]. |
| 11803 | 11803 | ** </dl> |
| 11804 | 11804 | ** |
| 11805 | 11805 | ** It is safe to execute SQL statements, including those that write to the |
| 11806 | 11806 | ** table that the callback related to, from within the xConflict callback. |
| 11807 | | -** This can be used to further customize the applications conflict |
| 11807 | +** This can be used to further customize the application's conflict |
| 11808 | 11808 | ** resolution strategy. |
| 11809 | 11809 | ** |
| 11810 | 11810 | ** All changes made by these functions are enclosed in a savepoint transaction. |
| 11811 | 11811 | ** If any other error (aside from a constraint failure when attempting to |
| 11812 | 11812 | ** write to the target database) occurs, then the savepoint transaction is |
| | @@ -12112,11 +12112,11 @@ |
| 12112 | 12112 | ** CAPI3REF: Rebase a changeset |
| 12113 | 12113 | ** EXPERIMENTAL |
| 12114 | 12114 | ** |
| 12115 | 12115 | ** Argument pIn must point to a buffer containing a changeset nIn bytes |
| 12116 | 12116 | ** in size. This function allocates and populates a buffer with a copy |
| 12117 | | -** of the changeset rebased rebased according to the configuration of the |
| 12117 | +** of the changeset rebased according to the configuration of the |
| 12118 | 12118 | ** rebaser object passed as the first argument. If successful, (*ppOut) |
| 12119 | 12119 | ** is set to point to the new buffer containing the rebased changeset and |
| 12120 | 12120 | ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the |
| 12121 | 12121 | ** responsibility of the caller to eventually free the new buffer using |
| 12122 | 12122 | ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) |
| | @@ -12520,11 +12520,11 @@ |
| 12520 | 12520 | ** the callback, an SQLite error code is returned. |
| 12521 | 12521 | ** |
| 12522 | 12522 | ** |
| 12523 | 12523 | ** xSetAuxdata(pFts5, pAux, xDelete) |
| 12524 | 12524 | ** |
| 12525 | | -** Save the pointer passed as the second argument as the extension functions |
| 12525 | +** Save the pointer passed as the second argument as the extension function's |
| 12526 | 12526 | ** "auxiliary data". The pointer may then be retrieved by the current or any |
| 12527 | 12527 | ** future invocation of the same fts5 extension function made as part of |
| 12528 | 12528 | ** the same MATCH query using the xGetAuxdata() API. |
| 12529 | 12529 | ** |
| 12530 | 12530 | ** Each extension function is allocated a single auxiliary data slot for |
| | @@ -12762,12 +12762,12 @@ |
| 12762 | 12762 | ** all instances of "first place" or "1st place" regardless of which form |
| 12763 | 12763 | ** the user specified in the MATCH query text. |
| 12764 | 12764 | ** |
| 12765 | 12765 | ** There are several ways to approach this in FTS5: |
| 12766 | 12766 | ** |
| 12767 | | -** <ol><li> By mapping all synonyms to a single token. In this case, the |
| 12768 | | -** In the above example, this means that the tokenizer returns the |
| 12767 | +** <ol><li> By mapping all synonyms to a single token. In this case, using |
| 12768 | +** the above example, this means that the tokenizer returns the |
| 12769 | 12769 | ** same token for inputs "first" and "1st". Say that token is in |
| 12770 | 12770 | ** fact "first", so that when the user inserts the document "I won |
| 12771 | 12771 | ** 1st place" entries are added to the index for tokens "i", "won", |
| 12772 | 12772 | ** "first" and "place". If the user then queries for '1st + place', |
| 12773 | 12773 | ** the tokenizer substitutes "first" for "1st" and the query works |
| | @@ -13435,10 +13435,30 @@ |
| 13435 | 13435 | #else |
| 13436 | 13436 | # define ALWAYS(X) (X) |
| 13437 | 13437 | # define NEVER(X) (X) |
| 13438 | 13438 | #endif |
| 13439 | 13439 | |
| 13440 | +/* |
| 13441 | +** The harmless(X) macro indicates that expression X is usually false |
| 13442 | +** but can be true without causing any problems, but we don't know of |
| 13443 | +** any way to cause X to be true. |
| 13444 | +** |
| 13445 | +** In debugging and testing builds, this macro will abort if X is ever |
| 13446 | +** true. In this way, developers are alerted to a possible test case |
| 13447 | +** that causes X to be true. If a harmless macro ever fails, that is |
| 13448 | +** an opportunity to change the macro into a testcase() and add a new |
| 13449 | +** test case to the test suite. |
| 13450 | +** |
| 13451 | +** For normal production builds, harmless(X) is a no-op, since it does |
| 13452 | +** not matter whether expression X is true or false. |
| 13453 | +*/ |
| 13454 | +#ifdef SQLITE_DEBUG |
| 13455 | +# define harmless(X) assert(!(X)); |
| 13456 | +#else |
| 13457 | +# define harmless(X) |
| 13458 | +#endif |
| 13459 | + |
| 13440 | 13460 | /* |
| 13441 | 13461 | ** Some conditionals are optimizations only. In other words, if the |
| 13442 | 13462 | ** conditionals are replaced with a constant 1 (true) or 0 (false) then |
| 13443 | 13463 | ** the correct answer is still obtained, though perhaps not as quickly. |
| 13444 | 13464 | ** |
| | @@ -15149,13 +15169,14 @@ |
| 15149 | 15169 | #define OP_VRename 163 |
| 15150 | 15170 | #define OP_Pagecount 164 |
| 15151 | 15171 | #define OP_MaxPgcnt 165 |
| 15152 | 15172 | #define OP_Trace 166 |
| 15153 | 15173 | #define OP_CursorHint 167 |
| 15154 | | -#define OP_Noop 168 |
| 15155 | | -#define OP_Explain 169 |
| 15156 | | -#define OP_Abortable 170 |
| 15174 | +#define OP_ReleaseReg 168 /* synopsis: release r[P1@P2] mask P3 */ |
| 15175 | +#define OP_Noop 169 |
| 15176 | +#define OP_Explain 170 |
| 15177 | +#define OP_Abortable 171 |
| 15157 | 15178 | |
| 15158 | 15179 | /* Properties such as "out2" or "jump" that are specified in |
| 15159 | 15180 | ** comments following the "case" for each opcode in the vdbe.c |
| 15160 | 15181 | ** are encoded into bitvectors as follows: |
| 15161 | 15182 | */ |
| | @@ -15185,11 +15206,11 @@ |
| 15185 | 15206 | /* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 15186 | 15207 | /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15187 | 15208 | /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\ |
| 15188 | 15209 | /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15189 | 15210 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 15190 | | -/* 168 */ 0x00, 0x00, 0x00,} |
| 15211 | +/* 168 */ 0x00, 0x00, 0x00, 0x00,} |
| 15191 | 15212 | |
| 15192 | 15213 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 15193 | 15214 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 15194 | 15215 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 15195 | 15216 | ** generated this include file strives to group all JUMP opcodes |
| | @@ -15262,10 +15283,15 @@ |
| 15262 | 15283 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); |
| 15263 | 15284 | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5); |
| 15264 | 15285 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); |
| 15265 | 15286 | SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr); |
| 15266 | 15287 | SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); |
| 15288 | +#ifdef SQLITE_DEBUG |
| 15289 | +SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse*,int addr, int n, u32 mask); |
| 15290 | +#else |
| 15291 | +# define sqlite3VdbeReleaseRegisters(P,A,N,M) |
| 15292 | +#endif |
| 15267 | 15293 | SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
| 15268 | 15294 | SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type); |
| 15269 | 15295 | SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); |
| 15270 | 15296 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); |
| 15271 | 15297 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| | @@ -16841,16 +16867,10 @@ |
| 16841 | 16867 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 16842 | 16868 | pArg, 0, xFunc, 0, 0, 0, #zName, } |
| 16843 | 16869 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 16844 | 16870 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 16845 | 16871 | (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } |
| 16846 | | -#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \ |
| 16847 | | - {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \ |
| 16848 | | - SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}} |
| 16849 | | -#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \ |
| 16850 | | - {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ |
| 16851 | | - SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}} |
| 16852 | 16872 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ |
| 16853 | 16873 | {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ |
| 16854 | 16874 | SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}} |
| 16855 | 16875 | #define INTERNAL_FUNCTION(zName, nArg, xFunc) \ |
| 16856 | 16876 | {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| | @@ -17978,17 +17998,17 @@ |
| 17978 | 17998 | ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences |
| 17979 | 17999 | ** for the result set. The KeyInfo for addrOpenEphm[2] contains collating |
| 17980 | 18000 | ** sequences for the ORDER BY clause. |
| 17981 | 18001 | */ |
| 17982 | 18002 | struct Select { |
| 17983 | | - ExprList *pEList; /* The fields of the result */ |
| 17984 | 18003 | u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ |
| 17985 | 18004 | LogEst nSelectRow; /* Estimated number of result rows */ |
| 17986 | 18005 | u32 selFlags; /* Various SF_* values */ |
| 17987 | 18006 | int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */ |
| 17988 | 18007 | u32 selId; /* Unique identifier number for this SELECT */ |
| 17989 | 18008 | int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */ |
| 18009 | + ExprList *pEList; /* The fields of the result */ |
| 17990 | 18010 | SrcList *pSrc; /* The FROM clause */ |
| 17991 | 18011 | Expr *pWhere; /* The WHERE clause */ |
| 17992 | 18012 | ExprList *pGroupBy; /* The GROUP BY clause */ |
| 17993 | 18013 | Expr *pHaving; /* The HAVING clause */ |
| 17994 | 18014 | ExprList *pOrderBy; /* The ORDER BY clause */ |
| | @@ -18030,10 +18050,11 @@ |
| 18030 | 18050 | #define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */ |
| 18031 | 18051 | #define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */ |
| 18032 | 18052 | #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */ |
| 18033 | 18053 | #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */ |
| 18034 | 18054 | #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ |
| 18055 | +#define SF_View 0x0200000 /* SELECT statement is a view */ |
| 18035 | 18056 | |
| 18036 | 18057 | /* |
| 18037 | 18058 | ** The results of a SELECT can be distributed in several ways, as defined |
| 18038 | 18059 | ** by one of the following macros. The "SRT" prefix means "SELECT Result |
| 18039 | 18060 | ** Type". |
| | @@ -18309,12 +18330,12 @@ |
| 18309 | 18330 | #endif |
| 18310 | 18331 | }; |
| 18311 | 18332 | |
| 18312 | 18333 | #define PARSE_MODE_NORMAL 0 |
| 18313 | 18334 | #define PARSE_MODE_DECLARE_VTAB 1 |
| 18314 | | -#define PARSE_MODE_RENAME_COLUMN 2 |
| 18315 | | -#define PARSE_MODE_RENAME_TABLE 3 |
| 18335 | +#define PARSE_MODE_RENAME 2 |
| 18336 | +#define PARSE_MODE_UNMAP 3 |
| 18316 | 18337 | |
| 18317 | 18338 | /* |
| 18318 | 18339 | ** Sizes and pointers of various parts of the Parse object. |
| 18319 | 18340 | */ |
| 18320 | 18341 | #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/ |
| | @@ -18332,11 +18353,11 @@ |
| 18332 | 18353 | #endif |
| 18333 | 18354 | |
| 18334 | 18355 | #if defined(SQLITE_OMIT_ALTERTABLE) |
| 18335 | 18356 | #define IN_RENAME_OBJECT 0 |
| 18336 | 18357 | #else |
| 18337 | | - #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN) |
| 18358 | + #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME) |
| 18338 | 18359 | #endif |
| 18339 | 18360 | |
| 18340 | 18361 | #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE) |
| 18341 | 18362 | #define IN_SPECIAL_PARSE 0 |
| 18342 | 18363 | #else |
| | @@ -19151,10 +19172,11 @@ |
| 19151 | 19172 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 19152 | 19173 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 19153 | 19174 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 19154 | 19175 | Expr*,ExprList*,u32,Expr*); |
| 19155 | 19176 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 19177 | +SQLITE_PRIVATE void sqlite3SelectReset(Parse*, Select*); |
| 19156 | 19178 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 19157 | 19179 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); |
| 19158 | 19180 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 19159 | 19181 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 19160 | 19182 | SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*); |
| | @@ -20734,11 +20756,11 @@ |
| 20734 | 20756 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); |
| 20735 | 20757 | SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull); |
| 20736 | 20758 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); |
| 20737 | 20759 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 20738 | 20760 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 20739 | | -SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8); |
| 20761 | +SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8); |
| 20740 | 20762 | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*); |
| 20741 | 20763 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); |
| 20742 | 20764 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); |
| 20743 | 20765 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 20744 | 20766 | SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*); |
| | @@ -22654,11 +22676,11 @@ |
| 22654 | 22676 | DO_OS_MALLOC_TEST(0); |
| 22655 | 22677 | /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed |
| 22656 | 22678 | ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, |
| 22657 | 22679 | ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before |
| 22658 | 22680 | ** reaching the VFS. */ |
| 22659 | | - rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); |
| 22681 | + rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x1087f7f, pFlagsOut); |
| 22660 | 22682 | assert( rc==SQLITE_OK || pFile->pMethods==0 ); |
| 22661 | 22683 | return rc; |
| 22662 | 22684 | } |
| 22663 | 22685 | SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ |
| 22664 | 22686 | DO_OS_MALLOC_TEST(0); |
| | @@ -29289,12 +29311,13 @@ |
| 29289 | 29311 | zOp2[0] = 0; |
| 29290 | 29312 | } |
| 29291 | 29313 | sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s", |
| 29292 | 29314 | pExpr->iColumn, zFlgs, zOp2); |
| 29293 | 29315 | }else{ |
| 29294 | | - sqlite3TreeViewLine(pView, "{%d:%d}%s", |
| 29295 | | - pExpr->iTable, pExpr->iColumn, zFlgs); |
| 29316 | + sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s", |
| 29317 | + pExpr->iTable, pExpr->iColumn, |
| 29318 | + pExpr->y.pTab, zFlgs); |
| 29296 | 29319 | } |
| 29297 | 29320 | if( ExprHasProperty(pExpr, EP_FixedCol) ){ |
| 29298 | 29321 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 29299 | 29322 | } |
| 29300 | 29323 | break; |
| | @@ -30961,11 +30984,11 @@ |
| 30961 | 30984 | #pragma warning(disable : 4756) |
| 30962 | 30985 | #endif |
| 30963 | 30986 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 30964 | 30987 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 30965 | 30988 | int incr; |
| 30966 | | - const char *zEnd = z + length; |
| 30989 | + const char *zEnd; |
| 30967 | 30990 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 30968 | 30991 | int sign = 1; /* sign of significand */ |
| 30969 | 30992 | i64 s = 0; /* significand */ |
| 30970 | 30993 | int d = 0; /* adjust exponent for shifting decimal point */ |
| 30971 | 30994 | int esign = 1; /* sign of exponent */ |
| | @@ -30975,13 +30998,15 @@ |
| 30975 | 30998 | int nDigit = 0; /* Number of digits processed */ |
| 30976 | 30999 | int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ |
| 30977 | 31000 | |
| 30978 | 31001 | assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); |
| 30979 | 31002 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 31003 | + if( length==0 ) return 0; |
| 30980 | 31004 | |
| 30981 | 31005 | if( enc==SQLITE_UTF8 ){ |
| 30982 | 31006 | incr = 1; |
| 31007 | + zEnd = z + length; |
| 30983 | 31008 | }else{ |
| 30984 | 31009 | int i; |
| 30985 | 31010 | incr = 2; |
| 30986 | 31011 | assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); |
| 30987 | 31012 | testcase( enc==SQLITE_UTF16LE ); |
| | @@ -32660,13 +32685,14 @@ |
| 32660 | 32685 | /* 163 */ "VRename" OpHelp(""), |
| 32661 | 32686 | /* 164 */ "Pagecount" OpHelp(""), |
| 32662 | 32687 | /* 165 */ "MaxPgcnt" OpHelp(""), |
| 32663 | 32688 | /* 166 */ "Trace" OpHelp(""), |
| 32664 | 32689 | /* 167 */ "CursorHint" OpHelp(""), |
| 32665 | | - /* 168 */ "Noop" OpHelp(""), |
| 32666 | | - /* 169 */ "Explain" OpHelp(""), |
| 32667 | | - /* 170 */ "Abortable" OpHelp(""), |
| 32690 | + /* 168 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 32691 | + /* 169 */ "Noop" OpHelp(""), |
| 32692 | + /* 170 */ "Explain" OpHelp(""), |
| 32693 | + /* 171 */ "Abortable" OpHelp(""), |
| 32668 | 32694 | }; |
| 32669 | 32695 | return azName[i]; |
| 32670 | 32696 | } |
| 32671 | 32697 | #endif |
| 32672 | 32698 | |
| | @@ -36555,11 +36581,11 @@ |
| 36555 | 36581 | zDirname[ii] = '\0'; |
| 36556 | 36582 | }else{ |
| 36557 | 36583 | if( zDirname[0]!='/' ) zDirname[0] = '.'; |
| 36558 | 36584 | zDirname[1] = 0; |
| 36559 | 36585 | } |
| 36560 | | - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); |
| 36586 | + fd = robust_open(zDirname, O_RDONLY|O_BINARY|O_NOFOLLOW, 0); |
| 36561 | 36587 | if( fd>=0 ){ |
| 36562 | 36588 | OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); |
| 36563 | 36589 | } |
| 36564 | 36590 | *pFd = fd; |
| 36565 | 36591 | if( fd>=0 ) return SQLITE_OK; |
| | @@ -37446,14 +37472,16 @@ |
| 37446 | 37472 | } |
| 37447 | 37473 | } |
| 37448 | 37474 | |
| 37449 | 37475 | if( pInode->bProcessLock==0 ){ |
| 37450 | 37476 | if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){ |
| 37451 | | - pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777)); |
| 37477 | + pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT|O_NOFOLLOW, |
| 37478 | + (sStat.st_mode&0777)); |
| 37452 | 37479 | } |
| 37453 | 37480 | if( pShmNode->hShm<0 ){ |
| 37454 | | - pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777)); |
| 37481 | + pShmNode->hShm = robust_open(zShm, O_RDONLY|O_NOFOLLOW, |
| 37482 | + (sStat.st_mode&0777)); |
| 37455 | 37483 | if( pShmNode->hShm<0 ){ |
| 37456 | 37484 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm); |
| 37457 | 37485 | goto shm_open_err; |
| 37458 | 37486 | } |
| 37459 | 37487 | pShmNode->isReadonly = 1; |
| | @@ -38799,11 +38827,11 @@ |
| 38799 | 38827 | int *pOutFlags /* Output flags returned to SQLite core */ |
| 38800 | 38828 | ){ |
| 38801 | 38829 | unixFile *p = (unixFile *)pFile; |
| 38802 | 38830 | int fd = -1; /* File descriptor returned by open() */ |
| 38803 | 38831 | int openFlags = 0; /* Flags to pass to open() */ |
| 38804 | | - int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 38832 | + int eType = flags&0x0FFF00; /* Type of file to open */ |
| 38805 | 38833 | int noLock; /* True to omit locking primitives */ |
| 38806 | 38834 | int rc = SQLITE_OK; /* Function Return Code */ |
| 38807 | 38835 | int ctrlFlags = 0; /* UNIXFILE_* flags */ |
| 38808 | 38836 | |
| 38809 | 38837 | int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); |
| | @@ -38909,11 +38937,11 @@ |
| 38909 | 38937 | ** 'conch file' locking functions later on. */ |
| 38910 | 38938 | if( isReadonly ) openFlags |= O_RDONLY; |
| 38911 | 38939 | if( isReadWrite ) openFlags |= O_RDWR; |
| 38912 | 38940 | if( isCreate ) openFlags |= O_CREAT; |
| 38913 | 38941 | if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); |
| 38914 | | - openFlags |= (O_LARGEFILE|O_BINARY); |
| 38942 | + openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW); |
| 38915 | 38943 | |
| 38916 | 38944 | if( fd<0 ){ |
| 38917 | 38945 | mode_t openMode; /* Permissions to create file with */ |
| 38918 | 38946 | uid_t uid; /* Userid for the file */ |
| 38919 | 38947 | gid_t gid; /* Groupid for the file */ |
| | @@ -39121,29 +39149,20 @@ |
| 39121 | 39149 | ){ |
| 39122 | 39150 | UNUSED_PARAMETER(NotUsed); |
| 39123 | 39151 | SimulateIOError( return SQLITE_IOERR_ACCESS; ); |
| 39124 | 39152 | assert( pResOut!=0 ); |
| 39125 | 39153 | |
| 39126 | | - /* The spec says there are four possible values for flags. But the |
| 39127 | | - ** SQLITE_ACCESS_READ flag is never used */ |
| 39128 | | - assert( flags==SQLITE_ACCESS_EXISTS |
| 39129 | | - || flags==SQLITE_ACCESS_READWRITE |
| 39130 | | - || flags==SQLITE_ACCESS_SYMLINK ); |
| 39154 | + /* The spec says there are three possible values for flags. But only |
| 39155 | + ** two of them are actually used */ |
| 39156 | + assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE ); |
| 39131 | 39157 | |
| 39132 | 39158 | if( flags==SQLITE_ACCESS_EXISTS ){ |
| 39133 | 39159 | struct stat buf; |
| 39134 | | - *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0); |
| 39135 | | - }else if( flags==SQLITE_ACCESS_READWRITE ){ |
| 39160 | + *pResOut = 0==osStat(zPath, &buf) && |
| 39161 | + (S_ISDIR(buf.st_mode) || buf.st_size>0); |
| 39162 | + }else{ |
| 39136 | 39163 | *pResOut = osAccess(zPath, W_OK|R_OK)==0; |
| 39137 | | - }else{ |
| 39138 | | -#if !defined(HAVE_LSTAT) |
| 39139 | | - *pResOut = 0; |
| 39140 | | -#else |
| 39141 | | - struct stat buf; |
| 39142 | | - *pResOut = (0==osLstat(zPath, &buf) && S_ISLNK(buf.st_mode)); |
| 39143 | | -#endif |
| 39144 | | - assert( flags==SQLITE_ACCESS_SYMLINK ); |
| 39145 | 39164 | } |
| 39146 | 39165 | return SQLITE_OK; |
| 39147 | 39166 | } |
| 39148 | 39167 | |
| 39149 | 39168 | /* |
| | @@ -39191,11 +39210,11 @@ |
| 39191 | 39210 | #if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT) |
| 39192 | 39211 | return mkFullPathname(zPath, zOut, nOut); |
| 39193 | 39212 | #else |
| 39194 | 39213 | int rc = SQLITE_OK; |
| 39195 | 39214 | int nByte; |
| 39196 | | - int nLink = 1; /* Number of symbolic links followed so far */ |
| 39215 | + int nLink = 0; /* Number of symbolic links followed so far */ |
| 39197 | 39216 | const char *zIn = zPath; /* Input path for each iteration of loop */ |
| 39198 | 39217 | char *zDel = 0; |
| 39199 | 39218 | |
| 39200 | 39219 | assert( pVfs->mxPathname==MAX_PATHNAME ); |
| 39201 | 39220 | UNUSED_PARAMETER(pVfs); |
| | @@ -39220,14 +39239,15 @@ |
| 39220 | 39239 | }else{ |
| 39221 | 39240 | bLink = S_ISLNK(buf.st_mode); |
| 39222 | 39241 | } |
| 39223 | 39242 | |
| 39224 | 39243 | if( bLink ){ |
| 39244 | + nLink++; |
| 39225 | 39245 | if( zDel==0 ){ |
| 39226 | 39246 | zDel = sqlite3_malloc(nOut); |
| 39227 | 39247 | if( zDel==0 ) rc = SQLITE_NOMEM_BKPT; |
| 39228 | | - }else if( ++nLink>SQLITE_MAX_SYMLINKS ){ |
| 39248 | + }else if( nLink>=SQLITE_MAX_SYMLINKS ){ |
| 39229 | 39249 | rc = SQLITE_CANTOPEN_BKPT; |
| 39230 | 39250 | } |
| 39231 | 39251 | |
| 39232 | 39252 | if( rc==SQLITE_OK ){ |
| 39233 | 39253 | nByte = osReadlink(zIn, zDel, nOut-1); |
| | @@ -39259,10 +39279,11 @@ |
| 39259 | 39279 | if( bLink==0 ) break; |
| 39260 | 39280 | zIn = zOut; |
| 39261 | 39281 | }while( rc==SQLITE_OK ); |
| 39262 | 39282 | |
| 39263 | 39283 | sqlite3_free(zDel); |
| 39284 | + if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK; |
| 39264 | 39285 | return rc; |
| 39265 | 39286 | #endif /* HAVE_READLINK && HAVE_LSTAT */ |
| 39266 | 39287 | } |
| 39267 | 39288 | |
| 39268 | 39289 | |
| | @@ -39744,11 +39765,11 @@ |
| 39744 | 39765 | int islockfile /* if non zero missing dirs will be created */ |
| 39745 | 39766 | ) { |
| 39746 | 39767 | int fd = -1; |
| 39747 | 39768 | unixFile *pNew; |
| 39748 | 39769 | int rc = SQLITE_OK; |
| 39749 | | - int openFlags = O_RDWR | O_CREAT; |
| 39770 | + int openFlags = O_RDWR | O_CREAT | O_NOFOLLOW; |
| 39750 | 39771 | sqlite3_vfs dummyVfs; |
| 39751 | 39772 | int terrno = 0; |
| 39752 | 39773 | UnixUnusedFd *pUnused = NULL; |
| 39753 | 39774 | |
| 39754 | 39775 | /* 1. first try to open/create the file |
| | @@ -39774,11 +39795,11 @@ |
| 39774 | 39795 | fd = robust_open(path, openFlags, 0); |
| 39775 | 39796 | } |
| 39776 | 39797 | } |
| 39777 | 39798 | } |
| 39778 | 39799 | if( fd<0 ){ |
| 39779 | | - openFlags = O_RDONLY; |
| 39800 | + openFlags = O_RDONLY | O_NOFOLLOW; |
| 39780 | 39801 | fd = robust_open(path, openFlags, 0); |
| 39781 | 39802 | terrno = errno; |
| 39782 | 39803 | } |
| 39783 | 39804 | if( fd<0 ){ |
| 39784 | 39805 | if( islockfile ){ |
| | @@ -39900,11 +39921,11 @@ |
| 39900 | 39921 | if( readLen<PROXY_PATHINDEX ){ |
| 39901 | 39922 | sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen); |
| 39902 | 39923 | goto end_breaklock; |
| 39903 | 39924 | } |
| 39904 | 39925 | /* write it out to the temporary break file */ |
| 39905 | | - fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0); |
| 39926 | + fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), 0); |
| 39906 | 39927 | if( fd<0 ){ |
| 39907 | 39928 | sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 39908 | 39929 | goto end_breaklock; |
| 39909 | 39930 | } |
| 39910 | 39931 | if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){ |
| | @@ -41060,18 +41081,10 @@ |
| 41060 | 41081 | |
| 41061 | 41082 | #ifndef NTDDI_WINTHRESHOLD |
| 41062 | 41083 | # define NTDDI_WINTHRESHOLD 0x06040000 |
| 41063 | 41084 | #endif |
| 41064 | 41085 | |
| 41065 | | -/* |
| 41066 | | -** This constant is needed by the winAccess function; therefore, define |
| 41067 | | -** it when it is missing from the SDK header files. |
| 41068 | | -*/ |
| 41069 | | -#ifndef FILE_ATTRIBUTE_REPARSE_POINT |
| 41070 | | -# define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 |
| 41071 | | -#endif |
| 41072 | | - |
| 41073 | 41086 | /* |
| 41074 | 41087 | ** Check to see if the GetVersionEx[AW] functions are deprecated on the |
| 41075 | 41088 | ** target system. GetVersionEx was first deprecated in Win8.1. |
| 41076 | 41089 | */ |
| 41077 | 41090 | #ifndef SQLITE_WIN32_GETVERSIONEX |
| | @@ -46460,14 +46473,10 @@ |
| 46460 | 46473 | break; |
| 46461 | 46474 | case SQLITE_ACCESS_READWRITE: |
| 46462 | 46475 | rc = attr!=INVALID_FILE_ATTRIBUTES && |
| 46463 | 46476 | (attr & FILE_ATTRIBUTE_READONLY)==0; |
| 46464 | 46477 | break; |
| 46465 | | - case SQLITE_ACCESS_SYMLINK: |
| 46466 | | - rc = attr!=INVALID_FILE_ATTRIBUTES && |
| 46467 | | - (attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0; |
| 46468 | | - break; |
| 46469 | 46478 | default: |
| 46470 | 46479 | assert(!"Invalid flags argument"); |
| 46471 | 46480 | } |
| 46472 | 46481 | *pResOut = rc; |
| 46473 | 46482 | OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n", |
| | @@ -49503,17 +49512,19 @@ |
| 49503 | 49512 | sqlite3_free(p); |
| 49504 | 49513 | pPg = 0; |
| 49505 | 49514 | } |
| 49506 | 49515 | #else |
| 49507 | 49516 | pPg = pcache1Alloc(pCache->szAlloc); |
| 49508 | | - p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 49509 | 49517 | #endif |
| 49510 | 49518 | if( benignMalloc ){ sqlite3EndBenignMalloc(); } |
| 49511 | 49519 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 49512 | 49520 | pcache1EnterMutex(pCache->pGroup); |
| 49513 | 49521 | #endif |
| 49514 | 49522 | if( pPg==0 ) return 0; |
| 49523 | +#ifndef SQLITE_PCACHE_SEPARATE_HEADER |
| 49524 | + p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 49525 | +#endif |
| 49515 | 49526 | p->page.pBuf = pPg; |
| 49516 | 49527 | p->page.pExtra = &p[1]; |
| 49517 | 49528 | p->isBulkLocal = 0; |
| 49518 | 49529 | p->isAnchor = 0; |
| 49519 | 49530 | } |
| | @@ -55782,31 +55793,34 @@ |
| 55782 | 55793 | ** to by zPathname, length nPathname. Or, if this is a temporary file, |
| 55783 | 55794 | ** leave both nPathname and zPathname set to 0. |
| 55784 | 55795 | */ |
| 55785 | 55796 | if( zFilename && zFilename[0] ){ |
| 55786 | 55797 | const char *z; |
| 55787 | | - if( (vfsFlags & SQLITE_OPEN_NOFOLLOW)!=0 ){ |
| 55788 | | - int isLink = 0; |
| 55789 | | - int rc = sqlite3OsAccess(pVfs, zFilename, SQLITE_ACCESS_SYMLINK, &isLink); |
| 55790 | | - if( rc==SQLITE_OK && isLink ) rc = SQLITE_CANTOPEN_SYMLINK; |
| 55791 | | - if( rc ) return rc; |
| 55792 | | - } |
| 55793 | 55798 | nPathname = pVfs->mxPathname+1; |
| 55794 | 55799 | zPathname = sqlite3DbMallocRaw(0, nPathname*2); |
| 55795 | 55800 | if( zPathname==0 ){ |
| 55796 | 55801 | return SQLITE_NOMEM_BKPT; |
| 55797 | 55802 | } |
| 55798 | 55803 | zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ |
| 55799 | 55804 | rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname); |
| 55805 | + if( rc!=SQLITE_OK ){ |
| 55806 | + if( rc==SQLITE_OK_SYMLINK ){ |
| 55807 | + if( vfsFlags & SQLITE_OPEN_NOFOLLOW ){ |
| 55808 | + rc = SQLITE_CANTOPEN_SYMLINK; |
| 55809 | + }else{ |
| 55810 | + rc = SQLITE_OK; |
| 55811 | + } |
| 55812 | + } |
| 55813 | + } |
| 55800 | 55814 | nPathname = sqlite3Strlen30(zPathname); |
| 55801 | 55815 | z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; |
| 55802 | 55816 | while( *z ){ |
| 55803 | 55817 | z += strlen(z)+1; |
| 55804 | 55818 | z += strlen(z)+1; |
| 55805 | 55819 | nUri++; |
| 55806 | 55820 | } |
| 55807 | | - nUriByte = (int)(&z[2] - zUri); |
| 55821 | + nUriByte = (int)(&z[1] - zUri); |
| 55808 | 55822 | assert( nUriByte>=1 ); |
| 55809 | 55823 | if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ |
| 55810 | 55824 | /* This branch is taken when the journal path required by |
| 55811 | 55825 | ** the database being opened will be more than pVfs->mxPathname |
| 55812 | 55826 | ** bytes in length. This means the database cannot be opened, |
| | @@ -57616,10 +57630,11 @@ |
| 57616 | 57630 | |
| 57617 | 57631 | /* This routine should not be called if a prior error has occurred. |
| 57618 | 57632 | ** But if (due to a coding error elsewhere in the system) it does get |
| 57619 | 57633 | ** called, just return the same error code without doing anything. */ |
| 57620 | 57634 | if( NEVER(pPager->errCode) ) return pPager->errCode; |
| 57635 | + pPager->iDataVersion++; |
| 57621 | 57636 | |
| 57622 | 57637 | assert( pPager->eState==PAGER_WRITER_LOCKED |
| 57623 | 57638 | || pPager->eState==PAGER_WRITER_FINISHED |
| 57624 | 57639 | || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD) |
| 57625 | 57640 | ); |
| | @@ -57644,11 +57659,10 @@ |
| 57644 | 57659 | pPager->eState = PAGER_READER; |
| 57645 | 57660 | return SQLITE_OK; |
| 57646 | 57661 | } |
| 57647 | 57662 | |
| 57648 | 57663 | PAGERTRACE(("COMMIT %d\n", PAGERID(pPager))); |
| 57649 | | - pPager->iDataVersion++; |
| 57650 | 57664 | rc = pager_end_transaction(pPager, pPager->setMaster, 1); |
| 57651 | 57665 | return pager_error(pPager, rc); |
| 57652 | 57666 | } |
| 57653 | 57667 | |
| 57654 | 57668 | /* |
| | @@ -60565,11 +60579,23 @@ |
| 60565 | 60579 | ** of the aReadMark[] slot. The assumption here is that if that is |
| 60566 | 60580 | ** happening, the other client may only be increasing the value, |
| 60567 | 60581 | ** not decreasing it. So assuming either that either the "old" or |
| 60568 | 60582 | ** "new" version of the value is read, and not some arbitrary value |
| 60569 | 60583 | ** that would never be written by a real client, things are still |
| 60570 | | - ** safe. */ |
| 60584 | + ** safe. |
| 60585 | + ** |
| 60586 | + ** Astute readers have pointed out that the assumption stated in the |
| 60587 | + ** last sentence of the previous paragraph is not guaranteed to be |
| 60588 | + ** true for all conforming systems. However, the assumption is true |
| 60589 | + ** for all compilers and architectures in common use today (circa |
| 60590 | + ** 2019-11-27) and the alternatives are both slow and complex, and |
| 60591 | + ** so we will continue to go with the current design for now. If this |
| 60592 | + ** bothers you, or if you really are running on a system where aligned |
| 60593 | + ** 32-bit reads and writes are not atomic, then you can simply avoid |
| 60594 | + ** the use of WAL mode, or only use WAL mode together with |
| 60595 | + ** PRAGMA locking_mode=EXCLUSIVE and all will be well. |
| 60596 | + */ |
| 60571 | 60597 | u32 y = pInfo->aReadMark[i]; |
| 60572 | 60598 | if( mxSafeFrame>y ){ |
| 60573 | 60599 | assert( y<=pWal->hdr.mxFrame ); |
| 60574 | 60600 | rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); |
| 60575 | 60601 | if( rc==SQLITE_OK ){ |
| | @@ -66021,13 +66047,17 @@ |
| 66021 | 66047 | memcpy(zFullPathname, zFilename, nFilename); |
| 66022 | 66048 | }else{ |
| 66023 | 66049 | rc = sqlite3OsFullPathname(pVfs, zFilename, |
| 66024 | 66050 | nFullPathname, zFullPathname); |
| 66025 | 66051 | if( rc ){ |
| 66026 | | - sqlite3_free(zFullPathname); |
| 66027 | | - sqlite3_free(p); |
| 66028 | | - return rc; |
| 66052 | + if( rc==SQLITE_OK_SYMLINK ){ |
| 66053 | + rc = SQLITE_OK; |
| 66054 | + }else{ |
| 66055 | + sqlite3_free(zFullPathname); |
| 66056 | + sqlite3_free(p); |
| 66057 | + return rc; |
| 66058 | + } |
| 66029 | 66059 | } |
| 66030 | 66060 | } |
| 66031 | 66061 | #if SQLITE_THREADSAFE |
| 66032 | 66062 | mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN); |
| 66033 | 66063 | sqlite3_mutex_enter(mutexOpen); |
| | @@ -69332,12 +69362,15 @@ |
| 69332 | 69362 | |
| 69333 | 69363 | /* If the database file is corrupt, it is possible for the value of idx |
| 69334 | 69364 | ** to be invalid here. This can only occur if a second cursor modifies |
| 69335 | 69365 | ** the page while cursor pCur is holding a reference to it. Which can |
| 69336 | 69366 | ** only happen if the database is corrupt in such a way as to link the |
| 69337 | | - ** page into more than one b-tree structure. */ |
| 69338 | | - testcase( idx>pPage->nCell ); |
| 69367 | + ** page into more than one b-tree structure. |
| 69368 | + ** |
| 69369 | + ** Update 2019-12-23: appears to long longer be possible after the |
| 69370 | + ** addition of anotherValidCursor() condition on balance_deeper(). */ |
| 69371 | + harmless( idx>pPage->nCell ); |
| 69339 | 69372 | |
| 69340 | 69373 | if( idx>=pPage->nCell ){ |
| 69341 | 69374 | if( !pPage->leaf ){ |
| 69342 | 69375 | rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); |
| 69343 | 69376 | if( rc ) return rc; |
| | @@ -71921,10 +71954,34 @@ |
| 71921 | 71954 | put4byte(&pRoot->aData[pRoot->hdrOffset+8], pgnoChild); |
| 71922 | 71955 | |
| 71923 | 71956 | *ppChild = pChild; |
| 71924 | 71957 | return SQLITE_OK; |
| 71925 | 71958 | } |
| 71959 | + |
| 71960 | +/* |
| 71961 | +** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid |
| 71962 | +** on the same B-tree as pCur. |
| 71963 | +** |
| 71964 | +** This can if a database is corrupt with two or more SQL tables |
| 71965 | +** pointing to the same b-tree. If an insert occurs on one SQL table |
| 71966 | +** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL |
| 71967 | +** table linked to the same b-tree. If the secondary insert causes a |
| 71968 | +** rebalance, that can change content out from under the cursor on the |
| 71969 | +** first SQL table, violating invariants on the first insert. |
| 71970 | +*/ |
| 71971 | +static int anotherValidCursor(BtCursor *pCur){ |
| 71972 | + BtCursor *pOther; |
| 71973 | + for(pOther=pCur->pBt->pCursor; pOther; pOther=pOther->pNext){ |
| 71974 | + if( pOther!=pCur |
| 71975 | + && pOther->eState==CURSOR_VALID |
| 71976 | + && pOther->pPage==pCur->pPage |
| 71977 | + ){ |
| 71978 | + return SQLITE_CORRUPT_BKPT; |
| 71979 | + } |
| 71980 | + } |
| 71981 | + return SQLITE_OK; |
| 71982 | +} |
| 71926 | 71983 | |
| 71927 | 71984 | /* |
| 71928 | 71985 | ** The page that pCur currently points to has just been modified in |
| 71929 | 71986 | ** some way. This function figures out if this modification means the |
| 71930 | 71987 | ** tree needs to be balanced, and if so calls the appropriate balancing |
| | @@ -71949,11 +72006,11 @@ |
| 71949 | 72006 | |
| 71950 | 72007 | if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break; |
| 71951 | 72008 | if( pPage->nOverflow==0 && pPage->nFree<=nMin ){ |
| 71952 | 72009 | break; |
| 71953 | 72010 | }else if( (iPage = pCur->iPage)==0 ){ |
| 71954 | | - if( pPage->nOverflow ){ |
| 72011 | + if( pPage->nOverflow && (rc = anotherValidCursor(pCur))==SQLITE_OK ){ |
| 71955 | 72012 | /* The root page of the b-tree is overfull. In this case call the |
| 71956 | 72013 | ** balance_deeper() function to create a new child for the root-page |
| 71957 | 72014 | ** and copy the current contents of the root-page to it. The |
| 71958 | 72015 | ** next iteration of the do-loop will balance the child page. |
| 71959 | 72016 | */ |
| | @@ -72320,11 +72377,13 @@ |
| 72320 | 72377 | return btreeOverwriteCell(pCur, &x2); |
| 72321 | 72378 | } |
| 72322 | 72379 | } |
| 72323 | 72380 | |
| 72324 | 72381 | } |
| 72325 | | - assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) ); |
| 72382 | + assert( pCur->eState==CURSOR_VALID |
| 72383 | + || (pCur->eState==CURSOR_INVALID && loc) |
| 72384 | + || CORRUPT_DB ); |
| 72326 | 72385 | |
| 72327 | 72386 | pPage = pCur->pPage; |
| 72328 | 72387 | assert( pPage->intKey || pX->nKey>=0 ); |
| 72329 | 72388 | assert( pPage->leaf || !pPage->intKey ); |
| 72330 | 72389 | if( pPage->nFree<0 ){ |
| | @@ -75489,12 +75548,11 @@ |
| 75489 | 75548 | if( flags & (MEM_Int|MEM_IntReal) ){ |
| 75490 | 75549 | testcase( flags & MEM_IntReal ); |
| 75491 | 75550 | return pMem->u.i; |
| 75492 | 75551 | }else if( flags & MEM_Real ){ |
| 75493 | 75552 | return doubleToInt64(pMem->u.r); |
| 75494 | | - }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 75495 | | - assert( pMem->z || pMem->n==0 ); |
| 75553 | + }else if( (flags & (MEM_Str|MEM_Blob))!=0 && pMem->z!=0 ){ |
| 75496 | 75554 | return memIntValue(pMem); |
| 75497 | 75555 | }else{ |
| 75498 | 75556 | return 0; |
| 75499 | 75557 | } |
| 75500 | 75558 | } |
| | @@ -75647,12 +75705,12 @@ |
| 75647 | 75705 | ** "aff". Casting is different from applying affinity in that a cast |
| 75648 | 75706 | ** is forced. In other words, the value is converted into the desired |
| 75649 | 75707 | ** affinity even if that results in loss of data. This routine is |
| 75650 | 75708 | ** used (for example) to implement the SQL "cast()" operator. |
| 75651 | 75709 | */ |
| 75652 | | -SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ |
| 75653 | | - if( pMem->flags & MEM_Null ) return; |
| 75710 | +SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ |
| 75711 | + if( pMem->flags & MEM_Null ) return SQLITE_OK; |
| 75654 | 75712 | switch( aff ){ |
| 75655 | 75713 | case SQLITE_AFF_BLOB: { /* Really a cast to BLOB */ |
| 75656 | 75714 | if( (pMem->flags & MEM_Blob)==0 ){ |
| 75657 | 75715 | sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding); |
| 75658 | 75716 | assert( pMem->flags & MEM_Str || pMem->db->mallocFailed ); |
| | @@ -75679,13 +75737,14 @@ |
| 75679 | 75737 | assert( MEM_Str==(MEM_Blob>>3) ); |
| 75680 | 75738 | pMem->flags |= (pMem->flags&MEM_Blob)>>3; |
| 75681 | 75739 | sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding); |
| 75682 | 75740 | assert( pMem->flags & MEM_Str || pMem->db->mallocFailed ); |
| 75683 | 75741 | pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero); |
| 75684 | | - break; |
| 75742 | + return sqlite3VdbeChangeEncoding(pMem, encoding); |
| 75685 | 75743 | } |
| 75686 | 75744 | } |
| 75745 | + return SQLITE_OK; |
| 75687 | 75746 | } |
| 75688 | 75747 | |
| 75689 | 75748 | /* |
| 75690 | 75749 | ** Initialize bulk memory to be a consistent Mem object. |
| 75691 | 75750 | ** |
| | @@ -77454,10 +77513,11 @@ |
| 77454 | 77513 | ** |
| 77455 | 77514 | ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort. |
| 77456 | 77515 | ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. |
| 77457 | 77516 | ** * OP_Destroy |
| 77458 | 77517 | ** * OP_VUpdate |
| 77518 | +** * OP_VCreate |
| 77459 | 77519 | ** * OP_VRename |
| 77460 | 77520 | ** * OP_FkCounter with P2==0 (immediate foreign key constraint) |
| 77461 | 77521 | ** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine |
| 77462 | 77522 | ** (for CREATE TABLE AS SELECT ...) |
| 77463 | 77523 | ** |
| | @@ -77481,10 +77541,11 @@ |
| 77481 | 77541 | |
| 77482 | 77542 | while( (pOp = opIterNext(&sIter))!=0 ){ |
| 77483 | 77543 | int opcode = pOp->opcode; |
| 77484 | 77544 | if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename |
| 77485 | 77545 | || opcode==OP_VDestroy |
| 77546 | + || opcode==OP_VCreate |
| 77486 | 77547 | || (opcode==OP_ParseSchema && pOp->p4.z==0) |
| 77487 | 77548 | || ((opcode==OP_Halt || opcode==OP_HaltIfNull) |
| 77488 | 77549 | && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort)) |
| 77489 | 77550 | ){ |
| 77490 | 77551 | hasAbort = 1; |
| | @@ -77970,10 +78031,33 @@ |
| 77970 | 78031 | return sqlite3VdbeChangeToNoop(p, p->nOp-1); |
| 77971 | 78032 | }else{ |
| 77972 | 78033 | return 0; |
| 77973 | 78034 | } |
| 77974 | 78035 | } |
| 78036 | + |
| 78037 | +#ifdef SQLITE_DEBUG |
| 78038 | +/* |
| 78039 | +** Generate an OP_ReleaseReg opcode to indicate that a range of |
| 78040 | +** registers, except any identified by mask, are no longer in use. |
| 78041 | +*/ |
| 78042 | +SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse *pParse, int iFirst, int N, u32 mask){ |
| 78043 | + assert( pParse->pVdbe ); |
| 78044 | + while( N>0 && (mask&1)!=0 ){ |
| 78045 | + mask >>= 1; |
| 78046 | + iFirst++; |
| 78047 | + N--; |
| 78048 | + } |
| 78049 | + while( N>0 && N<=32 && (mask & MASKBIT32(N-1))!=0 ){ |
| 78050 | + mask &= ~MASKBIT32(N-1); |
| 78051 | + N--; |
| 78052 | + } |
| 78053 | + if( N>0 ){ |
| 78054 | + sqlite3VdbeAddOp3(pParse->pVdbe, OP_ReleaseReg, iFirst, N, *(int*)&mask); |
| 78055 | + } |
| 78056 | +} |
| 78057 | +#endif /* SQLITE_DEBUG */ |
| 78058 | + |
| 77975 | 78059 | |
| 77976 | 78060 | /* |
| 77977 | 78061 | ** Change the value of the P4 operand for a specific instruction. |
| 77978 | 78062 | ** This routine is useful when a large program is loaded from a |
| 77979 | 78063 | ** static array using sqlite3VdbeAddOpList but we want to make a |
| | @@ -78088,11 +78172,12 @@ |
| 78088 | 78172 | ** makes the code easier to read during debugging. None of this happens |
| 78089 | 78173 | ** in a production build. |
| 78090 | 78174 | */ |
| 78091 | 78175 | static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){ |
| 78092 | 78176 | assert( p->nOp>0 || p->aOp==0 ); |
| 78093 | | - assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); |
| 78177 | + assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed |
| 78178 | + || p->pParse->nErr>0 ); |
| 78094 | 78179 | if( p->nOp ){ |
| 78095 | 78180 | assert( p->aOp ); |
| 78096 | 78181 | sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment); |
| 78097 | 78182 | p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap); |
| 78098 | 78183 | } |
| | @@ -86128,13 +86213,15 @@ |
| 86128 | 86213 | testcase( pOp->p2==SQLITE_AFF_INTEGER ); |
| 86129 | 86214 | testcase( pOp->p2==SQLITE_AFF_REAL ); |
| 86130 | 86215 | pIn1 = &aMem[pOp->p1]; |
| 86131 | 86216 | memAboutToChange(p, pIn1); |
| 86132 | 86217 | rc = ExpandBlob(pIn1); |
| 86133 | | - sqlite3VdbeMemCast(pIn1, pOp->p2, encoding); |
| 86218 | + if( rc ) goto abort_due_to_error; |
| 86219 | + rc = sqlite3VdbeMemCast(pIn1, pOp->p2, encoding); |
| 86220 | + if( rc ) goto abort_due_to_error; |
| 86134 | 86221 | UPDATE_MAX_BLOBSIZE(pIn1); |
| 86135 | | - if( rc ) goto abort_due_to_error; |
| 86222 | + REGISTER_TRACE(pOp->p1, pIn1); |
| 86136 | 86223 | break; |
| 86137 | 86224 | } |
| 86138 | 86225 | #endif /* SQLITE_OMIT_CAST */ |
| 86139 | 86226 | |
| 86140 | 86227 | /* Opcode: Eq P1 P2 P3 P4 P5 |
| | @@ -86289,16 +86376,11 @@ |
| 86289 | 86376 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 86290 | 86377 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 86291 | 86378 | if( (flags1 | flags3)&MEM_Str ){ |
| 86292 | 86379 | if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 86293 | 86380 | applyNumericAffinity(pIn1,0); |
| 86294 | | - assert( flags3==pIn3->flags ); |
| 86295 | | - /* testcase( flags3!=pIn3->flags ); |
| 86296 | | - ** this used to be possible with pIn1==pIn3, but not since |
| 86297 | | - ** the column cache was removed. The following assignment |
| 86298 | | - ** is essentially a no-op. But, it provides defense-in-depth |
| 86299 | | - ** in case our analysis is incorrect, so it is left in. */ |
| 86381 | + testcase( flags3!=pIn3->flags ); |
| 86300 | 86382 | flags3 = pIn3->flags; |
| 86301 | 86383 | } |
| 86302 | 86384 | if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 86303 | 86385 | applyNumericAffinity(pIn3,0); |
| 86304 | 86386 | } |
| | @@ -86317,11 +86399,11 @@ |
| 86317 | 86399 | testcase( pIn1->flags & MEM_Real ); |
| 86318 | 86400 | testcase( pIn1->flags & MEM_IntReal ); |
| 86319 | 86401 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 86320 | 86402 | testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); |
| 86321 | 86403 | flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); |
| 86322 | | - assert( pIn1!=pIn3 ); |
| 86404 | + if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str; |
| 86323 | 86405 | } |
| 86324 | 86406 | if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 86325 | 86407 | testcase( pIn3->flags & MEM_Int ); |
| 86326 | 86408 | testcase( pIn3->flags & MEM_Real ); |
| 86327 | 86409 | testcase( pIn3->flags & MEM_IntReal ); |
| | @@ -86352,14 +86434,14 @@ |
| 86352 | 86434 | static const unsigned char aGTb[] = { 1, 0, 1, 0, 0, 1 }; |
| 86353 | 86435 | res2 = aGTb[pOp->opcode - OP_Ne]; |
| 86354 | 86436 | } |
| 86355 | 86437 | |
| 86356 | 86438 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 86439 | + assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); |
| 86440 | + pIn3->flags = flags3; |
| 86357 | 86441 | assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); |
| 86358 | 86442 | pIn1->flags = flags1; |
| 86359 | | - assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); |
| 86360 | | - pIn3->flags = flags3; |
| 86361 | 86443 | |
| 86362 | 86444 | if( pOp->p5 & SQLITE_STOREP2 ){ |
| 86363 | 86445 | pOut = &aMem[pOp->p2]; |
| 86364 | 86446 | iCompare = res; |
| 86365 | 86447 | if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){ |
| | @@ -86391,20 +86473,35 @@ |
| 86391 | 86473 | break; |
| 86392 | 86474 | } |
| 86393 | 86475 | |
| 86394 | 86476 | /* Opcode: ElseNotEq * P2 * * * |
| 86395 | 86477 | ** |
| 86396 | | -** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator. |
| 86397 | | -** If result of an OP_Eq comparison on the same two operands |
| 86398 | | -** would have be NULL or false (0), then then jump to P2. |
| 86399 | | -** If the result of an OP_Eq comparison on the two previous operands |
| 86400 | | -** would have been true (1), then fall through. |
| 86478 | +** This opcode must follow an OP_Lt or OP_Gt comparison operator. There |
| 86479 | +** can be zero or more OP_ReleaseReg opcodes intervening, but no other |
| 86480 | +** opcodes are allowed to occur between this instruction and the previous |
| 86481 | +** OP_Lt or OP_Gt. Furthermore, the prior OP_Lt or OP_Gt must have the |
| 86482 | +** SQLITE_STOREP2 bit set in the P5 field. |
| 86483 | +** |
| 86484 | +** If result of an OP_Eq comparison on the same two operands as the |
| 86485 | +** prior OP_Lt or OP_Gt would have been NULL or false (0), then then |
| 86486 | +** jump to P2. If the result of an OP_Eq comparison on the two previous |
| 86487 | +** operands would have been true (1), then fall through. |
| 86401 | 86488 | */ |
| 86402 | 86489 | case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */ |
| 86403 | | - assert( pOp>aOp ); |
| 86404 | | - assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt ); |
| 86405 | | - assert( pOp[-1].p5 & SQLITE_STOREP2 ); |
| 86490 | + |
| 86491 | +#ifdef SQLITE_DEBUG |
| 86492 | + /* Verify the preconditions of this opcode - that it follows an OP_Lt or |
| 86493 | + ** OP_Gt with the SQLITE_STOREP2 flag set, with zero or more intervening |
| 86494 | + ** OP_ReleaseReg opcodes */ |
| 86495 | + int iAddr; |
| 86496 | + for(iAddr = (int)(pOp - aOp) - 1; ALWAYS(iAddr>=0); iAddr--){ |
| 86497 | + if( aOp[iAddr].opcode==OP_ReleaseReg ) continue; |
| 86498 | + assert( aOp[iAddr].opcode==OP_Lt || aOp[iAddr].opcode==OP_Gt ); |
| 86499 | + assert( aOp[iAddr].p5 & SQLITE_STOREP2 ); |
| 86500 | + break; |
| 86501 | + } |
| 86502 | +#endif /* SQLITE_DEBUG */ |
| 86406 | 86503 | VdbeBranchTaken(iCompare!=0, 2); |
| 86407 | 86504 | if( iCompare!=0 ) goto jump_to_p2; |
| 86408 | 86505 | break; |
| 86409 | 86506 | } |
| 86410 | 86507 | |
| | @@ -86811,11 +86908,13 @@ |
| 86811 | 86908 | const u8 *zEndHdr; /* Pointer to first byte after the header */ |
| 86812 | 86909 | u64 offset64; /* 64-bit offset */ |
| 86813 | 86910 | u32 t; /* A type code from the record header */ |
| 86814 | 86911 | Mem *pReg; /* PseudoTable input register */ |
| 86815 | 86912 | |
| 86913 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 86816 | 86914 | pC = p->apCsr[pOp->p1]; |
| 86915 | + assert( pC!=0 ); |
| 86817 | 86916 | p2 = pOp->p2; |
| 86818 | 86917 | |
| 86819 | 86918 | /* If the cursor cache is stale (meaning it is not currently point at |
| 86820 | 86919 | ** the correct row) then bring it up-to-date by doing the necessary |
| 86821 | 86920 | ** B-Tree seek. */ |
| | @@ -86823,11 +86922,10 @@ |
| 86823 | 86922 | if( rc ) goto abort_due_to_error; |
| 86824 | 86923 | |
| 86825 | 86924 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 86826 | 86925 | pDest = &aMem[pOp->p3]; |
| 86827 | 86926 | memAboutToChange(p, pDest); |
| 86828 | | - assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 86829 | 86927 | assert( pC!=0 ); |
| 86830 | 86928 | assert( p2<pC->nField ); |
| 86831 | 86929 | aOffset = pC->aOffset; |
| 86832 | 86930 | assert( pC->eCurType!=CURTYPE_VTAB ); |
| 86833 | 86931 | assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow ); |
| | @@ -87080,11 +87178,11 @@ |
| 87080 | 87178 | assert( pOp->p2>0 ); |
| 87081 | 87179 | assert( zAffinity[pOp->p2]==0 ); |
| 87082 | 87180 | pIn1 = &aMem[pOp->p1]; |
| 87083 | 87181 | while( 1 /*exit-by-break*/ ){ |
| 87084 | 87182 | assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] ); |
| 87085 | | - assert( memIsValid(pIn1) ); |
| 87183 | + assert( zAffinity[0]==SQLITE_AFF_NONE || memIsValid(pIn1) ); |
| 87086 | 87184 | applyAffinity(pIn1, zAffinity[0], encoding); |
| 87087 | 87185 | if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){ |
| 87088 | 87186 | /* When applying REAL affinity, if the result is still an MEM_Int |
| 87089 | 87187 | ** that will fit in 6 bytes, then change the type to MEM_IntReal |
| 87090 | 87188 | ** so that we keep the high-resolution integer value but know that |
| | @@ -87526,12 +87624,16 @@ |
| 87526 | 87624 | p->pc = (int)(pOp - aOp); |
| 87527 | 87625 | db->autoCommit = 0; |
| 87528 | 87626 | p->rc = rc = SQLITE_BUSY; |
| 87529 | 87627 | goto vdbe_return; |
| 87530 | 87628 | } |
| 87531 | | - db->isTransactionSavepoint = 0; |
| 87532 | 87629 | rc = p->rc; |
| 87630 | + if( rc ){ |
| 87631 | + db->autoCommit = 0; |
| 87632 | + }else{ |
| 87633 | + db->isTransactionSavepoint = 0; |
| 87634 | + } |
| 87533 | 87635 | }else{ |
| 87534 | 87636 | int isSchemaChange; |
| 87535 | 87637 | iSavepoint = db->nSavepoint - iSavepoint - 1; |
| 87536 | 87638 | if( p1==SAVEPOINT_ROLLBACK ){ |
| 87537 | 87639 | isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0; |
| | @@ -87555,10 +87657,11 @@ |
| 87555 | 87657 | sqlite3ExpirePreparedStatements(db, 0); |
| 87556 | 87658 | sqlite3ResetAllSchemasOfConnection(db); |
| 87557 | 87659 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 87558 | 87660 | } |
| 87559 | 87661 | } |
| 87662 | + if( rc ) goto abort_due_to_error; |
| 87560 | 87663 | |
| 87561 | 87664 | /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all |
| 87562 | 87665 | ** savepoints nested inside of the savepoint being operated on. */ |
| 87563 | 87666 | while( db->pSavepoint!=pSavepoint ){ |
| 87564 | 87667 | pTmp = db->pSavepoint; |
| | @@ -88050,10 +88153,11 @@ |
| 88050 | 88153 | case OP_OpenDup: { |
| 88051 | 88154 | VdbeCursor *pOrig; /* The original cursor to be duplicated */ |
| 88052 | 88155 | VdbeCursor *pCx; /* The new cursor */ |
| 88053 | 88156 | |
| 88054 | 88157 | pOrig = p->apCsr[pOp->p2]; |
| 88158 | + assert( pOrig ); |
| 88055 | 88159 | assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */ |
| 88056 | 88160 | |
| 88057 | 88161 | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); |
| 88058 | 88162 | if( pCx==0 ) goto no_mem; |
| 88059 | 88163 | pCx->nullRow = 1; |
| | @@ -91479,11 +91583,11 @@ |
| 91479 | 91583 | pVtab = pCur->uc.pVCur->pVtab; |
| 91480 | 91584 | pModule = pVtab->pModule; |
| 91481 | 91585 | assert( pModule->xColumn ); |
| 91482 | 91586 | memset(&sContext, 0, sizeof(sContext)); |
| 91483 | 91587 | sContext.pOut = pDest; |
| 91484 | | - testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 ); |
| 91588 | + assert( pOp->p5==OPFLAG_NOCHNG || pOp->p5==0 ); |
| 91485 | 91589 | if( pOp->p5 & OPFLAG_NOCHNG ){ |
| 91486 | 91590 | sqlite3VdbeMemSetNull(pDest); |
| 91487 | 91591 | pDest->flags = MEM_Null|MEM_Zero; |
| 91488 | 91592 | pDest->u.nZero = 0; |
| 91489 | 91593 | }else{ |
| | @@ -91939,10 +92043,57 @@ |
| 91939 | 92043 | case OP_Abortable: { |
| 91940 | 92044 | sqlite3VdbeAssertAbortable(p); |
| 91941 | 92045 | break; |
| 91942 | 92046 | } |
| 91943 | 92047 | #endif |
| 92048 | + |
| 92049 | +#ifdef SQLITE_DEBUG |
| 92050 | +/* Opcode: ReleaseReg P1 P2 P3 * * |
| 92051 | +** Synopsis: release r[P1@P2] mask P3 |
| 92052 | +** |
| 92053 | +** Release registers from service. Any content that was in the |
| 92054 | +** the registers is unreliable after this opcode completes. |
| 92055 | +** |
| 92056 | +** The registers released will be the P2 registers starting at P1, |
| 92057 | +** except if bit ii of P3 set, then do not release register P1+ii. |
| 92058 | +** In other words, P3 is a mask of registers to preserve. |
| 92059 | +** |
| 92060 | +** Releasing a register clears the Mem.pScopyFrom pointer. That means |
| 92061 | +** that if the content of the released register was set using OP_SCopy, |
| 92062 | +** a change to the value of the source register for the OP_SCopy will no longer |
| 92063 | +** generate an assertion fault in sqlite3VdbeMemAboutToChange(). |
| 92064 | +** |
| 92065 | +** TODO: Released registers ought to also have their datatype set to |
| 92066 | +** MEM_Undefined so that any subsequent attempt to read the released |
| 92067 | +** register (before it is reinitialized) will generate an assertion fault. |
| 92068 | +** However, there are places in the code generator which release registers |
| 92069 | +** before their are used, under the (valid) assumption that the registers |
| 92070 | +** will not be reallocated for some other purpose before they are used and |
| 92071 | +** hence are safe to release. |
| 92072 | +** |
| 92073 | +** This opcode is only available in testing and debugging builds. It is |
| 92074 | +** not generated for release builds. The purpose of this opcode is to help |
| 92075 | +** validate the generated bytecode. This opcode does not actually contribute |
| 92076 | +** to computing an answer. |
| 92077 | +*/ |
| 92078 | +case OP_ReleaseReg: { |
| 92079 | + Mem *pMem; |
| 92080 | + int i; |
| 92081 | + u32 constMask; |
| 92082 | + assert( pOp->p1>0 ); |
| 92083 | + assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); |
| 92084 | + pMem = &aMem[pOp->p1]; |
| 92085 | + constMask = pOp->p3; |
| 92086 | + for(i=0; i<pOp->p2; i++, pMem++){ |
| 92087 | + if( i>=32 || (constMask & MASKBIT32(i))==0 ){ |
| 92088 | + pMem->pScopyFrom = 0; |
| 92089 | + /* MemSetTypeFlag(pMem, MEM_Undefined); // See the TODO */ |
| 92090 | + } |
| 92091 | + } |
| 92092 | + break; |
| 92093 | +} |
| 92094 | +#endif |
| 91944 | 92095 | |
| 91945 | 92096 | /* Opcode: Noop * * * * * |
| 91946 | 92097 | ** |
| 91947 | 92098 | ** Do nothing. This instruction is often useful as a jump |
| 91948 | 92099 | ** destination. |
| | @@ -95849,12 +96000,12 @@ |
| 95849 | 96000 | testcase( ExprHasProperty(pExpr, EP_Reduced) ); |
| 95850 | 96001 | while(1){ |
| 95851 | 96002 | rc = pWalker->xExprCallback(pWalker, pExpr); |
| 95852 | 96003 | if( rc ) return rc & WRC_Abort; |
| 95853 | 96004 | if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ |
| 96005 | + assert( pExpr->x.pList==0 || pExpr->pRight==0 ); |
| 95854 | 96006 | if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; |
| 95855 | | - assert( pExpr->x.pList==0 || pExpr->pRight==0 ); |
| 95856 | 96007 | if( pExpr->pRight ){ |
| 95857 | 96008 | assert( !ExprHasProperty(pExpr, EP_WinFunc) ); |
| 95858 | 96009 | pExpr = pExpr->pRight; |
| 95859 | 96010 | continue; |
| 95860 | 96011 | }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| | @@ -96538,22 +96689,39 @@ |
| 96538 | 96689 | pTopNC->nErr++; |
| 96539 | 96690 | } |
| 96540 | 96691 | |
| 96541 | 96692 | /* If a column from a table in pSrcList is referenced, then record |
| 96542 | 96693 | ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes |
| 96543 | | - ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the |
| 96544 | | - ** column number is greater than the number of bits in the bitmask |
| 96545 | | - ** then set the high-order bit of the bitmask. |
| 96694 | + ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is |
| 96695 | + ** set if the 63rd or any subsequent column is used. |
| 96696 | + ** |
| 96697 | + ** The colUsed mask is an optimization used to help determine if an |
| 96698 | + ** index is a covering index. The correct answer is still obtained |
| 96699 | + ** if the mask contains extra set bits. However, it is important to |
| 96700 | + ** avoid setting bits beyond the maximum column number of the table. |
| 96701 | + ** (See ticket [b92e5e8ec2cdbaa1]). |
| 96702 | + ** |
| 96703 | + ** If a generated column is referenced, set bits for every column |
| 96704 | + ** of the table. |
| 96546 | 96705 | */ |
| 96547 | 96706 | if( pExpr->iColumn>=0 && pMatch!=0 ){ |
| 96548 | 96707 | int n = pExpr->iColumn; |
| 96549 | | - testcase( n==BMS-1 ); |
| 96550 | | - if( n>=BMS ){ |
| 96551 | | - n = BMS-1; |
| 96552 | | - } |
| 96708 | + Table *pExTab = pExpr->y.pTab; |
| 96709 | + assert( pExTab!=0 ); |
| 96553 | 96710 | assert( pMatch->iCursor==pExpr->iTable ); |
| 96554 | | - pMatch->colUsed |= ((Bitmask)1)<<n; |
| 96711 | + if( (pExTab->tabFlags & TF_HasGenerated)!=0 |
| 96712 | + && (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0 |
| 96713 | + ){ |
| 96714 | + testcase( pExTab->nCol==BMS-1 ); |
| 96715 | + testcase( pExTab->nCol==BMS ); |
| 96716 | + pMatch->colUsed = pExTab->nCol>=BMS ? ALLBITS : MASKBIT(pExTab->nCol)-1; |
| 96717 | + }else{ |
| 96718 | + testcase( n==BMS-1 ); |
| 96719 | + testcase( n==BMS ); |
| 96720 | + if( n>=BMS ) n = BMS-1; |
| 96721 | + pMatch->colUsed |= ((Bitmask)1)<<n; |
| 96722 | + } |
| 96555 | 96723 | } |
| 96556 | 96724 | |
| 96557 | 96725 | /* Clean up and return |
| 96558 | 96726 | */ |
| 96559 | 96727 | sqlite3ExprDelete(db, pExpr->pLeft); |
| | @@ -96588,47 +96756,68 @@ |
| 96588 | 96756 | */ |
| 96589 | 96757 | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){ |
| 96590 | 96758 | Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0); |
| 96591 | 96759 | if( p ){ |
| 96592 | 96760 | struct SrcList_item *pItem = &pSrc->a[iSrc]; |
| 96593 | | - p->y.pTab = pItem->pTab; |
| 96761 | + Table *pTab = p->y.pTab = pItem->pTab; |
| 96594 | 96762 | p->iTable = pItem->iCursor; |
| 96595 | 96763 | if( p->y.pTab->iPKey==iCol ){ |
| 96596 | 96764 | p->iColumn = -1; |
| 96597 | 96765 | }else{ |
| 96598 | 96766 | p->iColumn = (ynVar)iCol; |
| 96599 | | - testcase( iCol==BMS ); |
| 96600 | | - testcase( iCol==BMS-1 ); |
| 96601 | | - pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol); |
| 96767 | + if( (pTab->tabFlags & TF_HasGenerated)!=0 |
| 96768 | + && (pTab->aCol[iCol].colFlags & COLFLAG_GENERATED)!=0 |
| 96769 | + ){ |
| 96770 | + testcase( pTab->nCol==63 ); |
| 96771 | + testcase( pTab->nCol==64 ); |
| 96772 | + pItem->colUsed = pTab->nCol>=64 ? ALLBITS : MASKBIT(pTab->nCol)-1; |
| 96773 | + }else{ |
| 96774 | + testcase( iCol==BMS ); |
| 96775 | + testcase( iCol==BMS-1 ); |
| 96776 | + pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol); |
| 96777 | + } |
| 96602 | 96778 | } |
| 96603 | 96779 | } |
| 96604 | 96780 | return p; |
| 96605 | 96781 | } |
| 96606 | 96782 | |
| 96607 | 96783 | /* |
| 96608 | 96784 | ** Report an error that an expression is not valid for some set of |
| 96609 | 96785 | ** pNC->ncFlags values determined by validMask. |
| 96786 | +** |
| 96787 | +** static void notValid( |
| 96788 | +** Parse *pParse, // Leave error message here |
| 96789 | +** NameContext *pNC, // The name context |
| 96790 | +** const char *zMsg, // Type of error |
| 96791 | +** int validMask, // Set of contexts for which prohibited |
| 96792 | +** Expr *pExpr // Invalidate this expression on error |
| 96793 | +** ){...} |
| 96794 | +** |
| 96795 | +** As an optimization, since the conditional is almost always false |
| 96796 | +** (because errors are rare), the conditional is moved outside of the |
| 96797 | +** function call using a macro. |
| 96610 | 96798 | */ |
| 96611 | | -static void notValid( |
| 96612 | | - Parse *pParse, /* Leave error message here */ |
| 96613 | | - NameContext *pNC, /* The name context */ |
| 96614 | | - const char *zMsg, /* Type of error */ |
| 96615 | | - int validMask /* Set of contexts for which prohibited */ |
| 96799 | +static void notValidImpl( |
| 96800 | + Parse *pParse, /* Leave error message here */ |
| 96801 | + NameContext *pNC, /* The name context */ |
| 96802 | + const char *zMsg, /* Type of error */ |
| 96803 | + Expr *pExpr /* Invalidate this expression on error */ |
| 96616 | 96804 | ){ |
| 96617 | | - assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); |
| 96618 | | - if( (pNC->ncFlags & validMask)!=0 ){ |
| 96619 | | - const char *zIn = "partial index WHERE clauses"; |
| 96620 | | - if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions"; |
| 96805 | + const char *zIn = "partial index WHERE clauses"; |
| 96806 | + if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions"; |
| 96621 | 96807 | #ifndef SQLITE_OMIT_CHECK |
| 96622 | | - else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; |
| 96808 | + else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; |
| 96623 | 96809 | #endif |
| 96624 | 96810 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 96625 | | - else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns"; |
| 96811 | + else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns"; |
| 96626 | 96812 | #endif |
| 96627 | | - sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); |
| 96628 | | - } |
| 96813 | + sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); |
| 96814 | + if( pExpr ) pExpr->op = TK_NULL; |
| 96629 | 96815 | } |
| 96816 | +#define sqlite3ResolveNotValid(P,N,M,X,E) \ |
| 96817 | + assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \ |
| 96818 | + if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E); |
| 96630 | 96819 | |
| 96631 | 96820 | /* |
| 96632 | 96821 | ** Expression p should encode a floating point value between 1.0 and 0.0. |
| 96633 | 96822 | ** Return 1024 times this value. Or return -1 if p is not a floating point |
| 96634 | 96823 | ** value between 1.0 and 0.0. |
| | @@ -96713,11 +96902,14 @@ |
| 96713 | 96902 | zDb = 0; |
| 96714 | 96903 | zTable = 0; |
| 96715 | 96904 | zColumn = pExpr->u.zToken; |
| 96716 | 96905 | }else{ |
| 96717 | 96906 | Expr *pLeft = pExpr->pLeft; |
| 96718 | | - notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr|NC_GenCol); |
| 96907 | + testcase( pNC->ncFlags & NC_IdxExpr ); |
| 96908 | + testcase( pNC->ncFlags & NC_GenCol ); |
| 96909 | + sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator", |
| 96910 | + NC_IdxExpr|NC_GenCol, 0); |
| 96719 | 96911 | pRight = pExpr->pRight; |
| 96720 | 96912 | if( pRight->op==TK_ID ){ |
| 96721 | 96913 | zDb = 0; |
| 96722 | 96914 | }else{ |
| 96723 | 96915 | assert( pRight->op==TK_DOT ); |
| | @@ -96810,11 +97002,12 @@ |
| 96810 | 97002 | } |
| 96811 | 97003 | if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 96812 | 97004 | /* Date/time functions that use 'now', and other functions like |
| 96813 | 97005 | ** sqlite_version() that might change over time cannot be used |
| 96814 | 97006 | ** in an index. */ |
| 96815 | | - notValid(pParse, pNC, "non-deterministic functions", NC_SelfRef); |
| 97007 | + sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions", |
| 97008 | + NC_SelfRef, 0); |
| 96816 | 97009 | }else{ |
| 96817 | 97010 | assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */ |
| 96818 | 97011 | pExpr->op2 = pNC->ncFlags & NC_SelfRef; |
| 96819 | 97012 | } |
| 96820 | 97013 | if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0 |
| | @@ -96912,11 +97105,11 @@ |
| 96912 | 97105 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 96913 | 97106 | if( pWin ){ |
| 96914 | 97107 | Select *pSel = pNC->pWinSelect; |
| 96915 | 97108 | assert( pWin==pExpr->y.pWin ); |
| 96916 | 97109 | if( IN_RENAME_OBJECT==0 ){ |
| 96917 | | - sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef); |
| 97110 | + sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); |
| 96918 | 97111 | } |
| 96919 | 97112 | sqlite3WalkExprList(pWalker, pWin->pPartition); |
| 96920 | 97113 | sqlite3WalkExprList(pWalker, pWin->pOrderBy); |
| 96921 | 97114 | sqlite3WalkExpr(pWalker, pWin->pFilter); |
| 96922 | 97115 | sqlite3WindowLink(pSel, pWin); |
| | @@ -96957,12 +97150,16 @@ |
| 96957 | 97150 | #endif |
| 96958 | 97151 | case TK_IN: { |
| 96959 | 97152 | testcase( pExpr->op==TK_IN ); |
| 96960 | 97153 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 96961 | 97154 | int nRef = pNC->nRef; |
| 96962 | | - notValid(pParse, pNC, "subqueries", |
| 96963 | | - NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol); |
| 97155 | + testcase( pNC->ncFlags & NC_IsCheck ); |
| 97156 | + testcase( pNC->ncFlags & NC_PartIdx ); |
| 97157 | + testcase( pNC->ncFlags & NC_IdxExpr ); |
| 97158 | + testcase( pNC->ncFlags & NC_GenCol ); |
| 97159 | + sqlite3ResolveNotValid(pParse, pNC, "subqueries", |
| 97160 | + NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr); |
| 96964 | 97161 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 96965 | 97162 | assert( pNC->nRef>=nRef ); |
| 96966 | 97163 | if( nRef!=pNC->nRef ){ |
| 96967 | 97164 | ExprSetProperty(pExpr, EP_VarSelect); |
| 96968 | 97165 | pNC->ncFlags |= NC_VarSelect; |
| | @@ -96969,12 +97166,16 @@ |
| 96969 | 97166 | } |
| 96970 | 97167 | } |
| 96971 | 97168 | break; |
| 96972 | 97169 | } |
| 96973 | 97170 | case TK_VARIABLE: { |
| 96974 | | - notValid(pParse, pNC, "parameters", |
| 96975 | | - NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol); |
| 97171 | + testcase( pNC->ncFlags & NC_IsCheck ); |
| 97172 | + testcase( pNC->ncFlags & NC_PartIdx ); |
| 97173 | + testcase( pNC->ncFlags & NC_IdxExpr ); |
| 97174 | + testcase( pNC->ncFlags & NC_GenCol ); |
| 97175 | + sqlite3ResolveNotValid(pParse, pNC, "parameters", |
| 97176 | + NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr); |
| 96976 | 97177 | break; |
| 96977 | 97178 | } |
| 96978 | 97179 | case TK_IS: |
| 96979 | 97180 | case TK_ISNOT: { |
| 96980 | 97181 | Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight); |
| | @@ -98203,10 +98404,11 @@ |
| 98203 | 98404 | ){ |
| 98204 | 98405 | int p5; |
| 98205 | 98406 | int addr; |
| 98206 | 98407 | CollSeq *p4; |
| 98207 | 98408 | |
| 98409 | + if( pParse->nErr ) return 0; |
| 98208 | 98410 | if( isCommuted ){ |
| 98209 | 98411 | p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft); |
| 98210 | 98412 | }else{ |
| 98211 | 98413 | p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); |
| 98212 | 98414 | } |
| | @@ -98420,10 +98622,11 @@ |
| 98420 | 98622 | int regRight = 0; |
| 98421 | 98623 | u8 opx = op; |
| 98422 | 98624 | int addrDone = sqlite3VdbeMakeLabel(pParse); |
| 98423 | 98625 | int isCommuted = ExprHasProperty(pExpr,EP_Commuted); |
| 98424 | 98626 | |
| 98627 | + if( pParse->nErr ) return; |
| 98425 | 98628 | if( nLeft!=sqlite3ExprVectorSize(pRight) ){ |
| 98426 | 98629 | sqlite3ErrorMsg(pParse, "row value misused"); |
| 98427 | 98630 | return; |
| 98428 | 98631 | } |
| 98429 | 98632 | assert( pExpr->op==TK_EQ || pExpr->op==TK_NE |
| | @@ -99768,11 +99971,13 @@ |
| 99768 | 99971 | switch( pExpr->op ){ |
| 99769 | 99972 | /* Consider functions to be constant if all their arguments are constant |
| 99770 | 99973 | ** and either pWalker->eCode==4 or 5 or the function has the |
| 99771 | 99974 | ** SQLITE_FUNC_CONST flag. */ |
| 99772 | 99975 | case TK_FUNCTION: |
| 99773 | | - if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){ |
| 99976 | + if( (pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc)) |
| 99977 | + && !ExprHasProperty(pExpr, EP_WinFunc) |
| 99978 | + ){ |
| 99774 | 99979 | return WRC_Continue; |
| 99775 | 99980 | }else{ |
| 99776 | 99981 | pWalker->eCode = 0; |
| 99777 | 99982 | return WRC_Abort; |
| 99778 | 99983 | } |
| | @@ -100031,11 +100236,13 @@ |
| 100031 | 100236 | case TK_BLOB: |
| 100032 | 100237 | return 0; |
| 100033 | 100238 | case TK_COLUMN: |
| 100034 | 100239 | return ExprHasProperty(p, EP_CanBeNull) || |
| 100035 | 100240 | p->y.pTab==0 || /* Reference to column of index on expression */ |
| 100036 | | - (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0); |
| 100241 | + (p->iColumn>=0 |
| 100242 | + && ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */ |
| 100243 | + && p->y.pTab->aCol[p->iColumn].notNull==0); |
| 100037 | 100244 | default: |
| 100038 | 100245 | return 1; |
| 100039 | 100246 | } |
| 100040 | 100247 | } |
| 100041 | 100248 | |
| | @@ -100508,12 +100715,14 @@ |
| 100508 | 100715 | ** message of the form: |
| 100509 | 100716 | ** |
| 100510 | 100717 | ** "sub-select returns N columns - expected M" |
| 100511 | 100718 | */ |
| 100512 | 100719 | SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){ |
| 100513 | | - const char *zFmt = "sub-select returns %d columns - expected %d"; |
| 100514 | | - sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect); |
| 100720 | + if( pParse->nErr==0 ){ |
| 100721 | + const char *zFmt = "sub-select returns %d columns - expected %d"; |
| 100722 | + sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect); |
| 100723 | + } |
| 100515 | 100724 | } |
| 100516 | 100725 | #endif |
| 100517 | 100726 | |
| 100518 | 100727 | /* |
| 100519 | 100728 | ** Expression pExpr is a vector that has been used in a context where |
| | @@ -101011,19 +101220,25 @@ |
| 101011 | 101220 | } |
| 101012 | 101221 | if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){ |
| 101013 | 101222 | sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull); |
| 101014 | 101223 | } |
| 101015 | 101224 | if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){ |
| 101016 | | - sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2, |
| 101225 | + int op = rLhs!=r2 ? OP_Eq : OP_NotNull; |
| 101226 | + sqlite3VdbeAddOp4(v, op, rLhs, labelOk, r2, |
| 101017 | 101227 | (void*)pColl, P4_COLLSEQ); |
| 101018 | | - VdbeCoverageIf(v, ii<pList->nExpr-1); |
| 101019 | | - VdbeCoverageIf(v, ii==pList->nExpr-1); |
| 101228 | + VdbeCoverageIf(v, ii<pList->nExpr-1 && op==OP_Eq); |
| 101229 | + VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_Eq); |
| 101230 | + VdbeCoverageIf(v, ii<pList->nExpr-1 && op==OP_NotNull); |
| 101231 | + VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_NotNull); |
| 101020 | 101232 | sqlite3VdbeChangeP5(v, zAff[0]); |
| 101021 | 101233 | }else{ |
| 101234 | + int op = rLhs!=r2 ? OP_Ne : OP_IsNull; |
| 101022 | 101235 | assert( destIfNull==destIfFalse ); |
| 101023 | | - sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2, |
| 101024 | | - (void*)pColl, P4_COLLSEQ); VdbeCoverage(v); |
| 101236 | + sqlite3VdbeAddOp4(v, op, rLhs, destIfFalse, r2, |
| 101237 | + (void*)pColl, P4_COLLSEQ); |
| 101238 | + VdbeCoverageIf(v, op==OP_Ne); |
| 101239 | + VdbeCoverageIf(v, op==OP_IsNull); |
| 101025 | 101240 | sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL); |
| 101026 | 101241 | } |
| 101027 | 101242 | sqlite3ReleaseTempReg(pParse, regToFree); |
| 101028 | 101243 | } |
| 101029 | 101244 | if( regCkNull ){ |
| | @@ -101042,10 +101257,11 @@ |
| 101042 | 101257 | if( destIfNull==destIfFalse ){ |
| 101043 | 101258 | destStep2 = destIfFalse; |
| 101044 | 101259 | }else{ |
| 101045 | 101260 | destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse); |
| 101046 | 101261 | } |
| 101262 | + if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; |
| 101047 | 101263 | for(i=0; i<nVector; i++){ |
| 101048 | 101264 | Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i); |
| 101049 | 101265 | if( sqlite3ExprCanBeNull(p) ){ |
| 101050 | 101266 | sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2); |
| 101051 | 101267 | VdbeCoverage(v); |
| | @@ -101233,15 +101449,24 @@ |
| 101233 | 101449 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn( |
| 101234 | 101450 | Parse *pParse, |
| 101235 | 101451 | Column *pCol, |
| 101236 | 101452 | int regOut |
| 101237 | 101453 | ){ |
| 101454 | + int iAddr; |
| 101455 | + Vdbe *v = pParse->pVdbe; |
| 101456 | + assert( v!=0 ); |
| 101457 | + assert( pParse->iSelfTab!=0 ); |
| 101458 | + if( pParse->iSelfTab>0 ){ |
| 101459 | + iAddr = sqlite3VdbeAddOp3(v, OP_IfNullRow, pParse->iSelfTab-1, 0, regOut); |
| 101460 | + }else{ |
| 101461 | + iAddr = 0; |
| 101462 | + } |
| 101238 | 101463 | sqlite3ExprCode(pParse, pCol->pDflt, regOut); |
| 101239 | 101464 | if( pCol->affinity>=SQLITE_AFF_TEXT ){ |
| 101240 | | - sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0, |
| 101241 | | - &pCol->affinity, 1); |
| 101465 | + sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1); |
| 101242 | 101466 | } |
| 101467 | + if( iAddr ) sqlite3VdbeJumpHere(v, iAddr); |
| 101243 | 101468 | } |
| 101244 | 101469 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ |
| 101245 | 101470 | |
| 101246 | 101471 | /* |
| 101247 | 101472 | ** Generate code to extract the value of the iCol-th column of a table. |
| | @@ -101312,21 +101537,21 @@ |
| 101312 | 101537 | u8 p5 /* P5 value for OP_Column + FLAGS */ |
| 101313 | 101538 | ){ |
| 101314 | 101539 | assert( pParse->pVdbe!=0 ); |
| 101315 | 101540 | sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg); |
| 101316 | 101541 | if( p5 ){ |
| 101317 | | - sqlite3VdbeChangeP5(pParse->pVdbe, p5); |
| 101542 | + VdbeOp *pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1); |
| 101543 | + if( pOp->opcode==OP_Column ) pOp->p5 = p5; |
| 101318 | 101544 | } |
| 101319 | 101545 | return iReg; |
| 101320 | 101546 | } |
| 101321 | 101547 | |
| 101322 | 101548 | /* |
| 101323 | 101549 | ** Generate code to move content from registers iFrom...iFrom+nReg-1 |
| 101324 | 101550 | ** over to iTo..iTo+nReg-1. |
| 101325 | 101551 | */ |
| 101326 | 101552 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){ |
| 101327 | | - assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo ); |
| 101328 | 101553 | sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg); |
| 101329 | 101554 | } |
| 101330 | 101555 | |
| 101331 | 101556 | /* |
| 101332 | 101557 | ** Convert a scalar expression node to a TK_REGISTER referencing |
| | @@ -101424,19 +101649,25 @@ |
| 101424 | 101649 | } |
| 101425 | 101650 | /* Otherwise, fall thru into the TK_COLUMN case */ |
| 101426 | 101651 | } |
| 101427 | 101652 | case TK_COLUMN: { |
| 101428 | 101653 | int iTab = pExpr->iTable; |
| 101654 | + int iReg; |
| 101429 | 101655 | if( ExprHasProperty(pExpr, EP_FixedCol) ){ |
| 101430 | 101656 | /* This COLUMN expression is really a constant due to WHERE clause |
| 101431 | 101657 | ** constraints, and that constant is coded by the pExpr->pLeft |
| 101432 | 101658 | ** expresssion. However, make sure the constant has the correct |
| 101433 | 101659 | ** datatype by applying the Affinity of the table column to the |
| 101434 | 101660 | ** constant. |
| 101435 | 101661 | */ |
| 101436 | | - int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); |
| 101437 | | - int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); |
| 101662 | + int aff; |
| 101663 | + iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); |
| 101664 | + if( pExpr->y.pTab ){ |
| 101665 | + aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); |
| 101666 | + }else{ |
| 101667 | + aff = pExpr->affExpr; |
| 101668 | + } |
| 101438 | 101669 | if( aff>SQLITE_AFF_BLOB ){ |
| 101439 | 101670 | static const char zAff[] = "B\000C\000D\000E"; |
| 101440 | 101671 | assert( SQLITE_AFF_BLOB=='A' ); |
| 101441 | 101672 | assert( SQLITE_AFF_TEXT=='B' ); |
| 101442 | 101673 | if( iReg!=target ){ |
| | @@ -101460,11 +101691,11 @@ |
| 101460 | 101691 | Table *pTab = pExpr->y.pTab; |
| 101461 | 101692 | int iSrc; |
| 101462 | 101693 | int iCol = pExpr->iColumn; |
| 101463 | 101694 | assert( pTab!=0 ); |
| 101464 | 101695 | assert( iCol>=XN_ROWID ); |
| 101465 | | - assert( iCol<pExpr->y.pTab->nCol ); |
| 101696 | + assert( iCol<pTab->nCol ); |
| 101466 | 101697 | if( iCol<0 ){ |
| 101467 | 101698 | return -1-pParse->iSelfTab; |
| 101468 | 101699 | } |
| 101469 | 101700 | pCol = pTab->aCol + iCol; |
| 101470 | 101701 | testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) ); |
| | @@ -101495,13 +101726,17 @@ |
| 101495 | 101726 | /* Coding an expression that is part of an index where column names |
| 101496 | 101727 | ** in the index refer to the table to which the index belongs */ |
| 101497 | 101728 | iTab = pParse->iSelfTab - 1; |
| 101498 | 101729 | } |
| 101499 | 101730 | } |
| 101500 | | - return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 101731 | + iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 101501 | 101732 | pExpr->iColumn, iTab, target, |
| 101502 | 101733 | pExpr->op2); |
| 101734 | + if( pExpr->y.pTab==0 && pExpr->affExpr==SQLITE_AFF_REAL ){ |
| 101735 | + sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg); |
| 101736 | + } |
| 101737 | + return iReg; |
| 101503 | 101738 | } |
| 101504 | 101739 | case TK_INTEGER: { |
| 101505 | 101740 | codeInteger(pParse, pExpr, 0, target); |
| 101506 | 101741 | return target; |
| 101507 | 101742 | } |
| | @@ -101519,11 +101754,16 @@ |
| 101519 | 101754 | case TK_STRING: { |
| 101520 | 101755 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 101521 | 101756 | sqlite3VdbeLoadString(v, target, pExpr->u.zToken); |
| 101522 | 101757 | return target; |
| 101523 | 101758 | } |
| 101524 | | - case TK_NULL: { |
| 101759 | + default: { |
| 101760 | + /* Make NULL the default case so that if a bug causes an illegal |
| 101761 | + ** Expr node to be passed into this function, it will be handled |
| 101762 | + ** sanely and not crash. But keep the assert() to bring the problem |
| 101763 | + ** to the attention of the developers. */ |
| 101764 | + assert( op==TK_NULL ); |
| 101525 | 101765 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 101526 | 101766 | return target; |
| 101527 | 101767 | } |
| 101528 | 101768 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 101529 | 101769 | case TK_BLOB: { |
| | @@ -101546,11 +101786,11 @@ |
| 101546 | 101786 | assert( pExpr->u.zToken!=0 ); |
| 101547 | 101787 | assert( pExpr->u.zToken[0]!=0 ); |
| 101548 | 101788 | sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target); |
| 101549 | 101789 | if( pExpr->u.zToken[1]!=0 ){ |
| 101550 | 101790 | const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn); |
| 101551 | | - assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 ); |
| 101791 | + assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) ); |
| 101552 | 101792 | pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */ |
| 101553 | 101793 | sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC); |
| 101554 | 101794 | } |
| 101555 | 101795 | return target; |
| 101556 | 101796 | } |
| | @@ -101859,12 +102099,16 @@ |
| 101859 | 102099 | #endif |
| 101860 | 102100 | { |
| 101861 | 102101 | sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg, |
| 101862 | 102102 | pDef, pExpr->op2); |
| 101863 | 102103 | } |
| 101864 | | - if( nFarg && constMask==0 ){ |
| 101865 | | - sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 102104 | + if( nFarg ){ |
| 102105 | + if( constMask==0 ){ |
| 102106 | + sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 102107 | + }else{ |
| 102108 | + sqlite3VdbeReleaseRegisters(pParse, r1, nFarg, constMask); |
| 102109 | + } |
| 101866 | 102110 | } |
| 101867 | 102111 | return target; |
| 101868 | 102112 | } |
| 101869 | 102113 | #ifndef SQLITE_OMIT_SUBQUERY |
| 101870 | 102114 | case TK_EXISTS: |
| | @@ -101956,11 +102200,11 @@ |
| 101956 | 102200 | ** p1==2 -> old.b p1==5 -> new.b |
| 101957 | 102201 | */ |
| 101958 | 102202 | Table *pTab = pExpr->y.pTab; |
| 101959 | 102203 | int iCol = pExpr->iColumn; |
| 101960 | 102204 | int p1 = pExpr->iTable * (pTab->nCol+1) + 1 |
| 101961 | | - + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1); |
| 102205 | + + sqlite3TableColumnToStorage(pTab, iCol); |
| 101962 | 102206 | |
| 101963 | 102207 | assert( pExpr->iTable==0 || pExpr->iTable==1 ); |
| 101964 | 102208 | assert( iCol>=-1 && iCol<pTab->nCol ); |
| 101965 | 102209 | assert( pTab->iPKey<0 || iCol!=pTab->iPKey ); |
| 101966 | 102210 | assert( p1>=0 && p1<(pTab->nCol*2+2) ); |
| | @@ -102030,11 +102274,11 @@ |
| 102030 | 102274 | ** |
| 102031 | 102275 | ** The result of the expression is the Ri for the first matching Ei, |
| 102032 | 102276 | ** or if there is no matching Ei, the ELSE term Y, or if there is |
| 102033 | 102277 | ** no ELSE term, NULL. |
| 102034 | 102278 | */ |
| 102035 | | - default: assert( op==TK_CASE ); { |
| 102279 | + case TK_CASE: { |
| 102036 | 102280 | int endLabel; /* GOTO label for end of CASE stmt */ |
| 102037 | 102281 | int nextCase; /* GOTO label for next WHEN clause */ |
| 102038 | 102282 | int nExpr; /* 2x number of WHEN terms */ |
| 102039 | 102283 | int i; /* Loop counter */ |
| 102040 | 102284 | ExprList *pEList; /* List of WHEN terms */ |
| | @@ -103087,11 +103331,14 @@ |
| 103087 | 103331 | sqlite3WalkExpr(pWalker, pExpr->pRight); |
| 103088 | 103332 | } |
| 103089 | 103333 | return WRC_Prune; |
| 103090 | 103334 | |
| 103091 | 103335 | case TK_BETWEEN: |
| 103092 | | - sqlite3WalkExpr(pWalker, pExpr->pLeft); |
| 103336 | + if( sqlite3WalkExpr(pWalker, pExpr->pLeft)==WRC_Abort ){ |
| 103337 | + assert( pWalker->eCode ); |
| 103338 | + return WRC_Abort; |
| 103339 | + } |
| 103093 | 103340 | return WRC_Prune; |
| 103094 | 103341 | |
| 103095 | 103342 | /* Virtual tables are allowed to use constraints like x=NULL. So |
| 103096 | 103343 | ** a term of the form x=y does not prove that y is not null if x |
| 103097 | 103344 | ** is the column of a virtual table */ |
| | @@ -103501,12 +103748,15 @@ |
| 103501 | 103748 | /* |
| 103502 | 103749 | ** Deallocate a register, making available for reuse for some other |
| 103503 | 103750 | ** purpose. |
| 103504 | 103751 | */ |
| 103505 | 103752 | SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){ |
| 103506 | | - if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){ |
| 103507 | | - pParse->aTempReg[pParse->nTempReg++] = iReg; |
| 103753 | + if( iReg ){ |
| 103754 | + sqlite3VdbeReleaseRegisters(pParse, iReg, 1, 0); |
| 103755 | + if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){ |
| 103756 | + pParse->aTempReg[pParse->nTempReg++] = iReg; |
| 103757 | + } |
| 103508 | 103758 | } |
| 103509 | 103759 | } |
| 103510 | 103760 | |
| 103511 | 103761 | /* |
| 103512 | 103762 | ** Allocate or deallocate a block of nReg consecutive registers. |
| | @@ -103528,10 +103778,11 @@ |
| 103528 | 103778 | SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){ |
| 103529 | 103779 | if( nReg==1 ){ |
| 103530 | 103780 | sqlite3ReleaseTempReg(pParse, iReg); |
| 103531 | 103781 | return; |
| 103532 | 103782 | } |
| 103783 | + sqlite3VdbeReleaseRegisters(pParse, iReg, nReg, 0); |
| 103533 | 103784 | if( nReg>pParse->nRangeReg ){ |
| 103534 | 103785 | pParse->nRangeReg = nReg; |
| 103535 | 103786 | pParse->iRangeReg = iReg; |
| 103536 | 103787 | } |
| 103537 | 103788 | } |
| | @@ -104271,16 +104522,18 @@ |
| 104271 | 104522 | */ |
| 104272 | 104523 | SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){ |
| 104273 | 104524 | RenameToken *pNew; |
| 104274 | 104525 | assert( pPtr || pParse->db->mallocFailed ); |
| 104275 | 104526 | renameTokenCheckAll(pParse, pPtr); |
| 104276 | | - pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken)); |
| 104277 | | - if( pNew ){ |
| 104278 | | - pNew->p = pPtr; |
| 104279 | | - pNew->t = *pToken; |
| 104280 | | - pNew->pNext = pParse->pRename; |
| 104281 | | - pParse->pRename = pNew; |
| 104527 | + if( pParse->eParseMode!=PARSE_MODE_UNMAP ){ |
| 104528 | + pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken)); |
| 104529 | + if( pNew ){ |
| 104530 | + pNew->p = pPtr; |
| 104531 | + pNew->t = *pToken; |
| 104532 | + pNew->pNext = pParse->pRename; |
| 104533 | + pParse->pRename = pNew; |
| 104534 | + } |
| 104282 | 104535 | } |
| 104283 | 104536 | |
| 104284 | 104537 | return pPtr; |
| 104285 | 104538 | } |
| 104286 | 104539 | |
| | @@ -104306,17 +104559,39 @@ |
| 104306 | 104559 | static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ |
| 104307 | 104560 | Parse *pParse = pWalker->pParse; |
| 104308 | 104561 | sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr); |
| 104309 | 104562 | return WRC_Continue; |
| 104310 | 104563 | } |
| 104564 | + |
| 104565 | +/* |
| 104566 | +** Iterate through the Select objects that are part of WITH clauses attached |
| 104567 | +** to select statement pSelect. |
| 104568 | +*/ |
| 104569 | +static void renameWalkWith(Walker *pWalker, Select *pSelect){ |
| 104570 | + With *pWith = pSelect->pWith; |
| 104571 | + if( pWith ){ |
| 104572 | + int i; |
| 104573 | + for(i=0; i<pWith->nCte; i++){ |
| 104574 | + Select *p = pWith->a[i].pSelect; |
| 104575 | + NameContext sNC; |
| 104576 | + memset(&sNC, 0, sizeof(sNC)); |
| 104577 | + sNC.pParse = pWalker->pParse; |
| 104578 | + sqlite3SelectPrep(sNC.pParse, p, &sNC); |
| 104579 | + sqlite3WalkSelect(pWalker, p); |
| 104580 | + sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols); |
| 104581 | + } |
| 104582 | + } |
| 104583 | +} |
| 104311 | 104584 | |
| 104312 | 104585 | /* |
| 104313 | 104586 | ** Walker callback used by sqlite3RenameExprUnmap(). |
| 104314 | 104587 | */ |
| 104315 | 104588 | static int renameUnmapSelectCb(Walker *pWalker, Select *p){ |
| 104316 | 104589 | Parse *pParse = pWalker->pParse; |
| 104317 | 104590 | int i; |
| 104591 | + if( pParse->nErr ) return WRC_Abort; |
| 104592 | + if( NEVER(p->selFlags & SF_View) ) return WRC_Prune; |
| 104318 | 104593 | if( ALWAYS(p->pEList) ){ |
| 104319 | 104594 | ExprList *pList = p->pEList; |
| 104320 | 104595 | for(i=0; i<pList->nExpr; i++){ |
| 104321 | 104596 | if( pList->a[i].zName ){ |
| 104322 | 104597 | sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName); |
| | @@ -104325,25 +104600,31 @@ |
| 104325 | 104600 | } |
| 104326 | 104601 | if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */ |
| 104327 | 104602 | SrcList *pSrc = p->pSrc; |
| 104328 | 104603 | for(i=0; i<pSrc->nSrc; i++){ |
| 104329 | 104604 | sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); |
| 104605 | + if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort; |
| 104330 | 104606 | } |
| 104331 | 104607 | } |
| 104608 | + |
| 104609 | + renameWalkWith(pWalker, p); |
| 104332 | 104610 | return WRC_Continue; |
| 104333 | 104611 | } |
| 104334 | 104612 | |
| 104335 | 104613 | /* |
| 104336 | 104614 | ** Remove all nodes that are part of expression pExpr from the rename list. |
| 104337 | 104615 | */ |
| 104338 | 104616 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){ |
| 104617 | + u8 eMode = pParse->eParseMode; |
| 104339 | 104618 | Walker sWalker; |
| 104340 | 104619 | memset(&sWalker, 0, sizeof(Walker)); |
| 104341 | 104620 | sWalker.pParse = pParse; |
| 104342 | 104621 | sWalker.xExprCallback = renameUnmapExprCb; |
| 104343 | 104622 | sWalker.xSelectCallback = renameUnmapSelectCb; |
| 104623 | + pParse->eParseMode = PARSE_MODE_UNMAP; |
| 104344 | 104624 | sqlite3WalkExpr(&sWalker, pExpr); |
| 104625 | + pParse->eParseMode = eMode; |
| 104345 | 104626 | } |
| 104346 | 104627 | |
| 104347 | 104628 | /* |
| 104348 | 104629 | ** Remove all nodes that are part of expression-list pEList from the |
| 104349 | 104630 | ** rename list. |
| | @@ -104393,34 +104674,17 @@ |
| 104393 | 104674 | break; |
| 104394 | 104675 | } |
| 104395 | 104676 | } |
| 104396 | 104677 | } |
| 104397 | 104678 | |
| 104398 | | -/* |
| 104399 | | -** Iterate through the Select objects that are part of WITH clauses attached |
| 104400 | | -** to select statement pSelect. |
| 104401 | | -*/ |
| 104402 | | -static void renameWalkWith(Walker *pWalker, Select *pSelect){ |
| 104403 | | - if( pSelect->pWith ){ |
| 104404 | | - int i; |
| 104405 | | - for(i=0; i<pSelect->pWith->nCte; i++){ |
| 104406 | | - Select *p = pSelect->pWith->a[i].pSelect; |
| 104407 | | - NameContext sNC; |
| 104408 | | - memset(&sNC, 0, sizeof(sNC)); |
| 104409 | | - sNC.pParse = pWalker->pParse; |
| 104410 | | - sqlite3SelectPrep(sNC.pParse, p, &sNC); |
| 104411 | | - sqlite3WalkSelect(pWalker, p); |
| 104412 | | - } |
| 104413 | | - } |
| 104414 | | -} |
| 104415 | | - |
| 104416 | 104679 | /* |
| 104417 | 104680 | ** This is a Walker select callback. It does nothing. It is only required |
| 104418 | 104681 | ** because without a dummy callback, sqlite3WalkExpr() and similar do not |
| 104419 | 104682 | ** descend into sub-select statements. |
| 104420 | 104683 | */ |
| 104421 | 104684 | static int renameColumnSelectCb(Walker *pWalker, Select *p){ |
| 104685 | + if( p->selFlags & SF_View ) return WRC_Prune; |
| 104422 | 104686 | renameWalkWith(pWalker, p); |
| 104423 | 104687 | return WRC_Continue; |
| 104424 | 104688 | } |
| 104425 | 104689 | |
| 104426 | 104690 | /* |
| | @@ -104547,11 +104811,10 @@ |
| 104547 | 104811 | ** is initialized by this function before it is used. |
| 104548 | 104812 | */ |
| 104549 | 104813 | static int renameParseSql( |
| 104550 | 104814 | Parse *p, /* Memory to use for Parse object */ |
| 104551 | 104815 | const char *zDb, /* Name of schema SQL belongs to */ |
| 104552 | | - int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */ |
| 104553 | 104816 | sqlite3 *db, /* Database handle */ |
| 104554 | 104817 | const char *zSql, /* SQL to parse */ |
| 104555 | 104818 | int bTemp /* True if SQL is from temp schema */ |
| 104556 | 104819 | ){ |
| 104557 | 104820 | int rc; |
| | @@ -104561,11 +104824,11 @@ |
| 104561 | 104824 | |
| 104562 | 104825 | /* Parse the SQL statement passed as the first argument. If no error |
| 104563 | 104826 | ** occurs and the parse does not result in a new table, index or |
| 104564 | 104827 | ** trigger object, the database must be corrupt. */ |
| 104565 | 104828 | memset(p, 0, sizeof(Parse)); |
| 104566 | | - p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN); |
| 104829 | + p->eParseMode = PARSE_MODE_RENAME; |
| 104567 | 104830 | p->db = db; |
| 104568 | 104831 | p->nQueryLoop = 1; |
| 104569 | 104832 | rc = sqlite3RunParser(p, zSql, &zErr); |
| 104570 | 104833 | assert( p->zErrMsg==0 ); |
| 104571 | 104834 | assert( rc!=SQLITE_OK || zErr==0 ); |
| | @@ -104868,11 +105131,11 @@ |
| 104868 | 105131 | sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol); |
| 104869 | 105132 | |
| 104870 | 105133 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 104871 | 105134 | db->xAuth = 0; |
| 104872 | 105135 | #endif |
| 104873 | | - rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp); |
| 105136 | + rc = renameParseSql(&sParse, zDb, db, zSql, bTemp); |
| 104874 | 105137 | |
| 104875 | 105138 | /* Find tokens that need to be replaced. */ |
| 104876 | 105139 | memset(&sWalker, 0, sizeof(Walker)); |
| 104877 | 105140 | sWalker.pParse = &sParse; |
| 104878 | 105141 | sWalker.xExprCallback = renameColumnExprCb; |
| | @@ -104882,12 +105145,13 @@ |
| 104882 | 105145 | sCtx.pTab = pTab; |
| 104883 | 105146 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| 104884 | 105147 | if( sParse.pNewTable ){ |
| 104885 | 105148 | Select *pSelect = sParse.pNewTable->pSelect; |
| 104886 | 105149 | if( pSelect ){ |
| 105150 | + pSelect->selFlags &= ~SF_View; |
| 104887 | 105151 | sParse.rc = SQLITE_OK; |
| 104888 | | - sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); |
| 105152 | + sqlite3SelectPrep(&sParse, pSelect, 0); |
| 104889 | 105153 | rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); |
| 104890 | 105154 | if( rc==SQLITE_OK ){ |
| 104891 | 105155 | sqlite3WalkSelect(&sWalker, pSelect); |
| 104892 | 105156 | } |
| 104893 | 105157 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| | @@ -105000,10 +105264,11 @@ |
| 105000 | 105264 | */ |
| 105001 | 105265 | static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ |
| 105002 | 105266 | int i; |
| 105003 | 105267 | RenameCtx *p = pWalker->u.pRename; |
| 105004 | 105268 | SrcList *pSrc = pSelect->pSrc; |
| 105269 | + if( pSelect->selFlags & SF_View ) return WRC_Prune; |
| 105005 | 105270 | if( pSrc==0 ){ |
| 105006 | 105271 | assert( pWalker->pParse->db->mallocFailed ); |
| 105007 | 105272 | return WRC_Abort; |
| 105008 | 105273 | } |
| 105009 | 105274 | for(i=0; i<pSrc->nSrc; i++){ |
| | @@ -105070,26 +105335,32 @@ |
| 105070 | 105335 | sWalker.pParse = &sParse; |
| 105071 | 105336 | sWalker.xExprCallback = renameTableExprCb; |
| 105072 | 105337 | sWalker.xSelectCallback = renameTableSelectCb; |
| 105073 | 105338 | sWalker.u.pRename = &sCtx; |
| 105074 | 105339 | |
| 105075 | | - rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp); |
| 105340 | + rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); |
| 105076 | 105341 | |
| 105077 | 105342 | if( rc==SQLITE_OK ){ |
| 105078 | 105343 | int isLegacy = (db->flags & SQLITE_LegacyAlter); |
| 105079 | 105344 | if( sParse.pNewTable ){ |
| 105080 | 105345 | Table *pTab = sParse.pNewTable; |
| 105081 | 105346 | |
| 105082 | 105347 | if( pTab->pSelect ){ |
| 105083 | 105348 | if( isLegacy==0 ){ |
| 105349 | + Select *pSelect = pTab->pSelect; |
| 105084 | 105350 | NameContext sNC; |
| 105085 | 105351 | memset(&sNC, 0, sizeof(sNC)); |
| 105086 | 105352 | sNC.pParse = &sParse; |
| 105087 | 105353 | |
| 105354 | + assert( pSelect->selFlags & SF_View ); |
| 105355 | + pSelect->selFlags &= ~SF_View; |
| 105088 | 105356 | sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); |
| 105089 | | - if( sParse.nErr ) rc = sParse.rc; |
| 105090 | | - sqlite3WalkSelect(&sWalker, pTab->pSelect); |
| 105357 | + if( sParse.nErr ){ |
| 105358 | + rc = sParse.rc; |
| 105359 | + }else{ |
| 105360 | + sqlite3WalkSelect(&sWalker, pTab->pSelect); |
| 105361 | + } |
| 105091 | 105362 | } |
| 105092 | 105363 | }else{ |
| 105093 | 105364 | /* Modify any FK definitions to point to the new table. */ |
| 105094 | 105365 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 105095 | 105366 | if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){ |
| | @@ -105206,11 +105477,11 @@ |
| 105206 | 105477 | |
| 105207 | 105478 | UNUSED_PARAMETER(NotUsed); |
| 105208 | 105479 | if( zDb && zInput ){ |
| 105209 | 105480 | int rc; |
| 105210 | 105481 | Parse sParse; |
| 105211 | | - rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp); |
| 105482 | + rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); |
| 105212 | 105483 | if( rc==SQLITE_OK ){ |
| 105213 | 105484 | if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){ |
| 105214 | 105485 | NameContext sNC; |
| 105215 | 105486 | memset(&sNC, 0, sizeof(sNC)); |
| 105216 | 105487 | sNC.pParse = &sParse; |
| | @@ -108999,17 +109270,19 @@ |
| 108999 | 109270 | ** |
| 109000 | 109271 | ** So, in other words, this routine shifts all the virtual columns to |
| 109001 | 109272 | ** the end. |
| 109002 | 109273 | ** |
| 109003 | 109274 | ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and |
| 109004 | | -** this routine is a no-op macro. |
| 109275 | +** this routine is a no-op macro. If the pTab does not have any virtual |
| 109276 | +** columns, then this routine is no-op that always return iCol. If iCol |
| 109277 | +** is negative (indicating the ROWID column) then this routine return iCol. |
| 109005 | 109278 | */ |
| 109006 | 109279 | SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){ |
| 109007 | 109280 | int i; |
| 109008 | 109281 | i16 n; |
| 109009 | 109282 | assert( iCol<pTab->nCol ); |
| 109010 | | - if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol; |
| 109283 | + if( (pTab->tabFlags & TF_HasVirtual)==0 || iCol<0 ) return iCol; |
| 109011 | 109284 | for(i=0, n=0; i<iCol; i++){ |
| 109012 | 109285 | if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++; |
| 109013 | 109286 | } |
| 109014 | 109287 | if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){ |
| 109015 | 109288 | /* iCol is a virtual column itself */ |
| | @@ -109597,10 +109870,11 @@ |
| 109597 | 109870 | pTab->iPKey = iCol; |
| 109598 | 109871 | pTab->keyConf = (u8)onError; |
| 109599 | 109872 | assert( autoInc==0 || autoInc==1 ); |
| 109600 | 109873 | pTab->tabFlags |= autoInc*TF_Autoincrement; |
| 109601 | 109874 | if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags; |
| 109875 | + (void)sqlite3HasExplicitNulls(pParse, pList); |
| 109602 | 109876 | }else if( autoInc ){ |
| 109603 | 109877 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 109604 | 109878 | sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " |
| 109605 | 109879 | "INTEGER PRIMARY KEY"); |
| 109606 | 109880 | #endif |
| | @@ -109681,11 +109955,14 @@ |
| 109681 | 109955 | SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){ |
| 109682 | 109956 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 109683 | 109957 | u8 eType = COLFLAG_VIRTUAL; |
| 109684 | 109958 | Table *pTab = pParse->pNewTable; |
| 109685 | 109959 | Column *pCol; |
| 109686 | | - if( NEVER(pTab==0) ) goto generated_done; |
| 109960 | + if( pTab==0 ){ |
| 109961 | + /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */ |
| 109962 | + goto generated_done; |
| 109963 | + } |
| 109687 | 109964 | pCol = &(pTab->aCol[pTab->nCol-1]); |
| 109688 | 109965 | if( IN_DECLARE_VTAB ){ |
| 109689 | 109966 | sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns"); |
| 109690 | 109967 | goto generated_done; |
| 109691 | 109968 | } |
| | @@ -110289,10 +110566,16 @@ |
| 110289 | 110566 | #ifndef SQLITE_OMIT_CHECK |
| 110290 | 110567 | /* Resolve names in all CHECK constraint expressions. |
| 110291 | 110568 | */ |
| 110292 | 110569 | if( p->pCheck ){ |
| 110293 | 110570 | sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck); |
| 110571 | + if( pParse->nErr ){ |
| 110572 | + /* If errors are seen, delete the CHECK constraints now, else they might |
| 110573 | + ** actually be used if PRAGMA writable_schema=ON is set. */ |
| 110574 | + sqlite3ExprListDelete(db, p->pCheck); |
| 110575 | + p->pCheck = 0; |
| 110576 | + } |
| 110294 | 110577 | } |
| 110295 | 110578 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 110296 | 110579 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 110297 | 110580 | if( p->tabFlags & TF_HasGenerated ){ |
| 110298 | 110581 | int ii, nNG = 0; |
| | @@ -110299,14 +110582,23 @@ |
| 110299 | 110582 | testcase( p->tabFlags & TF_HasVirtual ); |
| 110300 | 110583 | testcase( p->tabFlags & TF_HasStored ); |
| 110301 | 110584 | for(ii=0; ii<p->nCol; ii++){ |
| 110302 | 110585 | u32 colFlags = p->aCol[ii].colFlags; |
| 110303 | 110586 | if( (colFlags & COLFLAG_GENERATED)!=0 ){ |
| 110587 | + Expr *pX = p->aCol[ii].pDflt; |
| 110304 | 110588 | testcase( colFlags & COLFLAG_VIRTUAL ); |
| 110305 | 110589 | testcase( colFlags & COLFLAG_STORED ); |
| 110306 | | - sqlite3ResolveSelfReference(pParse, p, NC_GenCol, |
| 110307 | | - p->aCol[ii].pDflt, 0); |
| 110590 | + if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){ |
| 110591 | + /* If there are errors in resolving the expression, change the |
| 110592 | + ** expression to a NULL. This prevents code generators that operate |
| 110593 | + ** on the expression from inserting extra parts into the expression |
| 110594 | + ** tree that have been allocated from lookaside memory, which is |
| 110595 | + ** illegal in a schema and will lead to errors heap corruption when |
| 110596 | + ** the database connection closes. */ |
| 110597 | + sqlite3ExprDelete(db, pX); |
| 110598 | + p->aCol[ii].pDflt = sqlite3ExprAlloc(db, TK_NULL, 0, 0); |
| 110599 | + } |
| 110308 | 110600 | }else{ |
| 110309 | 110601 | nNG++; |
| 110310 | 110602 | } |
| 110311 | 110603 | } |
| 110312 | 110604 | if( nNG==0 ){ |
| | @@ -110532,10 +110824,11 @@ |
| 110532 | 110824 | /* Make a copy of the entire SELECT statement that defines the view. |
| 110533 | 110825 | ** This will force all the Expr.token.z values to be dynamically |
| 110534 | 110826 | ** allocated rather than point to the input string - which means that |
| 110535 | 110827 | ** they will persist after the current sqlite3_exec() call returns. |
| 110536 | 110828 | */ |
| 110829 | + pSelect->selFlags |= SF_View; |
| 110537 | 110830 | if( IN_RENAME_OBJECT ){ |
| 110538 | 110831 | p->pSelect = pSelect; |
| 110539 | 110832 | pSelect = 0; |
| 110540 | 110833 | }else{ |
| 110541 | 110834 | p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); |
| | @@ -111958,30 +112251,13 @@ |
| 111958 | 112251 | } |
| 111959 | 112252 | |
| 111960 | 112253 | sqlite3VdbeJumpHere(v, pIndex->tnum); |
| 111961 | 112254 | } |
| 111962 | 112255 | } |
| 111963 | | - |
| 111964 | | - /* When adding an index to the list of indices for a table, make |
| 111965 | | - ** sure all indices labeled OE_Replace come after all those labeled |
| 111966 | | - ** OE_Ignore. This is necessary for the correct constraint check |
| 111967 | | - ** processing (in sqlite3GenerateConstraintChecks()) as part of |
| 111968 | | - ** UPDATE and INSERT statements. |
| 111969 | | - */ |
| 111970 | 112256 | if( db->init.busy || pTblName==0 ){ |
| 111971 | | - if( onError!=OE_Replace || pTab->pIndex==0 |
| 111972 | | - || pTab->pIndex->onError==OE_Replace){ |
| 111973 | | - pIndex->pNext = pTab->pIndex; |
| 111974 | | - pTab->pIndex = pIndex; |
| 111975 | | - }else{ |
| 111976 | | - Index *pOther = pTab->pIndex; |
| 111977 | | - while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){ |
| 111978 | | - pOther = pOther->pNext; |
| 111979 | | - } |
| 111980 | | - pIndex->pNext = pOther->pNext; |
| 111981 | | - pOther->pNext = pIndex; |
| 111982 | | - } |
| 112257 | + pIndex->pNext = pTab->pIndex; |
| 112258 | + pTab->pIndex = pIndex; |
| 111983 | 112259 | pIndex = 0; |
| 111984 | 112260 | } |
| 111985 | 112261 | else if( IN_RENAME_OBJECT ){ |
| 111986 | 112262 | assert( pParse->pNewIndex==0 ); |
| 111987 | 112263 | pParse->pNewIndex = pIndex; |
| | @@ -111989,10 +112265,25 @@ |
| 111989 | 112265 | } |
| 111990 | 112266 | |
| 111991 | 112267 | /* Clean up before exiting */ |
| 111992 | 112268 | exit_create_index: |
| 111993 | 112269 | if( pIndex ) sqlite3FreeIndex(db, pIndex); |
| 112270 | + if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */ |
| 112271 | + Index **ppFrom = &pTab->pIndex; |
| 112272 | + Index *pThis; |
| 112273 | + for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ |
| 112274 | + Index *pNext; |
| 112275 | + if( pThis->onError!=OE_Replace ) continue; |
| 112276 | + while( (pNext = pThis->pNext)!=0 && pNext->onError!=OE_Replace ){ |
| 112277 | + *ppFrom = pNext; |
| 112278 | + pThis->pNext = pNext->pNext; |
| 112279 | + pNext->pNext = pThis; |
| 112280 | + ppFrom = &pNext->pNext; |
| 112281 | + } |
| 112282 | + break; |
| 112283 | + } |
| 112284 | + } |
| 111994 | 112285 | sqlite3ExprDelete(db, pPIWhere); |
| 111995 | 112286 | sqlite3ExprListDelete(db, pList); |
| 111996 | 112287 | sqlite3SrcListDelete(db, pTblName); |
| 111997 | 112288 | sqlite3DbFree(db, zName); |
| 111998 | 112289 | } |
| | @@ -118231,14 +118522,15 @@ |
| 118231 | 118522 | } |
| 118232 | 118523 | return 0; |
| 118233 | 118524 | } |
| 118234 | 118525 | |
| 118235 | 118526 | /* This walker callback will compute the union of colFlags flags for all |
| 118236 | | -** references columns in a CHECK constraint or generated column expression. |
| 118527 | +** referenced columns in a CHECK constraint or generated column expression. |
| 118237 | 118528 | */ |
| 118238 | 118529 | static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){ |
| 118239 | | - if( pExpr->op==TK_COLUMN ){ |
| 118530 | + if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 ){ |
| 118531 | + assert( pExpr->iColumn < pWalker->u.pTab->nCol ); |
| 118240 | 118532 | pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags; |
| 118241 | 118533 | } |
| 118242 | 118534 | return WRC_Continue; |
| 118243 | 118535 | } |
| 118244 | 118536 | |
| | @@ -118257,10 +118549,40 @@ |
| 118257 | 118549 | ){ |
| 118258 | 118550 | int i; |
| 118259 | 118551 | Walker w; |
| 118260 | 118552 | Column *pRedo; |
| 118261 | 118553 | int eProgress; |
| 118554 | + VdbeOp *pOp; |
| 118555 | + |
| 118556 | + assert( pTab->tabFlags & TF_HasGenerated ); |
| 118557 | + testcase( pTab->tabFlags & TF_HasVirtual ); |
| 118558 | + testcase( pTab->tabFlags & TF_HasStored ); |
| 118559 | + |
| 118560 | + /* Before computing generated columns, first go through and make sure |
| 118561 | + ** that appropriate affinity has been applied to the regular columns |
| 118562 | + */ |
| 118563 | + sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore); |
| 118564 | + if( (pTab->tabFlags & TF_HasStored)!=0 |
| 118565 | + && (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity |
| 118566 | + ){ |
| 118567 | + /* Change the OP_Affinity argument to '@' (NONE) for all stored |
| 118568 | + ** columns. '@' is the no-op affinity and those columns have not |
| 118569 | + ** yet been computed. */ |
| 118570 | + int ii, jj; |
| 118571 | + char *zP4 = pOp->p4.z; |
| 118572 | + assert( zP4!=0 ); |
| 118573 | + assert( pOp->p4type==P4_DYNAMIC ); |
| 118574 | + for(ii=jj=0; zP4[jj]; ii++){ |
| 118575 | + if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){ |
| 118576 | + continue; |
| 118577 | + } |
| 118578 | + if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){ |
| 118579 | + zP4[jj] = SQLITE_AFF_NONE; |
| 118580 | + } |
| 118581 | + jj++; |
| 118582 | + } |
| 118583 | + } |
| 118262 | 118584 | |
| 118263 | 118585 | /* Because there can be multiple generated columns that refer to one another, |
| 118264 | 118586 | ** this is a two-pass algorithm. On the first pass, mark all generated |
| 118265 | 118587 | ** columns as "not available". |
| 118266 | 118588 | */ |
| | @@ -118977,10 +119299,14 @@ |
| 118977 | 119299 | if( IsVirtual(pTab) ){ |
| 118978 | 119300 | sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"", |
| 118979 | 119301 | pTab->zName); |
| 118980 | 119302 | goto insert_cleanup; |
| 118981 | 119303 | } |
| 119304 | + if( pTab->pSelect ){ |
| 119305 | + sqlite3ErrorMsg(pParse, "cannot UPSERT a view"); |
| 119306 | + goto insert_cleanup; |
| 119307 | + } |
| 118982 | 119308 | if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){ |
| 118983 | 119309 | goto insert_cleanup; |
| 118984 | 119310 | } |
| 118985 | 119311 | pTabList->a[0].iCursor = iDataCur; |
| 118986 | 119312 | pUpsert->pUpsertSrc = pTabList; |
| | @@ -119211,14 +119537,12 @@ |
| 119211 | 119537 | |
| 119212 | 119538 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 119213 | 119539 | /* Compute the new value for generated columns after all other |
| 119214 | 119540 | ** columns have already been computed. This must be done after |
| 119215 | 119541 | ** computing the ROWID in case one of the generated columns |
| 119216 | | - ** refers to the ROWID. */ |
| 119542 | + ** is derived from the INTEGER PRIMARY KEY. */ |
| 119217 | 119543 | if( pTab->tabFlags & TF_HasGenerated ){ |
| 119218 | | - testcase( pTab->tabFlags & TF_HasVirtual ); |
| 119219 | | - testcase( pTab->tabFlags & TF_HasStored ); |
| 119220 | 119544 | sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab); |
| 119221 | 119545 | } |
| 119222 | 119546 | #endif |
| 119223 | 119547 | |
| 119224 | 119548 | /* Generate code to check constraints and generate index keys and |
| | @@ -120246,10 +120570,14 @@ |
| 120246 | 120570 | |
| 120247 | 120571 | v = sqlite3GetVdbe(pParse); |
| 120248 | 120572 | assert( v!=0 ); |
| 120249 | 120573 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 120250 | 120574 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 120575 | + /* All REPLACE indexes are at the end of the list */ |
| 120576 | + assert( pIdx->onError!=OE_Replace |
| 120577 | + || pIdx->pNext==0 |
| 120578 | + || pIdx->pNext->onError==OE_Replace ); |
| 120251 | 120579 | if( aRegIdx[i]==0 ) continue; |
| 120252 | 120580 | if( pIdx->pPartIdxWhere ){ |
| 120253 | 120581 | sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); |
| 120254 | 120582 | VdbeCoverage(v); |
| 120255 | 120583 | } |
| | @@ -124713,11 +125041,13 @@ |
| 124713 | 125041 | char *zErr; |
| 124714 | 125042 | int jmp2; |
| 124715 | 125043 | if( j==pTab->iPKey ) continue; |
| 124716 | 125044 | if( pTab->aCol[j].notNull==0 ) continue; |
| 124717 | 125045 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); |
| 124718 | | - sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 125046 | + if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ |
| 125047 | + sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 125048 | + } |
| 124719 | 125049 | jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); |
| 124720 | 125050 | zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, |
| 124721 | 125051 | pTab->aCol[j].zName); |
| 124722 | 125052 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 124723 | 125053 | integrityCheckResultRow(v); |
| | @@ -126679,11 +127009,14 @@ |
| 126679 | 127009 | }; |
| 126680 | 127010 | #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ |
| 126681 | 127011 | |
| 126682 | 127012 | /* |
| 126683 | 127013 | ** Delete all the content of a Select structure. Deallocate the structure |
| 126684 | | -** itself only if bFree is true. |
| 127014 | +** itself depending on the value of bFree |
| 127015 | +** |
| 127016 | +** If bFree==1, call sqlite3DbFree() on the p object. |
| 127017 | +** If bFree==0, Leave the first Select object unfreed |
| 126685 | 127018 | */ |
| 126686 | 127019 | static void clearSelect(sqlite3 *db, Select *p, int bFree){ |
| 126687 | 127020 | while( p ){ |
| 126688 | 127021 | Select *pPrior = p->pPrior; |
| 126689 | 127022 | sqlite3ExprListDelete(db, p->pEList); |
| | @@ -126782,10 +127115,24 @@ |
| 126782 | 127115 | ** Delete the given Select structure and all of its substructures. |
| 126783 | 127116 | */ |
| 126784 | 127117 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){ |
| 126785 | 127118 | if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1); |
| 126786 | 127119 | } |
| 127120 | + |
| 127121 | +/* |
| 127122 | +** Delete all the substructure for p, but keep p allocated. Redefine |
| 127123 | +** p to be a single SELECT where every column of the result set has a |
| 127124 | +** value of NULL. |
| 127125 | +*/ |
| 127126 | +SQLITE_PRIVATE void sqlite3SelectReset(Parse *pParse, Select *p){ |
| 127127 | + if( ALWAYS(p) ){ |
| 127128 | + clearSelect(pParse->db, p, 0); |
| 127129 | + memset(&p->iLimit, 0, sizeof(Select) - offsetof(Select,iLimit)); |
| 127130 | + p->pEList = sqlite3ExprListAppend(pParse, 0, |
| 127131 | + sqlite3ExprAlloc(pParse->db,TK_NULL,0,0)); |
| 127132 | + } |
| 127133 | +} |
| 126787 | 127134 | |
| 126788 | 127135 | /* |
| 126789 | 127136 | ** Return a pointer to the right-most SELECT statement in a compound. |
| 126790 | 127137 | */ |
| 126791 | 127138 | static Select *findRightmost(Select *p){ |
| | @@ -129069,10 +129416,11 @@ |
| 129069 | 129416 | assert( p->selFlags & SF_MultiValue ); |
| 129070 | 129417 | do{ |
| 129071 | 129418 | assert( p->selFlags & SF_Values ); |
| 129072 | 129419 | assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) ); |
| 129073 | 129420 | assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr ); |
| 129421 | + if( p->pWin ) return -1; |
| 129074 | 129422 | if( p->pPrior==0 ) break; |
| 129075 | 129423 | assert( p->pPrior->pNext==p ); |
| 129076 | 129424 | p = p->pPrior; |
| 129077 | 129425 | nRow += bShowAll; |
| 129078 | 129426 | }while(1); |
| | @@ -129159,11 +129507,12 @@ |
| 129159 | 129507 | |
| 129160 | 129508 | /* Special handling for a compound-select that originates as a VALUES clause. |
| 129161 | 129509 | */ |
| 129162 | 129510 | if( p->selFlags & SF_MultiValue ){ |
| 129163 | 129511 | rc = multiSelectValues(pParse, p, &dest); |
| 129164 | | - goto multi_select_end; |
| 129512 | + if( rc>=0 ) goto multi_select_end; |
| 129513 | + rc = SQLITE_OK; |
| 129165 | 129514 | } |
| 129166 | 129515 | |
| 129167 | 129516 | /* Make sure all SELECTs in the statement have the same number of elements |
| 129168 | 129517 | ** in their result sets. |
| 129169 | 129518 | */ |
| | @@ -129304,13 +129653,13 @@ |
| 129304 | 129653 | |
| 129305 | 129654 | /* Convert the data in the temporary table into whatever form |
| 129306 | 129655 | ** it is that we currently need. |
| 129307 | 129656 | */ |
| 129308 | 129657 | assert( unionTab==dest.iSDParm || dest.eDest!=priorOp ); |
| 129309 | | - if( dest.eDest!=priorOp ){ |
| 129658 | + assert( p->pEList || db->mallocFailed ); |
| 129659 | + if( dest.eDest!=priorOp && db->mallocFailed==0 ){ |
| 129310 | 129660 | int iCont, iBreak, iStart; |
| 129311 | | - assert( p->pEList ); |
| 129312 | 129661 | iBreak = sqlite3VdbeMakeLabel(pParse); |
| 129313 | 129662 | iCont = sqlite3VdbeMakeLabel(pParse); |
| 129314 | 129663 | computeLimitRegisters(pParse, p, iBreak); |
| 129315 | 129664 | sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v); |
| 129316 | 129665 | iStart = sqlite3VdbeCurrentAddr(v); |
| | @@ -129402,10 +129751,11 @@ |
| 129402 | 129751 | if( p->pNext==0 ){ |
| 129403 | 129752 | ExplainQueryPlanPop(pParse); |
| 129404 | 129753 | } |
| 129405 | 129754 | #endif |
| 129406 | 129755 | } |
| 129756 | + if( pParse->nErr ) goto multi_select_end; |
| 129407 | 129757 | |
| 129408 | 129758 | /* Compute collating sequences used by |
| 129409 | 129759 | ** temporary tables needed to implement the compound select. |
| 129410 | 129760 | ** Attach the KeyInfo structure to all temporary tables. |
| 129411 | 129761 | ** |
| | @@ -130193,10 +130543,11 @@ |
| 130193 | 130543 | ** (3) If the subquery is the right operand of a LEFT JOIN then |
| 130194 | 130544 | ** (3a) the subquery may not be a join and |
| 130195 | 130545 | ** (3b) the FROM clause of the subquery may not contain a virtual |
| 130196 | 130546 | ** table and |
| 130197 | 130547 | ** (3c) the outer query may not be an aggregate. |
| 130548 | +** (3d) the outer query may not be DISTINCT. |
| 130198 | 130549 | ** |
| 130199 | 130550 | ** (4) The subquery can not be DISTINCT. |
| 130200 | 130551 | ** |
| 130201 | 130552 | ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT |
| 130202 | 130553 | ** sub-queries that were excluded from this optimization. Restriction |
| | @@ -130389,12 +130740,15 @@ |
| 130389 | 130740 | ** |
| 130390 | 130741 | ** See also tickets #306, #350, and #3300. |
| 130391 | 130742 | */ |
| 130392 | 130743 | if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 130393 | 130744 | isLeftJoin = 1; |
| 130394 | | - if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){ |
| 130395 | | - /* (3a) (3c) (3b) */ |
| 130745 | + if( pSubSrc->nSrc>1 /* (3a) */ |
| 130746 | + || isAgg /* (3b) */ |
| 130747 | + || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */ |
| 130748 | + || (p->selFlags & SF_Distinct)!=0 /* (3d) */ |
| 130749 | + ){ |
| 130396 | 130750 | return 0; |
| 130397 | 130751 | } |
| 130398 | 130752 | } |
| 130399 | 130753 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 130400 | 130754 | else if( iFrom>0 && !isAgg ){ |
| | @@ -131164,10 +131518,13 @@ |
| 131164 | 131518 | pNew->pHaving = 0; |
| 131165 | 131519 | pNew->pOrderBy = 0; |
| 131166 | 131520 | p->pPrior = 0; |
| 131167 | 131521 | p->pNext = 0; |
| 131168 | 131522 | p->pWith = 0; |
| 131523 | +#ifndef SQLITE_OMIT_WINDOWFUNC |
| 131524 | + p->pWinDefn = 0; |
| 131525 | +#endif |
| 131169 | 131526 | p->selFlags &= ~SF_Compound; |
| 131170 | 131527 | assert( (p->selFlags & SF_Converted)==0 ); |
| 131171 | 131528 | p->selFlags |= SF_Converted; |
| 131172 | 131529 | assert( pNew->pPrior!=0 ); |
| 131173 | 131530 | pNew->pPrior->pNext = pNew; |
| | @@ -132323,11 +132680,13 @@ |
| 132323 | 132680 | if( pDest->eDest==SRT_Output ){ |
| 132324 | 132681 | generateColumnNames(pParse, p); |
| 132325 | 132682 | } |
| 132326 | 132683 | |
| 132327 | 132684 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 132328 | | - if( sqlite3WindowRewrite(pParse, p) ){ |
| 132685 | + rc = sqlite3WindowRewrite(pParse, p); |
| 132686 | + if( rc ){ |
| 132687 | + assert( db->mallocFailed || pParse->nErr>0 ); |
| 132329 | 132688 | goto select_end; |
| 132330 | 132689 | } |
| 132331 | 132690 | #if SELECTTRACE_ENABLED |
| 132332 | 132691 | if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ |
| 132333 | 132692 | SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); |
| | @@ -132659,10 +133018,11 @@ |
| 132659 | 133018 | ** written the query must use a temp-table for at least one of the ORDER |
| 132660 | 133019 | ** BY and DISTINCT, and an index or separate temp-table for the other. |
| 132661 | 133020 | */ |
| 132662 | 133021 | if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct |
| 132663 | 133022 | && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 |
| 133023 | + && p->pWin==0 |
| 132664 | 133024 | ){ |
| 132665 | 133025 | p->selFlags &= ~SF_Distinct; |
| 132666 | 133026 | pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); |
| 132667 | 133027 | /* Notice that even thought SF_Distinct has been cleared from p->selFlags, |
| 132668 | 133028 | ** the sDistinct.isTnct is still set. Hence, isTnct represents the |
| | @@ -134182,12 +134542,16 @@ |
| 134182 | 134542 | if( ALWAYS(pTrigger) ){ |
| 134183 | 134543 | if( pTrigger->pSchema==pTrigger->pTabSchema ){ |
| 134184 | 134544 | Table *pTab = tableOfTrigger(pTrigger); |
| 134185 | 134545 | if( pTab ){ |
| 134186 | 134546 | Trigger **pp; |
| 134187 | | - for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext)); |
| 134188 | | - *pp = (*pp)->pNext; |
| 134547 | + for(pp=&pTab->pTrigger; *pp; pp=&((*pp)->pNext)){ |
| 134548 | + if( *pp==pTrigger ){ |
| 134549 | + *pp = (*pp)->pNext; |
| 134550 | + break; |
| 134551 | + } |
| 134552 | + } |
| 134189 | 134553 | } |
| 134190 | 134554 | } |
| 134191 | 134555 | sqlite3DeleteTrigger(db, pTrigger); |
| 134192 | 134556 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 134193 | 134557 | } |
| | @@ -136913,10 +137277,12 @@ |
| 136913 | 137277 | char *zStmt; |
| 136914 | 137278 | char *zWhere; |
| 136915 | 137279 | int iDb; |
| 136916 | 137280 | int iReg; |
| 136917 | 137281 | Vdbe *v; |
| 137282 | + |
| 137283 | + sqlite3MayAbort(pParse); |
| 136918 | 137284 | |
| 136919 | 137285 | /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ |
| 136920 | 137286 | if( pEnd ){ |
| 136921 | 137287 | pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n; |
| 136922 | 137288 | } |
| | @@ -136939,17 +137305,17 @@ |
| 136939 | 137305 | pTab->zName, |
| 136940 | 137306 | pTab->zName, |
| 136941 | 137307 | zStmt, |
| 136942 | 137308 | pParse->regRowid |
| 136943 | 137309 | ); |
| 136944 | | - sqlite3DbFree(db, zStmt); |
| 136945 | 137310 | v = sqlite3GetVdbe(pParse); |
| 136946 | 137311 | sqlite3ChangeCookie(pParse, iDb); |
| 136947 | 137312 | |
| 136948 | 137313 | sqlite3VdbeAddOp0(v, OP_Expire); |
| 136949 | | - zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); |
| 137314 | + zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt); |
| 136950 | 137315 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); |
| 137316 | + sqlite3DbFree(db, zStmt); |
| 136951 | 137317 | |
| 136952 | 137318 | iReg = ++pParse->nMem; |
| 136953 | 137319 | sqlite3VdbeLoadString(v, iReg, pTab->zName); |
| 136954 | 137320 | sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg); |
| 136955 | 137321 | } |
| | @@ -137347,11 +137713,12 @@ |
| 137347 | 137713 | return SQLITE_LOCKED; |
| 137348 | 137714 | } |
| 137349 | 137715 | } |
| 137350 | 137716 | p = vtabDisconnectAll(db, pTab); |
| 137351 | 137717 | xDestroy = p->pMod->pModule->xDestroy; |
| 137352 | | - assert( xDestroy!=0 ); /* Checked before the virtual table is created */ |
| 137718 | + if( xDestroy==0 ) xDestroy = p->pMod->pModule->xDisconnect; |
| 137719 | + assert( xDestroy!=0 ); |
| 137353 | 137720 | pTab->nTabRef++; |
| 137354 | 137721 | rc = xDestroy(p->pVtab); |
| 137355 | 137722 | /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ |
| 137356 | 137723 | if( rc==SQLITE_OK ){ |
| 137357 | 137724 | assert( pTab->pVTable==p && p->pNext==0 ); |
| | @@ -138776,11 +139143,12 @@ |
| 138776 | 139143 | int iEq, /* Look at loop terms starting here */ |
| 138777 | 139144 | WhereLoop *pLoop, /* The current loop */ |
| 138778 | 139145 | Expr *pX /* The IN expression to be reduced */ |
| 138779 | 139146 | ){ |
| 138780 | 139147 | sqlite3 *db = pParse->db; |
| 138781 | | - Expr *pNew = sqlite3ExprDup(db, pX, 0); |
| 139148 | + Expr *pNew; |
| 139149 | + pNew = sqlite3ExprDup(db, pX, 0); |
| 138782 | 139150 | if( db->mallocFailed==0 ){ |
| 138783 | 139151 | ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */ |
| 138784 | 139152 | ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */ |
| 138785 | 139153 | ExprList *pRhs = 0; /* New RHS after modifications */ |
| 138786 | 139154 | ExprList *pLhs = 0; /* New LHS after mods */ |
| | @@ -139488,10 +139856,13 @@ |
| 139488 | 139856 | pExpr->affExpr = sqlite3ExprAffinity(pExpr); |
| 139489 | 139857 | pExpr->op = TK_COLUMN; |
| 139490 | 139858 | pExpr->iTable = pX->iIdxCur; |
| 139491 | 139859 | pExpr->iColumn = pX->iIdxCol; |
| 139492 | 139860 | pExpr->y.pTab = 0; |
| 139861 | + testcase( ExprHasProperty(pExpr, EP_Skip) ); |
| 139862 | + testcase( ExprHasProperty(pExpr, EP_Unlikely) ); |
| 139863 | + ExprClearProperty(pExpr, EP_Skip|EP_Unlikely); |
| 139493 | 139864 | return WRC_Prune; |
| 139494 | 139865 | }else{ |
| 139495 | 139866 | return WRC_Continue; |
| 139496 | 139867 | } |
| 139497 | 139868 | } |
| | @@ -139502,10 +139873,12 @@ |
| 139502 | 139873 | */ |
| 139503 | 139874 | static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){ |
| 139504 | 139875 | if( pExpr->op==TK_COLUMN ){ |
| 139505 | 139876 | IdxExprTrans *pX = p->u.pIdxTrans; |
| 139506 | 139877 | if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){ |
| 139878 | + assert( pExpr->y.pTab!=0 ); |
| 139879 | + pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn); |
| 139507 | 139880 | pExpr->iTable = pX->iIdxCur; |
| 139508 | 139881 | pExpr->iColumn = pX->iIdxCol; |
| 139509 | 139882 | pExpr->y.pTab = 0; |
| 139510 | 139883 | } |
| 139511 | 139884 | } |
| | @@ -139547,13 +139920,24 @@ |
| 139547 | 139920 | for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){ |
| 139548 | 139921 | i16 iRef = pIdx->aiColumn[iIdxCol]; |
| 139549 | 139922 | if( iRef==XN_EXPR ){ |
| 139550 | 139923 | assert( aColExpr->a[iIdxCol].pExpr!=0 ); |
| 139551 | 139924 | x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; |
| 139925 | + if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue; |
| 139552 | 139926 | w.xExprCallback = whereIndexExprTransNode; |
| 139553 | 139927 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 139554 | | - }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){ |
| 139928 | + }else if( iRef>=0 |
| 139929 | + && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 |
| 139930 | + && (pTab->aCol[iRef].zColl==0 |
| 139931 | + || sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0) |
| 139932 | + ){ |
| 139933 | + /* Check to see if there are direct references to generated columns |
| 139934 | + ** that are contained in the index. Pulling the generated column |
| 139935 | + ** out of the index is an optimization only - the main table is always |
| 139936 | + ** available if the index cannot be used. To avoid unnecessary |
| 139937 | + ** complication, omit this optimization if the collating sequence for |
| 139938 | + ** the column is non-standard */ |
| 139555 | 139939 | x.iTabCol = iRef; |
| 139556 | 139940 | w.xExprCallback = whereIndexExprTransColumn; |
| 139557 | 139941 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ |
| 139558 | 139942 | }else{ |
| 139559 | 139943 | continue; |
| | @@ -140213,14 +140597,14 @@ |
| 140213 | 140597 | omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 |
| 140214 | 140598 | && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0; |
| 140215 | 140599 | if( omitTable ){ |
| 140216 | 140600 | /* pIdx is a covering index. No need to access the main table. */ |
| 140217 | 140601 | }else if( HasRowid(pIdx->pTable) ){ |
| 140218 | | - if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || ( |
| 140219 | | - (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) |
| 140220 | | - && (pWInfo->eOnePass==ONEPASS_SINGLE) |
| 140221 | | - )){ |
| 140602 | + if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) |
| 140603 | + || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)!=0 |
| 140604 | + && (pWInfo->eOnePass==ONEPASS_SINGLE || pLoop->nLTerm==0) ) |
| 140605 | + ){ |
| 140222 | 140606 | iRowidReg = ++pParse->nMem; |
| 140223 | 140607 | sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); |
| 140224 | 140608 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg); |
| 140225 | 140609 | VdbeCoverage(v); |
| 140226 | 140610 | }else{ |
| | @@ -142055,10 +142439,11 @@ |
| 142055 | 142439 | Expr *pNewExpr; |
| 142056 | 142440 | pNewExpr = sqlite3PExpr(pParse, TK_MATCH, |
| 142057 | 142441 | 0, sqlite3ExprDup(db, pRight, 0)); |
| 142058 | 142442 | if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ |
| 142059 | 142443 | ExprSetProperty(pNewExpr, EP_FromJoin); |
| 142444 | + pNewExpr->iRightJoinTable = pExpr->iRightJoinTable; |
| 142060 | 142445 | } |
| 142061 | 142446 | idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); |
| 142062 | 142447 | testcase( idxNew==0 ); |
| 142063 | 142448 | pNewTerm = &pWC->a[idxNew]; |
| 142064 | 142449 | pNewTerm->prereqRight = prereqExpr; |
| | @@ -142111,15 +142496,19 @@ |
| 142111 | 142496 | ** a virtual term for each vector component. The expression object |
| 142112 | 142497 | ** used by each such virtual term is pExpr (the full vector IN(...) |
| 142113 | 142498 | ** expression). The WhereTerm.iField variable identifies the index within |
| 142114 | 142499 | ** the vector on the LHS that the virtual term represents. |
| 142115 | 142500 | ** |
| 142116 | | - ** This only works if the RHS is a simple SELECT, not a compound |
| 142501 | + ** This only works if the RHS is a simple SELECT (not a compound) that does |
| 142502 | + ** not use window functions. |
| 142117 | 142503 | */ |
| 142118 | 142504 | if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0 |
| 142119 | 142505 | && pExpr->pLeft->op==TK_VECTOR |
| 142120 | 142506 | && pExpr->x.pSelect->pPrior==0 |
| 142507 | +#ifndef SQLITE_OMIT_WINDOWFUNC |
| 142508 | + && pExpr->x.pSelect->pWin==0 |
| 142509 | +#endif |
| 142121 | 142510 | ){ |
| 142122 | 142511 | int i; |
| 142123 | 142512 | for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){ |
| 142124 | 142513 | int idxNew; |
| 142125 | 142514 | idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL); |
| | @@ -142273,13 +142662,14 @@ |
| 142273 | 142662 | mask |= exprSelectUsage(pMaskSet, p->x.pSelect); |
| 142274 | 142663 | }else if( p->x.pList ){ |
| 142275 | 142664 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList); |
| 142276 | 142665 | } |
| 142277 | 142666 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 142278 | | - if( p->op==TK_FUNCTION && p->y.pWin ){ |
| 142667 | + if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && p->y.pWin ){ |
| 142279 | 142668 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition); |
| 142280 | 142669 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy); |
| 142670 | + mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter); |
| 142281 | 142671 | } |
| 142282 | 142672 | #endif |
| 142283 | 142673 | return mask; |
| 142284 | 142674 | } |
| 142285 | 142675 | SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){ |
| | @@ -143163,11 +143553,12 @@ |
| 143163 | 143553 | if( (idxCols & cMask)==0 ){ |
| 143164 | 143554 | Expr *pX = pTerm->pExpr; |
| 143165 | 143555 | idxCols |= cMask; |
| 143166 | 143556 | pIdx->aiColumn[n] = pTerm->u.leftColumn; |
| 143167 | 143557 | pColl = sqlite3ExprCompareCollSeq(pParse, pX); |
| 143168 | | - pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : sqlite3StrBINARY; |
| 143558 | + assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */ |
| 143559 | + pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY; |
| 143169 | 143560 | n++; |
| 143170 | 143561 | } |
| 143171 | 143562 | } |
| 143172 | 143563 | } |
| 143173 | 143564 | assert( (u32)n==pLoop->u.btree.nEq ); |
| | @@ -143341,22 +143732,17 @@ |
| 143341 | 143732 | testcase( pTerm->eOperator & WO_IS ); |
| 143342 | 143733 | testcase( pTerm->eOperator & WO_ISNULL ); |
| 143343 | 143734 | testcase( pTerm->eOperator & WO_ALL ); |
| 143344 | 143735 | if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; |
| 143345 | 143736 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 143737 | + |
| 143738 | + /* tag-20191211-002: WHERE-clause constraints are not useful to the |
| 143739 | + ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the |
| 143740 | + ** equivalent restriction for ordinary tables. */ |
| 143346 | 143741 | if( (pSrc->fg.jointype & JT_LEFT)!=0 |
| 143347 | 143742 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 143348 | | - && (pTerm->eOperator & (WO_IS|WO_ISNULL)) |
| 143349 | 143743 | ){ |
| 143350 | | - /* An "IS" term in the WHERE clause where the virtual table is the rhs |
| 143351 | | - ** of a LEFT JOIN. Do not pass this term to the virtual table |
| 143352 | | - ** implementation, as this can lead to incorrect results from SQL such |
| 143353 | | - ** as: |
| 143354 | | - ** |
| 143355 | | - ** "LEFT JOIN vtab WHERE vtab.col IS NULL" */ |
| 143356 | | - testcase( pTerm->eOperator & WO_ISNULL ); |
| 143357 | | - testcase( pTerm->eOperator & WO_IS ); |
| 143358 | 143744 | continue; |
| 143359 | 143745 | } |
| 143360 | 143746 | assert( pTerm->u.leftColumn>=(-1) ); |
| 143361 | 143747 | pIdxCons[j].iColumn = pTerm->u.leftColumn; |
| 143362 | 143748 | pIdxCons[j].iTermOffset = i; |
| | @@ -143383,11 +143769,12 @@ |
| 143383 | 143769 | assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) ); |
| 143384 | 143770 | |
| 143385 | 143771 | if( op & (WO_LT|WO_LE|WO_GT|WO_GE) |
| 143386 | 143772 | && sqlite3ExprIsVector(pTerm->pExpr->pRight) |
| 143387 | 143773 | ){ |
| 143388 | | - if( i<16 ) mNoOmit |= (1 << i); |
| 143774 | + testcase( j!=i ); |
| 143775 | + if( j<16 ) mNoOmit |= (1 << j); |
| 143389 | 143776 | if( op==WO_LT ) pIdxCons[j].op = WO_LE; |
| 143390 | 143777 | if( op==WO_GT ) pIdxCons[j].op = WO_GE; |
| 143391 | 143778 | } |
| 143392 | 143779 | } |
| 143393 | 143780 | |
| | @@ -144128,14 +144515,16 @@ |
| 144128 | 144515 | sqlite3DebugPrintf( |
| 144129 | 144516 | "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x", |
| 144130 | 144517 | iTerm, pTerm, zType, zLeft, pTerm->truthProb, |
| 144131 | 144518 | pTerm->eOperator, pTerm->wtFlags); |
| 144132 | 144519 | if( pTerm->iField ){ |
| 144133 | | - sqlite3DebugPrintf(" iField=%d\n", pTerm->iField); |
| 144134 | | - }else{ |
| 144135 | | - sqlite3DebugPrintf("\n"); |
| 144520 | + sqlite3DebugPrintf(" iField=%d", pTerm->iField); |
| 144136 | 144521 | } |
| 144522 | + if( pTerm->iParent>=0 ){ |
| 144523 | + sqlite3DebugPrintf(" iParent=%d", pTerm->iParent); |
| 144524 | + } |
| 144525 | + sqlite3DebugPrintf("\n"); |
| 144137 | 144526 | sqlite3TreeViewExpr(0, pTerm->pExpr, 0); |
| 144138 | 144527 | } |
| 144139 | 144528 | } |
| 144140 | 144529 | #endif |
| 144141 | 144530 | |
| | @@ -144178,11 +144567,11 @@ |
| 144178 | 144567 | sqlite3DebugPrintf("%20s",""); |
| 144179 | 144568 | } |
| 144180 | 144569 | }else{ |
| 144181 | 144570 | char *z; |
| 144182 | 144571 | if( p->u.vtab.idxStr ){ |
| 144183 | | - z = sqlite3_mprintf("(%d,\"%s\",%x)", |
| 144572 | + z = sqlite3_mprintf("(%d,\"%s\",%#x)", |
| 144184 | 144573 | p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask); |
| 144185 | 144574 | }else{ |
| 144186 | 144575 | z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask); |
| 144187 | 144576 | } |
| 144188 | 144577 | sqlite3DebugPrintf(" %-19s", z); |
| | @@ -144833,13 +145222,13 @@ |
| 144833 | 145222 | |
| 144834 | 145223 | /* Do not allow the upper bound of a LIKE optimization range constraint |
| 144835 | 145224 | ** to mix with a lower range bound from some other source */ |
| 144836 | 145225 | if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 144837 | 145226 | |
| 144838 | | - /* Do not allow constraints from the WHERE clause to be used by the |
| 144839 | | - ** right table of a LEFT JOIN. Only constraints in the ON clause are |
| 144840 | | - ** allowed */ |
| 145227 | + /* tag-20191211-001: Do not allow constraints from the WHERE clause to |
| 145228 | + ** be used by the right table of a LEFT JOIN. Only constraints in the |
| 145229 | + ** ON clause are allowed. See tag-20191211-002 for the vtab equivalent. */ |
| 144841 | 145230 | if( (pSrc->fg.jointype & JT_LEFT)!=0 |
| 144842 | 145231 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 144843 | 145232 | ){ |
| 144844 | 145233 | continue; |
| 144845 | 145234 | } |
| | @@ -145152,23 +145541,29 @@ |
| 145152 | 145541 | } |
| 145153 | 145542 | |
| 145154 | 145543 | /* Check to see if a partial index with pPartIndexWhere can be used |
| 145155 | 145544 | ** in the current query. Return true if it can be and false if not. |
| 145156 | 145545 | */ |
| 145157 | | -static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ |
| 145546 | +static int whereUsablePartialIndex( |
| 145547 | + int iTab, /* The table for which we want an index */ |
| 145548 | + int isLeft, /* True if iTab is the right table of a LEFT JOIN */ |
| 145549 | + WhereClause *pWC, /* The WHERE clause of the query */ |
| 145550 | + Expr *pWhere /* The WHERE clause from the partial index */ |
| 145551 | +){ |
| 145158 | 145552 | int i; |
| 145159 | 145553 | WhereTerm *pTerm; |
| 145160 | 145554 | Parse *pParse = pWC->pWInfo->pParse; |
| 145161 | 145555 | while( pWhere->op==TK_AND ){ |
| 145162 | | - if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0; |
| 145556 | + if( !whereUsablePartialIndex(iTab,isLeft,pWC,pWhere->pLeft) ) return 0; |
| 145163 | 145557 | pWhere = pWhere->pRight; |
| 145164 | 145558 | } |
| 145165 | 145559 | if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0; |
| 145166 | 145560 | for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 145167 | 145561 | Expr *pExpr; |
| 145168 | 145562 | pExpr = pTerm->pExpr; |
| 145169 | 145563 | if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) |
| 145564 | + && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) |
| 145170 | 145565 | && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) |
| 145171 | 145566 | ){ |
| 145172 | 145567 | return 1; |
| 145173 | 145568 | } |
| 145174 | 145569 | } |
| | @@ -145327,12 +145722,15 @@ |
| 145327 | 145722 | /* Loop over all indices. If there was an INDEXED BY clause, then only |
| 145328 | 145723 | ** consider index pProbe. */ |
| 145329 | 145724 | for(; rc==SQLITE_OK && pProbe; |
| 145330 | 145725 | pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++ |
| 145331 | 145726 | ){ |
| 145727 | + int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0; |
| 145332 | 145728 | if( pProbe->pPartIdxWhere!=0 |
| 145333 | | - && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){ |
| 145729 | + && !whereUsablePartialIndex(pSrc->iCursor, isLeft, pWC, |
| 145730 | + pProbe->pPartIdxWhere) |
| 145731 | + ){ |
| 145334 | 145732 | testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */ |
| 145335 | 145733 | continue; /* Partial index inappropriate for this query */ |
| 145336 | 145734 | } |
| 145337 | 145735 | if( pProbe->bNoQuery ) continue; |
| 145338 | 145736 | rSize = pProbe->aiRowLogEst[0]; |
| | @@ -145555,11 +145953,18 @@ |
| 145555 | 145953 | assert( iTerm<pNew->nLSlot ); |
| 145556 | 145954 | pNew->aLTerm[iTerm] = pTerm; |
| 145557 | 145955 | if( iTerm>mxTerm ) mxTerm = iTerm; |
| 145558 | 145956 | testcase( iTerm==15 ); |
| 145559 | 145957 | testcase( iTerm==16 ); |
| 145560 | | - if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm; |
| 145958 | + if( pUsage[i].omit ){ |
| 145959 | + if( i<16 && ((1<<i)&mNoOmit)==0 ){ |
| 145960 | + testcase( i!=iTerm ); |
| 145961 | + pNew->u.vtab.omitMask |= 1<<iTerm; |
| 145962 | + }else{ |
| 145963 | + testcase( i!=iTerm ); |
| 145964 | + } |
| 145965 | + } |
| 145561 | 145966 | if( (pTerm->eOperator & WO_IN)!=0 ){ |
| 145562 | 145967 | /* A virtual table that is constrained by an IN clause may not |
| 145563 | 145968 | ** consume the ORDER BY clause because (1) the order of IN terms |
| 145564 | 145969 | ** is not necessarily related to the order of output terms and |
| 145565 | 145970 | ** (2) Multiple outputs from a single IN value will not merge |
| | @@ -145568,11 +145973,10 @@ |
| 145568 | 145973 | pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE; |
| 145569 | 145974 | *pbIn = 1; assert( (mExclude & WO_IN)==0 ); |
| 145570 | 145975 | } |
| 145571 | 145976 | } |
| 145572 | 145977 | } |
| 145573 | | - pNew->u.vtab.omitMask &= ~mNoOmit; |
| 145574 | 145978 | |
| 145575 | 145979 | pNew->nLTerm = mxTerm+1; |
| 145576 | 145980 | for(i=0; i<=mxTerm; i++){ |
| 145577 | 145981 | if( pNew->aLTerm[i]==0 ){ |
| 145578 | 145982 | /* The non-zero argvIdx values must be contiguous. Raise an |
| | @@ -147163,10 +147567,11 @@ |
| 147163 | 147567 | sSelect.pEList = pResultSet; |
| 147164 | 147568 | sqlite3TreeViewSelect(0, &sSelect, 0); |
| 147165 | 147569 | } |
| 147166 | 147570 | } |
| 147167 | 147571 | if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ |
| 147572 | + sqlite3DebugPrintf("---- WHERE clause at start of analysis:\n"); |
| 147168 | 147573 | sqlite3WhereClausePrint(sWLB.pWC); |
| 147169 | 147574 | } |
| 147170 | 147575 | #endif |
| 147171 | 147576 | |
| 147172 | 147577 | if( nTabList!=1 || whereShortCut(&sWLB)==0 ){ |
| | @@ -147301,11 +147706,17 @@ |
| 147301 | 147706 | } |
| 147302 | 147707 | pWInfo->nLevel--; |
| 147303 | 147708 | nTabList--; |
| 147304 | 147709 | } |
| 147305 | 147710 | } |
| 147711 | +#if defined(WHERETRACE_ENABLED) |
| 147712 | + if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ |
| 147713 | + sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n"); |
| 147714 | + sqlite3WhereClausePrint(sWLB.pWC); |
| 147715 | + } |
| 147306 | 147716 | WHERETRACE(0xffff,("*** Optimizer Finished ***\n")); |
| 147717 | +#endif |
| 147307 | 147718 | pWInfo->pParse->nQueryLoop += pWInfo->nRowOut; |
| 147308 | 147719 | |
| 147309 | 147720 | /* If the caller is an UPDATE or DELETE statement that is requesting |
| 147310 | 147721 | ** to use a one-pass algorithm, determine if this is appropriate. |
| 147311 | 147722 | ** |
| | @@ -148571,25 +148982,37 @@ |
| 148571 | 148982 | } |
| 148572 | 148983 | /* Fall through. */ |
| 148573 | 148984 | |
| 148574 | 148985 | case TK_AGG_FUNCTION: |
| 148575 | 148986 | case TK_COLUMN: { |
| 148576 | | - Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 148577 | | - p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup); |
| 148987 | + int iCol = -1; |
| 148988 | + if( p->pSub ){ |
| 148989 | + int i; |
| 148990 | + for(i=0; i<p->pSub->nExpr; i++){ |
| 148991 | + if( 0==sqlite3ExprCompare(0, p->pSub->a[i].pExpr, pExpr, -1) ){ |
| 148992 | + iCol = i; |
| 148993 | + break; |
| 148994 | + } |
| 148995 | + } |
| 148996 | + } |
| 148997 | + if( iCol<0 ){ |
| 148998 | + Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 148999 | + p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup); |
| 149000 | + } |
| 148578 | 149001 | if( p->pSub ){ |
| 148579 | 149002 | assert( ExprHasProperty(pExpr, EP_Static)==0 ); |
| 148580 | 149003 | ExprSetProperty(pExpr, EP_Static); |
| 148581 | 149004 | sqlite3ExprDelete(pParse->db, pExpr); |
| 148582 | 149005 | ExprClearProperty(pExpr, EP_Static); |
| 148583 | 149006 | memset(pExpr, 0, sizeof(Expr)); |
| 148584 | 149007 | |
| 148585 | 149008 | pExpr->op = TK_COLUMN; |
| 148586 | | - pExpr->iColumn = p->pSub->nExpr-1; |
| 149009 | + pExpr->iColumn = (iCol<0 ? p->pSub->nExpr-1: iCol); |
| 148587 | 149010 | pExpr->iTable = p->pWin->iEphCsr; |
| 148588 | 149011 | pExpr->y.pTab = p->pTab; |
| 148589 | 149012 | } |
| 148590 | | - |
| 149013 | + if( pParse->db->mallocFailed ) return WRC_Abort; |
| 148591 | 149014 | break; |
| 148592 | 149015 | } |
| 148593 | 149016 | |
| 148594 | 149017 | default: /* no-op */ |
| 148595 | 149018 | break; |
| | @@ -148667,13 +149090,15 @@ |
| 148667 | 149090 | if( pAppend ){ |
| 148668 | 149091 | int i; |
| 148669 | 149092 | int nInit = pList ? pList->nExpr : 0; |
| 148670 | 149093 | for(i=0; i<pAppend->nExpr; i++){ |
| 148671 | 149094 | Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0); |
| 149095 | + assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) ); |
| 148672 | 149096 | if( bIntToNull && pDup && pDup->op==TK_INTEGER ){ |
| 148673 | 149097 | pDup->op = TK_NULL; |
| 148674 | 149098 | pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); |
| 149099 | + pDup->u.zToken = 0; |
| 148675 | 149100 | } |
| 148676 | 149101 | pList = sqlite3ExprListAppend(pParse, pList, pDup); |
| 148677 | 149102 | if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags; |
| 148678 | 149103 | } |
| 148679 | 149104 | } |
| | @@ -148704,11 +149129,11 @@ |
| 148704 | 149129 | Window *pWin; /* Window object iterator */ |
| 148705 | 149130 | Table *pTab; |
| 148706 | 149131 | |
| 148707 | 149132 | pTab = sqlite3DbMallocZero(db, sizeof(Table)); |
| 148708 | 149133 | if( pTab==0 ){ |
| 148709 | | - return SQLITE_NOMEM; |
| 149134 | + return sqlite3ErrorToParser(db, SQLITE_NOMEM); |
| 148710 | 149135 | } |
| 148711 | 149136 | |
| 148712 | 149137 | p->pSrc = 0; |
| 148713 | 149138 | p->pWhere = 0; |
| 148714 | 149139 | p->pGroupBy = 0; |
| | @@ -148791,10 +149216,13 @@ |
| 148791 | 149216 | p->pSrc->a[0].pSelect = pSub; |
| 148792 | 149217 | sqlite3SrcListAssignCursors(pParse, p->pSrc); |
| 148793 | 149218 | pSub->selFlags |= SF_Expanded; |
| 148794 | 149219 | pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE); |
| 148795 | 149220 | if( pTab2==0 ){ |
| 149221 | + /* Might actually be some other kind of error, but in that case |
| 149222 | + ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get |
| 149223 | + ** the correct error message regardless. */ |
| 148796 | 149224 | rc = SQLITE_NOMEM; |
| 148797 | 149225 | }else{ |
| 148798 | 149226 | memcpy(pTab, pTab2, sizeof(Table)); |
| 148799 | 149227 | pTab->tabFlags |= TF_Ephemeral; |
| 148800 | 149228 | p->pSrc->a[0].pTab = pTab; |
| | @@ -148809,10 +149237,17 @@ |
| 148809 | 149237 | } |
| 148810 | 149238 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| 148811 | 149239 | sqlite3DbFree(db, pTab); |
| 148812 | 149240 | } |
| 148813 | 149241 | |
| 149242 | + if( rc ){ |
| 149243 | + if( pParse->nErr==0 ){ |
| 149244 | + assert( pParse->db->mallocFailed ); |
| 149245 | + sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM); |
| 149246 | + } |
| 149247 | + sqlite3SelectReset(pParse, p); |
| 149248 | + } |
| 148814 | 149249 | return rc; |
| 148815 | 149250 | } |
| 148816 | 149251 | |
| 148817 | 149252 | /* |
| 148818 | 149253 | ** Unlink the Window object from the Select to which it is attached, |
| | @@ -149045,10 +149480,11 @@ |
| 149045 | 149480 | /* |
| 149046 | 149481 | ** Return 0 if the two window objects are identical, or non-zero otherwise. |
| 149047 | 149482 | ** Identical window objects can be processed in a single scan. |
| 149048 | 149483 | */ |
| 149049 | 149484 | SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){ |
| 149485 | + if( NEVER(p1==0) || NEVER(p2==0) ) return 1; |
| 149050 | 149486 | if( p1->eFrmType!=p2->eFrmType ) return 1; |
| 149051 | 149487 | if( p1->eStart!=p2->eStart ) return 1; |
| 149052 | 149488 | if( p1->eEnd!=p2->eEnd ) return 1; |
| 149053 | 149489 | if( p1->eExclude!=p2->eExclude ) return 1; |
| 149054 | 149490 | if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1; |
| | @@ -151033,21 +151469,22 @@ |
| 151033 | 151469 | #define sqlite3ParserCTX_PDECL ,Parse *pParse |
| 151034 | 151470 | #define sqlite3ParserCTX_PARAM ,pParse |
| 151035 | 151471 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 151036 | 151472 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 151037 | 151473 | #define YYFALLBACK 1 |
| 151038 | | -#define YYNSTATE 550 |
| 151474 | +#define YYNSTATE 551 |
| 151039 | 151475 | #define YYNRULE 385 |
| 151476 | +#define YYNRULE_WITH_ACTION 325 |
| 151040 | 151477 | #define YYNTOKEN 181 |
| 151041 | | -#define YY_MAX_SHIFT 549 |
| 151042 | | -#define YY_MIN_SHIFTREDUCE 800 |
| 151043 | | -#define YY_MAX_SHIFTREDUCE 1184 |
| 151044 | | -#define YY_ERROR_ACTION 1185 |
| 151045 | | -#define YY_ACCEPT_ACTION 1186 |
| 151046 | | -#define YY_NO_ACTION 1187 |
| 151047 | | -#define YY_MIN_REDUCE 1188 |
| 151048 | | -#define YY_MAX_REDUCE 1572 |
| 151478 | +#define YY_MAX_SHIFT 550 |
| 151479 | +#define YY_MIN_SHIFTREDUCE 801 |
| 151480 | +#define YY_MAX_SHIFTREDUCE 1185 |
| 151481 | +#define YY_ERROR_ACTION 1186 |
| 151482 | +#define YY_ACCEPT_ACTION 1187 |
| 151483 | +#define YY_NO_ACTION 1188 |
| 151484 | +#define YY_MIN_REDUCE 1189 |
| 151485 | +#define YY_MAX_REDUCE 1573 |
| 151049 | 151486 | /************* End control #defines *******************************************/ |
| 151050 | 151487 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 151051 | 151488 | |
| 151052 | 151489 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 151053 | 151490 | ** otherwise. |
| | @@ -151112,206 +151549,206 @@ |
| 151112 | 151549 | ** yy_default[] Default action for each state. |
| 151113 | 151550 | ** |
| 151114 | 151551 | *********** Begin parsing tables **********************************************/ |
| 151115 | 151552 | #define YY_ACTTAB_COUNT (1958) |
| 151116 | 151553 | static const YYACTIONTYPE yy_action[] = { |
| 151117 | | - /* 0 */ 544, 1219, 544, 449, 1257, 544, 1236, 544, 114, 111, |
| 151118 | | - /* 10 */ 211, 544, 1534, 544, 1257, 521, 114, 111, 211, 390, |
| 151119 | | - /* 20 */ 1229, 342, 42, 42, 42, 42, 1222, 42, 42, 71, |
| 151120 | | - /* 30 */ 71, 934, 1221, 71, 71, 71, 71, 1459, 1490, 935, |
| 151121 | | - /* 40 */ 817, 451, 6, 121, 122, 112, 1162, 1162, 1003, 1006, |
| 151122 | | - /* 50 */ 996, 996, 119, 119, 120, 120, 120, 120, 1540, 390, |
| 151123 | | - /* 60 */ 1355, 1514, 549, 2, 1190, 194, 526, 434, 143, 291, |
| 151124 | | - /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1270, 525, |
| 151125 | | - /* 80 */ 501, 491, 164, 121, 122, 112, 1162, 1162, 1003, 1006, |
| 151126 | | - /* 90 */ 996, 996, 119, 119, 120, 120, 120, 120, 1355, 440, |
| 151127 | | - /* 100 */ 1511, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151128 | | - /* 110 */ 115, 422, 266, 266, 266, 266, 1495, 356, 1497, 433, |
| 151129 | | - /* 120 */ 355, 1495, 515, 522, 1482, 541, 1111, 541, 1111, 390, |
| 151554 | + /* 0 */ 544, 1220, 544, 449, 1258, 544, 1237, 544, 114, 111, |
| 151555 | + /* 10 */ 211, 544, 1535, 544, 1258, 521, 114, 111, 211, 390, |
| 151556 | + /* 20 */ 1230, 342, 42, 42, 42, 42, 1223, 42, 42, 71, |
| 151557 | + /* 30 */ 71, 935, 1222, 71, 71, 71, 71, 1460, 1491, 936, |
| 151558 | + /* 40 */ 818, 451, 6, 121, 122, 112, 1163, 1163, 1004, 1007, |
| 151559 | + /* 50 */ 997, 997, 119, 119, 120, 120, 120, 120, 1541, 390, |
| 151560 | + /* 60 */ 1356, 1515, 550, 2, 1191, 194, 526, 434, 143, 291, |
| 151561 | + /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1271, 525, |
| 151562 | + /* 80 */ 501, 491, 164, 121, 122, 112, 1163, 1163, 1004, 1007, |
| 151563 | + /* 90 */ 997, 997, 119, 119, 120, 120, 120, 120, 1356, 440, |
| 151564 | + /* 100 */ 1512, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151565 | + /* 110 */ 115, 422, 266, 266, 266, 266, 1496, 356, 1498, 433, |
| 151566 | + /* 120 */ 355, 1496, 515, 522, 1483, 541, 1112, 541, 1112, 390, |
| 151130 | 151567 | /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221, |
| 151131 | | - /* 140 */ 1026, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151132 | | - /* 150 */ 115, 422, 1139, 121, 122, 112, 1162, 1162, 1003, 1006, |
| 151133 | | - /* 160 */ 996, 996, 119, 119, 120, 120, 120, 120, 404, 426, |
| 151134 | | - /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1415, 466, 123, |
| 151568 | + /* 140 */ 1027, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151569 | + /* 150 */ 115, 422, 1140, 121, 122, 112, 1163, 1163, 1004, 1007, |
| 151570 | + /* 160 */ 997, 997, 119, 119, 120, 120, 120, 120, 404, 426, |
| 151571 | + /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1416, 466, 123, |
| 151135 | 151572 | /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, |
| 151136 | 151573 | /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390, |
| 151137 | | - /* 200 */ 503, 120, 120, 120, 120, 113, 1048, 1139, 1140, 1141, |
| 151138 | | - /* 210 */ 1048, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151139 | | - /* 220 */ 115, 422, 1458, 121, 122, 112, 1162, 1162, 1003, 1006, |
| 151140 | | - /* 230 */ 996, 996, 119, 119, 120, 120, 120, 120, 390, 442, |
| 151141 | | - /* 240 */ 314, 83, 461, 81, 357, 380, 1139, 80, 118, 118, |
| 151574 | + /* 200 */ 503, 120, 120, 120, 120, 113, 1049, 1140, 1141, 1142, |
| 151575 | + /* 210 */ 1049, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151576 | + /* 220 */ 115, 422, 1459, 121, 122, 112, 1163, 1163, 1004, 1007, |
| 151577 | + /* 230 */ 997, 997, 119, 119, 120, 120, 120, 120, 390, 442, |
| 151578 | + /* 240 */ 314, 83, 461, 81, 357, 380, 1140, 80, 118, 118, |
| 151142 | 151579 | /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179, |
| 151143 | | - /* 260 */ 432, 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, |
| 151144 | | - /* 270 */ 996, 119, 119, 120, 120, 120, 120, 432, 431, 266, |
| 151580 | + /* 260 */ 432, 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, |
| 151581 | + /* 270 */ 997, 119, 119, 120, 120, 120, 120, 432, 431, 266, |
| 151145 | 151582 | /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151146 | | - /* 290 */ 115, 422, 541, 1106, 900, 504, 1139, 114, 111, 211, |
| 151147 | | - /* 300 */ 1428, 1139, 1140, 1141, 206, 489, 1106, 390, 447, 1106, |
| 151148 | | - /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1428, 1430, 17, |
| 151583 | + /* 290 */ 115, 422, 541, 1107, 901, 504, 1140, 114, 111, 211, |
| 151584 | + /* 300 */ 1429, 1140, 1141, 1142, 206, 489, 1107, 390, 447, 1107, |
| 151585 | + /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1429, 1431, 17, |
| 151149 | 151586 | /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, |
| 151150 | | - /* 330 */ 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, |
| 151151 | | - /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1355, 432, 1139, |
| 151152 | | - /* 350 */ 480, 1139, 1140, 1141, 993, 993, 1004, 1007, 443, 118, |
| 151587 | + /* 330 */ 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, |
| 151588 | + /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1356, 432, 1140, |
| 151589 | + /* 350 */ 480, 1140, 1141, 1142, 994, 994, 1005, 1008, 443, 118, |
| 151153 | 151590 | /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422, |
| 151154 | | - /* 370 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, |
| 151155 | | - /* 380 */ 119, 120, 120, 120, 120, 1051, 1051, 463, 1428, 118, |
| 151591 | + /* 370 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, |
| 151592 | + /* 380 */ 119, 120, 120, 120, 120, 1052, 1052, 463, 1429, 118, |
| 151156 | 151593 | /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422, |
| 151157 | | - /* 400 */ 1139, 449, 544, 1423, 1139, 1140, 1141, 233, 963, 1139, |
| 151158 | | - /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 839, |
| 151159 | | - /* 420 */ 474, 164, 185, 332, 71, 71, 1240, 997, 118, 118, |
| 151594 | + /* 400 */ 1140, 449, 544, 1424, 1140, 1141, 1142, 233, 964, 1140, |
| 151595 | + /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 840, |
| 151596 | + /* 420 */ 474, 164, 185, 332, 71, 71, 1241, 998, 118, 118, |
| 151160 | 151597 | /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121, |
| 151161 | | - /* 440 */ 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, |
| 151162 | | - /* 450 */ 120, 120, 120, 120, 390, 1139, 1140, 1141, 832, 12, |
| 151163 | | - /* 460 */ 313, 507, 163, 354, 1139, 1140, 1141, 114, 111, 211, |
| 151598 | + /* 440 */ 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, |
| 151599 | + /* 450 */ 120, 120, 120, 120, 390, 1140, 1141, 1142, 833, 12, |
| 151600 | + /* 460 */ 313, 507, 163, 354, 1140, 1141, 1142, 114, 111, 211, |
| 151164 | 151601 | /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122, |
| 151165 | | - /* 480 */ 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, |
| 151602 | + /* 480 */ 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, |
| 151166 | 151603 | /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118, |
| 151167 | | - /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1139, 209, |
| 151168 | | - /* 510 */ 409, 521, 1139, 1106, 1568, 376, 252, 269, 340, 485, |
| 151169 | | - /* 520 */ 335, 484, 238, 390, 511, 362, 1106, 1124, 331, 1106, |
| 151604 | + /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1140, 209, |
| 151605 | + /* 510 */ 409, 521, 1140, 1107, 1569, 376, 252, 269, 340, 485, |
| 151606 | + /* 520 */ 335, 484, 238, 390, 511, 362, 1107, 1125, 331, 1107, |
| 151170 | 151607 | /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118, |
| 151171 | 151608 | /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112, |
| 151172 | | - /* 550 */ 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, |
| 151173 | | - /* 560 */ 120, 120, 390, 1139, 1140, 1141, 984, 1139, 1140, 1141, |
| 151174 | | - /* 570 */ 1139, 233, 490, 1489, 479, 476, 475, 6, 163, 544, |
| 151175 | | - /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1162, |
| 151176 | | - /* 590 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120, |
| 151609 | + /* 550 */ 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, |
| 151610 | + /* 560 */ 120, 120, 390, 1140, 1141, 1142, 985, 1140, 1141, 1142, |
| 151611 | + /* 570 */ 1140, 233, 490, 1490, 479, 476, 475, 6, 163, 544, |
| 151612 | + /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1163, |
| 151613 | + /* 590 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120, |
| 151177 | 151614 | /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117, |
| 151178 | 151615 | /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544, |
| 151179 | | - /* 620 */ 1483, 542, 1139, 889, 889, 1139, 1140, 1141, 1470, 1139, |
| 151180 | | - /* 630 */ 275, 390, 805, 806, 807, 968, 420, 420, 420, 16, |
| 151181 | | - /* 640 */ 16, 55, 55, 1239, 118, 118, 118, 118, 117, 117, |
| 151182 | | - /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1162, 1162, |
| 151183 | | - /* 660 */ 1003, 1006, 996, 996, 119, 119, 120, 120, 120, 120, |
| 151184 | | - /* 670 */ 390, 1186, 1, 1, 549, 2, 1190, 1139, 1140, 1141, |
| 151185 | | - /* 680 */ 194, 291, 895, 136, 1139, 1140, 1141, 894, 519, 1489, |
| 151186 | | - /* 690 */ 1270, 3, 378, 6, 121, 122, 112, 1162, 1162, 1003, |
| 151187 | | - /* 700 */ 1006, 996, 996, 119, 119, 120, 120, 120, 120, 855, |
| 151188 | | - /* 710 */ 544, 921, 544, 118, 118, 118, 118, 117, 117, 116, |
| 151189 | | - /* 720 */ 116, 116, 115, 422, 266, 266, 1089, 1566, 1139, 1518, |
| 151190 | | - /* 730 */ 1566, 1190, 13, 13, 13, 13, 291, 541, 136, 390, |
| 151191 | | - /* 740 */ 483, 419, 418, 963, 342, 1270, 466, 408, 856, 279, |
| 151616 | + /* 620 */ 1484, 542, 1140, 890, 890, 1140, 1141, 1142, 1471, 1140, |
| 151617 | + /* 630 */ 275, 390, 806, 807, 808, 969, 420, 420, 420, 16, |
| 151618 | + /* 640 */ 16, 55, 55, 1240, 118, 118, 118, 118, 117, 117, |
| 151619 | + /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1163, 1163, |
| 151620 | + /* 660 */ 1004, 1007, 997, 997, 119, 119, 120, 120, 120, 120, |
| 151621 | + /* 670 */ 390, 1187, 1, 1, 550, 2, 1191, 1140, 1141, 1142, |
| 151622 | + /* 680 */ 194, 291, 896, 136, 1140, 1141, 1142, 895, 519, 1490, |
| 151623 | + /* 690 */ 1271, 3, 378, 6, 121, 122, 112, 1163, 1163, 1004, |
| 151624 | + /* 700 */ 1007, 997, 997, 119, 119, 120, 120, 120, 120, 856, |
| 151625 | + /* 710 */ 544, 922, 544, 118, 118, 118, 118, 117, 117, 116, |
| 151626 | + /* 720 */ 116, 116, 115, 422, 266, 266, 1090, 1567, 1140, 549, |
| 151627 | + /* 730 */ 1567, 1191, 13, 13, 13, 13, 291, 541, 136, 390, |
| 151628 | + /* 740 */ 483, 419, 418, 964, 342, 1271, 466, 408, 857, 279, |
| 151192 | 151629 | /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116, |
| 151193 | | - /* 760 */ 116, 115, 422, 121, 122, 112, 1162, 1162, 1003, 1006, |
| 151194 | | - /* 770 */ 996, 996, 119, 119, 120, 120, 120, 120, 544, 266, |
| 151195 | | - /* 780 */ 266, 426, 390, 1139, 1140, 1141, 1169, 827, 1169, 466, |
| 151196 | | - /* 790 */ 429, 145, 541, 1143, 399, 313, 437, 301, 835, 1487, |
| 151197 | | - /* 800 */ 71, 71, 410, 6, 1087, 471, 221, 100, 112, 1162, |
| 151198 | | - /* 810 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120, |
| 151630 | + /* 760 */ 116, 115, 422, 121, 122, 112, 1163, 1163, 1004, 1007, |
| 151631 | + /* 770 */ 997, 997, 119, 119, 120, 120, 120, 120, 544, 266, |
| 151632 | + /* 780 */ 266, 426, 390, 1140, 1141, 1142, 1170, 828, 1170, 466, |
| 151633 | + /* 790 */ 429, 145, 541, 1144, 399, 313, 437, 301, 836, 1488, |
| 151634 | + /* 800 */ 71, 71, 410, 6, 1088, 471, 221, 100, 112, 1163, |
| 151635 | + /* 810 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120, |
| 151199 | 151636 | /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 151200 | | - /* 830 */ 115, 422, 237, 1422, 544, 449, 426, 287, 983, 544, |
| 151201 | | - /* 840 */ 236, 235, 234, 827, 97, 527, 427, 1262, 1262, 1143, |
| 151202 | | - /* 850 */ 492, 306, 428, 835, 974, 544, 71, 71, 973, 1238, |
| 151637 | + /* 830 */ 115, 422, 237, 1423, 544, 449, 426, 287, 984, 544, |
| 151638 | + /* 840 */ 236, 235, 234, 828, 97, 527, 427, 1263, 1263, 1144, |
| 151639 | + /* 850 */ 492, 306, 428, 836, 975, 544, 71, 71, 974, 1239, |
| 151203 | 151640 | /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117, |
| 151204 | 151641 | /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266, |
| 151205 | | - /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 973, |
| 151206 | | - /* 890 */ 973, 975, 541, 526, 1106, 326, 390, 541, 493, 395, |
| 151207 | | - /* 900 */ 1467, 195, 528, 13, 13, 1355, 240, 1106, 277, 280, |
| 151208 | | - /* 910 */ 1106, 280, 303, 455, 305, 331, 390, 31, 188, 417, |
| 151209 | | - /* 920 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, |
| 151210 | | - /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 983, |
| 151211 | | - /* 940 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, |
| 151212 | | - /* 950 */ 119, 120, 120, 120, 120, 974, 321, 1139, 324, 973, |
| 151213 | | - /* 960 */ 121, 110, 112, 1162, 1162, 1003, 1006, 996, 996, 119, |
| 151214 | | - /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1182, 118, 118, |
| 151215 | | - /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1139, |
| 151216 | | - /* 990 */ 973, 973, 975, 304, 9, 364, 244, 360, 118, 118, |
| 151642 | + /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 974, |
| 151643 | + /* 890 */ 974, 976, 541, 526, 1107, 326, 390, 541, 493, 395, |
| 151644 | + /* 900 */ 1468, 195, 528, 13, 13, 1356, 240, 1107, 277, 280, |
| 151645 | + /* 910 */ 1107, 280, 303, 455, 305, 331, 390, 31, 188, 417, |
| 151646 | + /* 920 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, |
| 151647 | + /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 984, |
| 151648 | + /* 940 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, |
| 151649 | + /* 950 */ 119, 120, 120, 120, 120, 975, 321, 1140, 324, 974, |
| 151650 | + /* 960 */ 121, 110, 112, 1163, 1163, 1004, 1007, 997, 997, 119, |
| 151651 | + /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1183, 118, 118, |
| 151652 | + /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1140, |
| 151653 | + /* 990 */ 974, 974, 976, 304, 9, 364, 244, 360, 118, 118, |
| 151217 | 151654 | /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312, |
| 151218 | | - /* 1010 */ 544, 342, 1139, 1140, 1141, 299, 290, 535, 118, 118, |
| 151219 | | - /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1260, |
| 151220 | | - /* 1030 */ 1260, 1160, 13, 13, 278, 419, 418, 466, 390, 920, |
| 151221 | | - /* 1040 */ 260, 260, 289, 1166, 1139, 1140, 1141, 189, 1168, 266, |
| 151222 | | - /* 1050 */ 266, 466, 388, 541, 1183, 544, 1167, 263, 144, 487, |
| 151223 | | - /* 1060 */ 919, 544, 541, 122, 112, 1162, 1162, 1003, 1006, 996, |
| 151224 | | - /* 1070 */ 996, 119, 119, 120, 120, 120, 120, 71, 71, 1139, |
| 151225 | | - /* 1080 */ 1169, 1269, 1169, 13, 13, 895, 1067, 1160, 544, 466, |
| 151226 | | - /* 1090 */ 894, 107, 536, 1488, 4, 1265, 1106, 6, 523, 1046, |
| 151227 | | - /* 1100 */ 12, 1068, 1089, 1567, 311, 453, 1567, 518, 539, 1106, |
| 151228 | | - /* 1110 */ 56, 56, 1106, 1486, 421, 1355, 1069, 6, 343, 285, |
| 151655 | + /* 1010 */ 544, 342, 1140, 1141, 1142, 299, 290, 535, 118, 118, |
| 151656 | + /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1261, |
| 151657 | + /* 1030 */ 1261, 1161, 13, 13, 278, 419, 418, 466, 390, 921, |
| 151658 | + /* 1040 */ 260, 260, 289, 1167, 1140, 1141, 1142, 189, 1169, 266, |
| 151659 | + /* 1050 */ 266, 466, 388, 541, 1184, 544, 1168, 263, 144, 487, |
| 151660 | + /* 1060 */ 920, 544, 541, 122, 112, 1163, 1163, 1004, 1007, 997, |
| 151661 | + /* 1070 */ 997, 119, 119, 120, 120, 120, 120, 71, 71, 1140, |
| 151662 | + /* 1080 */ 1170, 1270, 1170, 13, 13, 896, 1068, 1161, 544, 466, |
| 151663 | + /* 1090 */ 895, 107, 536, 1489, 4, 1266, 1107, 6, 523, 1047, |
| 151664 | + /* 1100 */ 12, 1069, 1090, 1568, 311, 453, 1568, 518, 539, 1107, |
| 151665 | + /* 1110 */ 56, 56, 1107, 1487, 421, 1356, 1070, 6, 343, 285, |
| 151229 | 151666 | /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, |
| 151230 | | - /* 1130 */ 422, 423, 1268, 319, 1139, 1140, 1141, 875, 266, 266, |
| 151231 | | - /* 1140 */ 1274, 107, 536, 533, 4, 1485, 293, 876, 1208, 6, |
| 151232 | | - /* 1150 */ 210, 541, 541, 164, 1539, 494, 414, 864, 539, 267, |
| 151233 | | - /* 1160 */ 267, 1211, 396, 509, 497, 204, 266, 266, 394, 529, |
| 151234 | | - /* 1170 */ 8, 983, 541, 517, 544, 919, 456, 105, 105, 541, |
| 151235 | | - /* 1180 */ 1087, 423, 266, 266, 106, 415, 423, 546, 545, 266, |
| 151236 | | - /* 1190 */ 266, 973, 516, 533, 1370, 541, 15, 15, 266, 266, |
| 151237 | | - /* 1200 */ 454, 1117, 541, 266, 266, 1067, 1369, 513, 290, 535, |
| 151238 | | - /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 919, 125, |
| 151239 | | - /* 1220 */ 1068, 983, 973, 973, 975, 976, 27, 105, 105, 399, |
| 151240 | | - /* 1230 */ 341, 1508, 44, 44, 106, 1069, 423, 546, 545, 57, |
| 151241 | | - /* 1240 */ 57, 973, 341, 1508, 107, 536, 544, 4, 460, 399, |
| 151242 | | - /* 1250 */ 214, 1117, 457, 294, 375, 1088, 532, 297, 544, 537, |
| 151667 | + /* 1130 */ 422, 423, 1269, 319, 1140, 1141, 1142, 876, 266, 266, |
| 151668 | + /* 1140 */ 1275, 107, 536, 533, 4, 1486, 293, 877, 1209, 6, |
| 151669 | + /* 1150 */ 210, 541, 541, 164, 1540, 494, 414, 865, 539, 267, |
| 151670 | + /* 1160 */ 267, 1212, 396, 509, 497, 204, 266, 266, 394, 529, |
| 151671 | + /* 1170 */ 8, 984, 541, 517, 544, 920, 456, 105, 105, 541, |
| 151672 | + /* 1180 */ 1088, 423, 266, 266, 106, 415, 423, 546, 545, 266, |
| 151673 | + /* 1190 */ 266, 974, 516, 533, 1371, 541, 15, 15, 266, 266, |
| 151674 | + /* 1200 */ 454, 1118, 541, 266, 266, 1068, 1370, 513, 290, 535, |
| 151675 | + /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 920, 125, |
| 151676 | + /* 1220 */ 1069, 984, 974, 974, 976, 977, 27, 105, 105, 399, |
| 151677 | + /* 1230 */ 341, 1509, 44, 44, 106, 1070, 423, 546, 545, 57, |
| 151678 | + /* 1240 */ 57, 974, 341, 1509, 107, 536, 544, 4, 460, 399, |
| 151679 | + /* 1250 */ 214, 1118, 457, 294, 375, 1089, 532, 297, 544, 537, |
| 151243 | 151680 | /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58, |
| 151244 | | - /* 1270 */ 544, 109, 973, 973, 975, 976, 27, 1513, 1128, 425, |
| 151681 | + /* 1270 */ 544, 109, 974, 974, 976, 977, 27, 1514, 1129, 425, |
| 151245 | 151682 | /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372, |
| 151246 | | - /* 1290 */ 255, 370, 60, 60, 814, 1177, 533, 544, 273, 544, |
| 151247 | | - /* 1300 */ 1160, 842, 387, 386, 544, 1306, 544, 215, 210, 296, |
| 151248 | | - /* 1310 */ 513, 846, 544, 265, 208, 514, 1305, 295, 274, 61, |
| 151249 | | - /* 1320 */ 61, 62, 62, 436, 983, 1159, 45, 45, 46, 46, |
| 151250 | | - /* 1330 */ 105, 105, 1183, 919, 47, 47, 1473, 106, 544, 423, |
| 151251 | | - /* 1340 */ 546, 545, 218, 544, 973, 934, 1084, 217, 544, 377, |
| 151252 | | - /* 1350 */ 395, 107, 536, 935, 4, 156, 1160, 842, 158, 544, |
| 151683 | + /* 1290 */ 255, 370, 60, 60, 815, 1178, 533, 544, 273, 544, |
| 151684 | + /* 1300 */ 1161, 843, 387, 386, 544, 1307, 544, 215, 210, 296, |
| 151685 | + /* 1310 */ 513, 847, 544, 265, 208, 514, 1306, 295, 274, 61, |
| 151686 | + /* 1320 */ 61, 62, 62, 436, 984, 1160, 45, 45, 46, 46, |
| 151687 | + /* 1330 */ 105, 105, 1184, 920, 47, 47, 1474, 106, 544, 423, |
| 151688 | + /* 1340 */ 546, 545, 218, 544, 974, 935, 1085, 217, 544, 377, |
| 151689 | + /* 1350 */ 395, 107, 536, 936, 4, 156, 1161, 843, 158, 544, |
| 151253 | 151690 | /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307, |
| 151254 | | - /* 1370 */ 63, 63, 544, 1447, 216, 973, 973, 975, 976, 27, |
| 151255 | | - /* 1380 */ 444, 64, 64, 544, 1446, 65, 65, 544, 524, 14, |
| 151691 | + /* 1370 */ 63, 63, 544, 1448, 216, 974, 974, 976, 977, 27, |
| 151692 | + /* 1380 */ 444, 64, 64, 544, 1447, 65, 65, 544, 524, 14, |
| 151256 | 151693 | /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97, |
| 151257 | | - /* 1400 */ 1033, 544, 960, 533, 268, 127, 127, 544, 391, 67, |
| 151258 | | - /* 1410 */ 67, 544, 977, 290, 535, 52, 52, 513, 544, 68, |
| 151259 | | - /* 1420 */ 68, 1293, 512, 69, 69, 397, 165, 854, 853, 53, |
| 151260 | | - /* 1430 */ 53, 983, 965, 151, 151, 243, 430, 105, 105, 199, |
| 151261 | | - /* 1440 */ 152, 152, 448, 1302, 106, 243, 423, 546, 545, 1128, |
| 151262 | | - /* 1450 */ 425, 973, 320, 270, 861, 862, 1033, 220, 373, 373, |
| 151263 | | - /* 1460 */ 372, 255, 370, 450, 323, 814, 243, 544, 977, 544, |
| 151264 | | - /* 1470 */ 107, 536, 544, 4, 544, 937, 938, 325, 215, 1045, |
| 151265 | | - /* 1480 */ 296, 1045, 973, 973, 975, 976, 27, 539, 295, 76, |
| 151266 | | - /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1502, 1253, |
| 151267 | | - /* 1500 */ 107, 536, 544, 4, 1044, 544, 1044, 531, 1237, 544, |
| 151694 | + /* 1400 */ 1034, 544, 961, 533, 268, 127, 127, 544, 391, 67, |
| 151695 | + /* 1410 */ 67, 544, 978, 290, 535, 52, 52, 513, 544, 68, |
| 151696 | + /* 1420 */ 68, 1294, 512, 69, 69, 397, 165, 855, 854, 53, |
| 151697 | + /* 1430 */ 53, 984, 966, 151, 151, 243, 430, 105, 105, 199, |
| 151698 | + /* 1440 */ 152, 152, 448, 1303, 106, 243, 423, 546, 545, 1129, |
| 151699 | + /* 1450 */ 425, 974, 320, 270, 862, 863, 1034, 220, 373, 373, |
| 151700 | + /* 1460 */ 372, 255, 370, 450, 323, 815, 243, 544, 978, 544, |
| 151701 | + /* 1470 */ 107, 536, 544, 4, 544, 938, 939, 325, 215, 1046, |
| 151702 | + /* 1480 */ 296, 1046, 974, 974, 976, 977, 27, 539, 295, 76, |
| 151703 | + /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1503, 1254, |
| 151704 | + /* 1500 */ 107, 536, 544, 4, 1045, 544, 1045, 531, 1238, 544, |
| 151268 | 151705 | /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544, |
| 151269 | | - /* 1520 */ 472, 1527, 533, 239, 73, 73, 156, 129, 129, 158, |
| 151706 | + /* 1520 */ 472, 1528, 533, 239, 73, 73, 156, 129, 129, 158, |
| 151270 | 151707 | /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149, |
| 151271 | | - /* 1540 */ 423, 134, 134, 329, 1029, 216, 97, 239, 928, 345, |
| 151272 | | - /* 1550 */ 983, 243, 533, 1314, 339, 544, 105, 105, 899, 1354, |
| 151273 | | - /* 1560 */ 544, 1289, 258, 106, 338, 423, 546, 545, 544, 1300, |
| 151274 | | - /* 1570 */ 973, 892, 99, 536, 109, 4, 544, 133, 133, 391, |
| 151275 | | - /* 1580 */ 983, 197, 131, 131, 290, 535, 105, 105, 530, 539, |
| 151276 | | - /* 1590 */ 132, 132, 1360, 106, 1218, 423, 546, 545, 75, 75, |
| 151277 | | - /* 1600 */ 973, 973, 973, 975, 976, 27, 544, 430, 825, 1210, |
| 151278 | | - /* 1610 */ 893, 139, 423, 109, 544, 1199, 1198, 1200, 1521, 544, |
| 151279 | | - /* 1620 */ 201, 544, 11, 374, 533, 1286, 347, 349, 77, 77, |
| 151280 | | - /* 1630 */ 1339, 973, 973, 975, 976, 27, 74, 74, 351, 213, |
| 151281 | | - /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1347, 382, |
| 151282 | | - /* 1650 */ 353, 452, 983, 337, 1236, 1419, 1418, 205, 105, 105, |
| 151283 | | - /* 1660 */ 192, 367, 193, 534, 1524, 106, 1177, 423, 546, 545, |
| 151284 | | - /* 1670 */ 247, 167, 973, 270, 1466, 200, 1464, 1174, 373, 373, |
| 151285 | | - /* 1680 */ 372, 255, 370, 398, 79, 814, 83, 82, 1424, 446, |
| 151286 | | - /* 1690 */ 161, 177, 169, 95, 1336, 438, 172, 173, 215, 174, |
| 151287 | | - /* 1700 */ 296, 175, 35, 973, 973, 975, 976, 27, 295, 1344, |
| 151288 | | - /* 1710 */ 439, 470, 223, 36, 379, 445, 1413, 381, 459, 1350, |
| 151289 | | - /* 1720 */ 181, 227, 88, 465, 259, 229, 1435, 318, 186, 468, |
| 151290 | | - /* 1730 */ 322, 230, 384, 1201, 231, 486, 1256, 1255, 217, 411, |
| 151291 | | - /* 1740 */ 1254, 1247, 90, 846, 206, 413, 156, 505, 1538, 158, |
| 151292 | | - /* 1750 */ 1225, 1537, 283, 1507, 1226, 336, 385, 284, 1224, 496, |
| 151293 | | - /* 1760 */ 1536, 1297, 94, 346, 348, 216, 1246, 499, 1298, 245, |
| 151294 | | - /* 1770 */ 246, 1296, 416, 350, 1493, 124, 1492, 10, 524, 361, |
| 151295 | | - /* 1780 */ 1399, 101, 96, 288, 508, 253, 1134, 1207, 34, 1295, |
| 151296 | | - /* 1790 */ 547, 254, 256, 257, 392, 548, 1196, 1191, 359, 391, |
| 151297 | | - /* 1800 */ 1279, 1278, 196, 365, 290, 535, 366, 352, 1451, 1321, |
| 151298 | | - /* 1810 */ 1320, 1452, 153, 137, 281, 154, 801, 424, 155, 1450, |
| 151299 | | - /* 1820 */ 1449, 198, 292, 202, 203, 78, 212, 430, 271, 135, |
| 151300 | | - /* 1830 */ 1043, 1041, 957, 168, 219, 157, 170, 878, 308, 222, |
| 151301 | | - /* 1840 */ 1057, 176, 159, 961, 400, 84, 402, 178, 85, 86, |
| 151302 | | - /* 1850 */ 87, 166, 160, 393, 1060, 224, 225, 1056, 146, 18, |
| 151303 | | - /* 1860 */ 226, 317, 1049, 1171, 243, 464, 182, 228, 37, 183, |
| 151304 | | - /* 1870 */ 816, 469, 338, 232, 330, 481, 184, 89, 844, 19, |
| 151305 | | - /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 857, 147, 488, |
| 151306 | | - /* 1890 */ 282, 1122, 148, 1009, 927, 1092, 39, 93, 40, 495, |
| 151307 | | - /* 1900 */ 1093, 187, 498, 207, 262, 264, 922, 242, 1108, 109, |
| 151308 | | - /* 1910 */ 1112, 1110, 1096, 33, 21, 1116, 520, 1024, 22, 23, |
| 151309 | | - /* 1920 */ 24, 1115, 25, 190, 97, 1010, 1008, 26, 1012, 1066, |
| 151310 | | - /* 1930 */ 248, 7, 1065, 249, 1013, 28, 41, 888, 978, 826, |
| 151311 | | - /* 1940 */ 108, 29, 250, 540, 251, 1529, 371, 368, 1129, 1187, |
| 151312 | | - /* 1950 */ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1528, |
| 151708 | + /* 1540 */ 423, 134, 134, 329, 1030, 216, 97, 239, 929, 345, |
| 151709 | + /* 1550 */ 984, 243, 533, 1315, 339, 544, 105, 105, 900, 1355, |
| 151710 | + /* 1560 */ 544, 1290, 258, 106, 338, 423, 546, 545, 544, 1301, |
| 151711 | + /* 1570 */ 974, 893, 99, 536, 109, 4, 544, 133, 133, 391, |
| 151712 | + /* 1580 */ 984, 197, 131, 131, 290, 535, 105, 105, 530, 539, |
| 151713 | + /* 1590 */ 132, 132, 1361, 106, 1219, 423, 546, 545, 75, 75, |
| 151714 | + /* 1600 */ 974, 974, 974, 976, 977, 27, 544, 430, 826, 1211, |
| 151715 | + /* 1610 */ 894, 139, 423, 109, 544, 1200, 1199, 1201, 1522, 544, |
| 151716 | + /* 1620 */ 201, 544, 11, 374, 533, 1287, 347, 349, 77, 77, |
| 151717 | + /* 1630 */ 1340, 974, 974, 976, 977, 27, 74, 74, 351, 213, |
| 151718 | + /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1348, 382, |
| 151719 | + /* 1650 */ 353, 452, 984, 337, 1237, 1420, 1419, 205, 105, 105, |
| 151720 | + /* 1660 */ 192, 367, 193, 534, 1525, 106, 1178, 423, 546, 545, |
| 151721 | + /* 1670 */ 247, 167, 974, 270, 1467, 200, 1465, 1175, 373, 373, |
| 151722 | + /* 1680 */ 372, 255, 370, 398, 79, 815, 83, 82, 1425, 446, |
| 151723 | + /* 1690 */ 161, 177, 169, 95, 1337, 438, 172, 173, 215, 174, |
| 151724 | + /* 1700 */ 296, 175, 35, 974, 974, 976, 977, 27, 295, 1345, |
| 151725 | + /* 1710 */ 439, 470, 223, 36, 379, 445, 1414, 381, 459, 1351, |
| 151726 | + /* 1720 */ 181, 227, 88, 465, 259, 229, 1436, 318, 186, 468, |
| 151727 | + /* 1730 */ 322, 230, 384, 1202, 231, 486, 1257, 1256, 217, 411, |
| 151728 | + /* 1740 */ 1255, 1248, 90, 847, 206, 413, 156, 505, 1539, 158, |
| 151729 | + /* 1750 */ 1226, 1538, 283, 1508, 1227, 336, 385, 284, 1225, 496, |
| 151730 | + /* 1760 */ 1537, 1298, 94, 346, 348, 216, 1247, 499, 1299, 245, |
| 151731 | + /* 1770 */ 246, 1297, 416, 350, 1494, 124, 1493, 10, 524, 361, |
| 151732 | + /* 1780 */ 1400, 101, 96, 288, 508, 253, 1135, 1208, 34, 1296, |
| 151733 | + /* 1790 */ 547, 254, 256, 257, 392, 548, 1197, 1192, 359, 391, |
| 151734 | + /* 1800 */ 1280, 1279, 196, 365, 290, 535, 366, 352, 1452, 1322, |
| 151735 | + /* 1810 */ 1321, 1453, 153, 137, 281, 154, 802, 424, 155, 1451, |
| 151736 | + /* 1820 */ 1450, 198, 292, 202, 203, 78, 212, 430, 271, 135, |
| 151737 | + /* 1830 */ 1044, 1042, 958, 168, 219, 157, 170, 879, 308, 222, |
| 151738 | + /* 1840 */ 1058, 176, 159, 962, 400, 84, 402, 178, 85, 86, |
| 151739 | + /* 1850 */ 87, 166, 160, 393, 1061, 224, 225, 1057, 146, 18, |
| 151740 | + /* 1860 */ 226, 317, 1050, 1172, 243, 464, 182, 228, 37, 183, |
| 151741 | + /* 1870 */ 817, 469, 338, 232, 330, 481, 184, 89, 845, 19, |
| 151742 | + /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 858, 147, 488, |
| 151743 | + /* 1890 */ 282, 1123, 148, 1010, 928, 1093, 39, 93, 40, 495, |
| 151744 | + /* 1900 */ 1094, 187, 498, 207, 262, 264, 923, 242, 1109, 109, |
| 151745 | + /* 1910 */ 1113, 1111, 1097, 33, 21, 1117, 520, 1025, 22, 23, |
| 151746 | + /* 1920 */ 24, 1116, 25, 190, 97, 1011, 1009, 26, 1013, 1067, |
| 151747 | + /* 1930 */ 248, 7, 1066, 249, 1014, 28, 41, 889, 979, 827, |
| 151748 | + /* 1940 */ 108, 29, 250, 540, 251, 1530, 371, 368, 1131, 1130, |
| 151749 | + /* 1950 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1529, |
| 151313 | 151750 | }; |
| 151314 | 151751 | static const YYCODETYPE yy_lookahead[] = { |
| 151315 | 151752 | /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268, |
| 151316 | 151753 | /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19, |
| 151317 | 151754 | /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211, |
| | @@ -151504,11 +151941,11 @@ |
| 151504 | 151941 | /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24, |
| 151505 | 151942 | /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26, |
| 151506 | 151943 | /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34, |
| 151507 | 151944 | /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23, |
| 151508 | 151945 | /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23, |
| 151509 | | - /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 310, |
| 151946 | + /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 1, |
| 151510 | 151947 | /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310, |
| 151511 | 151948 | /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151512 | 151949 | /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151513 | 151950 | /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151514 | 151951 | /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| | @@ -151525,13 +151962,13 @@ |
| 151525 | 151962 | /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151526 | 151963 | /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151527 | 151964 | /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151528 | 151965 | /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151529 | 151966 | }; |
| 151530 | | -#define YY_SHIFT_COUNT (549) |
| 151967 | +#define YY_SHIFT_COUNT (550) |
| 151531 | 151968 | #define YY_SHIFT_MIN (0) |
| 151532 | | -#define YY_SHIFT_MAX (1947) |
| 151969 | +#define YY_SHIFT_MAX (1948) |
| 151533 | 151970 | static const unsigned short int yy_shift_ofst[] = { |
| 151534 | 151971 | /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481, |
| 151535 | 151972 | /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481, |
| 151536 | 151973 | /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, |
| 151537 | 151974 | /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340, |
| | @@ -151584,10 +152021,11 @@ |
| 151584 | 152021 | /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884, |
| 151585 | 152022 | /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889, |
| 151586 | 152023 | /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905, |
| 151587 | 152024 | /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918, |
| 151588 | 152025 | /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947, |
| 152026 | + /* 550 */ 1948, |
| 151589 | 152027 | }; |
| 151590 | 152028 | #define YY_REDUCE_COUNT (389) |
| 151591 | 152029 | #define YY_REDUCE_MIN (-262) |
| 151592 | 152030 | #define YY_REDUCE_MAX (1617) |
| 151593 | 152031 | static const short yy_reduce_ofst[] = { |
| | @@ -151630,65 +152068,66 @@ |
| 151630 | 152068 | /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592, |
| 151631 | 152069 | /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600, |
| 151632 | 152070 | /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616, |
| 151633 | 152071 | }; |
| 151634 | 152072 | static const YYACTIONTYPE yy_default[] = { |
| 151635 | | - /* 0 */ 1572, 1572, 1572, 1408, 1185, 1294, 1185, 1185, 1185, 1408, |
| 151636 | | - /* 10 */ 1408, 1408, 1185, 1324, 1324, 1461, 1216, 1185, 1185, 1185, |
| 151637 | | - /* 20 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1407, 1185, 1185, |
| 151638 | | - /* 30 */ 1185, 1185, 1491, 1491, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151639 | | - /* 40 */ 1185, 1185, 1185, 1333, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151640 | | - /* 50 */ 1409, 1410, 1185, 1185, 1185, 1460, 1462, 1425, 1343, 1342, |
| 151641 | | - /* 60 */ 1341, 1340, 1443, 1311, 1338, 1331, 1335, 1403, 1404, 1402, |
| 151642 | | - /* 70 */ 1406, 1410, 1409, 1185, 1334, 1374, 1388, 1373, 1185, 1185, |
| 151643 | | - /* 80 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151644 | | - /* 90 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151645 | | - /* 100 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151646 | | - /* 110 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151647 | | - /* 120 */ 1185, 1185, 1185, 1185, 1185, 1185, 1382, 1387, 1393, 1386, |
| 151648 | | - /* 130 */ 1383, 1376, 1375, 1377, 1378, 1185, 1206, 1258, 1185, 1185, |
| 151649 | | - /* 140 */ 1185, 1185, 1479, 1478, 1185, 1185, 1216, 1368, 1367, 1379, |
| 151650 | | - /* 150 */ 1380, 1390, 1389, 1468, 1526, 1525, 1426, 1185, 1185, 1185, |
| 151651 | | - /* 160 */ 1185, 1185, 1185, 1491, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151652 | | - /* 170 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151653 | | - /* 180 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1491, 1491, |
| 151654 | | - /* 190 */ 1185, 1216, 1491, 1491, 1212, 1212, 1318, 1185, 1474, 1294, |
| 151655 | | - /* 200 */ 1285, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151656 | | - /* 210 */ 1185, 1185, 1185, 1185, 1185, 1465, 1463, 1185, 1185, 1185, |
| 151657 | | - /* 220 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151658 | | - /* 230 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151659 | | - /* 240 */ 1185, 1185, 1185, 1185, 1185, 1290, 1185, 1185, 1185, 1185, |
| 151660 | | - /* 250 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1520, 1185, 1438, |
| 151661 | | - /* 260 */ 1272, 1290, 1290, 1290, 1290, 1292, 1273, 1271, 1284, 1217, |
| 151662 | | - /* 270 */ 1192, 1564, 1337, 1313, 1313, 1561, 1337, 1337, 1561, 1233, |
| 151663 | | - /* 280 */ 1542, 1228, 1324, 1324, 1324, 1313, 1318, 1318, 1405, 1291, |
| 151664 | | - /* 290 */ 1284, 1185, 1564, 1299, 1299, 1563, 1563, 1299, 1426, 1346, |
| 151665 | | - /* 300 */ 1352, 1261, 1337, 1267, 1267, 1267, 1267, 1299, 1203, 1337, |
| 151666 | | - /* 310 */ 1337, 1346, 1352, 1261, 1261, 1337, 1299, 1203, 1442, 1558, |
| 151667 | | - /* 320 */ 1299, 1203, 1416, 1299, 1203, 1299, 1203, 1416, 1259, 1259, |
| 151668 | | - /* 330 */ 1259, 1248, 1185, 1185, 1416, 1259, 1233, 1259, 1248, 1259, |
| 151669 | | - /* 340 */ 1259, 1509, 1416, 1420, 1420, 1416, 1317, 1312, 1317, 1312, |
| 151670 | | - /* 350 */ 1317, 1312, 1317, 1312, 1299, 1501, 1501, 1327, 1327, 1332, |
| 151671 | | - /* 360 */ 1318, 1411, 1299, 1185, 1332, 1330, 1328, 1337, 1209, 1251, |
| 151672 | | - /* 370 */ 1523, 1523, 1519, 1519, 1519, 1569, 1569, 1474, 1535, 1216, |
| 151673 | | - /* 380 */ 1216, 1216, 1216, 1535, 1235, 1235, 1217, 1217, 1216, 1535, |
| 151674 | | - /* 390 */ 1185, 1185, 1185, 1185, 1185, 1185, 1530, 1185, 1427, 1303, |
| 151675 | | - /* 400 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151676 | | - /* 410 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151677 | | - /* 420 */ 1185, 1185, 1185, 1357, 1185, 1188, 1471, 1185, 1185, 1469, |
| 151678 | | - /* 430 */ 1185, 1185, 1185, 1185, 1185, 1185, 1304, 1185, 1185, 1185, |
| 151679 | | - /* 440 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151680 | | - /* 450 */ 1185, 1185, 1185, 1185, 1185, 1560, 1185, 1185, 1185, 1185, |
| 151681 | | - /* 460 */ 1185, 1185, 1441, 1440, 1185, 1185, 1301, 1185, 1185, 1185, |
| 151682 | | - /* 470 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151683 | | - /* 480 */ 1231, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151684 | | - /* 490 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151685 | | - /* 500 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1329, 1185, 1185, |
| 151686 | | - /* 510 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151687 | | - /* 520 */ 1185, 1185, 1506, 1319, 1185, 1185, 1551, 1185, 1185, 1185, |
| 151688 | | - /* 530 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, |
| 151689 | | - /* 540 */ 1185, 1546, 1275, 1359, 1185, 1358, 1362, 1185, 1197, 1185, |
| 152073 | + /* 0 */ 1573, 1573, 1573, 1409, 1186, 1295, 1186, 1186, 1186, 1409, |
| 152074 | + /* 10 */ 1409, 1409, 1186, 1325, 1325, 1462, 1217, 1186, 1186, 1186, |
| 152075 | + /* 20 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1408, 1186, 1186, |
| 152076 | + /* 30 */ 1186, 1186, 1492, 1492, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152077 | + /* 40 */ 1186, 1186, 1186, 1334, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152078 | + /* 50 */ 1410, 1411, 1186, 1186, 1186, 1461, 1463, 1426, 1344, 1343, |
| 152079 | + /* 60 */ 1342, 1341, 1444, 1312, 1339, 1332, 1336, 1404, 1405, 1403, |
| 152080 | + /* 70 */ 1407, 1411, 1410, 1186, 1335, 1375, 1389, 1374, 1186, 1186, |
| 152081 | + /* 80 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152082 | + /* 90 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152083 | + /* 100 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152084 | + /* 110 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152085 | + /* 120 */ 1186, 1186, 1186, 1186, 1186, 1186, 1383, 1388, 1394, 1387, |
| 152086 | + /* 130 */ 1384, 1377, 1376, 1378, 1379, 1186, 1207, 1259, 1186, 1186, |
| 152087 | + /* 140 */ 1186, 1186, 1480, 1479, 1186, 1186, 1217, 1369, 1368, 1380, |
| 152088 | + /* 150 */ 1381, 1391, 1390, 1469, 1527, 1526, 1427, 1186, 1186, 1186, |
| 152089 | + /* 160 */ 1186, 1186, 1186, 1492, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152090 | + /* 170 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152091 | + /* 180 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1492, 1492, |
| 152092 | + /* 190 */ 1186, 1217, 1492, 1492, 1213, 1213, 1319, 1186, 1475, 1295, |
| 152093 | + /* 200 */ 1286, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152094 | + /* 210 */ 1186, 1186, 1186, 1186, 1186, 1466, 1464, 1186, 1186, 1186, |
| 152095 | + /* 220 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152096 | + /* 230 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152097 | + /* 240 */ 1186, 1186, 1186, 1186, 1186, 1291, 1186, 1186, 1186, 1186, |
| 152098 | + /* 250 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1521, 1186, 1439, |
| 152099 | + /* 260 */ 1273, 1291, 1291, 1291, 1291, 1293, 1274, 1272, 1285, 1218, |
| 152100 | + /* 270 */ 1193, 1565, 1338, 1314, 1314, 1562, 1338, 1338, 1562, 1234, |
| 152101 | + /* 280 */ 1543, 1229, 1325, 1325, 1325, 1314, 1319, 1319, 1406, 1292, |
| 152102 | + /* 290 */ 1285, 1186, 1565, 1300, 1300, 1564, 1564, 1300, 1427, 1347, |
| 152103 | + /* 300 */ 1353, 1262, 1338, 1268, 1268, 1268, 1268, 1300, 1204, 1338, |
| 152104 | + /* 310 */ 1338, 1347, 1353, 1262, 1262, 1338, 1300, 1204, 1443, 1559, |
| 152105 | + /* 320 */ 1300, 1204, 1417, 1300, 1204, 1300, 1204, 1417, 1260, 1260, |
| 152106 | + /* 330 */ 1260, 1249, 1186, 1186, 1417, 1260, 1234, 1260, 1249, 1260, |
| 152107 | + /* 340 */ 1260, 1510, 1417, 1421, 1421, 1417, 1318, 1313, 1318, 1313, |
| 152108 | + /* 350 */ 1318, 1313, 1318, 1313, 1300, 1502, 1502, 1328, 1328, 1333, |
| 152109 | + /* 360 */ 1319, 1412, 1300, 1186, 1333, 1331, 1329, 1338, 1210, 1252, |
| 152110 | + /* 370 */ 1524, 1524, 1520, 1520, 1520, 1570, 1570, 1475, 1536, 1217, |
| 152111 | + /* 380 */ 1217, 1217, 1217, 1536, 1236, 1236, 1218, 1218, 1217, 1536, |
| 152112 | + /* 390 */ 1186, 1186, 1186, 1186, 1186, 1186, 1531, 1186, 1428, 1304, |
| 152113 | + /* 400 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152114 | + /* 410 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152115 | + /* 420 */ 1186, 1186, 1186, 1358, 1186, 1189, 1472, 1186, 1186, 1470, |
| 152116 | + /* 430 */ 1186, 1186, 1186, 1186, 1186, 1186, 1305, 1186, 1186, 1186, |
| 152117 | + /* 440 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152118 | + /* 450 */ 1186, 1186, 1186, 1186, 1186, 1561, 1186, 1186, 1186, 1186, |
| 152119 | + /* 460 */ 1186, 1186, 1442, 1441, 1186, 1186, 1302, 1186, 1186, 1186, |
| 152120 | + /* 470 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152121 | + /* 480 */ 1232, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152122 | + /* 490 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152123 | + /* 500 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1330, 1186, 1186, |
| 152124 | + /* 510 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152125 | + /* 520 */ 1186, 1186, 1507, 1320, 1186, 1186, 1552, 1186, 1186, 1186, |
| 152126 | + /* 530 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, |
| 152127 | + /* 540 */ 1186, 1547, 1276, 1360, 1186, 1359, 1363, 1186, 1198, 1186, |
| 152128 | + /* 550 */ 1186, |
| 151690 | 152129 | }; |
| 151691 | 152130 | /********** End of lemon-generated parsing tables *****************************/ |
| 151692 | 152131 | |
| 151693 | 152132 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 151694 | 152133 | ** If a construct like the following: |
| | @@ -152619,11 +153058,11 @@ |
| 152619 | 153058 | /* 325 */ "input ::= cmdlist", |
| 152620 | 153059 | /* 326 */ "cmdlist ::= cmdlist ecmd", |
| 152621 | 153060 | /* 327 */ "cmdlist ::= ecmd", |
| 152622 | 153061 | /* 328 */ "ecmd ::= SEMI", |
| 152623 | 153062 | /* 329 */ "ecmd ::= cmdx SEMI", |
| 152624 | | - /* 330 */ "ecmd ::= explain cmdx", |
| 153063 | + /* 330 */ "ecmd ::= explain cmdx SEMI", |
| 152625 | 153064 | /* 331 */ "trans_opt ::=", |
| 152626 | 153065 | /* 332 */ "trans_opt ::= TRANSACTION", |
| 152627 | 153066 | /* 333 */ "trans_opt ::= TRANSACTION nm", |
| 152628 | 153067 | /* 334 */ "savepoint_opt ::= SAVEPOINT", |
| 152629 | 153068 | /* 335 */ "savepoint_opt ::=", |
| | @@ -153511,11 +153950,11 @@ |
| 153511 | 153950 | 181, /* (325) input ::= cmdlist */ |
| 153512 | 153951 | 182, /* (326) cmdlist ::= cmdlist ecmd */ |
| 153513 | 153952 | 182, /* (327) cmdlist ::= ecmd */ |
| 153514 | 153953 | 183, /* (328) ecmd ::= SEMI */ |
| 153515 | 153954 | 183, /* (329) ecmd ::= cmdx SEMI */ |
| 153516 | | - 183, /* (330) ecmd ::= explain cmdx */ |
| 153955 | + 183, /* (330) ecmd ::= explain cmdx SEMI */ |
| 153517 | 153956 | 188, /* (331) trans_opt ::= */ |
| 153518 | 153957 | 188, /* (332) trans_opt ::= TRANSACTION */ |
| 153519 | 153958 | 188, /* (333) trans_opt ::= TRANSACTION nm */ |
| 153520 | 153959 | 190, /* (334) savepoint_opt ::= SAVEPOINT */ |
| 153521 | 153960 | 190, /* (335) savepoint_opt ::= */ |
| | @@ -153901,11 +154340,11 @@ |
| 153901 | 154340 | -1, /* (325) input ::= cmdlist */ |
| 153902 | 154341 | -2, /* (326) cmdlist ::= cmdlist ecmd */ |
| 153903 | 154342 | -1, /* (327) cmdlist ::= ecmd */ |
| 153904 | 154343 | -1, /* (328) ecmd ::= SEMI */ |
| 153905 | 154344 | -2, /* (329) ecmd ::= cmdx SEMI */ |
| 153906 | | - -2, /* (330) ecmd ::= explain cmdx */ |
| 154345 | + -3, /* (330) ecmd ::= explain cmdx SEMI */ |
| 153907 | 154346 | 0, /* (331) trans_opt ::= */ |
| 153908 | 154347 | -1, /* (332) trans_opt ::= TRANSACTION */ |
| 153909 | 154348 | -2, /* (333) trans_opt ::= TRANSACTION nm */ |
| 153910 | 154349 | -1, /* (334) savepoint_opt ::= SAVEPOINT */ |
| 153911 | 154350 | 0, /* (335) savepoint_opt ::= */ |
| | @@ -153989,16 +154428,19 @@ |
| 153989 | 154428 | yymsp = yypParser->yytos; |
| 153990 | 154429 | #ifndef NDEBUG |
| 153991 | 154430 | if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
| 153992 | 154431 | yysize = yyRuleInfoNRhs[yyruleno]; |
| 153993 | 154432 | if( yysize ){ |
| 153994 | | - fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", |
| 154433 | + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 153995 | 154434 | yyTracePrompt, |
| 153996 | | - yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); |
| 154435 | + yyruleno, yyRuleName[yyruleno], |
| 154436 | + yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action", |
| 154437 | + yymsp[yysize].stateno); |
| 153997 | 154438 | }else{ |
| 153998 | | - fprintf(yyTraceFILE, "%sReduce %d [%s].\n", |
| 153999 | | - yyTracePrompt, yyruleno, yyRuleName[yyruleno]); |
| 154439 | + fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", |
| 154440 | + yyTracePrompt, yyruleno, yyRuleName[yyruleno], |
| 154441 | + yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action"); |
| 154000 | 154442 | } |
| 154001 | 154443 | } |
| 154002 | 154444 | #endif /* NDEBUG */ |
| 154003 | 154445 | |
| 154004 | 154446 | /* Check that the stack is large enough to grow by a single entry |
| | @@ -155405,11 +155847,11 @@ |
| 155405 | 155847 | /* (325) input ::= cmdlist */ yytestcase(yyruleno==325); |
| 155406 | 155848 | /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326); |
| 155407 | 155849 | /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327); |
| 155408 | 155850 | /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328); |
| 155409 | 155851 | /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329); |
| 155410 | | - /* (330) ecmd ::= explain cmdx */ yytestcase(yyruleno==330); |
| 155852 | + /* (330) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=330); |
| 155411 | 155853 | /* (331) trans_opt ::= */ yytestcase(yyruleno==331); |
| 155412 | 155854 | /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332); |
| 155413 | 155855 | /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333); |
| 155414 | 155856 | /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334); |
| 155415 | 155857 | /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335); |
| | @@ -163082,10 +163524,13 @@ |
| 163082 | 163524 | # define TESTONLY(X) X |
| 163083 | 163525 | #else |
| 163084 | 163526 | # define TESTONLY(X) |
| 163085 | 163527 | #endif |
| 163086 | 163528 | |
| 163529 | +#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
| 163530 | +#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 163531 | + |
| 163087 | 163532 | #endif /* SQLITE_AMALGAMATION */ |
| 163088 | 163533 | |
| 163089 | 163534 | #ifdef SQLITE_DEBUG |
| 163090 | 163535 | SQLITE_PRIVATE int sqlite3Fts3Corrupt(void); |
| 163091 | 163536 | # define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt() |
| | @@ -163125,10 +163570,11 @@ |
| 163125 | 163570 | sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */ |
| 163126 | 163571 | char *zContentTbl; /* content=xxx option, or NULL */ |
| 163127 | 163572 | char *zLanguageid; /* languageid=xxx option, or NULL */ |
| 163128 | 163573 | int nAutoincrmerge; /* Value configured by 'automerge' */ |
| 163129 | 163574 | u32 nLeafAdd; /* Number of leaf blocks added this trans */ |
| 163575 | + int bLock; /* Used to prevent recursive content= tbls */ |
| 163130 | 163576 | |
| 163131 | 163577 | /* Precompiled statements used by the implementation. Each of these |
| 163132 | 163578 | ** statements is run and reset within a single virtual table API call. |
| 163133 | 163579 | */ |
| 163134 | 163580 | sqlite3_stmt *aStmt[40]; |
| | @@ -163463,10 +163909,11 @@ |
| 163463 | 163909 | |
| 163464 | 163910 | /* fts3.c */ |
| 163465 | 163911 | SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...); |
| 163466 | 163912 | SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64); |
| 163467 | 163913 | SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *); |
| 163914 | +SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *, sqlite_uint64 *); |
| 163468 | 163915 | SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*); |
| 163469 | 163916 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *); |
| 163470 | 163917 | SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64); |
| 163471 | 163918 | SQLITE_PRIVATE void sqlite3Fts3Dequote(char *); |
| 163472 | 163919 | SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*); |
| | @@ -163550,22 +163997,10 @@ |
| 163550 | 163997 | #ifndef SQLITE_CORE |
| 163551 | 163998 | /* # include "sqlite3ext.h" */ |
| 163552 | 163999 | SQLITE_EXTENSION_INIT1 |
| 163553 | 164000 | #endif |
| 163554 | 164001 | |
| 163555 | | -/* |
| 163556 | | -** The following are copied from sqliteInt.h. |
| 163557 | | -** |
| 163558 | | -** Constants for the largest and smallest possible 64-bit signed integers. |
| 163559 | | -** These macros are designed to work correctly on both 32-bit and 64-bit |
| 163560 | | -** compilers. |
| 163561 | | -*/ |
| 163562 | | -#ifndef SQLITE_AMALGAMATION |
| 163563 | | -# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) |
| 163564 | | -# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) |
| 163565 | | -#endif |
| 163566 | | - |
| 163567 | 164002 | static int fts3EvalNext(Fts3Cursor *pCsr); |
| 163568 | 164003 | static int fts3EvalStart(Fts3Cursor *pCsr); |
| 163569 | 164004 | static int fts3TermSegReaderCursor( |
| 163570 | 164005 | Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **); |
| 163571 | 164006 | |
| | @@ -163606,16 +164041,11 @@ |
| 163606 | 164041 | if( (v & mask2)==0 ){ var = v; return ret; } |
| 163607 | 164042 | #define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \ |
| 163608 | 164043 | v = (*ptr++); \ |
| 163609 | 164044 | if( (v & mask2)==0 ){ var = v; return ret; } |
| 163610 | 164045 | |
| 163611 | | -/* |
| 163612 | | -** Read a 64-bit variable-length integer from memory starting at p[0]. |
| 163613 | | -** Return the number of bytes read, or 0 on error. |
| 163614 | | -** The value is stored in *v. |
| 163615 | | -*/ |
| 163616 | | -SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){ |
| 164046 | +SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *pBuf, sqlite_uint64 *v){ |
| 163617 | 164047 | const unsigned char *p = (const unsigned char*)pBuf; |
| 163618 | 164048 | const unsigned char *pStart = p; |
| 163619 | 164049 | u32 a; |
| 163620 | 164050 | u64 b; |
| 163621 | 164051 | int shift; |
| | @@ -163632,10 +164062,19 @@ |
| 163632 | 164062 | if( (c & 0x80)==0 ) break; |
| 163633 | 164063 | } |
| 163634 | 164064 | *v = b; |
| 163635 | 164065 | return (int)(p - pStart); |
| 163636 | 164066 | } |
| 164067 | + |
| 164068 | +/* |
| 164069 | +** Read a 64-bit variable-length integer from memory starting at p[0]. |
| 164070 | +** Return the number of bytes read, or 0 on error. |
| 164071 | +** The value is stored in *v. |
| 164072 | +*/ |
| 164073 | +SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){ |
| 164074 | + return sqlite3Fts3GetVarintU(pBuf, (sqlite3_uint64*)v); |
| 164075 | +} |
| 163637 | 164076 | |
| 163638 | 164077 | /* |
| 163639 | 164078 | ** Read a 64-bit variable-length integer from memory starting at p[0] and |
| 163640 | 164079 | ** not extending past pEnd[-1]. |
| 163641 | 164080 | ** Return the number of bytes read, or 0 on error. |
| | @@ -164852,10 +165291,14 @@ |
| 164852 | 165291 | |
| 164853 | 165292 | int iLangidCons = -1; /* Index of langid=x constraint, if present */ |
| 164854 | 165293 | int iDocidGe = -1; /* Index of docid>=x constraint, if present */ |
| 164855 | 165294 | int iDocidLe = -1; /* Index of docid<=x constraint, if present */ |
| 164856 | 165295 | int iIdx; |
| 165296 | + |
| 165297 | + if( p->bLock ){ |
| 165298 | + return SQLITE_ERROR; |
| 165299 | + } |
| 164857 | 165300 | |
| 164858 | 165301 | /* By default use a full table scan. This is an expensive option, |
| 164859 | 165302 | ** so search through the constraints to see if a more efficient |
| 164860 | 165303 | ** strategy is possible. |
| 164861 | 165304 | */ |
| | @@ -165051,11 +165494,15 @@ |
| 165051 | 165494 | pCsr->pStmt = p->pSeekStmt; |
| 165052 | 165495 | p->pSeekStmt = 0; |
| 165053 | 165496 | }else{ |
| 165054 | 165497 | zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); |
| 165055 | 165498 | if( !zSql ) return SQLITE_NOMEM; |
| 165056 | | - rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0); |
| 165499 | + p->bLock++; |
| 165500 | + rc = sqlite3_prepare_v3( |
| 165501 | + p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0 |
| 165502 | + ); |
| 165503 | + p->bLock--; |
| 165057 | 165504 | sqlite3_free(zSql); |
| 165058 | 165505 | } |
| 165059 | 165506 | if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1; |
| 165060 | 165507 | } |
| 165061 | 165508 | return rc; |
| | @@ -165069,15 +165516,19 @@ |
| 165069 | 165516 | static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ |
| 165070 | 165517 | int rc = SQLITE_OK; |
| 165071 | 165518 | if( pCsr->isRequireSeek ){ |
| 165072 | 165519 | rc = fts3CursorSeekStmt(pCsr); |
| 165073 | 165520 | if( rc==SQLITE_OK ){ |
| 165521 | + Fts3Table *pTab = (Fts3Table*)pCsr->base.pVtab; |
| 165522 | + pTab->bLock++; |
| 165074 | 165523 | sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); |
| 165075 | 165524 | pCsr->isRequireSeek = 0; |
| 165076 | 165525 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 165526 | + pTab->bLock--; |
| 165077 | 165527 | return SQLITE_OK; |
| 165078 | 165528 | }else{ |
| 165529 | + pTab->bLock--; |
| 165079 | 165530 | rc = sqlite3_reset(pCsr->pStmt); |
| 165080 | 165531 | if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ |
| 165081 | 165532 | /* If no row was found and no error has occurred, then the %_content |
| 165082 | 165533 | ** table is missing a row that is present in the full-text index. |
| 165083 | 165534 | ** The data structures are corrupt. */ |
| | @@ -165245,11 +165696,11 @@ |
| 165245 | 165696 | |
| 165246 | 165697 | assert( piLeaf || piLeaf2 ); |
| 165247 | 165698 | |
| 165248 | 165699 | fts3GetVarint32(zNode, &iHeight); |
| 165249 | 165700 | rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2); |
| 165250 | | - assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) ); |
| 165701 | + assert_fts3_nc( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) ); |
| 165251 | 165702 | |
| 165252 | 165703 | if( rc==SQLITE_OK && iHeight>1 ){ |
| 165253 | 165704 | char *zBlob = 0; /* Blob read from %_segments table */ |
| 165254 | 165705 | int nBlob = 0; /* Size of zBlob in bytes */ |
| 165255 | 165706 | |
| | @@ -165726,16 +166177,16 @@ |
| 165726 | 166177 | sqlite3_int64 *pVal /* IN/OUT: Integer value */ |
| 165727 | 166178 | ){ |
| 165728 | 166179 | if( *pp>=pEnd ){ |
| 165729 | 166180 | *pp = 0; |
| 165730 | 166181 | }else{ |
| 165731 | | - sqlite3_int64 iVal; |
| 165732 | | - *pp += sqlite3Fts3GetVarint(*pp, &iVal); |
| 166182 | + u64 iVal; |
| 166183 | + *pp += sqlite3Fts3GetVarintU(*pp, &iVal); |
| 165733 | 166184 | if( bDescIdx ){ |
| 165734 | | - *pVal -= iVal; |
| 166185 | + *pVal = (i64)((u64)*pVal - iVal); |
| 165735 | 166186 | }else{ |
| 165736 | | - *pVal += iVal; |
| 166187 | + *pVal = (i64)((u64)*pVal + iVal); |
| 165737 | 166188 | } |
| 165738 | 166189 | } |
| 165739 | 166190 | } |
| 165740 | 166191 | |
| 165741 | 166192 | /* |
| | @@ -165761,14 +166212,14 @@ |
| 165761 | 166212 | sqlite3_int64 iVal /* Write this value to the list */ |
| 165762 | 166213 | ){ |
| 165763 | 166214 | sqlite3_uint64 iWrite; |
| 165764 | 166215 | if( bDescIdx==0 || *pbFirst==0 ){ |
| 165765 | 166216 | assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev ); |
| 165766 | | - iWrite = iVal - *piPrev; |
| 166217 | + iWrite = (u64)iVal - (u64)*piPrev; |
| 165767 | 166218 | }else{ |
| 165768 | 166219 | assert_fts3_nc( *piPrev>=iVal ); |
| 165769 | | - iWrite = *piPrev - iVal; |
| 166220 | + iWrite = (u64)*piPrev - (u64)iVal; |
| 165770 | 166221 | } |
| 165771 | 166222 | assert( *pbFirst || *piPrev==0 ); |
| 165772 | 166223 | assert_fts3_nc( *pbFirst==0 || iWrite>0 ); |
| 165773 | 166224 | *pp += sqlite3Fts3PutVarint(*pp, iWrite); |
| 165774 | 166225 | *piPrev = iVal; |
| | @@ -165783,11 +166234,12 @@ |
| 165783 | 166234 | ** Otherwise, (i2-i1). |
| 165784 | 166235 | ** |
| 165785 | 166236 | ** Using this makes it easier to write code that can merge doclists that are |
| 165786 | 166237 | ** sorted in either ascending or descending order. |
| 165787 | 166238 | */ |
| 165788 | | -#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2)) |
| 166239 | +/* #define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i64)((u64)i1-i2)) */ |
| 166240 | +#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1>i2?1:((i1==i2)?0:-1))) |
| 165789 | 166241 | |
| 165790 | 166242 | /* |
| 165791 | 166243 | ** This function does an "OR" merge of two doclists (output contains all |
| 165792 | 166244 | ** positions contained in either argument doclist). If the docids in the |
| 165793 | 166245 | ** input doclists are sorted in ascending order, parameter bDescDoclist |
| | @@ -166197,11 +166649,11 @@ |
| 166197 | 166649 | ** for the pending-terms. If this is a scan, then this call must be being |
| 166198 | 166650 | ** made by an fts4aux module, not an FTS table. In this case calling |
| 166199 | 166651 | ** Fts3SegReaderPending might segfault, as the data structures used by |
| 166200 | 166652 | ** fts4aux are not completely populated. So it's easiest to filter these |
| 166201 | 166653 | ** calls out here. */ |
| 166202 | | - if( iLevel<0 && p->aIndex ){ |
| 166654 | + if( iLevel<0 && p->aIndex && p->iPrevLangid==iLangid ){ |
| 166203 | 166655 | Fts3SegReader *pSeg = 0; |
| 166204 | 166656 | rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg); |
| 166205 | 166657 | if( rc==SQLITE_OK && pSeg ){ |
| 166206 | 166658 | rc = fts3SegReaderCursorAppend(pCsr, pSeg); |
| 166207 | 166659 | } |
| | @@ -166460,17 +166912,20 @@ |
| 166460 | 166912 | */ |
| 166461 | 166913 | static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){ |
| 166462 | 166914 | int rc; |
| 166463 | 166915 | Fts3Cursor *pCsr = (Fts3Cursor *)pCursor; |
| 166464 | 166916 | if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){ |
| 166917 | + Fts3Table *pTab = (Fts3Table*)pCursor->pVtab; |
| 166918 | + pTab->bLock++; |
| 166465 | 166919 | if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){ |
| 166466 | 166920 | pCsr->isEof = 1; |
| 166467 | 166921 | rc = sqlite3_reset(pCsr->pStmt); |
| 166468 | 166922 | }else{ |
| 166469 | 166923 | pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0); |
| 166470 | 166924 | rc = SQLITE_OK; |
| 166471 | 166925 | } |
| 166926 | + pTab->bLock--; |
| 166472 | 166927 | }else{ |
| 166473 | 166928 | rc = fts3EvalNext((Fts3Cursor *)pCursor); |
| 166474 | 166929 | } |
| 166475 | 166930 | assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); |
| 166476 | 166931 | return rc; |
| | @@ -166526,10 +166981,14 @@ |
| 166526 | 166981 | sqlite3_value *pDocidLe = 0; /* The "docid <= ?" constraint, if any */ |
| 166527 | 166982 | int iIdx; |
| 166528 | 166983 | |
| 166529 | 166984 | UNUSED_PARAMETER(idxStr); |
| 166530 | 166985 | UNUSED_PARAMETER(nVal); |
| 166986 | + |
| 166987 | + if( p->bLock ){ |
| 166988 | + return SQLITE_ERROR; |
| 166989 | + } |
| 166531 | 166990 | |
| 166532 | 166991 | eSearch = (idxNum & 0x0000FFFF); |
| 166533 | 166992 | assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) ); |
| 166534 | 166993 | assert( p->pSegments==0 ); |
| 166535 | 166994 | |
| | @@ -166598,11 +167057,15 @@ |
| 166598 | 167057 | zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s", |
| 166599 | 167058 | p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC") |
| 166600 | 167059 | ); |
| 166601 | 167060 | } |
| 166602 | 167061 | if( zSql ){ |
| 166603 | | - rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0); |
| 167062 | + p->bLock++; |
| 167063 | + rc = sqlite3_prepare_v3( |
| 167064 | + p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0 |
| 167065 | + ); |
| 167066 | + p->bLock--; |
| 166604 | 167067 | sqlite3_free(zSql); |
| 166605 | 167068 | }else{ |
| 166606 | 167069 | rc = SQLITE_NOMEM; |
| 166607 | 167070 | } |
| 166608 | 167071 | }else if( eSearch==FTS3_DOCID_SEARCH ){ |
| | @@ -167757,19 +168220,20 @@ |
| 167757 | 168220 | Fts3Table *pTab, |
| 167758 | 168221 | Fts3Doclist *pDL, |
| 167759 | 168222 | u8 *pbEof |
| 167760 | 168223 | ){ |
| 167761 | 168224 | char *pIter; /* Used to iterate through aAll */ |
| 167762 | | - char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */ |
| 168225 | + char *pEnd; /* 1 byte past end of aAll */ |
| 167763 | 168226 | |
| 167764 | 168227 | if( pDL->pNextDocid ){ |
| 167765 | 168228 | pIter = pDL->pNextDocid; |
| 168229 | + assert( pDL->aAll!=0 || pIter==0 ); |
| 167766 | 168230 | }else{ |
| 167767 | 168231 | pIter = pDL->aAll; |
| 167768 | 168232 | } |
| 167769 | 168233 | |
| 167770 | | - if( pIter>=pEnd ){ |
| 168234 | + if( pIter==0 || pIter>=(pEnd = pDL->aAll + pDL->nAll) ){ |
| 167771 | 168235 | /* We have already reached the end of this doclist. EOF. */ |
| 167772 | 168236 | *pbEof = 1; |
| 167773 | 168237 | }else{ |
| 167774 | 168238 | sqlite3_int64 iDelta; |
| 167775 | 168239 | pIter += sqlite3Fts3GetVarint(pIter, &iDelta); |
| | @@ -174105,11 +174569,11 @@ |
| 174105 | 174569 | int rc = SQLITE_OK; |
| 174106 | 174570 | |
| 174107 | 174571 | assert( !p || p->iLastDocid<=iDocid ); |
| 174108 | 174572 | |
| 174109 | 174573 | if( !p || p->iLastDocid!=iDocid ){ |
| 174110 | | - sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0); |
| 174574 | + u64 iDelta = (u64)iDocid - (u64)(p ? p->iLastDocid : 0); |
| 174111 | 174575 | if( p ){ |
| 174112 | 174576 | assert( p->nData<p->nSpace ); |
| 174113 | 174577 | assert( p->aData[p->nData]==0 ); |
| 174114 | 174578 | p->nData++; |
| 174115 | 174579 | } |
| | @@ -174646,10 +175110,12 @@ |
| 174646 | 175110 | aByte = 0; |
| 174647 | 175111 | } |
| 174648 | 175112 | } |
| 174649 | 175113 | *paBlob = aByte; |
| 174650 | 175114 | } |
| 175115 | + }else if( rc==SQLITE_ERROR ){ |
| 175116 | + rc = FTS_CORRUPT_VTAB; |
| 174651 | 175117 | } |
| 174652 | 175118 | |
| 174653 | 175119 | return rc; |
| 174654 | 175120 | } |
| 174655 | 175121 | |
| | @@ -174938,22 +175404,22 @@ |
| 174938 | 175404 | if( p>=pEnd ){ |
| 174939 | 175405 | pReader->pOffsetList = 0; |
| 174940 | 175406 | }else{ |
| 174941 | 175407 | rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX); |
| 174942 | 175408 | if( rc==SQLITE_OK ){ |
| 174943 | | - sqlite3_int64 iDelta; |
| 174944 | | - pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta); |
| 175409 | + u64 iDelta; |
| 175410 | + pReader->pOffsetList = p + sqlite3Fts3GetVarintU(p, &iDelta); |
| 174945 | 175411 | if( pTab->bDescIdx ){ |
| 174946 | | - pReader->iDocid -= iDelta; |
| 175412 | + pReader->iDocid = (i64)((u64)pReader->iDocid - iDelta); |
| 174947 | 175413 | }else{ |
| 174948 | | - pReader->iDocid += iDelta; |
| 175414 | + pReader->iDocid = (i64)((u64)pReader->iDocid + iDelta); |
| 174949 | 175415 | } |
| 174950 | 175416 | } |
| 174951 | 175417 | } |
| 174952 | 175418 | } |
| 174953 | 175419 | |
| 174954 | | - return SQLITE_OK; |
| 175420 | + return rc; |
| 174955 | 175421 | } |
| 174956 | 175422 | |
| 174957 | 175423 | |
| 174958 | 175424 | SQLITE_PRIVATE int sqlite3Fts3MsrOvfl( |
| 174959 | 175425 | Fts3Cursor *pCsr, |
| | @@ -175688,10 +176154,11 @@ |
| 175688 | 176154 | |
| 175689 | 176155 | if( nData>0 && nData+nReq>p->nNodeSize ){ |
| 175690 | 176156 | int rc; |
| 175691 | 176157 | |
| 175692 | 176158 | /* The current leaf node is full. Write it out to the database. */ |
| 176159 | + if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB; |
| 175693 | 176160 | rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData); |
| 175694 | 176161 | if( rc!=SQLITE_OK ) return rc; |
| 175695 | 176162 | p->nLeafAdd++; |
| 175696 | 176163 | |
| 175697 | 176164 | /* Add the current term to the interior node tree. The term added to |
| | @@ -176385,14 +176852,14 @@ |
| 176385 | 176852 | /* Calculate the 'docid' delta value to write into the merged |
| 176386 | 176853 | ** doclist. */ |
| 176387 | 176854 | sqlite3_int64 iDelta; |
| 176388 | 176855 | if( p->bDescIdx && nDoclist>0 ){ |
| 176389 | 176856 | if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB; |
| 176390 | | - iDelta = iPrev - iDocid; |
| 176857 | + iDelta = (i64)((u64)iPrev - (u64)iDocid); |
| 176391 | 176858 | }else{ |
| 176392 | 176859 | if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB; |
| 176393 | | - iDelta = iDocid - iPrev; |
| 176860 | + iDelta = (i64)((u64)iDocid - (u64)iPrev); |
| 176394 | 176861 | } |
| 176395 | 176862 | |
| 176396 | 176863 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 176397 | 176864 | if( nDoclist+nByte>pCsr->nBuffer ){ |
| 176398 | 176865 | char *aNew; |
| | @@ -176671,11 +177138,11 @@ |
| 176671 | 177138 | if( rc!=SQLITE_ROW ) break; |
| 176672 | 177139 | rc = fts3SegWriterAdd(p, &pWriter, 1, |
| 176673 | 177140 | csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist); |
| 176674 | 177141 | } |
| 176675 | 177142 | if( rc!=SQLITE_OK ) goto finished; |
| 176676 | | - assert( pWriter || bIgnoreEmpty ); |
| 177143 | + assert_fts3_nc( pWriter || bIgnoreEmpty ); |
| 176677 | 177144 | |
| 176678 | 177145 | if( iLevel!=FTS3_SEGCURSOR_PENDING ){ |
| 176679 | 177146 | rc = fts3DeleteSegdir( |
| 176680 | 177147 | p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment |
| 176681 | 177148 | ); |
| | @@ -178257,17 +178724,21 @@ |
| 178257 | 178724 | */ |
| 178258 | 178725 | static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){ |
| 178259 | 178726 | const int nHint = pHint->n; |
| 178260 | 178727 | int i; |
| 178261 | 178728 | |
| 178262 | | - i = pHint->n-2; |
| 178729 | + i = pHint->n-1; |
| 178730 | + if( (pHint->a[i] & 0x80) ) return FTS_CORRUPT_VTAB; |
| 178263 | 178731 | while( i>0 && (pHint->a[i-1] & 0x80) ) i--; |
| 178732 | + if( i==0 ) return FTS_CORRUPT_VTAB; |
| 178733 | + i--; |
| 178264 | 178734 | while( i>0 && (pHint->a[i-1] & 0x80) ) i--; |
| 178265 | 178735 | |
| 178266 | 178736 | pHint->n = i; |
| 178267 | 178737 | i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel); |
| 178268 | 178738 | i += fts3GetVarint32(&pHint->a[i], pnInput); |
| 178739 | + assert( i<=nHint ); |
| 178269 | 178740 | if( i!=nHint ) return FTS_CORRUPT_VTAB; |
| 178270 | 178741 | |
| 178271 | 178742 | return SQLITE_OK; |
| 178272 | 178743 | } |
| 178273 | 178744 | |
| | @@ -178593,28 +179064,28 @@ |
| 178593 | 179064 | char *pCsr = csr.aDoclist; |
| 178594 | 179065 | char *pEnd = &pCsr[csr.nDoclist]; |
| 178595 | 179066 | |
| 178596 | 179067 | i64 iDocid = 0; |
| 178597 | 179068 | i64 iCol = 0; |
| 178598 | | - i64 iPos = 0; |
| 179069 | + u64 iPos = 0; |
| 178599 | 179070 | |
| 178600 | 179071 | pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid); |
| 178601 | 179072 | while( pCsr<pEnd ){ |
| 178602 | | - i64 iVal = 0; |
| 178603 | | - pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); |
| 179073 | + u64 iVal = 0; |
| 179074 | + pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal); |
| 178604 | 179075 | if( pCsr<pEnd ){ |
| 178605 | 179076 | if( iVal==0 || iVal==1 ){ |
| 178606 | 179077 | iCol = 0; |
| 178607 | 179078 | iPos = 0; |
| 178608 | 179079 | if( iVal ){ |
| 178609 | 179080 | pCsr += sqlite3Fts3GetVarint(pCsr, &iCol); |
| 178610 | 179081 | }else{ |
| 178611 | | - pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); |
| 179082 | + pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal); |
| 178612 | 179083 | if( p->bDescIdx ){ |
| 178613 | | - iDocid -= iVal; |
| 179084 | + iDocid = (i64)((u64)iDocid - iVal); |
| 178614 | 179085 | }else{ |
| 178615 | | - iDocid += iVal; |
| 179086 | + iDocid = (i64)((u64)iDocid + iVal); |
| 178616 | 179087 | } |
| 178617 | 179088 | } |
| 178618 | 179089 | }else{ |
| 178619 | 179090 | iPos += (iVal - 2); |
| 178620 | 179091 | cksum = cksum ^ fts3ChecksumEntry( |
| | @@ -182886,22 +183357,53 @@ |
| 182886 | 183357 | pRoot->jnFlags |= JNODE_APPEND; |
| 182887 | 183358 | pParse->aNode[iLabel].jnFlags |= JNODE_RAW; |
| 182888 | 183359 | } |
| 182889 | 183360 | return pNode; |
| 182890 | 183361 | } |
| 182891 | | - }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){ |
| 182892 | | - if( pRoot->eType!=JSON_ARRAY ) return 0; |
| 183362 | + }else if( zPath[0]=='[' ){ |
| 182893 | 183363 | i = 0; |
| 182894 | 183364 | j = 1; |
| 182895 | 183365 | while( safe_isdigit(zPath[j]) ){ |
| 182896 | 183366 | i = i*10 + zPath[j] - '0'; |
| 182897 | 183367 | j++; |
| 182898 | 183368 | } |
| 182899 | | - if( zPath[j]!=']' ){ |
| 182900 | | - *pzErr = zPath; |
| 182901 | | - return 0; |
| 183369 | + if( j<2 || zPath[j]!=']' ){ |
| 183370 | + if( zPath[1]=='#' ){ |
| 183371 | + JsonNode *pBase = pRoot; |
| 183372 | + int iBase = iRoot; |
| 183373 | + if( pRoot->eType!=JSON_ARRAY ) return 0; |
| 183374 | + for(;;){ |
| 183375 | + while( j<=pBase->n ){ |
| 183376 | + if( (pBase[j].jnFlags & JNODE_REMOVE)==0 ) i++; |
| 183377 | + j += jsonNodeSize(&pBase[j]); |
| 183378 | + } |
| 183379 | + if( (pBase->jnFlags & JNODE_APPEND)==0 ) break; |
| 183380 | + iBase += pBase->u.iAppend; |
| 183381 | + pBase = &pParse->aNode[iBase]; |
| 183382 | + j = 1; |
| 183383 | + } |
| 183384 | + j = 2; |
| 183385 | + if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){ |
| 183386 | + unsigned int x = 0; |
| 183387 | + j = 3; |
| 183388 | + do{ |
| 183389 | + x = x*10 + zPath[j] - '0'; |
| 183390 | + j++; |
| 183391 | + }while( safe_isdigit(zPath[j]) ); |
| 183392 | + if( x>i ) return 0; |
| 183393 | + i -= x; |
| 183394 | + } |
| 183395 | + if( zPath[j]!=']' ){ |
| 183396 | + *pzErr = zPath; |
| 183397 | + return 0; |
| 183398 | + } |
| 183399 | + }else{ |
| 183400 | + *pzErr = zPath; |
| 183401 | + return 0; |
| 183402 | + } |
| 182902 | 183403 | } |
| 183404 | + if( pRoot->eType!=JSON_ARRAY ) return 0; |
| 182903 | 183405 | zPath += j + 1; |
| 182904 | 183406 | j = 1; |
| 182905 | 183407 | for(;;){ |
| 182906 | 183408 | while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){ |
| 182907 | 183409 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--; |
| | @@ -184365,10 +184867,11 @@ |
| 184365 | 184867 | /* #include "sqlite3ext.h" */ |
| 184366 | 184868 | SQLITE_EXTENSION_INIT1 |
| 184367 | 184869 | #else |
| 184368 | 184870 | /* #include "sqlite3.h" */ |
| 184369 | 184871 | #endif |
| 184872 | +SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */ |
| 184370 | 184873 | |
| 184371 | 184874 | #ifndef SQLITE_AMALGAMATION |
| 184372 | 184875 | #include "sqlite3rtree.h" |
| 184373 | 184876 | typedef sqlite3_int64 i64; |
| 184374 | 184877 | typedef sqlite3_uint64 u64; |
| | @@ -184628,10 +185131,16 @@ |
| 184628 | 185131 | #define RTREE_GE 0x44 /* D */ |
| 184629 | 185132 | #define RTREE_GT 0x45 /* E */ |
| 184630 | 185133 | #define RTREE_MATCH 0x46 /* F: Old-style sqlite3_rtree_geometry_callback() */ |
| 184631 | 185134 | #define RTREE_QUERY 0x47 /* G: New-style sqlite3_rtree_query_callback() */ |
| 184632 | 185135 | |
| 185136 | +/* Special operators available only on cursors. Needs to be consecutive |
| 185137 | +** with the normal values above, but must be less than RTREE_MATCH. These |
| 185138 | +** are used in the cursor for contraints such as x=NULL (RTREE_FALSE) or |
| 185139 | +** x<'xyz' (RTREE_TRUE) */ |
| 185140 | +#define RTREE_TRUE 0x3f /* ? */ |
| 185141 | +#define RTREE_FALSE 0x40 /* @ */ |
| 184633 | 185142 | |
| 184634 | 185143 | /* |
| 184635 | 185144 | ** An rtree structure node. |
| 184636 | 185145 | */ |
| 184637 | 185146 | struct RtreeNode { |
| | @@ -185361,13 +185870,16 @@ |
| 185361 | 185870 | return rc; |
| 185362 | 185871 | } |
| 185363 | 185872 | |
| 185364 | 185873 | |
| 185365 | 185874 | /* |
| 185366 | | -** Free the RtreeCursor.aConstraint[] array and its contents. |
| 185875 | +** Reset a cursor back to its initial state. |
| 185367 | 185876 | */ |
| 185368 | | -static void freeCursorConstraints(RtreeCursor *pCsr){ |
| 185877 | +static void resetCursor(RtreeCursor *pCsr){ |
| 185878 | + Rtree *pRtree = (Rtree *)(pCsr->base.pVtab); |
| 185879 | + int ii; |
| 185880 | + sqlite3_stmt *pStmt; |
| 185369 | 185881 | if( pCsr->aConstraint ){ |
| 185370 | 185882 | int i; /* Used to iterate through constraint array */ |
| 185371 | 185883 | for(i=0; i<pCsr->nConstraint; i++){ |
| 185372 | 185884 | sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo; |
| 185373 | 185885 | if( pInfo ){ |
| | @@ -185376,24 +185888,28 @@ |
| 185376 | 185888 | } |
| 185377 | 185889 | } |
| 185378 | 185890 | sqlite3_free(pCsr->aConstraint); |
| 185379 | 185891 | pCsr->aConstraint = 0; |
| 185380 | 185892 | } |
| 185893 | + for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]); |
| 185894 | + sqlite3_free(pCsr->aPoint); |
| 185895 | + pStmt = pCsr->pReadAux; |
| 185896 | + memset(pCsr, 0, sizeof(RtreeCursor)); |
| 185897 | + pCsr->base.pVtab = (sqlite3_vtab*)pRtree; |
| 185898 | + pCsr->pReadAux = pStmt; |
| 185899 | + |
| 185381 | 185900 | } |
| 185382 | 185901 | |
| 185383 | 185902 | /* |
| 185384 | 185903 | ** Rtree virtual table module xClose method. |
| 185385 | 185904 | */ |
| 185386 | 185905 | static int rtreeClose(sqlite3_vtab_cursor *cur){ |
| 185387 | 185906 | Rtree *pRtree = (Rtree *)(cur->pVtab); |
| 185388 | | - int ii; |
| 185389 | 185907 | RtreeCursor *pCsr = (RtreeCursor *)cur; |
| 185390 | 185908 | assert( pRtree->nCursor>0 ); |
| 185391 | | - freeCursorConstraints(pCsr); |
| 185909 | + resetCursor(pCsr); |
| 185392 | 185910 | sqlite3_finalize(pCsr->pReadAux); |
| 185393 | | - sqlite3_free(pCsr->aPoint); |
| 185394 | | - for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]); |
| 185395 | 185911 | sqlite3_free(pCsr); |
| 185396 | 185912 | pRtree->nCursor--; |
| 185397 | 185913 | nodeBlobReset(pRtree); |
| 185398 | 185914 | return SQLITE_OK; |
| 185399 | 185915 | } |
| | @@ -185547,13 +186063,16 @@ |
| 185547 | 186063 | ** in a coordinate pair. But make pCellData point to the lower bound. |
| 185548 | 186064 | */ |
| 185549 | 186065 | pCellData += 8 + 4*(p->iCoord&0xfe); |
| 185550 | 186066 | |
| 185551 | 186067 | assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE |
| 185552 | | - || p->op==RTREE_GT || p->op==RTREE_EQ ); |
| 186068 | + || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE |
| 186069 | + || p->op==RTREE_FALSE ); |
| 185553 | 186070 | assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ |
| 185554 | 186071 | switch( p->op ){ |
| 186072 | + case RTREE_TRUE: return; /* Always satisfied */ |
| 186073 | + case RTREE_FALSE: break; /* Never satisfied */ |
| 185555 | 186074 | case RTREE_LE: |
| 185556 | 186075 | case RTREE_LT: |
| 185557 | 186076 | case RTREE_EQ: |
| 185558 | 186077 | RTREE_DECODE_COORD(eInt, pCellData, val); |
| 185559 | 186078 | /* val now holds the lower bound of the coordinate pair */ |
| | @@ -185587,20 +186106,23 @@ |
| 185587 | 186106 | int *peWithin /* Adjust downward, as appropriate */ |
| 185588 | 186107 | ){ |
| 185589 | 186108 | RtreeDValue xN; /* Coordinate value converted to a double */ |
| 185590 | 186109 | |
| 185591 | 186110 | assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE |
| 185592 | | - || p->op==RTREE_GT || p->op==RTREE_EQ ); |
| 186111 | + || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE |
| 186112 | + || p->op==RTREE_FALSE ); |
| 185593 | 186113 | pCellData += 8 + p->iCoord*4; |
| 185594 | 186114 | assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ |
| 185595 | 186115 | RTREE_DECODE_COORD(eInt, pCellData, xN); |
| 185596 | 186116 | switch( p->op ){ |
| 185597 | | - case RTREE_LE: if( xN <= p->u.rValue ) return; break; |
| 185598 | | - case RTREE_LT: if( xN < p->u.rValue ) return; break; |
| 185599 | | - case RTREE_GE: if( xN >= p->u.rValue ) return; break; |
| 185600 | | - case RTREE_GT: if( xN > p->u.rValue ) return; break; |
| 185601 | | - default: if( xN == p->u.rValue ) return; break; |
| 186117 | + case RTREE_TRUE: return; /* Always satisfied */ |
| 186118 | + case RTREE_FALSE: break; /* Never satisfied */ |
| 186119 | + case RTREE_LE: if( xN <= p->u.rValue ) return; break; |
| 186120 | + case RTREE_LT: if( xN < p->u.rValue ) return; break; |
| 186121 | + case RTREE_GE: if( xN >= p->u.rValue ) return; break; |
| 186122 | + case RTREE_GT: if( xN > p->u.rValue ) return; break; |
| 186123 | + default: if( xN == p->u.rValue ) return; break; |
| 185602 | 186124 | } |
| 185603 | 186125 | *peWithin = NOT_WITHIN; |
| 185604 | 186126 | } |
| 185605 | 186127 | |
| 185606 | 186128 | /* |
| | @@ -186089,30 +186611,32 @@ |
| 186089 | 186611 | RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; |
| 186090 | 186612 | RtreeNode *pRoot = 0; |
| 186091 | 186613 | int ii; |
| 186092 | 186614 | int rc = SQLITE_OK; |
| 186093 | 186615 | int iCell = 0; |
| 186094 | | - sqlite3_stmt *pStmt; |
| 186095 | 186616 | |
| 186096 | 186617 | rtreeReference(pRtree); |
| 186097 | 186618 | |
| 186098 | 186619 | /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ |
| 186099 | | - freeCursorConstraints(pCsr); |
| 186100 | | - sqlite3_free(pCsr->aPoint); |
| 186101 | | - pStmt = pCsr->pReadAux; |
| 186102 | | - memset(pCsr, 0, sizeof(RtreeCursor)); |
| 186103 | | - pCsr->base.pVtab = (sqlite3_vtab*)pRtree; |
| 186104 | | - pCsr->pReadAux = pStmt; |
| 186620 | + resetCursor(pCsr); |
| 186105 | 186621 | |
| 186106 | 186622 | pCsr->iStrategy = idxNum; |
| 186107 | 186623 | if( idxNum==1 ){ |
| 186108 | 186624 | /* Special case - lookup by rowid. */ |
| 186109 | 186625 | RtreeNode *pLeaf; /* Leaf on which the required cell resides */ |
| 186110 | 186626 | RtreeSearchPoint *p; /* Search point for the leaf */ |
| 186111 | 186627 | i64 iRowid = sqlite3_value_int64(argv[0]); |
| 186112 | 186628 | i64 iNode = 0; |
| 186113 | | - rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); |
| 186629 | + int eType = sqlite3_value_numeric_type(argv[0]); |
| 186630 | + if( eType==SQLITE_INTEGER |
| 186631 | + || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid) |
| 186632 | + ){ |
| 186633 | + rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); |
| 186634 | + }else{ |
| 186635 | + rc = SQLITE_OK; |
| 186636 | + pLeaf = 0; |
| 186637 | + } |
| 186114 | 186638 | if( rc==SQLITE_OK && pLeaf!=0 ){ |
| 186115 | 186639 | p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0); |
| 186116 | 186640 | assert( p!=0 ); /* Always returns pCsr->sPoint */ |
| 186117 | 186641 | pCsr->aNode[0] = pLeaf; |
| 186118 | 186642 | p->id = iNode; |
| | @@ -186138,10 +186662,11 @@ |
| 186138 | 186662 | memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1)); |
| 186139 | 186663 | assert( (idxStr==0 && argc==0) |
| 186140 | 186664 | || (idxStr && (int)strlen(idxStr)==argc*2) ); |
| 186141 | 186665 | for(ii=0; ii<argc; ii++){ |
| 186142 | 186666 | RtreeConstraint *p = &pCsr->aConstraint[ii]; |
| 186667 | + int eType = sqlite3_value_numeric_type(argv[ii]); |
| 186143 | 186668 | p->op = idxStr[ii*2]; |
| 186144 | 186669 | p->iCoord = idxStr[ii*2+1]-'0'; |
| 186145 | 186670 | if( p->op>=RTREE_MATCH ){ |
| 186146 | 186671 | /* A MATCH operator. The right-hand-side must be a blob that |
| 186147 | 186672 | ** can be cast into an RtreeMatchArg object. One created using |
| | @@ -186152,16 +186677,25 @@ |
| 186152 | 186677 | break; |
| 186153 | 186678 | } |
| 186154 | 186679 | p->pInfo->nCoord = pRtree->nDim2; |
| 186155 | 186680 | p->pInfo->anQueue = pCsr->anQueue; |
| 186156 | 186681 | p->pInfo->mxLevel = pRtree->iDepth + 1; |
| 186157 | | - }else{ |
| 186682 | + }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 186158 | 186683 | #ifdef SQLITE_RTREE_INT_ONLY |
| 186159 | 186684 | p->u.rValue = sqlite3_value_int64(argv[ii]); |
| 186160 | 186685 | #else |
| 186161 | 186686 | p->u.rValue = sqlite3_value_double(argv[ii]); |
| 186162 | 186687 | #endif |
| 186688 | + }else{ |
| 186689 | + p->u.rValue = RTREE_ZERO; |
| 186690 | + if( eType==SQLITE_NULL ){ |
| 186691 | + p->op = RTREE_FALSE; |
| 186692 | + }else if( p->op==RTREE_LT || p->op==RTREE_LE ){ |
| 186693 | + p->op = RTREE_TRUE; |
| 186694 | + }else{ |
| 186695 | + p->op = RTREE_FALSE; |
| 186696 | + } |
| 186163 | 186697 | } |
| 186164 | 186698 | } |
| 186165 | 186699 | } |
| 186166 | 186700 | } |
| 186167 | 186701 | if( rc==SQLITE_OK ){ |
| | @@ -187933,10 +188467,18 @@ |
| 187933 | 188467 | } |
| 187934 | 188468 | |
| 187935 | 188469 | sqlite3_free(zSql); |
| 187936 | 188470 | return rc; |
| 187937 | 188471 | } |
| 188472 | + |
| 188473 | +/* |
| 188474 | +** Return the length of a token |
| 188475 | +*/ |
| 188476 | +static int rtreeTokenLength(const char *z){ |
| 188477 | + int dummy = 0; |
| 188478 | + return sqlite3GetToken((const unsigned char*)z,&dummy); |
| 188479 | +} |
| 187938 | 188480 | |
| 187939 | 188481 | /* |
| 187940 | 188482 | ** This function is the implementation of both the xConnect and xCreate |
| 187941 | 188483 | ** methods of the r-tree virtual table. |
| 187942 | 188484 | ** |
| | @@ -187970,12 +188512,12 @@ |
| 187970 | 188512 | "Too many columns for an rtree table", /* 3 */ |
| 187971 | 188513 | "Auxiliary rtree columns must be last" /* 4 */ |
| 187972 | 188514 | }; |
| 187973 | 188515 | |
| 187974 | 188516 | assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */ |
| 187975 | | - if( argc>RTREE_MAX_AUX_COLUMN+3 ){ |
| 187976 | | - *pzErr = sqlite3_mprintf("%s", aErrMsg[3]); |
| 188517 | + if( argc<6 || argc>RTREE_MAX_AUX_COLUMN+3 ){ |
| 188518 | + *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]); |
| 187977 | 188519 | return SQLITE_ERROR; |
| 187978 | 188520 | } |
| 187979 | 188521 | |
| 187980 | 188522 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 187981 | 188523 | |
| | @@ -187999,20 +188541,22 @@ |
| 187999 | 188541 | /* Create/Connect to the underlying relational database schema. If |
| 188000 | 188542 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 188001 | 188543 | ** the r-tree table schema. |
| 188002 | 188544 | */ |
| 188003 | 188545 | pSql = sqlite3_str_new(db); |
| 188004 | | - sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]); |
| 188546 | + sqlite3_str_appendf(pSql, "CREATE TABLE x(%.*s INT", |
| 188547 | + rtreeTokenLength(argv[3]), argv[3]); |
| 188005 | 188548 | for(ii=4; ii<argc; ii++){ |
| 188006 | | - if( argv[ii][0]=='+' ){ |
| 188549 | + const char *zArg = argv[ii]; |
| 188550 | + if( zArg[0]=='+' ){ |
| 188007 | 188551 | pRtree->nAux++; |
| 188008 | | - sqlite3_str_appendf(pSql, ",%s", argv[ii]+1); |
| 188552 | + sqlite3_str_appendf(pSql, ",%.*s", rtreeTokenLength(zArg+1), zArg+1); |
| 188009 | 188553 | }else if( pRtree->nAux>0 ){ |
| 188010 | 188554 | break; |
| 188011 | 188555 | }else{ |
| 188012 | 188556 | pRtree->nDim2++; |
| 188013 | | - sqlite3_str_appendf(pSql, ",%s", argv[ii]); |
| 188557 | + sqlite3_str_appendf(pSql, ",%.*s NUM", rtreeTokenLength(zArg), zArg); |
| 188014 | 188558 | } |
| 188015 | 188559 | } |
| 188016 | 188560 | sqlite3_str_appendf(pSql, ");"); |
| 188017 | 188561 | zSql = sqlite3_str_finish(pSql); |
| 188018 | 188562 | if( !zSql ){ |
| | @@ -189956,21 +190500,15 @@ |
| 189956 | 190500 | Rtree *pRtree = (Rtree *)pVtabCursor->pVtab; |
| 189957 | 190501 | RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; |
| 189958 | 190502 | RtreeNode *pRoot = 0; |
| 189959 | 190503 | int rc = SQLITE_OK; |
| 189960 | 190504 | int iCell = 0; |
| 189961 | | - sqlite3_stmt *pStmt; |
| 189962 | 190505 | |
| 189963 | 190506 | rtreeReference(pRtree); |
| 189964 | 190507 | |
| 189965 | 190508 | /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ |
| 189966 | | - freeCursorConstraints(pCsr); |
| 189967 | | - sqlite3_free(pCsr->aPoint); |
| 189968 | | - pStmt = pCsr->pReadAux; |
| 189969 | | - memset(pCsr, 0, sizeof(RtreeCursor)); |
| 189970 | | - pCsr->base.pVtab = (sqlite3_vtab*)pRtree; |
| 189971 | | - pCsr->pReadAux = pStmt; |
| 190509 | + resetCursor(pCsr); |
| 189972 | 190510 | |
| 189973 | 190511 | pCsr->iStrategy = idxNum; |
| 189974 | 190512 | if( idxNum==1 ){ |
| 189975 | 190513 | /* Special case - lookup by rowid. */ |
| 189976 | 190514 | RtreeNode *pLeaf; /* Leaf on which the required cell resides */ |
| | @@ -196990,11 +197528,11 @@ |
| 196990 | 197528 | } |
| 196991 | 197529 | z += 2; |
| 196992 | 197530 | }else{ |
| 196993 | 197531 | while( *z==0 ) z++; |
| 196994 | 197532 | } |
| 196995 | | - z += (n + 8 + 1); |
| 197533 | + z += (n + 8 + 2); |
| 196996 | 197534 | return z; |
| 196997 | 197535 | } |
| 196998 | 197536 | |
| 196999 | 197537 | /* |
| 197000 | 197538 | ** Open an rbu file handle. |
| | @@ -204281,11 +204819,11 @@ |
| 204281 | 204819 | ** the callback, an SQLite error code is returned. |
| 204282 | 204820 | ** |
| 204283 | 204821 | ** |
| 204284 | 204822 | ** xSetAuxdata(pFts5, pAux, xDelete) |
| 204285 | 204823 | ** |
| 204286 | | -** Save the pointer passed as the second argument as the extension functions |
| 204824 | +** Save the pointer passed as the second argument as the extension function's |
| 204287 | 204825 | ** "auxiliary data". The pointer may then be retrieved by the current or any |
| 204288 | 204826 | ** future invocation of the same fts5 extension function made as part of |
| 204289 | 204827 | ** the same MATCH query using the xGetAuxdata() API. |
| 204290 | 204828 | ** |
| 204291 | 204829 | ** Each extension function is allocated a single auxiliary data slot for |
| | @@ -204523,12 +205061,12 @@ |
| 204523 | 205061 | ** all instances of "first place" or "1st place" regardless of which form |
| 204524 | 205062 | ** the user specified in the MATCH query text. |
| 204525 | 205063 | ** |
| 204526 | 205064 | ** There are several ways to approach this in FTS5: |
| 204527 | 205065 | ** |
| 204528 | | -** <ol><li> By mapping all synonyms to a single token. In this case, the |
| 204529 | | -** In the above example, this means that the tokenizer returns the |
| 205066 | +** <ol><li> By mapping all synonyms to a single token. In this case, using |
| 205067 | +** the above example, this means that the tokenizer returns the |
| 204530 | 205068 | ** same token for inputs "first" and "1st". Say that token is in |
| 204531 | 205069 | ** fact "first", so that when the user inserts the document "I won |
| 204532 | 205070 | ** 1st place" entries are added to the index for tokens "i", "won", |
| 204533 | 205071 | ** "first" and "place". If the user then queries for '1st + place', |
| 204534 | 205072 | ** the tokenizer substitutes "first" for "1st" and the query works |
| | @@ -205685,10 +206223,11 @@ |
| 205685 | 206223 | #define sqlite3Fts5ParserCTX_PARAM |
| 205686 | 206224 | #define sqlite3Fts5ParserCTX_FETCH |
| 205687 | 206225 | #define sqlite3Fts5ParserCTX_STORE |
| 205688 | 206226 | #define fts5YYNSTATE 35 |
| 205689 | 206227 | #define fts5YYNRULE 28 |
| 206228 | +#define fts5YYNRULE_WITH_ACTION 28 |
| 205690 | 206229 | #define fts5YYNFTS5TOKEN 16 |
| 205691 | 206230 | #define fts5YY_MAX_SHIFT 34 |
| 205692 | 206231 | #define fts5YY_MIN_SHIFTREDUCE 52 |
| 205693 | 206232 | #define fts5YY_MAX_SHIFTREDUCE 79 |
| 205694 | 206233 | #define fts5YY_ERROR_ACTION 80 |
| | @@ -206514,16 +207053,19 @@ |
| 206514 | 207053 | fts5yymsp = fts5yypParser->fts5yytos; |
| 206515 | 207054 | #ifndef NDEBUG |
| 206516 | 207055 | if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ |
| 206517 | 207056 | fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; |
| 206518 | 207057 | if( fts5yysize ){ |
| 206519 | | - fprintf(fts5yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", |
| 207058 | + fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 206520 | 207059 | fts5yyTracePrompt, |
| 206521 | | - fts5yyruleno, fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno); |
| 207060 | + fts5yyruleno, fts5yyRuleName[fts5yyruleno], |
| 207061 | + fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action", |
| 207062 | + fts5yymsp[fts5yysize].stateno); |
| 206522 | 207063 | }else{ |
| 206523 | | - fprintf(fts5yyTraceFILE, "%sReduce %d [%s].\n", |
| 206524 | | - fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno]); |
| 207064 | + fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s.\n", |
| 207065 | + fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno], |
| 207066 | + fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action"); |
| 206525 | 207067 | } |
| 206526 | 207068 | } |
| 206527 | 207069 | #endif /* NDEBUG */ |
| 206528 | 207070 | |
| 206529 | 207071 | /* Check that the stack is large enough to grow by a single entry |
| | @@ -208278,11 +208820,11 @@ |
| 208278 | 208820 | |
| 208279 | 208821 | /* Set stack variable q to the close-quote character */ |
| 208280 | 208822 | assert( q=='[' || q=='\'' || q=='"' || q=='`' ); |
| 208281 | 208823 | if( q=='[' ) q = ']'; |
| 208282 | 208824 | |
| 208283 | | - while( ALWAYS(z[iIn]) ){ |
| 208825 | + while( z[iIn] ){ |
| 208284 | 208826 | if( z[iIn]==q ){ |
| 208285 | 208827 | if( z[iIn+1]!=q ){ |
| 208286 | 208828 | /* Character iIn was the close quote. */ |
| 208287 | 208829 | iIn++; |
| 208288 | 208830 | break; |
| | @@ -211607,14 +212149,16 @@ |
| 211607 | 212149 | } |
| 211608 | 212150 | azConfig[0] = 0; |
| 211609 | 212151 | azConfig[1] = "main"; |
| 211610 | 212152 | azConfig[2] = "tbl"; |
| 211611 | 212153 | for(i=3; iArg<nArg; iArg++){ |
| 211612 | | - azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]); |
| 212154 | + const char *z = (const char*)sqlite3_value_text(apVal[iArg]); |
| 212155 | + azConfig[i++] = (z ? z : ""); |
| 211613 | 212156 | } |
| 211614 | 212157 | |
| 211615 | 212158 | zExpr = (const char*)sqlite3_value_text(apVal[0]); |
| 212159 | + if( zExpr==0 ) zExpr = ""; |
| 211616 | 212160 | |
| 211617 | 212161 | rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr); |
| 211618 | 212162 | if( rc==SQLITE_OK ){ |
| 211619 | 212163 | rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr); |
| 211620 | 212164 | } |
| | @@ -217860,14 +218404,17 @@ |
| 217860 | 218404 | int n = 0; |
| 217861 | 218405 | int i; |
| 217862 | 218406 | for(i=0; i<nChar; i++){ |
| 217863 | 218407 | if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */ |
| 217864 | 218408 | if( (unsigned char)p[n++]>=0xc0 ){ |
| 217865 | | - if( n>=nByte ) break; |
| 218409 | + if( n>=nByte ) return 0; |
| 217866 | 218410 | while( (p[n] & 0xc0)==0x80 ){ |
| 217867 | 218411 | n++; |
| 217868 | | - if( n>=nByte ) break; |
| 218412 | + if( n>=nByte ){ |
| 218413 | + if( i+1==nChar ) break; |
| 218414 | + return 0; |
| 218415 | + } |
| 217869 | 218416 | } |
| 217870 | 218417 | } |
| 217871 | 218418 | } |
| 217872 | 218419 | return n; |
| 217873 | 218420 | } |
| | @@ -218265,10 +218812,41 @@ |
| 218265 | 218812 | |
| 218266 | 218813 | *pCksum = cksum; |
| 218267 | 218814 | return rc; |
| 218268 | 218815 | } |
| 218269 | 218816 | |
| 218817 | +/* |
| 218818 | +** Check if buffer z[], size n bytes, contains as series of valid utf-8 |
| 218819 | +** encoded codepoints. If so, return 0. Otherwise, if the buffer does not |
| 218820 | +** contain valid utf-8, return non-zero. |
| 218821 | +*/ |
| 218822 | +static int fts5TestUtf8(const char *z, int n){ |
| 218823 | + assert_nc( n>0 ); |
| 218824 | + int i = 0; |
| 218825 | + while( i<n ){ |
| 218826 | + if( (z[i] & 0x80)==0x00 ){ |
| 218827 | + i++; |
| 218828 | + }else |
| 218829 | + if( (z[i] & 0xE0)==0xC0 ){ |
| 218830 | + if( i+1>=n || (z[i+1] & 0xC0)!=0x80 ) return 1; |
| 218831 | + i += 2; |
| 218832 | + }else |
| 218833 | + if( (z[i] & 0xF0)==0xE0 ){ |
| 218834 | + if( i+2>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1; |
| 218835 | + i += 3; |
| 218836 | + }else |
| 218837 | + if( (z[i] & 0xF8)==0xF0 ){ |
| 218838 | + if( i+3>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1; |
| 218839 | + if( (z[i+2] & 0xC0)!=0x80 ) return 1; |
| 218840 | + i += 3; |
| 218841 | + }else{ |
| 218842 | + return 1; |
| 218843 | + } |
| 218844 | + } |
| 218845 | + |
| 218846 | + return 0; |
| 218847 | +} |
| 218270 | 218848 | |
| 218271 | 218849 | /* |
| 218272 | 218850 | ** This function is also purely an internal test. It does not contribute to |
| 218273 | 218851 | ** FTS functionality, or even the integrity-check, in any way. |
| 218274 | 218852 | */ |
| | @@ -218305,12 +218883,18 @@ |
| 218305 | 218883 | ** the index is disabled are the same. In both ASC and DESC order. |
| 218306 | 218884 | ** |
| 218307 | 218885 | ** This check may only be performed if the hash table is empty. This |
| 218308 | 218886 | ** is because the hash table only supports a single scan query at |
| 218309 | 218887 | ** a time, and the multi-iter loop from which this function is called |
| 218310 | | - ** is already performing such a scan. */ |
| 218311 | | - if( p->nPendingData==0 ){ |
| 218888 | + ** is already performing such a scan. |
| 218889 | + ** |
| 218890 | + ** Also only do this if buffer zTerm contains nTerm bytes of valid |
| 218891 | + ** utf-8. Otherwise, the last part of the buffer contents might contain |
| 218892 | + ** a non-utf-8 sequence that happens to be a prefix of a valid utf-8 |
| 218893 | + ** character stored in the main fts index, which will cause the |
| 218894 | + ** test to fail. */ |
| 218895 | + if( p->nPendingData==0 && 0==fts5TestUtf8(zTerm, nTerm) ){ |
| 218312 | 218896 | if( iIdx>0 && rc==SQLITE_OK ){ |
| 218313 | 218897 | int f = flags|FTS5INDEX_QUERY_TEST_NOIDX; |
| 218314 | 218898 | ck2 = 0; |
| 218315 | 218899 | rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2); |
| 218316 | 218900 | if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT; |
| | @@ -218439,12 +219023,12 @@ |
| 218439 | 219023 | /* Iterate through the b-tree hierarchy. */ |
| 218440 | 219024 | while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 218441 | 219025 | i64 iRow; /* Rowid for this leaf */ |
| 218442 | 219026 | Fts5Data *pLeaf; /* Data for this leaf */ |
| 218443 | 219027 | |
| 219028 | + const char *zIdxTerm = (const char*)sqlite3_column_blob(pStmt, 1); |
| 218444 | 219029 | int nIdxTerm = sqlite3_column_bytes(pStmt, 1); |
| 218445 | | - const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1); |
| 218446 | 219030 | int iIdxLeaf = sqlite3_column_int(pStmt, 2); |
| 218447 | 219031 | int bIdxDlidx = sqlite3_column_int(pStmt, 3); |
| 218448 | 219032 | |
| 218449 | 219033 | /* If the leaf in question has already been trimmed from the segment, |
| 218450 | 219034 | ** ignore this b-tree entry. Otherwise, load it into memory. */ |
| | @@ -220027,19 +220611,28 @@ |
| 220027 | 220611 | case FTS5_PLAN_SORTED_MATCH: { |
| 220028 | 220612 | rc = fts5SorterNext(pCsr); |
| 220029 | 220613 | break; |
| 220030 | 220614 | } |
| 220031 | 220615 | |
| 220032 | | - default: |
| 220616 | + default: { |
| 220617 | + Fts5Config *pConfig = ((Fts5Table*)pCursor->pVtab)->pConfig; |
| 220618 | + pConfig->bLock++; |
| 220033 | 220619 | rc = sqlite3_step(pCsr->pStmt); |
| 220620 | + pConfig->bLock--; |
| 220034 | 220621 | if( rc!=SQLITE_ROW ){ |
| 220035 | 220622 | CsrFlagSet(pCsr, FTS5CSR_EOF); |
| 220036 | 220623 | rc = sqlite3_reset(pCsr->pStmt); |
| 220624 | + if( rc!=SQLITE_OK ){ |
| 220625 | + pCursor->pVtab->zErrMsg = sqlite3_mprintf( |
| 220626 | + "%s", sqlite3_errmsg(pConfig->db) |
| 220627 | + ); |
| 220628 | + } |
| 220037 | 220629 | }else{ |
| 220038 | 220630 | rc = SQLITE_OK; |
| 220039 | 220631 | } |
| 220040 | 220632 | break; |
| 220633 | + } |
| 220041 | 220634 | } |
| 220042 | 220635 | } |
| 220043 | 220636 | |
| 220044 | 220637 | return rc; |
| 220045 | 220638 | } |
| | @@ -220319,10 +220912,17 @@ |
| 220319 | 220912 | int iCol; /* Column on LHS of MATCH operator */ |
| 220320 | 220913 | char **pzErrmsg = pConfig->pzErrmsg; |
| 220321 | 220914 | int i; |
| 220322 | 220915 | int iIdxStr = 0; |
| 220323 | 220916 | Fts5Expr *pExpr = 0; |
| 220917 | + |
| 220918 | + if( pConfig->bLock ){ |
| 220919 | + pTab->p.base.zErrMsg = sqlite3_mprintf( |
| 220920 | + "recursively defined fts5 content table" |
| 220921 | + ); |
| 220922 | + return SQLITE_ERROR; |
| 220923 | + } |
| 220324 | 220924 | |
| 220325 | 220925 | if( pCsr->ePlan ){ |
| 220326 | 220926 | fts5FreeCursorComponents(pCsr); |
| 220327 | 220927 | memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr)); |
| 220328 | 220928 | } |
| | @@ -220540,21 +221140,28 @@ |
| 220540 | 221140 | assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 ); |
| 220541 | 221141 | assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ); |
| 220542 | 221142 | } |
| 220543 | 221143 | |
| 220544 | 221144 | if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){ |
| 221145 | + Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); |
| 220545 | 221146 | assert( pCsr->pExpr ); |
| 220546 | 221147 | sqlite3_reset(pCsr->pStmt); |
| 220547 | 221148 | sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr)); |
| 221149 | + pTab->pConfig->bLock++; |
| 220548 | 221150 | rc = sqlite3_step(pCsr->pStmt); |
| 221151 | + pTab->pConfig->bLock--; |
| 220549 | 221152 | if( rc==SQLITE_ROW ){ |
| 220550 | 221153 | rc = SQLITE_OK; |
| 220551 | 221154 | CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT); |
| 220552 | 221155 | }else{ |
| 220553 | 221156 | rc = sqlite3_reset(pCsr->pStmt); |
| 220554 | 221157 | if( rc==SQLITE_OK ){ |
| 220555 | 221158 | rc = FTS5_CORRUPT; |
| 221159 | + }else if( pTab->pConfig->pzErrmsg ){ |
| 221160 | + *pTab->pConfig->pzErrmsg = sqlite3_mprintf( |
| 221161 | + "%s", sqlite3_errmsg(pTab->pConfig->db) |
| 221162 | + ); |
| 220556 | 221163 | } |
| 220557 | 221164 | } |
| 220558 | 221165 | } |
| 220559 | 221166 | return rc; |
| 220560 | 221167 | } |
| | @@ -221566,14 +222173,16 @@ |
| 221566 | 222173 | if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){ |
| 221567 | 222174 | fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg); |
| 221568 | 222175 | } |
| 221569 | 222176 | } |
| 221570 | 222177 | }else if( !fts5IsContentless(pTab) ){ |
| 222178 | + pConfig->pzErrmsg = &pTab->p.base.zErrMsg; |
| 221571 | 222179 | rc = fts5SeekCursor(pCsr, 1); |
| 221572 | 222180 | if( rc==SQLITE_OK ){ |
| 221573 | 222181 | sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); |
| 221574 | 222182 | } |
| 222183 | + pConfig->pzErrmsg = 0; |
| 221575 | 222184 | } |
| 221576 | 222185 | return rc; |
| 221577 | 222186 | } |
| 221578 | 222187 | |
| 221579 | 222188 | |
| | @@ -221846,11 +222455,11 @@ |
| 221846 | 222455 | int nArg, /* Number of args */ |
| 221847 | 222456 | sqlite3_value **apUnused /* Function arguments */ |
| 221848 | 222457 | ){ |
| 221849 | 222458 | assert( nArg==0 ); |
| 221850 | 222459 | UNUSED_PARAM2(nArg, apUnused); |
| 221851 | | - sqlite3_result_text(pCtx, "fts5: 2019-11-20 12:07:40 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8", -1, SQLITE_TRANSIENT); |
| 222460 | + sqlite3_result_text(pCtx, "fts5: 2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3", -1, SQLITE_TRANSIENT); |
| 221852 | 222461 | } |
| 221853 | 222462 | |
| 221854 | 222463 | /* |
| 221855 | 222464 | ** Return true if zName is the extension on one of the shadow tables used |
| 221856 | 222465 | ** by this module. |
| | @@ -222593,14 +223202,15 @@ |
| 222593 | 223202 | sqlite3Fts5BufferZero(&buf); |
| 222594 | 223203 | rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid); |
| 222595 | 223204 | for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){ |
| 222596 | 223205 | ctx.szCol = 0; |
| 222597 | 223206 | if( pConfig->abUnindexed[ctx.iCol]==0 ){ |
| 223207 | + const char *zText = (const char*)sqlite3_column_text(pScan, ctx.iCol+1); |
| 223208 | + int nText = sqlite3_column_bytes(pScan, ctx.iCol+1); |
| 222598 | 223209 | rc = sqlite3Fts5Tokenize(pConfig, |
| 222599 | 223210 | FTS5_TOKENIZE_DOCUMENT, |
| 222600 | | - (const char*)sqlite3_column_text(pScan, ctx.iCol+1), |
| 222601 | | - sqlite3_column_bytes(pScan, ctx.iCol+1), |
| 223211 | + zText, nText, |
| 222602 | 223212 | (void*)&ctx, |
| 222603 | 223213 | fts5StorageInsertCallback |
| 222604 | 223214 | ); |
| 222605 | 223215 | } |
| 222606 | 223216 | sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol); |
| | @@ -222718,14 +223328,15 @@ |
| 222718 | 223328 | rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid); |
| 222719 | 223329 | } |
| 222720 | 223330 | for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){ |
| 222721 | 223331 | ctx.szCol = 0; |
| 222722 | 223332 | if( pConfig->abUnindexed[ctx.iCol]==0 ){ |
| 223333 | + const char *zText = (const char*)sqlite3_value_text(apVal[ctx.iCol+2]); |
| 223334 | + int nText = sqlite3_value_bytes(apVal[ctx.iCol+2]); |
| 222723 | 223335 | rc = sqlite3Fts5Tokenize(pConfig, |
| 222724 | 223336 | FTS5_TOKENIZE_DOCUMENT, |
| 222725 | | - (const char*)sqlite3_value_text(apVal[ctx.iCol+2]), |
| 222726 | | - sqlite3_value_bytes(apVal[ctx.iCol+2]), |
| 223337 | + zText, nText, |
| 222727 | 223338 | (void*)&ctx, |
| 222728 | 223339 | fts5StorageInsertCallback |
| 222729 | 223340 | ); |
| 222730 | 223341 | } |
| 222731 | 223342 | sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol); |
| | @@ -222890,14 +223501,15 @@ |
| 222890 | 223501 | ctx.szCol = 0; |
| 222891 | 223502 | if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ |
| 222892 | 223503 | rc = sqlite3Fts5TermsetNew(&ctx.pTermset); |
| 222893 | 223504 | } |
| 222894 | 223505 | if( rc==SQLITE_OK ){ |
| 223506 | + const char *zText = (const char*)sqlite3_column_text(pScan, i+1); |
| 223507 | + int nText = sqlite3_column_bytes(pScan, i+1); |
| 222895 | 223508 | rc = sqlite3Fts5Tokenize(pConfig, |
| 222896 | 223509 | FTS5_TOKENIZE_DOCUMENT, |
| 222897 | | - (const char*)sqlite3_column_text(pScan, i+1), |
| 222898 | | - sqlite3_column_bytes(pScan, i+1), |
| 223510 | + zText, nText, |
| 222899 | 223511 | (void*)&ctx, |
| 222900 | 223512 | fts5StorageIntegrityCallback |
| 222901 | 223513 | ); |
| 222902 | 223514 | } |
| 222903 | 223515 | if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ |
| | @@ -226616,12 +227228,12 @@ |
| 226616 | 227228 | } |
| 226617 | 227229 | #endif /* SQLITE_CORE */ |
| 226618 | 227230 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 226619 | 227231 | |
| 226620 | 227232 | /************** End of stmt.c ************************************************/ |
| 226621 | | -#if __LINE__!=226621 |
| 227233 | +#if __LINE__!=227233 |
| 226622 | 227234 | #undef SQLITE_SOURCE_ID |
| 226623 | | -#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9alt2" |
| 227235 | +#define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1befalt2" |
| 226624 | 227236 | #endif |
| 226625 | 227237 | /* Return the source-id for this library */ |
| 226626 | 227238 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 226627 | 227239 | /************************** End of sqlite3.c ******************************/ |
| 226628 | 227240 | |