| | @@ -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-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3" |
| 1170 | +#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b" |
| 1171 | 1171 | |
| 1172 | 1172 | /* |
| 1173 | 1173 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1174 | 1174 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1175 | 1175 | ** |
| | @@ -1581,11 +1581,10 @@ |
| 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)) |
| 1587 | 1586 | |
| 1588 | 1587 | /* |
| 1589 | 1588 | ** CAPI3REF: Flags For File Open Operations |
| 1590 | 1589 | ** |
| 1591 | 1590 | ** These bit values are intended for use in the |
| | @@ -2022,20 +2021,20 @@ |
| 2022 | 2021 | ** |
| 2023 | 2022 | ** <li>[[SQLITE_FCNTL_BUSYHANDLER]] |
| 2024 | 2023 | ** ^The [SQLITE_FCNTL_BUSYHANDLER] |
| 2025 | 2024 | ** file-control may be invoked by SQLite on the database file handle |
| 2026 | 2025 | ** shortly after it is opened in order to provide a custom VFS with access |
| 2027 | | -** to the connection's busy-handler callback. The argument is of type (void**) |
| 2026 | +** to the connections busy-handler callback. The argument is of type (void **) |
| 2028 | 2027 | ** - an array of two (void *) values. The first (void *) actually points |
| 2029 | | -** to a function of type (int (*)(void *)). In order to invoke the connection's |
| 2028 | +** to a function of type (int (*)(void *)). In order to invoke the connections |
| 2030 | 2029 | ** busy-handler, this function should be invoked with the second (void *) in |
| 2031 | 2030 | ** the array as the only argument. If it returns non-zero, then the operation |
| 2032 | 2031 | ** should be retried. If it returns zero, the custom VFS should abandon the |
| 2033 | 2032 | ** current operation. |
| 2034 | 2033 | ** |
| 2035 | 2034 | ** <li>[[SQLITE_FCNTL_TEMPFILENAME]] |
| 2036 | | -** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
| 2035 | +** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
| 2037 | 2036 | ** to have SQLite generate a |
| 2038 | 2037 | ** temporary filename using the same algorithm that is followed to generate |
| 2039 | 2038 | ** temporary filenames for TEMP tables and other internal uses. The |
| 2040 | 2039 | ** argument should be a char** which will be filled with the filename |
| 2041 | 2040 | ** written into memory obtained from [sqlite3_malloc()]. The caller should |
| | @@ -2144,11 +2143,11 @@ |
| 2144 | 2143 | ** interface can be used to find if any database on the connection has changed, |
| 2145 | 2144 | ** but that interface responds to changes on TEMP as well as MAIN and does |
| 2146 | 2145 | ** not provide a mechanism to detect changes to MAIN only. Also, the |
| 2147 | 2146 | ** [sqlite3_total_changes()] interface responds to internal changes only and |
| 2148 | 2147 | ** omits changes made by other database connections. The |
| 2149 | | -** [PRAGMA data_version] command provides a mechanism to detect changes to |
| 2148 | +** [PRAGMA data_version] command provide a mechanism to detect changes to |
| 2150 | 2149 | ** a single attached database that occur due to other database connections, |
| 2151 | 2150 | ** but omits changes implemented by the database connection on which it is |
| 2152 | 2151 | ** called. This file control is the only mechanism to detect changes that |
| 2153 | 2152 | ** happen either internally or externally and that are associated with |
| 2154 | 2153 | ** a particular attached database. |
| | @@ -2232,14 +2231,14 @@ |
| 2232 | 2231 | ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 |
| 2233 | 2232 | ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased |
| 2234 | 2233 | ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields |
| 2235 | 2234 | ** may be appended to the sqlite3_vfs object and the iVersion value |
| 2236 | 2235 | ** may increase again in future versions of SQLite. |
| 2237 | | -** Note that due to an oversight, the structure |
| 2238 | | -** of the sqlite3_vfs object changed in the transition from |
| 2236 | +** Note that the structure |
| 2237 | +** of the sqlite3_vfs object changes in the transition from |
| 2239 | 2238 | ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] |
| 2240 | | -** and yet the iVersion field was not increased. |
| 2239 | +** and yet the iVersion field was not modified. |
| 2241 | 2240 | ** |
| 2242 | 2241 | ** The szOsFile field is the size of the subclassed [sqlite3_file] |
| 2243 | 2242 | ** structure used by this VFS. mxPathname is the maximum length of |
| 2244 | 2243 | ** a pathname in this VFS. |
| 2245 | 2244 | ** |
| | @@ -2326,11 +2325,11 @@ |
| 2326 | 2325 | ** be created, and that it is an error if it already exists. |
| 2327 | 2326 | ** It is <i>not</i> used to indicate the file should be opened |
| 2328 | 2327 | ** for exclusive access. |
| 2329 | 2328 | ** |
| 2330 | 2329 | ** ^At least szOsFile bytes of memory are allocated by SQLite |
| 2331 | | -** to hold the [sqlite3_file] structure passed as the third |
| 2330 | +** to hold the [sqlite3_file] structure passed as the third |
| 2332 | 2331 | ** argument to xOpen. The xOpen method does not have to |
| 2333 | 2332 | ** allocate the structure; it should just fill it in. Note that |
| 2334 | 2333 | ** the xOpen method must set the sqlite3_file.pMethods to either |
| 2335 | 2334 | ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do |
| 2336 | 2335 | ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods |
| | @@ -2449,10 +2448,11 @@ |
| 2449 | 2448 | ** SQLite. |
| 2450 | 2449 | */ |
| 2451 | 2450 | #define SQLITE_ACCESS_EXISTS 0 |
| 2452 | 2451 | #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ |
| 2453 | 2452 | #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 required mutexes or initialize internal data |
| 2668 | +** it might allocate any require 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-defined page |
| 2809 | +** This configuration option is a no-op if an application-define 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 statements |
| 3294 | +** the legacy [double-quoted string literal] misfeature for DML statement |
| 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 statement count reaches zero are interrupted as if they had been |
| 3555 | +** running statements 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 columns (M==2) and three rows (N==3). Thus the |
| 3723 | +** There are two column (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 named azResult. Then azResult holds this content: |
| 3725 | +** in an array names 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"; |
| | @@ -3873,10 +3873,23 @@ |
| 3873 | 3873 | ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(), |
| 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 | +** |
| 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]. |
| 3878 | 3891 | ** |
| 3879 | 3892 | ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
| 3880 | 3893 | ** must be either NULL or else pointers obtained from a prior |
| 3881 | 3894 | ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have |
| 3882 | 3895 | ** not yet been released. |
| | @@ -3922,11 +3935,11 @@ |
| 3922 | 3935 | ** CAPI3REF: Pseudo-Random Number Generator |
| 3923 | 3936 | ** |
| 3924 | 3937 | ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
| 3925 | 3938 | ** select random [ROWID | ROWIDs] when inserting new records into a table that |
| 3926 | 3939 | ** already uses the largest possible [ROWID]. The PRNG is also used for |
| 3927 | | -** the built-in random() and randomblob() SQL functions. This interface allows |
| 3940 | +** the build-in random() and randomblob() SQL functions. This interface allows |
| 3928 | 3941 | ** applications to access the same PRNG for other purposes. |
| 3929 | 3942 | ** |
| 3930 | 3943 | ** ^A call to this routine stores N bytes of randomness into buffer P. |
| 3931 | 3944 | ** ^The P parameter can be a NULL pointer. |
| 3932 | 3945 | ** |
| | @@ -4523,11 +4536,11 @@ |
| 4523 | 4536 | ** a VFS implementation when the flags parameter to xOpen() has one or |
| 4524 | 4537 | ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and |
| 4525 | 4538 | ** P is the name of the query parameter, then |
| 4526 | 4539 | ** sqlite3_uri_parameter(F,P) returns the value of the P |
| 4527 | 4540 | ** parameter if it exists or a NULL pointer if P does not appear as a |
| 4528 | | -** query parameter on F. If P is a query parameter of F and it |
| 4541 | +** query parameter on F. If P is a query parameter of F |
| 4529 | 4542 | ** has no explicit value, then sqlite3_uri_parameter(F,P) returns |
| 4530 | 4543 | ** a pointer to an empty string. |
| 4531 | 4544 | ** |
| 4532 | 4545 | ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean |
| 4533 | 4546 | ** parameter and returns true (1) or false (0) according to the value |
| | @@ -4535,11 +4548,11 @@ |
| 4535 | 4548 | ** value of query parameter P is one of "yes", "true", or "on" in any |
| 4536 | 4549 | ** case or if the value begins with a non-zero number. The |
| 4537 | 4550 | ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of |
| 4538 | 4551 | ** query parameter P is one of "no", "false", or "off" in any case or |
| 4539 | 4552 | ** if the value begins with a numeric zero. If P is not a query |
| 4540 | | -** parameter on F or if the value of P does not match any of the |
| 4553 | +** parameter on F or if the value of P is does not match any of the |
| 4541 | 4554 | ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). |
| 4542 | 4555 | ** |
| 4543 | 4556 | ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a |
| 4544 | 4557 | ** 64-bit signed integer and returns that integer, or D if P does not |
| 4545 | 4558 | ** exist. If the value of P is something other than an integer, then |
| | @@ -4872,16 +4885,16 @@ |
| 4872 | 4885 | ** in order to find the underlying cause of the problem. With the "v2" prepare |
| 4873 | 4886 | ** interfaces, the underlying reason for the error is returned immediately. |
| 4874 | 4887 | ** </li> |
| 4875 | 4888 | ** |
| 4876 | 4889 | ** <li> |
| 4877 | | -** ^If the specific value bound to a [parameter | host parameter] in the |
| 4890 | +** ^If the specific value bound to [parameter | host parameter] in the |
| 4878 | 4891 | ** WHERE clause might influence the choice of query plan for a statement, |
| 4879 | 4892 | ** then the statement will be automatically recompiled, as if there had been |
| 4880 | | -** a schema change, on the first [sqlite3_step()] call following any change |
| 4893 | +** a schema change, on the first [sqlite3_step()] call following any change |
| 4881 | 4894 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 4882 | | -** ^The specific value of a WHERE-clause [parameter] might influence the |
| 4895 | +** ^The specific value of WHERE-clause [parameter] might influence the |
| 4883 | 4896 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 4884 | 4897 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 4885 | 4898 | ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. |
| 4886 | 4899 | ** </li> |
| 4887 | 4900 | ** </ol> |
| | @@ -5386,19 +5399,23 @@ |
| 5386 | 5399 | ** the statement, where N is the second function argument. |
| 5387 | 5400 | ** ^The left-most column is column 0 for these routines. |
| 5388 | 5401 | ** |
| 5389 | 5402 | ** ^If the Nth column returned by the statement is an expression or |
| 5390 | 5403 | ** subquery and is not a column value, then all of these functions return |
| 5391 | | -** NULL. ^These routines might also return NULL if a memory allocation error |
| 5404 | +** NULL. ^These routine might also return NULL if a memory allocation error |
| 5392 | 5405 | ** occurs. ^Otherwise, they return the name of the attached database, table, |
| 5393 | 5406 | ** or column that query result column was extracted from. |
| 5394 | 5407 | ** |
| 5395 | 5408 | ** ^As with all other SQLite APIs, those whose names end with "16" return |
| 5396 | 5409 | ** UTF-16 encoded strings and the other functions return UTF-8. |
| 5397 | 5410 | ** |
| 5398 | 5411 | ** ^These APIs are only available if the library was compiled with the |
| 5399 | 5412 | ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. |
| 5413 | +** |
| 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. |
| 5400 | 5417 | ** |
| 5401 | 5418 | ** If two or more threads call one or more |
| 5402 | 5419 | ** [sqlite3_column_database_name | column metadata interfaces] |
| 5403 | 5420 | ** for the same [prepared statement] and result column |
| 5404 | 5421 | ** at the same time then the results are undefined. |
| | @@ -5532,11 +5549,11 @@ |
| 5532 | 5549 | ** METHOD: sqlite3_stmt |
| 5533 | 5550 | ** |
| 5534 | 5551 | ** ^The sqlite3_data_count(P) interface returns the number of columns in the |
| 5535 | 5552 | ** current row of the result set of [prepared statement] P. |
| 5536 | 5553 | ** ^If prepared statement P does not have results ready to return |
| 5537 | | -** (via calls to the [sqlite3_column_int | sqlite3_column()] family of |
| 5554 | +** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 5538 | 5555 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 5539 | 5556 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 5540 | 5557 | ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to |
| 5541 | 5558 | ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) |
| 5542 | 5559 | ** will return non-zero if previous call to [sqlite3_step](P) returned |
| | @@ -6034,16 +6051,13 @@ |
| 6034 | 6051 | ** These constants may be ORed together with the |
| 6035 | 6052 | ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument |
| 6036 | 6053 | ** to [sqlite3_create_function()], [sqlite3_create_function16()], or |
| 6037 | 6054 | ** [sqlite3_create_function_v2()]. |
| 6038 | 6055 | ** |
| 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. |
| 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. |
| 6045 | 6059 | ** |
| 6046 | 6060 | ** The SQLITE_DIRECTONLY flag means that the function may only be invoked |
| 6047 | 6061 | ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is |
| 6048 | 6062 | ** a security feature which is recommended for all |
| 6049 | 6063 | ** [application-defined SQL functions] that have side-effects. This flag |
| | @@ -6118,12 +6132,12 @@ |
| 6118 | 6132 | ** |
| 6119 | 6133 | ** <b>Details:</b> |
| 6120 | 6134 | ** |
| 6121 | 6135 | ** These routines extract type, size, and content information from |
| 6122 | 6136 | ** [protected sqlite3_value] objects. Protected sqlite3_value objects |
| 6123 | | -** are used to pass parameter information into the functions that |
| 6124 | | -** implement [application-defined SQL functions] and [virtual tables]. |
| 6137 | +** are used to pass parameter information into implementation of |
| 6138 | +** [application-defined SQL functions] and [virtual tables]. |
| 6125 | 6139 | ** |
| 6126 | 6140 | ** These routines work only with [protected sqlite3_value] objects. |
| 6127 | 6141 | ** Any attempt to use these routines on an [unprotected sqlite3_value] |
| 6128 | 6142 | ** is not threadsafe. |
| 6129 | 6143 | ** |
| | @@ -6176,11 +6190,11 @@ |
| 6176 | 6190 | ** the return value is arbitrary and meaningless. |
| 6177 | 6191 | ** |
| 6178 | 6192 | ** ^The sqlite3_value_frombind(X) interface returns non-zero if the |
| 6179 | 6193 | ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] |
| 6180 | 6194 | ** interfaces. ^If X comes from an SQL literal value, or a table column, |
| 6181 | | -** or an expression, then sqlite3_value_frombind(X) returns zero. |
| 6195 | +** and expression, then sqlite3_value_frombind(X) returns zero. |
| 6182 | 6196 | ** |
| 6183 | 6197 | ** Please pay particular attention to the fact that the pointer returned |
| 6184 | 6198 | ** from [sqlite3_value_blob()], [sqlite3_value_text()], or |
| 6185 | 6199 | ** [sqlite3_value_text16()] can be invalidated by a subsequent call to |
| 6186 | 6200 | ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], |
| | @@ -6262,12 +6276,12 @@ |
| 6262 | 6276 | ** |
| 6263 | 6277 | ** Implementations of aggregate SQL functions use this |
| 6264 | 6278 | ** routine to allocate memory for storing their state. |
| 6265 | 6279 | ** |
| 6266 | 6280 | ** ^The first time the sqlite3_aggregate_context(C,N) routine is called |
| 6267 | | -** for a particular aggregate function, SQLite allocates |
| 6268 | | -** N bytes of memory, zeroes out that memory, and returns a pointer |
| 6281 | +** for a particular aggregate function, SQLite |
| 6282 | +** allocates N of memory, zeroes out that memory, and returns a pointer |
| 6269 | 6283 | ** to the new memory. ^On second and subsequent calls to |
| 6270 | 6284 | ** sqlite3_aggregate_context() for the same aggregate function instance, |
| 6271 | 6285 | ** the same buffer is returned. Sqlite3_aggregate_context() is normally |
| 6272 | 6286 | ** called once for each invocation of the xStep callback and then one |
| 6273 | 6287 | ** last time when the xFinal callback is invoked. ^(When no rows match |
| | @@ -6280,11 +6294,11 @@ |
| 6280 | 6294 | ** when first called if N is less than or equal to zero or if a memory |
| 6281 | 6295 | ** allocate error occurs. |
| 6282 | 6296 | ** |
| 6283 | 6297 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 6284 | 6298 | ** determined by the N parameter on first successful call. Changing the |
| 6285 | | -** value of N in any subsequents call to sqlite3_aggregate_context() within |
| 6299 | +** value of N in subsequent call to sqlite3_aggregate_context() within |
| 6286 | 6300 | ** the same aggregate function instance will not resize the memory |
| 6287 | 6301 | ** allocation.)^ Within the xFinal callback, it is customary to set |
| 6288 | 6302 | ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
| 6289 | 6303 | ** pointless memory allocations occur. |
| 6290 | 6304 | ** |
| | @@ -6628,11 +6642,11 @@ |
| 6628 | 6642 | ** <li> If A<B THEN B>A. |
| 6629 | 6643 | ** <li> If A<B and B<C then A<C. |
| 6630 | 6644 | ** </ol> |
| 6631 | 6645 | ** |
| 6632 | 6646 | ** If a collating function fails any of the above constraints and that |
| 6633 | | -** collating function is registered and used, then the behavior of SQLite |
| 6647 | +** collating function is registered and used, then the behavior of SQLite |
| 6634 | 6648 | ** is undefined. |
| 6635 | 6649 | ** |
| 6636 | 6650 | ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() |
| 6637 | 6651 | ** with the addition that the xDestroy callback is invoked on pArg when |
| 6638 | 6652 | ** the collating function is deleted. |
| | @@ -6955,20 +6969,16 @@ |
| 6955 | 6969 | |
| 6956 | 6970 | /* |
| 6957 | 6971 | ** CAPI3REF: Return The Filename For A Database Connection |
| 6958 | 6972 | ** METHOD: sqlite3 |
| 6959 | 6973 | ** |
| 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 |
| 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 |
| 6963 | 6977 | ** connection D, or if database N is a temporary or in-memory database, then |
| 6964 | 6978 | ** this function will return either a NULL pointer or an empty string. |
| 6965 | 6979 | ** |
| 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. |
| 6969 | | -** |
| 6970 | 6980 | ** ^The filename returned by this function is the output of the |
| 6971 | 6981 | ** xFullPathname method of the [VFS]. ^In other words, the filename |
| 6972 | 6982 | ** will be an absolute pathname, even if the filename used |
| 6973 | 6983 | ** to open the database originally was a URI or relative pathname. |
| 6974 | 6984 | */ |
| | @@ -7118,23 +7128,19 @@ |
| 7118 | 7128 | ** In prior versions of SQLite, |
| 7119 | 7129 | ** sharing was enabled or disabled for each thread separately. |
| 7120 | 7130 | ** |
| 7121 | 7131 | ** ^(The cache sharing mode set by this interface effects all subsequent |
| 7122 | 7132 | ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. |
| 7123 | | -** Existing database connections continue to use the sharing mode |
| 7133 | +** Existing database connections continue use the sharing mode |
| 7124 | 7134 | ** that was in effect at the time they were opened.)^ |
| 7125 | 7135 | ** |
| 7126 | 7136 | ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled |
| 7127 | 7137 | ** successfully. An [error code] is returned otherwise.)^ |
| 7128 | 7138 | ** |
| 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. |
| 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. |
| 7136 | 7142 | ** |
| 7137 | 7143 | ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 |
| 7138 | 7144 | ** and will always return SQLITE_MISUSE. On those systems, |
| 7139 | 7145 | ** shared cache mode should be enabled per-database connection via |
| 7140 | 7146 | ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. |
| | @@ -7263,11 +7269,11 @@ |
| 7263 | 7269 | ** information about column C of table T in database D |
| 7264 | 7270 | ** on [database connection] X.)^ ^The sqlite3_table_column_metadata() |
| 7265 | 7271 | ** interface returns SQLITE_OK and fills in the non-NULL pointers in |
| 7266 | 7272 | ** the final five arguments with appropriate values if the specified |
| 7267 | 7273 | ** column exists. ^The sqlite3_table_column_metadata() interface returns |
| 7268 | | -** SQLITE_ERROR if the specified column does not exist. |
| 7274 | +** SQLITE_ERROR and if the specified column does not exist. |
| 7269 | 7275 | ** ^If the column-name parameter to sqlite3_table_column_metadata() is a |
| 7270 | 7276 | ** NULL pointer, then this routine simply checks for the existence of the |
| 7271 | 7277 | ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it |
| 7272 | 7278 | ** does not. If the table name parameter T in a call to |
| 7273 | 7279 | ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is |
| | @@ -7405,11 +7411,11 @@ |
| 7405 | 7411 | ** [sqlite3_load_extension()] and the SQL function [load_extension()]. |
| 7406 | 7412 | ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) |
| 7407 | 7413 | ** to enable or disable only the C-API.)^ |
| 7408 | 7414 | ** |
| 7409 | 7415 | ** <b>Security warning:</b> It is recommended that extension loading |
| 7410 | | -** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 7416 | +** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 7411 | 7417 | ** rather than this interface, so the [load_extension()] SQL function |
| 7412 | 7418 | ** remains disabled. This will prevent SQL injections from giving attackers |
| 7413 | 7419 | ** access to extension loading capabilities. |
| 7414 | 7420 | */ |
| 7415 | 7421 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| | @@ -7492,11 +7498,11 @@ |
| 7492 | 7498 | /* |
| 7493 | 7499 | ** CAPI3REF: Virtual Table Object |
| 7494 | 7500 | ** KEYWORDS: sqlite3_module {virtual table module} |
| 7495 | 7501 | ** |
| 7496 | 7502 | ** This structure, sometimes called a "virtual table module", |
| 7497 | | -** defines the implementation of a [virtual table]. |
| 7503 | +** defines the implementation of a [virtual tables]. |
| 7498 | 7504 | ** This structure consists mostly of methods for the module. |
| 7499 | 7505 | ** |
| 7500 | 7506 | ** ^A virtual table module is created by filling in a persistent |
| 7501 | 7507 | ** instance of this structure and passing a pointer to that instance |
| 7502 | 7508 | ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. |
| | @@ -7589,17 +7595,11 @@ |
| 7589 | 7595 | ** The [xBestIndex] method must fill aConstraintUsage[] with information |
| 7590 | 7596 | ** about what parameters to pass to xFilter. ^If argvIndex>0 then |
| 7591 | 7597 | ** the right-hand side of the corresponding aConstraint[] is evaluated |
| 7592 | 7598 | ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit |
| 7593 | 7599 | ** is true, then the constraint is assumed to be fully handled by the |
| 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.)^ |
| 7600 | +** virtual table and is not checked again by SQLite.)^ |
| 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 include crashing the application). The estimatedRows field should |
| 7640 | +** to included 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 define the allowed values for the |
| 7692 | +** These macros defined 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 the [pagecache memory allocator]. Only the value returned in the |
| 8775 | +** handed to [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 of malloc attempts that were |
| 8851 | +** <dd>This parameter returns the number 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 resolved by increasing the cache size. |
| 8933 | +** inefficiencies that can be resolve 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 changes to |
| 9022 | +** automatically regenerated due to schema changes or change 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 xFetch() calls, SQLite may |
| 9193 | +** failed.)^ In between the to 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 connection's transaction. |
| 9511 | +** call that concludes the blocking connections 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 connection's transaction is concluded, there may be |
| 9549 | +** When a blocking connections 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 V parameter will be |
| 10023 | +** <dd>^The [sqlite3_int64] variable pointed to by the T 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 V parameter will be set |
| 10027 | +** <dd>^The [sqlite3_int64] variable pointed to by the T 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 V parameter will be set to the |
| 10031 | +** <dd>^The "double" variable pointed to by the T 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 V parameter will be set |
| 10039 | +** <dd>^The "const char *" variable pointed to by the T 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 V parameter will be set |
| 10044 | +** <dd>^The "const char *" variable pointed to by the T 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 V parameter will be set to the |
| 10049 | +** <dd>^The "int" variable pointed to by the T 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 are not tracked. Note that once a table is |
| 10904 | +** If xFilter returns 0, changes is 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 is successful, SQLITE_OK is returned. Otherwise, an SQLite |
| 11078 | +** If the operation 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 the function |
| 11215 | +** This function may only be used with iterators created by 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 state |
| 11632 | | -** of the final contents of the changegroup is undefined. |
| 11631 | +** function returns SQLITE_NOMEM. In all cases, if an error occurs the |
| 11632 | +** 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 application's conflict |
| 11807 | +** This can be used to further customize the applications 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 according to the configuration of the |
| 12117 | +** of the changeset rebased 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 function's |
| 12525 | +** Save the pointer passed as the second argument as the extension functions |
| 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, using |
| 12768 | | -** the above example, this means that the tokenizer returns the |
| 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 |
| 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,30 +13435,10 @@ |
| 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 | | - |
| 13460 | 13440 | /* |
| 13461 | 13441 | ** Some conditionals are optimizations only. In other words, if the |
| 13462 | 13442 | ** conditionals are replaced with a constant 1 (true) or 0 (false) then |
| 13463 | 13443 | ** the correct answer is still obtained, though perhaps not as quickly. |
| 13464 | 13444 | ** |
| | @@ -15169,14 +15149,13 @@ |
| 15169 | 15149 | #define OP_VRename 163 |
| 15170 | 15150 | #define OP_Pagecount 164 |
| 15171 | 15151 | #define OP_MaxPgcnt 165 |
| 15172 | 15152 | #define OP_Trace 166 |
| 15173 | 15153 | #define OP_CursorHint 167 |
| 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 |
| 15154 | +#define OP_Noop 168 |
| 15155 | +#define OP_Explain 169 |
| 15156 | +#define OP_Abortable 170 |
| 15178 | 15157 | |
| 15179 | 15158 | /* Properties such as "out2" or "jump" that are specified in |
| 15180 | 15159 | ** comments following the "case" for each opcode in the vdbe.c |
| 15181 | 15160 | ** are encoded into bitvectors as follows: |
| 15182 | 15161 | */ |
| | @@ -15206,11 +15185,11 @@ |
| 15206 | 15185 | /* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 15207 | 15186 | /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15208 | 15187 | /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\ |
| 15209 | 15188 | /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15210 | 15189 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 15211 | | -/* 168 */ 0x00, 0x00, 0x00, 0x00,} |
| 15190 | +/* 168 */ 0x00, 0x00, 0x00,} |
| 15212 | 15191 | |
| 15213 | 15192 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 15214 | 15193 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 15215 | 15194 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 15216 | 15195 | ** generated this include file strives to group all JUMP opcodes |
| | @@ -15283,15 +15262,10 @@ |
| 15283 | 15262 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); |
| 15284 | 15263 | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5); |
| 15285 | 15264 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); |
| 15286 | 15265 | SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr); |
| 15287 | 15266 | 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 |
| 15293 | 15267 | SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
| 15294 | 15268 | SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type); |
| 15295 | 15269 | SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); |
| 15296 | 15270 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); |
| 15297 | 15271 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| | @@ -16867,10 +16841,16 @@ |
| 16867 | 16841 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 16868 | 16842 | pArg, 0, xFunc, 0, 0, 0, #zName, } |
| 16869 | 16843 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 16870 | 16844 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 16871 | 16845 | (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}} |
| 16872 | 16852 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ |
| 16873 | 16853 | {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ |
| 16874 | 16854 | SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}} |
| 16875 | 16855 | #define INTERNAL_FUNCTION(zName, nArg, xFunc) \ |
| 16876 | 16856 | {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| | @@ -17998,17 +17978,17 @@ |
| 17998 | 17978 | ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences |
| 17999 | 17979 | ** for the result set. The KeyInfo for addrOpenEphm[2] contains collating |
| 18000 | 17980 | ** sequences for the ORDER BY clause. |
| 18001 | 17981 | */ |
| 18002 | 17982 | struct Select { |
| 17983 | + ExprList *pEList; /* The fields of the result */ |
| 18003 | 17984 | u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ |
| 18004 | 17985 | LogEst nSelectRow; /* Estimated number of result rows */ |
| 18005 | 17986 | u32 selFlags; /* Various SF_* values */ |
| 18006 | 17987 | int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */ |
| 18007 | 17988 | u32 selId; /* Unique identifier number for this SELECT */ |
| 18008 | 17989 | int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */ |
| 18009 | | - ExprList *pEList; /* The fields of the result */ |
| 18010 | 17990 | SrcList *pSrc; /* The FROM clause */ |
| 18011 | 17991 | Expr *pWhere; /* The WHERE clause */ |
| 18012 | 17992 | ExprList *pGroupBy; /* The GROUP BY clause */ |
| 18013 | 17993 | Expr *pHaving; /* The HAVING clause */ |
| 18014 | 17994 | ExprList *pOrderBy; /* The ORDER BY clause */ |
| | @@ -18050,11 +18030,10 @@ |
| 18050 | 18030 | #define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */ |
| 18051 | 18031 | #define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */ |
| 18052 | 18032 | #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */ |
| 18053 | 18033 | #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */ |
| 18054 | 18034 | #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ |
| 18055 | | -#define SF_View 0x0200000 /* SELECT statement is a view */ |
| 18056 | 18035 | |
| 18057 | 18036 | /* |
| 18058 | 18037 | ** The results of a SELECT can be distributed in several ways, as defined |
| 18059 | 18038 | ** by one of the following macros. The "SRT" prefix means "SELECT Result |
| 18060 | 18039 | ** Type". |
| | @@ -18330,12 +18309,12 @@ |
| 18330 | 18309 | #endif |
| 18331 | 18310 | }; |
| 18332 | 18311 | |
| 18333 | 18312 | #define PARSE_MODE_NORMAL 0 |
| 18334 | 18313 | #define PARSE_MODE_DECLARE_VTAB 1 |
| 18335 | | -#define PARSE_MODE_RENAME 2 |
| 18336 | | -#define PARSE_MODE_UNMAP 3 |
| 18314 | +#define PARSE_MODE_RENAME_COLUMN 2 |
| 18315 | +#define PARSE_MODE_RENAME_TABLE 3 |
| 18337 | 18316 | |
| 18338 | 18317 | /* |
| 18339 | 18318 | ** Sizes and pointers of various parts of the Parse object. |
| 18340 | 18319 | */ |
| 18341 | 18320 | #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/ |
| | @@ -18353,11 +18332,11 @@ |
| 18353 | 18332 | #endif |
| 18354 | 18333 | |
| 18355 | 18334 | #if defined(SQLITE_OMIT_ALTERTABLE) |
| 18356 | 18335 | #define IN_RENAME_OBJECT 0 |
| 18357 | 18336 | #else |
| 18358 | | - #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME) |
| 18337 | + #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN) |
| 18359 | 18338 | #endif |
| 18360 | 18339 | |
| 18361 | 18340 | #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE) |
| 18362 | 18341 | #define IN_SPECIAL_PARSE 0 |
| 18363 | 18342 | #else |
| | @@ -19172,11 +19151,10 @@ |
| 19172 | 19151 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 19173 | 19152 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 19174 | 19153 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 19175 | 19154 | Expr*,ExprList*,u32,Expr*); |
| 19176 | 19155 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 19177 | | -SQLITE_PRIVATE void sqlite3SelectReset(Parse*, Select*); |
| 19178 | 19156 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 19179 | 19157 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); |
| 19180 | 19158 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 19181 | 19159 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 19182 | 19160 | SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*); |
| | @@ -20756,11 +20734,11 @@ |
| 20756 | 20734 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); |
| 20757 | 20735 | SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull); |
| 20758 | 20736 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); |
| 20759 | 20737 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 20760 | 20738 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 20761 | | -SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8); |
| 20739 | +SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8); |
| 20762 | 20740 | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*); |
| 20763 | 20741 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); |
| 20764 | 20742 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); |
| 20765 | 20743 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 20766 | 20744 | SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*); |
| | @@ -22676,11 +22654,11 @@ |
| 22676 | 22654 | DO_OS_MALLOC_TEST(0); |
| 22677 | 22655 | /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed |
| 22678 | 22656 | ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, |
| 22679 | 22657 | ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before |
| 22680 | 22658 | ** reaching the VFS. */ |
| 22681 | | - rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x1087f7f, pFlagsOut); |
| 22659 | + rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); |
| 22682 | 22660 | assert( rc==SQLITE_OK || pFile->pMethods==0 ); |
| 22683 | 22661 | return rc; |
| 22684 | 22662 | } |
| 22685 | 22663 | SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ |
| 22686 | 22664 | DO_OS_MALLOC_TEST(0); |
| | @@ -29311,13 +29289,12 @@ |
| 29311 | 29289 | zOp2[0] = 0; |
| 29312 | 29290 | } |
| 29313 | 29291 | sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s", |
| 29314 | 29292 | pExpr->iColumn, zFlgs, zOp2); |
| 29315 | 29293 | }else{ |
| 29316 | | - sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s", |
| 29317 | | - pExpr->iTable, pExpr->iColumn, |
| 29318 | | - pExpr->y.pTab, zFlgs); |
| 29294 | + sqlite3TreeViewLine(pView, "{%d:%d}%s", |
| 29295 | + pExpr->iTable, pExpr->iColumn, zFlgs); |
| 29319 | 29296 | } |
| 29320 | 29297 | if( ExprHasProperty(pExpr, EP_FixedCol) ){ |
| 29321 | 29298 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 29322 | 29299 | } |
| 29323 | 29300 | break; |
| | @@ -30984,11 +30961,11 @@ |
| 30984 | 30961 | #pragma warning(disable : 4756) |
| 30985 | 30962 | #endif |
| 30986 | 30963 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 30987 | 30964 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 30988 | 30965 | int incr; |
| 30989 | | - const char *zEnd; |
| 30966 | + const char *zEnd = z + length; |
| 30990 | 30967 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 30991 | 30968 | int sign = 1; /* sign of significand */ |
| 30992 | 30969 | i64 s = 0; /* significand */ |
| 30993 | 30970 | int d = 0; /* adjust exponent for shifting decimal point */ |
| 30994 | 30971 | int esign = 1; /* sign of exponent */ |
| | @@ -30998,15 +30975,13 @@ |
| 30998 | 30975 | int nDigit = 0; /* Number of digits processed */ |
| 30999 | 30976 | int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ |
| 31000 | 30977 | |
| 31001 | 30978 | assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); |
| 31002 | 30979 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 31003 | | - if( length==0 ) return 0; |
| 31004 | 30980 | |
| 31005 | 30981 | if( enc==SQLITE_UTF8 ){ |
| 31006 | 30982 | incr = 1; |
| 31007 | | - zEnd = z + length; |
| 31008 | 30983 | }else{ |
| 31009 | 30984 | int i; |
| 31010 | 30985 | incr = 2; |
| 31011 | 30986 | assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); |
| 31012 | 30987 | testcase( enc==SQLITE_UTF16LE ); |
| | @@ -32685,14 +32660,13 @@ |
| 32685 | 32660 | /* 163 */ "VRename" OpHelp(""), |
| 32686 | 32661 | /* 164 */ "Pagecount" OpHelp(""), |
| 32687 | 32662 | /* 165 */ "MaxPgcnt" OpHelp(""), |
| 32688 | 32663 | /* 166 */ "Trace" OpHelp(""), |
| 32689 | 32664 | /* 167 */ "CursorHint" OpHelp(""), |
| 32690 | | - /* 168 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 32691 | | - /* 169 */ "Noop" OpHelp(""), |
| 32692 | | - /* 170 */ "Explain" OpHelp(""), |
| 32693 | | - /* 171 */ "Abortable" OpHelp(""), |
| 32665 | + /* 168 */ "Noop" OpHelp(""), |
| 32666 | + /* 169 */ "Explain" OpHelp(""), |
| 32667 | + /* 170 */ "Abortable" OpHelp(""), |
| 32694 | 32668 | }; |
| 32695 | 32669 | return azName[i]; |
| 32696 | 32670 | } |
| 32697 | 32671 | #endif |
| 32698 | 32672 | |
| | @@ -36581,11 +36555,11 @@ |
| 36581 | 36555 | zDirname[ii] = '\0'; |
| 36582 | 36556 | }else{ |
| 36583 | 36557 | if( zDirname[0]!='/' ) zDirname[0] = '.'; |
| 36584 | 36558 | zDirname[1] = 0; |
| 36585 | 36559 | } |
| 36586 | | - fd = robust_open(zDirname, O_RDONLY|O_BINARY|O_NOFOLLOW, 0); |
| 36560 | + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); |
| 36587 | 36561 | if( fd>=0 ){ |
| 36588 | 36562 | OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); |
| 36589 | 36563 | } |
| 36590 | 36564 | *pFd = fd; |
| 36591 | 36565 | if( fd>=0 ) return SQLITE_OK; |
| | @@ -37472,16 +37446,14 @@ |
| 37472 | 37446 | } |
| 37473 | 37447 | } |
| 37474 | 37448 | |
| 37475 | 37449 | if( pInode->bProcessLock==0 ){ |
| 37476 | 37450 | if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){ |
| 37477 | | - pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT|O_NOFOLLOW, |
| 37478 | | - (sStat.st_mode&0777)); |
| 37451 | + pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777)); |
| 37479 | 37452 | } |
| 37480 | 37453 | if( pShmNode->hShm<0 ){ |
| 37481 | | - pShmNode->hShm = robust_open(zShm, O_RDONLY|O_NOFOLLOW, |
| 37482 | | - (sStat.st_mode&0777)); |
| 37454 | + pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777)); |
| 37483 | 37455 | if( pShmNode->hShm<0 ){ |
| 37484 | 37456 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm); |
| 37485 | 37457 | goto shm_open_err; |
| 37486 | 37458 | } |
| 37487 | 37459 | pShmNode->isReadonly = 1; |
| | @@ -38827,11 +38799,11 @@ |
| 38827 | 38799 | int *pOutFlags /* Output flags returned to SQLite core */ |
| 38828 | 38800 | ){ |
| 38829 | 38801 | unixFile *p = (unixFile *)pFile; |
| 38830 | 38802 | int fd = -1; /* File descriptor returned by open() */ |
| 38831 | 38803 | int openFlags = 0; /* Flags to pass to open() */ |
| 38832 | | - int eType = flags&0x0FFF00; /* Type of file to open */ |
| 38804 | + int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 38833 | 38805 | int noLock; /* True to omit locking primitives */ |
| 38834 | 38806 | int rc = SQLITE_OK; /* Function Return Code */ |
| 38835 | 38807 | int ctrlFlags = 0; /* UNIXFILE_* flags */ |
| 38836 | 38808 | |
| 38837 | 38809 | int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); |
| | @@ -38937,11 +38909,11 @@ |
| 38937 | 38909 | ** 'conch file' locking functions later on. */ |
| 38938 | 38910 | if( isReadonly ) openFlags |= O_RDONLY; |
| 38939 | 38911 | if( isReadWrite ) openFlags |= O_RDWR; |
| 38940 | 38912 | if( isCreate ) openFlags |= O_CREAT; |
| 38941 | 38913 | if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); |
| 38942 | | - openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW); |
| 38914 | + openFlags |= (O_LARGEFILE|O_BINARY); |
| 38943 | 38915 | |
| 38944 | 38916 | if( fd<0 ){ |
| 38945 | 38917 | mode_t openMode; /* Permissions to create file with */ |
| 38946 | 38918 | uid_t uid; /* Userid for the file */ |
| 38947 | 38919 | gid_t gid; /* Groupid for the file */ |
| | @@ -39149,20 +39121,29 @@ |
| 39149 | 39121 | ){ |
| 39150 | 39122 | UNUSED_PARAMETER(NotUsed); |
| 39151 | 39123 | SimulateIOError( return SQLITE_IOERR_ACCESS; ); |
| 39152 | 39124 | assert( pResOut!=0 ); |
| 39153 | 39125 | |
| 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 ); |
| 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 ); |
| 39157 | 39131 | |
| 39158 | 39132 | if( flags==SQLITE_ACCESS_EXISTS ){ |
| 39159 | 39133 | struct stat buf; |
| 39160 | | - *pResOut = 0==osStat(zPath, &buf) && |
| 39161 | | - (S_ISDIR(buf.st_mode) || buf.st_size>0); |
| 39162 | | - }else{ |
| 39134 | + *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0); |
| 39135 | + }else if( flags==SQLITE_ACCESS_READWRITE ){ |
| 39163 | 39136 | *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 ); |
| 39164 | 39145 | } |
| 39165 | 39146 | return SQLITE_OK; |
| 39166 | 39147 | } |
| 39167 | 39148 | |
| 39168 | 39149 | /* |
| | @@ -39210,11 +39191,11 @@ |
| 39210 | 39191 | #if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT) |
| 39211 | 39192 | return mkFullPathname(zPath, zOut, nOut); |
| 39212 | 39193 | #else |
| 39213 | 39194 | int rc = SQLITE_OK; |
| 39214 | 39195 | int nByte; |
| 39215 | | - int nLink = 0; /* Number of symbolic links followed so far */ |
| 39196 | + int nLink = 1; /* Number of symbolic links followed so far */ |
| 39216 | 39197 | const char *zIn = zPath; /* Input path for each iteration of loop */ |
| 39217 | 39198 | char *zDel = 0; |
| 39218 | 39199 | |
| 39219 | 39200 | assert( pVfs->mxPathname==MAX_PATHNAME ); |
| 39220 | 39201 | UNUSED_PARAMETER(pVfs); |
| | @@ -39239,15 +39220,14 @@ |
| 39239 | 39220 | }else{ |
| 39240 | 39221 | bLink = S_ISLNK(buf.st_mode); |
| 39241 | 39222 | } |
| 39242 | 39223 | |
| 39243 | 39224 | if( bLink ){ |
| 39244 | | - nLink++; |
| 39245 | 39225 | if( zDel==0 ){ |
| 39246 | 39226 | zDel = sqlite3_malloc(nOut); |
| 39247 | 39227 | if( zDel==0 ) rc = SQLITE_NOMEM_BKPT; |
| 39248 | | - }else if( nLink>=SQLITE_MAX_SYMLINKS ){ |
| 39228 | + }else if( ++nLink>SQLITE_MAX_SYMLINKS ){ |
| 39249 | 39229 | rc = SQLITE_CANTOPEN_BKPT; |
| 39250 | 39230 | } |
| 39251 | 39231 | |
| 39252 | 39232 | if( rc==SQLITE_OK ){ |
| 39253 | 39233 | nByte = osReadlink(zIn, zDel, nOut-1); |
| | @@ -39279,11 +39259,10 @@ |
| 39279 | 39259 | if( bLink==0 ) break; |
| 39280 | 39260 | zIn = zOut; |
| 39281 | 39261 | }while( rc==SQLITE_OK ); |
| 39282 | 39262 | |
| 39283 | 39263 | sqlite3_free(zDel); |
| 39284 | | - if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK; |
| 39285 | 39264 | return rc; |
| 39286 | 39265 | #endif /* HAVE_READLINK && HAVE_LSTAT */ |
| 39287 | 39266 | } |
| 39288 | 39267 | |
| 39289 | 39268 | |
| | @@ -39765,11 +39744,11 @@ |
| 39765 | 39744 | int islockfile /* if non zero missing dirs will be created */ |
| 39766 | 39745 | ) { |
| 39767 | 39746 | int fd = -1; |
| 39768 | 39747 | unixFile *pNew; |
| 39769 | 39748 | int rc = SQLITE_OK; |
| 39770 | | - int openFlags = O_RDWR | O_CREAT | O_NOFOLLOW; |
| 39749 | + int openFlags = O_RDWR | O_CREAT; |
| 39771 | 39750 | sqlite3_vfs dummyVfs; |
| 39772 | 39751 | int terrno = 0; |
| 39773 | 39752 | UnixUnusedFd *pUnused = NULL; |
| 39774 | 39753 | |
| 39775 | 39754 | /* 1. first try to open/create the file |
| | @@ -39795,11 +39774,11 @@ |
| 39795 | 39774 | fd = robust_open(path, openFlags, 0); |
| 39796 | 39775 | } |
| 39797 | 39776 | } |
| 39798 | 39777 | } |
| 39799 | 39778 | if( fd<0 ){ |
| 39800 | | - openFlags = O_RDONLY | O_NOFOLLOW; |
| 39779 | + openFlags = O_RDONLY; |
| 39801 | 39780 | fd = robust_open(path, openFlags, 0); |
| 39802 | 39781 | terrno = errno; |
| 39803 | 39782 | } |
| 39804 | 39783 | if( fd<0 ){ |
| 39805 | 39784 | if( islockfile ){ |
| | @@ -39921,11 +39900,11 @@ |
| 39921 | 39900 | if( readLen<PROXY_PATHINDEX ){ |
| 39922 | 39901 | sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen); |
| 39923 | 39902 | goto end_breaklock; |
| 39924 | 39903 | } |
| 39925 | 39904 | /* write it out to the temporary break file */ |
| 39926 | | - fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), 0); |
| 39905 | + fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0); |
| 39927 | 39906 | if( fd<0 ){ |
| 39928 | 39907 | sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 39929 | 39908 | goto end_breaklock; |
| 39930 | 39909 | } |
| 39931 | 39910 | if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){ |
| | @@ -41081,10 +41060,18 @@ |
| 41081 | 41060 | |
| 41082 | 41061 | #ifndef NTDDI_WINTHRESHOLD |
| 41083 | 41062 | # define NTDDI_WINTHRESHOLD 0x06040000 |
| 41084 | 41063 | #endif |
| 41085 | 41064 | |
| 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 | + |
| 41086 | 41073 | /* |
| 41087 | 41074 | ** Check to see if the GetVersionEx[AW] functions are deprecated on the |
| 41088 | 41075 | ** target system. GetVersionEx was first deprecated in Win8.1. |
| 41089 | 41076 | */ |
| 41090 | 41077 | #ifndef SQLITE_WIN32_GETVERSIONEX |
| | @@ -46473,10 +46460,14 @@ |
| 46473 | 46460 | break; |
| 46474 | 46461 | case SQLITE_ACCESS_READWRITE: |
| 46475 | 46462 | rc = attr!=INVALID_FILE_ATTRIBUTES && |
| 46476 | 46463 | (attr & FILE_ATTRIBUTE_READONLY)==0; |
| 46477 | 46464 | break; |
| 46465 | + case SQLITE_ACCESS_SYMLINK: |
| 46466 | + rc = attr!=INVALID_FILE_ATTRIBUTES && |
| 46467 | + (attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0; |
| 46468 | + break; |
| 46478 | 46469 | default: |
| 46479 | 46470 | assert(!"Invalid flags argument"); |
| 46480 | 46471 | } |
| 46481 | 46472 | *pResOut = rc; |
| 46482 | 46473 | OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n", |
| | @@ -49512,19 +49503,17 @@ |
| 49512 | 49503 | sqlite3_free(p); |
| 49513 | 49504 | pPg = 0; |
| 49514 | 49505 | } |
| 49515 | 49506 | #else |
| 49516 | 49507 | pPg = pcache1Alloc(pCache->szAlloc); |
| 49508 | + p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 49517 | 49509 | #endif |
| 49518 | 49510 | if( benignMalloc ){ sqlite3EndBenignMalloc(); } |
| 49519 | 49511 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 49520 | 49512 | pcache1EnterMutex(pCache->pGroup); |
| 49521 | 49513 | #endif |
| 49522 | 49514 | if( pPg==0 ) return 0; |
| 49523 | | -#ifndef SQLITE_PCACHE_SEPARATE_HEADER |
| 49524 | | - p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 49525 | | -#endif |
| 49526 | 49515 | p->page.pBuf = pPg; |
| 49527 | 49516 | p->page.pExtra = &p[1]; |
| 49528 | 49517 | p->isBulkLocal = 0; |
| 49529 | 49518 | p->isAnchor = 0; |
| 49530 | 49519 | } |
| | @@ -55793,34 +55782,31 @@ |
| 55793 | 55782 | ** to by zPathname, length nPathname. Or, if this is a temporary file, |
| 55794 | 55783 | ** leave both nPathname and zPathname set to 0. |
| 55795 | 55784 | */ |
| 55796 | 55785 | if( zFilename && zFilename[0] ){ |
| 55797 | 55786 | 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 | + } |
| 55798 | 55793 | nPathname = pVfs->mxPathname+1; |
| 55799 | 55794 | zPathname = sqlite3DbMallocRaw(0, nPathname*2); |
| 55800 | 55795 | if( zPathname==0 ){ |
| 55801 | 55796 | return SQLITE_NOMEM_BKPT; |
| 55802 | 55797 | } |
| 55803 | 55798 | zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ |
| 55804 | 55799 | 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 | | - } |
| 55814 | 55800 | nPathname = sqlite3Strlen30(zPathname); |
| 55815 | 55801 | z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; |
| 55816 | 55802 | while( *z ){ |
| 55817 | 55803 | z += strlen(z)+1; |
| 55818 | 55804 | z += strlen(z)+1; |
| 55819 | 55805 | nUri++; |
| 55820 | 55806 | } |
| 55821 | | - nUriByte = (int)(&z[1] - zUri); |
| 55807 | + nUriByte = (int)(&z[2] - zUri); |
| 55822 | 55808 | assert( nUriByte>=1 ); |
| 55823 | 55809 | if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ |
| 55824 | 55810 | /* This branch is taken when the journal path required by |
| 55825 | 55811 | ** the database being opened will be more than pVfs->mxPathname |
| 55826 | 55812 | ** bytes in length. This means the database cannot be opened, |
| | @@ -57630,11 +57616,10 @@ |
| 57630 | 57616 | |
| 57631 | 57617 | /* This routine should not be called if a prior error has occurred. |
| 57632 | 57618 | ** But if (due to a coding error elsewhere in the system) it does get |
| 57633 | 57619 | ** called, just return the same error code without doing anything. */ |
| 57634 | 57620 | if( NEVER(pPager->errCode) ) return pPager->errCode; |
| 57635 | | - pPager->iDataVersion++; |
| 57636 | 57621 | |
| 57637 | 57622 | assert( pPager->eState==PAGER_WRITER_LOCKED |
| 57638 | 57623 | || pPager->eState==PAGER_WRITER_FINISHED |
| 57639 | 57624 | || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD) |
| 57640 | 57625 | ); |
| | @@ -57659,10 +57644,11 @@ |
| 57659 | 57644 | pPager->eState = PAGER_READER; |
| 57660 | 57645 | return SQLITE_OK; |
| 57661 | 57646 | } |
| 57662 | 57647 | |
| 57663 | 57648 | PAGERTRACE(("COMMIT %d\n", PAGERID(pPager))); |
| 57649 | + pPager->iDataVersion++; |
| 57664 | 57650 | rc = pager_end_transaction(pPager, pPager->setMaster, 1); |
| 57665 | 57651 | return pager_error(pPager, rc); |
| 57666 | 57652 | } |
| 57667 | 57653 | |
| 57668 | 57654 | /* |
| | @@ -60579,23 +60565,11 @@ |
| 60579 | 60565 | ** of the aReadMark[] slot. The assumption here is that if that is |
| 60580 | 60566 | ** happening, the other client may only be increasing the value, |
| 60581 | 60567 | ** not decreasing it. So assuming either that either the "old" or |
| 60582 | 60568 | ** "new" version of the value is read, and not some arbitrary value |
| 60583 | 60569 | ** that would never be written by a real client, things are still |
| 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 | | - */ |
| 60570 | + ** safe. */ |
| 60597 | 60571 | u32 y = pInfo->aReadMark[i]; |
| 60598 | 60572 | if( mxSafeFrame>y ){ |
| 60599 | 60573 | assert( y<=pWal->hdr.mxFrame ); |
| 60600 | 60574 | rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); |
| 60601 | 60575 | if( rc==SQLITE_OK ){ |
| | @@ -66047,17 +66021,13 @@ |
| 66047 | 66021 | memcpy(zFullPathname, zFilename, nFilename); |
| 66048 | 66022 | }else{ |
| 66049 | 66023 | rc = sqlite3OsFullPathname(pVfs, zFilename, |
| 66050 | 66024 | nFullPathname, zFullPathname); |
| 66051 | 66025 | if( 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 | | - } |
| 66026 | + sqlite3_free(zFullPathname); |
| 66027 | + sqlite3_free(p); |
| 66028 | + return rc; |
| 66059 | 66029 | } |
| 66060 | 66030 | } |
| 66061 | 66031 | #if SQLITE_THREADSAFE |
| 66062 | 66032 | mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN); |
| 66063 | 66033 | sqlite3_mutex_enter(mutexOpen); |
| | @@ -69362,15 +69332,12 @@ |
| 69362 | 69332 | |
| 69363 | 69333 | /* If the database file is corrupt, it is possible for the value of idx |
| 69364 | 69334 | ** to be invalid here. This can only occur if a second cursor modifies |
| 69365 | 69335 | ** the page while cursor pCur is holding a reference to it. Which can |
| 69366 | 69336 | ** only happen if the database is corrupt in such a way as to link the |
| 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 ); |
| 69337 | + ** page into more than one b-tree structure. */ |
| 69338 | + testcase( idx>pPage->nCell ); |
| 69372 | 69339 | |
| 69373 | 69340 | if( idx>=pPage->nCell ){ |
| 69374 | 69341 | if( !pPage->leaf ){ |
| 69375 | 69342 | rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); |
| 69376 | 69343 | if( rc ) return rc; |
| | @@ -71955,34 +71922,10 @@ |
| 71955 | 71922 | |
| 71956 | 71923 | *ppChild = pChild; |
| 71957 | 71924 | return SQLITE_OK; |
| 71958 | 71925 | } |
| 71959 | 71926 | |
| 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 | | -} |
| 71983 | | - |
| 71984 | 71927 | /* |
| 71985 | 71928 | ** The page that pCur currently points to has just been modified in |
| 71986 | 71929 | ** some way. This function figures out if this modification means the |
| 71987 | 71930 | ** tree needs to be balanced, and if so calls the appropriate balancing |
| 71988 | 71931 | ** routine. Balancing routines are: |
| | @@ -72006,11 +71949,11 @@ |
| 72006 | 71949 | |
| 72007 | 71950 | if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break; |
| 72008 | 71951 | if( pPage->nOverflow==0 && pPage->nFree<=nMin ){ |
| 72009 | 71952 | break; |
| 72010 | 71953 | }else if( (iPage = pCur->iPage)==0 ){ |
| 72011 | | - if( pPage->nOverflow && (rc = anotherValidCursor(pCur))==SQLITE_OK ){ |
| 71954 | + if( pPage->nOverflow ){ |
| 72012 | 71955 | /* The root page of the b-tree is overfull. In this case call the |
| 72013 | 71956 | ** balance_deeper() function to create a new child for the root-page |
| 72014 | 71957 | ** and copy the current contents of the root-page to it. The |
| 72015 | 71958 | ** next iteration of the do-loop will balance the child page. |
| 72016 | 71959 | */ |
| | @@ -72377,13 +72320,11 @@ |
| 72377 | 72320 | return btreeOverwriteCell(pCur, &x2); |
| 72378 | 72321 | } |
| 72379 | 72322 | } |
| 72380 | 72323 | |
| 72381 | 72324 | } |
| 72382 | | - assert( pCur->eState==CURSOR_VALID |
| 72383 | | - || (pCur->eState==CURSOR_INVALID && loc) |
| 72384 | | - || CORRUPT_DB ); |
| 72325 | + assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) ); |
| 72385 | 72326 | |
| 72386 | 72327 | pPage = pCur->pPage; |
| 72387 | 72328 | assert( pPage->intKey || pX->nKey>=0 ); |
| 72388 | 72329 | assert( pPage->leaf || !pPage->intKey ); |
| 72389 | 72330 | if( pPage->nFree<0 ){ |
| | @@ -75548,11 +75489,12 @@ |
| 75548 | 75489 | if( flags & (MEM_Int|MEM_IntReal) ){ |
| 75549 | 75490 | testcase( flags & MEM_IntReal ); |
| 75550 | 75491 | return pMem->u.i; |
| 75551 | 75492 | }else if( flags & MEM_Real ){ |
| 75552 | 75493 | return doubleToInt64(pMem->u.r); |
| 75553 | | - }else if( (flags & (MEM_Str|MEM_Blob))!=0 && pMem->z!=0 ){ |
| 75494 | + }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 75495 | + assert( pMem->z || pMem->n==0 ); |
| 75554 | 75496 | return memIntValue(pMem); |
| 75555 | 75497 | }else{ |
| 75556 | 75498 | return 0; |
| 75557 | 75499 | } |
| 75558 | 75500 | } |
| | @@ -75705,12 +75647,12 @@ |
| 75705 | 75647 | ** "aff". Casting is different from applying affinity in that a cast |
| 75706 | 75648 | ** is forced. In other words, the value is converted into the desired |
| 75707 | 75649 | ** affinity even if that results in loss of data. This routine is |
| 75708 | 75650 | ** used (for example) to implement the SQL "cast()" operator. |
| 75709 | 75651 | */ |
| 75710 | | -SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ |
| 75711 | | - if( pMem->flags & MEM_Null ) return SQLITE_OK; |
| 75652 | +SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ |
| 75653 | + if( pMem->flags & MEM_Null ) return; |
| 75712 | 75654 | switch( aff ){ |
| 75713 | 75655 | case SQLITE_AFF_BLOB: { /* Really a cast to BLOB */ |
| 75714 | 75656 | if( (pMem->flags & MEM_Blob)==0 ){ |
| 75715 | 75657 | sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding); |
| 75716 | 75658 | assert( pMem->flags & MEM_Str || pMem->db->mallocFailed ); |
| | @@ -75737,14 +75679,13 @@ |
| 75737 | 75679 | assert( MEM_Str==(MEM_Blob>>3) ); |
| 75738 | 75680 | pMem->flags |= (pMem->flags&MEM_Blob)>>3; |
| 75739 | 75681 | sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding); |
| 75740 | 75682 | assert( pMem->flags & MEM_Str || pMem->db->mallocFailed ); |
| 75741 | 75683 | pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero); |
| 75742 | | - return sqlite3VdbeChangeEncoding(pMem, encoding); |
| 75684 | + break; |
| 75743 | 75685 | } |
| 75744 | 75686 | } |
| 75745 | | - return SQLITE_OK; |
| 75746 | 75687 | } |
| 75747 | 75688 | |
| 75748 | 75689 | /* |
| 75749 | 75690 | ** Initialize bulk memory to be a consistent Mem object. |
| 75750 | 75691 | ** |
| | @@ -77513,11 +77454,10 @@ |
| 77513 | 77454 | ** |
| 77514 | 77455 | ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort. |
| 77515 | 77456 | ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. |
| 77516 | 77457 | ** * OP_Destroy |
| 77517 | 77458 | ** * OP_VUpdate |
| 77518 | | -** * OP_VCreate |
| 77519 | 77459 | ** * OP_VRename |
| 77520 | 77460 | ** * OP_FkCounter with P2==0 (immediate foreign key constraint) |
| 77521 | 77461 | ** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine |
| 77522 | 77462 | ** (for CREATE TABLE AS SELECT ...) |
| 77523 | 77463 | ** |
| | @@ -77541,11 +77481,10 @@ |
| 77541 | 77481 | |
| 77542 | 77482 | while( (pOp = opIterNext(&sIter))!=0 ){ |
| 77543 | 77483 | int opcode = pOp->opcode; |
| 77544 | 77484 | if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename |
| 77545 | 77485 | || opcode==OP_VDestroy |
| 77546 | | - || opcode==OP_VCreate |
| 77547 | 77486 | || (opcode==OP_ParseSchema && pOp->p4.z==0) |
| 77548 | 77487 | || ((opcode==OP_Halt || opcode==OP_HaltIfNull) |
| 77549 | 77488 | && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort)) |
| 77550 | 77489 | ){ |
| 77551 | 77490 | hasAbort = 1; |
| | @@ -78031,33 +77970,10 @@ |
| 78031 | 77970 | return sqlite3VdbeChangeToNoop(p, p->nOp-1); |
| 78032 | 77971 | }else{ |
| 78033 | 77972 | return 0; |
| 78034 | 77973 | } |
| 78035 | 77974 | } |
| 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 | | - |
| 78059 | 77975 | |
| 78060 | 77976 | /* |
| 78061 | 77977 | ** Change the value of the P4 operand for a specific instruction. |
| 78062 | 77978 | ** This routine is useful when a large program is loaded from a |
| 78063 | 77979 | ** static array using sqlite3VdbeAddOpList but we want to make a |
| | @@ -78172,12 +78088,11 @@ |
| 78172 | 78088 | ** makes the code easier to read during debugging. None of this happens |
| 78173 | 78089 | ** in a production build. |
| 78174 | 78090 | */ |
| 78175 | 78091 | static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){ |
| 78176 | 78092 | assert( p->nOp>0 || p->aOp==0 ); |
| 78177 | | - assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed |
| 78178 | | - || p->pParse->nErr>0 ); |
| 78093 | + assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); |
| 78179 | 78094 | if( p->nOp ){ |
| 78180 | 78095 | assert( p->aOp ); |
| 78181 | 78096 | sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment); |
| 78182 | 78097 | p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap); |
| 78183 | 78098 | } |
| | @@ -86213,15 +86128,13 @@ |
| 86213 | 86128 | testcase( pOp->p2==SQLITE_AFF_INTEGER ); |
| 86214 | 86129 | testcase( pOp->p2==SQLITE_AFF_REAL ); |
| 86215 | 86130 | pIn1 = &aMem[pOp->p1]; |
| 86216 | 86131 | memAboutToChange(p, pIn1); |
| 86217 | 86132 | rc = ExpandBlob(pIn1); |
| 86218 | | - if( rc ) goto abort_due_to_error; |
| 86219 | | - rc = sqlite3VdbeMemCast(pIn1, pOp->p2, encoding); |
| 86220 | | - if( rc ) goto abort_due_to_error; |
| 86133 | + sqlite3VdbeMemCast(pIn1, pOp->p2, encoding); |
| 86221 | 86134 | UPDATE_MAX_BLOBSIZE(pIn1); |
| 86222 | | - REGISTER_TRACE(pOp->p1, pIn1); |
| 86135 | + if( rc ) goto abort_due_to_error; |
| 86223 | 86136 | break; |
| 86224 | 86137 | } |
| 86225 | 86138 | #endif /* SQLITE_OMIT_CAST */ |
| 86226 | 86139 | |
| 86227 | 86140 | /* Opcode: Eq P1 P2 P3 P4 P5 |
| | @@ -86376,11 +86289,16 @@ |
| 86376 | 86289 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 86377 | 86290 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 86378 | 86291 | if( (flags1 | flags3)&MEM_Str ){ |
| 86379 | 86292 | if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 86380 | 86293 | applyNumericAffinity(pIn1,0); |
| 86381 | | - testcase( flags3!=pIn3->flags ); |
| 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. */ |
| 86382 | 86300 | flags3 = pIn3->flags; |
| 86383 | 86301 | } |
| 86384 | 86302 | if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 86385 | 86303 | applyNumericAffinity(pIn3,0); |
| 86386 | 86304 | } |
| | @@ -86399,11 +86317,11 @@ |
| 86399 | 86317 | testcase( pIn1->flags & MEM_Real ); |
| 86400 | 86318 | testcase( pIn1->flags & MEM_IntReal ); |
| 86401 | 86319 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 86402 | 86320 | testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); |
| 86403 | 86321 | flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); |
| 86404 | | - if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str; |
| 86322 | + assert( pIn1!=pIn3 ); |
| 86405 | 86323 | } |
| 86406 | 86324 | if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 86407 | 86325 | testcase( pIn3->flags & MEM_Int ); |
| 86408 | 86326 | testcase( pIn3->flags & MEM_Real ); |
| 86409 | 86327 | testcase( pIn3->flags & MEM_IntReal ); |
| | @@ -86434,14 +86352,14 @@ |
| 86434 | 86352 | static const unsigned char aGTb[] = { 1, 0, 1, 0, 0, 1 }; |
| 86435 | 86353 | res2 = aGTb[pOp->opcode - OP_Ne]; |
| 86436 | 86354 | } |
| 86437 | 86355 | |
| 86438 | 86356 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 86357 | + assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); |
| 86358 | + pIn1->flags = flags1; |
| 86439 | 86359 | assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); |
| 86440 | 86360 | pIn3->flags = flags3; |
| 86441 | | - assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); |
| 86442 | | - pIn1->flags = flags1; |
| 86443 | 86361 | |
| 86444 | 86362 | if( pOp->p5 & SQLITE_STOREP2 ){ |
| 86445 | 86363 | pOut = &aMem[pOp->p2]; |
| 86446 | 86364 | iCompare = res; |
| 86447 | 86365 | if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){ |
| | @@ -86473,35 +86391,20 @@ |
| 86473 | 86391 | break; |
| 86474 | 86392 | } |
| 86475 | 86393 | |
| 86476 | 86394 | /* Opcode: ElseNotEq * P2 * * * |
| 86477 | 86395 | ** |
| 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. |
| 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. |
| 86488 | 86401 | */ |
| 86489 | 86402 | case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */ |
| 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 */ |
| 86403 | + assert( pOp>aOp ); |
| 86404 | + assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt ); |
| 86405 | + assert( pOp[-1].p5 & SQLITE_STOREP2 ); |
| 86503 | 86406 | VdbeBranchTaken(iCompare!=0, 2); |
| 86504 | 86407 | if( iCompare!=0 ) goto jump_to_p2; |
| 86505 | 86408 | break; |
| 86506 | 86409 | } |
| 86507 | 86410 | |
| | @@ -86908,13 +86811,11 @@ |
| 86908 | 86811 | const u8 *zEndHdr; /* Pointer to first byte after the header */ |
| 86909 | 86812 | u64 offset64; /* 64-bit offset */ |
| 86910 | 86813 | u32 t; /* A type code from the record header */ |
| 86911 | 86814 | Mem *pReg; /* PseudoTable input register */ |
| 86912 | 86815 | |
| 86913 | | - assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 86914 | 86816 | pC = p->apCsr[pOp->p1]; |
| 86915 | | - assert( pC!=0 ); |
| 86916 | 86817 | p2 = pOp->p2; |
| 86917 | 86818 | |
| 86918 | 86819 | /* If the cursor cache is stale (meaning it is not currently point at |
| 86919 | 86820 | ** the correct row) then bring it up-to-date by doing the necessary |
| 86920 | 86821 | ** B-Tree seek. */ |
| | @@ -86922,10 +86823,11 @@ |
| 86922 | 86823 | if( rc ) goto abort_due_to_error; |
| 86923 | 86824 | |
| 86924 | 86825 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 86925 | 86826 | pDest = &aMem[pOp->p3]; |
| 86926 | 86827 | memAboutToChange(p, pDest); |
| 86828 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 86927 | 86829 | assert( pC!=0 ); |
| 86928 | 86830 | assert( p2<pC->nField ); |
| 86929 | 86831 | aOffset = pC->aOffset; |
| 86930 | 86832 | assert( pC->eCurType!=CURTYPE_VTAB ); |
| 86931 | 86833 | assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow ); |
| | @@ -87178,11 +87080,11 @@ |
| 87178 | 87080 | assert( pOp->p2>0 ); |
| 87179 | 87081 | assert( zAffinity[pOp->p2]==0 ); |
| 87180 | 87082 | pIn1 = &aMem[pOp->p1]; |
| 87181 | 87083 | while( 1 /*exit-by-break*/ ){ |
| 87182 | 87084 | assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] ); |
| 87183 | | - assert( zAffinity[0]==SQLITE_AFF_NONE || memIsValid(pIn1) ); |
| 87085 | + assert( memIsValid(pIn1) ); |
| 87184 | 87086 | applyAffinity(pIn1, zAffinity[0], encoding); |
| 87185 | 87087 | if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){ |
| 87186 | 87088 | /* When applying REAL affinity, if the result is still an MEM_Int |
| 87187 | 87089 | ** that will fit in 6 bytes, then change the type to MEM_IntReal |
| 87188 | 87090 | ** so that we keep the high-resolution integer value but know that |
| | @@ -87624,16 +87526,12 @@ |
| 87624 | 87526 | p->pc = (int)(pOp - aOp); |
| 87625 | 87527 | db->autoCommit = 0; |
| 87626 | 87528 | p->rc = rc = SQLITE_BUSY; |
| 87627 | 87529 | goto vdbe_return; |
| 87628 | 87530 | } |
| 87531 | + db->isTransactionSavepoint = 0; |
| 87629 | 87532 | rc = p->rc; |
| 87630 | | - if( rc ){ |
| 87631 | | - db->autoCommit = 0; |
| 87632 | | - }else{ |
| 87633 | | - db->isTransactionSavepoint = 0; |
| 87634 | | - } |
| 87635 | 87533 | }else{ |
| 87636 | 87534 | int isSchemaChange; |
| 87637 | 87535 | iSavepoint = db->nSavepoint - iSavepoint - 1; |
| 87638 | 87536 | if( p1==SAVEPOINT_ROLLBACK ){ |
| 87639 | 87537 | isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0; |
| | @@ -87657,11 +87555,10 @@ |
| 87657 | 87555 | sqlite3ExpirePreparedStatements(db, 0); |
| 87658 | 87556 | sqlite3ResetAllSchemasOfConnection(db); |
| 87659 | 87557 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 87660 | 87558 | } |
| 87661 | 87559 | } |
| 87662 | | - if( rc ) goto abort_due_to_error; |
| 87663 | 87560 | |
| 87664 | 87561 | /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all |
| 87665 | 87562 | ** savepoints nested inside of the savepoint being operated on. */ |
| 87666 | 87563 | while( db->pSavepoint!=pSavepoint ){ |
| 87667 | 87564 | pTmp = db->pSavepoint; |
| | @@ -88153,11 +88050,10 @@ |
| 88153 | 88050 | case OP_OpenDup: { |
| 88154 | 88051 | VdbeCursor *pOrig; /* The original cursor to be duplicated */ |
| 88155 | 88052 | VdbeCursor *pCx; /* The new cursor */ |
| 88156 | 88053 | |
| 88157 | 88054 | pOrig = p->apCsr[pOp->p2]; |
| 88158 | | - assert( pOrig ); |
| 88159 | 88055 | assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */ |
| 88160 | 88056 | |
| 88161 | 88057 | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); |
| 88162 | 88058 | if( pCx==0 ) goto no_mem; |
| 88163 | 88059 | pCx->nullRow = 1; |
| | @@ -91583,11 +91479,11 @@ |
| 91583 | 91479 | pVtab = pCur->uc.pVCur->pVtab; |
| 91584 | 91480 | pModule = pVtab->pModule; |
| 91585 | 91481 | assert( pModule->xColumn ); |
| 91586 | 91482 | memset(&sContext, 0, sizeof(sContext)); |
| 91587 | 91483 | sContext.pOut = pDest; |
| 91588 | | - assert( pOp->p5==OPFLAG_NOCHNG || pOp->p5==0 ); |
| 91484 | + testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 ); |
| 91589 | 91485 | if( pOp->p5 & OPFLAG_NOCHNG ){ |
| 91590 | 91486 | sqlite3VdbeMemSetNull(pDest); |
| 91591 | 91487 | pDest->flags = MEM_Null|MEM_Zero; |
| 91592 | 91488 | pDest->u.nZero = 0; |
| 91593 | 91489 | }else{ |
| | @@ -92040,57 +91936,10 @@ |
| 92040 | 91936 | ** An Abort is safe if either there have been no writes, or if there is |
| 92041 | 91937 | ** an active statement journal. |
| 92042 | 91938 | */ |
| 92043 | 91939 | case OP_Abortable: { |
| 92044 | 91940 | sqlite3VdbeAssertAbortable(p); |
| 92045 | | - break; |
| 92046 | | -} |
| 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 | 91941 | break; |
| 92093 | 91942 | } |
| 92094 | 91943 | #endif |
| 92095 | 91944 | |
| 92096 | 91945 | /* Opcode: Noop * * * * * |
| | @@ -96000,12 +95849,12 @@ |
| 96000 | 95849 | testcase( ExprHasProperty(pExpr, EP_Reduced) ); |
| 96001 | 95850 | while(1){ |
| 96002 | 95851 | rc = pWalker->xExprCallback(pWalker, pExpr); |
| 96003 | 95852 | if( rc ) return rc & WRC_Abort; |
| 96004 | 95853 | if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ |
| 96005 | | - assert( pExpr->x.pList==0 || pExpr->pRight==0 ); |
| 96006 | 95854 | if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; |
| 95855 | + assert( pExpr->x.pList==0 || pExpr->pRight==0 ); |
| 96007 | 95856 | if( pExpr->pRight ){ |
| 96008 | 95857 | assert( !ExprHasProperty(pExpr, EP_WinFunc) ); |
| 96009 | 95858 | pExpr = pExpr->pRight; |
| 96010 | 95859 | continue; |
| 96011 | 95860 | }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| | @@ -96689,39 +96538,22 @@ |
| 96689 | 96538 | pTopNC->nErr++; |
| 96690 | 96539 | } |
| 96691 | 96540 | |
| 96692 | 96541 | /* If a column from a table in pSrcList is referenced, then record |
| 96693 | 96542 | ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes |
| 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. |
| 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. |
| 96705 | 96546 | */ |
| 96706 | 96547 | if( pExpr->iColumn>=0 && pMatch!=0 ){ |
| 96707 | 96548 | int n = pExpr->iColumn; |
| 96708 | | - Table *pExTab = pExpr->y.pTab; |
| 96709 | | - assert( pExTab!=0 ); |
| 96549 | + testcase( n==BMS-1 ); |
| 96550 | + if( n>=BMS ){ |
| 96551 | + n = BMS-1; |
| 96552 | + } |
| 96710 | 96553 | assert( pMatch->iCursor==pExpr->iTable ); |
| 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 | | - } |
| 96554 | + pMatch->colUsed |= ((Bitmask)1)<<n; |
| 96723 | 96555 | } |
| 96724 | 96556 | |
| 96725 | 96557 | /* Clean up and return |
| 96726 | 96558 | */ |
| 96727 | 96559 | sqlite3ExprDelete(db, pExpr->pLeft); |
| | @@ -96756,68 +96588,47 @@ |
| 96756 | 96588 | */ |
| 96757 | 96589 | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){ |
| 96758 | 96590 | Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0); |
| 96759 | 96591 | if( p ){ |
| 96760 | 96592 | struct SrcList_item *pItem = &pSrc->a[iSrc]; |
| 96761 | | - Table *pTab = p->y.pTab = pItem->pTab; |
| 96593 | + p->y.pTab = pItem->pTab; |
| 96762 | 96594 | p->iTable = pItem->iCursor; |
| 96763 | 96595 | if( p->y.pTab->iPKey==iCol ){ |
| 96764 | 96596 | p->iColumn = -1; |
| 96765 | 96597 | }else{ |
| 96766 | 96598 | p->iColumn = (ynVar)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 | | - } |
| 96599 | + testcase( iCol==BMS ); |
| 96600 | + testcase( iCol==BMS-1 ); |
| 96601 | + pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol); |
| 96778 | 96602 | } |
| 96779 | 96603 | } |
| 96780 | 96604 | return p; |
| 96781 | 96605 | } |
| 96782 | 96606 | |
| 96783 | 96607 | /* |
| 96784 | 96608 | ** Report an error that an expression is not valid for some set of |
| 96785 | 96609 | ** 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. |
| 96798 | 96610 | */ |
| 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 */ |
| 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 */ |
| 96804 | 96616 | ){ |
| 96805 | | - const char *zIn = "partial index WHERE clauses"; |
| 96806 | | - if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions"; |
| 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"; |
| 96807 | 96621 | #ifndef SQLITE_OMIT_CHECK |
| 96808 | | - else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; |
| 96622 | + else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; |
| 96809 | 96623 | #endif |
| 96810 | 96624 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 96811 | | - else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns"; |
| 96625 | + else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns"; |
| 96812 | 96626 | #endif |
| 96813 | | - sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); |
| 96814 | | - if( pExpr ) pExpr->op = TK_NULL; |
| 96627 | + sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); |
| 96628 | + } |
| 96815 | 96629 | } |
| 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); |
| 96819 | 96630 | |
| 96820 | 96631 | /* |
| 96821 | 96632 | ** Expression p should encode a floating point value between 1.0 and 0.0. |
| 96822 | 96633 | ** Return 1024 times this value. Or return -1 if p is not a floating point |
| 96823 | 96634 | ** value between 1.0 and 0.0. |
| | @@ -96902,14 +96713,11 @@ |
| 96902 | 96713 | zDb = 0; |
| 96903 | 96714 | zTable = 0; |
| 96904 | 96715 | zColumn = pExpr->u.zToken; |
| 96905 | 96716 | }else{ |
| 96906 | 96717 | Expr *pLeft = pExpr->pLeft; |
| 96907 | | - testcase( pNC->ncFlags & NC_IdxExpr ); |
| 96908 | | - testcase( pNC->ncFlags & NC_GenCol ); |
| 96909 | | - sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator", |
| 96910 | | - NC_IdxExpr|NC_GenCol, 0); |
| 96718 | + notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr|NC_GenCol); |
| 96911 | 96719 | pRight = pExpr->pRight; |
| 96912 | 96720 | if( pRight->op==TK_ID ){ |
| 96913 | 96721 | zDb = 0; |
| 96914 | 96722 | }else{ |
| 96915 | 96723 | assert( pRight->op==TK_DOT ); |
| | @@ -97002,12 +96810,11 @@ |
| 97002 | 96810 | } |
| 97003 | 96811 | if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 97004 | 96812 | /* Date/time functions that use 'now', and other functions like |
| 97005 | 96813 | ** sqlite_version() that might change over time cannot be used |
| 97006 | 96814 | ** in an index. */ |
| 97007 | | - sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions", |
| 97008 | | - NC_SelfRef, 0); |
| 96815 | + notValid(pParse, pNC, "non-deterministic functions", NC_SelfRef); |
| 97009 | 96816 | }else{ |
| 97010 | 96817 | assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */ |
| 97011 | 96818 | pExpr->op2 = pNC->ncFlags & NC_SelfRef; |
| 97012 | 96819 | } |
| 97013 | 96820 | if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0 |
| | @@ -97105,11 +96912,11 @@ |
| 97105 | 96912 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 97106 | 96913 | if( pWin ){ |
| 97107 | 96914 | Select *pSel = pNC->pWinSelect; |
| 97108 | 96915 | assert( pWin==pExpr->y.pWin ); |
| 97109 | 96916 | if( IN_RENAME_OBJECT==0 ){ |
| 97110 | | - sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); |
| 96917 | + sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef); |
| 97111 | 96918 | } |
| 97112 | 96919 | sqlite3WalkExprList(pWalker, pWin->pPartition); |
| 97113 | 96920 | sqlite3WalkExprList(pWalker, pWin->pOrderBy); |
| 97114 | 96921 | sqlite3WalkExpr(pWalker, pWin->pFilter); |
| 97115 | 96922 | sqlite3WindowLink(pSel, pWin); |
| | @@ -97150,16 +96957,12 @@ |
| 97150 | 96957 | #endif |
| 97151 | 96958 | case TK_IN: { |
| 97152 | 96959 | testcase( pExpr->op==TK_IN ); |
| 97153 | 96960 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 97154 | 96961 | int nRef = pNC->nRef; |
| 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); |
| 96962 | + notValid(pParse, pNC, "subqueries", |
| 96963 | + NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol); |
| 97161 | 96964 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 97162 | 96965 | assert( pNC->nRef>=nRef ); |
| 97163 | 96966 | if( nRef!=pNC->nRef ){ |
| 97164 | 96967 | ExprSetProperty(pExpr, EP_VarSelect); |
| 97165 | 96968 | pNC->ncFlags |= NC_VarSelect; |
| | @@ -97166,16 +96969,12 @@ |
| 97166 | 96969 | } |
| 97167 | 96970 | } |
| 97168 | 96971 | break; |
| 97169 | 96972 | } |
| 97170 | 96973 | case TK_VARIABLE: { |
| 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); |
| 96974 | + notValid(pParse, pNC, "parameters", |
| 96975 | + NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol); |
| 97177 | 96976 | break; |
| 97178 | 96977 | } |
| 97179 | 96978 | case TK_IS: |
| 97180 | 96979 | case TK_ISNOT: { |
| 97181 | 96980 | Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight); |
| | @@ -98404,11 +98203,10 @@ |
| 98404 | 98203 | ){ |
| 98405 | 98204 | int p5; |
| 98406 | 98205 | int addr; |
| 98407 | 98206 | CollSeq *p4; |
| 98408 | 98207 | |
| 98409 | | - if( pParse->nErr ) return 0; |
| 98410 | 98208 | if( isCommuted ){ |
| 98411 | 98209 | p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft); |
| 98412 | 98210 | }else{ |
| 98413 | 98211 | p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); |
| 98414 | 98212 | } |
| | @@ -98622,11 +98420,10 @@ |
| 98622 | 98420 | int regRight = 0; |
| 98623 | 98421 | u8 opx = op; |
| 98624 | 98422 | int addrDone = sqlite3VdbeMakeLabel(pParse); |
| 98625 | 98423 | int isCommuted = ExprHasProperty(pExpr,EP_Commuted); |
| 98626 | 98424 | |
| 98627 | | - if( pParse->nErr ) return; |
| 98628 | 98425 | if( nLeft!=sqlite3ExprVectorSize(pRight) ){ |
| 98629 | 98426 | sqlite3ErrorMsg(pParse, "row value misused"); |
| 98630 | 98427 | return; |
| 98631 | 98428 | } |
| 98632 | 98429 | assert( pExpr->op==TK_EQ || pExpr->op==TK_NE |
| | @@ -99971,13 +99768,11 @@ |
| 99971 | 99768 | switch( pExpr->op ){ |
| 99972 | 99769 | /* Consider functions to be constant if all their arguments are constant |
| 99973 | 99770 | ** and either pWalker->eCode==4 or 5 or the function has the |
| 99974 | 99771 | ** SQLITE_FUNC_CONST flag. */ |
| 99975 | 99772 | case TK_FUNCTION: |
| 99976 | | - if( (pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc)) |
| 99977 | | - && !ExprHasProperty(pExpr, EP_WinFunc) |
| 99978 | | - ){ |
| 99773 | + if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){ |
| 99979 | 99774 | return WRC_Continue; |
| 99980 | 99775 | }else{ |
| 99981 | 99776 | pWalker->eCode = 0; |
| 99982 | 99777 | return WRC_Abort; |
| 99983 | 99778 | } |
| | @@ -100236,13 +100031,11 @@ |
| 100236 | 100031 | case TK_BLOB: |
| 100237 | 100032 | return 0; |
| 100238 | 100033 | case TK_COLUMN: |
| 100239 | 100034 | return ExprHasProperty(p, EP_CanBeNull) || |
| 100240 | 100035 | p->y.pTab==0 || /* Reference to column of index on expression */ |
| 100241 | | - (p->iColumn>=0 |
| 100242 | | - && ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */ |
| 100243 | | - && p->y.pTab->aCol[p->iColumn].notNull==0); |
| 100036 | + (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0); |
| 100244 | 100037 | default: |
| 100245 | 100038 | return 1; |
| 100246 | 100039 | } |
| 100247 | 100040 | } |
| 100248 | 100041 | |
| | @@ -100715,14 +100508,12 @@ |
| 100715 | 100508 | ** message of the form: |
| 100716 | 100509 | ** |
| 100717 | 100510 | ** "sub-select returns N columns - expected M" |
| 100718 | 100511 | */ |
| 100719 | 100512 | SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){ |
| 100720 | | - if( pParse->nErr==0 ){ |
| 100721 | | - const char *zFmt = "sub-select returns %d columns - expected %d"; |
| 100722 | | - sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect); |
| 100723 | | - } |
| 100513 | + const char *zFmt = "sub-select returns %d columns - expected %d"; |
| 100514 | + sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect); |
| 100724 | 100515 | } |
| 100725 | 100516 | #endif |
| 100726 | 100517 | |
| 100727 | 100518 | /* |
| 100728 | 100519 | ** Expression pExpr is a vector that has been used in a context where |
| | @@ -101220,25 +101011,19 @@ |
| 101220 | 101011 | } |
| 101221 | 101012 | if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){ |
| 101222 | 101013 | sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull); |
| 101223 | 101014 | } |
| 101224 | 101015 | if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){ |
| 101225 | | - int op = rLhs!=r2 ? OP_Eq : OP_NotNull; |
| 101226 | | - sqlite3VdbeAddOp4(v, op, rLhs, labelOk, r2, |
| 101016 | + sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2, |
| 101227 | 101017 | (void*)pColl, P4_COLLSEQ); |
| 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); |
| 101018 | + VdbeCoverageIf(v, ii<pList->nExpr-1); |
| 101019 | + VdbeCoverageIf(v, ii==pList->nExpr-1); |
| 101232 | 101020 | sqlite3VdbeChangeP5(v, zAff[0]); |
| 101233 | 101021 | }else{ |
| 101234 | | - int op = rLhs!=r2 ? OP_Ne : OP_IsNull; |
| 101235 | 101022 | assert( destIfNull==destIfFalse ); |
| 101236 | | - sqlite3VdbeAddOp4(v, op, rLhs, destIfFalse, r2, |
| 101237 | | - (void*)pColl, P4_COLLSEQ); |
| 101238 | | - VdbeCoverageIf(v, op==OP_Ne); |
| 101239 | | - VdbeCoverageIf(v, op==OP_IsNull); |
| 101023 | + sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2, |
| 101024 | + (void*)pColl, P4_COLLSEQ); VdbeCoverage(v); |
| 101240 | 101025 | sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL); |
| 101241 | 101026 | } |
| 101242 | 101027 | sqlite3ReleaseTempReg(pParse, regToFree); |
| 101243 | 101028 | } |
| 101244 | 101029 | if( regCkNull ){ |
| | @@ -101257,11 +101042,10 @@ |
| 101257 | 101042 | if( destIfNull==destIfFalse ){ |
| 101258 | 101043 | destStep2 = destIfFalse; |
| 101259 | 101044 | }else{ |
| 101260 | 101045 | destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse); |
| 101261 | 101046 | } |
| 101262 | | - if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; |
| 101263 | 101047 | for(i=0; i<nVector; i++){ |
| 101264 | 101048 | Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i); |
| 101265 | 101049 | if( sqlite3ExprCanBeNull(p) ){ |
| 101266 | 101050 | sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2); |
| 101267 | 101051 | VdbeCoverage(v); |
| | @@ -101449,24 +101233,15 @@ |
| 101449 | 101233 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn( |
| 101450 | 101234 | Parse *pParse, |
| 101451 | 101235 | Column *pCol, |
| 101452 | 101236 | int regOut |
| 101453 | 101237 | ){ |
| 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 | | - } |
| 101463 | 101238 | sqlite3ExprCode(pParse, pCol->pDflt, regOut); |
| 101464 | 101239 | if( pCol->affinity>=SQLITE_AFF_TEXT ){ |
| 101465 | | - sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1); |
| 101240 | + sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0, |
| 101241 | + &pCol->affinity, 1); |
| 101466 | 101242 | } |
| 101467 | | - if( iAddr ) sqlite3VdbeJumpHere(v, iAddr); |
| 101468 | 101243 | } |
| 101469 | 101244 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ |
| 101470 | 101245 | |
| 101471 | 101246 | /* |
| 101472 | 101247 | ** Generate code to extract the value of the iCol-th column of a table. |
| | @@ -101537,21 +101312,21 @@ |
| 101537 | 101312 | u8 p5 /* P5 value for OP_Column + FLAGS */ |
| 101538 | 101313 | ){ |
| 101539 | 101314 | assert( pParse->pVdbe!=0 ); |
| 101540 | 101315 | sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg); |
| 101541 | 101316 | if( p5 ){ |
| 101542 | | - VdbeOp *pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1); |
| 101543 | | - if( pOp->opcode==OP_Column ) pOp->p5 = p5; |
| 101317 | + sqlite3VdbeChangeP5(pParse->pVdbe, p5); |
| 101544 | 101318 | } |
| 101545 | 101319 | return iReg; |
| 101546 | 101320 | } |
| 101547 | 101321 | |
| 101548 | 101322 | /* |
| 101549 | 101323 | ** Generate code to move content from registers iFrom...iFrom+nReg-1 |
| 101550 | 101324 | ** over to iTo..iTo+nReg-1. |
| 101551 | 101325 | */ |
| 101552 | 101326 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){ |
| 101327 | + assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo ); |
| 101553 | 101328 | sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg); |
| 101554 | 101329 | } |
| 101555 | 101330 | |
| 101556 | 101331 | /* |
| 101557 | 101332 | ** Convert a scalar expression node to a TK_REGISTER referencing |
| | @@ -101649,25 +101424,19 @@ |
| 101649 | 101424 | } |
| 101650 | 101425 | /* Otherwise, fall thru into the TK_COLUMN case */ |
| 101651 | 101426 | } |
| 101652 | 101427 | case TK_COLUMN: { |
| 101653 | 101428 | int iTab = pExpr->iTable; |
| 101654 | | - int iReg; |
| 101655 | 101429 | if( ExprHasProperty(pExpr, EP_FixedCol) ){ |
| 101656 | 101430 | /* This COLUMN expression is really a constant due to WHERE clause |
| 101657 | 101431 | ** constraints, and that constant is coded by the pExpr->pLeft |
| 101658 | 101432 | ** expresssion. However, make sure the constant has the correct |
| 101659 | 101433 | ** datatype by applying the Affinity of the table column to the |
| 101660 | 101434 | ** constant. |
| 101661 | 101435 | */ |
| 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 | | - } |
| 101436 | + int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); |
| 101437 | + int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); |
| 101669 | 101438 | if( aff>SQLITE_AFF_BLOB ){ |
| 101670 | 101439 | static const char zAff[] = "B\000C\000D\000E"; |
| 101671 | 101440 | assert( SQLITE_AFF_BLOB=='A' ); |
| 101672 | 101441 | assert( SQLITE_AFF_TEXT=='B' ); |
| 101673 | 101442 | if( iReg!=target ){ |
| | @@ -101691,11 +101460,11 @@ |
| 101691 | 101460 | Table *pTab = pExpr->y.pTab; |
| 101692 | 101461 | int iSrc; |
| 101693 | 101462 | int iCol = pExpr->iColumn; |
| 101694 | 101463 | assert( pTab!=0 ); |
| 101695 | 101464 | assert( iCol>=XN_ROWID ); |
| 101696 | | - assert( iCol<pTab->nCol ); |
| 101465 | + assert( iCol<pExpr->y.pTab->nCol ); |
| 101697 | 101466 | if( iCol<0 ){ |
| 101698 | 101467 | return -1-pParse->iSelfTab; |
| 101699 | 101468 | } |
| 101700 | 101469 | pCol = pTab->aCol + iCol; |
| 101701 | 101470 | testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) ); |
| | @@ -101726,17 +101495,13 @@ |
| 101726 | 101495 | /* Coding an expression that is part of an index where column names |
| 101727 | 101496 | ** in the index refer to the table to which the index belongs */ |
| 101728 | 101497 | iTab = pParse->iSelfTab - 1; |
| 101729 | 101498 | } |
| 101730 | 101499 | } |
| 101731 | | - iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 101500 | + return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 101732 | 101501 | pExpr->iColumn, iTab, target, |
| 101733 | 101502 | pExpr->op2); |
| 101734 | | - if( pExpr->y.pTab==0 && pExpr->affExpr==SQLITE_AFF_REAL ){ |
| 101735 | | - sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg); |
| 101736 | | - } |
| 101737 | | - return iReg; |
| 101738 | 101503 | } |
| 101739 | 101504 | case TK_INTEGER: { |
| 101740 | 101505 | codeInteger(pParse, pExpr, 0, target); |
| 101741 | 101506 | return target; |
| 101742 | 101507 | } |
| | @@ -101754,16 +101519,11 @@ |
| 101754 | 101519 | case TK_STRING: { |
| 101755 | 101520 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 101756 | 101521 | sqlite3VdbeLoadString(v, target, pExpr->u.zToken); |
| 101757 | 101522 | return target; |
| 101758 | 101523 | } |
| 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 ); |
| 101524 | + case TK_NULL: { |
| 101765 | 101525 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 101766 | 101526 | return target; |
| 101767 | 101527 | } |
| 101768 | 101528 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 101769 | 101529 | case TK_BLOB: { |
| | @@ -101786,11 +101546,11 @@ |
| 101786 | 101546 | assert( pExpr->u.zToken!=0 ); |
| 101787 | 101547 | assert( pExpr->u.zToken[0]!=0 ); |
| 101788 | 101548 | sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target); |
| 101789 | 101549 | if( pExpr->u.zToken[1]!=0 ){ |
| 101790 | 101550 | const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn); |
| 101791 | | - assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) ); |
| 101551 | + assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 ); |
| 101792 | 101552 | pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */ |
| 101793 | 101553 | sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC); |
| 101794 | 101554 | } |
| 101795 | 101555 | return target; |
| 101796 | 101556 | } |
| | @@ -102099,16 +101859,12 @@ |
| 102099 | 101859 | #endif |
| 102100 | 101860 | { |
| 102101 | 101861 | sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg, |
| 102102 | 101862 | pDef, pExpr->op2); |
| 102103 | 101863 | } |
| 102104 | | - if( nFarg ){ |
| 102105 | | - if( constMask==0 ){ |
| 102106 | | - sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 102107 | | - }else{ |
| 102108 | | - sqlite3VdbeReleaseRegisters(pParse, r1, nFarg, constMask); |
| 102109 | | - } |
| 101864 | + if( nFarg && constMask==0 ){ |
| 101865 | + sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 102110 | 101866 | } |
| 102111 | 101867 | return target; |
| 102112 | 101868 | } |
| 102113 | 101869 | #ifndef SQLITE_OMIT_SUBQUERY |
| 102114 | 101870 | case TK_EXISTS: |
| | @@ -102200,11 +101956,11 @@ |
| 102200 | 101956 | ** p1==2 -> old.b p1==5 -> new.b |
| 102201 | 101957 | */ |
| 102202 | 101958 | Table *pTab = pExpr->y.pTab; |
| 102203 | 101959 | int iCol = pExpr->iColumn; |
| 102204 | 101960 | int p1 = pExpr->iTable * (pTab->nCol+1) + 1 |
| 102205 | | - + sqlite3TableColumnToStorage(pTab, iCol); |
| 101961 | + + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1); |
| 102206 | 101962 | |
| 102207 | 101963 | assert( pExpr->iTable==0 || pExpr->iTable==1 ); |
| 102208 | 101964 | assert( iCol>=-1 && iCol<pTab->nCol ); |
| 102209 | 101965 | assert( pTab->iPKey<0 || iCol!=pTab->iPKey ); |
| 102210 | 101966 | assert( p1>=0 && p1<(pTab->nCol*2+2) ); |
| | @@ -102274,11 +102030,11 @@ |
| 102274 | 102030 | ** |
| 102275 | 102031 | ** The result of the expression is the Ri for the first matching Ei, |
| 102276 | 102032 | ** or if there is no matching Ei, the ELSE term Y, or if there is |
| 102277 | 102033 | ** no ELSE term, NULL. |
| 102278 | 102034 | */ |
| 102279 | | - case TK_CASE: { |
| 102035 | + default: assert( op==TK_CASE ); { |
| 102280 | 102036 | int endLabel; /* GOTO label for end of CASE stmt */ |
| 102281 | 102037 | int nextCase; /* GOTO label for next WHEN clause */ |
| 102282 | 102038 | int nExpr; /* 2x number of WHEN terms */ |
| 102283 | 102039 | int i; /* Loop counter */ |
| 102284 | 102040 | ExprList *pEList; /* List of WHEN terms */ |
| | @@ -103331,14 +103087,11 @@ |
| 103331 | 103087 | sqlite3WalkExpr(pWalker, pExpr->pRight); |
| 103332 | 103088 | } |
| 103333 | 103089 | return WRC_Prune; |
| 103334 | 103090 | |
| 103335 | 103091 | case TK_BETWEEN: |
| 103336 | | - if( sqlite3WalkExpr(pWalker, pExpr->pLeft)==WRC_Abort ){ |
| 103337 | | - assert( pWalker->eCode ); |
| 103338 | | - return WRC_Abort; |
| 103339 | | - } |
| 103092 | + sqlite3WalkExpr(pWalker, pExpr->pLeft); |
| 103340 | 103093 | return WRC_Prune; |
| 103341 | 103094 | |
| 103342 | 103095 | /* Virtual tables are allowed to use constraints like x=NULL. So |
| 103343 | 103096 | ** a term of the form x=y does not prove that y is not null if x |
| 103344 | 103097 | ** is the column of a virtual table */ |
| | @@ -103748,15 +103501,12 @@ |
| 103748 | 103501 | /* |
| 103749 | 103502 | ** Deallocate a register, making available for reuse for some other |
| 103750 | 103503 | ** purpose. |
| 103751 | 103504 | */ |
| 103752 | 103505 | SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){ |
| 103753 | | - if( iReg ){ |
| 103754 | | - sqlite3VdbeReleaseRegisters(pParse, iReg, 1, 0); |
| 103755 | | - if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){ |
| 103756 | | - pParse->aTempReg[pParse->nTempReg++] = iReg; |
| 103757 | | - } |
| 103506 | + if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){ |
| 103507 | + pParse->aTempReg[pParse->nTempReg++] = iReg; |
| 103758 | 103508 | } |
| 103759 | 103509 | } |
| 103760 | 103510 | |
| 103761 | 103511 | /* |
| 103762 | 103512 | ** Allocate or deallocate a block of nReg consecutive registers. |
| | @@ -103778,11 +103528,10 @@ |
| 103778 | 103528 | SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){ |
| 103779 | 103529 | if( nReg==1 ){ |
| 103780 | 103530 | sqlite3ReleaseTempReg(pParse, iReg); |
| 103781 | 103531 | return; |
| 103782 | 103532 | } |
| 103783 | | - sqlite3VdbeReleaseRegisters(pParse, iReg, nReg, 0); |
| 103784 | 103533 | if( nReg>pParse->nRangeReg ){ |
| 103785 | 103534 | pParse->nRangeReg = nReg; |
| 103786 | 103535 | pParse->iRangeReg = iReg; |
| 103787 | 103536 | } |
| 103788 | 103537 | } |
| | @@ -104522,18 +104271,16 @@ |
| 104522 | 104271 | */ |
| 104523 | 104272 | SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){ |
| 104524 | 104273 | RenameToken *pNew; |
| 104525 | 104274 | assert( pPtr || pParse->db->mallocFailed ); |
| 104526 | 104275 | renameTokenCheckAll(pParse, pPtr); |
| 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 | | - } |
| 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; |
| 104535 | 104282 | } |
| 104536 | 104283 | |
| 104537 | 104284 | return pPtr; |
| 104538 | 104285 | } |
| 104539 | 104286 | |
| | @@ -104560,38 +104307,16 @@ |
| 104560 | 104307 | Parse *pParse = pWalker->pParse; |
| 104561 | 104308 | sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr); |
| 104562 | 104309 | return WRC_Continue; |
| 104563 | 104310 | } |
| 104564 | 104311 | |
| 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 | | -} |
| 104584 | | - |
| 104585 | 104312 | /* |
| 104586 | 104313 | ** Walker callback used by sqlite3RenameExprUnmap(). |
| 104587 | 104314 | */ |
| 104588 | 104315 | static int renameUnmapSelectCb(Walker *pWalker, Select *p){ |
| 104589 | 104316 | Parse *pParse = pWalker->pParse; |
| 104590 | 104317 | int i; |
| 104591 | | - if( pParse->nErr ) return WRC_Abort; |
| 104592 | | - if( NEVER(p->selFlags & SF_View) ) return WRC_Prune; |
| 104593 | 104318 | if( ALWAYS(p->pEList) ){ |
| 104594 | 104319 | ExprList *pList = p->pEList; |
| 104595 | 104320 | for(i=0; i<pList->nExpr; i++){ |
| 104596 | 104321 | if( pList->a[i].zName ){ |
| 104597 | 104322 | sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName); |
| | @@ -104600,31 +104325,25 @@ |
| 104600 | 104325 | } |
| 104601 | 104326 | if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */ |
| 104602 | 104327 | SrcList *pSrc = p->pSrc; |
| 104603 | 104328 | for(i=0; i<pSrc->nSrc; i++){ |
| 104604 | 104329 | sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); |
| 104605 | | - if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort; |
| 104606 | 104330 | } |
| 104607 | 104331 | } |
| 104608 | | - |
| 104609 | | - renameWalkWith(pWalker, p); |
| 104610 | 104332 | return WRC_Continue; |
| 104611 | 104333 | } |
| 104612 | 104334 | |
| 104613 | 104335 | /* |
| 104614 | 104336 | ** Remove all nodes that are part of expression pExpr from the rename list. |
| 104615 | 104337 | */ |
| 104616 | 104338 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){ |
| 104617 | | - u8 eMode = pParse->eParseMode; |
| 104618 | 104339 | Walker sWalker; |
| 104619 | 104340 | memset(&sWalker, 0, sizeof(Walker)); |
| 104620 | 104341 | sWalker.pParse = pParse; |
| 104621 | 104342 | sWalker.xExprCallback = renameUnmapExprCb; |
| 104622 | 104343 | sWalker.xSelectCallback = renameUnmapSelectCb; |
| 104623 | | - pParse->eParseMode = PARSE_MODE_UNMAP; |
| 104624 | 104344 | sqlite3WalkExpr(&sWalker, pExpr); |
| 104625 | | - pParse->eParseMode = eMode; |
| 104626 | 104345 | } |
| 104627 | 104346 | |
| 104628 | 104347 | /* |
| 104629 | 104348 | ** Remove all nodes that are part of expression-list pEList from the |
| 104630 | 104349 | ** rename list. |
| | @@ -104673,18 +104392,35 @@ |
| 104673 | 104392 | pCtx->nList++; |
| 104674 | 104393 | break; |
| 104675 | 104394 | } |
| 104676 | 104395 | } |
| 104677 | 104396 | } |
| 104397 | + |
| 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 | +} |
| 104678 | 104415 | |
| 104679 | 104416 | /* |
| 104680 | 104417 | ** This is a Walker select callback. It does nothing. It is only required |
| 104681 | 104418 | ** because without a dummy callback, sqlite3WalkExpr() and similar do not |
| 104682 | 104419 | ** descend into sub-select statements. |
| 104683 | 104420 | */ |
| 104684 | 104421 | static int renameColumnSelectCb(Walker *pWalker, Select *p){ |
| 104685 | | - if( p->selFlags & SF_View ) return WRC_Prune; |
| 104686 | 104422 | renameWalkWith(pWalker, p); |
| 104687 | 104423 | return WRC_Continue; |
| 104688 | 104424 | } |
| 104689 | 104425 | |
| 104690 | 104426 | /* |
| | @@ -104811,10 +104547,11 @@ |
| 104811 | 104547 | ** is initialized by this function before it is used. |
| 104812 | 104548 | */ |
| 104813 | 104549 | static int renameParseSql( |
| 104814 | 104550 | Parse *p, /* Memory to use for Parse object */ |
| 104815 | 104551 | const char *zDb, /* Name of schema SQL belongs to */ |
| 104552 | + int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */ |
| 104816 | 104553 | sqlite3 *db, /* Database handle */ |
| 104817 | 104554 | const char *zSql, /* SQL to parse */ |
| 104818 | 104555 | int bTemp /* True if SQL is from temp schema */ |
| 104819 | 104556 | ){ |
| 104820 | 104557 | int rc; |
| | @@ -104824,11 +104561,11 @@ |
| 104824 | 104561 | |
| 104825 | 104562 | /* Parse the SQL statement passed as the first argument. If no error |
| 104826 | 104563 | ** occurs and the parse does not result in a new table, index or |
| 104827 | 104564 | ** trigger object, the database must be corrupt. */ |
| 104828 | 104565 | memset(p, 0, sizeof(Parse)); |
| 104829 | | - p->eParseMode = PARSE_MODE_RENAME; |
| 104566 | + p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN); |
| 104830 | 104567 | p->db = db; |
| 104831 | 104568 | p->nQueryLoop = 1; |
| 104832 | 104569 | rc = sqlite3RunParser(p, zSql, &zErr); |
| 104833 | 104570 | assert( p->zErrMsg==0 ); |
| 104834 | 104571 | assert( rc!=SQLITE_OK || zErr==0 ); |
| | @@ -105131,11 +104868,11 @@ |
| 105131 | 104868 | sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol); |
| 105132 | 104869 | |
| 105133 | 104870 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 105134 | 104871 | db->xAuth = 0; |
| 105135 | 104872 | #endif |
| 105136 | | - rc = renameParseSql(&sParse, zDb, db, zSql, bTemp); |
| 104873 | + rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp); |
| 105137 | 104874 | |
| 105138 | 104875 | /* Find tokens that need to be replaced. */ |
| 105139 | 104876 | memset(&sWalker, 0, sizeof(Walker)); |
| 105140 | 104877 | sWalker.pParse = &sParse; |
| 105141 | 104878 | sWalker.xExprCallback = renameColumnExprCb; |
| | @@ -105145,13 +104882,12 @@ |
| 105145 | 104882 | sCtx.pTab = pTab; |
| 105146 | 104883 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| 105147 | 104884 | if( sParse.pNewTable ){ |
| 105148 | 104885 | Select *pSelect = sParse.pNewTable->pSelect; |
| 105149 | 104886 | if( pSelect ){ |
| 105150 | | - pSelect->selFlags &= ~SF_View; |
| 105151 | 104887 | sParse.rc = SQLITE_OK; |
| 105152 | | - sqlite3SelectPrep(&sParse, pSelect, 0); |
| 104888 | + sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); |
| 105153 | 104889 | rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); |
| 105154 | 104890 | if( rc==SQLITE_OK ){ |
| 105155 | 104891 | sqlite3WalkSelect(&sWalker, pSelect); |
| 105156 | 104892 | } |
| 105157 | 104893 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| | @@ -105264,11 +105000,10 @@ |
| 105264 | 105000 | */ |
| 105265 | 105001 | static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ |
| 105266 | 105002 | int i; |
| 105267 | 105003 | RenameCtx *p = pWalker->u.pRename; |
| 105268 | 105004 | SrcList *pSrc = pSelect->pSrc; |
| 105269 | | - if( pSelect->selFlags & SF_View ) return WRC_Prune; |
| 105270 | 105005 | if( pSrc==0 ){ |
| 105271 | 105006 | assert( pWalker->pParse->db->mallocFailed ); |
| 105272 | 105007 | return WRC_Abort; |
| 105273 | 105008 | } |
| 105274 | 105009 | for(i=0; i<pSrc->nSrc; i++){ |
| | @@ -105335,32 +105070,26 @@ |
| 105335 | 105070 | sWalker.pParse = &sParse; |
| 105336 | 105071 | sWalker.xExprCallback = renameTableExprCb; |
| 105337 | 105072 | sWalker.xSelectCallback = renameTableSelectCb; |
| 105338 | 105073 | sWalker.u.pRename = &sCtx; |
| 105339 | 105074 | |
| 105340 | | - rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); |
| 105075 | + rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp); |
| 105341 | 105076 | |
| 105342 | 105077 | if( rc==SQLITE_OK ){ |
| 105343 | 105078 | int isLegacy = (db->flags & SQLITE_LegacyAlter); |
| 105344 | 105079 | if( sParse.pNewTable ){ |
| 105345 | 105080 | Table *pTab = sParse.pNewTable; |
| 105346 | 105081 | |
| 105347 | 105082 | if( pTab->pSelect ){ |
| 105348 | 105083 | if( isLegacy==0 ){ |
| 105349 | | - Select *pSelect = pTab->pSelect; |
| 105350 | 105084 | NameContext sNC; |
| 105351 | 105085 | memset(&sNC, 0, sizeof(sNC)); |
| 105352 | 105086 | sNC.pParse = &sParse; |
| 105353 | 105087 | |
| 105354 | | - assert( pSelect->selFlags & SF_View ); |
| 105355 | | - pSelect->selFlags &= ~SF_View; |
| 105356 | 105088 | sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); |
| 105357 | | - if( sParse.nErr ){ |
| 105358 | | - rc = sParse.rc; |
| 105359 | | - }else{ |
| 105360 | | - sqlite3WalkSelect(&sWalker, pTab->pSelect); |
| 105361 | | - } |
| 105089 | + if( sParse.nErr ) rc = sParse.rc; |
| 105090 | + sqlite3WalkSelect(&sWalker, pTab->pSelect); |
| 105362 | 105091 | } |
| 105363 | 105092 | }else{ |
| 105364 | 105093 | /* Modify any FK definitions to point to the new table. */ |
| 105365 | 105094 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 105366 | 105095 | if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){ |
| | @@ -105477,11 +105206,11 @@ |
| 105477 | 105206 | |
| 105478 | 105207 | UNUSED_PARAMETER(NotUsed); |
| 105479 | 105208 | if( zDb && zInput ){ |
| 105480 | 105209 | int rc; |
| 105481 | 105210 | Parse sParse; |
| 105482 | | - rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); |
| 105211 | + rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp); |
| 105483 | 105212 | if( rc==SQLITE_OK ){ |
| 105484 | 105213 | if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){ |
| 105485 | 105214 | NameContext sNC; |
| 105486 | 105215 | memset(&sNC, 0, sizeof(sNC)); |
| 105487 | 105216 | sNC.pParse = &sParse; |
| | @@ -109270,19 +108999,17 @@ |
| 109270 | 108999 | ** |
| 109271 | 109000 | ** So, in other words, this routine shifts all the virtual columns to |
| 109272 | 109001 | ** the end. |
| 109273 | 109002 | ** |
| 109274 | 109003 | ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and |
| 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. |
| 109004 | +** this routine is a no-op macro. |
| 109278 | 109005 | */ |
| 109279 | 109006 | SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){ |
| 109280 | 109007 | int i; |
| 109281 | 109008 | i16 n; |
| 109282 | 109009 | assert( iCol<pTab->nCol ); |
| 109283 | | - if( (pTab->tabFlags & TF_HasVirtual)==0 || iCol<0 ) return iCol; |
| 109010 | + if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol; |
| 109284 | 109011 | for(i=0, n=0; i<iCol; i++){ |
| 109285 | 109012 | if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++; |
| 109286 | 109013 | } |
| 109287 | 109014 | if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){ |
| 109288 | 109015 | /* iCol is a virtual column itself */ |
| | @@ -109870,11 +109597,10 @@ |
| 109870 | 109597 | pTab->iPKey = iCol; |
| 109871 | 109598 | pTab->keyConf = (u8)onError; |
| 109872 | 109599 | assert( autoInc==0 || autoInc==1 ); |
| 109873 | 109600 | pTab->tabFlags |= autoInc*TF_Autoincrement; |
| 109874 | 109601 | if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags; |
| 109875 | | - (void)sqlite3HasExplicitNulls(pParse, pList); |
| 109876 | 109602 | }else if( autoInc ){ |
| 109877 | 109603 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 109878 | 109604 | sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " |
| 109879 | 109605 | "INTEGER PRIMARY KEY"); |
| 109880 | 109606 | #endif |
| | @@ -109955,14 +109681,11 @@ |
| 109955 | 109681 | SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){ |
| 109956 | 109682 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 109957 | 109683 | u8 eType = COLFLAG_VIRTUAL; |
| 109958 | 109684 | Table *pTab = pParse->pNewTable; |
| 109959 | 109685 | Column *pCol; |
| 109960 | | - if( pTab==0 ){ |
| 109961 | | - /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */ |
| 109962 | | - goto generated_done; |
| 109963 | | - } |
| 109686 | + if( NEVER(pTab==0) ) goto generated_done; |
| 109964 | 109687 | pCol = &(pTab->aCol[pTab->nCol-1]); |
| 109965 | 109688 | if( IN_DECLARE_VTAB ){ |
| 109966 | 109689 | sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns"); |
| 109967 | 109690 | goto generated_done; |
| 109968 | 109691 | } |
| | @@ -110566,16 +110289,10 @@ |
| 110566 | 110289 | #ifndef SQLITE_OMIT_CHECK |
| 110567 | 110290 | /* Resolve names in all CHECK constraint expressions. |
| 110568 | 110291 | */ |
| 110569 | 110292 | if( p->pCheck ){ |
| 110570 | 110293 | 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 | | - } |
| 110577 | 110294 | } |
| 110578 | 110295 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 110579 | 110296 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 110580 | 110297 | if( p->tabFlags & TF_HasGenerated ){ |
| 110581 | 110298 | int ii, nNG = 0; |
| | @@ -110582,23 +110299,14 @@ |
| 110582 | 110299 | testcase( p->tabFlags & TF_HasVirtual ); |
| 110583 | 110300 | testcase( p->tabFlags & TF_HasStored ); |
| 110584 | 110301 | for(ii=0; ii<p->nCol; ii++){ |
| 110585 | 110302 | u32 colFlags = p->aCol[ii].colFlags; |
| 110586 | 110303 | if( (colFlags & COLFLAG_GENERATED)!=0 ){ |
| 110587 | | - Expr *pX = p->aCol[ii].pDflt; |
| 110588 | 110304 | testcase( colFlags & COLFLAG_VIRTUAL ); |
| 110589 | 110305 | testcase( colFlags & COLFLAG_STORED ); |
| 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 | | - } |
| 110306 | + sqlite3ResolveSelfReference(pParse, p, NC_GenCol, |
| 110307 | + p->aCol[ii].pDflt, 0); |
| 110600 | 110308 | }else{ |
| 110601 | 110309 | nNG++; |
| 110602 | 110310 | } |
| 110603 | 110311 | } |
| 110604 | 110312 | if( nNG==0 ){ |
| | @@ -110824,11 +110532,10 @@ |
| 110824 | 110532 | /* Make a copy of the entire SELECT statement that defines the view. |
| 110825 | 110533 | ** This will force all the Expr.token.z values to be dynamically |
| 110826 | 110534 | ** allocated rather than point to the input string - which means that |
| 110827 | 110535 | ** they will persist after the current sqlite3_exec() call returns. |
| 110828 | 110536 | */ |
| 110829 | | - pSelect->selFlags |= SF_View; |
| 110830 | 110537 | if( IN_RENAME_OBJECT ){ |
| 110831 | 110538 | p->pSelect = pSelect; |
| 110832 | 110539 | pSelect = 0; |
| 110833 | 110540 | }else{ |
| 110834 | 110541 | p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); |
| | @@ -112251,13 +111958,30 @@ |
| 112251 | 111958 | } |
| 112252 | 111959 | |
| 112253 | 111960 | sqlite3VdbeJumpHere(v, pIndex->tnum); |
| 112254 | 111961 | } |
| 112255 | 111962 | } |
| 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 | + */ |
| 112256 | 111970 | if( db->init.busy || pTblName==0 ){ |
| 112257 | | - pIndex->pNext = pTab->pIndex; |
| 112258 | | - pTab->pIndex = pIndex; |
| 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 | + } |
| 112259 | 111983 | pIndex = 0; |
| 112260 | 111984 | } |
| 112261 | 111985 | else if( IN_RENAME_OBJECT ){ |
| 112262 | 111986 | assert( pParse->pNewIndex==0 ); |
| 112263 | 111987 | pParse->pNewIndex = pIndex; |
| | @@ -112265,25 +111989,10 @@ |
| 112265 | 111989 | } |
| 112266 | 111990 | |
| 112267 | 111991 | /* Clean up before exiting */ |
| 112268 | 111992 | exit_create_index: |
| 112269 | 111993 | 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 | | - } |
| 112285 | 111994 | sqlite3ExprDelete(db, pPIWhere); |
| 112286 | 111995 | sqlite3ExprListDelete(db, pList); |
| 112287 | 111996 | sqlite3SrcListDelete(db, pTblName); |
| 112288 | 111997 | sqlite3DbFree(db, zName); |
| 112289 | 111998 | } |
| | @@ -118522,15 +118231,14 @@ |
| 118522 | 118231 | } |
| 118523 | 118232 | return 0; |
| 118524 | 118233 | } |
| 118525 | 118234 | |
| 118526 | 118235 | /* This walker callback will compute the union of colFlags flags for all |
| 118527 | | -** referenced columns in a CHECK constraint or generated column expression. |
| 118236 | +** references columns in a CHECK constraint or generated column expression. |
| 118528 | 118237 | */ |
| 118529 | 118238 | static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){ |
| 118530 | | - if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 ){ |
| 118531 | | - assert( pExpr->iColumn < pWalker->u.pTab->nCol ); |
| 118239 | + if( pExpr->op==TK_COLUMN ){ |
| 118532 | 118240 | pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags; |
| 118533 | 118241 | } |
| 118534 | 118242 | return WRC_Continue; |
| 118535 | 118243 | } |
| 118536 | 118244 | |
| | @@ -118549,40 +118257,10 @@ |
| 118549 | 118257 | ){ |
| 118550 | 118258 | int i; |
| 118551 | 118259 | Walker w; |
| 118552 | 118260 | Column *pRedo; |
| 118553 | 118261 | 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 | | - } |
| 118584 | 118262 | |
| 118585 | 118263 | /* Because there can be multiple generated columns that refer to one another, |
| 118586 | 118264 | ** this is a two-pass algorithm. On the first pass, mark all generated |
| 118587 | 118265 | ** columns as "not available". |
| 118588 | 118266 | */ |
| | @@ -119299,14 +118977,10 @@ |
| 119299 | 118977 | if( IsVirtual(pTab) ){ |
| 119300 | 118978 | sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"", |
| 119301 | 118979 | pTab->zName); |
| 119302 | 118980 | goto insert_cleanup; |
| 119303 | 118981 | } |
| 119304 | | - if( pTab->pSelect ){ |
| 119305 | | - sqlite3ErrorMsg(pParse, "cannot UPSERT a view"); |
| 119306 | | - goto insert_cleanup; |
| 119307 | | - } |
| 119308 | 118982 | if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){ |
| 119309 | 118983 | goto insert_cleanup; |
| 119310 | 118984 | } |
| 119311 | 118985 | pTabList->a[0].iCursor = iDataCur; |
| 119312 | 118986 | pUpsert->pUpsertSrc = pTabList; |
| | @@ -119537,12 +119211,14 @@ |
| 119537 | 119211 | |
| 119538 | 119212 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 119539 | 119213 | /* Compute the new value for generated columns after all other |
| 119540 | 119214 | ** columns have already been computed. This must be done after |
| 119541 | 119215 | ** computing the ROWID in case one of the generated columns |
| 119542 | | - ** is derived from the INTEGER PRIMARY KEY. */ |
| 119216 | + ** refers to the ROWID. */ |
| 119543 | 119217 | if( pTab->tabFlags & TF_HasGenerated ){ |
| 119218 | + testcase( pTab->tabFlags & TF_HasVirtual ); |
| 119219 | + testcase( pTab->tabFlags & TF_HasStored ); |
| 119544 | 119220 | sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab); |
| 119545 | 119221 | } |
| 119546 | 119222 | #endif |
| 119547 | 119223 | |
| 119548 | 119224 | /* Generate code to check constraints and generate index keys and |
| | @@ -120570,14 +120246,10 @@ |
| 120570 | 120246 | |
| 120571 | 120247 | v = sqlite3GetVdbe(pParse); |
| 120572 | 120248 | assert( v!=0 ); |
| 120573 | 120249 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 120574 | 120250 | 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 ); |
| 120579 | 120251 | if( aRegIdx[i]==0 ) continue; |
| 120580 | 120252 | if( pIdx->pPartIdxWhere ){ |
| 120581 | 120253 | sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); |
| 120582 | 120254 | VdbeCoverage(v); |
| 120583 | 120255 | } |
| | @@ -125041,13 +124713,11 @@ |
| 125041 | 124713 | char *zErr; |
| 125042 | 124714 | int jmp2; |
| 125043 | 124715 | if( j==pTab->iPKey ) continue; |
| 125044 | 124716 | if( pTab->aCol[j].notNull==0 ) continue; |
| 125045 | 124717 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); |
| 125046 | | - if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ |
| 125047 | | - sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 125048 | | - } |
| 124718 | + sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 125049 | 124719 | jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); |
| 125050 | 124720 | zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, |
| 125051 | 124721 | pTab->aCol[j].zName); |
| 125052 | 124722 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 125053 | 124723 | integrityCheckResultRow(v); |
| | @@ -127009,14 +126679,11 @@ |
| 127009 | 126679 | }; |
| 127010 | 126680 | #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ |
| 127011 | 126681 | |
| 127012 | 126682 | /* |
| 127013 | 126683 | ** Delete all the content of a Select structure. Deallocate the structure |
| 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 |
| 126684 | +** itself only if bFree is true. |
| 127018 | 126685 | */ |
| 127019 | 126686 | static void clearSelect(sqlite3 *db, Select *p, int bFree){ |
| 127020 | 126687 | while( p ){ |
| 127021 | 126688 | Select *pPrior = p->pPrior; |
| 127022 | 126689 | sqlite3ExprListDelete(db, p->pEList); |
| | @@ -127116,24 +126783,10 @@ |
| 127116 | 126783 | */ |
| 127117 | 126784 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){ |
| 127118 | 126785 | if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1); |
| 127119 | 126786 | } |
| 127120 | 126787 | |
| 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 | | -} |
| 127134 | | - |
| 127135 | 126788 | /* |
| 127136 | 126789 | ** Return a pointer to the right-most SELECT statement in a compound. |
| 127137 | 126790 | */ |
| 127138 | 126791 | static Select *findRightmost(Select *p){ |
| 127139 | 126792 | while( p->pNext ) p = p->pNext; |
| | @@ -129416,11 +129069,10 @@ |
| 129416 | 129069 | assert( p->selFlags & SF_MultiValue ); |
| 129417 | 129070 | do{ |
| 129418 | 129071 | assert( p->selFlags & SF_Values ); |
| 129419 | 129072 | assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) ); |
| 129420 | 129073 | assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr ); |
| 129421 | | - if( p->pWin ) return -1; |
| 129422 | 129074 | if( p->pPrior==0 ) break; |
| 129423 | 129075 | assert( p->pPrior->pNext==p ); |
| 129424 | 129076 | p = p->pPrior; |
| 129425 | 129077 | nRow += bShowAll; |
| 129426 | 129078 | }while(1); |
| | @@ -129507,12 +129159,11 @@ |
| 129507 | 129159 | |
| 129508 | 129160 | /* Special handling for a compound-select that originates as a VALUES clause. |
| 129509 | 129161 | */ |
| 129510 | 129162 | if( p->selFlags & SF_MultiValue ){ |
| 129511 | 129163 | rc = multiSelectValues(pParse, p, &dest); |
| 129512 | | - if( rc>=0 ) goto multi_select_end; |
| 129513 | | - rc = SQLITE_OK; |
| 129164 | + goto multi_select_end; |
| 129514 | 129165 | } |
| 129515 | 129166 | |
| 129516 | 129167 | /* Make sure all SELECTs in the statement have the same number of elements |
| 129517 | 129168 | ** in their result sets. |
| 129518 | 129169 | */ |
| | @@ -129653,13 +129304,13 @@ |
| 129653 | 129304 | |
| 129654 | 129305 | /* Convert the data in the temporary table into whatever form |
| 129655 | 129306 | ** it is that we currently need. |
| 129656 | 129307 | */ |
| 129657 | 129308 | assert( unionTab==dest.iSDParm || dest.eDest!=priorOp ); |
| 129658 | | - assert( p->pEList || db->mallocFailed ); |
| 129659 | | - if( dest.eDest!=priorOp && db->mallocFailed==0 ){ |
| 129309 | + if( dest.eDest!=priorOp ){ |
| 129660 | 129310 | int iCont, iBreak, iStart; |
| 129311 | + assert( p->pEList ); |
| 129661 | 129312 | iBreak = sqlite3VdbeMakeLabel(pParse); |
| 129662 | 129313 | iCont = sqlite3VdbeMakeLabel(pParse); |
| 129663 | 129314 | computeLimitRegisters(pParse, p, iBreak); |
| 129664 | 129315 | sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v); |
| 129665 | 129316 | iStart = sqlite3VdbeCurrentAddr(v); |
| | @@ -129751,11 +129402,10 @@ |
| 129751 | 129402 | if( p->pNext==0 ){ |
| 129752 | 129403 | ExplainQueryPlanPop(pParse); |
| 129753 | 129404 | } |
| 129754 | 129405 | #endif |
| 129755 | 129406 | } |
| 129756 | | - if( pParse->nErr ) goto multi_select_end; |
| 129757 | 129407 | |
| 129758 | 129408 | /* Compute collating sequences used by |
| 129759 | 129409 | ** temporary tables needed to implement the compound select. |
| 129760 | 129410 | ** Attach the KeyInfo structure to all temporary tables. |
| 129761 | 129411 | ** |
| | @@ -130543,11 +130193,10 @@ |
| 130543 | 130193 | ** (3) If the subquery is the right operand of a LEFT JOIN then |
| 130544 | 130194 | ** (3a) the subquery may not be a join and |
| 130545 | 130195 | ** (3b) the FROM clause of the subquery may not contain a virtual |
| 130546 | 130196 | ** table and |
| 130547 | 130197 | ** (3c) the outer query may not be an aggregate. |
| 130548 | | -** (3d) the outer query may not be DISTINCT. |
| 130549 | 130198 | ** |
| 130550 | 130199 | ** (4) The subquery can not be DISTINCT. |
| 130551 | 130200 | ** |
| 130552 | 130201 | ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT |
| 130553 | 130202 | ** sub-queries that were excluded from this optimization. Restriction |
| | @@ -130740,15 +130389,12 @@ |
| 130740 | 130389 | ** |
| 130741 | 130390 | ** See also tickets #306, #350, and #3300. |
| 130742 | 130391 | */ |
| 130743 | 130392 | if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 130744 | 130393 | isLeftJoin = 1; |
| 130745 | | - if( pSubSrc->nSrc>1 /* (3a) */ |
| 130746 | | - || isAgg /* (3b) */ |
| 130747 | | - || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */ |
| 130748 | | - || (p->selFlags & SF_Distinct)!=0 /* (3d) */ |
| 130749 | | - ){ |
| 130394 | + if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){ |
| 130395 | + /* (3a) (3c) (3b) */ |
| 130750 | 130396 | return 0; |
| 130751 | 130397 | } |
| 130752 | 130398 | } |
| 130753 | 130399 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 130754 | 130400 | else if( iFrom>0 && !isAgg ){ |
| | @@ -131518,13 +131164,10 @@ |
| 131518 | 131164 | pNew->pHaving = 0; |
| 131519 | 131165 | pNew->pOrderBy = 0; |
| 131520 | 131166 | p->pPrior = 0; |
| 131521 | 131167 | p->pNext = 0; |
| 131522 | 131168 | p->pWith = 0; |
| 131523 | | -#ifndef SQLITE_OMIT_WINDOWFUNC |
| 131524 | | - p->pWinDefn = 0; |
| 131525 | | -#endif |
| 131526 | 131169 | p->selFlags &= ~SF_Compound; |
| 131527 | 131170 | assert( (p->selFlags & SF_Converted)==0 ); |
| 131528 | 131171 | p->selFlags |= SF_Converted; |
| 131529 | 131172 | assert( pNew->pPrior!=0 ); |
| 131530 | 131173 | pNew->pPrior->pNext = pNew; |
| | @@ -132680,13 +132323,11 @@ |
| 132680 | 132323 | if( pDest->eDest==SRT_Output ){ |
| 132681 | 132324 | generateColumnNames(pParse, p); |
| 132682 | 132325 | } |
| 132683 | 132326 | |
| 132684 | 132327 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 132685 | | - rc = sqlite3WindowRewrite(pParse, p); |
| 132686 | | - if( rc ){ |
| 132687 | | - assert( db->mallocFailed || pParse->nErr>0 ); |
| 132328 | + if( sqlite3WindowRewrite(pParse, p) ){ |
| 132688 | 132329 | goto select_end; |
| 132689 | 132330 | } |
| 132690 | 132331 | #if SELECTTRACE_ENABLED |
| 132691 | 132332 | if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ |
| 132692 | 132333 | SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); |
| | @@ -133018,11 +132659,10 @@ |
| 133018 | 132659 | ** written the query must use a temp-table for at least one of the ORDER |
| 133019 | 132660 | ** BY and DISTINCT, and an index or separate temp-table for the other. |
| 133020 | 132661 | */ |
| 133021 | 132662 | if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct |
| 133022 | 132663 | && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 |
| 133023 | | - && p->pWin==0 |
| 133024 | 132664 | ){ |
| 133025 | 132665 | p->selFlags &= ~SF_Distinct; |
| 133026 | 132666 | pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); |
| 133027 | 132667 | /* Notice that even thought SF_Distinct has been cleared from p->selFlags, |
| 133028 | 132668 | ** the sDistinct.isTnct is still set. Hence, isTnct represents the |
| | @@ -134542,16 +134182,12 @@ |
| 134542 | 134182 | if( ALWAYS(pTrigger) ){ |
| 134543 | 134183 | if( pTrigger->pSchema==pTrigger->pTabSchema ){ |
| 134544 | 134184 | Table *pTab = tableOfTrigger(pTrigger); |
| 134545 | 134185 | if( pTab ){ |
| 134546 | 134186 | Trigger **pp; |
| 134547 | | - for(pp=&pTab->pTrigger; *pp; pp=&((*pp)->pNext)){ |
| 134548 | | - if( *pp==pTrigger ){ |
| 134549 | | - *pp = (*pp)->pNext; |
| 134550 | | - break; |
| 134551 | | - } |
| 134552 | | - } |
| 134187 | + for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext)); |
| 134188 | + *pp = (*pp)->pNext; |
| 134553 | 134189 | } |
| 134554 | 134190 | } |
| 134555 | 134191 | sqlite3DeleteTrigger(db, pTrigger); |
| 134556 | 134192 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 134557 | 134193 | } |
| | @@ -137278,12 +136914,10 @@ |
| 137278 | 136914 | char *zWhere; |
| 137279 | 136915 | int iDb; |
| 137280 | 136916 | int iReg; |
| 137281 | 136917 | Vdbe *v; |
| 137282 | 136918 | |
| 137283 | | - sqlite3MayAbort(pParse); |
| 137284 | | - |
| 137285 | 136919 | /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ |
| 137286 | 136920 | if( pEnd ){ |
| 137287 | 136921 | pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n; |
| 137288 | 136922 | } |
| 137289 | 136923 | zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken); |
| | @@ -137305,17 +136939,17 @@ |
| 137305 | 136939 | pTab->zName, |
| 137306 | 136940 | pTab->zName, |
| 137307 | 136941 | zStmt, |
| 137308 | 136942 | pParse->regRowid |
| 137309 | 136943 | ); |
| 136944 | + sqlite3DbFree(db, zStmt); |
| 137310 | 136945 | v = sqlite3GetVdbe(pParse); |
| 137311 | 136946 | sqlite3ChangeCookie(pParse, iDb); |
| 137312 | 136947 | |
| 137313 | 136948 | sqlite3VdbeAddOp0(v, OP_Expire); |
| 137314 | | - zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt); |
| 136949 | + zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); |
| 137315 | 136950 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); |
| 137316 | | - sqlite3DbFree(db, zStmt); |
| 137317 | 136951 | |
| 137318 | 136952 | iReg = ++pParse->nMem; |
| 137319 | 136953 | sqlite3VdbeLoadString(v, iReg, pTab->zName); |
| 137320 | 136954 | sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg); |
| 137321 | 136955 | } |
| | @@ -137713,12 +137347,11 @@ |
| 137713 | 137347 | return SQLITE_LOCKED; |
| 137714 | 137348 | } |
| 137715 | 137349 | } |
| 137716 | 137350 | p = vtabDisconnectAll(db, pTab); |
| 137717 | 137351 | xDestroy = p->pMod->pModule->xDestroy; |
| 137718 | | - if( xDestroy==0 ) xDestroy = p->pMod->pModule->xDisconnect; |
| 137719 | | - assert( xDestroy!=0 ); |
| 137352 | + assert( xDestroy!=0 ); /* Checked before the virtual table is created */ |
| 137720 | 137353 | pTab->nTabRef++; |
| 137721 | 137354 | rc = xDestroy(p->pVtab); |
| 137722 | 137355 | /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ |
| 137723 | 137356 | if( rc==SQLITE_OK ){ |
| 137724 | 137357 | assert( pTab->pVTable==p && p->pNext==0 ); |
| | @@ -139143,12 +138776,11 @@ |
| 139143 | 138776 | int iEq, /* Look at loop terms starting here */ |
| 139144 | 138777 | WhereLoop *pLoop, /* The current loop */ |
| 139145 | 138778 | Expr *pX /* The IN expression to be reduced */ |
| 139146 | 138779 | ){ |
| 139147 | 138780 | sqlite3 *db = pParse->db; |
| 139148 | | - Expr *pNew; |
| 139149 | | - pNew = sqlite3ExprDup(db, pX, 0); |
| 138781 | + Expr *pNew = sqlite3ExprDup(db, pX, 0); |
| 139150 | 138782 | if( db->mallocFailed==0 ){ |
| 139151 | 138783 | ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */ |
| 139152 | 138784 | ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */ |
| 139153 | 138785 | ExprList *pRhs = 0; /* New RHS after modifications */ |
| 139154 | 138786 | ExprList *pLhs = 0; /* New LHS after mods */ |
| | @@ -139856,13 +139488,10 @@ |
| 139856 | 139488 | pExpr->affExpr = sqlite3ExprAffinity(pExpr); |
| 139857 | 139489 | pExpr->op = TK_COLUMN; |
| 139858 | 139490 | pExpr->iTable = pX->iIdxCur; |
| 139859 | 139491 | pExpr->iColumn = pX->iIdxCol; |
| 139860 | 139492 | pExpr->y.pTab = 0; |
| 139861 | | - testcase( ExprHasProperty(pExpr, EP_Skip) ); |
| 139862 | | - testcase( ExprHasProperty(pExpr, EP_Unlikely) ); |
| 139863 | | - ExprClearProperty(pExpr, EP_Skip|EP_Unlikely); |
| 139864 | 139493 | return WRC_Prune; |
| 139865 | 139494 | }else{ |
| 139866 | 139495 | return WRC_Continue; |
| 139867 | 139496 | } |
| 139868 | 139497 | } |
| | @@ -139873,12 +139502,10 @@ |
| 139873 | 139502 | */ |
| 139874 | 139503 | static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){ |
| 139875 | 139504 | if( pExpr->op==TK_COLUMN ){ |
| 139876 | 139505 | IdxExprTrans *pX = p->u.pIdxTrans; |
| 139877 | 139506 | if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){ |
| 139878 | | - assert( pExpr->y.pTab!=0 ); |
| 139879 | | - pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn); |
| 139880 | 139507 | pExpr->iTable = pX->iIdxCur; |
| 139881 | 139508 | pExpr->iColumn = pX->iIdxCol; |
| 139882 | 139509 | pExpr->y.pTab = 0; |
| 139883 | 139510 | } |
| 139884 | 139511 | } |
| | @@ -139920,24 +139547,13 @@ |
| 139920 | 139547 | for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){ |
| 139921 | 139548 | i16 iRef = pIdx->aiColumn[iIdxCol]; |
| 139922 | 139549 | if( iRef==XN_EXPR ){ |
| 139923 | 139550 | assert( aColExpr->a[iIdxCol].pExpr!=0 ); |
| 139924 | 139551 | x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; |
| 139925 | | - if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue; |
| 139926 | 139552 | w.xExprCallback = whereIndexExprTransNode; |
| 139927 | 139553 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 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 */ |
| 139554 | + }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){ |
| 139939 | 139555 | x.iTabCol = iRef; |
| 139940 | 139556 | w.xExprCallback = whereIndexExprTransColumn; |
| 139941 | 139557 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ |
| 139942 | 139558 | }else{ |
| 139943 | 139559 | continue; |
| | @@ -140597,14 +140213,14 @@ |
| 140597 | 140213 | omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 |
| 140598 | 140214 | && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0; |
| 140599 | 140215 | if( omitTable ){ |
| 140600 | 140216 | /* pIdx is a covering index. No need to access the main table. */ |
| 140601 | 140217 | }else if( HasRowid(pIdx->pTable) ){ |
| 140602 | | - if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) |
| 140603 | | - || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)!=0 |
| 140604 | | - && (pWInfo->eOnePass==ONEPASS_SINGLE || pLoop->nLTerm==0) ) |
| 140605 | | - ){ |
| 140218 | + if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || ( |
| 140219 | + (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) |
| 140220 | + && (pWInfo->eOnePass==ONEPASS_SINGLE) |
| 140221 | + )){ |
| 140606 | 140222 | iRowidReg = ++pParse->nMem; |
| 140607 | 140223 | sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); |
| 140608 | 140224 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg); |
| 140609 | 140225 | VdbeCoverage(v); |
| 140610 | 140226 | }else{ |
| | @@ -142439,11 +142055,10 @@ |
| 142439 | 142055 | Expr *pNewExpr; |
| 142440 | 142056 | pNewExpr = sqlite3PExpr(pParse, TK_MATCH, |
| 142441 | 142057 | 0, sqlite3ExprDup(db, pRight, 0)); |
| 142442 | 142058 | if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ |
| 142443 | 142059 | ExprSetProperty(pNewExpr, EP_FromJoin); |
| 142444 | | - pNewExpr->iRightJoinTable = pExpr->iRightJoinTable; |
| 142445 | 142060 | } |
| 142446 | 142061 | idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); |
| 142447 | 142062 | testcase( idxNew==0 ); |
| 142448 | 142063 | pNewTerm = &pWC->a[idxNew]; |
| 142449 | 142064 | pNewTerm->prereqRight = prereqExpr; |
| | @@ -142496,19 +142111,15 @@ |
| 142496 | 142111 | ** a virtual term for each vector component. The expression object |
| 142497 | 142112 | ** used by each such virtual term is pExpr (the full vector IN(...) |
| 142498 | 142113 | ** expression). The WhereTerm.iField variable identifies the index within |
| 142499 | 142114 | ** the vector on the LHS that the virtual term represents. |
| 142500 | 142115 | ** |
| 142501 | | - ** This only works if the RHS is a simple SELECT (not a compound) that does |
| 142502 | | - ** not use window functions. |
| 142116 | + ** This only works if the RHS is a simple SELECT, not a compound |
| 142503 | 142117 | */ |
| 142504 | 142118 | if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0 |
| 142505 | 142119 | && pExpr->pLeft->op==TK_VECTOR |
| 142506 | 142120 | && pExpr->x.pSelect->pPrior==0 |
| 142507 | | -#ifndef SQLITE_OMIT_WINDOWFUNC |
| 142508 | | - && pExpr->x.pSelect->pWin==0 |
| 142509 | | -#endif |
| 142510 | 142121 | ){ |
| 142511 | 142122 | int i; |
| 142512 | 142123 | for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){ |
| 142513 | 142124 | int idxNew; |
| 142514 | 142125 | idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL); |
| | @@ -142662,14 +142273,13 @@ |
| 142662 | 142273 | mask |= exprSelectUsage(pMaskSet, p->x.pSelect); |
| 142663 | 142274 | }else if( p->x.pList ){ |
| 142664 | 142275 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList); |
| 142665 | 142276 | } |
| 142666 | 142277 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 142667 | | - if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && p->y.pWin ){ |
| 142278 | + if( p->op==TK_FUNCTION && p->y.pWin ){ |
| 142668 | 142279 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition); |
| 142669 | 142280 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy); |
| 142670 | | - mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter); |
| 142671 | 142281 | } |
| 142672 | 142282 | #endif |
| 142673 | 142283 | return mask; |
| 142674 | 142284 | } |
| 142675 | 142285 | SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){ |
| | @@ -143553,12 +143163,11 @@ |
| 143553 | 143163 | if( (idxCols & cMask)==0 ){ |
| 143554 | 143164 | Expr *pX = pTerm->pExpr; |
| 143555 | 143165 | idxCols |= cMask; |
| 143556 | 143166 | pIdx->aiColumn[n] = pTerm->u.leftColumn; |
| 143557 | 143167 | pColl = sqlite3ExprCompareCollSeq(pParse, pX); |
| 143558 | | - assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */ |
| 143559 | | - pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY; |
| 143168 | + pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : sqlite3StrBINARY; |
| 143560 | 143169 | n++; |
| 143561 | 143170 | } |
| 143562 | 143171 | } |
| 143563 | 143172 | } |
| 143564 | 143173 | assert( (u32)n==pLoop->u.btree.nEq ); |
| | @@ -143732,17 +143341,22 @@ |
| 143732 | 143341 | testcase( pTerm->eOperator & WO_IS ); |
| 143733 | 143342 | testcase( pTerm->eOperator & WO_ISNULL ); |
| 143734 | 143343 | testcase( pTerm->eOperator & WO_ALL ); |
| 143735 | 143344 | if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; |
| 143736 | 143345 | 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. */ |
| 143741 | 143346 | if( (pSrc->fg.jointype & JT_LEFT)!=0 |
| 143742 | 143347 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 143348 | + && (pTerm->eOperator & (WO_IS|WO_ISNULL)) |
| 143743 | 143349 | ){ |
| 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 ); |
| 143744 | 143358 | continue; |
| 143745 | 143359 | } |
| 143746 | 143360 | assert( pTerm->u.leftColumn>=(-1) ); |
| 143747 | 143361 | pIdxCons[j].iColumn = pTerm->u.leftColumn; |
| 143748 | 143362 | pIdxCons[j].iTermOffset = i; |
| | @@ -143769,12 +143383,11 @@ |
| 143769 | 143383 | assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) ); |
| 143770 | 143384 | |
| 143771 | 143385 | if( op & (WO_LT|WO_LE|WO_GT|WO_GE) |
| 143772 | 143386 | && sqlite3ExprIsVector(pTerm->pExpr->pRight) |
| 143773 | 143387 | ){ |
| 143774 | | - testcase( j!=i ); |
| 143775 | | - if( j<16 ) mNoOmit |= (1 << j); |
| 143388 | + if( i<16 ) mNoOmit |= (1 << i); |
| 143776 | 143389 | if( op==WO_LT ) pIdxCons[j].op = WO_LE; |
| 143777 | 143390 | if( op==WO_GT ) pIdxCons[j].op = WO_GE; |
| 143778 | 143391 | } |
| 143779 | 143392 | } |
| 143780 | 143393 | |
| | @@ -144515,16 +144128,14 @@ |
| 144515 | 144128 | sqlite3DebugPrintf( |
| 144516 | 144129 | "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x", |
| 144517 | 144130 | iTerm, pTerm, zType, zLeft, pTerm->truthProb, |
| 144518 | 144131 | pTerm->eOperator, pTerm->wtFlags); |
| 144519 | 144132 | if( pTerm->iField ){ |
| 144520 | | - sqlite3DebugPrintf(" iField=%d", pTerm->iField); |
| 144133 | + sqlite3DebugPrintf(" iField=%d\n", pTerm->iField); |
| 144134 | + }else{ |
| 144135 | + sqlite3DebugPrintf("\n"); |
| 144521 | 144136 | } |
| 144522 | | - if( pTerm->iParent>=0 ){ |
| 144523 | | - sqlite3DebugPrintf(" iParent=%d", pTerm->iParent); |
| 144524 | | - } |
| 144525 | | - sqlite3DebugPrintf("\n"); |
| 144526 | 144137 | sqlite3TreeViewExpr(0, pTerm->pExpr, 0); |
| 144527 | 144138 | } |
| 144528 | 144139 | } |
| 144529 | 144140 | #endif |
| 144530 | 144141 | |
| | @@ -144567,11 +144178,11 @@ |
| 144567 | 144178 | sqlite3DebugPrintf("%20s",""); |
| 144568 | 144179 | } |
| 144569 | 144180 | }else{ |
| 144570 | 144181 | char *z; |
| 144571 | 144182 | if( p->u.vtab.idxStr ){ |
| 144572 | | - z = sqlite3_mprintf("(%d,\"%s\",%#x)", |
| 144183 | + z = sqlite3_mprintf("(%d,\"%s\",%x)", |
| 144573 | 144184 | p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask); |
| 144574 | 144185 | }else{ |
| 144575 | 144186 | z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask); |
| 144576 | 144187 | } |
| 144577 | 144188 | sqlite3DebugPrintf(" %-19s", z); |
| | @@ -145222,13 +144833,13 @@ |
| 145222 | 144833 | |
| 145223 | 144834 | /* Do not allow the upper bound of a LIKE optimization range constraint |
| 145224 | 144835 | ** to mix with a lower range bound from some other source */ |
| 145225 | 144836 | if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 145226 | 144837 | |
| 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. */ |
| 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 */ |
| 145230 | 144841 | if( (pSrc->fg.jointype & JT_LEFT)!=0 |
| 145231 | 144842 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 145232 | 144843 | ){ |
| 145233 | 144844 | continue; |
| 145234 | 144845 | } |
| | @@ -145541,29 +145152,23 @@ |
| 145541 | 145152 | } |
| 145542 | 145153 | |
| 145543 | 145154 | /* Check to see if a partial index with pPartIndexWhere can be used |
| 145544 | 145155 | ** in the current query. Return true if it can be and false if not. |
| 145545 | 145156 | */ |
| 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 | | -){ |
| 145157 | +static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ |
| 145552 | 145158 | int i; |
| 145553 | 145159 | WhereTerm *pTerm; |
| 145554 | 145160 | Parse *pParse = pWC->pWInfo->pParse; |
| 145555 | 145161 | while( pWhere->op==TK_AND ){ |
| 145556 | | - if( !whereUsablePartialIndex(iTab,isLeft,pWC,pWhere->pLeft) ) return 0; |
| 145162 | + if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0; |
| 145557 | 145163 | pWhere = pWhere->pRight; |
| 145558 | 145164 | } |
| 145559 | 145165 | if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0; |
| 145560 | 145166 | for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 145561 | 145167 | Expr *pExpr; |
| 145562 | 145168 | pExpr = pTerm->pExpr; |
| 145563 | 145169 | if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) |
| 145564 | | - && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) |
| 145565 | 145170 | && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) |
| 145566 | 145171 | ){ |
| 145567 | 145172 | return 1; |
| 145568 | 145173 | } |
| 145569 | 145174 | } |
| | @@ -145722,15 +145327,12 @@ |
| 145722 | 145327 | /* Loop over all indices. If there was an INDEXED BY clause, then only |
| 145723 | 145328 | ** consider index pProbe. */ |
| 145724 | 145329 | for(; rc==SQLITE_OK && pProbe; |
| 145725 | 145330 | pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++ |
| 145726 | 145331 | ){ |
| 145727 | | - int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0; |
| 145728 | 145332 | if( pProbe->pPartIdxWhere!=0 |
| 145729 | | - && !whereUsablePartialIndex(pSrc->iCursor, isLeft, pWC, |
| 145730 | | - pProbe->pPartIdxWhere) |
| 145731 | | - ){ |
| 145333 | + && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){ |
| 145732 | 145334 | testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */ |
| 145733 | 145335 | continue; /* Partial index inappropriate for this query */ |
| 145734 | 145336 | } |
| 145735 | 145337 | if( pProbe->bNoQuery ) continue; |
| 145736 | 145338 | rSize = pProbe->aiRowLogEst[0]; |
| | @@ -145953,18 +145555,11 @@ |
| 145953 | 145555 | assert( iTerm<pNew->nLSlot ); |
| 145954 | 145556 | pNew->aLTerm[iTerm] = pTerm; |
| 145955 | 145557 | if( iTerm>mxTerm ) mxTerm = iTerm; |
| 145956 | 145558 | testcase( iTerm==15 ); |
| 145957 | 145559 | testcase( iTerm==16 ); |
| 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 | | - } |
| 145560 | + if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm; |
| 145966 | 145561 | if( (pTerm->eOperator & WO_IN)!=0 ){ |
| 145967 | 145562 | /* A virtual table that is constrained by an IN clause may not |
| 145968 | 145563 | ** consume the ORDER BY clause because (1) the order of IN terms |
| 145969 | 145564 | ** is not necessarily related to the order of output terms and |
| 145970 | 145565 | ** (2) Multiple outputs from a single IN value will not merge |
| | @@ -145973,10 +145568,11 @@ |
| 145973 | 145568 | pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE; |
| 145974 | 145569 | *pbIn = 1; assert( (mExclude & WO_IN)==0 ); |
| 145975 | 145570 | } |
| 145976 | 145571 | } |
| 145977 | 145572 | } |
| 145573 | + pNew->u.vtab.omitMask &= ~mNoOmit; |
| 145978 | 145574 | |
| 145979 | 145575 | pNew->nLTerm = mxTerm+1; |
| 145980 | 145576 | for(i=0; i<=mxTerm; i++){ |
| 145981 | 145577 | if( pNew->aLTerm[i]==0 ){ |
| 145982 | 145578 | /* The non-zero argvIdx values must be contiguous. Raise an |
| | @@ -147567,11 +147163,10 @@ |
| 147567 | 147163 | sSelect.pEList = pResultSet; |
| 147568 | 147164 | sqlite3TreeViewSelect(0, &sSelect, 0); |
| 147569 | 147165 | } |
| 147570 | 147166 | } |
| 147571 | 147167 | if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ |
| 147572 | | - sqlite3DebugPrintf("---- WHERE clause at start of analysis:\n"); |
| 147573 | 147168 | sqlite3WhereClausePrint(sWLB.pWC); |
| 147574 | 147169 | } |
| 147575 | 147170 | #endif |
| 147576 | 147171 | |
| 147577 | 147172 | if( nTabList!=1 || whereShortCut(&sWLB)==0 ){ |
| | @@ -147706,17 +147301,11 @@ |
| 147706 | 147301 | } |
| 147707 | 147302 | pWInfo->nLevel--; |
| 147708 | 147303 | nTabList--; |
| 147709 | 147304 | } |
| 147710 | 147305 | } |
| 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 | | - } |
| 147716 | 147306 | WHERETRACE(0xffff,("*** Optimizer Finished ***\n")); |
| 147717 | | -#endif |
| 147718 | 147307 | pWInfo->pParse->nQueryLoop += pWInfo->nRowOut; |
| 147719 | 147308 | |
| 147720 | 147309 | /* If the caller is an UPDATE or DELETE statement that is requesting |
| 147721 | 147310 | ** to use a one-pass algorithm, determine if this is appropriate. |
| 147722 | 147311 | ** |
| | @@ -148982,37 +148571,25 @@ |
| 148982 | 148571 | } |
| 148983 | 148572 | /* Fall through. */ |
| 148984 | 148573 | |
| 148985 | 148574 | case TK_AGG_FUNCTION: |
| 148986 | 148575 | case TK_COLUMN: { |
| 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 | | - } |
| 148576 | + Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 148577 | + p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup); |
| 149001 | 148578 | if( p->pSub ){ |
| 149002 | 148579 | assert( ExprHasProperty(pExpr, EP_Static)==0 ); |
| 149003 | 148580 | ExprSetProperty(pExpr, EP_Static); |
| 149004 | 148581 | sqlite3ExprDelete(pParse->db, pExpr); |
| 149005 | 148582 | ExprClearProperty(pExpr, EP_Static); |
| 149006 | 148583 | memset(pExpr, 0, sizeof(Expr)); |
| 149007 | 148584 | |
| 149008 | 148585 | pExpr->op = TK_COLUMN; |
| 149009 | | - pExpr->iColumn = (iCol<0 ? p->pSub->nExpr-1: iCol); |
| 148586 | + pExpr->iColumn = p->pSub->nExpr-1; |
| 149010 | 148587 | pExpr->iTable = p->pWin->iEphCsr; |
| 149011 | 148588 | pExpr->y.pTab = p->pTab; |
| 149012 | 148589 | } |
| 149013 | | - if( pParse->db->mallocFailed ) return WRC_Abort; |
| 148590 | + |
| 149014 | 148591 | break; |
| 149015 | 148592 | } |
| 149016 | 148593 | |
| 149017 | 148594 | default: /* no-op */ |
| 149018 | 148595 | break; |
| | @@ -149090,15 +148667,13 @@ |
| 149090 | 148667 | if( pAppend ){ |
| 149091 | 148668 | int i; |
| 149092 | 148669 | int nInit = pList ? pList->nExpr : 0; |
| 149093 | 148670 | for(i=0; i<pAppend->nExpr; i++){ |
| 149094 | 148671 | Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0); |
| 149095 | | - assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) ); |
| 149096 | 148672 | if( bIntToNull && pDup && pDup->op==TK_INTEGER ){ |
| 149097 | 148673 | pDup->op = TK_NULL; |
| 149098 | 148674 | pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); |
| 149099 | | - pDup->u.zToken = 0; |
| 149100 | 148675 | } |
| 149101 | 148676 | pList = sqlite3ExprListAppend(pParse, pList, pDup); |
| 149102 | 148677 | if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags; |
| 149103 | 148678 | } |
| 149104 | 148679 | } |
| | @@ -149129,11 +148704,11 @@ |
| 149129 | 148704 | Window *pWin; /* Window object iterator */ |
| 149130 | 148705 | Table *pTab; |
| 149131 | 148706 | |
| 149132 | 148707 | pTab = sqlite3DbMallocZero(db, sizeof(Table)); |
| 149133 | 148708 | if( pTab==0 ){ |
| 149134 | | - return sqlite3ErrorToParser(db, SQLITE_NOMEM); |
| 148709 | + return SQLITE_NOMEM; |
| 149135 | 148710 | } |
| 149136 | 148711 | |
| 149137 | 148712 | p->pSrc = 0; |
| 149138 | 148713 | p->pWhere = 0; |
| 149139 | 148714 | p->pGroupBy = 0; |
| | @@ -149216,13 +148791,10 @@ |
| 149216 | 148791 | p->pSrc->a[0].pSelect = pSub; |
| 149217 | 148792 | sqlite3SrcListAssignCursors(pParse, p->pSrc); |
| 149218 | 148793 | pSub->selFlags |= SF_Expanded; |
| 149219 | 148794 | pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE); |
| 149220 | 148795 | 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. */ |
| 149224 | 148796 | rc = SQLITE_NOMEM; |
| 149225 | 148797 | }else{ |
| 149226 | 148798 | memcpy(pTab, pTab2, sizeof(Table)); |
| 149227 | 148799 | pTab->tabFlags |= TF_Ephemeral; |
| 149228 | 148800 | p->pSrc->a[0].pTab = pTab; |
| | @@ -149237,17 +148809,10 @@ |
| 149237 | 148809 | } |
| 149238 | 148810 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| 149239 | 148811 | sqlite3DbFree(db, pTab); |
| 149240 | 148812 | } |
| 149241 | 148813 | |
| 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 | | - } |
| 149249 | 148814 | return rc; |
| 149250 | 148815 | } |
| 149251 | 148816 | |
| 149252 | 148817 | /* |
| 149253 | 148818 | ** Unlink the Window object from the Select to which it is attached, |
| | @@ -149480,11 +149045,10 @@ |
| 149480 | 149045 | /* |
| 149481 | 149046 | ** Return 0 if the two window objects are identical, or non-zero otherwise. |
| 149482 | 149047 | ** Identical window objects can be processed in a single scan. |
| 149483 | 149048 | */ |
| 149484 | 149049 | SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){ |
| 149485 | | - if( NEVER(p1==0) || NEVER(p2==0) ) return 1; |
| 149486 | 149050 | if( p1->eFrmType!=p2->eFrmType ) return 1; |
| 149487 | 149051 | if( p1->eStart!=p2->eStart ) return 1; |
| 149488 | 149052 | if( p1->eEnd!=p2->eEnd ) return 1; |
| 149489 | 149053 | if( p1->eExclude!=p2->eExclude ) return 1; |
| 149490 | 149054 | if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1; |
| | @@ -151469,22 +151033,21 @@ |
| 151469 | 151033 | #define sqlite3ParserCTX_PDECL ,Parse *pParse |
| 151470 | 151034 | #define sqlite3ParserCTX_PARAM ,pParse |
| 151471 | 151035 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 151472 | 151036 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 151473 | 151037 | #define YYFALLBACK 1 |
| 151474 | | -#define YYNSTATE 551 |
| 151038 | +#define YYNSTATE 550 |
| 151475 | 151039 | #define YYNRULE 385 |
| 151476 | | -#define YYNRULE_WITH_ACTION 325 |
| 151477 | 151040 | #define YYNTOKEN 181 |
| 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 |
| 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 |
| 151486 | 151049 | /************* End control #defines *******************************************/ |
| 151487 | 151050 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 151488 | 151051 | |
| 151489 | 151052 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 151490 | 151053 | ** otherwise. |
| | @@ -151549,206 +151112,206 @@ |
| 151549 | 151112 | ** yy_default[] Default action for each state. |
| 151550 | 151113 | ** |
| 151551 | 151114 | *********** Begin parsing tables **********************************************/ |
| 151552 | 151115 | #define YY_ACTTAB_COUNT (1958) |
| 151553 | 151116 | static const YYACTIONTYPE yy_action[] = { |
| 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, |
| 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, |
| 151567 | 151130 | /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221, |
| 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, |
| 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, |
| 151572 | 151135 | /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, |
| 151573 | 151136 | /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390, |
| 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, |
| 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, |
| 151579 | 151142 | /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179, |
| 151580 | | - /* 260 */ 432, 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, |
| 151581 | | - /* 270 */ 997, 119, 119, 120, 120, 120, 120, 432, 431, 266, |
| 151143 | + /* 260 */ 432, 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, |
| 151144 | + /* 270 */ 996, 119, 119, 120, 120, 120, 120, 432, 431, 266, |
| 151582 | 151145 | /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 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, |
| 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, |
| 151586 | 151149 | /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, |
| 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, |
| 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, |
| 151590 | 151153 | /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422, |
| 151591 | | - /* 370 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, |
| 151592 | | - /* 380 */ 119, 120, 120, 120, 120, 1052, 1052, 463, 1429, 118, |
| 151154 | + /* 370 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, |
| 151155 | + /* 380 */ 119, 120, 120, 120, 120, 1051, 1051, 463, 1428, 118, |
| 151593 | 151156 | /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422, |
| 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, |
| 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, |
| 151597 | 151160 | /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121, |
| 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, |
| 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, |
| 151601 | 151164 | /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122, |
| 151602 | | - /* 480 */ 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, |
| 151165 | + /* 480 */ 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, |
| 151603 | 151166 | /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118, |
| 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, |
| 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, |
| 151607 | 151170 | /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118, |
| 151608 | 151171 | /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112, |
| 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, |
| 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, |
| 151614 | 151177 | /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117, |
| 151615 | 151178 | /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544, |
| 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, |
| 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, |
| 151629 | 151192 | /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116, |
| 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, |
| 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, |
| 151636 | 151199 | /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116, |
| 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, |
| 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, |
| 151640 | 151203 | /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117, |
| 151641 | 151204 | /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266, |
| 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, |
| 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, |
| 151654 | 151217 | /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312, |
| 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, |
| 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, |
| 151666 | 151229 | /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, |
| 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, |
| 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, |
| 151680 | 151243 | /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58, |
| 151681 | | - /* 1270 */ 544, 109, 974, 974, 976, 977, 27, 1514, 1129, 425, |
| 151244 | + /* 1270 */ 544, 109, 973, 973, 975, 976, 27, 1513, 1128, 425, |
| 151682 | 151245 | /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372, |
| 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, |
| 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, |
| 151690 | 151253 | /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307, |
| 151691 | | - /* 1370 */ 63, 63, 544, 1448, 216, 974, 974, 976, 977, 27, |
| 151692 | | - /* 1380 */ 444, 64, 64, 544, 1447, 65, 65, 544, 524, 14, |
| 151254 | + /* 1370 */ 63, 63, 544, 1447, 216, 973, 973, 975, 976, 27, |
| 151255 | + /* 1380 */ 444, 64, 64, 544, 1446, 65, 65, 544, 524, 14, |
| 151693 | 151256 | /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97, |
| 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, |
| 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, |
| 151705 | 151268 | /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544, |
| 151706 | | - /* 1520 */ 472, 1528, 533, 239, 73, 73, 156, 129, 129, 158, |
| 151269 | + /* 1520 */ 472, 1527, 533, 239, 73, 73, 156, 129, 129, 158, |
| 151707 | 151270 | /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149, |
| 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, |
| 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, |
| 151750 | 151313 | }; |
| 151751 | 151314 | static const YYCODETYPE yy_lookahead[] = { |
| 151752 | 151315 | /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268, |
| 151753 | 151316 | /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19, |
| 151754 | 151317 | /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211, |
| | @@ -151941,11 +151504,11 @@ |
| 151941 | 151504 | /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24, |
| 151942 | 151505 | /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26, |
| 151943 | 151506 | /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34, |
| 151944 | 151507 | /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23, |
| 151945 | 151508 | /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23, |
| 151946 | | - /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 1, |
| 151509 | + /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 310, |
| 151947 | 151510 | /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310, |
| 151948 | 151511 | /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151949 | 151512 | /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151950 | 151513 | /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151951 | 151514 | /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| | @@ -151962,13 +151525,13 @@ |
| 151962 | 151525 | /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151963 | 151526 | /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151964 | 151527 | /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151965 | 151528 | /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, |
| 151966 | 151529 | }; |
| 151967 | | -#define YY_SHIFT_COUNT (550) |
| 151530 | +#define YY_SHIFT_COUNT (549) |
| 151968 | 151531 | #define YY_SHIFT_MIN (0) |
| 151969 | | -#define YY_SHIFT_MAX (1948) |
| 151532 | +#define YY_SHIFT_MAX (1947) |
| 151970 | 151533 | static const unsigned short int yy_shift_ofst[] = { |
| 151971 | 151534 | /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481, |
| 151972 | 151535 | /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481, |
| 151973 | 151536 | /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, |
| 151974 | 151537 | /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340, |
| | @@ -152021,11 +151584,10 @@ |
| 152021 | 151584 | /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884, |
| 152022 | 151585 | /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889, |
| 152023 | 151586 | /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905, |
| 152024 | 151587 | /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918, |
| 152025 | 151588 | /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947, |
| 152026 | | - /* 550 */ 1948, |
| 152027 | 151589 | }; |
| 152028 | 151590 | #define YY_REDUCE_COUNT (389) |
| 152029 | 151591 | #define YY_REDUCE_MIN (-262) |
| 152030 | 151592 | #define YY_REDUCE_MAX (1617) |
| 152031 | 151593 | static const short yy_reduce_ofst[] = { |
| | @@ -152068,66 +151630,65 @@ |
| 152068 | 151630 | /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592, |
| 152069 | 151631 | /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600, |
| 152070 | 151632 | /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616, |
| 152071 | 151633 | }; |
| 152072 | 151634 | static const YYACTIONTYPE yy_default[] = { |
| 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, |
| 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, |
| 152129 | 151690 | }; |
| 152130 | 151691 | /********** End of lemon-generated parsing tables *****************************/ |
| 152131 | 151692 | |
| 152132 | 151693 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 152133 | 151694 | ** If a construct like the following: |
| | @@ -153058,11 +152619,11 @@ |
| 153058 | 152619 | /* 325 */ "input ::= cmdlist", |
| 153059 | 152620 | /* 326 */ "cmdlist ::= cmdlist ecmd", |
| 153060 | 152621 | /* 327 */ "cmdlist ::= ecmd", |
| 153061 | 152622 | /* 328 */ "ecmd ::= SEMI", |
| 153062 | 152623 | /* 329 */ "ecmd ::= cmdx SEMI", |
| 153063 | | - /* 330 */ "ecmd ::= explain cmdx SEMI", |
| 152624 | + /* 330 */ "ecmd ::= explain cmdx", |
| 153064 | 152625 | /* 331 */ "trans_opt ::=", |
| 153065 | 152626 | /* 332 */ "trans_opt ::= TRANSACTION", |
| 153066 | 152627 | /* 333 */ "trans_opt ::= TRANSACTION nm", |
| 153067 | 152628 | /* 334 */ "savepoint_opt ::= SAVEPOINT", |
| 153068 | 152629 | /* 335 */ "savepoint_opt ::=", |
| | @@ -153950,11 +153511,11 @@ |
| 153950 | 153511 | 181, /* (325) input ::= cmdlist */ |
| 153951 | 153512 | 182, /* (326) cmdlist ::= cmdlist ecmd */ |
| 153952 | 153513 | 182, /* (327) cmdlist ::= ecmd */ |
| 153953 | 153514 | 183, /* (328) ecmd ::= SEMI */ |
| 153954 | 153515 | 183, /* (329) ecmd ::= cmdx SEMI */ |
| 153955 | | - 183, /* (330) ecmd ::= explain cmdx SEMI */ |
| 153516 | + 183, /* (330) ecmd ::= explain cmdx */ |
| 153956 | 153517 | 188, /* (331) trans_opt ::= */ |
| 153957 | 153518 | 188, /* (332) trans_opt ::= TRANSACTION */ |
| 153958 | 153519 | 188, /* (333) trans_opt ::= TRANSACTION nm */ |
| 153959 | 153520 | 190, /* (334) savepoint_opt ::= SAVEPOINT */ |
| 153960 | 153521 | 190, /* (335) savepoint_opt ::= */ |
| | @@ -154340,11 +153901,11 @@ |
| 154340 | 153901 | -1, /* (325) input ::= cmdlist */ |
| 154341 | 153902 | -2, /* (326) cmdlist ::= cmdlist ecmd */ |
| 154342 | 153903 | -1, /* (327) cmdlist ::= ecmd */ |
| 154343 | 153904 | -1, /* (328) ecmd ::= SEMI */ |
| 154344 | 153905 | -2, /* (329) ecmd ::= cmdx SEMI */ |
| 154345 | | - -3, /* (330) ecmd ::= explain cmdx SEMI */ |
| 153906 | + -2, /* (330) ecmd ::= explain cmdx */ |
| 154346 | 153907 | 0, /* (331) trans_opt ::= */ |
| 154347 | 153908 | -1, /* (332) trans_opt ::= TRANSACTION */ |
| 154348 | 153909 | -2, /* (333) trans_opt ::= TRANSACTION nm */ |
| 154349 | 153910 | -1, /* (334) savepoint_opt ::= SAVEPOINT */ |
| 154350 | 153911 | 0, /* (335) savepoint_opt ::= */ |
| | @@ -154428,19 +153989,16 @@ |
| 154428 | 153989 | yymsp = yypParser->yytos; |
| 154429 | 153990 | #ifndef NDEBUG |
| 154430 | 153991 | if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
| 154431 | 153992 | yysize = yyRuleInfoNRhs[yyruleno]; |
| 154432 | 153993 | if( yysize ){ |
| 154433 | | - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 153994 | + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", |
| 154434 | 153995 | yyTracePrompt, |
| 154435 | | - yyruleno, yyRuleName[yyruleno], |
| 154436 | | - yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action", |
| 154437 | | - yymsp[yysize].stateno); |
| 153996 | + yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); |
| 154438 | 153997 | }else{ |
| 154439 | | - fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", |
| 154440 | | - yyTracePrompt, yyruleno, yyRuleName[yyruleno], |
| 154441 | | - yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action"); |
| 153998 | + fprintf(yyTraceFILE, "%sReduce %d [%s].\n", |
| 153999 | + yyTracePrompt, yyruleno, yyRuleName[yyruleno]); |
| 154442 | 154000 | } |
| 154443 | 154001 | } |
| 154444 | 154002 | #endif /* NDEBUG */ |
| 154445 | 154003 | |
| 154446 | 154004 | /* Check that the stack is large enough to grow by a single entry |
| | @@ -155847,11 +155405,11 @@ |
| 155847 | 155405 | /* (325) input ::= cmdlist */ yytestcase(yyruleno==325); |
| 155848 | 155406 | /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326); |
| 155849 | 155407 | /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327); |
| 155850 | 155408 | /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328); |
| 155851 | 155409 | /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329); |
| 155852 | | - /* (330) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=330); |
| 155410 | + /* (330) ecmd ::= explain cmdx */ yytestcase(yyruleno==330); |
| 155853 | 155411 | /* (331) trans_opt ::= */ yytestcase(yyruleno==331); |
| 155854 | 155412 | /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332); |
| 155855 | 155413 | /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333); |
| 155856 | 155414 | /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334); |
| 155857 | 155415 | /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335); |
| | @@ -163524,13 +163082,10 @@ |
| 163524 | 163082 | # define TESTONLY(X) X |
| 163525 | 163083 | #else |
| 163526 | 163084 | # define TESTONLY(X) |
| 163527 | 163085 | #endif |
| 163528 | 163086 | |
| 163529 | | -#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
| 163530 | | -#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 163531 | | - |
| 163532 | 163087 | #endif /* SQLITE_AMALGAMATION */ |
| 163533 | 163088 | |
| 163534 | 163089 | #ifdef SQLITE_DEBUG |
| 163535 | 163090 | SQLITE_PRIVATE int sqlite3Fts3Corrupt(void); |
| 163536 | 163091 | # define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt() |
| | @@ -163570,11 +163125,10 @@ |
| 163570 | 163125 | sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */ |
| 163571 | 163126 | char *zContentTbl; /* content=xxx option, or NULL */ |
| 163572 | 163127 | char *zLanguageid; /* languageid=xxx option, or NULL */ |
| 163573 | 163128 | int nAutoincrmerge; /* Value configured by 'automerge' */ |
| 163574 | 163129 | u32 nLeafAdd; /* Number of leaf blocks added this trans */ |
| 163575 | | - int bLock; /* Used to prevent recursive content= tbls */ |
| 163576 | 163130 | |
| 163577 | 163131 | /* Precompiled statements used by the implementation. Each of these |
| 163578 | 163132 | ** statements is run and reset within a single virtual table API call. |
| 163579 | 163133 | */ |
| 163580 | 163134 | sqlite3_stmt *aStmt[40]; |
| | @@ -163909,11 +163463,10 @@ |
| 163909 | 163463 | |
| 163910 | 163464 | /* fts3.c */ |
| 163911 | 163465 | SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...); |
| 163912 | 163466 | SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64); |
| 163913 | 163467 | SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *); |
| 163914 | | -SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *, sqlite_uint64 *); |
| 163915 | 163468 | SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*); |
| 163916 | 163469 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *); |
| 163917 | 163470 | SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64); |
| 163918 | 163471 | SQLITE_PRIVATE void sqlite3Fts3Dequote(char *); |
| 163919 | 163472 | SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*); |
| | @@ -163997,10 +163550,22 @@ |
| 163997 | 163550 | #ifndef SQLITE_CORE |
| 163998 | 163551 | /* # include "sqlite3ext.h" */ |
| 163999 | 163552 | SQLITE_EXTENSION_INIT1 |
| 164000 | 163553 | #endif |
| 164001 | 163554 | |
| 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 | + |
| 164002 | 163567 | static int fts3EvalNext(Fts3Cursor *pCsr); |
| 164003 | 163568 | static int fts3EvalStart(Fts3Cursor *pCsr); |
| 164004 | 163569 | static int fts3TermSegReaderCursor( |
| 164005 | 163570 | Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **); |
| 164006 | 163571 | |
| | @@ -164041,11 +163606,16 @@ |
| 164041 | 163606 | if( (v & mask2)==0 ){ var = v; return ret; } |
| 164042 | 163607 | #define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \ |
| 164043 | 163608 | v = (*ptr++); \ |
| 164044 | 163609 | if( (v & mask2)==0 ){ var = v; return ret; } |
| 164045 | 163610 | |
| 164046 | | -SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *pBuf, sqlite_uint64 *v){ |
| 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){ |
| 164047 | 163617 | const unsigned char *p = (const unsigned char*)pBuf; |
| 164048 | 163618 | const unsigned char *pStart = p; |
| 164049 | 163619 | u32 a; |
| 164050 | 163620 | u64 b; |
| 164051 | 163621 | int shift; |
| | @@ -164063,19 +163633,10 @@ |
| 164063 | 163633 | } |
| 164064 | 163634 | *v = b; |
| 164065 | 163635 | return (int)(p - pStart); |
| 164066 | 163636 | } |
| 164067 | 163637 | |
| 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 | | -} |
| 164076 | | - |
| 164077 | 163638 | /* |
| 164078 | 163639 | ** Read a 64-bit variable-length integer from memory starting at p[0] and |
| 164079 | 163640 | ** not extending past pEnd[-1]. |
| 164080 | 163641 | ** Return the number of bytes read, or 0 on error. |
| 164081 | 163642 | ** The value is stored in *v. |
| | @@ -165292,14 +164853,10 @@ |
| 165292 | 164853 | int iLangidCons = -1; /* Index of langid=x constraint, if present */ |
| 165293 | 164854 | int iDocidGe = -1; /* Index of docid>=x constraint, if present */ |
| 165294 | 164855 | int iDocidLe = -1; /* Index of docid<=x constraint, if present */ |
| 165295 | 164856 | int iIdx; |
| 165296 | 164857 | |
| 165297 | | - if( p->bLock ){ |
| 165298 | | - return SQLITE_ERROR; |
| 165299 | | - } |
| 165300 | | - |
| 165301 | 164858 | /* By default use a full table scan. This is an expensive option, |
| 165302 | 164859 | ** so search through the constraints to see if a more efficient |
| 165303 | 164860 | ** strategy is possible. |
| 165304 | 164861 | */ |
| 165305 | 164862 | pInfo->idxNum = FTS3_FULLSCAN_SEARCH; |
| | @@ -165494,15 +165051,11 @@ |
| 165494 | 165051 | pCsr->pStmt = p->pSeekStmt; |
| 165495 | 165052 | p->pSeekStmt = 0; |
| 165496 | 165053 | }else{ |
| 165497 | 165054 | zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); |
| 165498 | 165055 | if( !zSql ) return SQLITE_NOMEM; |
| 165499 | | - p->bLock++; |
| 165500 | | - rc = sqlite3_prepare_v3( |
| 165501 | | - p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0 |
| 165502 | | - ); |
| 165503 | | - p->bLock--; |
| 165056 | + rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0); |
| 165504 | 165057 | sqlite3_free(zSql); |
| 165505 | 165058 | } |
| 165506 | 165059 | if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1; |
| 165507 | 165060 | } |
| 165508 | 165061 | return rc; |
| | @@ -165516,19 +165069,15 @@ |
| 165516 | 165069 | static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ |
| 165517 | 165070 | int rc = SQLITE_OK; |
| 165518 | 165071 | if( pCsr->isRequireSeek ){ |
| 165519 | 165072 | rc = fts3CursorSeekStmt(pCsr); |
| 165520 | 165073 | if( rc==SQLITE_OK ){ |
| 165521 | | - Fts3Table *pTab = (Fts3Table*)pCsr->base.pVtab; |
| 165522 | | - pTab->bLock++; |
| 165523 | 165074 | sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); |
| 165524 | 165075 | pCsr->isRequireSeek = 0; |
| 165525 | 165076 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 165526 | | - pTab->bLock--; |
| 165527 | 165077 | return SQLITE_OK; |
| 165528 | 165078 | }else{ |
| 165529 | | - pTab->bLock--; |
| 165530 | 165079 | rc = sqlite3_reset(pCsr->pStmt); |
| 165531 | 165080 | if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ |
| 165532 | 165081 | /* If no row was found and no error has occurred, then the %_content |
| 165533 | 165082 | ** table is missing a row that is present in the full-text index. |
| 165534 | 165083 | ** The data structures are corrupt. */ |
| | @@ -165696,11 +165245,11 @@ |
| 165696 | 165245 | |
| 165697 | 165246 | assert( piLeaf || piLeaf2 ); |
| 165698 | 165247 | |
| 165699 | 165248 | fts3GetVarint32(zNode, &iHeight); |
| 165700 | 165249 | rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2); |
| 165701 | | - assert_fts3_nc( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) ); |
| 165250 | + assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) ); |
| 165702 | 165251 | |
| 165703 | 165252 | if( rc==SQLITE_OK && iHeight>1 ){ |
| 165704 | 165253 | char *zBlob = 0; /* Blob read from %_segments table */ |
| 165705 | 165254 | int nBlob = 0; /* Size of zBlob in bytes */ |
| 165706 | 165255 | |
| | @@ -166177,16 +165726,16 @@ |
| 166177 | 165726 | sqlite3_int64 *pVal /* IN/OUT: Integer value */ |
| 166178 | 165727 | ){ |
| 166179 | 165728 | if( *pp>=pEnd ){ |
| 166180 | 165729 | *pp = 0; |
| 166181 | 165730 | }else{ |
| 166182 | | - u64 iVal; |
| 166183 | | - *pp += sqlite3Fts3GetVarintU(*pp, &iVal); |
| 165731 | + sqlite3_int64 iVal; |
| 165732 | + *pp += sqlite3Fts3GetVarint(*pp, &iVal); |
| 166184 | 165733 | if( bDescIdx ){ |
| 166185 | | - *pVal = (i64)((u64)*pVal - iVal); |
| 165734 | + *pVal -= iVal; |
| 166186 | 165735 | }else{ |
| 166187 | | - *pVal = (i64)((u64)*pVal + iVal); |
| 165736 | + *pVal += iVal; |
| 166188 | 165737 | } |
| 166189 | 165738 | } |
| 166190 | 165739 | } |
| 166191 | 165740 | |
| 166192 | 165741 | /* |
| | @@ -166212,14 +165761,14 @@ |
| 166212 | 165761 | sqlite3_int64 iVal /* Write this value to the list */ |
| 166213 | 165762 | ){ |
| 166214 | 165763 | sqlite3_uint64 iWrite; |
| 166215 | 165764 | if( bDescIdx==0 || *pbFirst==0 ){ |
| 166216 | 165765 | assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev ); |
| 166217 | | - iWrite = (u64)iVal - (u64)*piPrev; |
| 165766 | + iWrite = iVal - *piPrev; |
| 166218 | 165767 | }else{ |
| 166219 | 165768 | assert_fts3_nc( *piPrev>=iVal ); |
| 166220 | | - iWrite = (u64)*piPrev - (u64)iVal; |
| 165769 | + iWrite = *piPrev - iVal; |
| 166221 | 165770 | } |
| 166222 | 165771 | assert( *pbFirst || *piPrev==0 ); |
| 166223 | 165772 | assert_fts3_nc( *pbFirst==0 || iWrite>0 ); |
| 166224 | 165773 | *pp += sqlite3Fts3PutVarint(*pp, iWrite); |
| 166225 | 165774 | *piPrev = iVal; |
| | @@ -166234,12 +165783,11 @@ |
| 166234 | 165783 | ** Otherwise, (i2-i1). |
| 166235 | 165784 | ** |
| 166236 | 165785 | ** Using this makes it easier to write code that can merge doclists that are |
| 166237 | 165786 | ** sorted in either ascending or descending order. |
| 166238 | 165787 | */ |
| 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))) |
| 165788 | +#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2)) |
| 166241 | 165789 | |
| 166242 | 165790 | /* |
| 166243 | 165791 | ** This function does an "OR" merge of two doclists (output contains all |
| 166244 | 165792 | ** positions contained in either argument doclist). If the docids in the |
| 166245 | 165793 | ** input doclists are sorted in ascending order, parameter bDescDoclist |
| | @@ -166649,11 +166197,11 @@ |
| 166649 | 166197 | ** for the pending-terms. If this is a scan, then this call must be being |
| 166650 | 166198 | ** made by an fts4aux module, not an FTS table. In this case calling |
| 166651 | 166199 | ** Fts3SegReaderPending might segfault, as the data structures used by |
| 166652 | 166200 | ** fts4aux are not completely populated. So it's easiest to filter these |
| 166653 | 166201 | ** calls out here. */ |
| 166654 | | - if( iLevel<0 && p->aIndex && p->iPrevLangid==iLangid ){ |
| 166202 | + if( iLevel<0 && p->aIndex ){ |
| 166655 | 166203 | Fts3SegReader *pSeg = 0; |
| 166656 | 166204 | rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg); |
| 166657 | 166205 | if( rc==SQLITE_OK && pSeg ){ |
| 166658 | 166206 | rc = fts3SegReaderCursorAppend(pCsr, pSeg); |
| 166659 | 166207 | } |
| | @@ -166912,20 +166460,17 @@ |
| 166912 | 166460 | */ |
| 166913 | 166461 | static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){ |
| 166914 | 166462 | int rc; |
| 166915 | 166463 | Fts3Cursor *pCsr = (Fts3Cursor *)pCursor; |
| 166916 | 166464 | if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){ |
| 166917 | | - Fts3Table *pTab = (Fts3Table*)pCursor->pVtab; |
| 166918 | | - pTab->bLock++; |
| 166919 | 166465 | if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){ |
| 166920 | 166466 | pCsr->isEof = 1; |
| 166921 | 166467 | rc = sqlite3_reset(pCsr->pStmt); |
| 166922 | 166468 | }else{ |
| 166923 | 166469 | pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0); |
| 166924 | 166470 | rc = SQLITE_OK; |
| 166925 | 166471 | } |
| 166926 | | - pTab->bLock--; |
| 166927 | 166472 | }else{ |
| 166928 | 166473 | rc = fts3EvalNext((Fts3Cursor *)pCursor); |
| 166929 | 166474 | } |
| 166930 | 166475 | assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); |
| 166931 | 166476 | return rc; |
| | @@ -166982,14 +166527,10 @@ |
| 166982 | 166527 | int iIdx; |
| 166983 | 166528 | |
| 166984 | 166529 | UNUSED_PARAMETER(idxStr); |
| 166985 | 166530 | UNUSED_PARAMETER(nVal); |
| 166986 | 166531 | |
| 166987 | | - if( p->bLock ){ |
| 166988 | | - return SQLITE_ERROR; |
| 166989 | | - } |
| 166990 | | - |
| 166991 | 166532 | eSearch = (idxNum & 0x0000FFFF); |
| 166992 | 166533 | assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) ); |
| 166993 | 166534 | assert( p->pSegments==0 ); |
| 166994 | 166535 | |
| 166995 | 166536 | /* Collect arguments into local variables */ |
| | @@ -167057,15 +166598,11 @@ |
| 167057 | 166598 | zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s", |
| 167058 | 166599 | p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC") |
| 167059 | 166600 | ); |
| 167060 | 166601 | } |
| 167061 | 166602 | if( zSql ){ |
| 167062 | | - p->bLock++; |
| 167063 | | - rc = sqlite3_prepare_v3( |
| 167064 | | - p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0 |
| 167065 | | - ); |
| 167066 | | - p->bLock--; |
| 166603 | + rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0); |
| 167067 | 166604 | sqlite3_free(zSql); |
| 167068 | 166605 | }else{ |
| 167069 | 166606 | rc = SQLITE_NOMEM; |
| 167070 | 166607 | } |
| 167071 | 166608 | }else if( eSearch==FTS3_DOCID_SEARCH ){ |
| | @@ -168220,20 +167757,19 @@ |
| 168220 | 167757 | Fts3Table *pTab, |
| 168221 | 167758 | Fts3Doclist *pDL, |
| 168222 | 167759 | u8 *pbEof |
| 168223 | 167760 | ){ |
| 168224 | 167761 | char *pIter; /* Used to iterate through aAll */ |
| 168225 | | - char *pEnd; /* 1 byte past end of aAll */ |
| 167762 | + char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */ |
| 168226 | 167763 | |
| 168227 | 167764 | if( pDL->pNextDocid ){ |
| 168228 | 167765 | pIter = pDL->pNextDocid; |
| 168229 | | - assert( pDL->aAll!=0 || pIter==0 ); |
| 168230 | 167766 | }else{ |
| 168231 | 167767 | pIter = pDL->aAll; |
| 168232 | 167768 | } |
| 168233 | 167769 | |
| 168234 | | - if( pIter==0 || pIter>=(pEnd = pDL->aAll + pDL->nAll) ){ |
| 167770 | + if( pIter>=pEnd ){ |
| 168235 | 167771 | /* We have already reached the end of this doclist. EOF. */ |
| 168236 | 167772 | *pbEof = 1; |
| 168237 | 167773 | }else{ |
| 168238 | 167774 | sqlite3_int64 iDelta; |
| 168239 | 167775 | pIter += sqlite3Fts3GetVarint(pIter, &iDelta); |
| | @@ -174569,11 +174105,11 @@ |
| 174569 | 174105 | int rc = SQLITE_OK; |
| 174570 | 174106 | |
| 174571 | 174107 | assert( !p || p->iLastDocid<=iDocid ); |
| 174572 | 174108 | |
| 174573 | 174109 | if( !p || p->iLastDocid!=iDocid ){ |
| 174574 | | - u64 iDelta = (u64)iDocid - (u64)(p ? p->iLastDocid : 0); |
| 174110 | + sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0); |
| 174575 | 174111 | if( p ){ |
| 174576 | 174112 | assert( p->nData<p->nSpace ); |
| 174577 | 174113 | assert( p->aData[p->nData]==0 ); |
| 174578 | 174114 | p->nData++; |
| 174579 | 174115 | } |
| | @@ -175110,12 +174646,10 @@ |
| 175110 | 174646 | aByte = 0; |
| 175111 | 174647 | } |
| 175112 | 174648 | } |
| 175113 | 174649 | *paBlob = aByte; |
| 175114 | 174650 | } |
| 175115 | | - }else if( rc==SQLITE_ERROR ){ |
| 175116 | | - rc = FTS_CORRUPT_VTAB; |
| 175117 | 174651 | } |
| 175118 | 174652 | |
| 175119 | 174653 | return rc; |
| 175120 | 174654 | } |
| 175121 | 174655 | |
| | @@ -175404,22 +174938,22 @@ |
| 175404 | 174938 | if( p>=pEnd ){ |
| 175405 | 174939 | pReader->pOffsetList = 0; |
| 175406 | 174940 | }else{ |
| 175407 | 174941 | rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX); |
| 175408 | 174942 | if( rc==SQLITE_OK ){ |
| 175409 | | - u64 iDelta; |
| 175410 | | - pReader->pOffsetList = p + sqlite3Fts3GetVarintU(p, &iDelta); |
| 174943 | + sqlite3_int64 iDelta; |
| 174944 | + pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta); |
| 175411 | 174945 | if( pTab->bDescIdx ){ |
| 175412 | | - pReader->iDocid = (i64)((u64)pReader->iDocid - iDelta); |
| 174946 | + pReader->iDocid -= iDelta; |
| 175413 | 174947 | }else{ |
| 175414 | | - pReader->iDocid = (i64)((u64)pReader->iDocid + iDelta); |
| 174948 | + pReader->iDocid += iDelta; |
| 175415 | 174949 | } |
| 175416 | 174950 | } |
| 175417 | 174951 | } |
| 175418 | 174952 | } |
| 175419 | 174953 | |
| 175420 | | - return rc; |
| 174954 | + return SQLITE_OK; |
| 175421 | 174955 | } |
| 175422 | 174956 | |
| 175423 | 174957 | |
| 175424 | 174958 | SQLITE_PRIVATE int sqlite3Fts3MsrOvfl( |
| 175425 | 174959 | Fts3Cursor *pCsr, |
| | @@ -176154,11 +175688,10 @@ |
| 176154 | 175688 | |
| 176155 | 175689 | if( nData>0 && nData+nReq>p->nNodeSize ){ |
| 176156 | 175690 | int rc; |
| 176157 | 175691 | |
| 176158 | 175692 | /* The current leaf node is full. Write it out to the database. */ |
| 176159 | | - if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB; |
| 176160 | 175693 | rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData); |
| 176161 | 175694 | if( rc!=SQLITE_OK ) return rc; |
| 176162 | 175695 | p->nLeafAdd++; |
| 176163 | 175696 | |
| 176164 | 175697 | /* Add the current term to the interior node tree. The term added to |
| | @@ -176852,14 +176385,14 @@ |
| 176852 | 176385 | /* Calculate the 'docid' delta value to write into the merged |
| 176853 | 176386 | ** doclist. */ |
| 176854 | 176387 | sqlite3_int64 iDelta; |
| 176855 | 176388 | if( p->bDescIdx && nDoclist>0 ){ |
| 176856 | 176389 | if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB; |
| 176857 | | - iDelta = (i64)((u64)iPrev - (u64)iDocid); |
| 176390 | + iDelta = iPrev - iDocid; |
| 176858 | 176391 | }else{ |
| 176859 | 176392 | if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB; |
| 176860 | | - iDelta = (i64)((u64)iDocid - (u64)iPrev); |
| 176393 | + iDelta = iDocid - iPrev; |
| 176861 | 176394 | } |
| 176862 | 176395 | |
| 176863 | 176396 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 176864 | 176397 | if( nDoclist+nByte>pCsr->nBuffer ){ |
| 176865 | 176398 | char *aNew; |
| | @@ -177138,11 +176671,11 @@ |
| 177138 | 176671 | if( rc!=SQLITE_ROW ) break; |
| 177139 | 176672 | rc = fts3SegWriterAdd(p, &pWriter, 1, |
| 177140 | 176673 | csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist); |
| 177141 | 176674 | } |
| 177142 | 176675 | if( rc!=SQLITE_OK ) goto finished; |
| 177143 | | - assert_fts3_nc( pWriter || bIgnoreEmpty ); |
| 176676 | + assert( pWriter || bIgnoreEmpty ); |
| 177144 | 176677 | |
| 177145 | 176678 | if( iLevel!=FTS3_SEGCURSOR_PENDING ){ |
| 177146 | 176679 | rc = fts3DeleteSegdir( |
| 177147 | 176680 | p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment |
| 177148 | 176681 | ); |
| | @@ -178724,21 +178257,17 @@ |
| 178724 | 178257 | */ |
| 178725 | 178258 | static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){ |
| 178726 | 178259 | const int nHint = pHint->n; |
| 178727 | 178260 | int i; |
| 178728 | 178261 | |
| 178729 | | - i = pHint->n-1; |
| 178730 | | - if( (pHint->a[i] & 0x80) ) return FTS_CORRUPT_VTAB; |
| 178262 | + i = pHint->n-2; |
| 178731 | 178263 | while( i>0 && (pHint->a[i-1] & 0x80) ) i--; |
| 178732 | | - if( i==0 ) return FTS_CORRUPT_VTAB; |
| 178733 | | - i--; |
| 178734 | 178264 | while( i>0 && (pHint->a[i-1] & 0x80) ) i--; |
| 178735 | 178265 | |
| 178736 | 178266 | pHint->n = i; |
| 178737 | 178267 | i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel); |
| 178738 | 178268 | i += fts3GetVarint32(&pHint->a[i], pnInput); |
| 178739 | | - assert( i<=nHint ); |
| 178740 | 178269 | if( i!=nHint ) return FTS_CORRUPT_VTAB; |
| 178741 | 178270 | |
| 178742 | 178271 | return SQLITE_OK; |
| 178743 | 178272 | } |
| 178744 | 178273 | |
| | @@ -179064,28 +178593,28 @@ |
| 179064 | 178593 | char *pCsr = csr.aDoclist; |
| 179065 | 178594 | char *pEnd = &pCsr[csr.nDoclist]; |
| 179066 | 178595 | |
| 179067 | 178596 | i64 iDocid = 0; |
| 179068 | 178597 | i64 iCol = 0; |
| 179069 | | - u64 iPos = 0; |
| 178598 | + i64 iPos = 0; |
| 179070 | 178599 | |
| 179071 | 178600 | pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid); |
| 179072 | 178601 | while( pCsr<pEnd ){ |
| 179073 | | - u64 iVal = 0; |
| 179074 | | - pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal); |
| 178602 | + i64 iVal = 0; |
| 178603 | + pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); |
| 179075 | 178604 | if( pCsr<pEnd ){ |
| 179076 | 178605 | if( iVal==0 || iVal==1 ){ |
| 179077 | 178606 | iCol = 0; |
| 179078 | 178607 | iPos = 0; |
| 179079 | 178608 | if( iVal ){ |
| 179080 | 178609 | pCsr += sqlite3Fts3GetVarint(pCsr, &iCol); |
| 179081 | 178610 | }else{ |
| 179082 | | - pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal); |
| 178611 | + pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); |
| 179083 | 178612 | if( p->bDescIdx ){ |
| 179084 | | - iDocid = (i64)((u64)iDocid - iVal); |
| 178613 | + iDocid -= iVal; |
| 179085 | 178614 | }else{ |
| 179086 | | - iDocid = (i64)((u64)iDocid + iVal); |
| 178615 | + iDocid += iVal; |
| 179087 | 178616 | } |
| 179088 | 178617 | } |
| 179089 | 178618 | }else{ |
| 179090 | 178619 | iPos += (iVal - 2); |
| 179091 | 178620 | cksum = cksum ^ fts3ChecksumEntry( |
| | @@ -183357,53 +182886,22 @@ |
| 183357 | 182886 | pRoot->jnFlags |= JNODE_APPEND; |
| 183358 | 182887 | pParse->aNode[iLabel].jnFlags |= JNODE_RAW; |
| 183359 | 182888 | } |
| 183360 | 182889 | return pNode; |
| 183361 | 182890 | } |
| 183362 | | - }else if( zPath[0]=='[' ){ |
| 182891 | + }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){ |
| 182892 | + if( pRoot->eType!=JSON_ARRAY ) return 0; |
| 183363 | 182893 | i = 0; |
| 183364 | 182894 | j = 1; |
| 183365 | 182895 | while( safe_isdigit(zPath[j]) ){ |
| 183366 | 182896 | i = i*10 + zPath[j] - '0'; |
| 183367 | 182897 | j++; |
| 183368 | 182898 | } |
| 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 | | - } |
| 183403 | | - } |
| 183404 | | - if( pRoot->eType!=JSON_ARRAY ) return 0; |
| 182899 | + if( zPath[j]!=']' ){ |
| 182900 | + *pzErr = zPath; |
| 182901 | + return 0; |
| 182902 | + } |
| 183405 | 182903 | zPath += j + 1; |
| 183406 | 182904 | j = 1; |
| 183407 | 182905 | for(;;){ |
| 183408 | 182906 | while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){ |
| 183409 | 182907 | if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--; |
| | @@ -184867,11 +184365,10 @@ |
| 184867 | 184365 | /* #include "sqlite3ext.h" */ |
| 184868 | 184366 | SQLITE_EXTENSION_INIT1 |
| 184869 | 184367 | #else |
| 184870 | 184368 | /* #include "sqlite3.h" */ |
| 184871 | 184369 | #endif |
| 184872 | | -SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */ |
| 184873 | 184370 | |
| 184874 | 184371 | #ifndef SQLITE_AMALGAMATION |
| 184875 | 184372 | #include "sqlite3rtree.h" |
| 184876 | 184373 | typedef sqlite3_int64 i64; |
| 184877 | 184374 | typedef sqlite3_uint64 u64; |
| | @@ -185131,16 +184628,10 @@ |
| 185131 | 184628 | #define RTREE_GE 0x44 /* D */ |
| 185132 | 184629 | #define RTREE_GT 0x45 /* E */ |
| 185133 | 184630 | #define RTREE_MATCH 0x46 /* F: Old-style sqlite3_rtree_geometry_callback() */ |
| 185134 | 184631 | #define RTREE_QUERY 0x47 /* G: New-style sqlite3_rtree_query_callback() */ |
| 185135 | 184632 | |
| 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 /* @ */ |
| 185142 | 184633 | |
| 185143 | 184634 | /* |
| 185144 | 184635 | ** An rtree structure node. |
| 185145 | 184636 | */ |
| 185146 | 184637 | struct RtreeNode { |
| | @@ -185870,16 +185361,13 @@ |
| 185870 | 185361 | return rc; |
| 185871 | 185362 | } |
| 185872 | 185363 | |
| 185873 | 185364 | |
| 185874 | 185365 | /* |
| 185875 | | -** Reset a cursor back to its initial state. |
| 185366 | +** Free the RtreeCursor.aConstraint[] array and its contents. |
| 185876 | 185367 | */ |
| 185877 | | -static void resetCursor(RtreeCursor *pCsr){ |
| 185878 | | - Rtree *pRtree = (Rtree *)(pCsr->base.pVtab); |
| 185879 | | - int ii; |
| 185880 | | - sqlite3_stmt *pStmt; |
| 185368 | +static void freeCursorConstraints(RtreeCursor *pCsr){ |
| 185881 | 185369 | if( pCsr->aConstraint ){ |
| 185882 | 185370 | int i; /* Used to iterate through constraint array */ |
| 185883 | 185371 | for(i=0; i<pCsr->nConstraint; i++){ |
| 185884 | 185372 | sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo; |
| 185885 | 185373 | if( pInfo ){ |
| | @@ -185888,28 +185376,24 @@ |
| 185888 | 185376 | } |
| 185889 | 185377 | } |
| 185890 | 185378 | sqlite3_free(pCsr->aConstraint); |
| 185891 | 185379 | pCsr->aConstraint = 0; |
| 185892 | 185380 | } |
| 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 | | - |
| 185900 | 185381 | } |
| 185901 | 185382 | |
| 185902 | 185383 | /* |
| 185903 | 185384 | ** Rtree virtual table module xClose method. |
| 185904 | 185385 | */ |
| 185905 | 185386 | static int rtreeClose(sqlite3_vtab_cursor *cur){ |
| 185906 | 185387 | Rtree *pRtree = (Rtree *)(cur->pVtab); |
| 185388 | + int ii; |
| 185907 | 185389 | RtreeCursor *pCsr = (RtreeCursor *)cur; |
| 185908 | 185390 | assert( pRtree->nCursor>0 ); |
| 185909 | | - resetCursor(pCsr); |
| 185391 | + freeCursorConstraints(pCsr); |
| 185910 | 185392 | sqlite3_finalize(pCsr->pReadAux); |
| 185393 | + sqlite3_free(pCsr->aPoint); |
| 185394 | + for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]); |
| 185911 | 185395 | sqlite3_free(pCsr); |
| 185912 | 185396 | pRtree->nCursor--; |
| 185913 | 185397 | nodeBlobReset(pRtree); |
| 185914 | 185398 | return SQLITE_OK; |
| 185915 | 185399 | } |
| | @@ -186063,16 +185547,13 @@ |
| 186063 | 185547 | ** in a coordinate pair. But make pCellData point to the lower bound. |
| 186064 | 185548 | */ |
| 186065 | 185549 | pCellData += 8 + 4*(p->iCoord&0xfe); |
| 186066 | 185550 | |
| 186067 | 185551 | assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE |
| 186068 | | - || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE |
| 186069 | | - || p->op==RTREE_FALSE ); |
| 185552 | + || p->op==RTREE_GT || p->op==RTREE_EQ ); |
| 186070 | 185553 | assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ |
| 186071 | 185554 | switch( p->op ){ |
| 186072 | | - case RTREE_TRUE: return; /* Always satisfied */ |
| 186073 | | - case RTREE_FALSE: break; /* Never satisfied */ |
| 186074 | 185555 | case RTREE_LE: |
| 186075 | 185556 | case RTREE_LT: |
| 186076 | 185557 | case RTREE_EQ: |
| 186077 | 185558 | RTREE_DECODE_COORD(eInt, pCellData, val); |
| 186078 | 185559 | /* val now holds the lower bound of the coordinate pair */ |
| | @@ -186106,23 +185587,20 @@ |
| 186106 | 185587 | int *peWithin /* Adjust downward, as appropriate */ |
| 186107 | 185588 | ){ |
| 186108 | 185589 | RtreeDValue xN; /* Coordinate value converted to a double */ |
| 186109 | 185590 | |
| 186110 | 185591 | assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE |
| 186111 | | - || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE |
| 186112 | | - || p->op==RTREE_FALSE ); |
| 185592 | + || p->op==RTREE_GT || p->op==RTREE_EQ ); |
| 186113 | 185593 | pCellData += 8 + p->iCoord*4; |
| 186114 | 185594 | assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ |
| 186115 | 185595 | RTREE_DECODE_COORD(eInt, pCellData, xN); |
| 186116 | 185596 | switch( p->op ){ |
| 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; |
| 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; |
| 186124 | 185602 | } |
| 186125 | 185603 | *peWithin = NOT_WITHIN; |
| 186126 | 185604 | } |
| 186127 | 185605 | |
| 186128 | 185606 | /* |
| | @@ -186611,32 +186089,30 @@ |
| 186611 | 186089 | RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; |
| 186612 | 186090 | RtreeNode *pRoot = 0; |
| 186613 | 186091 | int ii; |
| 186614 | 186092 | int rc = SQLITE_OK; |
| 186615 | 186093 | int iCell = 0; |
| 186094 | + sqlite3_stmt *pStmt; |
| 186616 | 186095 | |
| 186617 | 186096 | rtreeReference(pRtree); |
| 186618 | 186097 | |
| 186619 | 186098 | /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ |
| 186620 | | - resetCursor(pCsr); |
| 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; |
| 186621 | 186105 | |
| 186622 | 186106 | pCsr->iStrategy = idxNum; |
| 186623 | 186107 | if( idxNum==1 ){ |
| 186624 | 186108 | /* Special case - lookup by rowid. */ |
| 186625 | 186109 | RtreeNode *pLeaf; /* Leaf on which the required cell resides */ |
| 186626 | 186110 | RtreeSearchPoint *p; /* Search point for the leaf */ |
| 186627 | 186111 | i64 iRowid = sqlite3_value_int64(argv[0]); |
| 186628 | 186112 | i64 iNode = 0; |
| 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 | | - } |
| 186113 | + rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); |
| 186638 | 186114 | if( rc==SQLITE_OK && pLeaf!=0 ){ |
| 186639 | 186115 | p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0); |
| 186640 | 186116 | assert( p!=0 ); /* Always returns pCsr->sPoint */ |
| 186641 | 186117 | pCsr->aNode[0] = pLeaf; |
| 186642 | 186118 | p->id = iNode; |
| | @@ -186662,11 +186138,10 @@ |
| 186662 | 186138 | memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1)); |
| 186663 | 186139 | assert( (idxStr==0 && argc==0) |
| 186664 | 186140 | || (idxStr && (int)strlen(idxStr)==argc*2) ); |
| 186665 | 186141 | for(ii=0; ii<argc; ii++){ |
| 186666 | 186142 | RtreeConstraint *p = &pCsr->aConstraint[ii]; |
| 186667 | | - int eType = sqlite3_value_numeric_type(argv[ii]); |
| 186668 | 186143 | p->op = idxStr[ii*2]; |
| 186669 | 186144 | p->iCoord = idxStr[ii*2+1]-'0'; |
| 186670 | 186145 | if( p->op>=RTREE_MATCH ){ |
| 186671 | 186146 | /* A MATCH operator. The right-hand-side must be a blob that |
| 186672 | 186147 | ** can be cast into an RtreeMatchArg object. One created using |
| | @@ -186677,25 +186152,16 @@ |
| 186677 | 186152 | break; |
| 186678 | 186153 | } |
| 186679 | 186154 | p->pInfo->nCoord = pRtree->nDim2; |
| 186680 | 186155 | p->pInfo->anQueue = pCsr->anQueue; |
| 186681 | 186156 | p->pInfo->mxLevel = pRtree->iDepth + 1; |
| 186682 | | - }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 186157 | + }else{ |
| 186683 | 186158 | #ifdef SQLITE_RTREE_INT_ONLY |
| 186684 | 186159 | p->u.rValue = sqlite3_value_int64(argv[ii]); |
| 186685 | 186160 | #else |
| 186686 | 186161 | p->u.rValue = sqlite3_value_double(argv[ii]); |
| 186687 | 186162 | #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 | | - } |
| 186697 | 186163 | } |
| 186698 | 186164 | } |
| 186699 | 186165 | } |
| 186700 | 186166 | } |
| 186701 | 186167 | if( rc==SQLITE_OK ){ |
| | @@ -188468,18 +187934,10 @@ |
| 188468 | 187934 | |
| 188469 | 187935 | sqlite3_free(zSql); |
| 188470 | 187936 | return rc; |
| 188471 | 187937 | } |
| 188472 | 187938 | |
| 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 | | -} |
| 188480 | | - |
| 188481 | 187939 | /* |
| 188482 | 187940 | ** This function is the implementation of both the xConnect and xCreate |
| 188483 | 187941 | ** methods of the r-tree virtual table. |
| 188484 | 187942 | ** |
| 188485 | 187943 | ** argv[0] -> module name |
| | @@ -188512,12 +187970,12 @@ |
| 188512 | 187970 | "Too many columns for an rtree table", /* 3 */ |
| 188513 | 187971 | "Auxiliary rtree columns must be last" /* 4 */ |
| 188514 | 187972 | }; |
| 188515 | 187973 | |
| 188516 | 187974 | assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */ |
| 188517 | | - if( argc<6 || argc>RTREE_MAX_AUX_COLUMN+3 ){ |
| 188518 | | - *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]); |
| 187975 | + if( argc>RTREE_MAX_AUX_COLUMN+3 ){ |
| 187976 | + *pzErr = sqlite3_mprintf("%s", aErrMsg[3]); |
| 188519 | 187977 | return SQLITE_ERROR; |
| 188520 | 187978 | } |
| 188521 | 187979 | |
| 188522 | 187980 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 188523 | 187981 | |
| | @@ -188541,22 +187999,20 @@ |
| 188541 | 187999 | /* Create/Connect to the underlying relational database schema. If |
| 188542 | 188000 | ** that is successful, call sqlite3_declare_vtab() to configure |
| 188543 | 188001 | ** the r-tree table schema. |
| 188544 | 188002 | */ |
| 188545 | 188003 | pSql = sqlite3_str_new(db); |
| 188546 | | - sqlite3_str_appendf(pSql, "CREATE TABLE x(%.*s INT", |
| 188547 | | - rtreeTokenLength(argv[3]), argv[3]); |
| 188004 | + sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]); |
| 188548 | 188005 | for(ii=4; ii<argc; ii++){ |
| 188549 | | - const char *zArg = argv[ii]; |
| 188550 | | - if( zArg[0]=='+' ){ |
| 188006 | + if( argv[ii][0]=='+' ){ |
| 188551 | 188007 | pRtree->nAux++; |
| 188552 | | - sqlite3_str_appendf(pSql, ",%.*s", rtreeTokenLength(zArg+1), zArg+1); |
| 188008 | + sqlite3_str_appendf(pSql, ",%s", argv[ii]+1); |
| 188553 | 188009 | }else if( pRtree->nAux>0 ){ |
| 188554 | 188010 | break; |
| 188555 | 188011 | }else{ |
| 188556 | 188012 | pRtree->nDim2++; |
| 188557 | | - sqlite3_str_appendf(pSql, ",%.*s NUM", rtreeTokenLength(zArg), zArg); |
| 188013 | + sqlite3_str_appendf(pSql, ",%s", argv[ii]); |
| 188558 | 188014 | } |
| 188559 | 188015 | } |
| 188560 | 188016 | sqlite3_str_appendf(pSql, ");"); |
| 188561 | 188017 | zSql = sqlite3_str_finish(pSql); |
| 188562 | 188018 | if( !zSql ){ |
| | @@ -190500,15 +189956,21 @@ |
| 190500 | 189956 | Rtree *pRtree = (Rtree *)pVtabCursor->pVtab; |
| 190501 | 189957 | RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; |
| 190502 | 189958 | RtreeNode *pRoot = 0; |
| 190503 | 189959 | int rc = SQLITE_OK; |
| 190504 | 189960 | int iCell = 0; |
| 189961 | + sqlite3_stmt *pStmt; |
| 190505 | 189962 | |
| 190506 | 189963 | rtreeReference(pRtree); |
| 190507 | 189964 | |
| 190508 | 189965 | /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ |
| 190509 | | - resetCursor(pCsr); |
| 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; |
| 190510 | 189972 | |
| 190511 | 189973 | pCsr->iStrategy = idxNum; |
| 190512 | 189974 | if( idxNum==1 ){ |
| 190513 | 189975 | /* Special case - lookup by rowid. */ |
| 190514 | 189976 | RtreeNode *pLeaf; /* Leaf on which the required cell resides */ |
| | @@ -197528,11 +196990,11 @@ |
| 197528 | 196990 | } |
| 197529 | 196991 | z += 2; |
| 197530 | 196992 | }else{ |
| 197531 | 196993 | while( *z==0 ) z++; |
| 197532 | 196994 | } |
| 197533 | | - z += (n + 8 + 2); |
| 196995 | + z += (n + 8 + 1); |
| 197534 | 196996 | return z; |
| 197535 | 196997 | } |
| 197536 | 196998 | |
| 197537 | 196999 | /* |
| 197538 | 197000 | ** Open an rbu file handle. |
| | @@ -204819,11 +204281,11 @@ |
| 204819 | 204281 | ** the callback, an SQLite error code is returned. |
| 204820 | 204282 | ** |
| 204821 | 204283 | ** |
| 204822 | 204284 | ** xSetAuxdata(pFts5, pAux, xDelete) |
| 204823 | 204285 | ** |
| 204824 | | -** Save the pointer passed as the second argument as the extension function's |
| 204286 | +** Save the pointer passed as the second argument as the extension functions |
| 204825 | 204287 | ** "auxiliary data". The pointer may then be retrieved by the current or any |
| 204826 | 204288 | ** future invocation of the same fts5 extension function made as part of |
| 204827 | 204289 | ** the same MATCH query using the xGetAuxdata() API. |
| 204828 | 204290 | ** |
| 204829 | 204291 | ** Each extension function is allocated a single auxiliary data slot for |
| | @@ -205061,12 +204523,12 @@ |
| 205061 | 204523 | ** all instances of "first place" or "1st place" regardless of which form |
| 205062 | 204524 | ** the user specified in the MATCH query text. |
| 205063 | 204525 | ** |
| 205064 | 204526 | ** There are several ways to approach this in FTS5: |
| 205065 | 204527 | ** |
| 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 |
| 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 |
| 205068 | 204530 | ** same token for inputs "first" and "1st". Say that token is in |
| 205069 | 204531 | ** fact "first", so that when the user inserts the document "I won |
| 205070 | 204532 | ** 1st place" entries are added to the index for tokens "i", "won", |
| 205071 | 204533 | ** "first" and "place". If the user then queries for '1st + place', |
| 205072 | 204534 | ** the tokenizer substitutes "first" for "1st" and the query works |
| | @@ -206223,11 +205685,10 @@ |
| 206223 | 205685 | #define sqlite3Fts5ParserCTX_PARAM |
| 206224 | 205686 | #define sqlite3Fts5ParserCTX_FETCH |
| 206225 | 205687 | #define sqlite3Fts5ParserCTX_STORE |
| 206226 | 205688 | #define fts5YYNSTATE 35 |
| 206227 | 205689 | #define fts5YYNRULE 28 |
| 206228 | | -#define fts5YYNRULE_WITH_ACTION 28 |
| 206229 | 205690 | #define fts5YYNFTS5TOKEN 16 |
| 206230 | 205691 | #define fts5YY_MAX_SHIFT 34 |
| 206231 | 205692 | #define fts5YY_MIN_SHIFTREDUCE 52 |
| 206232 | 205693 | #define fts5YY_MAX_SHIFTREDUCE 79 |
| 206233 | 205694 | #define fts5YY_ERROR_ACTION 80 |
| | @@ -207053,19 +206514,16 @@ |
| 207053 | 206514 | fts5yymsp = fts5yypParser->fts5yytos; |
| 207054 | 206515 | #ifndef NDEBUG |
| 207055 | 206516 | if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ |
| 207056 | 206517 | fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; |
| 207057 | 206518 | if( fts5yysize ){ |
| 207058 | | - fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 206519 | + fprintf(fts5yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", |
| 207059 | 206520 | fts5yyTracePrompt, |
| 207060 | | - fts5yyruleno, fts5yyRuleName[fts5yyruleno], |
| 207061 | | - fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action", |
| 207062 | | - fts5yymsp[fts5yysize].stateno); |
| 206521 | + fts5yyruleno, fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno); |
| 207063 | 206522 | }else{ |
| 207064 | | - fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s.\n", |
| 207065 | | - fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno], |
| 207066 | | - fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action"); |
| 206523 | + fprintf(fts5yyTraceFILE, "%sReduce %d [%s].\n", |
| 206524 | + fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno]); |
| 207067 | 206525 | } |
| 207068 | 206526 | } |
| 207069 | 206527 | #endif /* NDEBUG */ |
| 207070 | 206528 | |
| 207071 | 206529 | /* Check that the stack is large enough to grow by a single entry |
| | @@ -208820,11 +208278,11 @@ |
| 208820 | 208278 | |
| 208821 | 208279 | /* Set stack variable q to the close-quote character */ |
| 208822 | 208280 | assert( q=='[' || q=='\'' || q=='"' || q=='`' ); |
| 208823 | 208281 | if( q=='[' ) q = ']'; |
| 208824 | 208282 | |
| 208825 | | - while( z[iIn] ){ |
| 208283 | + while( ALWAYS(z[iIn]) ){ |
| 208826 | 208284 | if( z[iIn]==q ){ |
| 208827 | 208285 | if( z[iIn+1]!=q ){ |
| 208828 | 208286 | /* Character iIn was the close quote. */ |
| 208829 | 208287 | iIn++; |
| 208830 | 208288 | break; |
| | @@ -212149,16 +211607,14 @@ |
| 212149 | 211607 | } |
| 212150 | 211608 | azConfig[0] = 0; |
| 212151 | 211609 | azConfig[1] = "main"; |
| 212152 | 211610 | azConfig[2] = "tbl"; |
| 212153 | 211611 | for(i=3; iArg<nArg; iArg++){ |
| 212154 | | - const char *z = (const char*)sqlite3_value_text(apVal[iArg]); |
| 212155 | | - azConfig[i++] = (z ? z : ""); |
| 211612 | + azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]); |
| 212156 | 211613 | } |
| 212157 | 211614 | |
| 212158 | 211615 | zExpr = (const char*)sqlite3_value_text(apVal[0]); |
| 212159 | | - if( zExpr==0 ) zExpr = ""; |
| 212160 | 211616 | |
| 212161 | 211617 | rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr); |
| 212162 | 211618 | if( rc==SQLITE_OK ){ |
| 212163 | 211619 | rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr); |
| 212164 | 211620 | } |
| | @@ -218404,17 +217860,14 @@ |
| 218404 | 217860 | int n = 0; |
| 218405 | 217861 | int i; |
| 218406 | 217862 | for(i=0; i<nChar; i++){ |
| 218407 | 217863 | if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */ |
| 218408 | 217864 | if( (unsigned char)p[n++]>=0xc0 ){ |
| 218409 | | - if( n>=nByte ) return 0; |
| 217865 | + if( n>=nByte ) break; |
| 218410 | 217866 | while( (p[n] & 0xc0)==0x80 ){ |
| 218411 | 217867 | n++; |
| 218412 | | - if( n>=nByte ){ |
| 218413 | | - if( i+1==nChar ) break; |
| 218414 | | - return 0; |
| 218415 | | - } |
| 217868 | + if( n>=nByte ) break; |
| 218416 | 217869 | } |
| 218417 | 217870 | } |
| 218418 | 217871 | } |
| 218419 | 217872 | return n; |
| 218420 | 217873 | } |
| | @@ -218812,41 +218265,10 @@ |
| 218812 | 218265 | |
| 218813 | 218266 | *pCksum = cksum; |
| 218814 | 218267 | return rc; |
| 218815 | 218268 | } |
| 218816 | 218269 | |
| 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 | | -} |
| 218848 | 218270 | |
| 218849 | 218271 | /* |
| 218850 | 218272 | ** This function is also purely an internal test. It does not contribute to |
| 218851 | 218273 | ** FTS functionality, or even the integrity-check, in any way. |
| 218852 | 218274 | */ |
| | @@ -218883,18 +218305,12 @@ |
| 218883 | 218305 | ** the index is disabled are the same. In both ASC and DESC order. |
| 218884 | 218306 | ** |
| 218885 | 218307 | ** This check may only be performed if the hash table is empty. This |
| 218886 | 218308 | ** is because the hash table only supports a single scan query at |
| 218887 | 218309 | ** a time, and the multi-iter loop from which this function is called |
| 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) ){ |
| 218310 | + ** is already performing such a scan. */ |
| 218311 | + if( p->nPendingData==0 ){ |
| 218896 | 218312 | if( iIdx>0 && rc==SQLITE_OK ){ |
| 218897 | 218313 | int f = flags|FTS5INDEX_QUERY_TEST_NOIDX; |
| 218898 | 218314 | ck2 = 0; |
| 218899 | 218315 | rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2); |
| 218900 | 218316 | if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT; |
| | @@ -219023,12 +218439,12 @@ |
| 219023 | 218439 | /* Iterate through the b-tree hierarchy. */ |
| 219024 | 218440 | while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 219025 | 218441 | i64 iRow; /* Rowid for this leaf */ |
| 219026 | 218442 | Fts5Data *pLeaf; /* Data for this leaf */ |
| 219027 | 218443 | |
| 219028 | | - const char *zIdxTerm = (const char*)sqlite3_column_blob(pStmt, 1); |
| 219029 | 218444 | int nIdxTerm = sqlite3_column_bytes(pStmt, 1); |
| 218445 | + const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1); |
| 219030 | 218446 | int iIdxLeaf = sqlite3_column_int(pStmt, 2); |
| 219031 | 218447 | int bIdxDlidx = sqlite3_column_int(pStmt, 3); |
| 219032 | 218448 | |
| 219033 | 218449 | /* If the leaf in question has already been trimmed from the segment, |
| 219034 | 218450 | ** ignore this b-tree entry. Otherwise, load it into memory. */ |
| | @@ -220611,28 +220027,19 @@ |
| 220611 | 220027 | case FTS5_PLAN_SORTED_MATCH: { |
| 220612 | 220028 | rc = fts5SorterNext(pCsr); |
| 220613 | 220029 | break; |
| 220614 | 220030 | } |
| 220615 | 220031 | |
| 220616 | | - default: { |
| 220617 | | - Fts5Config *pConfig = ((Fts5Table*)pCursor->pVtab)->pConfig; |
| 220618 | | - pConfig->bLock++; |
| 220032 | + default: |
| 220619 | 220033 | rc = sqlite3_step(pCsr->pStmt); |
| 220620 | | - pConfig->bLock--; |
| 220621 | 220034 | if( rc!=SQLITE_ROW ){ |
| 220622 | 220035 | CsrFlagSet(pCsr, FTS5CSR_EOF); |
| 220623 | 220036 | rc = sqlite3_reset(pCsr->pStmt); |
| 220624 | | - if( rc!=SQLITE_OK ){ |
| 220625 | | - pCursor->pVtab->zErrMsg = sqlite3_mprintf( |
| 220626 | | - "%s", sqlite3_errmsg(pConfig->db) |
| 220627 | | - ); |
| 220628 | | - } |
| 220629 | 220037 | }else{ |
| 220630 | 220038 | rc = SQLITE_OK; |
| 220631 | 220039 | } |
| 220632 | 220040 | break; |
| 220633 | | - } |
| 220634 | 220041 | } |
| 220635 | 220042 | } |
| 220636 | 220043 | |
| 220637 | 220044 | return rc; |
| 220638 | 220045 | } |
| | @@ -220913,17 +220320,10 @@ |
| 220913 | 220320 | char **pzErrmsg = pConfig->pzErrmsg; |
| 220914 | 220321 | int i; |
| 220915 | 220322 | int iIdxStr = 0; |
| 220916 | 220323 | Fts5Expr *pExpr = 0; |
| 220917 | 220324 | |
| 220918 | | - if( pConfig->bLock ){ |
| 220919 | | - pTab->p.base.zErrMsg = sqlite3_mprintf( |
| 220920 | | - "recursively defined fts5 content table" |
| 220921 | | - ); |
| 220922 | | - return SQLITE_ERROR; |
| 220923 | | - } |
| 220924 | | - |
| 220925 | 220325 | if( pCsr->ePlan ){ |
| 220926 | 220326 | fts5FreeCursorComponents(pCsr); |
| 220927 | 220327 | memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr)); |
| 220928 | 220328 | } |
| 220929 | 220329 | |
| | @@ -221140,28 +220540,21 @@ |
| 221140 | 220540 | assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 ); |
| 221141 | 220541 | assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ); |
| 221142 | 220542 | } |
| 221143 | 220543 | |
| 221144 | 220544 | if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){ |
| 221145 | | - Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); |
| 221146 | 220545 | assert( pCsr->pExpr ); |
| 221147 | 220546 | sqlite3_reset(pCsr->pStmt); |
| 221148 | 220547 | sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr)); |
| 221149 | | - pTab->pConfig->bLock++; |
| 221150 | 220548 | rc = sqlite3_step(pCsr->pStmt); |
| 221151 | | - pTab->pConfig->bLock--; |
| 221152 | 220549 | if( rc==SQLITE_ROW ){ |
| 221153 | 220550 | rc = SQLITE_OK; |
| 221154 | 220551 | CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT); |
| 221155 | 220552 | }else{ |
| 221156 | 220553 | rc = sqlite3_reset(pCsr->pStmt); |
| 221157 | 220554 | if( rc==SQLITE_OK ){ |
| 221158 | 220555 | rc = FTS5_CORRUPT; |
| 221159 | | - }else if( pTab->pConfig->pzErrmsg ){ |
| 221160 | | - *pTab->pConfig->pzErrmsg = sqlite3_mprintf( |
| 221161 | | - "%s", sqlite3_errmsg(pTab->pConfig->db) |
| 221162 | | - ); |
| 221163 | 220556 | } |
| 221164 | 220557 | } |
| 221165 | 220558 | } |
| 221166 | 220559 | return rc; |
| 221167 | 220560 | } |
| | @@ -222173,16 +221566,14 @@ |
| 222173 | 221566 | if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){ |
| 222174 | 221567 | fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg); |
| 222175 | 221568 | } |
| 222176 | 221569 | } |
| 222177 | 221570 | }else if( !fts5IsContentless(pTab) ){ |
| 222178 | | - pConfig->pzErrmsg = &pTab->p.base.zErrMsg; |
| 222179 | 221571 | rc = fts5SeekCursor(pCsr, 1); |
| 222180 | 221572 | if( rc==SQLITE_OK ){ |
| 222181 | 221573 | sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); |
| 222182 | 221574 | } |
| 222183 | | - pConfig->pzErrmsg = 0; |
| 222184 | 221575 | } |
| 222185 | 221576 | return rc; |
| 222186 | 221577 | } |
| 222187 | 221578 | |
| 222188 | 221579 | |
| | @@ -222455,11 +221846,11 @@ |
| 222455 | 221846 | int nArg, /* Number of args */ |
| 222456 | 221847 | sqlite3_value **apUnused /* Function arguments */ |
| 222457 | 221848 | ){ |
| 222458 | 221849 | assert( nArg==0 ); |
| 222459 | 221850 | UNUSED_PARAM2(nArg, apUnused); |
| 222460 | | - sqlite3_result_text(pCtx, "fts5: 2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3", -1, SQLITE_TRANSIENT); |
| 221851 | + sqlite3_result_text(pCtx, "fts5: 2019-11-20 12:07:40 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8", -1, SQLITE_TRANSIENT); |
| 222461 | 221852 | } |
| 222462 | 221853 | |
| 222463 | 221854 | /* |
| 222464 | 221855 | ** Return true if zName is the extension on one of the shadow tables used |
| 222465 | 221856 | ** by this module. |
| | @@ -223202,15 +222593,14 @@ |
| 223202 | 222593 | sqlite3Fts5BufferZero(&buf); |
| 223203 | 222594 | rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid); |
| 223204 | 222595 | for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){ |
| 223205 | 222596 | ctx.szCol = 0; |
| 223206 | 222597 | 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); |
| 223209 | 222598 | rc = sqlite3Fts5Tokenize(pConfig, |
| 223210 | 222599 | FTS5_TOKENIZE_DOCUMENT, |
| 223211 | | - zText, nText, |
| 222600 | + (const char*)sqlite3_column_text(pScan, ctx.iCol+1), |
| 222601 | + sqlite3_column_bytes(pScan, ctx.iCol+1), |
| 223212 | 222602 | (void*)&ctx, |
| 223213 | 222603 | fts5StorageInsertCallback |
| 223214 | 222604 | ); |
| 223215 | 222605 | } |
| 223216 | 222606 | sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol); |
| | @@ -223328,15 +222718,14 @@ |
| 223328 | 222718 | rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid); |
| 223329 | 222719 | } |
| 223330 | 222720 | for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){ |
| 223331 | 222721 | ctx.szCol = 0; |
| 223332 | 222722 | 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]); |
| 223335 | 222723 | rc = sqlite3Fts5Tokenize(pConfig, |
| 223336 | 222724 | FTS5_TOKENIZE_DOCUMENT, |
| 223337 | | - zText, nText, |
| 222725 | + (const char*)sqlite3_value_text(apVal[ctx.iCol+2]), |
| 222726 | + sqlite3_value_bytes(apVal[ctx.iCol+2]), |
| 223338 | 222727 | (void*)&ctx, |
| 223339 | 222728 | fts5StorageInsertCallback |
| 223340 | 222729 | ); |
| 223341 | 222730 | } |
| 223342 | 222731 | sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol); |
| | @@ -223501,15 +222890,14 @@ |
| 223501 | 222890 | ctx.szCol = 0; |
| 223502 | 222891 | if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ |
| 223503 | 222892 | rc = sqlite3Fts5TermsetNew(&ctx.pTermset); |
| 223504 | 222893 | } |
| 223505 | 222894 | 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); |
| 223508 | 222895 | rc = sqlite3Fts5Tokenize(pConfig, |
| 223509 | 222896 | FTS5_TOKENIZE_DOCUMENT, |
| 223510 | | - zText, nText, |
| 222897 | + (const char*)sqlite3_column_text(pScan, i+1), |
| 222898 | + sqlite3_column_bytes(pScan, i+1), |
| 223511 | 222899 | (void*)&ctx, |
| 223512 | 222900 | fts5StorageIntegrityCallback |
| 223513 | 222901 | ); |
| 223514 | 222902 | } |
| 223515 | 222903 | if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ |
| | @@ -227228,12 +226616,12 @@ |
| 227228 | 226616 | } |
| 227229 | 226617 | #endif /* SQLITE_CORE */ |
| 227230 | 226618 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 227231 | 226619 | |
| 227232 | 226620 | /************** End of stmt.c ************************************************/ |
| 227233 | | -#if __LINE__!=227233 |
| 226621 | +#if __LINE__!=226621 |
| 227234 | 226622 | #undef SQLITE_SOURCE_ID |
| 227235 | | -#define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1befalt2" |
| 226623 | +#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9alt2" |
| 227236 | 226624 | #endif |
| 227237 | 226625 | /* Return the source-id for this library */ |
| 227238 | 226626 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 227239 | 226627 | /************************** End of sqlite3.c ******************************/ |
| 227240 | 226628 | |