| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.30.0. By combining all the individual C code files into this |
| 3 | +** version 3.31.1. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -1163,13 +1163,13 @@ |
| 1163 | 1163 | ** |
| 1164 | 1164 | ** See also: [sqlite3_libversion()], |
| 1165 | 1165 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1166 | 1166 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1167 | 1167 | */ |
| 1168 | | -#define SQLITE_VERSION "3.30.0" |
| 1169 | | -#define SQLITE_VERSION_NUMBER 3030000 |
| 1170 | | -#define SQLITE_SOURCE_ID "2019-10-04 15:03:17 c20a35336432025445f9f7e289d0cc3e4003fb17f45a4ce74c6269c407c6e09f" |
| 1168 | +#define SQLITE_VERSION "3.31.1" |
| 1169 | +#define SQLITE_VERSION_NUMBER 3031001 |
| 1170 | +#define SQLITE_SOURCE_ID "2020-01-28 15:02:23 04885763c4cd00cbca26d048f2b19316bfc93e8edebeceaa171ebfc6c563d53e" |
| 1171 | 1171 | |
| 1172 | 1172 | /* |
| 1173 | 1173 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1174 | 1174 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1175 | 1175 | ** |
| | @@ -1556,10 +1556,11 @@ |
| 1556 | 1556 | #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) |
| 1557 | 1557 | #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) |
| 1558 | 1558 | #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) |
| 1559 | 1559 | #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) |
| 1560 | 1560 | #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */ |
| 1561 | +#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8)) |
| 1561 | 1562 | #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) |
| 1562 | 1563 | #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8)) |
| 1563 | 1564 | #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) |
| 1564 | 1565 | #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) |
| 1565 | 1566 | #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) |
| | @@ -1575,15 +1576,17 @@ |
| 1575 | 1576 | #define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) |
| 1576 | 1577 | #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) |
| 1577 | 1578 | #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) |
| 1578 | 1579 | #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) |
| 1579 | 1580 | #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) |
| 1581 | +#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) |
| 1580 | 1582 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) |
| 1581 | 1583 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) |
| 1582 | 1584 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) |
| 1583 | 1585 | #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) |
| 1584 | 1586 | #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) |
| 1587 | +#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) |
| 1585 | 1588 | |
| 1586 | 1589 | /* |
| 1587 | 1590 | ** CAPI3REF: Flags For File Open Operations |
| 1588 | 1591 | ** |
| 1589 | 1592 | ** These bit values are intended for use in the |
| | @@ -1608,10 +1611,11 @@ |
| 1608 | 1611 | #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ |
| 1609 | 1612 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 1610 | 1613 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 1611 | 1614 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 1612 | 1615 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 1616 | +#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 1613 | 1617 | |
| 1614 | 1618 | /* Reserved: 0x00F00000 */ |
| 1615 | 1619 | |
| 1616 | 1620 | /* |
| 1617 | 1621 | ** CAPI3REF: Device Characteristics |
| | @@ -2019,20 +2023,20 @@ |
| 2019 | 2023 | ** |
| 2020 | 2024 | ** <li>[[SQLITE_FCNTL_BUSYHANDLER]] |
| 2021 | 2025 | ** ^The [SQLITE_FCNTL_BUSYHANDLER] |
| 2022 | 2026 | ** file-control may be invoked by SQLite on the database file handle |
| 2023 | 2027 | ** shortly after it is opened in order to provide a custom VFS with access |
| 2024 | | -** to the connections busy-handler callback. The argument is of type (void **) |
| 2028 | +** to the connection's busy-handler callback. The argument is of type (void**) |
| 2025 | 2029 | ** - an array of two (void *) values. The first (void *) actually points |
| 2026 | | -** to a function of type (int (*)(void *)). In order to invoke the connections |
| 2030 | +** to a function of type (int (*)(void *)). In order to invoke the connection's |
| 2027 | 2031 | ** busy-handler, this function should be invoked with the second (void *) in |
| 2028 | 2032 | ** the array as the only argument. If it returns non-zero, then the operation |
| 2029 | 2033 | ** should be retried. If it returns zero, the custom VFS should abandon the |
| 2030 | 2034 | ** current operation. |
| 2031 | 2035 | ** |
| 2032 | 2036 | ** <li>[[SQLITE_FCNTL_TEMPFILENAME]] |
| 2033 | | -** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
| 2037 | +** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
| 2034 | 2038 | ** to have SQLite generate a |
| 2035 | 2039 | ** temporary filename using the same algorithm that is followed to generate |
| 2036 | 2040 | ** temporary filenames for TEMP tables and other internal uses. The |
| 2037 | 2041 | ** argument should be a char** which will be filled with the filename |
| 2038 | 2042 | ** written into memory obtained from [sqlite3_malloc()]. The caller should |
| | @@ -2141,16 +2145,22 @@ |
| 2141 | 2145 | ** interface can be used to find if any database on the connection has changed, |
| 2142 | 2146 | ** but that interface responds to changes on TEMP as well as MAIN and does |
| 2143 | 2147 | ** not provide a mechanism to detect changes to MAIN only. Also, the |
| 2144 | 2148 | ** [sqlite3_total_changes()] interface responds to internal changes only and |
| 2145 | 2149 | ** omits changes made by other database connections. The |
| 2146 | | -** [PRAGMA data_version] command provide a mechanism to detect changes to |
| 2150 | +** [PRAGMA data_version] command provides a mechanism to detect changes to |
| 2147 | 2151 | ** a single attached database that occur due to other database connections, |
| 2148 | 2152 | ** but omits changes implemented by the database connection on which it is |
| 2149 | 2153 | ** called. This file control is the only mechanism to detect changes that |
| 2150 | 2154 | ** happen either internally or externally and that are associated with |
| 2151 | 2155 | ** a particular attached database. |
| 2156 | +** |
| 2157 | +** <li>[[SQLITE_FCNTL_CKPT_DONE]] |
| 2158 | +** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint |
| 2159 | +** in wal mode after the client has finished copying pages from the wal |
| 2160 | +** file to the database file, but before the *-shm file is updated to |
| 2161 | +** record the fact that the pages have been checkpointed. |
| 2152 | 2162 | ** </ul> |
| 2153 | 2163 | */ |
| 2154 | 2164 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 2155 | 2165 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| 2156 | 2166 | #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 |
| | @@ -2184,10 +2194,11 @@ |
| 2184 | 2194 | #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 |
| 2185 | 2195 | #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 |
| 2186 | 2196 | #define SQLITE_FCNTL_LOCK_TIMEOUT 34 |
| 2187 | 2197 | #define SQLITE_FCNTL_DATA_VERSION 35 |
| 2188 | 2198 | #define SQLITE_FCNTL_SIZE_LIMIT 36 |
| 2199 | +#define SQLITE_FCNTL_CKPT_DONE 37 |
| 2189 | 2200 | |
| 2190 | 2201 | /* deprecated names */ |
| 2191 | 2202 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| 2192 | 2203 | #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE |
| 2193 | 2204 | #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| | @@ -2229,14 +2240,14 @@ |
| 2229 | 2240 | ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 |
| 2230 | 2241 | ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased |
| 2231 | 2242 | ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields |
| 2232 | 2243 | ** may be appended to the sqlite3_vfs object and the iVersion value |
| 2233 | 2244 | ** may increase again in future versions of SQLite. |
| 2234 | | -** Note that the structure |
| 2235 | | -** of the sqlite3_vfs object changes in the transition from |
| 2245 | +** Note that due to an oversight, the structure |
| 2246 | +** of the sqlite3_vfs object changed in the transition from |
| 2236 | 2247 | ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] |
| 2237 | | -** and yet the iVersion field was not modified. |
| 2248 | +** and yet the iVersion field was not increased. |
| 2238 | 2249 | ** |
| 2239 | 2250 | ** The szOsFile field is the size of the subclassed [sqlite3_file] |
| 2240 | 2251 | ** structure used by this VFS. mxPathname is the maximum length of |
| 2241 | 2252 | ** a pathname in this VFS. |
| 2242 | 2253 | ** |
| | @@ -2323,11 +2334,11 @@ |
| 2323 | 2334 | ** be created, and that it is an error if it already exists. |
| 2324 | 2335 | ** It is <i>not</i> used to indicate the file should be opened |
| 2325 | 2336 | ** for exclusive access. |
| 2326 | 2337 | ** |
| 2327 | 2338 | ** ^At least szOsFile bytes of memory are allocated by SQLite |
| 2328 | | -** to hold the [sqlite3_file] structure passed as the third |
| 2339 | +** to hold the [sqlite3_file] structure passed as the third |
| 2329 | 2340 | ** argument to xOpen. The xOpen method does not have to |
| 2330 | 2341 | ** allocate the structure; it should just fill it in. Note that |
| 2331 | 2342 | ** the xOpen method must set the sqlite3_file.pMethods to either |
| 2332 | 2343 | ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do |
| 2333 | 2344 | ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods |
| | @@ -2660,11 +2671,11 @@ |
| 2660 | 2671 | ** Every memory allocation request coming in through [sqlite3_malloc()] |
| 2661 | 2672 | ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, |
| 2662 | 2673 | ** that causes the corresponding memory allocation to fail. |
| 2663 | 2674 | ** |
| 2664 | 2675 | ** The xInit method initializes the memory allocator. For example, |
| 2665 | | -** it might allocate any require mutexes or initialize internal data |
| 2676 | +** it might allocate any required mutexes or initialize internal data |
| 2666 | 2677 | ** structures. The xShutdown method is invoked (indirectly) by |
| 2667 | 2678 | ** [sqlite3_shutdown()] and should deallocate any resources acquired |
| 2668 | 2679 | ** by xInit. The pAppData pointer is used as the only parameter to |
| 2669 | 2680 | ** xInit and xShutdown. |
| 2670 | 2681 | ** |
| | @@ -2782,10 +2793,11 @@ |
| 2782 | 2793 | ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, |
| 2783 | 2794 | ** interpreted as a boolean, which enables or disables the collection of |
| 2784 | 2795 | ** memory allocation statistics. ^(When memory allocation statistics are |
| 2785 | 2796 | ** disabled, the following SQLite interfaces become non-operational: |
| 2786 | 2797 | ** <ul> |
| 2798 | +** <li> [sqlite3_hard_heap_limit64()] |
| 2787 | 2799 | ** <li> [sqlite3_memory_used()] |
| 2788 | 2800 | ** <li> [sqlite3_memory_highwater()] |
| 2789 | 2801 | ** <li> [sqlite3_soft_heap_limit64()] |
| 2790 | 2802 | ** <li> [sqlite3_status64()] |
| 2791 | 2803 | ** </ul>)^ |
| | @@ -2800,11 +2812,11 @@ |
| 2800 | 2812 | ** |
| 2801 | 2813 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 2802 | 2814 | ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool |
| 2803 | 2815 | ** that SQLite can use for the database page cache with the default page |
| 2804 | 2816 | ** cache implementation. |
| 2805 | | -** This configuration option is a no-op if an application-define page |
| 2817 | +** This configuration option is a no-op if an application-defined page |
| 2806 | 2818 | ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]. |
| 2807 | 2819 | ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to |
| 2808 | 2820 | ** 8-byte aligned memory (pMem), the size of each page cache line (sz), |
| 2809 | 2821 | ** and the number of cache lines (N). |
| 2810 | 2822 | ** The sz argument should be the size of the largest database page |
| | @@ -3285,11 +3297,11 @@ |
| 3285 | 3297 | ** </dd> |
| 3286 | 3298 | ** |
| 3287 | 3299 | ** [[SQLITE_DBCONFIG_DQS_DML]] |
| 3288 | 3300 | ** <dt>SQLITE_DBCONFIG_DQS_DML</td> |
| 3289 | 3301 | ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates |
| 3290 | | -** the legacy [double-quoted string literal] misfeature for DML statement |
| 3302 | +** the legacy [double-quoted string literal] misfeature for DML statements |
| 3291 | 3303 | ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The |
| 3292 | 3304 | ** default value of this setting is determined by the [-DSQLITE_DQS] |
| 3293 | 3305 | ** compile-time option. |
| 3294 | 3306 | ** </dd> |
| 3295 | 3307 | ** |
| | @@ -3299,10 +3311,53 @@ |
| 3299 | 3311 | ** the legacy [double-quoted string literal] misfeature for DDL statements, |
| 3300 | 3312 | ** such as CREATE TABLE and CREATE INDEX. The |
| 3301 | 3313 | ** default value of this setting is determined by the [-DSQLITE_DQS] |
| 3302 | 3314 | ** compile-time option. |
| 3303 | 3315 | ** </dd> |
| 3316 | +** |
| 3317 | +** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]] |
| 3318 | +** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</td> |
| 3319 | +** <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to |
| 3320 | +** assume that database schemas (the contents of the [sqlite_master] tables) |
| 3321 | +** are untainted by malicious content. |
| 3322 | +** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite |
| 3323 | +** takes additional defensive steps to protect the application from harm |
| 3324 | +** including: |
| 3325 | +** <ul> |
| 3326 | +** <li> Prohibit the use of SQL functions inside triggers, views, |
| 3327 | +** CHECK constraints, DEFAULT clauses, expression indexes, |
| 3328 | +** partial indexes, or generated columns |
| 3329 | +** unless those functions are tagged with [SQLITE_INNOCUOUS]. |
| 3330 | +** <li> Prohibit the use of virtual tables inside of triggers or views |
| 3331 | +** unless those virtual tables are tagged with [SQLITE_VTAB_INNOCUOUS]. |
| 3332 | +** </ul> |
| 3333 | +** This setting defaults to "on" for legacy compatibility, however |
| 3334 | +** all applications are advised to turn it off if possible. This setting |
| 3335 | +** can also be controlled using the [PRAGMA trusted_schema] statement. |
| 3336 | +** </dd> |
| 3337 | +** |
| 3338 | +** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] |
| 3339 | +** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td> |
| 3340 | +** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates |
| 3341 | +** the legacy file format flag. When activated, this flag causes all newly |
| 3342 | +** created database file to have a schema format version number (the 4-byte |
| 3343 | +** integer found at offset 44 into the database header) of 1. This in turn |
| 3344 | +** means that the resulting database file will be readable and writable by |
| 3345 | +** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, |
| 3346 | +** newly created databases are generally not understandable by SQLite versions |
| 3347 | +** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there |
| 3348 | +** is now scarcely any need to generated database files that are compatible |
| 3349 | +** all the way back to version 3.0.0, and so this setting is of little |
| 3350 | +** practical use, but is provided so that SQLite can continue to claim the |
| 3351 | +** ability to generate new database files that are compatible with version |
| 3352 | +** 3.0.0. |
| 3353 | +** <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on, |
| 3354 | +** the [VACUUM] command will fail with an obscure error when attempting to |
| 3355 | +** process a table with generated columns and a descending index. This is |
| 3356 | +** not considered a bug since SQLite versions 3.3.0 and earlier do not support |
| 3357 | +** either generated columns or decending indexes. |
| 3358 | +** </dd> |
| 3304 | 3359 | ** </dl> |
| 3305 | 3360 | */ |
| 3306 | 3361 | #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ |
| 3307 | 3362 | #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ |
| 3308 | 3363 | #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ |
| | @@ -3317,11 +3372,13 @@ |
| 3317 | 3372 | #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */ |
| 3318 | 3373 | #define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 /* int int* */ |
| 3319 | 3374 | #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */ |
| 3320 | 3375 | #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */ |
| 3321 | 3376 | #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */ |
| 3322 | | -#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */ |
| 3377 | +#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */ |
| 3378 | +#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ |
| 3379 | +#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */ |
| 3323 | 3380 | |
| 3324 | 3381 | /* |
| 3325 | 3382 | ** CAPI3REF: Enable Or Disable Extended Result Codes |
| 3326 | 3383 | ** METHOD: sqlite3 |
| 3327 | 3384 | ** |
| | @@ -3523,11 +3580,11 @@ |
| 3523 | 3580 | ** will be rolled back automatically. |
| 3524 | 3581 | ** |
| 3525 | 3582 | ** ^The sqlite3_interrupt(D) call is in effect until all currently running |
| 3526 | 3583 | ** SQL statements on [database connection] D complete. ^Any new SQL statements |
| 3527 | 3584 | ** that are started after the sqlite3_interrupt() call and before the |
| 3528 | | -** running statements reaches zero are interrupted as if they had been |
| 3585 | +** running statement count reaches zero are interrupted as if they had been |
| 3529 | 3586 | ** running prior to the sqlite3_interrupt() call. ^New SQL statements |
| 3530 | 3587 | ** that are started after the running statement count reaches zero are |
| 3531 | 3588 | ** not effected by the sqlite3_interrupt(). |
| 3532 | 3589 | ** ^A call to sqlite3_interrupt(D) that occurs when there are no running |
| 3533 | 3590 | ** SQL statements is a no-op and has no effect on SQL statements |
| | @@ -3691,13 +3748,13 @@ |
| 3691 | 3748 | ** Alice | 43 |
| 3692 | 3749 | ** Bob | 28 |
| 3693 | 3750 | ** Cindy | 21 |
| 3694 | 3751 | ** </pre></blockquote> |
| 3695 | 3752 | ** |
| 3696 | | -** There are two column (M==2) and three rows (N==3). Thus the |
| 3753 | +** There are two columns (M==2) and three rows (N==3). Thus the |
| 3697 | 3754 | ** result table has 8 entries. Suppose the result table is stored |
| 3698 | | -** in an array names azResult. Then azResult holds this content: |
| 3755 | +** in an array named azResult. Then azResult holds this content: |
| 3699 | 3756 | ** |
| 3700 | 3757 | ** <blockquote><pre> |
| 3701 | 3758 | ** azResult[0] = "Name"; |
| 3702 | 3759 | ** azResult[1] = "Age"; |
| 3703 | 3760 | ** azResult[2] = "Alice"; |
| | @@ -3786,11 +3843,11 @@ |
| 3786 | 3843 | /* |
| 3787 | 3844 | ** CAPI3REF: Memory Allocation Subsystem |
| 3788 | 3845 | ** |
| 3789 | 3846 | ** The SQLite core uses these three routines for all of its own |
| 3790 | 3847 | ** internal memory allocation needs. "Core" in the previous sentence |
| 3791 | | -** does not include operating-system specific VFS implementation. The |
| 3848 | +** does not include operating-system specific [VFS] implementation. The |
| 3792 | 3849 | ** Windows VFS uses native malloc() and free() for some operations. |
| 3793 | 3850 | ** |
| 3794 | 3851 | ** ^The sqlite3_malloc() routine returns a pointer to a block |
| 3795 | 3852 | ** of memory at least N bytes in length, where N is the parameter. |
| 3796 | 3853 | ** ^If sqlite3_malloc() is unable to obtain sufficient free |
| | @@ -3847,23 +3904,10 @@ |
| 3847 | 3904 | ** sqlite3_malloc64(), and sqlite3_realloc64() |
| 3848 | 3905 | ** is always aligned to at least an 8 byte boundary, or to a |
| 3849 | 3906 | ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time |
| 3850 | 3907 | ** option is used. |
| 3851 | 3908 | ** |
| 3852 | | -** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
| 3853 | | -** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in |
| 3854 | | -** implementation of these routines to be omitted. That capability |
| 3855 | | -** is no longer provided. Only built-in memory allocators can be used. |
| 3856 | | -** |
| 3857 | | -** Prior to SQLite version 3.7.10, the Windows OS interface layer called |
| 3858 | | -** the system malloc() and free() directly when converting |
| 3859 | | -** filenames between the UTF-8 encoding used by SQLite |
| 3860 | | -** and whatever filename encoding is used by the particular Windows |
| 3861 | | -** installation. Memory allocation errors were detected, but |
| 3862 | | -** they were reported back as [SQLITE_CANTOPEN] or |
| 3863 | | -** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. |
| 3864 | | -** |
| 3865 | 3909 | ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
| 3866 | 3910 | ** must be either NULL or else pointers obtained from a prior |
| 3867 | 3911 | ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have |
| 3868 | 3912 | ** not yet been released. |
| 3869 | 3913 | ** |
| | @@ -3908,11 +3952,11 @@ |
| 3908 | 3952 | ** CAPI3REF: Pseudo-Random Number Generator |
| 3909 | 3953 | ** |
| 3910 | 3954 | ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
| 3911 | 3955 | ** select random [ROWID | ROWIDs] when inserting new records into a table that |
| 3912 | 3956 | ** already uses the largest possible [ROWID]. The PRNG is also used for |
| 3913 | | -** the build-in random() and randomblob() SQL functions. This interface allows |
| 3957 | +** the built-in random() and randomblob() SQL functions. This interface allows |
| 3914 | 3958 | ** applications to access the same PRNG for other purposes. |
| 3915 | 3959 | ** |
| 3916 | 3960 | ** ^A call to this routine stores N bytes of randomness into buffer P. |
| 3917 | 3961 | ** ^The P parameter can be a NULL pointer. |
| 3918 | 3962 | ** |
| | @@ -4282,14 +4326,12 @@ |
| 4282 | 4326 | ** passing it to [sqlite3_close()] when it is no longer required. |
| 4283 | 4327 | ** |
| 4284 | 4328 | ** The sqlite3_open_v2() interface works like sqlite3_open() |
| 4285 | 4329 | ** except that it accepts two additional parameters for additional control |
| 4286 | 4330 | ** over the new database connection. ^(The flags parameter to |
| 4287 | | -** sqlite3_open_v2() can take one of |
| 4288 | | -** the following three values, optionally combined with the |
| 4289 | | -** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], |
| 4290 | | -** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ |
| 4331 | +** sqlite3_open_v2() must include, at a minimum, one of the following |
| 4332 | +** three flag combinations:)^ |
| 4291 | 4333 | ** |
| 4292 | 4334 | ** <dl> |
| 4293 | 4335 | ** ^(<dt>[SQLITE_OPEN_READONLY]</dt> |
| 4294 | 4336 | ** <dd>The database is opened in read-only mode. If the database does not |
| 4295 | 4337 | ** already exist, an error is returned.</dd>)^ |
| | @@ -4302,28 +4344,56 @@ |
| 4302 | 4344 | ** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> |
| 4303 | 4345 | ** <dd>The database is opened for reading and writing, and is created if |
| 4304 | 4346 | ** it does not already exist. This is the behavior that is always used for |
| 4305 | 4347 | ** sqlite3_open() and sqlite3_open16().</dd>)^ |
| 4306 | 4348 | ** </dl> |
| 4349 | +** |
| 4350 | +** In addition to the required flags, the following optional flags are |
| 4351 | +** also supported: |
| 4352 | +** |
| 4353 | +** <dl> |
| 4354 | +** ^(<dt>[SQLITE_OPEN_URI]</dt> |
| 4355 | +** <dd>The filename can be interpreted as a URI if this flag is set.</dd>)^ |
| 4356 | +** |
| 4357 | +** ^(<dt>[SQLITE_OPEN_MEMORY]</dt> |
| 4358 | +** <dd>The database will be opened as an in-memory database. The database |
| 4359 | +** is named by the "filename" argument for the purposes of cache-sharing, |
| 4360 | +** if shared cache mode is enabled, but the "filename" is otherwise ignored. |
| 4361 | +** </dd>)^ |
| 4362 | +** |
| 4363 | +** ^(<dt>[SQLITE_OPEN_NOMUTEX]</dt> |
| 4364 | +** <dd>The new database connection will use the "multi-thread" |
| 4365 | +** [threading mode].)^ This means that separate threads are allowed |
| 4366 | +** to use SQLite at the same time, as long as each thread is using |
| 4367 | +** a different [database connection]. |
| 4368 | +** |
| 4369 | +** ^(<dt>[SQLITE_OPEN_FULLMUTEX]</dt> |
| 4370 | +** <dd>The new database connection will use the "serialized" |
| 4371 | +** [threading mode].)^ This means the multiple threads can safely |
| 4372 | +** attempt to use the same database connection at the same time. |
| 4373 | +** (Mutexes will block any actual concurrency, but in this mode |
| 4374 | +** there is no harm in trying.) |
| 4375 | +** |
| 4376 | +** ^(<dt>[SQLITE_OPEN_SHAREDCACHE]</dt> |
| 4377 | +** <dd>The database is opened [shared cache] enabled, overriding |
| 4378 | +** the default shared cache setting provided by |
| 4379 | +** [sqlite3_enable_shared_cache()].)^ |
| 4380 | +** |
| 4381 | +** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 4382 | +** <dd>The database is opened [shared cache] disabled, overriding |
| 4383 | +** the default shared cache setting provided by |
| 4384 | +** [sqlite3_enable_shared_cache()].)^ |
| 4385 | +** |
| 4386 | +** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 4387 | +** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 4388 | +** </dl>)^ |
| 4307 | 4389 | ** |
| 4308 | 4390 | ** If the 3rd parameter to sqlite3_open_v2() is not one of the |
| 4309 | | -** combinations shown above optionally combined with other |
| 4391 | +** required combinations shown above optionally combined with other |
| 4310 | 4392 | ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] |
| 4311 | 4393 | ** then the behavior is undefined. |
| 4312 | 4394 | ** |
| 4313 | | -** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection |
| 4314 | | -** opens in the multi-thread [threading mode] as long as the single-thread |
| 4315 | | -** mode has not been set at compile-time or start-time. ^If the |
| 4316 | | -** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens |
| 4317 | | -** in the serialized [threading mode] unless single-thread was |
| 4318 | | -** previously selected at compile-time or start-time. |
| 4319 | | -** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be |
| 4320 | | -** eligible to use [shared cache mode], regardless of whether or not shared |
| 4321 | | -** cache is enabled using [sqlite3_enable_shared_cache()]. ^The |
| 4322 | | -** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not |
| 4323 | | -** participate in [shared cache mode] even if it is enabled. |
| 4324 | | -** |
| 4325 | 4395 | ** ^The fourth parameter to sqlite3_open_v2() is the name of the |
| 4326 | 4396 | ** [sqlite3_vfs] object that defines the operating system interface that |
| 4327 | 4397 | ** the new database connection should use. ^If the fourth parameter is |
| 4328 | 4398 | ** a NULL pointer then the default [sqlite3_vfs] object is used. |
| 4329 | 4399 | ** |
| | @@ -4499,21 +4569,20 @@ |
| 4499 | 4569 | ); |
| 4500 | 4570 | |
| 4501 | 4571 | /* |
| 4502 | 4572 | ** CAPI3REF: Obtain Values For URI Parameters |
| 4503 | 4573 | ** |
| 4504 | | -** These are utility routines, useful to VFS implementations, that check |
| 4505 | | -** to see if a database file was a URI that contained a specific query |
| 4574 | +** These are utility routines, useful to [VFS|custom VFS implementations], |
| 4575 | +** that check if a database file was a URI that contained a specific query |
| 4506 | 4576 | ** parameter, and if so obtains the value of that query parameter. |
| 4507 | 4577 | ** |
| 4508 | 4578 | ** If F is the database filename pointer passed into the xOpen() method of |
| 4509 | | -** a VFS implementation when the flags parameter to xOpen() has one or |
| 4510 | | -** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and |
| 4511 | | -** P is the name of the query parameter, then |
| 4579 | +** a VFS implementation or it is the return value of [sqlite3_db_filename()] |
| 4580 | +** and if P is the name of the query parameter, then |
| 4512 | 4581 | ** sqlite3_uri_parameter(F,P) returns the value of the P |
| 4513 | 4582 | ** parameter if it exists or a NULL pointer if P does not appear as a |
| 4514 | | -** query parameter on F. If P is a query parameter of F |
| 4583 | +** query parameter on F. If P is a query parameter of F and it |
| 4515 | 4584 | ** has no explicit value, then sqlite3_uri_parameter(F,P) returns |
| 4516 | 4585 | ** a pointer to an empty string. |
| 4517 | 4586 | ** |
| 4518 | 4587 | ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean |
| 4519 | 4588 | ** parameter and returns true (1) or false (0) according to the value |
| | @@ -4521,29 +4590,76 @@ |
| 4521 | 4590 | ** value of query parameter P is one of "yes", "true", or "on" in any |
| 4522 | 4591 | ** case or if the value begins with a non-zero number. The |
| 4523 | 4592 | ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of |
| 4524 | 4593 | ** query parameter P is one of "no", "false", or "off" in any case or |
| 4525 | 4594 | ** if the value begins with a numeric zero. If P is not a query |
| 4526 | | -** parameter on F or if the value of P is does not match any of the |
| 4595 | +** parameter on F or if the value of P does not match any of the |
| 4527 | 4596 | ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). |
| 4528 | 4597 | ** |
| 4529 | 4598 | ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a |
| 4530 | 4599 | ** 64-bit signed integer and returns that integer, or D if P does not |
| 4531 | 4600 | ** exist. If the value of P is something other than an integer, then |
| 4532 | 4601 | ** zero is returned. |
| 4602 | +** |
| 4603 | +** The sqlite3_uri_key(F,N) returns a pointer to the name (not |
| 4604 | +** the value) of the N-th query parameter for filename F, or a NULL |
| 4605 | +** pointer if N is less than zero or greater than the number of query |
| 4606 | +** parameters minus 1. The N value is zero-based so N should be 0 to obtain |
| 4607 | +** the name of the first query parameter, 1 for the second parameter, and |
| 4608 | +** so forth. |
| 4533 | 4609 | ** |
| 4534 | 4610 | ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and |
| 4535 | 4611 | ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and |
| 4536 | | -** is not a database file pathname pointer that SQLite passed into the xOpen |
| 4537 | | -** VFS method, then the behavior of this routine is undefined and probably |
| 4538 | | -** undesirable. |
| 4612 | +** is not a database file pathname pointer that the SQLite core passed |
| 4613 | +** into the xOpen VFS method, then the behavior of this routine is undefined |
| 4614 | +** and probably undesirable. |
| 4615 | +** |
| 4616 | +** Beginning with SQLite [version 3.31.0] ([dateof:3.31.0]) the input F |
| 4617 | +** parameter can also be the name of a rollback journal file or WAL file |
| 4618 | +** in addition to the main database file. Prior to version 3.31.0, these |
| 4619 | +** routines would only work if F was the name of the main database file. |
| 4620 | +** When the F parameter is the name of the rollback journal or WAL file, |
| 4621 | +** it has access to all the same query parameters as were found on the |
| 4622 | +** main database file. |
| 4539 | 4623 | ** |
| 4540 | 4624 | ** See the [URI filename] documentation for additional information. |
| 4541 | 4625 | */ |
| 4542 | 4626 | SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); |
| 4543 | 4627 | SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); |
| 4544 | 4628 | SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); |
| 4629 | +SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N); |
| 4630 | + |
| 4631 | +/* |
| 4632 | +** CAPI3REF: Translate filenames |
| 4633 | +** |
| 4634 | +** These routines are available to [VFS|custom VFS implementations] for |
| 4635 | +** translating filenames between the main database file, the journal file, |
| 4636 | +** and the WAL file. |
| 4637 | +** |
| 4638 | +** If F is the name of an sqlite database file, journal file, or WAL file |
| 4639 | +** passed by the SQLite core into the VFS, then sqlite3_filename_database(F) |
| 4640 | +** returns the name of the corresponding database file. |
| 4641 | +** |
| 4642 | +** If F is the name of an sqlite database file, journal file, or WAL file |
| 4643 | +** passed by the SQLite core into the VFS, or if F is a database filename |
| 4644 | +** obtained from [sqlite3_db_filename()], then sqlite3_filename_journal(F) |
| 4645 | +** returns the name of the corresponding rollback journal file. |
| 4646 | +** |
| 4647 | +** If F is the name of an sqlite database file, journal file, or WAL file |
| 4648 | +** that was passed by the SQLite core into the VFS, or if F is a database |
| 4649 | +** filename obtained from [sqlite3_db_filename()], then |
| 4650 | +** sqlite3_filename_wal(F) returns the name of the corresponding |
| 4651 | +** WAL file. |
| 4652 | +** |
| 4653 | +** In all of the above, if F is not the name of a database, journal or WAL |
| 4654 | +** filename passed into the VFS from the SQLite core and F is not the |
| 4655 | +** return value from [sqlite3_db_filename()], then the result is |
| 4656 | +** undefined and is likely a memory access violation. |
| 4657 | +*/ |
| 4658 | +SQLITE_API const char *sqlite3_filename_database(const char*); |
| 4659 | +SQLITE_API const char *sqlite3_filename_journal(const char*); |
| 4660 | +SQLITE_API const char *sqlite3_filename_wal(const char*); |
| 4545 | 4661 | |
| 4546 | 4662 | |
| 4547 | 4663 | /* |
| 4548 | 4664 | ** CAPI3REF: Error Codes And Messages |
| 4549 | 4665 | ** METHOD: sqlite3 |
| | @@ -4858,16 +4974,16 @@ |
| 4858 | 4974 | ** in order to find the underlying cause of the problem. With the "v2" prepare |
| 4859 | 4975 | ** interfaces, the underlying reason for the error is returned immediately. |
| 4860 | 4976 | ** </li> |
| 4861 | 4977 | ** |
| 4862 | 4978 | ** <li> |
| 4863 | | -** ^If the specific value bound to [parameter | host parameter] in the |
| 4979 | +** ^If the specific value bound to a [parameter | host parameter] in the |
| 4864 | 4980 | ** WHERE clause might influence the choice of query plan for a statement, |
| 4865 | 4981 | ** then the statement will be automatically recompiled, as if there had been |
| 4866 | | -** a schema change, on the first [sqlite3_step()] call following any change |
| 4982 | +** a schema change, on the first [sqlite3_step()] call following any change |
| 4867 | 4983 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 4868 | | -** ^The specific value of WHERE-clause [parameter] might influence the |
| 4984 | +** ^The specific value of a WHERE-clause [parameter] might influence the |
| 4869 | 4985 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 4870 | 4986 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 4871 | 4987 | ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. |
| 4872 | 4988 | ** </li> |
| 4873 | 4989 | ** </ol> |
| | @@ -5372,24 +5488,20 @@ |
| 5372 | 5488 | ** the statement, where N is the second function argument. |
| 5373 | 5489 | ** ^The left-most column is column 0 for these routines. |
| 5374 | 5490 | ** |
| 5375 | 5491 | ** ^If the Nth column returned by the statement is an expression or |
| 5376 | 5492 | ** subquery and is not a column value, then all of these functions return |
| 5377 | | -** NULL. ^These routine might also return NULL if a memory allocation error |
| 5493 | +** NULL. ^These routines might also return NULL if a memory allocation error |
| 5378 | 5494 | ** occurs. ^Otherwise, they return the name of the attached database, table, |
| 5379 | 5495 | ** or column that query result column was extracted from. |
| 5380 | 5496 | ** |
| 5381 | 5497 | ** ^As with all other SQLite APIs, those whose names end with "16" return |
| 5382 | 5498 | ** UTF-16 encoded strings and the other functions return UTF-8. |
| 5383 | 5499 | ** |
| 5384 | 5500 | ** ^These APIs are only available if the library was compiled with the |
| 5385 | 5501 | ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. |
| 5386 | 5502 | ** |
| 5387 | | -** If two or more threads call one or more of these routines against the same |
| 5388 | | -** prepared statement and column at the same time then the results are |
| 5389 | | -** undefined. |
| 5390 | | -** |
| 5391 | 5503 | ** If two or more threads call one or more |
| 5392 | 5504 | ** [sqlite3_column_database_name | column metadata interfaces] |
| 5393 | 5505 | ** for the same [prepared statement] and result column |
| 5394 | 5506 | ** at the same time then the results are undefined. |
| 5395 | 5507 | */ |
| | @@ -5522,11 +5634,11 @@ |
| 5522 | 5634 | ** METHOD: sqlite3_stmt |
| 5523 | 5635 | ** |
| 5524 | 5636 | ** ^The sqlite3_data_count(P) interface returns the number of columns in the |
| 5525 | 5637 | ** current row of the result set of [prepared statement] P. |
| 5526 | 5638 | ** ^If prepared statement P does not have results ready to return |
| 5527 | | -** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 5639 | +** (via calls to the [sqlite3_column_int | sqlite3_column()] family of |
| 5528 | 5640 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 5529 | 5641 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 5530 | 5642 | ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to |
| 5531 | 5643 | ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) |
| 5532 | 5644 | ** will return non-zero if previous call to [sqlite3_step](P) returned |
| | @@ -5846,12 +5958,10 @@ |
| 5846 | 5958 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 5847 | 5959 | |
| 5848 | 5960 | /* |
| 5849 | 5961 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 5850 | 5962 | ** KEYWORDS: {function creation routines} |
| 5851 | | -** KEYWORDS: {application-defined SQL function} |
| 5852 | | -** KEYWORDS: {application-defined SQL functions} |
| 5853 | 5963 | ** METHOD: sqlite3 |
| 5854 | 5964 | ** |
| 5855 | 5965 | ** ^These functions (collectively known as "function creation routines") |
| 5856 | 5966 | ** are used to add SQL functions or aggregates or to redefine the behavior |
| 5857 | 5967 | ** of existing SQL functions or aggregates. The only differences between |
| | @@ -5903,13 +6013,24 @@ |
| 5903 | 6013 | ** perform additional optimizations on deterministic functions, so use |
| 5904 | 6014 | ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible. |
| 5905 | 6015 | ** |
| 5906 | 6016 | ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] |
| 5907 | 6017 | ** flag, which if present prevents the function from being invoked from |
| 5908 | | -** within VIEWs or TRIGGERs. For security reasons, the [SQLITE_DIRECTONLY] |
| 5909 | | -** flag is recommended for any application-defined SQL function that has |
| 5910 | | -** side-effects. |
| 6018 | +** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, |
| 6019 | +** index expressions, or the WHERE clause of partial indexes. |
| 6020 | +** |
| 6021 | +** <span style="background-color:#ffff90;"> |
| 6022 | +** For best security, the [SQLITE_DIRECTONLY] flag is recommended for |
| 6023 | +** all application-defined SQL functions that do not need to be |
| 6024 | +** used inside of triggers, view, CHECK constraints, or other elements of |
| 6025 | +** the database schema. This flags is especially recommended for SQL |
| 6026 | +** functions that have side effects or reveal internal application state. |
| 6027 | +** Without this flag, an attacker might be able to modify the schema of |
| 6028 | +** a database file to include invocations of the function with parameters |
| 6029 | +** chosen by the attacker, which the application will then execute when |
| 6030 | +** the database file is opened and read. |
| 6031 | +** </span> |
| 5911 | 6032 | ** |
| 5912 | 6033 | ** ^(The fifth parameter is an arbitrary pointer. The implementation of the |
| 5913 | 6034 | ** function can gain access to this pointer using [sqlite3_user_data()].)^ |
| 5914 | 6035 | ** |
| 5915 | 6036 | ** ^The sixth, seventh and eighth parameters passed to the three |
| | @@ -6024,33 +6145,71 @@ |
| 6024 | 6145 | ** These constants may be ORed together with the |
| 6025 | 6146 | ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument |
| 6026 | 6147 | ** to [sqlite3_create_function()], [sqlite3_create_function16()], or |
| 6027 | 6148 | ** [sqlite3_create_function_v2()]. |
| 6028 | 6149 | ** |
| 6029 | | -** The SQLITE_DETERMINISTIC flag means that the new function will always |
| 6030 | | -** maps the same inputs into the same output. The abs() function is |
| 6031 | | -** deterministic, for example, but randomblob() is not. |
| 6032 | | -** |
| 6150 | +** <dl> |
| 6151 | +** [[SQLITE_DETERMINISTIC]] <dt>SQLITE_DETERMINISTIC</dt><dd> |
| 6152 | +** The SQLITE_DETERMINISTIC flag means that the new function always gives |
| 6153 | +** the same output when the input parameters are the same. |
| 6154 | +** The [abs|abs() function] is deterministic, for example, but |
| 6155 | +** [randomblob|randomblob()] is not. Functions must |
| 6156 | +** be deterministic in order to be used in certain contexts such as |
| 6157 | +** with the WHERE clause of [partial indexes] or in [generated columns]. |
| 6158 | +** SQLite might also optimize deterministic functions by factoring them |
| 6159 | +** out of inner loops. |
| 6160 | +** </dd> |
| 6161 | +** |
| 6162 | +** [[SQLITE_DIRECTONLY]] <dt>SQLITE_DIRECTONLY</dt><dd> |
| 6033 | 6163 | ** The SQLITE_DIRECTONLY flag means that the function may only be invoked |
| 6034 | | -** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is |
| 6035 | | -** a security feature which is recommended for all |
| 6036 | | -** [application-defined SQL functions] that have side-effects. This flag |
| 6037 | | -** prevents an attacker from adding triggers and views to a schema then |
| 6038 | | -** tricking a high-privilege application into causing unintended side-effects |
| 6039 | | -** while performing ordinary queries. |
| 6164 | +** from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in |
| 6165 | +** schema structures such as [CHECK constraints], [DEFAULT clauses], |
| 6166 | +** [expression indexes], [partial indexes], or [generated columns]. |
| 6167 | +** The SQLITE_DIRECTONLY flags is a security feature which is recommended |
| 6168 | +** for all [application-defined SQL functions], and especially for functions |
| 6169 | +** that have side-effects or that could potentially leak sensitive |
| 6170 | +** information. |
| 6171 | +** </dd> |
| 6040 | 6172 | ** |
| 6173 | +** [[SQLITE_INNOCUOUS]] <dt>SQLITE_INNOCUOUS</dt><dd> |
| 6174 | +** The SQLITE_INNOCUOUS flag means that the function is unlikely |
| 6175 | +** to cause problems even if misused. An innocuous function should have |
| 6176 | +** no side effects and should not depend on any values other than its |
| 6177 | +** input parameters. The [abs|abs() function] is an example of an |
| 6178 | +** innocuous function. |
| 6179 | +** The [load_extension() SQL function] is not innocuous because of its |
| 6180 | +** side effects. |
| 6181 | +** <p> SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not |
| 6182 | +** exactly the same. The [random|random() function] is an example of a |
| 6183 | +** function that is innocuous but not deterministic. |
| 6184 | +** <p>Some heightened security settings |
| 6185 | +** ([SQLITE_DBCONFIG_TRUSTED_SCHEMA] and [PRAGMA trusted_schema=OFF]) |
| 6186 | +** disable the use of SQL functions inside views and triggers and in |
| 6187 | +** schema structures such as [CHECK constraints], [DEFAULT clauses], |
| 6188 | +** [expression indexes], [partial indexes], and [generated columns] unless |
| 6189 | +** the function is tagged with SQLITE_INNOCUOUS. Most built-in functions |
| 6190 | +** are innocuous. Developers are advised to avoid using the |
| 6191 | +** SQLITE_INNOCUOUS flag for application-defined functions unless the |
| 6192 | +** function has been carefully audited and found to be free of potentially |
| 6193 | +** security-adverse side-effects and information-leaks. |
| 6194 | +** </dd> |
| 6195 | +** |
| 6196 | +** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd> |
| 6041 | 6197 | ** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call |
| 6042 | 6198 | ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. |
| 6043 | 6199 | ** Specifying this flag makes no difference for scalar or aggregate user |
| 6044 | 6200 | ** functions. However, if it is not specified for a user-defined window |
| 6045 | 6201 | ** function, then any sub-types belonging to arguments passed to the window |
| 6046 | 6202 | ** function may be discarded before the window function is called (i.e. |
| 6047 | 6203 | ** sqlite3_value_subtype() will always return 0). |
| 6204 | +** </dd> |
| 6205 | +** </dl> |
| 6048 | 6206 | */ |
| 6049 | 6207 | #define SQLITE_DETERMINISTIC 0x000000800 |
| 6050 | 6208 | #define SQLITE_DIRECTONLY 0x000080000 |
| 6051 | 6209 | #define SQLITE_SUBTYPE 0x000100000 |
| 6210 | +#define SQLITE_INNOCUOUS 0x000200000 |
| 6052 | 6211 | |
| 6053 | 6212 | /* |
| 6054 | 6213 | ** CAPI3REF: Deprecated Functions |
| 6055 | 6214 | ** DEPRECATED |
| 6056 | 6215 | ** |
| | @@ -6105,12 +6264,12 @@ |
| 6105 | 6264 | ** |
| 6106 | 6265 | ** <b>Details:</b> |
| 6107 | 6266 | ** |
| 6108 | 6267 | ** These routines extract type, size, and content information from |
| 6109 | 6268 | ** [protected sqlite3_value] objects. Protected sqlite3_value objects |
| 6110 | | -** are used to pass parameter information into implementation of |
| 6111 | | -** [application-defined SQL functions] and [virtual tables]. |
| 6269 | +** are used to pass parameter information into the functions that |
| 6270 | +** implement [application-defined SQL functions] and [virtual tables]. |
| 6112 | 6271 | ** |
| 6113 | 6272 | ** These routines work only with [protected sqlite3_value] objects. |
| 6114 | 6273 | ** Any attempt to use these routines on an [unprotected sqlite3_value] |
| 6115 | 6274 | ** is not threadsafe. |
| 6116 | 6275 | ** |
| | @@ -6163,11 +6322,11 @@ |
| 6163 | 6322 | ** the return value is arbitrary and meaningless. |
| 6164 | 6323 | ** |
| 6165 | 6324 | ** ^The sqlite3_value_frombind(X) interface returns non-zero if the |
| 6166 | 6325 | ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] |
| 6167 | 6326 | ** interfaces. ^If X comes from an SQL literal value, or a table column, |
| 6168 | | -** and expression, then sqlite3_value_frombind(X) returns zero. |
| 6327 | +** or an expression, then sqlite3_value_frombind(X) returns zero. |
| 6169 | 6328 | ** |
| 6170 | 6329 | ** Please pay particular attention to the fact that the pointer returned |
| 6171 | 6330 | ** from [sqlite3_value_blob()], [sqlite3_value_text()], or |
| 6172 | 6331 | ** [sqlite3_value_text16()] can be invalidated by a subsequent call to |
| 6173 | 6332 | ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], |
| | @@ -6249,12 +6408,12 @@ |
| 6249 | 6408 | ** |
| 6250 | 6409 | ** Implementations of aggregate SQL functions use this |
| 6251 | 6410 | ** routine to allocate memory for storing their state. |
| 6252 | 6411 | ** |
| 6253 | 6412 | ** ^The first time the sqlite3_aggregate_context(C,N) routine is called |
| 6254 | | -** for a particular aggregate function, SQLite |
| 6255 | | -** allocates N of memory, zeroes out that memory, and returns a pointer |
| 6413 | +** for a particular aggregate function, SQLite allocates |
| 6414 | +** N bytes of memory, zeroes out that memory, and returns a pointer |
| 6256 | 6415 | ** to the new memory. ^On second and subsequent calls to |
| 6257 | 6416 | ** sqlite3_aggregate_context() for the same aggregate function instance, |
| 6258 | 6417 | ** the same buffer is returned. Sqlite3_aggregate_context() is normally |
| 6259 | 6418 | ** called once for each invocation of the xStep callback and then one |
| 6260 | 6419 | ** last time when the xFinal callback is invoked. ^(When no rows match |
| | @@ -6267,11 +6426,11 @@ |
| 6267 | 6426 | ** when first called if N is less than or equal to zero or if a memory |
| 6268 | 6427 | ** allocate error occurs. |
| 6269 | 6428 | ** |
| 6270 | 6429 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 6271 | 6430 | ** determined by the N parameter on first successful call. Changing the |
| 6272 | | -** value of N in subsequent call to sqlite3_aggregate_context() within |
| 6431 | +** value of N in any subsequents call to sqlite3_aggregate_context() within |
| 6273 | 6432 | ** the same aggregate function instance will not resize the memory |
| 6274 | 6433 | ** allocation.)^ Within the xFinal callback, it is customary to set |
| 6275 | 6434 | ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
| 6276 | 6435 | ** pointless memory allocations occur. |
| 6277 | 6436 | ** |
| | @@ -6578,31 +6737,32 @@ |
| 6578 | 6737 | ** <li> [SQLITE_UTF16BE], |
| 6579 | 6738 | ** <li> [SQLITE_UTF16], or |
| 6580 | 6739 | ** <li> [SQLITE_UTF16_ALIGNED]. |
| 6581 | 6740 | ** </ul>)^ |
| 6582 | 6741 | ** ^The eTextRep argument determines the encoding of strings passed |
| 6583 | | -** to the collating function callback, xCallback. |
| 6742 | +** to the collating function callback, xCompare. |
| 6584 | 6743 | ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep |
| 6585 | 6744 | ** force strings to be UTF16 with native byte order. |
| 6586 | 6745 | ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin |
| 6587 | 6746 | ** on an even byte address. |
| 6588 | 6747 | ** |
| 6589 | 6748 | ** ^The fourth argument, pArg, is an application data pointer that is passed |
| 6590 | 6749 | ** through as the first argument to the collating function callback. |
| 6591 | 6750 | ** |
| 6592 | | -** ^The fifth argument, xCallback, is a pointer to the collating function. |
| 6751 | +** ^The fifth argument, xCompare, is a pointer to the collating function. |
| 6593 | 6752 | ** ^Multiple collating functions can be registered using the same name but |
| 6594 | 6753 | ** with different eTextRep parameters and SQLite will use whichever |
| 6595 | 6754 | ** function requires the least amount of data transformation. |
| 6596 | | -** ^If the xCallback argument is NULL then the collating function is |
| 6755 | +** ^If the xCompare argument is NULL then the collating function is |
| 6597 | 6756 | ** deleted. ^When all collating functions having the same name are deleted, |
| 6598 | 6757 | ** that collation is no longer usable. |
| 6599 | 6758 | ** |
| 6600 | 6759 | ** ^The collating function callback is invoked with a copy of the pArg |
| 6601 | 6760 | ** application data pointer and with two strings in the encoding specified |
| 6602 | | -** by the eTextRep argument. The collating function must return an |
| 6603 | | -** integer that is negative, zero, or positive |
| 6761 | +** by the eTextRep argument. The two integer parameters to the collating |
| 6762 | +** function callback are the length of the two strings, in bytes. The collating |
| 6763 | +** function must return an integer that is negative, zero, or positive |
| 6604 | 6764 | ** if the first string is less than, equal to, or greater than the second, |
| 6605 | 6765 | ** respectively. A collating function must always return the same answer |
| 6606 | 6766 | ** given the same inputs. If two or more collating functions are registered |
| 6607 | 6767 | ** to the same collation name (using different eTextRep values) then all |
| 6608 | 6768 | ** must give an equivalent answer when invoked with equivalent strings. |
| | @@ -6615,11 +6775,11 @@ |
| 6615 | 6775 | ** <li> If A<B THEN B>A. |
| 6616 | 6776 | ** <li> If A<B and B<C then A<C. |
| 6617 | 6777 | ** </ol> |
| 6618 | 6778 | ** |
| 6619 | 6779 | ** If a collating function fails any of the above constraints and that |
| 6620 | | -** collating function is registered and used, then the behavior of SQLite |
| 6780 | +** collating function is registered and used, then the behavior of SQLite |
| 6621 | 6781 | ** is undefined. |
| 6622 | 6782 | ** |
| 6623 | 6783 | ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() |
| 6624 | 6784 | ** with the addition that the xDestroy callback is invoked on pArg when |
| 6625 | 6785 | ** the collating function is deleted. |
| | @@ -6942,20 +7102,35 @@ |
| 6942 | 7102 | |
| 6943 | 7103 | /* |
| 6944 | 7104 | ** CAPI3REF: Return The Filename For A Database Connection |
| 6945 | 7105 | ** METHOD: sqlite3 |
| 6946 | 7106 | ** |
| 6947 | | -** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename |
| 6948 | | -** associated with database N of connection D. ^The main database file |
| 6949 | | -** has the name "main". If there is no attached database N on the database |
| 7107 | +** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename |
| 7108 | +** associated with database N of connection D. |
| 7109 | +** ^If there is no attached database N on the database |
| 6950 | 7110 | ** connection D, or if database N is a temporary or in-memory database, then |
| 6951 | 7111 | ** this function will return either a NULL pointer or an empty string. |
| 7112 | +** |
| 7113 | +** ^The string value returned by this routine is owned and managed by |
| 7114 | +** the database connection. ^The value will be valid until the database N |
| 7115 | +** is [DETACH]-ed or until the database connection closes. |
| 6952 | 7116 | ** |
| 6953 | 7117 | ** ^The filename returned by this function is the output of the |
| 6954 | 7118 | ** xFullPathname method of the [VFS]. ^In other words, the filename |
| 6955 | 7119 | ** will be an absolute pathname, even if the filename used |
| 6956 | 7120 | ** to open the database originally was a URI or relative pathname. |
| 7121 | +** |
| 7122 | +** If the filename pointer returned by this routine is not NULL, then it |
| 7123 | +** can be used as the filename input parameter to these routines: |
| 7124 | +** <ul> |
| 7125 | +** <li> [sqlite3_uri_parameter()] |
| 7126 | +** <li> [sqlite3_uri_boolean()] |
| 7127 | +** <li> [sqlite3_uri_int64()] |
| 7128 | +** <li> [sqlite3_filename_database()] |
| 7129 | +** <li> [sqlite3_filename_journal()] |
| 7130 | +** <li> [sqlite3_filename_wal()] |
| 7131 | +** </ul> |
| 6957 | 7132 | */ |
| 6958 | 7133 | SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); |
| 6959 | 7134 | |
| 6960 | 7135 | /* |
| 6961 | 7136 | ** CAPI3REF: Determine if a database is read-only |
| | @@ -7101,19 +7276,23 @@ |
| 7101 | 7276 | ** In prior versions of SQLite, |
| 7102 | 7277 | ** sharing was enabled or disabled for each thread separately. |
| 7103 | 7278 | ** |
| 7104 | 7279 | ** ^(The cache sharing mode set by this interface effects all subsequent |
| 7105 | 7280 | ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. |
| 7106 | | -** Existing database connections continue use the sharing mode |
| 7281 | +** Existing database connections continue to use the sharing mode |
| 7107 | 7282 | ** that was in effect at the time they were opened.)^ |
| 7108 | 7283 | ** |
| 7109 | 7284 | ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled |
| 7110 | 7285 | ** successfully. An [error code] is returned otherwise.)^ |
| 7111 | 7286 | ** |
| 7112 | | -** ^Shared cache is disabled by default. But this might change in |
| 7113 | | -** future releases of SQLite. Applications that care about shared |
| 7114 | | -** cache setting should set it explicitly. |
| 7287 | +** ^Shared cache is disabled by default. It is recommended that it stay |
| 7288 | +** that way. In other words, do not use this routine. This interface |
| 7289 | +** continues to be provided for historical compatibility, but its use is |
| 7290 | +** discouraged. Any use of shared cache is discouraged. If shared cache |
| 7291 | +** must be used, it is recommended that shared cache only be enabled for |
| 7292 | +** individual database connections using the [sqlite3_open_v2()] interface |
| 7293 | +** with the [SQLITE_OPEN_SHAREDCACHE] flag. |
| 7115 | 7294 | ** |
| 7116 | 7295 | ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 |
| 7117 | 7296 | ** and will always return SQLITE_MISUSE. On those systems, |
| 7118 | 7297 | ** shared cache mode should be enabled per-database connection via |
| 7119 | 7298 | ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. |
| | @@ -7155,10 +7334,13 @@ |
| 7155 | 7334 | */ |
| 7156 | 7335 | SQLITE_API int sqlite3_db_release_memory(sqlite3*); |
| 7157 | 7336 | |
| 7158 | 7337 | /* |
| 7159 | 7338 | ** CAPI3REF: Impose A Limit On Heap Size |
| 7339 | +** |
| 7340 | +** These interfaces impose limits on the amount of heap memory that will be |
| 7341 | +** by all database connections within a single process. |
| 7160 | 7342 | ** |
| 7161 | 7343 | ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the |
| 7162 | 7344 | ** soft limit on the amount of heap memory that may be allocated by SQLite. |
| 7163 | 7345 | ** ^SQLite strives to keep heap memory utilization below the soft heap |
| 7164 | 7346 | ** limit by reducing the number of pages held in the page cache |
| | @@ -7166,24 +7348,45 @@ |
| 7166 | 7348 | ** ^The soft heap limit is "soft" because even though SQLite strives to stay |
| 7167 | 7349 | ** below the limit, it will exceed the limit rather than generate |
| 7168 | 7350 | ** an [SQLITE_NOMEM] error. In other words, the soft heap limit |
| 7169 | 7351 | ** is advisory only. |
| 7170 | 7352 | ** |
| 7171 | | -** ^The return value from sqlite3_soft_heap_limit64() is the size of |
| 7172 | | -** the soft heap limit prior to the call, or negative in the case of an |
| 7353 | +** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of |
| 7354 | +** N bytes on the amount of memory that will be allocated. ^The |
| 7355 | +** sqlite3_hard_heap_limit64(N) interface is similar to |
| 7356 | +** sqlite3_soft_heap_limit64(N) except that memory allocations will fail |
| 7357 | +** when the hard heap limit is reached. |
| 7358 | +** |
| 7359 | +** ^The return value from both sqlite3_soft_heap_limit64() and |
| 7360 | +** sqlite3_hard_heap_limit64() is the size of |
| 7361 | +** the heap limit prior to the call, or negative in the case of an |
| 7173 | 7362 | ** error. ^If the argument N is negative |
| 7174 | | -** then no change is made to the soft heap limit. Hence, the current |
| 7175 | | -** size of the soft heap limit can be determined by invoking |
| 7176 | | -** sqlite3_soft_heap_limit64() with a negative argument. |
| 7363 | +** then no change is made to the heap limit. Hence, the current |
| 7364 | +** size of heap limits can be determined by invoking |
| 7365 | +** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1). |
| 7177 | 7366 | ** |
| 7178 | | -** ^If the argument N is zero then the soft heap limit is disabled. |
| 7367 | +** ^Setting the heap limits to zero disables the heap limiter mechanism. |
| 7179 | 7368 | ** |
| 7180 | | -** ^(The soft heap limit is not enforced in the current implementation |
| 7369 | +** ^The soft heap limit may not be greater than the hard heap limit. |
| 7370 | +** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) |
| 7371 | +** is invoked with a value of N that is greater than the hard heap limit, |
| 7372 | +** the the soft heap limit is set to the value of the hard heap limit. |
| 7373 | +** ^The soft heap limit is automatically enabled whenever the hard heap |
| 7374 | +** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and |
| 7375 | +** the soft heap limit is outside the range of 1..N, then the soft heap |
| 7376 | +** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the |
| 7377 | +** hard heap limit is enabled makes the soft heap limit equal to the |
| 7378 | +** hard heap limit. |
| 7379 | +** |
| 7380 | +** The memory allocation limits can also be adjusted using |
| 7381 | +** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit]. |
| 7382 | +** |
| 7383 | +** ^(The heap limits are not enforced in the current implementation |
| 7181 | 7384 | ** if one or more of following conditions are true: |
| 7182 | 7385 | ** |
| 7183 | 7386 | ** <ul> |
| 7184 | | -** <li> The soft heap limit is set to zero. |
| 7387 | +** <li> The limit value is set to zero. |
| 7185 | 7388 | ** <li> Memory accounting is disabled using a combination of the |
| 7186 | 7389 | ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and |
| 7187 | 7390 | ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. |
| 7188 | 7391 | ** <li> An alternative page cache implementation is specified using |
| 7189 | 7392 | ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...). |
| | @@ -7190,25 +7393,15 @@ |
| 7190 | 7393 | ** <li> The page cache allocates from its own memory pool supplied |
| 7191 | 7394 | ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than |
| 7192 | 7395 | ** from the heap. |
| 7193 | 7396 | ** </ul>)^ |
| 7194 | 7397 | ** |
| 7195 | | -** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), |
| 7196 | | -** the soft heap limit is enforced |
| 7197 | | -** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] |
| 7198 | | -** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], |
| 7199 | | -** the soft heap limit is enforced on every memory allocation. Without |
| 7200 | | -** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced |
| 7201 | | -** when memory is allocated by the page cache. Testing suggests that because |
| 7202 | | -** the page cache is the predominate memory user in SQLite, most |
| 7203 | | -** applications will achieve adequate soft heap limit enforcement without |
| 7204 | | -** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. |
| 7205 | | -** |
| 7206 | | -** The circumstances under which SQLite will enforce the soft heap limit may |
| 7398 | +** The circumstances under which SQLite will enforce the heap limits may |
| 7207 | 7399 | ** changes in future releases of SQLite. |
| 7208 | 7400 | */ |
| 7209 | 7401 | SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); |
| 7402 | +SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N); |
| 7210 | 7403 | |
| 7211 | 7404 | /* |
| 7212 | 7405 | ** CAPI3REF: Deprecated Soft Heap Limit Interface |
| 7213 | 7406 | ** DEPRECATED |
| 7214 | 7407 | ** |
| | @@ -7228,11 +7421,11 @@ |
| 7228 | 7421 | ** information about column C of table T in database D |
| 7229 | 7422 | ** on [database connection] X.)^ ^The sqlite3_table_column_metadata() |
| 7230 | 7423 | ** interface returns SQLITE_OK and fills in the non-NULL pointers in |
| 7231 | 7424 | ** the final five arguments with appropriate values if the specified |
| 7232 | 7425 | ** column exists. ^The sqlite3_table_column_metadata() interface returns |
| 7233 | | -** SQLITE_ERROR and if the specified column does not exist. |
| 7426 | +** SQLITE_ERROR if the specified column does not exist. |
| 7234 | 7427 | ** ^If the column-name parameter to sqlite3_table_column_metadata() is a |
| 7235 | 7428 | ** NULL pointer, then this routine simply checks for the existence of the |
| 7236 | 7429 | ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it |
| 7237 | 7430 | ** does not. If the table name parameter T in a call to |
| 7238 | 7431 | ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is |
| | @@ -7370,11 +7563,11 @@ |
| 7370 | 7563 | ** [sqlite3_load_extension()] and the SQL function [load_extension()]. |
| 7371 | 7564 | ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) |
| 7372 | 7565 | ** to enable or disable only the C-API.)^ |
| 7373 | 7566 | ** |
| 7374 | 7567 | ** <b>Security warning:</b> It is recommended that extension loading |
| 7375 | | -** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 7568 | +** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 7376 | 7569 | ** rather than this interface, so the [load_extension()] SQL function |
| 7377 | 7570 | ** remains disabled. This will prevent SQL injections from giving attackers |
| 7378 | 7571 | ** access to extension loading capabilities. |
| 7379 | 7572 | */ |
| 7380 | 7573 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| | @@ -7457,11 +7650,11 @@ |
| 7457 | 7650 | /* |
| 7458 | 7651 | ** CAPI3REF: Virtual Table Object |
| 7459 | 7652 | ** KEYWORDS: sqlite3_module {virtual table module} |
| 7460 | 7653 | ** |
| 7461 | 7654 | ** This structure, sometimes called a "virtual table module", |
| 7462 | | -** defines the implementation of a [virtual tables]. |
| 7655 | +** defines the implementation of a [virtual table]. |
| 7463 | 7656 | ** This structure consists mostly of methods for the module. |
| 7464 | 7657 | ** |
| 7465 | 7658 | ** ^A virtual table module is created by filling in a persistent |
| 7466 | 7659 | ** instance of this structure and passing a pointer to that instance |
| 7467 | 7660 | ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. |
| | @@ -7554,11 +7747,17 @@ |
| 7554 | 7747 | ** The [xBestIndex] method must fill aConstraintUsage[] with information |
| 7555 | 7748 | ** about what parameters to pass to xFilter. ^If argvIndex>0 then |
| 7556 | 7749 | ** the right-hand side of the corresponding aConstraint[] is evaluated |
| 7557 | 7750 | ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit |
| 7558 | 7751 | ** is true, then the constraint is assumed to be fully handled by the |
| 7559 | | -** virtual table and is not checked again by SQLite.)^ |
| 7752 | +** virtual table and might not be checked again by the byte code.)^ ^(The |
| 7753 | +** aConstraintUsage[].omit flag is an optimization hint. When the omit flag |
| 7754 | +** is left in its default setting of false, the constraint will always be |
| 7755 | +** checked separately in byte code. If the omit flag is change to true, then |
| 7756 | +** the constraint may or may not be checked in byte code. In other words, |
| 7757 | +** when the omit flag is true there is no guarantee that the constraint will |
| 7758 | +** not be checked again using byte code.)^ |
| 7560 | 7759 | ** |
| 7561 | 7760 | ** ^The idxNum and idxPtr values are recorded and passed into the |
| 7562 | 7761 | ** [xFilter] method. |
| 7563 | 7762 | ** ^[sqlite3_free()] is used to free idxPtr if and only if |
| 7564 | 7763 | ** needToFreeIdxPtr is true. |
| | @@ -7594,11 +7793,11 @@ |
| 7594 | 7793 | ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info |
| 7595 | 7794 | ** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). |
| 7596 | 7795 | ** If a virtual table extension is |
| 7597 | 7796 | ** used with an SQLite version earlier than 3.8.2, the results of attempting |
| 7598 | 7797 | ** to read or write the estimatedRows field are undefined (but are likely |
| 7599 | | -** to included crashing the application). The estimatedRows field should |
| 7798 | +** to include crashing the application). The estimatedRows field should |
| 7600 | 7799 | ** therefore only be used if [sqlite3_libversion_number()] returns a |
| 7601 | 7800 | ** value greater than or equal to 3008002. Similarly, the idxFlags field |
| 7602 | 7801 | ** was added for [version 3.9.0] ([dateof:3.9.0]). |
| 7603 | 7802 | ** It may therefore only be used if |
| 7604 | 7803 | ** sqlite3_libversion_number() returns a value greater than or equal to |
| | @@ -7646,11 +7845,11 @@ |
| 7646 | 7845 | #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */ |
| 7647 | 7846 | |
| 7648 | 7847 | /* |
| 7649 | 7848 | ** CAPI3REF: Virtual Table Constraint Operator Codes |
| 7650 | 7849 | ** |
| 7651 | | -** These macros defined the allowed values for the |
| 7850 | +** These macros define the allowed values for the |
| 7652 | 7851 | ** [sqlite3_index_info].aConstraint[].op field. Each value represents |
| 7653 | 7852 | ** an operator that is part of a constraint term in the wHERE clause of |
| 7654 | 7853 | ** a query that uses a [virtual table]. |
| 7655 | 7854 | */ |
| 7656 | 7855 | #define SQLITE_INDEX_CONSTRAINT_EQ 2 |
| | @@ -8256,11 +8455,11 @@ |
| 8256 | 8455 | ** </ul>)^ |
| 8257 | 8456 | ** |
| 8258 | 8457 | ** The only difference is that the public sqlite3_XXX functions enumerated |
| 8259 | 8458 | ** above silently ignore any invocations that pass a NULL pointer instead |
| 8260 | 8459 | ** of a valid mutex handle. The implementations of the methods defined |
| 8261 | | -** by this structure are not required to handle this case, the results |
| 8460 | +** by this structure are not required to handle this case. The results |
| 8262 | 8461 | ** of passing a NULL pointer instead of a valid mutex handle are undefined |
| 8263 | 8462 | ** (i.e. it is acceptable to provide an implementation that segfaults if |
| 8264 | 8463 | ** it is passed a NULL pointer). |
| 8265 | 8464 | ** |
| 8266 | 8465 | ** The xMutexInit() method must be threadsafe. It must be harmless to |
| | @@ -8729,11 +8928,11 @@ |
| 8729 | 8928 | ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because |
| 8730 | 8929 | ** no space was left in the page cache.</dd>)^ |
| 8731 | 8930 | ** |
| 8732 | 8931 | ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
| 8733 | 8932 | ** <dd>This parameter records the largest memory allocation request |
| 8734 | | -** handed to [pagecache memory allocator]. Only the value returned in the |
| 8933 | +** handed to the [pagecache memory allocator]. Only the value returned in the |
| 8735 | 8934 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 8736 | 8935 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 8737 | 8936 | ** |
| 8738 | 8937 | ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt> |
| 8739 | 8938 | ** <dd>No longer used.</dd> |
| | @@ -8805,11 +9004,11 @@ |
| 8805 | 9004 | ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 8806 | 9005 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 8807 | 9006 | ** checked out.</dd>)^ |
| 8808 | 9007 | ** |
| 8809 | 9008 | ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 8810 | | -** <dd>This parameter returns the number malloc attempts that were |
| 9009 | +** <dd>This parameter returns the number of malloc attempts that were |
| 8811 | 9010 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 8812 | 9011 | ** the current value is always zero.)^ |
| 8813 | 9012 | ** |
| 8814 | 9013 | ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] |
| 8815 | 9014 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| | @@ -8887,11 +9086,11 @@ |
| 8887 | 9086 | ** <dd>This parameter returns the number of dirty cache entries that have |
| 8888 | 9087 | ** been written to disk in the middle of a transaction due to the page |
| 8889 | 9088 | ** cache overflowing. Transactions are more efficient if they are written |
| 8890 | 9089 | ** to disk all at once. When pages spill mid-transaction, that introduces |
| 8891 | 9090 | ** additional overhead. This parameter can be used help identify |
| 8892 | | -** inefficiencies that can be resolve by increasing the cache size. |
| 9091 | +** inefficiencies that can be resolved by increasing the cache size. |
| 8893 | 9092 | ** </dd> |
| 8894 | 9093 | ** |
| 8895 | 9094 | ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt> |
| 8896 | 9095 | ** <dd>This parameter returns zero for the current value if and only if |
| 8897 | 9096 | ** all foreign key constraints (deferred or immediate) have been |
| | @@ -8976,11 +9175,11 @@ |
| 8976 | 9175 | ** If the number of virtual machine operations exceeds 2147483647 |
| 8977 | 9176 | ** then the value returned by this statement status code is undefined. |
| 8978 | 9177 | ** |
| 8979 | 9178 | ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt> |
| 8980 | 9179 | ** <dd>^This is the number of times that the prepare statement has been |
| 8981 | | -** automatically regenerated due to schema changes or change to |
| 9180 | +** automatically regenerated due to schema changes or changes to |
| 8982 | 9181 | ** [bound parameters] that might affect the query plan. |
| 8983 | 9182 | ** |
| 8984 | 9183 | ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> |
| 8985 | 9184 | ** <dd>^This is the number of times that the prepared statement has |
| 8986 | 9185 | ** been run. A single "run" for the purposes of this counter is one |
| | @@ -9147,11 +9346,11 @@ |
| 9147 | 9346 | ** NULL if allocating a new page is effectively impossible. |
| 9148 | 9347 | ** </table> |
| 9149 | 9348 | ** |
| 9150 | 9349 | ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite |
| 9151 | 9350 | ** will only use a createFlag of 2 after a prior call with a createFlag of 1 |
| 9152 | | -** failed.)^ In between the to xFetch() calls, SQLite may |
| 9351 | +** failed.)^ In between the xFetch() calls, SQLite may |
| 9153 | 9352 | ** attempt to unpin one or more cache pages by spilling the content of |
| 9154 | 9353 | ** pinned pages to disk and synching the operating system disk cache. |
| 9155 | 9354 | ** |
| 9156 | 9355 | ** [[the xUnpin() page cache method]] |
| 9157 | 9356 | ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page |
| | @@ -9465,11 +9664,11 @@ |
| 9465 | 9664 | ** application receives an SQLITE_LOCKED error, it may call the |
| 9466 | 9665 | ** sqlite3_unlock_notify() method with the blocked connection handle as |
| 9467 | 9666 | ** the first argument to register for a callback that will be invoked |
| 9468 | 9667 | ** when the blocking connections current transaction is concluded. ^The |
| 9469 | 9668 | ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] |
| 9470 | | -** call that concludes the blocking connections transaction. |
| 9669 | +** call that concludes the blocking connection's transaction. |
| 9471 | 9670 | ** |
| 9472 | 9671 | ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, |
| 9473 | 9672 | ** there is a chance that the blocking connection will have already |
| 9474 | 9673 | ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. |
| 9475 | 9674 | ** If this happens, then the specified callback is invoked immediately, |
| | @@ -9503,11 +9702,11 @@ |
| 9503 | 9702 | ** However, the signature of the callback function allows SQLite to pass |
| 9504 | 9703 | ** it an array of void* context pointers. The first argument passed to |
| 9505 | 9704 | ** an unlock-notify callback is a pointer to an array of void* pointers, |
| 9506 | 9705 | ** and the second is the number of entries in the array. |
| 9507 | 9706 | ** |
| 9508 | | -** When a blocking connections transaction is concluded, there may be |
| 9707 | +** When a blocking connection's transaction is concluded, there may be |
| 9509 | 9708 | ** more than one blocked connection that has registered for an unlock-notify |
| 9510 | 9709 | ** callback. ^If two or more such blocked connections have specified the |
| 9511 | 9710 | ** same callback function, then instead of invoking the callback function |
| 9512 | 9711 | ** multiple times, it is invoked once with the set of void* context pointers |
| 9513 | 9712 | ** specified by the blocked connections bundled together into an array. |
| | @@ -9851,26 +10050,32 @@ |
| 9851 | 10050 | ** various facets of the virtual table interface. |
| 9852 | 10051 | ** |
| 9853 | 10052 | ** If this interface is invoked outside the context of an xConnect or |
| 9854 | 10053 | ** xCreate virtual table method then the behavior is undefined. |
| 9855 | 10054 | ** |
| 9856 | | -** At present, there is only one option that may be configured using |
| 9857 | | -** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options |
| 9858 | | -** may be added in the future. |
| 10055 | +** In the call sqlite3_vtab_config(D,C,...) the D parameter is the |
| 10056 | +** [database connection] in which the virtual table is being created and |
| 10057 | +** which is passed in as the first argument to the [xConnect] or [xCreate] |
| 10058 | +** method that is invoking sqlite3_vtab_config(). The C parameter is one |
| 10059 | +** of the [virtual table configuration options]. The presence and meaning |
| 10060 | +** of parameters after C depend on which [virtual table configuration option] |
| 10061 | +** is used. |
| 9859 | 10062 | */ |
| 9860 | 10063 | SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); |
| 9861 | 10064 | |
| 9862 | 10065 | /* |
| 9863 | 10066 | ** CAPI3REF: Virtual Table Configuration Options |
| 10067 | +** KEYWORDS: {virtual table configuration options} |
| 10068 | +** KEYWORDS: {virtual table configuration option} |
| 9864 | 10069 | ** |
| 9865 | 10070 | ** These macros define the various options to the |
| 9866 | 10071 | ** [sqlite3_vtab_config()] interface that [virtual table] implementations |
| 9867 | 10072 | ** can use to customize and optimize their behavior. |
| 9868 | 10073 | ** |
| 9869 | 10074 | ** <dl> |
| 9870 | 10075 | ** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]] |
| 9871 | | -** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT |
| 10076 | +** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT</dt> |
| 9872 | 10077 | ** <dd>Calls of the form |
| 9873 | 10078 | ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, |
| 9874 | 10079 | ** where X is an integer. If X is zero, then the [virtual table] whose |
| 9875 | 10080 | ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not |
| 9876 | 10081 | ** support constraints. In this configuration (which is the default) if |
| | @@ -9895,13 +10100,35 @@ |
| 9895 | 10100 | ** CONFLICT policy is REPLACE, the virtual table implementation should |
| 9896 | 10101 | ** silently replace the appropriate rows within the xUpdate callback and |
| 9897 | 10102 | ** return SQLITE_OK. Or, if this is not possible, it may return |
| 9898 | 10103 | ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT |
| 9899 | 10104 | ** constraint handling. |
| 10105 | +** </dd> |
| 10106 | +** |
| 10107 | +** [[SQLITE_VTAB_DIRECTONLY]]<dt>SQLITE_VTAB_DIRECTONLY</dt> |
| 10108 | +** <dd>Calls of the form |
| 10109 | +** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the |
| 10110 | +** the [xConnect] or [xCreate] methods of a [virtual table] implmentation |
| 10111 | +** prohibits that virtual table from being used from within triggers and |
| 10112 | +** views. |
| 10113 | +** </dd> |
| 10114 | +** |
| 10115 | +** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt> |
| 10116 | +** <dd>Calls of the form |
| 10117 | +** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the |
| 10118 | +** the [xConnect] or [xCreate] methods of a [virtual table] implmentation |
| 10119 | +** identify that virtual table as being safe to use from within triggers |
| 10120 | +** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the |
| 10121 | +** virtual table can do no serious harm even if it is controlled by a |
| 10122 | +** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS |
| 10123 | +** flag unless absolutely necessary. |
| 10124 | +** </dd> |
| 9900 | 10125 | ** </dl> |
| 9901 | 10126 | */ |
| 9902 | 10127 | #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 |
| 10128 | +#define SQLITE_VTAB_INNOCUOUS 2 |
| 10129 | +#define SQLITE_VTAB_DIRECTONLY 3 |
| 9903 | 10130 | |
| 9904 | 10131 | /* |
| 9905 | 10132 | ** CAPI3REF: Determine The Virtual Table Conflict Policy |
| 9906 | 10133 | ** |
| 9907 | 10134 | ** This function may only be called from within a call to the [xUpdate] method |
| | @@ -9977,37 +10204,37 @@ |
| 9977 | 10204 | ** managed by the prepared statement S and will be automatically freed when |
| 9978 | 10205 | ** S is finalized. |
| 9979 | 10206 | ** |
| 9980 | 10207 | ** <dl> |
| 9981 | 10208 | ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt> |
| 9982 | | -** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be |
| 10209 | +** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be |
| 9983 | 10210 | ** set to the total number of times that the X-th loop has run.</dd> |
| 9984 | 10211 | ** |
| 9985 | 10212 | ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt> |
| 9986 | | -** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set |
| 10213 | +** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be set |
| 9987 | 10214 | ** to the total number of rows examined by all iterations of the X-th loop.</dd> |
| 9988 | 10215 | ** |
| 9989 | 10216 | ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt> |
| 9990 | | -** <dd>^The "double" variable pointed to by the T parameter will be set to the |
| 10217 | +** <dd>^The "double" variable pointed to by the V parameter will be set to the |
| 9991 | 10218 | ** query planner's estimate for the average number of rows output from each |
| 9992 | 10219 | ** iteration of the X-th loop. If the query planner's estimates was accurate, |
| 9993 | 10220 | ** then this value will approximate the quotient NVISIT/NLOOP and the |
| 9994 | 10221 | ** product of this value for all prior loops with the same SELECTID will |
| 9995 | 10222 | ** be the NLOOP value for the current loop. |
| 9996 | 10223 | ** |
| 9997 | 10224 | ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt> |
| 9998 | | -** <dd>^The "const char *" variable pointed to by the T parameter will be set |
| 10225 | +** <dd>^The "const char *" variable pointed to by the V parameter will be set |
| 9999 | 10226 | ** to a zero-terminated UTF-8 string containing the name of the index or table |
| 10000 | 10227 | ** used for the X-th loop. |
| 10001 | 10228 | ** |
| 10002 | 10229 | ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt> |
| 10003 | | -** <dd>^The "const char *" variable pointed to by the T parameter will be set |
| 10230 | +** <dd>^The "const char *" variable pointed to by the V parameter will be set |
| 10004 | 10231 | ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] |
| 10005 | 10232 | ** description for the X-th loop. |
| 10006 | 10233 | ** |
| 10007 | 10234 | ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt> |
| 10008 | | -** <dd>^The "int" variable pointed to by the T parameter will be set to the |
| 10235 | +** <dd>^The "int" variable pointed to by the V parameter will be set to the |
| 10009 | 10236 | ** "select-id" for the X-th loop. The select-id identifies which query or |
| 10010 | 10237 | ** subquery the loop is part of. The main query has a select-id of zero. |
| 10011 | 10238 | ** The select-id is the same value as is output in the first column |
| 10012 | 10239 | ** of an [EXPLAIN QUERY PLAN] query. |
| 10013 | 10240 | ** </dl> |
| | @@ -10858,11 +11085,11 @@ |
| 10858 | 11085 | ** METHOD: sqlite3_session |
| 10859 | 11086 | ** |
| 10860 | 11087 | ** The second argument (xFilter) is the "filter callback". For changes to rows |
| 10861 | 11088 | ** in tables that are not attached to the Session object, the filter is called |
| 10862 | 11089 | ** to determine whether changes to the table's rows should be tracked or not. |
| 10863 | | -** If xFilter returns 0, changes is not tracked. Note that once a table is |
| 11090 | +** If xFilter returns 0, changes are not tracked. Note that once a table is |
| 10864 | 11091 | ** attached, xFilter will not be called again. |
| 10865 | 11092 | */ |
| 10866 | 11093 | SQLITE_API void sqlite3session_table_filter( |
| 10867 | 11094 | sqlite3_session *pSession, /* Session object */ |
| 10868 | 11095 | int(*xFilter)( |
| | @@ -11032,11 +11259,11 @@ |
| 11032 | 11259 | ** identical. |
| 11033 | 11260 | ** |
| 11034 | 11261 | ** It an error if database zFrom does not exist or does not contain the |
| 11035 | 11262 | ** required compatible table. |
| 11036 | 11263 | ** |
| 11037 | | -** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite |
| 11264 | +** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite |
| 11038 | 11265 | ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg |
| 11039 | 11266 | ** may be set to point to a buffer containing an English language error |
| 11040 | 11267 | ** message. It is the responsibility of the caller to free this buffer using |
| 11041 | 11268 | ** sqlite3_free(). |
| 11042 | 11269 | */ |
| | @@ -11169,11 +11396,11 @@ |
| 11169 | 11396 | |
| 11170 | 11397 | /* |
| 11171 | 11398 | ** CAPI3REF: Advance A Changeset Iterator |
| 11172 | 11399 | ** METHOD: sqlite3_changeset_iter |
| 11173 | 11400 | ** |
| 11174 | | -** This function may only be used with iterators created by function |
| 11401 | +** This function may only be used with iterators created by the function |
| 11175 | 11402 | ** [sqlite3changeset_start()]. If it is called on an iterator passed to |
| 11176 | 11403 | ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE |
| 11177 | 11404 | ** is returned and the call has no effect. |
| 11178 | 11405 | ** |
| 11179 | 11406 | ** Immediately after an iterator is created by sqlite3changeset_start(), it |
| | @@ -11585,12 +11812,12 @@ |
| 11585 | 11812 | ** in the changegroup, then the number of columns and the position of the |
| 11586 | 11813 | ** primary key columns for the table must be consistent. If this is not the |
| 11587 | 11814 | ** case, this function fails with SQLITE_SCHEMA. If the input changeset |
| 11588 | 11815 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is |
| 11589 | 11816 | ** returned. Or, if an out-of-memory condition occurs during processing, this |
| 11590 | | -** function returns SQLITE_NOMEM. In all cases, if an error occurs the |
| 11591 | | -** final contents of the changegroup is undefined. |
| 11817 | +** function returns SQLITE_NOMEM. In all cases, if an error occurs the state |
| 11818 | +** of the final contents of the changegroup is undefined. |
| 11592 | 11819 | ** |
| 11593 | 11820 | ** If no error occurs, SQLITE_OK is returned. |
| 11594 | 11821 | */ |
| 11595 | 11822 | SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); |
| 11596 | 11823 | |
| | @@ -11761,11 +11988,11 @@ |
| 11761 | 11988 | ** [SQLITE_CHANGESET_REPLACE]. |
| 11762 | 11989 | ** </dl> |
| 11763 | 11990 | ** |
| 11764 | 11991 | ** It is safe to execute SQL statements, including those that write to the |
| 11765 | 11992 | ** table that the callback related to, from within the xConflict callback. |
| 11766 | | -** This can be used to further customize the applications conflict |
| 11993 | +** This can be used to further customize the application's conflict |
| 11767 | 11994 | ** resolution strategy. |
| 11768 | 11995 | ** |
| 11769 | 11996 | ** All changes made by these functions are enclosed in a savepoint transaction. |
| 11770 | 11997 | ** If any other error (aside from a constraint failure when attempting to |
| 11771 | 11998 | ** write to the target database) occurs, then the savepoint transaction is |
| | @@ -12071,11 +12298,11 @@ |
| 12071 | 12298 | ** CAPI3REF: Rebase a changeset |
| 12072 | 12299 | ** EXPERIMENTAL |
| 12073 | 12300 | ** |
| 12074 | 12301 | ** Argument pIn must point to a buffer containing a changeset nIn bytes |
| 12075 | 12302 | ** in size. This function allocates and populates a buffer with a copy |
| 12076 | | -** of the changeset rebased rebased according to the configuration of the |
| 12303 | +** of the changeset rebased according to the configuration of the |
| 12077 | 12304 | ** rebaser object passed as the first argument. If successful, (*ppOut) |
| 12078 | 12305 | ** is set to point to the new buffer containing the rebased changeset and |
| 12079 | 12306 | ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the |
| 12080 | 12307 | ** responsibility of the caller to eventually free the new buffer using |
| 12081 | 12308 | ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) |
| | @@ -12479,11 +12706,11 @@ |
| 12479 | 12706 | ** the callback, an SQLite error code is returned. |
| 12480 | 12707 | ** |
| 12481 | 12708 | ** |
| 12482 | 12709 | ** xSetAuxdata(pFts5, pAux, xDelete) |
| 12483 | 12710 | ** |
| 12484 | | -** Save the pointer passed as the second argument as the extension functions |
| 12711 | +** Save the pointer passed as the second argument as the extension function's |
| 12485 | 12712 | ** "auxiliary data". The pointer may then be retrieved by the current or any |
| 12486 | 12713 | ** future invocation of the same fts5 extension function made as part of |
| 12487 | 12714 | ** the same MATCH query using the xGetAuxdata() API. |
| 12488 | 12715 | ** |
| 12489 | 12716 | ** Each extension function is allocated a single auxiliary data slot for |
| | @@ -12721,12 +12948,12 @@ |
| 12721 | 12948 | ** all instances of "first place" or "1st place" regardless of which form |
| 12722 | 12949 | ** the user specified in the MATCH query text. |
| 12723 | 12950 | ** |
| 12724 | 12951 | ** There are several ways to approach this in FTS5: |
| 12725 | 12952 | ** |
| 12726 | | -** <ol><li> By mapping all synonyms to a single token. In this case, the |
| 12727 | | -** In the above example, this means that the tokenizer returns the |
| 12953 | +** <ol><li> By mapping all synonyms to a single token. In this case, using |
| 12954 | +** the above example, this means that the tokenizer returns the |
| 12728 | 12955 | ** same token for inputs "first" and "1st". Say that token is in |
| 12729 | 12956 | ** fact "first", so that when the user inserts the document "I won |
| 12730 | 12957 | ** 1st place" entries are added to the index for tokens "i", "won", |
| 12731 | 12958 | ** "first" and "place". If the user then queries for '1st + place', |
| 12732 | 12959 | ** the tokenizer substitutes "first" for "1st" and the query works |
| | @@ -13394,10 +13621,30 @@ |
| 13394 | 13621 | #else |
| 13395 | 13622 | # define ALWAYS(X) (X) |
| 13396 | 13623 | # define NEVER(X) (X) |
| 13397 | 13624 | #endif |
| 13398 | 13625 | |
| 13626 | +/* |
| 13627 | +** The harmless(X) macro indicates that expression X is usually false |
| 13628 | +** but can be true without causing any problems, but we don't know of |
| 13629 | +** any way to cause X to be true. |
| 13630 | +** |
| 13631 | +** In debugging and testing builds, this macro will abort if X is ever |
| 13632 | +** true. In this way, developers are alerted to a possible test case |
| 13633 | +** that causes X to be true. If a harmless macro ever fails, that is |
| 13634 | +** an opportunity to change the macro into a testcase() and add a new |
| 13635 | +** test case to the test suite. |
| 13636 | +** |
| 13637 | +** For normal production builds, harmless(X) is a no-op, since it does |
| 13638 | +** not matter whether expression X is true or false. |
| 13639 | +*/ |
| 13640 | +#ifdef SQLITE_DEBUG |
| 13641 | +# define harmless(X) assert(!(X)); |
| 13642 | +#else |
| 13643 | +# define harmless(X) |
| 13644 | +#endif |
| 13645 | + |
| 13399 | 13646 | /* |
| 13400 | 13647 | ** Some conditionals are optimizations only. In other words, if the |
| 13401 | 13648 | ** conditionals are replaced with a constant 1 (true) or 0 (false) then |
| 13402 | 13649 | ** the correct answer is still obtained, though perhaps not as quickly. |
| 13403 | 13650 | ** |
| | @@ -13671,94 +13918,96 @@ |
| 13671 | 13918 | #define TK_UNBOUNDED 90 |
| 13672 | 13919 | #define TK_EXCLUDE 91 |
| 13673 | 13920 | #define TK_GROUPS 92 |
| 13674 | 13921 | #define TK_OTHERS 93 |
| 13675 | 13922 | #define TK_TIES 94 |
| 13676 | | -#define TK_REINDEX 95 |
| 13677 | | -#define TK_RENAME 96 |
| 13678 | | -#define TK_CTIME_KW 97 |
| 13679 | | -#define TK_ANY 98 |
| 13680 | | -#define TK_BITAND 99 |
| 13681 | | -#define TK_BITOR 100 |
| 13682 | | -#define TK_LSHIFT 101 |
| 13683 | | -#define TK_RSHIFT 102 |
| 13684 | | -#define TK_PLUS 103 |
| 13685 | | -#define TK_MINUS 104 |
| 13686 | | -#define TK_STAR 105 |
| 13687 | | -#define TK_SLASH 106 |
| 13688 | | -#define TK_REM 107 |
| 13689 | | -#define TK_CONCAT 108 |
| 13690 | | -#define TK_COLLATE 109 |
| 13691 | | -#define TK_BITNOT 110 |
| 13692 | | -#define TK_ON 111 |
| 13693 | | -#define TK_INDEXED 112 |
| 13694 | | -#define TK_STRING 113 |
| 13695 | | -#define TK_JOIN_KW 114 |
| 13696 | | -#define TK_CONSTRAINT 115 |
| 13697 | | -#define TK_DEFAULT 116 |
| 13698 | | -#define TK_NULL 117 |
| 13699 | | -#define TK_PRIMARY 118 |
| 13700 | | -#define TK_UNIQUE 119 |
| 13701 | | -#define TK_CHECK 120 |
| 13702 | | -#define TK_REFERENCES 121 |
| 13703 | | -#define TK_AUTOINCR 122 |
| 13704 | | -#define TK_INSERT 123 |
| 13705 | | -#define TK_DELETE 124 |
| 13706 | | -#define TK_UPDATE 125 |
| 13707 | | -#define TK_SET 126 |
| 13708 | | -#define TK_DEFERRABLE 127 |
| 13709 | | -#define TK_FOREIGN 128 |
| 13710 | | -#define TK_DROP 129 |
| 13711 | | -#define TK_UNION 130 |
| 13712 | | -#define TK_ALL 131 |
| 13713 | | -#define TK_EXCEPT 132 |
| 13714 | | -#define TK_INTERSECT 133 |
| 13715 | | -#define TK_SELECT 134 |
| 13716 | | -#define TK_VALUES 135 |
| 13717 | | -#define TK_DISTINCT 136 |
| 13718 | | -#define TK_DOT 137 |
| 13719 | | -#define TK_FROM 138 |
| 13720 | | -#define TK_JOIN 139 |
| 13721 | | -#define TK_USING 140 |
| 13722 | | -#define TK_ORDER 141 |
| 13723 | | -#define TK_GROUP 142 |
| 13724 | | -#define TK_HAVING 143 |
| 13725 | | -#define TK_LIMIT 144 |
| 13726 | | -#define TK_WHERE 145 |
| 13727 | | -#define TK_INTO 146 |
| 13728 | | -#define TK_NOTHING 147 |
| 13729 | | -#define TK_FLOAT 148 |
| 13730 | | -#define TK_BLOB 149 |
| 13731 | | -#define TK_INTEGER 150 |
| 13732 | | -#define TK_VARIABLE 151 |
| 13733 | | -#define TK_CASE 152 |
| 13734 | | -#define TK_WHEN 153 |
| 13735 | | -#define TK_THEN 154 |
| 13736 | | -#define TK_ELSE 155 |
| 13737 | | -#define TK_INDEX 156 |
| 13738 | | -#define TK_ALTER 157 |
| 13739 | | -#define TK_ADD 158 |
| 13740 | | -#define TK_WINDOW 159 |
| 13741 | | -#define TK_OVER 160 |
| 13742 | | -#define TK_FILTER 161 |
| 13743 | | -#define TK_COLUMN 162 |
| 13744 | | -#define TK_AGG_FUNCTION 163 |
| 13745 | | -#define TK_AGG_COLUMN 164 |
| 13746 | | -#define TK_TRUEFALSE 165 |
| 13747 | | -#define TK_ISNOT 166 |
| 13748 | | -#define TK_FUNCTION 167 |
| 13749 | | -#define TK_UMINUS 168 |
| 13750 | | -#define TK_UPLUS 169 |
| 13751 | | -#define TK_TRUTH 170 |
| 13752 | | -#define TK_REGISTER 171 |
| 13753 | | -#define TK_VECTOR 172 |
| 13754 | | -#define TK_SELECT_COLUMN 173 |
| 13755 | | -#define TK_IF_NULL_ROW 174 |
| 13756 | | -#define TK_ASTERISK 175 |
| 13757 | | -#define TK_SPAN 176 |
| 13758 | | -#define TK_SPACE 177 |
| 13759 | | -#define TK_ILLEGAL 178 |
| 13923 | +#define TK_GENERATED 95 |
| 13924 | +#define TK_ALWAYS 96 |
| 13925 | +#define TK_REINDEX 97 |
| 13926 | +#define TK_RENAME 98 |
| 13927 | +#define TK_CTIME_KW 99 |
| 13928 | +#define TK_ANY 100 |
| 13929 | +#define TK_BITAND 101 |
| 13930 | +#define TK_BITOR 102 |
| 13931 | +#define TK_LSHIFT 103 |
| 13932 | +#define TK_RSHIFT 104 |
| 13933 | +#define TK_PLUS 105 |
| 13934 | +#define TK_MINUS 106 |
| 13935 | +#define TK_STAR 107 |
| 13936 | +#define TK_SLASH 108 |
| 13937 | +#define TK_REM 109 |
| 13938 | +#define TK_CONCAT 110 |
| 13939 | +#define TK_COLLATE 111 |
| 13940 | +#define TK_BITNOT 112 |
| 13941 | +#define TK_ON 113 |
| 13942 | +#define TK_INDEXED 114 |
| 13943 | +#define TK_STRING 115 |
| 13944 | +#define TK_JOIN_KW 116 |
| 13945 | +#define TK_CONSTRAINT 117 |
| 13946 | +#define TK_DEFAULT 118 |
| 13947 | +#define TK_NULL 119 |
| 13948 | +#define TK_PRIMARY 120 |
| 13949 | +#define TK_UNIQUE 121 |
| 13950 | +#define TK_CHECK 122 |
| 13951 | +#define TK_REFERENCES 123 |
| 13952 | +#define TK_AUTOINCR 124 |
| 13953 | +#define TK_INSERT 125 |
| 13954 | +#define TK_DELETE 126 |
| 13955 | +#define TK_UPDATE 127 |
| 13956 | +#define TK_SET 128 |
| 13957 | +#define TK_DEFERRABLE 129 |
| 13958 | +#define TK_FOREIGN 130 |
| 13959 | +#define TK_DROP 131 |
| 13960 | +#define TK_UNION 132 |
| 13961 | +#define TK_ALL 133 |
| 13962 | +#define TK_EXCEPT 134 |
| 13963 | +#define TK_INTERSECT 135 |
| 13964 | +#define TK_SELECT 136 |
| 13965 | +#define TK_VALUES 137 |
| 13966 | +#define TK_DISTINCT 138 |
| 13967 | +#define TK_DOT 139 |
| 13968 | +#define TK_FROM 140 |
| 13969 | +#define TK_JOIN 141 |
| 13970 | +#define TK_USING 142 |
| 13971 | +#define TK_ORDER 143 |
| 13972 | +#define TK_GROUP 144 |
| 13973 | +#define TK_HAVING 145 |
| 13974 | +#define TK_LIMIT 146 |
| 13975 | +#define TK_WHERE 147 |
| 13976 | +#define TK_INTO 148 |
| 13977 | +#define TK_NOTHING 149 |
| 13978 | +#define TK_FLOAT 150 |
| 13979 | +#define TK_BLOB 151 |
| 13980 | +#define TK_INTEGER 152 |
| 13981 | +#define TK_VARIABLE 153 |
| 13982 | +#define TK_CASE 154 |
| 13983 | +#define TK_WHEN 155 |
| 13984 | +#define TK_THEN 156 |
| 13985 | +#define TK_ELSE 157 |
| 13986 | +#define TK_INDEX 158 |
| 13987 | +#define TK_ALTER 159 |
| 13988 | +#define TK_ADD 160 |
| 13989 | +#define TK_WINDOW 161 |
| 13990 | +#define TK_OVER 162 |
| 13991 | +#define TK_FILTER 163 |
| 13992 | +#define TK_COLUMN 164 |
| 13993 | +#define TK_AGG_FUNCTION 165 |
| 13994 | +#define TK_AGG_COLUMN 166 |
| 13995 | +#define TK_TRUEFALSE 167 |
| 13996 | +#define TK_ISNOT 168 |
| 13997 | +#define TK_FUNCTION 169 |
| 13998 | +#define TK_UMINUS 170 |
| 13999 | +#define TK_UPLUS 171 |
| 14000 | +#define TK_TRUTH 172 |
| 14001 | +#define TK_REGISTER 173 |
| 14002 | +#define TK_VECTOR 174 |
| 14003 | +#define TK_SELECT_COLUMN 175 |
| 14004 | +#define TK_IF_NULL_ROW 176 |
| 14005 | +#define TK_ASTERISK 177 |
| 14006 | +#define TK_SPAN 178 |
| 14007 | +#define TK_SPACE 179 |
| 14008 | +#define TK_ILLEGAL 180 |
| 13760 | 14009 | |
| 13761 | 14010 | /************** End of parse.h ***********************************************/ |
| 13762 | 14011 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 13763 | 14012 | #include <stdio.h> |
| 13764 | 14013 | #include <stdlib.h> |
| | @@ -14352,10 +14601,11 @@ |
| 14352 | 14601 | |
| 14353 | 14602 | /* |
| 14354 | 14603 | ** A bit in a Bitmask |
| 14355 | 14604 | */ |
| 14356 | 14605 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 14606 | +#define MASKBIT64(n) (((u64)1)<<(n)) |
| 14357 | 14607 | #define MASKBIT32(n) (((unsigned int)1)<<(n)) |
| 14358 | 14608 | #define ALLBITS ((Bitmask)-1) |
| 14359 | 14609 | |
| 14360 | 14610 | /* A VList object records a mapping between parameters/variables/wildcards |
| 14361 | 14611 | ** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer |
| | @@ -14678,19 +14928,21 @@ |
| 14678 | 14928 | SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes); |
| 14679 | 14929 | SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags); |
| 14680 | 14930 | SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); |
| 14681 | 14931 | SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags); |
| 14682 | 14932 | SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); |
| 14933 | +SQLITE_PRIVATE void sqlite3BtreeCursorPin(BtCursor*); |
| 14934 | +SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor*); |
| 14683 | 14935 | #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 14684 | 14936 | SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*); |
| 14685 | 14937 | #endif |
| 14686 | 14938 | SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*); |
| 14687 | 14939 | SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); |
| 14688 | 14940 | SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); |
| 14689 | 14941 | SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*); |
| 14690 | 14942 | |
| 14691 | | -SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); |
| 14943 | +SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(sqlite3*,Btree*,int*aRoot,int nRoot,int,int*); |
| 14692 | 14944 | SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); |
| 14693 | 14945 | SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*); |
| 14694 | 14946 | |
| 14695 | 14947 | #ifndef SQLITE_OMIT_INCRBLOB |
| 14696 | 14948 | SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*); |
| | @@ -14707,11 +14959,11 @@ |
| 14707 | 14959 | SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*); |
| 14708 | 14960 | #endif |
| 14709 | 14961 | SQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*); |
| 14710 | 14962 | |
| 14711 | 14963 | #ifndef SQLITE_OMIT_BTREECOUNT |
| 14712 | | -SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *); |
| 14964 | +SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3*, BtCursor*, i64*); |
| 14713 | 14965 | #endif |
| 14714 | 14966 | |
| 14715 | 14967 | #ifdef SQLITE_TEST |
| 14716 | 14968 | SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int); |
| 14717 | 14969 | SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*); |
| | @@ -14964,120 +15216,120 @@ |
| 14964 | 15216 | #define OP_IfNullRow 21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */ |
| 14965 | 15217 | #define OP_SeekLT 22 /* jump, synopsis: key=r[P3@P4] */ |
| 14966 | 15218 | #define OP_SeekLE 23 /* jump, synopsis: key=r[P3@P4] */ |
| 14967 | 15219 | #define OP_SeekGE 24 /* jump, synopsis: key=r[P3@P4] */ |
| 14968 | 15220 | #define OP_SeekGT 25 /* jump, synopsis: key=r[P3@P4] */ |
| 14969 | | -#define OP_IfNoHope 26 /* jump, synopsis: key=r[P3@P4] */ |
| 14970 | | -#define OP_NoConflict 27 /* jump, synopsis: key=r[P3@P4] */ |
| 14971 | | -#define OP_NotFound 28 /* jump, synopsis: key=r[P3@P4] */ |
| 14972 | | -#define OP_Found 29 /* jump, synopsis: key=r[P3@P4] */ |
| 14973 | | -#define OP_SeekRowid 30 /* jump, synopsis: intkey=r[P3] */ |
| 14974 | | -#define OP_NotExists 31 /* jump, synopsis: intkey=r[P3] */ |
| 14975 | | -#define OP_Last 32 /* jump */ |
| 14976 | | -#define OP_IfSmaller 33 /* jump */ |
| 14977 | | -#define OP_SorterSort 34 /* jump */ |
| 14978 | | -#define OP_Sort 35 /* jump */ |
| 14979 | | -#define OP_Rewind 36 /* jump */ |
| 14980 | | -#define OP_IdxLE 37 /* jump, synopsis: key=r[P3@P4] */ |
| 14981 | | -#define OP_IdxGT 38 /* jump, synopsis: key=r[P3@P4] */ |
| 14982 | | -#define OP_IdxLT 39 /* jump, synopsis: key=r[P3@P4] */ |
| 14983 | | -#define OP_IdxGE 40 /* jump, synopsis: key=r[P3@P4] */ |
| 14984 | | -#define OP_RowSetRead 41 /* jump, synopsis: r[P3]=rowset(P1) */ |
| 14985 | | -#define OP_RowSetTest 42 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 15221 | +#define OP_IfNotOpen 26 /* jump, synopsis: if( !csr[P1] ) goto P2 */ |
| 15222 | +#define OP_IfNoHope 27 /* jump, synopsis: key=r[P3@P4] */ |
| 15223 | +#define OP_NoConflict 28 /* jump, synopsis: key=r[P3@P4] */ |
| 15224 | +#define OP_NotFound 29 /* jump, synopsis: key=r[P3@P4] */ |
| 15225 | +#define OP_Found 30 /* jump, synopsis: key=r[P3@P4] */ |
| 15226 | +#define OP_SeekRowid 31 /* jump, synopsis: intkey=r[P3] */ |
| 15227 | +#define OP_NotExists 32 /* jump, synopsis: intkey=r[P3] */ |
| 15228 | +#define OP_Last 33 /* jump */ |
| 15229 | +#define OP_IfSmaller 34 /* jump */ |
| 15230 | +#define OP_SorterSort 35 /* jump */ |
| 15231 | +#define OP_Sort 36 /* jump */ |
| 15232 | +#define OP_Rewind 37 /* jump */ |
| 15233 | +#define OP_IdxLE 38 /* jump, synopsis: key=r[P3@P4] */ |
| 15234 | +#define OP_IdxGT 39 /* jump, synopsis: key=r[P3@P4] */ |
| 15235 | +#define OP_IdxLT 40 /* jump, synopsis: key=r[P3@P4] */ |
| 15236 | +#define OP_IdxGE 41 /* jump, synopsis: key=r[P3@P4] */ |
| 15237 | +#define OP_RowSetRead 42 /* jump, synopsis: r[P3]=rowset(P1) */ |
| 14986 | 15238 | #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 14987 | 15239 | #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 14988 | | -#define OP_Program 45 /* jump */ |
| 14989 | | -#define OP_FkIfZero 46 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ |
| 14990 | | -#define OP_IfPos 47 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 14991 | | -#define OP_IfNotZero 48 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 14992 | | -#define OP_DecrJumpZero 49 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 15240 | +#define OP_RowSetTest 45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 15241 | +#define OP_Program 46 /* jump */ |
| 15242 | +#define OP_FkIfZero 47 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ |
| 15243 | +#define OP_IfPos 48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 15244 | +#define OP_IfNotZero 49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 14993 | 15245 | #define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 14994 | 15246 | #define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 14995 | 15247 | #define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 14996 | 15248 | #define OP_Eq 53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 14997 | 15249 | #define OP_Gt 54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 14998 | 15250 | #define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 14999 | 15251 | #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 15000 | 15252 | #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 15001 | 15253 | #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */ |
| 15002 | | -#define OP_IncrVacuum 59 /* jump */ |
| 15003 | | -#define OP_VNext 60 /* jump */ |
| 15004 | | -#define OP_Init 61 /* jump, synopsis: Start at P2 */ |
| 15005 | | -#define OP_PureFunc0 62 |
| 15006 | | -#define OP_Function0 63 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 15007 | | -#define OP_PureFunc 64 |
| 15008 | | -#define OP_Function 65 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 15009 | | -#define OP_Return 66 |
| 15010 | | -#define OP_EndCoroutine 67 |
| 15011 | | -#define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */ |
| 15012 | | -#define OP_Halt 69 |
| 15013 | | -#define OP_Integer 70 /* synopsis: r[P2]=P1 */ |
| 15014 | | -#define OP_Int64 71 /* synopsis: r[P2]=P4 */ |
| 15015 | | -#define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */ |
| 15016 | | -#define OP_Null 73 /* synopsis: r[P2..P3]=NULL */ |
| 15017 | | -#define OP_SoftNull 74 /* synopsis: r[P1]=NULL */ |
| 15018 | | -#define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */ |
| 15019 | | -#define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 15020 | | -#define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 15021 | | -#define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 15022 | | -#define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */ |
| 15023 | | -#define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */ |
| 15024 | | -#define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */ |
| 15025 | | -#define OP_CollSeq 82 |
| 15026 | | -#define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */ |
| 15027 | | -#define OP_RealAffinity 84 |
| 15028 | | -#define OP_Cast 85 /* synopsis: affinity(r[P1]) */ |
| 15029 | | -#define OP_Permutation 86 |
| 15030 | | -#define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 15031 | | -#define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 15032 | | -#define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 15033 | | -#define OP_Column 90 /* synopsis: r[P3]=PX */ |
| 15034 | | -#define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */ |
| 15035 | | -#define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 15036 | | -#define OP_Count 93 /* synopsis: r[P2]=count() */ |
| 15037 | | -#define OP_ReadCookie 94 |
| 15038 | | -#define OP_SetCookie 95 |
| 15039 | | -#define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */ |
| 15040 | | -#define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */ |
| 15041 | | -#define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */ |
| 15042 | | -#define OP_BitAnd 99 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 15043 | | -#define OP_BitOr 100 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 15044 | | -#define OP_ShiftLeft 101 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 15045 | | -#define OP_ShiftRight 102 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 15046 | | -#define OP_Add 103 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 15047 | | -#define OP_Subtract 104 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 15048 | | -#define OP_Multiply 105 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 15049 | | -#define OP_Divide 106 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 15050 | | -#define OP_Remainder 107 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 15051 | | -#define OP_Concat 108 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 15052 | | -#define OP_OpenDup 109 |
| 15053 | | -#define OP_BitNot 110 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 15054 | | -#define OP_OpenAutoindex 111 /* synopsis: nColumn=P2 */ |
| 15055 | | -#define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */ |
| 15056 | | -#define OP_String8 113 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 15057 | | -#define OP_SorterOpen 114 |
| 15058 | | -#define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 15059 | | -#define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */ |
| 15060 | | -#define OP_Close 117 |
| 15061 | | -#define OP_ColumnsUsed 118 |
| 15062 | | -#define OP_SeekHit 119 /* synopsis: seekHit=P2 */ |
| 15063 | | -#define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 15064 | | -#define OP_NewRowid 121 /* synopsis: r[P2]=rowid */ |
| 15065 | | -#define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 15066 | | -#define OP_Delete 123 |
| 15067 | | -#define OP_ResetCount 124 |
| 15068 | | -#define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 15069 | | -#define OP_SorterData 126 /* synopsis: r[P2]=data */ |
| 15070 | | -#define OP_RowData 127 /* synopsis: r[P2]=data */ |
| 15071 | | -#define OP_Rowid 128 /* synopsis: r[P2]=rowid */ |
| 15072 | | -#define OP_NullRow 129 |
| 15073 | | -#define OP_SeekEnd 130 |
| 15074 | | -#define OP_SorterInsert 131 /* synopsis: key=r[P2] */ |
| 15075 | | -#define OP_IdxInsert 132 /* synopsis: key=r[P2] */ |
| 15076 | | -#define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */ |
| 15077 | | -#define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */ |
| 15078 | | -#define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */ |
| 15254 | +#define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 15255 | +#define OP_IncrVacuum 60 /* jump */ |
| 15256 | +#define OP_VNext 61 /* jump */ |
| 15257 | +#define OP_Init 62 /* jump, synopsis: Start at P2 */ |
| 15258 | +#define OP_PureFunc 63 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 15259 | +#define OP_Function 64 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 15260 | +#define OP_Return 65 |
| 15261 | +#define OP_EndCoroutine 66 |
| 15262 | +#define OP_HaltIfNull 67 /* synopsis: if r[P3]=null halt */ |
| 15263 | +#define OP_Halt 68 |
| 15264 | +#define OP_Integer 69 /* synopsis: r[P2]=P1 */ |
| 15265 | +#define OP_Int64 70 /* synopsis: r[P2]=P4 */ |
| 15266 | +#define OP_String 71 /* synopsis: r[P2]='P4' (len=P1) */ |
| 15267 | +#define OP_Null 72 /* synopsis: r[P2..P3]=NULL */ |
| 15268 | +#define OP_SoftNull 73 /* synopsis: r[P1]=NULL */ |
| 15269 | +#define OP_Blob 74 /* synopsis: r[P2]=P4 (len=P1) */ |
| 15270 | +#define OP_Variable 75 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 15271 | +#define OP_Move 76 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 15272 | +#define OP_Copy 77 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 15273 | +#define OP_SCopy 78 /* synopsis: r[P2]=r[P1] */ |
| 15274 | +#define OP_IntCopy 79 /* synopsis: r[P2]=r[P1] */ |
| 15275 | +#define OP_ResultRow 80 /* synopsis: output=r[P1@P2] */ |
| 15276 | +#define OP_CollSeq 81 |
| 15277 | +#define OP_AddImm 82 /* synopsis: r[P1]=r[P1]+P2 */ |
| 15278 | +#define OP_RealAffinity 83 |
| 15279 | +#define OP_Cast 84 /* synopsis: affinity(r[P1]) */ |
| 15280 | +#define OP_Permutation 85 |
| 15281 | +#define OP_Compare 86 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 15282 | +#define OP_IsTrue 87 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 15283 | +#define OP_Offset 88 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 15284 | +#define OP_Column 89 /* synopsis: r[P3]=PX */ |
| 15285 | +#define OP_Affinity 90 /* synopsis: affinity(r[P1@P2]) */ |
| 15286 | +#define OP_MakeRecord 91 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 15287 | +#define OP_Count 92 /* synopsis: r[P2]=count() */ |
| 15288 | +#define OP_ReadCookie 93 |
| 15289 | +#define OP_SetCookie 94 |
| 15290 | +#define OP_ReopenIdx 95 /* synopsis: root=P2 iDb=P3 */ |
| 15291 | +#define OP_OpenRead 96 /* synopsis: root=P2 iDb=P3 */ |
| 15292 | +#define OP_OpenWrite 97 /* synopsis: root=P2 iDb=P3 */ |
| 15293 | +#define OP_OpenDup 98 |
| 15294 | +#define OP_OpenAutoindex 99 /* synopsis: nColumn=P2 */ |
| 15295 | +#define OP_OpenEphemeral 100 /* synopsis: nColumn=P2 */ |
| 15296 | +#define OP_BitAnd 101 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 15297 | +#define OP_BitOr 102 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 15298 | +#define OP_ShiftLeft 103 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 15299 | +#define OP_ShiftRight 104 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 15300 | +#define OP_Add 105 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 15301 | +#define OP_Subtract 106 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 15302 | +#define OP_Multiply 107 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 15303 | +#define OP_Divide 108 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 15304 | +#define OP_Remainder 109 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 15305 | +#define OP_Concat 110 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 15306 | +#define OP_SorterOpen 111 |
| 15307 | +#define OP_BitNot 112 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 15308 | +#define OP_SequenceTest 113 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 15309 | +#define OP_OpenPseudo 114 /* synopsis: P3 columns in r[P2] */ |
| 15310 | +#define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 15311 | +#define OP_Close 116 |
| 15312 | +#define OP_ColumnsUsed 117 |
| 15313 | +#define OP_SeekHit 118 /* synopsis: seekHit=P2 */ |
| 15314 | +#define OP_Sequence 119 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 15315 | +#define OP_NewRowid 120 /* synopsis: r[P2]=rowid */ |
| 15316 | +#define OP_Insert 121 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 15317 | +#define OP_Delete 122 |
| 15318 | +#define OP_ResetCount 123 |
| 15319 | +#define OP_SorterCompare 124 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 15320 | +#define OP_SorterData 125 /* synopsis: r[P2]=data */ |
| 15321 | +#define OP_RowData 126 /* synopsis: r[P2]=data */ |
| 15322 | +#define OP_Rowid 127 /* synopsis: r[P2]=rowid */ |
| 15323 | +#define OP_NullRow 128 |
| 15324 | +#define OP_SeekEnd 129 |
| 15325 | +#define OP_SorterInsert 130 /* synopsis: key=r[P2] */ |
| 15326 | +#define OP_IdxInsert 131 /* synopsis: key=r[P2] */ |
| 15327 | +#define OP_IdxDelete 132 /* synopsis: key=r[P2@P3] */ |
| 15328 | +#define OP_DeferredSeek 133 /* synopsis: Move P3 to P1.rowid if needed */ |
| 15329 | +#define OP_IdxRowid 134 /* synopsis: r[P2]=rowid */ |
| 15330 | +#define OP_FinishSeek 135 |
| 15079 | 15331 | #define OP_Destroy 136 |
| 15080 | 15332 | #define OP_Clear 137 |
| 15081 | 15333 | #define OP_ResetSorter 138 |
| 15082 | 15334 | #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ |
| 15083 | 15335 | #define OP_SqlExec 140 |
| | @@ -15086,35 +15338,38 @@ |
| 15086 | 15338 | #define OP_DropTable 143 |
| 15087 | 15339 | #define OP_DropIndex 144 |
| 15088 | 15340 | #define OP_DropTrigger 145 |
| 15089 | 15341 | #define OP_IntegrityCk 146 |
| 15090 | 15342 | #define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */ |
| 15091 | | -#define OP_Real 148 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 15092 | | -#define OP_Param 149 |
| 15093 | | -#define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */ |
| 15343 | +#define OP_Param 148 |
| 15344 | +#define OP_FkCounter 149 /* synopsis: fkctr[P1]+=P2 */ |
| 15345 | +#define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 15094 | 15346 | #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 15095 | 15347 | #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 15096 | 15348 | #define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ |
| 15097 | 15349 | #define OP_AggStep 154 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15098 | 15350 | #define OP_AggStep1 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15099 | 15351 | #define OP_AggValue 156 /* synopsis: r[P3]=value N=P2 */ |
| 15100 | 15352 | #define OP_AggFinal 157 /* synopsis: accum=r[P1] N=P2 */ |
| 15101 | 15353 | #define OP_Expire 158 |
| 15102 | | -#define OP_TableLock 159 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 15103 | | -#define OP_VBegin 160 |
| 15104 | | -#define OP_VCreate 161 |
| 15105 | | -#define OP_VDestroy 162 |
| 15106 | | -#define OP_VOpen 163 |
| 15107 | | -#define OP_VColumn 164 /* synopsis: r[P3]=vcolumn(P2) */ |
| 15108 | | -#define OP_VRename 165 |
| 15109 | | -#define OP_Pagecount 166 |
| 15110 | | -#define OP_MaxPgcnt 167 |
| 15111 | | -#define OP_Trace 168 |
| 15112 | | -#define OP_CursorHint 169 |
| 15113 | | -#define OP_Noop 170 |
| 15114 | | -#define OP_Explain 171 |
| 15115 | | -#define OP_Abortable 172 |
| 15354 | +#define OP_CursorLock 159 |
| 15355 | +#define OP_CursorUnlock 160 |
| 15356 | +#define OP_TableLock 161 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 15357 | +#define OP_VBegin 162 |
| 15358 | +#define OP_VCreate 163 |
| 15359 | +#define OP_VDestroy 164 |
| 15360 | +#define OP_VOpen 165 |
| 15361 | +#define OP_VColumn 166 /* synopsis: r[P3]=vcolumn(P2) */ |
| 15362 | +#define OP_VRename 167 |
| 15363 | +#define OP_Pagecount 168 |
| 15364 | +#define OP_MaxPgcnt 169 |
| 15365 | +#define OP_Trace 170 |
| 15366 | +#define OP_CursorHint 171 |
| 15367 | +#define OP_ReleaseReg 172 /* synopsis: release r[P1@P2] mask P3 */ |
| 15368 | +#define OP_Noop 173 |
| 15369 | +#define OP_Explain 174 |
| 15370 | +#define OP_Abortable 175 |
| 15116 | 15371 | |
| 15117 | 15372 | /* Properties such as "out2" or "jump" that are specified in |
| 15118 | 15373 | ** comments following the "case" for each opcode in the vdbe.c |
| 15119 | 15374 | ** are encoded into bitvectors as follows: |
| 15120 | 15375 | */ |
| | @@ -15126,37 +15381,38 @@ |
| 15126 | 15381 | #define OPFLG_OUT3 0x20 /* out3: P3 is an output */ |
| 15127 | 15382 | #define OPFLG_INITIALIZER {\ |
| 15128 | 15383 | /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\ |
| 15129 | 15384 | /* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\ |
| 15130 | 15385 | /* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\ |
| 15131 | | -/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ |
| 15132 | | -/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 15133 | | -/* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\ |
| 15386 | +/* 24 */ 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09, 0x09,\ |
| 15387 | +/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 15388 | +/* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\ |
| 15134 | 15389 | /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 15135 | | -/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\ |
| 15136 | | -/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\ |
| 15137 | | -/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\ |
| 15138 | | -/* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ |
| 15139 | | -/* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 15140 | | -/* 96 */ 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 15141 | | -/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12, 0x00,\ |
| 15142 | | -/* 112 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15143 | | -/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15144 | | -/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\ |
| 15390 | +/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00,\ |
| 15391 | +/* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ |
| 15392 | +/* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ |
| 15393 | +/* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12,\ |
| 15394 | +/* 88 */ 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 15395 | +/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\ |
| 15396 | +/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\ |
| 15397 | +/* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,\ |
| 15398 | +/* 120 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\ |
| 15399 | +/* 128 */ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00,\ |
| 15145 | 15400 | /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 15146 | | -/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x04,\ |
| 15401 | +/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x10, 0x04,\ |
| 15147 | 15402 | /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15148 | | -/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ |
| 15149 | | -/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,} |
| 15403 | +/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15404 | +/* 168 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15405 | +} |
| 15150 | 15406 | |
| 15151 | 15407 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 15152 | 15408 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 15153 | 15409 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 15154 | 15410 | ** generated this include file strives to group all JUMP opcodes |
| 15155 | 15411 | ** together near the beginning of the list. |
| 15156 | 15412 | */ |
| 15157 | | -#define SQLITE_MX_JUMP_OPCODE 61 /* Maximum JUMP opcode */ |
| 15413 | +#define SQLITE_MX_JUMP_OPCODE 62 /* Maximum JUMP opcode */ |
| 15158 | 15414 | |
| 15159 | 15415 | /************** End of opcodes.h *********************************************/ |
| 15160 | 15416 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 15161 | 15417 | |
| 15162 | 15418 | /* |
| | @@ -15168,10 +15424,11 @@ |
| 15168 | 15424 | /* |
| 15169 | 15425 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 15170 | 15426 | ** for a description of what each of these routines does. |
| 15171 | 15427 | */ |
| 15172 | 15428 | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*); |
| 15429 | +SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe*); |
| 15173 | 15430 | SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int); |
| 15174 | 15431 | SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int); |
| 15175 | 15432 | SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int); |
| 15176 | 15433 | SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int); |
| 15177 | 15434 | SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*); |
| | @@ -15178,10 +15435,11 @@ |
| 15178 | 15435 | SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...); |
| 15179 | 15436 | SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); |
| 15180 | 15437 | SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); |
| 15181 | 15438 | SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int); |
| 15182 | 15439 | SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); |
| 15440 | +SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall(Parse*,int,int,int,int,const FuncDef*,int); |
| 15183 | 15441 | SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int); |
| 15184 | 15442 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) |
| 15185 | 15443 | SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N); |
| 15186 | 15444 | SQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p); |
| 15187 | 15445 | #else |
| | @@ -15219,10 +15477,15 @@ |
| 15219 | 15477 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); |
| 15220 | 15478 | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5); |
| 15221 | 15479 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); |
| 15222 | 15480 | SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr); |
| 15223 | 15481 | SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); |
| 15482 | +#ifdef SQLITE_DEBUG |
| 15483 | +SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse*,int addr, int n, u32 mask, int); |
| 15484 | +#else |
| 15485 | +# define sqlite3VdbeReleaseRegisters(P,A,N,M,F) |
| 15486 | +#endif |
| 15224 | 15487 | SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
| 15225 | 15488 | SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type); |
| 15226 | 15489 | SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); |
| 15227 | 15490 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); |
| 15228 | 15491 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| | @@ -15267,13 +15530,12 @@ |
| 15267 | 15530 | SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*); |
| 15268 | 15531 | |
| 15269 | 15532 | typedef int (*RecordCompare)(int,const void*,UnpackedRecord*); |
| 15270 | 15533 | SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); |
| 15271 | 15534 | |
| 15272 | | -#ifndef SQLITE_OMIT_TRIGGER |
| 15273 | 15535 | SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 15274 | | -#endif |
| 15536 | +SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*); |
| 15275 | 15537 | |
| 15276 | 15538 | SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*); |
| 15277 | 15539 | |
| 15278 | 15540 | /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on |
| 15279 | 15541 | ** each VDBE opcode. |
| | @@ -15583,11 +15845,11 @@ |
| 15583 | 15845 | SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*); |
| 15584 | 15846 | #ifdef SQLITE_DEBUG |
| 15585 | 15847 | SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*); |
| 15586 | 15848 | #endif |
| 15587 | 15849 | SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*); |
| 15588 | | -SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int); |
| 15850 | +SQLITE_PRIVATE const char *sqlite3PagerFilename(const Pager*, int); |
| 15589 | 15851 | SQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager*); |
| 15590 | 15852 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); |
| 15591 | 15853 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*); |
| 15592 | 15854 | SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); |
| 15593 | 15855 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| | @@ -16303,25 +16565,68 @@ |
| 16303 | 16565 | ** with a particular database connection. Hence, schema information cannot |
| 16304 | 16566 | ** be stored in lookaside because in shared cache mode the schema information |
| 16305 | 16567 | ** is shared by multiple database connections. Therefore, while parsing |
| 16306 | 16568 | ** schema information, the Lookaside.bEnabled flag is cleared so that |
| 16307 | 16569 | ** lookaside allocations are not used to construct the schema objects. |
| 16570 | +** |
| 16571 | +** New lookaside allocations are only allowed if bDisable==0. When |
| 16572 | +** bDisable is greater than zero, sz is set to zero which effectively |
| 16573 | +** disables lookaside without adding a new test for the bDisable flag |
| 16574 | +** in a performance-critical path. sz should be set by to szTrue whenever |
| 16575 | +** bDisable changes back to zero. |
| 16576 | +** |
| 16577 | +** Lookaside buffers are initially held on the pInit list. As they are |
| 16578 | +** used and freed, they are added back to the pFree list. New allocations |
| 16579 | +** come off of pFree first, then pInit as a fallback. This dual-list |
| 16580 | +** allows use to compute a high-water mark - the maximum number of allocations |
| 16581 | +** outstanding at any point in the past - by subtracting the number of |
| 16582 | +** allocations on the pInit list from the total number of allocations. |
| 16583 | +** |
| 16584 | +** Enhancement on 2019-12-12: Two-size-lookaside |
| 16585 | +** The default lookaside configuration is 100 slots of 1200 bytes each. |
| 16586 | +** The larger slot sizes are important for performance, but they waste |
| 16587 | +** a lot of space, as most lookaside allocations are less than 128 bytes. |
| 16588 | +** The two-size-lookaside enhancement breaks up the lookaside allocation |
| 16589 | +** into two pools: One of 128-byte slots and the other of the default size |
| 16590 | +** (1200-byte) slots. Allocations are filled from the small-pool first, |
| 16591 | +** failing over to the full-size pool if that does not work. Thus more |
| 16592 | +** lookaside slots are available while also using less memory. |
| 16593 | +** This enhancement can be omitted by compiling with |
| 16594 | +** SQLITE_OMIT_TWOSIZE_LOOKASIDE. |
| 16308 | 16595 | */ |
| 16309 | 16596 | struct Lookaside { |
| 16310 | 16597 | u32 bDisable; /* Only operate the lookaside when zero */ |
| 16311 | 16598 | u16 sz; /* Size of each buffer in bytes */ |
| 16599 | + u16 szTrue; /* True value of sz, even if disabled */ |
| 16312 | 16600 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 16313 | 16601 | u32 nSlot; /* Number of lookaside slots allocated */ |
| 16314 | 16602 | u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ |
| 16315 | 16603 | LookasideSlot *pInit; /* List of buffers not previously used */ |
| 16316 | 16604 | LookasideSlot *pFree; /* List of available buffers */ |
| 16605 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 16606 | + LookasideSlot *pSmallInit; /* List of small buffers not prediously used */ |
| 16607 | + LookasideSlot *pSmallFree; /* List of available small buffers */ |
| 16608 | + void *pMiddle; /* First byte past end of full-size buffers and |
| 16609 | + ** the first byte of LOOKASIDE_SMALL buffers */ |
| 16610 | +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ |
| 16317 | 16611 | void *pStart; /* First byte of available memory space */ |
| 16318 | 16612 | void *pEnd; /* First byte past end of available space */ |
| 16319 | 16613 | }; |
| 16320 | 16614 | struct LookasideSlot { |
| 16321 | 16615 | LookasideSlot *pNext; /* Next buffer in the list of free buffers */ |
| 16322 | 16616 | }; |
| 16617 | + |
| 16618 | +#define DisableLookaside db->lookaside.bDisable++;db->lookaside.sz=0 |
| 16619 | +#define EnableLookaside db->lookaside.bDisable--;\ |
| 16620 | + db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue |
| 16621 | + |
| 16622 | +/* Size of the smaller allocations in two-size lookside */ |
| 16623 | +#ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 16624 | +# define LOOKASIDE_SMALL 0 |
| 16625 | +#else |
| 16626 | +# define LOOKASIDE_SMALL 128 |
| 16627 | +#endif |
| 16323 | 16628 | |
| 16324 | 16629 | /* |
| 16325 | 16630 | ** A hash table for built-in function definitions. (Application-defined |
| 16326 | 16631 | ** functions use a regular table table from hash.h.) |
| 16327 | 16632 | ** |
| | @@ -16527,10 +16832,17 @@ |
| 16527 | 16832 | ** A macro to discover the encoding of a database. |
| 16528 | 16833 | */ |
| 16529 | 16834 | #define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc) |
| 16530 | 16835 | #define ENC(db) ((db)->enc) |
| 16531 | 16836 | |
| 16837 | +/* |
| 16838 | +** A u64 constant where the lower 32 bits are all zeros. Only the |
| 16839 | +** upper 32 bits are included in the argument. Necessary because some |
| 16840 | +** C-compilers still do not accept LL integer literals. |
| 16841 | +*/ |
| 16842 | +#define HI(X) ((u64)(X)<<32) |
| 16843 | + |
| 16532 | 16844 | /* |
| 16533 | 16845 | ** Possible values for the sqlite3.flags. |
| 16534 | 16846 | ** |
| 16535 | 16847 | ** Value constraints (enforced via assert()): |
| 16536 | 16848 | ** SQLITE_FullFSync == PAGER_FULLFSYNC |
| | @@ -16542,13 +16854,12 @@ |
| 16542 | 16854 | #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */ |
| 16543 | 16855 | #define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */ |
| 16544 | 16856 | #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */ |
| 16545 | 16857 | #define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */ |
| 16546 | 16858 | #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */ |
| 16547 | | -#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */ |
| 16548 | | - /* DELETE, or UPDATE and return */ |
| 16549 | | - /* the count using a callback. */ |
| 16859 | +#define SQLITE_TrustedSchema 0x00000080 /* Allow unsafe functions and |
| 16860 | + ** vtabs in the schema definition */ |
| 16550 | 16861 | #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */ |
| 16551 | 16862 | /* result set is empty */ |
| 16552 | 16863 | #define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */ |
| 16553 | 16864 | #define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */ |
| 16554 | 16865 | #define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */ |
| | @@ -16570,13 +16881,15 @@ |
| 16570 | 16881 | #define SQLITE_NoSchemaError 0x08000000 /* Do not report schema parse errors*/ |
| 16571 | 16882 | #define SQLITE_Defensive 0x10000000 /* Input SQL is likely hostile */ |
| 16572 | 16883 | #define SQLITE_DqsDDL 0x20000000 /* dbl-quoted strings allowed in DDL*/ |
| 16573 | 16884 | #define SQLITE_DqsDML 0x40000000 /* dbl-quoted strings allowed in DML*/ |
| 16574 | 16885 | #define SQLITE_EnableView 0x80000000 /* Enable the use of views */ |
| 16886 | +#define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ |
| 16887 | + /* DELETE, or UPDATE and return */ |
| 16888 | + /* the count using a callback. */ |
| 16575 | 16889 | |
| 16576 | 16890 | /* Flags used only if debugging */ |
| 16577 | | -#define HI(X) ((u64)(X)<<32) |
| 16578 | 16891 | #ifdef SQLITE_DEBUG |
| 16579 | 16892 | #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */ |
| 16580 | 16893 | #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */ |
| 16581 | 16894 | #define SQLITE_VdbeTrace HI(0x0400000) /* True to trace VDBE execution */ |
| 16582 | 16895 | #define SQLITE_VdbeAddopTrace HI(0x0800000) /* Trace sqlite3VdbeAddOp() calls */ |
| | @@ -16590,10 +16903,11 @@ |
| 16590 | 16903 | #define DBFLAG_SchemaChange 0x0001 /* Uncommitted Hash table changes */ |
| 16591 | 16904 | #define DBFLAG_PreferBuiltin 0x0002 /* Preference to built-in funcs */ |
| 16592 | 16905 | #define DBFLAG_Vacuum 0x0004 /* Currently in a VACUUM */ |
| 16593 | 16906 | #define DBFLAG_VacuumInto 0x0008 /* Currently running VACUUM INTO */ |
| 16594 | 16907 | #define DBFLAG_SchemaKnownOk 0x0010 /* Schema is known to be valid */ |
| 16908 | +#define DBFLAG_InternalFunc 0x0020 /* Allow use of internal functions */ |
| 16595 | 16909 | |
| 16596 | 16910 | /* |
| 16597 | 16911 | ** Bits of the sqlite3.dbOptFlags field that are used by the |
| 16598 | 16912 | ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to |
| 16599 | 16913 | ** selectively disable various optimizations. |
| | @@ -16697,10 +17011,11 @@ |
| 16697 | 17011 | ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg |
| 16698 | 17012 | ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG |
| 16699 | 17013 | ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG |
| 16700 | 17014 | ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API |
| 16701 | 17015 | ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API |
| 17016 | +** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS |
| 16702 | 17017 | ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API |
| 16703 | 17018 | */ |
| 16704 | 17019 | #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ |
| 16705 | 17020 | #define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */ |
| 16706 | 17021 | #define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */ |
| | @@ -16713,16 +17028,26 @@ |
| 16713 | 17028 | #define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */ |
| 16714 | 17029 | #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */ |
| 16715 | 17030 | #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ |
| 16716 | 17031 | #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a |
| 16717 | 17032 | ** single query - might change over time */ |
| 16718 | | -#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */ |
| 17033 | +#define SQLITE_FUNC_TEST 0x4000 /* Built-in testing functions */ |
| 16719 | 17034 | #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */ |
| 16720 | 17035 | #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ |
| 16721 | 17036 | #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */ |
| 16722 | 17037 | #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */ |
| 16723 | 17038 | #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */ |
| 17039 | +#define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ |
| 17040 | +#define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */ |
| 17041 | + |
| 17042 | +/* Identifier numbers for each in-line function */ |
| 17043 | +#define INLINEFUNC_coalesce 0 |
| 17044 | +#define INLINEFUNC_implies_nonnull_row 1 |
| 17045 | +#define INLINEFUNC_expr_implies_expr 2 |
| 17046 | +#define INLINEFUNC_expr_compare 3 |
| 17047 | +#define INLINEFUNC_affinity 4 |
| 17048 | +#define INLINEFUNC_unlikely 99 /* Default case */ |
| 16724 | 17049 | |
| 16725 | 17050 | /* |
| 16726 | 17051 | ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |
| 16727 | 17052 | ** used to create the initializers for the FuncDef structures. |
| 16728 | 17053 | ** |
| | @@ -16734,10 +17059,26 @@ |
| 16734 | 17059 | ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. |
| 16735 | 17060 | ** |
| 16736 | 17061 | ** VFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 16737 | 17062 | ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag. |
| 16738 | 17063 | ** |
| 17064 | +** SFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 17065 | +** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and |
| 17066 | +** adds the SQLITE_DIRECTONLY flag. |
| 17067 | +** |
| 17068 | +** INLINE_FUNC(zName, nArg, iFuncId, mFlags) |
| 17069 | +** zName is the name of a function that is implemented by in-line |
| 17070 | +** byte code rather than by the usual callbacks. The iFuncId |
| 17071 | +** parameter determines the function id. The mFlags parameter is |
| 17072 | +** optional SQLITE_FUNC_ flags for this function. |
| 17073 | +** |
| 17074 | +** TEST_FUNC(zName, nArg, iFuncId, mFlags) |
| 17075 | +** zName is the name of a test-only function implemented by in-line |
| 17076 | +** byte code rather than by the usual callbacks. The iFuncId |
| 17077 | +** parameter determines the function id. The mFlags parameter is |
| 17078 | +** optional SQLITE_FUNC_ flags for this function. |
| 17079 | +** |
| 16739 | 17080 | ** DFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 16740 | 17081 | ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and |
| 16741 | 17082 | ** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions |
| 16742 | 17083 | ** and functions like sqlite_version() that can change, but not during |
| 16743 | 17084 | ** a single query. The iArg is ignored. The user-data is always set |
| | @@ -16773,10 +17114,20 @@ |
| 16773 | 17114 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 16774 | 17115 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 16775 | 17116 | #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 16776 | 17117 | {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 16777 | 17118 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17119 | +#define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 17120 | + {nArg, SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \ |
| 17121 | + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17122 | +#define INLINE_FUNC(zName, nArg, iArg, mFlags) \ |
| 17123 | + {nArg, SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ |
| 17124 | + SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } |
| 17125 | +#define TEST_FUNC(zName, nArg, iArg, mFlags) \ |
| 17126 | + {nArg, SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \ |
| 17127 | + SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ |
| 17128 | + SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } |
| 16778 | 17129 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 16779 | 17130 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ |
| 16780 | 17131 | 0, 0, xFunc, 0, 0, 0, #zName, {0} } |
| 16781 | 17132 | #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \ |
| 16782 | 17133 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| | @@ -16788,16 +17139,10 @@ |
| 16788 | 17139 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 16789 | 17140 | pArg, 0, xFunc, 0, 0, 0, #zName, } |
| 16790 | 17141 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 16791 | 17142 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 16792 | 17143 | (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } |
| 16793 | | -#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \ |
| 16794 | | - {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \ |
| 16795 | | - SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}} |
| 16796 | | -#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \ |
| 16797 | | - {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ |
| 16798 | | - SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}} |
| 16799 | 17144 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ |
| 16800 | 17145 | {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ |
| 16801 | 17146 | SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}} |
| 16802 | 17147 | #define INTERNAL_FUNCTION(zName, nArg, xFunc) \ |
| 16803 | 17148 | {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| | @@ -16839,30 +17184,49 @@ |
| 16839 | 17184 | void (*xDestroy)(void *); /* Module destructor function */ |
| 16840 | 17185 | Table *pEpoTab; /* Eponymous table for this module */ |
| 16841 | 17186 | }; |
| 16842 | 17187 | |
| 16843 | 17188 | /* |
| 16844 | | -** information about each column of an SQL table is held in an instance |
| 16845 | | -** of this structure. |
| 17189 | +** Information about each column of an SQL table is held in an instance |
| 17190 | +** of the Column structure, in the Table.aCol[] array. |
| 17191 | +** |
| 17192 | +** Definitions: |
| 17193 | +** |
| 17194 | +** "table column index" This is the index of the column in the |
| 17195 | +** Table.aCol[] array, and also the index of |
| 17196 | +** the column in the original CREATE TABLE stmt. |
| 17197 | +** |
| 17198 | +** "storage column index" This is the index of the column in the |
| 17199 | +** record BLOB generated by the OP_MakeRecord |
| 17200 | +** opcode. The storage column index is less than |
| 17201 | +** or equal to the table column index. It is |
| 17202 | +** equal if and only if there are no VIRTUAL |
| 17203 | +** columns to the left. |
| 16846 | 17204 | */ |
| 16847 | 17205 | struct Column { |
| 16848 | 17206 | char *zName; /* Name of this column, \000, then the type */ |
| 16849 | | - Expr *pDflt; /* Default value of this column */ |
| 17207 | + Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */ |
| 16850 | 17208 | char *zColl; /* Collating sequence. If NULL, use the default */ |
| 16851 | 17209 | u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ |
| 16852 | 17210 | char affinity; /* One of the SQLITE_AFF_... values */ |
| 16853 | 17211 | u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */ |
| 16854 | | - u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */ |
| 17212 | + u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */ |
| 16855 | 17213 | }; |
| 16856 | 17214 | |
| 16857 | 17215 | /* Allowed values for Column.colFlags: |
| 16858 | 17216 | */ |
| 16859 | | -#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
| 16860 | | -#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
| 16861 | | -#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ |
| 16862 | | -#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */ |
| 17217 | +#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
| 17218 | +#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
| 17219 | +#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ |
| 17220 | +#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */ |
| 16863 | 17221 | #define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */ |
| 17222 | +#define COLFLAG_VIRTUAL 0x0020 /* GENERATED ALWAYS AS ... VIRTUAL */ |
| 17223 | +#define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */ |
| 17224 | +#define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */ |
| 17225 | +#define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */ |
| 17226 | +#define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */ |
| 17227 | +#define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */ |
| 16864 | 17228 | |
| 16865 | 17229 | /* |
| 16866 | 17230 | ** A "Collating Sequence" is defined by an instance of the following |
| 16867 | 17231 | ** structure. Conceptually, a collating sequence consists of a name and |
| 16868 | 17232 | ** a comparison routine that defines the order of that sequence. |
| | @@ -16976,13 +17340,20 @@ |
| 16976 | 17340 | sqlite3 *db; /* Database connection associated with this table */ |
| 16977 | 17341 | Module *pMod; /* Pointer to module implementation */ |
| 16978 | 17342 | sqlite3_vtab *pVtab; /* Pointer to vtab instance */ |
| 16979 | 17343 | int nRef; /* Number of pointers to this structure */ |
| 16980 | 17344 | u8 bConstraint; /* True if constraints are supported */ |
| 17345 | + u8 eVtabRisk; /* Riskiness of allowing hacker access */ |
| 16981 | 17346 | int iSavepoint; /* Depth of the SAVEPOINT stack */ |
| 16982 | 17347 | VTable *pNext; /* Next in linked list (see above) */ |
| 16983 | 17348 | }; |
| 17349 | + |
| 17350 | +/* Allowed values for VTable.eVtabRisk |
| 17351 | +*/ |
| 17352 | +#define SQLITE_VTABRISK_Low 0 |
| 17353 | +#define SQLITE_VTABRISK_Normal 1 |
| 17354 | +#define SQLITE_VTABRISK_High 2 |
| 16984 | 17355 | |
| 16985 | 17356 | /* |
| 16986 | 17357 | ** The schema for each SQL table and view is represented in memory |
| 16987 | 17358 | ** by an instance of the following structure. |
| 16988 | 17359 | */ |
| | @@ -16998,10 +17369,11 @@ |
| 16998 | 17369 | int tnum; /* Root BTree page for this table */ |
| 16999 | 17370 | u32 nTabRef; /* Number of pointers to this Table */ |
| 17000 | 17371 | u32 tabFlags; /* Mask of TF_* values */ |
| 17001 | 17372 | i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */ |
| 17002 | 17373 | i16 nCol; /* Number of columns in this table */ |
| 17374 | + i16 nNVCol; /* Number of columns that are not VIRTUAL */ |
| 17003 | 17375 | LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */ |
| 17004 | 17376 | LogEst szTabRow; /* Estimated size of each table row in bytes */ |
| 17005 | 17377 | #ifdef SQLITE_ENABLE_COSTMULT |
| 17006 | 17378 | LogEst costMult; /* Cost multiplier for using this table */ |
| 17007 | 17379 | #endif |
| | @@ -17024,24 +17396,32 @@ |
| 17024 | 17396 | ** |
| 17025 | 17397 | ** TF_OOOHidden applies to tables or view that have hidden columns that are |
| 17026 | 17398 | ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING |
| 17027 | 17399 | ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, |
| 17028 | 17400 | ** the TF_OOOHidden attribute would apply in this case. Such tables require |
| 17029 | | -** special handling during INSERT processing. |
| 17401 | +** special handling during INSERT processing. The "OOO" means "Out Of Order". |
| 17402 | +** |
| 17403 | +** Constraints: |
| 17404 | +** |
| 17405 | +** TF_HasVirtual == COLFLAG_Virtual |
| 17406 | +** TF_HasStored == COLFLAG_Stored |
| 17030 | 17407 | */ |
| 17031 | 17408 | #define TF_Readonly 0x0001 /* Read-only system table */ |
| 17032 | 17409 | #define TF_Ephemeral 0x0002 /* An ephemeral table */ |
| 17033 | 17410 | #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */ |
| 17034 | 17411 | #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */ |
| 17035 | 17412 | #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */ |
| 17036 | | -#define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */ |
| 17037 | | -#define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */ |
| 17038 | | -#define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */ |
| 17413 | +#define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */ |
| 17414 | +#define TF_HasStored 0x0040 /* Has one or more STORED columns */ |
| 17415 | +#define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */ |
| 17416 | +#define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */ |
| 17039 | 17417 | #define TF_StatsUsed 0x0100 /* Query planner decisions affected by |
| 17040 | 17418 | ** Index.aiRowLogEst[] values */ |
| 17041 | | -#define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */ |
| 17042 | | -#define TF_Shadow 0x0400 /* True for a shadow table */ |
| 17419 | +#define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */ |
| 17420 | +#define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */ |
| 17421 | +#define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ |
| 17422 | +#define TF_Shadow 0x1000 /* True for a shadow table */ |
| 17043 | 17423 | |
| 17044 | 17424 | /* |
| 17045 | 17425 | ** Test to see whether or not a table is a virtual table. This is |
| 17046 | 17426 | ** done as a macro so that it will be optimized out when virtual |
| 17047 | 17427 | ** table support is omitted from the build. |
| | @@ -17288,10 +17668,11 @@ |
| 17288 | 17668 | unsigned isCovering:1; /* True if this is a covering index */ |
| 17289 | 17669 | unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ |
| 17290 | 17670 | unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */ |
| 17291 | 17671 | unsigned bNoQuery:1; /* Do not use this index to optimize queries */ |
| 17292 | 17672 | unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */ |
| 17673 | + unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */ |
| 17293 | 17674 | #ifdef SQLITE_ENABLE_STAT4 |
| 17294 | 17675 | int nSample; /* Number of elements in aSample[] */ |
| 17295 | 17676 | int nSampleCol; /* Size of IndexSample.anEq[] and so on */ |
| 17296 | 17677 | tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ |
| 17297 | 17678 | IndexSample *aSample; /* Samples of the left-most key */ |
| | @@ -17479,10 +17860,14 @@ |
| 17479 | 17860 | ** allocated, regardless of whether or not EP_Reduced is set. |
| 17480 | 17861 | */ |
| 17481 | 17862 | struct Expr { |
| 17482 | 17863 | u8 op; /* Operation performed by this node */ |
| 17483 | 17864 | char affExpr; /* affinity, or RAISE type */ |
| 17865 | + u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op |
| 17866 | + ** TK_COLUMN: the value of p5 for OP_Column |
| 17867 | + ** TK_AGG_FUNCTION: nesting depth |
| 17868 | + ** TK_FUNCTION: NC_SelfRef flag if needs OP_PureFunc */ |
| 17484 | 17869 | u32 flags; /* Various flags. EP_* See below */ |
| 17485 | 17870 | union { |
| 17486 | 17871 | char *zToken; /* Token value. Zero terminated and dequoted */ |
| 17487 | 17872 | int iValue; /* Non-negative integer value if EP_IntValue */ |
| 17488 | 17873 | } u; |
| | @@ -17517,13 +17902,10 @@ |
| 17517 | 17902 | ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. |
| 17518 | 17903 | ** TK_VARIABLE: variable number (always >= 1). |
| 17519 | 17904 | ** TK_SELECT_COLUMN: column of the result vector */ |
| 17520 | 17905 | i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ |
| 17521 | 17906 | i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ |
| 17522 | | - u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op |
| 17523 | | - ** TK_COLUMN: the value of p5 for OP_Column |
| 17524 | | - ** TK_AGG_FUNCTION: nesting depth */ |
| 17525 | 17907 | AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ |
| 17526 | 17908 | union { |
| 17527 | 17909 | Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL |
| 17528 | 17910 | ** for a column of an index on an expression */ |
| 17529 | 17911 | Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */ |
| | @@ -17548,11 +17930,11 @@ |
| 17548 | 17930 | #define EP_Agg 0x000010 /* Contains one or more aggregate functions */ |
| 17549 | 17931 | #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */ |
| 17550 | 17932 | #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */ |
| 17551 | 17933 | #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */ |
| 17552 | 17934 | #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */ |
| 17553 | | - /* 0x000200 Available for reuse */ |
| 17935 | +#define EP_Commuted 0x000200 /* Comparison operator has been commuted */ |
| 17554 | 17936 | #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */ |
| 17555 | 17937 | #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */ |
| 17556 | 17938 | #define EP_Skip 0x001000 /* Operator does not contribute to affinity */ |
| 17557 | 17939 | #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
| 17558 | 17940 | #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| | @@ -17569,11 +17951,11 @@ |
| 17569 | 17951 | #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */ |
| 17570 | 17952 | #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */ |
| 17571 | 17953 | #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */ |
| 17572 | 17954 | #define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */ |
| 17573 | 17955 | #define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */ |
| 17574 | | -#define EP_Indirect 0x40000000 /* Contained within a TRIGGER or a VIEW */ |
| 17956 | +#define EP_FromDDL 0x40000000 /* Originates from sqlite_master */ |
| 17575 | 17957 | |
| 17576 | 17958 | /* |
| 17577 | 17959 | ** The EP_Propagate mask is a set of properties that automatically propagate |
| 17578 | 17960 | ** upwards into parent nodes. |
| 17579 | 17961 | */ |
| | @@ -17617,39 +17999,48 @@ |
| 17617 | 17999 | |
| 17618 | 18000 | /* |
| 17619 | 18001 | ** True if the expression passed as an argument was a function with |
| 17620 | 18002 | ** an OVER() clause (a window function). |
| 17621 | 18003 | */ |
| 17622 | | -#define IsWindowFunc(p) ( \ |
| 18004 | +#ifdef SQLITE_OMIT_WINDOWFUNC |
| 18005 | +# define IsWindowFunc(p) 0 |
| 18006 | +#else |
| 18007 | +# define IsWindowFunc(p) ( \ |
| 17623 | 18008 | ExprHasProperty((p), EP_WinFunc) && p->y.pWin->eFrmType!=TK_FILTER \ |
| 17624 | | -) |
| 18009 | + ) |
| 18010 | +#endif |
| 17625 | 18011 | |
| 17626 | 18012 | /* |
| 17627 | 18013 | ** A list of expressions. Each expression may optionally have a |
| 17628 | 18014 | ** name. An expr/name combination can be used in several ways, such |
| 17629 | 18015 | ** as the list of "expr AS ID" fields following a "SELECT" or in the |
| 17630 | 18016 | ** list of "ID = expr" items in an UPDATE. A list of expressions can |
| 17631 | 18017 | ** also be used as the argument to a function, in which case the a.zName |
| 17632 | 18018 | ** field is not used. |
| 17633 | 18019 | ** |
| 17634 | | -** By default the Expr.zSpan field holds a human-readable description of |
| 17635 | | -** the expression that is used in the generation of error messages and |
| 17636 | | -** column labels. In this case, Expr.zSpan is typically the text of a |
| 17637 | | -** column expression as it exists in a SELECT statement. However, if |
| 17638 | | -** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name |
| 17639 | | -** of the result column in the form: DATABASE.TABLE.COLUMN. This later |
| 17640 | | -** form is used for name resolution with nested FROM clauses. |
| 18020 | +** In order to try to keep memory usage down, the Expr.a.zEName field |
| 18021 | +** is used for multiple purposes: |
| 18022 | +** |
| 18023 | +** eEName Usage |
| 18024 | +** ---------- ------------------------- |
| 18025 | +** ENAME_NAME (1) the AS of result set column |
| 18026 | +** (2) COLUMN= of an UPDATE |
| 18027 | +** |
| 18028 | +** ENAME_TAB DB.TABLE.NAME used to resolve names |
| 18029 | +** of subqueries |
| 18030 | +** |
| 18031 | +** ENAME_SPAN Text of the original result set |
| 18032 | +** expression. |
| 17641 | 18033 | */ |
| 17642 | 18034 | struct ExprList { |
| 17643 | 18035 | int nExpr; /* Number of expressions on the list */ |
| 17644 | 18036 | struct ExprList_item { /* For each expression in the list */ |
| 17645 | 18037 | Expr *pExpr; /* The parse tree for this expression */ |
| 17646 | | - char *zName; /* Token associated with this expression */ |
| 17647 | | - char *zSpan; /* Original text of the expression */ |
| 18038 | + char *zEName; /* Token associated with this expression */ |
| 17648 | 18039 | u8 sortFlags; /* Mask of KEYINFO_ORDER_* flags */ |
| 18040 | + unsigned eEName :2; /* Meaning of zEName */ |
| 17649 | 18041 | unsigned done :1; /* A flag to indicate when processing is finished */ |
| 17650 | | - unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */ |
| 17651 | 18042 | unsigned reusable :1; /* Constant expression is reusable */ |
| 17652 | 18043 | unsigned bSorterRef :1; /* Defer evaluation until after sorting */ |
| 17653 | 18044 | unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */ |
| 17654 | 18045 | union { |
| 17655 | 18046 | struct { |
| | @@ -17659,10 +18050,17 @@ |
| 17659 | 18050 | int iConstExprReg; /* Register in which Expr value is cached */ |
| 17660 | 18051 | } u; |
| 17661 | 18052 | } a[1]; /* One slot for each expression in the list */ |
| 17662 | 18053 | }; |
| 17663 | 18054 | |
| 18055 | +/* |
| 18056 | +** Allowed values for Expr.a.eEName |
| 18057 | +*/ |
| 18058 | +#define ENAME_NAME 0 /* The AS clause of a result set */ |
| 18059 | +#define ENAME_SPAN 1 /* Complete text of the result set expression */ |
| 18060 | +#define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ |
| 18061 | + |
| 17664 | 18062 | /* |
| 17665 | 18063 | ** An instance of this structure can hold a simple list of identifiers, |
| 17666 | 18064 | ** such as the list "a,b,c" in the following statements: |
| 17667 | 18065 | ** |
| 17668 | 18066 | ** INSERT INTO t(a,b,c) VALUES ...; |
| | @@ -17722,10 +18120,11 @@ |
| 17722 | 18120 | unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ |
| 17723 | 18121 | unsigned isTabFunc :1; /* True if table-valued-function syntax */ |
| 17724 | 18122 | unsigned isCorrelated :1; /* True if sub-query is correlated */ |
| 17725 | 18123 | unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| 17726 | 18124 | unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 18125 | + unsigned fromDDL :1; /* Comes from sqlite_master */ |
| 17727 | 18126 | } fg; |
| 17728 | 18127 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 17729 | 18128 | Expr *pOn; /* The ON clause of a join */ |
| 17730 | 18129 | IdList *pUsing; /* The USING clause of a join */ |
| 17731 | 18130 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
| | @@ -17825,25 +18224,28 @@ |
| 17825 | 18224 | ** NC_HasAgg == SF_HasAgg == EP_Agg |
| 17826 | 18225 | ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX |
| 17827 | 18226 | ** NC_HasWin == EP_Win |
| 17828 | 18227 | ** |
| 17829 | 18228 | */ |
| 17830 | | -#define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ |
| 17831 | | -#define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */ |
| 17832 | | -#define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ |
| 17833 | | -#define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ |
| 17834 | | -#define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ |
| 17835 | | -#define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ |
| 17836 | | -#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ |
| 17837 | | -#define NC_UEList 0x0080 /* True if uNC.pEList is used */ |
| 17838 | | -#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */ |
| 17839 | | -#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */ |
| 17840 | | -#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ |
| 17841 | | -#define NC_Complex 0x2000 /* True if a function or subquery seen */ |
| 17842 | | -#define NC_AllowWin 0x4000 /* Window functions are allowed here */ |
| 17843 | | -#define NC_HasWin 0x8000 /* One or more window functions seen */ |
| 17844 | | -#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ |
| 18229 | +#define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */ |
| 18230 | +#define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */ |
| 18231 | +#define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */ |
| 18232 | +#define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */ |
| 18233 | +#define NC_HasAgg 0x00010 /* One or more aggregate functions seen */ |
| 18234 | +#define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */ |
| 18235 | +#define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */ |
| 18236 | +#define NC_VarSelect 0x00040 /* A correlated subquery has been seen */ |
| 18237 | +#define NC_UEList 0x00080 /* True if uNC.pEList is used */ |
| 18238 | +#define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */ |
| 18239 | +#define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */ |
| 18240 | +#define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */ |
| 18241 | +#define NC_Complex 0x02000 /* True if a function or subquery seen */ |
| 18242 | +#define NC_AllowWin 0x04000 /* Window functions are allowed here */ |
| 18243 | +#define NC_HasWin 0x08000 /* One or more window functions seen */ |
| 18244 | +#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ |
| 18245 | +#define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */ |
| 18246 | +#define NC_FromDDL 0x40000 /* SQL text comes from sqlite_master */ |
| 17845 | 18247 | |
| 17846 | 18248 | /* |
| 17847 | 18249 | ** An instance of the following object describes a single ON CONFLICT |
| 17848 | 18250 | ** clause in an upsert. |
| 17849 | 18251 | ** |
| | @@ -17889,17 +18291,17 @@ |
| 17889 | 18291 | ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences |
| 17890 | 18292 | ** for the result set. The KeyInfo for addrOpenEphm[2] contains collating |
| 17891 | 18293 | ** sequences for the ORDER BY clause. |
| 17892 | 18294 | */ |
| 17893 | 18295 | struct Select { |
| 17894 | | - ExprList *pEList; /* The fields of the result */ |
| 17895 | 18296 | u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ |
| 17896 | 18297 | LogEst nSelectRow; /* Estimated number of result rows */ |
| 17897 | 18298 | u32 selFlags; /* Various SF_* values */ |
| 17898 | 18299 | int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */ |
| 17899 | 18300 | u32 selId; /* Unique identifier number for this SELECT */ |
| 17900 | 18301 | int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */ |
| 18302 | + ExprList *pEList; /* The fields of the result */ |
| 17901 | 18303 | SrcList *pSrc; /* The FROM clause */ |
| 17902 | 18304 | Expr *pWhere; /* The WHERE clause */ |
| 17903 | 18305 | ExprList *pGroupBy; /* The GROUP BY clause */ |
| 17904 | 18306 | Expr *pHaving; /* The HAVING clause */ |
| 17905 | 18307 | ExprList *pOrderBy; /* The ORDER BY clause */ |
| | @@ -17920,30 +18322,32 @@ |
| 17920 | 18322 | ** Value constraints (all checked via assert()) |
| 17921 | 18323 | ** SF_HasAgg == NC_HasAgg |
| 17922 | 18324 | ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX |
| 17923 | 18325 | ** SF_FixedLimit == WHERE_USE_LIMIT |
| 17924 | 18326 | */ |
| 17925 | | -#define SF_Distinct 0x00001 /* Output should be DISTINCT */ |
| 17926 | | -#define SF_All 0x00002 /* Includes the ALL keyword */ |
| 17927 | | -#define SF_Resolved 0x00004 /* Identifiers have been resolved */ |
| 17928 | | -#define SF_Aggregate 0x00008 /* Contains agg functions or a GROUP BY */ |
| 17929 | | -#define SF_HasAgg 0x00010 /* Contains aggregate functions */ |
| 17930 | | -#define SF_UsesEphemeral 0x00020 /* Uses the OpenEphemeral opcode */ |
| 17931 | | -#define SF_Expanded 0x00040 /* sqlite3SelectExpand() called on this */ |
| 17932 | | -#define SF_HasTypeInfo 0x00080 /* FROM subqueries have Table metadata */ |
| 17933 | | -#define SF_Compound 0x00100 /* Part of a compound query */ |
| 17934 | | -#define SF_Values 0x00200 /* Synthesized from VALUES clause */ |
| 17935 | | -#define SF_MultiValue 0x00400 /* Single VALUES term with multiple rows */ |
| 17936 | | -#define SF_NestedFrom 0x00800 /* Part of a parenthesized FROM clause */ |
| 17937 | | -#define SF_MinMaxAgg 0x01000 /* Aggregate containing min() or max() */ |
| 17938 | | -#define SF_Recursive 0x02000 /* The recursive part of a recursive CTE */ |
| 17939 | | -#define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */ |
| 17940 | | -#define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */ |
| 17941 | | -#define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */ |
| 17942 | | -#define SF_IncludeHidden 0x20000 /* Include hidden columns in output */ |
| 17943 | | -#define SF_ComplexResult 0x40000 /* Result contains subquery or function */ |
| 17944 | | -#define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */ |
| 18327 | +#define SF_Distinct 0x0000001 /* Output should be DISTINCT */ |
| 18328 | +#define SF_All 0x0000002 /* Includes the ALL keyword */ |
| 18329 | +#define SF_Resolved 0x0000004 /* Identifiers have been resolved */ |
| 18330 | +#define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */ |
| 18331 | +#define SF_HasAgg 0x0000010 /* Contains aggregate functions */ |
| 18332 | +#define SF_UsesEphemeral 0x0000020 /* Uses the OpenEphemeral opcode */ |
| 18333 | +#define SF_Expanded 0x0000040 /* sqlite3SelectExpand() called on this */ |
| 18334 | +#define SF_HasTypeInfo 0x0000080 /* FROM subqueries have Table metadata */ |
| 18335 | +#define SF_Compound 0x0000100 /* Part of a compound query */ |
| 18336 | +#define SF_Values 0x0000200 /* Synthesized from VALUES clause */ |
| 18337 | +#define SF_MultiValue 0x0000400 /* Single VALUES term with multiple rows */ |
| 18338 | +#define SF_NestedFrom 0x0000800 /* Part of a parenthesized FROM clause */ |
| 18339 | +#define SF_MinMaxAgg 0x0001000 /* Aggregate containing min() or max() */ |
| 18340 | +#define SF_Recursive 0x0002000 /* The recursive part of a recursive CTE */ |
| 18341 | +#define SF_FixedLimit 0x0004000 /* nSelectRow set by a constant LIMIT */ |
| 18342 | +#define SF_MaybeConvert 0x0008000 /* Need convertCompoundSelectToSubquery() */ |
| 18343 | +#define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */ |
| 18344 | +#define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */ |
| 18345 | +#define SF_ComplexResult 0x0040000 /* Result contains subquery or function */ |
| 18346 | +#define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */ |
| 18347 | +#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ |
| 18348 | +#define SF_View 0x0200000 /* SELECT statement is a view */ |
| 17945 | 18349 | |
| 17946 | 18350 | /* |
| 17947 | 18351 | ** The results of a SELECT can be distributed in several ways, as defined |
| 17948 | 18352 | ** by one of the following macros. The "SRT" prefix means "SELECT Result |
| 17949 | 18353 | ** Type". |
| | @@ -18219,12 +18623,12 @@ |
| 18219 | 18623 | #endif |
| 18220 | 18624 | }; |
| 18221 | 18625 | |
| 18222 | 18626 | #define PARSE_MODE_NORMAL 0 |
| 18223 | 18627 | #define PARSE_MODE_DECLARE_VTAB 1 |
| 18224 | | -#define PARSE_MODE_RENAME_COLUMN 2 |
| 18225 | | -#define PARSE_MODE_RENAME_TABLE 3 |
| 18628 | +#define PARSE_MODE_RENAME 2 |
| 18629 | +#define PARSE_MODE_UNMAP 3 |
| 18226 | 18630 | |
| 18227 | 18631 | /* |
| 18228 | 18632 | ** Sizes and pointers of various parts of the Parse object. |
| 18229 | 18633 | */ |
| 18230 | 18634 | #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/ |
| | @@ -18242,11 +18646,11 @@ |
| 18242 | 18646 | #endif |
| 18243 | 18647 | |
| 18244 | 18648 | #if defined(SQLITE_OMIT_ALTERTABLE) |
| 18245 | 18649 | #define IN_RENAME_OBJECT 0 |
| 18246 | 18650 | #else |
| 18247 | | - #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN) |
| 18651 | + #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME) |
| 18248 | 18652 | #endif |
| 18249 | 18653 | |
| 18250 | 18654 | #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE) |
| 18251 | 18655 | #define IN_SPECIAL_PARSE 0 |
| 18252 | 18656 | #else |
| | @@ -18393,11 +18797,11 @@ |
| 18393 | 18797 | */ |
| 18394 | 18798 | typedef struct DbFixer DbFixer; |
| 18395 | 18799 | struct DbFixer { |
| 18396 | 18800 | Parse *pParse; /* The parsing context. Error messages written here */ |
| 18397 | 18801 | Schema *pSchema; /* Fix items to this schema */ |
| 18398 | | - int bVarOnly; /* Check for variable references only */ |
| 18802 | + u8 bTemp; /* True for TEMP schema entries */ |
| 18399 | 18803 | const char *zDb; /* Make sure all objects are contained in this database */ |
| 18400 | 18804 | const char *zType; /* Type of the container - used for error messages */ |
| 18401 | 18805 | const Token *pName; /* Name of the container - used for error messages */ |
| 18402 | 18806 | }; |
| 18403 | 18807 | |
| | @@ -18498,11 +18902,10 @@ |
| 18498 | 18902 | #endif |
| 18499 | 18903 | #ifndef SQLITE_UNTESTABLE |
| 18500 | 18904 | int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ |
| 18501 | 18905 | #endif |
| 18502 | 18906 | int bLocaltimeFault; /* True to fail localtime() calls */ |
| 18503 | | - int bInternalFunctions; /* Internal SQL functions are visible */ |
| 18504 | 18907 | int iOnceResetThreshold; /* When to reset OP_Once counters */ |
| 18505 | 18908 | u32 szSorterRef; /* Min size in bytes to use sorter-refs */ |
| 18506 | 18909 | unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */ |
| 18507 | 18910 | }; |
| 18508 | 18911 | |
| | @@ -18531,11 +18934,11 @@ |
| 18531 | 18934 | Parse *pParse; /* Parser context. */ |
| 18532 | 18935 | int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */ |
| 18533 | 18936 | int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ |
| 18534 | 18937 | void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ |
| 18535 | 18938 | int walkerDepth; /* Number of subqueries */ |
| 18536 | | - u8 eCode; /* A small processing code */ |
| 18939 | + u16 eCode; /* A small processing code */ |
| 18537 | 18940 | union { /* Extra data for callback */ |
| 18538 | 18941 | NameContext *pNC; /* Naming context */ |
| 18539 | 18942 | int n; /* A counter */ |
| 18540 | 18943 | int iCur; /* A cursor number */ |
| 18541 | 18944 | SrcList *pSrcList; /* FROM clause */ |
| | @@ -18547,10 +18950,11 @@ |
| 18547 | 18950 | ExprList *pGroupBy; /* GROUP BY clause */ |
| 18548 | 18951 | Select *pSelect; /* HAVING to WHERE clause ctx */ |
| 18549 | 18952 | struct WindowRewrite *pRewrite; /* Window rewrite context */ |
| 18550 | 18953 | struct WhereConst *pConst; /* WHERE clause constants */ |
| 18551 | 18954 | struct RenameCtx *pRename; /* RENAME COLUMN context */ |
| 18955 | + struct Table *pTab; /* Table of generated column */ |
| 18552 | 18956 | } u; |
| 18553 | 18957 | }; |
| 18554 | 18958 | |
| 18555 | 18959 | /* Forward declarations */ |
| 18556 | 18960 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); |
| | @@ -18660,11 +19064,11 @@ |
| 18660 | 19064 | SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p); |
| 18661 | 19065 | SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8); |
| 18662 | 19066 | SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*); |
| 18663 | 19067 | SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin); |
| 18664 | 19068 | SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int); |
| 18665 | | -SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*); |
| 19069 | +SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*); |
| 18666 | 19070 | SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); |
| 18667 | 19071 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); |
| 18668 | 19072 | SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*); |
| 18669 | 19073 | SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*); |
| 18670 | 19074 | SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p); |
| | @@ -18926,10 +19330,11 @@ |
| 18926 | 19330 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*); |
| 18927 | 19331 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 18928 | 19332 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 18929 | 19333 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 18930 | 19334 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int); |
| 19335 | +SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,Expr*,FuncDef*); |
| 18931 | 19336 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 18932 | 19337 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 18933 | 19338 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| 18934 | 19339 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 18935 | 19340 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| | @@ -18954,11 +19359,18 @@ |
| 18954 | 19359 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); |
| 18955 | 19360 | SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char); |
| 18956 | 19361 | SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char); |
| 18957 | 19362 | SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int); |
| 18958 | 19363 | SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*); |
| 18959 | | -SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16); |
| 19364 | +SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index*, i16); |
| 19365 | +#ifdef SQLITE_OMIT_GENERATED_COLUMNS |
| 19366 | +# define sqlite3TableColumnToStorage(T,X) (X) /* No-op pass-through */ |
| 19367 | +# define sqlite3StorageColumnToTable(T,X) (X) /* No-op pass-through */ |
| 19368 | +#else |
| 19369 | +SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table*, i16); |
| 19370 | +SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table*, i16); |
| 19371 | +#endif |
| 18960 | 19372 | SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); |
| 18961 | 19373 | #if SQLITE_ENABLE_HIDDEN_COLUMNS |
| 18962 | 19374 | SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*); |
| 18963 | 19375 | #else |
| 18964 | 19376 | # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */ |
| | @@ -18967,10 +19379,11 @@ |
| 18967 | 19379 | SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int); |
| 18968 | 19380 | SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); |
| 18969 | 19381 | SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*); |
| 18970 | 19382 | SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*); |
| 18971 | 19383 | SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); |
| 19384 | +SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*); |
| 18972 | 19385 | SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); |
| 18973 | 19386 | SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, |
| 18974 | 19387 | sqlite3_vfs**,char**,char **); |
| 18975 | 19388 | #ifdef SQLITE_HAS_CODEC |
| 18976 | 19389 | SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*); |
| | @@ -19024,10 +19437,13 @@ |
| 19024 | 19437 | #else |
| 19025 | 19438 | # define sqlite3AutoincrementBegin(X) |
| 19026 | 19439 | # define sqlite3AutoincrementEnd(X) |
| 19027 | 19440 | #endif |
| 19028 | 19441 | SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*); |
| 19442 | +#ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 19443 | +SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(Parse*, int, Table*); |
| 19444 | +#endif |
| 19029 | 19445 | SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); |
| 19030 | 19446 | SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*); |
| 19031 | 19447 | SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); |
| 19032 | 19448 | SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int); |
| 19033 | 19449 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*); |
| | @@ -19046,10 +19462,11 @@ |
| 19046 | 19462 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 19047 | 19463 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 19048 | 19464 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 19049 | 19465 | Expr*,ExprList*,u32,Expr*); |
| 19050 | 19466 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 19467 | +SQLITE_PRIVATE void sqlite3SelectReset(Parse*, Select*); |
| 19051 | 19468 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 19052 | 19469 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); |
| 19053 | 19470 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 19054 | 19471 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 19055 | 19472 | SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*); |
| | @@ -19068,21 +19485,24 @@ |
| 19068 | 19485 | SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*); |
| 19069 | 19486 | SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*); |
| 19070 | 19487 | #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */ |
| 19071 | 19488 | #define ONEPASS_SINGLE 1 /* ONEPASS valid for a single row update */ |
| 19072 | 19489 | #define ONEPASS_MULTI 2 /* ONEPASS is valid for multiple rows */ |
| 19490 | +SQLITE_PRIVATE int sqlite3WhereUsesDeferredSeek(WhereInfo*); |
| 19073 | 19491 | SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int); |
| 19074 | 19492 | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); |
| 19075 | 19493 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
| 19076 | 19494 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 19077 | 19495 | SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int); |
| 19496 | +#ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 19497 | +SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int); |
| 19498 | +#endif |
| 19078 | 19499 | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int); |
| 19079 | 19500 | SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int); |
| 19080 | 19501 | SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int); |
| 19081 | 19502 | SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*); |
| 19082 | 19503 | SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int); |
| 19083 | | -SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int); |
| 19084 | 19504 | SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8); |
| 19085 | 19505 | #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */ |
| 19086 | 19506 | #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */ |
| 19087 | 19507 | #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */ |
| 19088 | 19508 | #define SQLITE_ECEL_OMITREF 0x08 /* Omit if ExprList.u.x.iOrderByCol */ |
| | @@ -19120,10 +19540,11 @@ |
| 19120 | 19540 | SQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int); |
| 19121 | 19541 | SQLITE_PRIVATE void sqlite3EndTransaction(Parse*,int); |
| 19122 | 19542 | SQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*); |
| 19123 | 19543 | SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *); |
| 19124 | 19544 | SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*); |
| 19545 | +SQLITE_PRIVATE u32 sqlite3IsTrueOrFalse(const char*); |
| 19125 | 19546 | SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr*); |
| 19126 | 19547 | SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr*); |
| 19127 | 19548 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); |
| 19128 | 19549 | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*); |
| 19129 | 19550 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| | @@ -19215,10 +19636,11 @@ |
| 19215 | 19636 | # define sqlite3IsToplevel(p) 1 |
| 19216 | 19637 | # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0 |
| 19217 | 19638 | #endif |
| 19218 | 19639 | |
| 19219 | 19640 | SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); |
| 19641 | +SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int); |
| 19220 | 19642 | SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
| 19221 | 19643 | SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int); |
| 19222 | 19644 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 19223 | 19645 | SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*); |
| 19224 | 19646 | SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*); |
| | @@ -19375,11 +19797,16 @@ |
| 19375 | 19797 | SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int); |
| 19376 | 19798 | SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int); |
| 19377 | 19799 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*); |
| 19378 | 19800 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| 19379 | 19801 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| 19380 | | -SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); |
| 19802 | +SQLITE_PRIVATE int sqlite3MatchEName( |
| 19803 | + const struct ExprList_item*, |
| 19804 | + const char*, |
| 19805 | + const char*, |
| 19806 | + const char* |
| 19807 | +); |
| 19381 | 19808 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 19382 | 19809 | SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*); |
| 19383 | 19810 | SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); |
| 19384 | 19811 | SQLITE_PRIVATE int sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); |
| 19385 | 19812 | SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); |
| | @@ -19512,10 +19939,16 @@ |
| 19512 | 19939 | const sqlite3_module*, |
| 19513 | 19940 | void*, |
| 19514 | 19941 | void(*)(void*) |
| 19515 | 19942 | ); |
| 19516 | 19943 | # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) |
| 19944 | +#endif |
| 19945 | +SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); |
| 19946 | +#ifndef SQLITE_OMIT_VIRTUALTABLE |
| 19947 | +SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); |
| 19948 | +#else |
| 19949 | +# define sqlite3ShadowTableName(A,B) 0 |
| 19517 | 19950 | #endif |
| 19518 | 19951 | SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); |
| 19519 | 19952 | SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); |
| 19520 | 19953 | SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); |
| 19521 | 19954 | SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int); |
| | @@ -19534,10 +19967,11 @@ |
| 19534 | 19967 | #ifdef SQLITE_ENABLE_NORMALIZE |
| 19535 | 19968 | SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*); |
| 19536 | 19969 | #endif |
| 19537 | 19970 | SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*); |
| 19538 | 19971 | SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*); |
| 19972 | +SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse*,Expr*); |
| 19539 | 19973 | SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); |
| 19540 | 19974 | SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*); |
| 19541 | 19975 | SQLITE_PRIVATE const char *sqlite3JournalModename(int); |
| 19542 | 19976 | #ifndef SQLITE_OMIT_WAL |
| 19543 | 19977 | SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); |
| | @@ -19840,11 +20274,10 @@ |
| 19840 | 20274 | ** Bit 0x40 is set if the character is non-alphanumeric and can be used in an |
| 19841 | 20275 | ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any |
| 19842 | 20276 | ** non-ASCII UTF character. Hence the test for whether or not a character is |
| 19843 | 20277 | ** part of an identifier is 0x46. |
| 19844 | 20278 | */ |
| 19845 | | -#ifdef SQLITE_ASCII |
| 19846 | 20279 | SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = { |
| 19847 | 20280 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */ |
| 19848 | 20281 | 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */ |
| 19849 | 20282 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10..17 ........ */ |
| 19850 | 20283 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 18..1f ........ */ |
| | @@ -19878,11 +20311,10 @@ |
| 19878 | 20311 | 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /* e0..e7 ........ */ |
| 19879 | 20312 | 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /* e8..ef ........ */ |
| 19880 | 20313 | 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /* f0..f7 ........ */ |
| 19881 | 20314 | 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 /* f8..ff ........ */ |
| 19882 | 20315 | }; |
| 19883 | | -#endif |
| 19884 | 20316 | |
| 19885 | 20317 | /* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards |
| 19886 | 20318 | ** compatibility for legacy applications, the URI filename capability is |
| 19887 | 20319 | ** disabled by default. |
| 19888 | 20320 | ** |
| | @@ -19943,13 +20375,22 @@ |
| 19943 | 20375 | ** number of bytes in each lookaside slot (should be a multiple of 8) |
| 19944 | 20376 | ** and N is the number of slots. The lookaside-configuration can be |
| 19945 | 20377 | ** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE) |
| 19946 | 20378 | ** or at run-time for an individual database connection using |
| 19947 | 20379 | ** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE); |
| 20380 | +** |
| 20381 | +** With the two-size-lookaside enhancement, less lookaside is required. |
| 20382 | +** The default configuration of 1200,40 actually provides 30 1200-byte slots |
| 20383 | +** and 93 128-byte slots, which is more lookaside than is available |
| 20384 | +** using the older 1200,100 configuration without two-size-lookaside. |
| 19948 | 20385 | */ |
| 19949 | 20386 | #ifndef SQLITE_DEFAULT_LOOKASIDE |
| 19950 | | -# define SQLITE_DEFAULT_LOOKASIDE 1200,100 |
| 20387 | +# ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 20388 | +# define SQLITE_DEFAULT_LOOKASIDE 1200,100 /* 120KB of memory */ |
| 20389 | +# else |
| 20390 | +# define SQLITE_DEFAULT_LOOKASIDE 1200,40 /* 48KB of memory */ |
| 20391 | +# endif |
| 19951 | 20392 | #endif |
| 19952 | 20393 | |
| 19953 | 20394 | |
| 19954 | 20395 | /* The default maximum size of an in-memory database created using |
| 19955 | 20396 | ** sqlite3_deserialize() |
| | @@ -20011,11 +20452,10 @@ |
| 20011 | 20452 | #endif |
| 20012 | 20453 | #ifndef SQLITE_UNTESTABLE |
| 20013 | 20454 | 0, /* xTestCallback */ |
| 20014 | 20455 | #endif |
| 20015 | 20456 | 0, /* bLocaltimeFault */ |
| 20016 | | - 0, /* bInternalFunctions */ |
| 20017 | 20457 | 0x7ffffffe, /* iOnceResetThreshold */ |
| 20018 | 20458 | SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */ |
| 20019 | 20459 | 0, /* iPrngSeed */ |
| 20020 | 20460 | }; |
| 20021 | 20461 | |
| | @@ -20376,11 +20816,12 @@ |
| 20376 | 20816 | |
| 20377 | 20817 | /* |
| 20378 | 20818 | ** True if Mem X is a NULL-nochng type. |
| 20379 | 20819 | */ |
| 20380 | 20820 | #define MemNullNochng(X) \ |
| 20381 | | - ((X)->flags==(MEM_Null|MEM_Zero) && (X)->n==0 && (X)->u.nZero==0) |
| 20821 | + (((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \ |
| 20822 | + && (X)->n==0 && (X)->u.nZero==0) |
| 20382 | 20823 | |
| 20383 | 20824 | /* |
| 20384 | 20825 | ** Return true if a memory cell is not marked as invalid. This macro |
| 20385 | 20826 | ** is for use inside assert() statements only. |
| 20386 | 20827 | */ |
| | @@ -20572,10 +21013,11 @@ |
| 20572 | 21013 | ** Function prototypes |
| 20573 | 21014 | */ |
| 20574 | 21015 | SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...); |
| 20575 | 21016 | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*); |
| 20576 | 21017 | void sqliteVdbePopStack(Vdbe*,int); |
| 21018 | +SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor*); |
| 20577 | 21019 | SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*); |
| 20578 | 21020 | SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*); |
| 20579 | 21021 | SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32); |
| 20580 | 21022 | SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8); |
| 20581 | 21023 | SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32); |
| | @@ -20618,11 +21060,11 @@ |
| 20618 | 21060 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); |
| 20619 | 21061 | SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull); |
| 20620 | 21062 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); |
| 20621 | 21063 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 20622 | 21064 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 20623 | | -SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8); |
| 21065 | +SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8); |
| 20624 | 21066 | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*); |
| 20625 | 21067 | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); |
| 20626 | 21068 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); |
| 20627 | 21069 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 20628 | 21070 | SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*); |
| | @@ -20684,11 +21126,11 @@ |
| 20684 | 21126 | # define sqlite3VdbeCheckFk(p,i) 0 |
| 20685 | 21127 | #endif |
| 20686 | 21128 | |
| 20687 | 21129 | #ifdef SQLITE_DEBUG |
| 20688 | 21130 | SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*); |
| 20689 | | -SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); |
| 21131 | +SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr); |
| 20690 | 21132 | #endif |
| 20691 | 21133 | #ifndef SQLITE_OMIT_UTF16 |
| 20692 | 21134 | SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8); |
| 20693 | 21135 | SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem); |
| 20694 | 21136 | #endif |
| | @@ -20876,10 +21318,14 @@ |
| 20876 | 21318 | ** Count the number of slots of lookaside memory that are outstanding |
| 20877 | 21319 | */ |
| 20878 | 21320 | SQLITE_PRIVATE int sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){ |
| 20879 | 21321 | u32 nInit = countLookasideSlots(db->lookaside.pInit); |
| 20880 | 21322 | u32 nFree = countLookasideSlots(db->lookaside.pFree); |
| 21323 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 21324 | + nInit += countLookasideSlots(db->lookaside.pSmallInit); |
| 21325 | + nFree += countLookasideSlots(db->lookaside.pSmallFree); |
| 21326 | +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ |
| 20881 | 21327 | if( pHighwater ) *pHighwater = db->lookaside.nSlot - nInit; |
| 20882 | 21328 | return db->lookaside.nSlot - (nInit+nFree); |
| 20883 | 21329 | } |
| 20884 | 21330 | |
| 20885 | 21331 | /* |
| | @@ -20908,10 +21354,19 @@ |
| 20908 | 21354 | while( p->pNext ) p = p->pNext; |
| 20909 | 21355 | p->pNext = db->lookaside.pInit; |
| 20910 | 21356 | db->lookaside.pInit = db->lookaside.pFree; |
| 20911 | 21357 | db->lookaside.pFree = 0; |
| 20912 | 21358 | } |
| 21359 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 21360 | + p = db->lookaside.pSmallFree; |
| 21361 | + if( p ){ |
| 21362 | + while( p->pNext ) p = p->pNext; |
| 21363 | + p->pNext = db->lookaside.pSmallInit; |
| 21364 | + db->lookaside.pSmallInit = db->lookaside.pSmallFree; |
| 21365 | + db->lookaside.pSmallFree = 0; |
| 21366 | + } |
| 21367 | +#endif |
| 20913 | 21368 | } |
| 20914 | 21369 | break; |
| 20915 | 21370 | } |
| 20916 | 21371 | |
| 20917 | 21372 | case SQLITE_DBSTATUS_LOOKASIDE_HIT: |
| | @@ -21759,11 +22214,11 @@ |
| 21759 | 22214 | */ |
| 21760 | 22215 | if( sqlite3_stricmp(z, "unixepoch")==0 && p->rawS ){ |
| 21761 | 22216 | r = p->s*1000.0 + 210866760000000.0; |
| 21762 | 22217 | if( r>=0.0 && r<464269060800000.0 ){ |
| 21763 | 22218 | clearYMD_HMS_TZ(p); |
| 21764 | | - p->iJD = (sqlite3_int64)r; |
| 22219 | + p->iJD = (sqlite3_int64)(r + 0.5); |
| 21765 | 22220 | p->validJD = 1; |
| 21766 | 22221 | p->rawS = 0; |
| 21767 | 22222 | rc = 0; |
| 21768 | 22223 | } |
| 21769 | 22224 | } |
| | @@ -22538,11 +22993,11 @@ |
| 22538 | 22993 | DO_OS_MALLOC_TEST(0); |
| 22539 | 22994 | /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed |
| 22540 | 22995 | ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, |
| 22541 | 22996 | ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before |
| 22542 | 22997 | ** reaching the VFS. */ |
| 22543 | | - rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); |
| 22998 | + rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x1087f7f, pFlagsOut); |
| 22544 | 22999 | assert( rc==SQLITE_OK || pFile->pMethods==0 ); |
| 22545 | 23000 | return rc; |
| 22546 | 23001 | } |
| 22547 | 23002 | SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ |
| 22548 | 23003 | DO_OS_MALLOC_TEST(0); |
| | @@ -26056,11 +26511,11 @@ |
| 26056 | 26511 | ** May you share freely, never taking more than you give. |
| 26057 | 26512 | ** |
| 26058 | 26513 | ****************************************************************************** |
| 26059 | 26514 | ** |
| 26060 | 26515 | ** This file contains inline asm code for retrieving "high-performance" |
| 26061 | | -** counters for x86 class CPUs. |
| 26516 | +** counters for x86 and x86_64 class CPUs. |
| 26062 | 26517 | */ |
| 26063 | 26518 | #ifndef SQLITE_HWTIME_H |
| 26064 | 26519 | #define SQLITE_HWTIME_H |
| 26065 | 26520 | |
| 26066 | 26521 | /* |
| | @@ -26067,12 +26522,13 @@ |
| 26067 | 26522 | ** The following routine only works on pentium-class (or newer) processors. |
| 26068 | 26523 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 26069 | 26524 | ** processor and returns that value. This can be used for high-res |
| 26070 | 26525 | ** profiling. |
| 26071 | 26526 | */ |
| 26072 | | -#if (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 26073 | | - (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 26527 | +#if !defined(__STRICT_ANSI__) && \ |
| 26528 | + (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 26529 | + (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 26074 | 26530 | |
| 26075 | 26531 | #if defined(__GNUC__) |
| 26076 | 26532 | |
| 26077 | 26533 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 26078 | 26534 | unsigned int lo, hi; |
| | @@ -26089,19 +26545,19 @@ |
| 26089 | 26545 | } |
| 26090 | 26546 | } |
| 26091 | 26547 | |
| 26092 | 26548 | #endif |
| 26093 | 26549 | |
| 26094 | | -#elif (defined(__GNUC__) && defined(__x86_64__)) |
| 26550 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) |
| 26095 | 26551 | |
| 26096 | 26552 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 26097 | 26553 | unsigned long val; |
| 26098 | 26554 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); |
| 26099 | 26555 | return val; |
| 26100 | 26556 | } |
| 26101 | 26557 | |
| 26102 | | -#elif (defined(__GNUC__) && defined(__ppc__)) |
| 26558 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) |
| 26103 | 26559 | |
| 26104 | 26560 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 26105 | 26561 | unsigned long long retval; |
| 26106 | 26562 | unsigned long junk; |
| 26107 | 26563 | __asm__ __volatile__ ("\n\ |
| | @@ -26114,18 +26570,17 @@ |
| 26114 | 26570 | return retval; |
| 26115 | 26571 | } |
| 26116 | 26572 | |
| 26117 | 26573 | #else |
| 26118 | 26574 | |
| 26119 | | - #error Need implementation of sqlite3Hwtime() for your platform. |
| 26120 | | - |
| 26121 | 26575 | /* |
| 26122 | | - ** To compile without implementing sqlite3Hwtime() for your platform, |
| 26123 | | - ** you can remove the above #error and use the following |
| 26124 | | - ** stub function. You will lose timing support for many |
| 26125 | | - ** of the debugging and testing utilities, but it should at |
| 26126 | | - ** least compile and run. |
| 26576 | + ** asm() is needed for hardware timing support. Without asm(), |
| 26577 | + ** disable the sqlite3Hwtime() routine. |
| 26578 | + ** |
| 26579 | + ** sqlite3Hwtime() is only used for some obscure debugging |
| 26580 | + ** and analysis configurations, not in any deliverable, so this |
| 26581 | + ** should not be a great loss. |
| 26127 | 26582 | */ |
| 26128 | 26583 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 26129 | 26584 | |
| 26130 | 26585 | #endif |
| 26131 | 26586 | |
| | @@ -26705,23 +27160,31 @@ |
| 26705 | 27160 | UNUSED_PARAMETER(n); |
| 26706 | 27161 | return 0; |
| 26707 | 27162 | #endif |
| 26708 | 27163 | } |
| 26709 | 27164 | |
| 27165 | +/* |
| 27166 | +** Default value of the hard heap limit. 0 means "no limit". |
| 27167 | +*/ |
| 27168 | +#ifndef SQLITE_MAX_MEMORY |
| 27169 | +# define SQLITE_MAX_MEMORY 0 |
| 27170 | +#endif |
| 27171 | + |
| 26710 | 27172 | /* |
| 26711 | 27173 | ** State information local to the memory allocation subsystem. |
| 26712 | 27174 | */ |
| 26713 | 27175 | static SQLITE_WSD struct Mem0Global { |
| 26714 | 27176 | sqlite3_mutex *mutex; /* Mutex to serialize access */ |
| 26715 | 27177 | sqlite3_int64 alarmThreshold; /* The soft heap limit */ |
| 27178 | + sqlite3_int64 hardLimit; /* The hard upper bound on memory */ |
| 26716 | 27179 | |
| 26717 | 27180 | /* |
| 26718 | 27181 | ** True if heap is nearly "full" where "full" is defined by the |
| 26719 | 27182 | ** sqlite3_soft_heap_limit() setting. |
| 26720 | 27183 | */ |
| 26721 | 27184 | int nearlyFull; |
| 26722 | | -} mem0 = { 0, 0, 0 }; |
| 27185 | +} mem0 = { 0, SQLITE_MAX_MEMORY, SQLITE_MAX_MEMORY, 0 }; |
| 26723 | 27186 | |
| 26724 | 27187 | #define mem0 GLOBAL(struct Mem0Global, mem0) |
| 26725 | 27188 | |
| 26726 | 27189 | /* |
| 26727 | 27190 | ** Return the memory allocator mutex. sqlite3_status() needs it. |
| | @@ -26747,12 +27210,19 @@ |
| 26747 | 27210 | return SQLITE_OK; |
| 26748 | 27211 | } |
| 26749 | 27212 | #endif |
| 26750 | 27213 | |
| 26751 | 27214 | /* |
| 26752 | | -** Set the soft heap-size limit for the library. Passing a zero or |
| 26753 | | -** negative value indicates no limit. |
| 27215 | +** Set the soft heap-size limit for the library. An argument of |
| 27216 | +** zero disables the limit. A negative argument is a no-op used to |
| 27217 | +** obtain the return value. |
| 27218 | +** |
| 27219 | +** The return value is the value of the heap limit just before this |
| 27220 | +** interface was called. |
| 27221 | +** |
| 27222 | +** If the hard heap limit is enabled, then the soft heap limit cannot |
| 27223 | +** be disabled nor raised above the hard heap limit. |
| 26754 | 27224 | */ |
| 26755 | 27225 | SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ |
| 26756 | 27226 | sqlite3_int64 priorLimit; |
| 26757 | 27227 | sqlite3_int64 excess; |
| 26758 | 27228 | sqlite3_int64 nUsed; |
| | @@ -26763,10 +27233,13 @@ |
| 26763 | 27233 | sqlite3_mutex_enter(mem0.mutex); |
| 26764 | 27234 | priorLimit = mem0.alarmThreshold; |
| 26765 | 27235 | if( n<0 ){ |
| 26766 | 27236 | sqlite3_mutex_leave(mem0.mutex); |
| 26767 | 27237 | return priorLimit; |
| 27238 | + } |
| 27239 | + if( mem0.hardLimit>0 && (n>mem0.hardLimit || n==0) ){ |
| 27240 | + n = mem0.hardLimit; |
| 26768 | 27241 | } |
| 26769 | 27242 | mem0.alarmThreshold = n; |
| 26770 | 27243 | nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 26771 | 27244 | mem0.nearlyFull = (n>0 && n<=nUsed); |
| 26772 | 27245 | sqlite3_mutex_leave(mem0.mutex); |
| | @@ -26776,10 +27249,41 @@ |
| 26776 | 27249 | } |
| 26777 | 27250 | SQLITE_API void sqlite3_soft_heap_limit(int n){ |
| 26778 | 27251 | if( n<0 ) n = 0; |
| 26779 | 27252 | sqlite3_soft_heap_limit64(n); |
| 26780 | 27253 | } |
| 27254 | + |
| 27255 | +/* |
| 27256 | +** Set the hard heap-size limit for the library. An argument of zero |
| 27257 | +** disables the hard heap limit. A negative argument is a no-op used |
| 27258 | +** to obtain the return value without affecting the hard heap limit. |
| 27259 | +** |
| 27260 | +** The return value is the value of the hard heap limit just prior to |
| 27261 | +** calling this interface. |
| 27262 | +** |
| 27263 | +** Setting the hard heap limit will also activate the soft heap limit |
| 27264 | +** and constrain the soft heap limit to be no more than the hard heap |
| 27265 | +** limit. |
| 27266 | +*/ |
| 27267 | +SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 n){ |
| 27268 | + sqlite3_int64 priorLimit; |
| 27269 | +#ifndef SQLITE_OMIT_AUTOINIT |
| 27270 | + int rc = sqlite3_initialize(); |
| 27271 | + if( rc ) return -1; |
| 27272 | +#endif |
| 27273 | + sqlite3_mutex_enter(mem0.mutex); |
| 27274 | + priorLimit = mem0.hardLimit; |
| 27275 | + if( n>=0 ){ |
| 27276 | + mem0.hardLimit = n; |
| 27277 | + if( n<mem0.alarmThreshold || mem0.alarmThreshold==0 ){ |
| 27278 | + mem0.alarmThreshold = n; |
| 27279 | + } |
| 27280 | + } |
| 27281 | + sqlite3_mutex_leave(mem0.mutex); |
| 27282 | + return priorLimit; |
| 27283 | +} |
| 27284 | + |
| 26781 | 27285 | |
| 26782 | 27286 | /* |
| 26783 | 27287 | ** Initialize the memory allocation subsystem. |
| 26784 | 27288 | */ |
| 26785 | 27289 | SQLITE_PRIVATE int sqlite3MallocInit(void){ |
| | @@ -26863,23 +27367,23 @@ |
| 26863 | 27367 | ** mode and specifically when the DMD "Dark Matter Detector" is enabled |
| 26864 | 27368 | ** or else a crash results. Hence, do not attempt to optimize out the |
| 26865 | 27369 | ** following xRoundup() call. */ |
| 26866 | 27370 | nFull = sqlite3GlobalConfig.m.xRoundup(n); |
| 26867 | 27371 | |
| 26868 | | -#ifdef SQLITE_MAX_MEMORY |
| 26869 | | - if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){ |
| 26870 | | - *pp = 0; |
| 26871 | | - return; |
| 26872 | | - } |
| 26873 | | -#endif |
| 26874 | | - |
| 26875 | 27372 | sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n); |
| 26876 | 27373 | if( mem0.alarmThreshold>0 ){ |
| 26877 | 27374 | sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 26878 | 27375 | if( nUsed >= mem0.alarmThreshold - nFull ){ |
| 26879 | 27376 | mem0.nearlyFull = 1; |
| 26880 | 27377 | sqlite3MallocAlarm(nFull); |
| 27378 | + if( mem0.hardLimit ){ |
| 27379 | + nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 27380 | + if( nUsed >= mem0.hardLimit - nFull ){ |
| 27381 | + *pp = 0; |
| 27382 | + return; |
| 27383 | + } |
| 27384 | + } |
| 26881 | 27385 | }else{ |
| 26882 | 27386 | mem0.nearlyFull = 0; |
| 26883 | 27387 | } |
| 26884 | 27388 | } |
| 26885 | 27389 | p = sqlite3GlobalConfig.m.xMalloc(nFull); |
| | @@ -26955,28 +27459,46 @@ |
| 26955 | 27459 | ** sqlite3Malloc() or sqlite3_malloc(). |
| 26956 | 27460 | */ |
| 26957 | 27461 | SQLITE_PRIVATE int sqlite3MallocSize(void *p){ |
| 26958 | 27462 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 26959 | 27463 | return sqlite3GlobalConfig.m.xSize(p); |
| 27464 | +} |
| 27465 | +static int lookasideMallocSize(sqlite3 *db, void *p){ |
| 27466 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 27467 | + return p<db->lookaside.pMiddle ? db->lookaside.szTrue : LOOKASIDE_SMALL; |
| 27468 | +#else |
| 27469 | + return db->lookaside.szTrue; |
| 27470 | +#endif |
| 26960 | 27471 | } |
| 26961 | 27472 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ |
| 26962 | 27473 | assert( p!=0 ); |
| 27474 | +#ifdef SQLITE_DEBUG |
| 26963 | 27475 | if( db==0 || !isLookaside(db,p) ){ |
| 26964 | | -#ifdef SQLITE_DEBUG |
| 26965 | 27476 | if( db==0 ){ |
| 26966 | 27477 | assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 26967 | 27478 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 26968 | 27479 | }else{ |
| 26969 | 27480 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 26970 | 27481 | assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 26971 | 27482 | } |
| 27483 | + } |
| 26972 | 27484 | #endif |
| 26973 | | - return sqlite3GlobalConfig.m.xSize(p); |
| 26974 | | - }else{ |
| 26975 | | - assert( sqlite3_mutex_held(db->mutex) ); |
| 26976 | | - return db->lookaside.sz; |
| 27485 | + if( db ){ |
| 27486 | + if( ((uptr)p)<(uptr)(db->lookaside.pEnd) ){ |
| 27487 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 27488 | + if( ((uptr)p)>=(uptr)(db->lookaside.pMiddle) ){ |
| 27489 | + assert( sqlite3_mutex_held(db->mutex) ); |
| 27490 | + return LOOKASIDE_SMALL; |
| 27491 | + } |
| 27492 | +#endif |
| 27493 | + if( ((uptr)p)>=(uptr)(db->lookaside.pStart) ){ |
| 27494 | + assert( sqlite3_mutex_held(db->mutex) ); |
| 27495 | + return db->lookaside.szTrue; |
| 27496 | + } |
| 27497 | + } |
| 26977 | 27498 | } |
| 27499 | + return sqlite3GlobalConfig.m.xSize(p); |
| 26978 | 27500 | } |
| 26979 | 27501 | SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){ |
| 26980 | 27502 | assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 26981 | 27503 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 26982 | 27504 | return p ? sqlite3GlobalConfig.m.xSize(p) : 0; |
| | @@ -27019,19 +27541,31 @@ |
| 27019 | 27541 | if( db ){ |
| 27020 | 27542 | if( db->pnBytesFreed ){ |
| 27021 | 27543 | measureAllocationSize(db, p); |
| 27022 | 27544 | return; |
| 27023 | 27545 | } |
| 27024 | | - if( isLookaside(db, p) ){ |
| 27025 | | - LookasideSlot *pBuf = (LookasideSlot*)p; |
| 27546 | + if( ((uptr)p)<(uptr)(db->lookaside.pEnd) ){ |
| 27547 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 27548 | + if( ((uptr)p)>=(uptr)(db->lookaside.pMiddle) ){ |
| 27549 | + LookasideSlot *pBuf = (LookasideSlot*)p; |
| 27026 | 27550 | #ifdef SQLITE_DEBUG |
| 27027 | | - /* Trash all content in the buffer being freed */ |
| 27028 | | - memset(p, 0xaa, db->lookaside.sz); |
| 27551 | + memset(p, 0xaa, LOOKASIDE_SMALL); /* Trash freed content */ |
| 27029 | 27552 | #endif |
| 27030 | | - pBuf->pNext = db->lookaside.pFree; |
| 27031 | | - db->lookaside.pFree = pBuf; |
| 27032 | | - return; |
| 27553 | + pBuf->pNext = db->lookaside.pSmallFree; |
| 27554 | + db->lookaside.pSmallFree = pBuf; |
| 27555 | + return; |
| 27556 | + } |
| 27557 | +#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ |
| 27558 | + if( ((uptr)p)>=(uptr)(db->lookaside.pStart) ){ |
| 27559 | + LookasideSlot *pBuf = (LookasideSlot*)p; |
| 27560 | +#ifdef SQLITE_DEBUG |
| 27561 | + memset(p, 0xaa, db->lookaside.szTrue); /* Trash freed content */ |
| 27562 | +#endif |
| 27563 | + pBuf->pNext = db->lookaside.pFree; |
| 27564 | + db->lookaside.pFree = pBuf; |
| 27565 | + return; |
| 27566 | + } |
| 27033 | 27567 | } |
| 27034 | 27568 | } |
| 27035 | 27569 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 27036 | 27570 | assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 27037 | 27571 | assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) ); |
| | @@ -27183,27 +27717,41 @@ |
| 27183 | 27717 | #ifndef SQLITE_OMIT_LOOKASIDE |
| 27184 | 27718 | LookasideSlot *pBuf; |
| 27185 | 27719 | assert( db!=0 ); |
| 27186 | 27720 | assert( sqlite3_mutex_held(db->mutex) ); |
| 27187 | 27721 | assert( db->pnBytesFreed==0 ); |
| 27188 | | - if( db->lookaside.bDisable==0 ){ |
| 27189 | | - assert( db->mallocFailed==0 ); |
| 27190 | | - if( n>db->lookaside.sz ){ |
| 27191 | | - db->lookaside.anStat[1]++; |
| 27192 | | - }else if( (pBuf = db->lookaside.pFree)!=0 ){ |
| 27193 | | - db->lookaside.pFree = pBuf->pNext; |
| 27194 | | - db->lookaside.anStat[0]++; |
| 27195 | | - return (void*)pBuf; |
| 27196 | | - }else if( (pBuf = db->lookaside.pInit)!=0 ){ |
| 27197 | | - db->lookaside.pInit = pBuf->pNext; |
| 27198 | | - db->lookaside.anStat[0]++; |
| 27199 | | - return (void*)pBuf; |
| 27200 | | - }else{ |
| 27201 | | - db->lookaside.anStat[2]++; |
| 27202 | | - } |
| 27203 | | - }else if( db->mallocFailed ){ |
| 27204 | | - return 0; |
| 27722 | + if( n>db->lookaside.sz ){ |
| 27723 | + if( !db->lookaside.bDisable ){ |
| 27724 | + db->lookaside.anStat[1]++; |
| 27725 | + }else if( db->mallocFailed ){ |
| 27726 | + return 0; |
| 27727 | + } |
| 27728 | + return dbMallocRawFinish(db, n); |
| 27729 | + } |
| 27730 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 27731 | + if( n<=LOOKASIDE_SMALL ){ |
| 27732 | + if( (pBuf = db->lookaside.pSmallFree)!=0 ){ |
| 27733 | + db->lookaside.pSmallFree = pBuf->pNext; |
| 27734 | + db->lookaside.anStat[0]++; |
| 27735 | + return (void*)pBuf; |
| 27736 | + }else if( (pBuf = db->lookaside.pSmallInit)!=0 ){ |
| 27737 | + db->lookaside.pSmallInit = pBuf->pNext; |
| 27738 | + db->lookaside.anStat[0]++; |
| 27739 | + return (void*)pBuf; |
| 27740 | + } |
| 27741 | + } |
| 27742 | +#endif |
| 27743 | + if( (pBuf = db->lookaside.pFree)!=0 ){ |
| 27744 | + db->lookaside.pFree = pBuf->pNext; |
| 27745 | + db->lookaside.anStat[0]++; |
| 27746 | + return (void*)pBuf; |
| 27747 | + }else if( (pBuf = db->lookaside.pInit)!=0 ){ |
| 27748 | + db->lookaside.pInit = pBuf->pNext; |
| 27749 | + db->lookaside.anStat[0]++; |
| 27750 | + return (void*)pBuf; |
| 27751 | + }else{ |
| 27752 | + db->lookaside.anStat[2]++; |
| 27205 | 27753 | } |
| 27206 | 27754 | #else |
| 27207 | 27755 | assert( db!=0 ); |
| 27208 | 27756 | assert( sqlite3_mutex_held(db->mutex) ); |
| 27209 | 27757 | assert( db->pnBytesFreed==0 ); |
| | @@ -27223,11 +27771,20 @@ |
| 27223 | 27771 | */ |
| 27224 | 27772 | SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){ |
| 27225 | 27773 | assert( db!=0 ); |
| 27226 | 27774 | if( p==0 ) return sqlite3DbMallocRawNN(db, n); |
| 27227 | 27775 | assert( sqlite3_mutex_held(db->mutex) ); |
| 27228 | | - if( isLookaside(db,p) && n<=db->lookaside.sz ) return p; |
| 27776 | + if( ((uptr)p)<(uptr)db->lookaside.pEnd ){ |
| 27777 | +#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 27778 | + if( ((uptr)p)>=(uptr)db->lookaside.pMiddle ){ |
| 27779 | + if( n<=LOOKASIDE_SMALL ) return p; |
| 27780 | + }else |
| 27781 | +#endif |
| 27782 | + if( ((uptr)p)>=(uptr)db->lookaside.pStart ){ |
| 27783 | + if( n<=db->lookaside.szTrue ) return p; |
| 27784 | + } |
| 27785 | + } |
| 27229 | 27786 | return dbReallocFinish(db, p, n); |
| 27230 | 27787 | } |
| 27231 | 27788 | static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){ |
| 27232 | 27789 | void *pNew = 0; |
| 27233 | 27790 | assert( db!=0 ); |
| | @@ -27234,11 +27791,11 @@ |
| 27234 | 27791 | assert( p!=0 ); |
| 27235 | 27792 | if( db->mallocFailed==0 ){ |
| 27236 | 27793 | if( isLookaside(db, p) ){ |
| 27237 | 27794 | pNew = sqlite3DbMallocRawNN(db, n); |
| 27238 | 27795 | if( pNew ){ |
| 27239 | | - memcpy(pNew, p, db->lookaside.sz); |
| 27796 | + memcpy(pNew, p, lookasideMallocSize(db, p)); |
| 27240 | 27797 | sqlite3DbFree(db, p); |
| 27241 | 27798 | } |
| 27242 | 27799 | }else{ |
| 27243 | 27800 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 27244 | 27801 | assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| | @@ -27333,11 +27890,11 @@ |
| 27333 | 27890 | if( db->mallocFailed==0 && db->bBenignMalloc==0 ){ |
| 27334 | 27891 | db->mallocFailed = 1; |
| 27335 | 27892 | if( db->nVdbeExec>0 ){ |
| 27336 | 27893 | db->u1.isInterrupted = 1; |
| 27337 | 27894 | } |
| 27338 | | - db->lookaside.bDisable++; |
| 27895 | + DisableLookaside; |
| 27339 | 27896 | if( db->pParse ){ |
| 27340 | 27897 | db->pParse->rc = SQLITE_NOMEM_BKPT; |
| 27341 | 27898 | } |
| 27342 | 27899 | } |
| 27343 | 27900 | } |
| | @@ -27352,11 +27909,11 @@ |
| 27352 | 27909 | SQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){ |
| 27353 | 27910 | if( db->mallocFailed && db->nVdbeExec==0 ){ |
| 27354 | 27911 | db->mallocFailed = 0; |
| 27355 | 27912 | db->u1.isInterrupted = 0; |
| 27356 | 27913 | assert( db->lookaside.bDisable>0 ); |
| 27357 | | - db->lookaside.bDisable--; |
| 27914 | + EnableLookaside; |
| 27358 | 27915 | } |
| 27359 | 27916 | } |
| 27360 | 27917 | |
| 27361 | 27918 | /* |
| 27362 | 27919 | ** Take actions at the end of an API call to indicate an OOM error |
| | @@ -28760,11 +29317,11 @@ |
| 28760 | 29317 | } |
| 28761 | 29318 | if( zFormat!=0 ){ |
| 28762 | 29319 | va_start(ap, zFormat); |
| 28763 | 29320 | sqlite3_str_vappendf(&acc, zFormat, ap); |
| 28764 | 29321 | va_end(ap); |
| 28765 | | - assert( acc.nChar>0 ); |
| 29322 | + assert( acc.nChar>0 || acc.accError ); |
| 28766 | 29323 | sqlite3_str_append(&acc, "\n", 1); |
| 28767 | 29324 | } |
| 28768 | 29325 | sqlite3StrAccumFinish(&acc); |
| 28769 | 29326 | fprintf(stdout,"%s", zBuf); |
| 28770 | 29327 | fflush(stdout); |
| | @@ -28800,11 +29357,11 @@ |
| 28800 | 29357 | sqlite3_str_appendf(&x, "%s", pCte->zName); |
| 28801 | 29358 | if( pCte->pCols && pCte->pCols->nExpr>0 ){ |
| 28802 | 29359 | char cSep = '('; |
| 28803 | 29360 | int j; |
| 28804 | 29361 | for(j=0; j<pCte->pCols->nExpr; j++){ |
| 28805 | | - sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zName); |
| 29362 | + sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zEName); |
| 28806 | 29363 | cSep = ','; |
| 28807 | 29364 | } |
| 28808 | 29365 | sqlite3_str_appendf(&x, ")"); |
| 28809 | 29366 | } |
| 28810 | 29367 | sqlite3_str_appendf(&x, " AS"); |
| | @@ -28825,11 +29382,11 @@ |
| 28825 | 29382 | for(i=0; i<pSrc->nSrc; i++){ |
| 28826 | 29383 | const struct SrcList_item *pItem = &pSrc->a[i]; |
| 28827 | 29384 | StrAccum x; |
| 28828 | 29385 | char zLine[100]; |
| 28829 | 29386 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 28830 | | - sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor); |
| 29387 | + sqlite3_str_appendf(&x, "{%d:*}", pItem->iCursor); |
| 28831 | 29388 | if( pItem->zDatabase ){ |
| 28832 | 29389 | sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName); |
| 28833 | 29390 | }else if( pItem->zName ){ |
| 28834 | 29391 | sqlite3_str_appendf(&x, " %s", pItem->zName); |
| 28835 | 29392 | } |
| | @@ -28841,10 +29398,13 @@ |
| 28841 | 29398 | sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias); |
| 28842 | 29399 | } |
| 28843 | 29400 | if( pItem->fg.jointype & JT_LEFT ){ |
| 28844 | 29401 | sqlite3_str_appendf(&x, " LEFT-JOIN"); |
| 28845 | 29402 | } |
| 29403 | + if( pItem->fg.fromDDL ){ |
| 29404 | + sqlite3_str_appendf(&x, " DDL"); |
| 29405 | + } |
| 28846 | 29406 | sqlite3StrAccumFinish(&x); |
| 28847 | 29407 | sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); |
| 28848 | 29408 | if( pItem->pSelect ){ |
| 28849 | 29409 | sqlite3TreeViewSelect(pView, pItem->pSelect, 0); |
| 28850 | 29410 | } |
| | @@ -29097,18 +29657,21 @@ |
| 29097 | 29657 | sqlite3TreeViewLine(pView, "nil"); |
| 29098 | 29658 | sqlite3TreeViewPop(pView); |
| 29099 | 29659 | return; |
| 29100 | 29660 | } |
| 29101 | 29661 | if( pExpr->flags || pExpr->affExpr ){ |
| 29662 | + StrAccum x; |
| 29663 | + sqlite3StrAccumInit(&x, 0, zFlgs, sizeof(zFlgs), 0); |
| 29664 | + sqlite3_str_appendf(&x, " fg.af=%x.%c", |
| 29665 | + pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n'); |
| 29102 | 29666 | if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 29103 | | - sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c iRJT=%d", |
| 29104 | | - pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n', |
| 29105 | | - pExpr->iRightJoinTable); |
| 29106 | | - }else{ |
| 29107 | | - sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c", |
| 29108 | | - pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n'); |
| 29667 | + sqlite3_str_appendf(&x, " iRJT=%d", pExpr->iRightJoinTable); |
| 29109 | 29668 | } |
| 29669 | + if( ExprHasProperty(pExpr, EP_FromDDL) ){ |
| 29670 | + sqlite3_str_appendf(&x, " DDL"); |
| 29671 | + } |
| 29672 | + sqlite3StrAccumFinish(&x); |
| 29110 | 29673 | }else{ |
| 29111 | 29674 | zFlgs[0] = 0; |
| 29112 | 29675 | } |
| 29113 | 29676 | switch( pExpr->op ){ |
| 29114 | 29677 | case TK_AGG_COLUMN: { |
| | @@ -29117,14 +29680,22 @@ |
| 29117 | 29680 | break; |
| 29118 | 29681 | } |
| 29119 | 29682 | case TK_COLUMN: { |
| 29120 | 29683 | if( pExpr->iTable<0 ){ |
| 29121 | 29684 | /* This only happens when coding check constraints */ |
| 29122 | | - sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs); |
| 29685 | + char zOp2[16]; |
| 29686 | + if( pExpr->op2 ){ |
| 29687 | + sqlite3_snprintf(sizeof(zOp2),zOp2," op2=0x%02x",pExpr->op2); |
| 29688 | + }else{ |
| 29689 | + zOp2[0] = 0; |
| 29690 | + } |
| 29691 | + sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s", |
| 29692 | + pExpr->iColumn, zFlgs, zOp2); |
| 29123 | 29693 | }else{ |
| 29124 | | - sqlite3TreeViewLine(pView, "{%d:%d}%s", |
| 29125 | | - pExpr->iTable, pExpr->iColumn, zFlgs); |
| 29694 | + sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s", |
| 29695 | + pExpr->iTable, pExpr->iColumn, |
| 29696 | + pExpr->y.pTab, zFlgs); |
| 29126 | 29697 | } |
| 29127 | 29698 | if( ExprHasProperty(pExpr, EP_FixedCol) ){ |
| 29128 | 29699 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 29129 | 29700 | } |
| 29130 | 29701 | break; |
| | @@ -29252,18 +29823,29 @@ |
| 29252 | 29823 | pFarg = 0; |
| 29253 | 29824 | pWin = 0; |
| 29254 | 29825 | }else{ |
| 29255 | 29826 | pFarg = pExpr->x.pList; |
| 29256 | 29827 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 29257 | | - pWin = pExpr->y.pWin; |
| 29828 | + pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; |
| 29258 | 29829 | #else |
| 29259 | 29830 | pWin = 0; |
| 29260 | 29831 | #endif |
| 29261 | 29832 | } |
| 29262 | 29833 | if( pExpr->op==TK_AGG_FUNCTION ){ |
| 29263 | 29834 | sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s", |
| 29264 | 29835 | pExpr->op2, pExpr->u.zToken, zFlgs); |
| 29836 | + }else if( pExpr->op2!=0 ){ |
| 29837 | + const char *zOp2; |
| 29838 | + char zBuf[8]; |
| 29839 | + sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2); |
| 29840 | + zOp2 = zBuf; |
| 29841 | + if( pExpr->op2==NC_IsCheck ) zOp2 = "NC_IsCheck"; |
| 29842 | + if( pExpr->op2==NC_IdxExpr ) zOp2 = "NC_IdxExpr"; |
| 29843 | + if( pExpr->op2==NC_PartIdx ) zOp2 = "NC_PartIdx"; |
| 29844 | + if( pExpr->op2==NC_GenCol ) zOp2 = "NC_GenCol"; |
| 29845 | + sqlite3TreeViewLine(pView, "FUNCTION %Q%s op2=%s", |
| 29846 | + pExpr->u.zToken, zFlgs, zOp2); |
| 29265 | 29847 | }else{ |
| 29266 | 29848 | sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); |
| 29267 | 29849 | } |
| 29268 | 29850 | if( pFarg ){ |
| 29269 | 29851 | sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0); |
| | @@ -29355,11 +29937,13 @@ |
| 29355 | 29937 | pExpr->iTable, pExpr->iColumn, zFlgs); |
| 29356 | 29938 | sqlite3TreeViewExpr(pView, pExpr->pRight, 0); |
| 29357 | 29939 | break; |
| 29358 | 29940 | } |
| 29359 | 29941 | case TK_VECTOR: { |
| 29360 | | - sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR"); |
| 29942 | + char *z = sqlite3_mprintf("VECTOR%s",zFlgs); |
| 29943 | + sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z); |
| 29944 | + sqlite3_free(z); |
| 29361 | 29945 | break; |
| 29362 | 29946 | } |
| 29363 | 29947 | case TK_SELECT_COLUMN: { |
| 29364 | 29948 | sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn); |
| 29365 | 29949 | sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0); |
| | @@ -29401,12 +29985,13 @@ |
| 29401 | 29985 | }else{ |
| 29402 | 29986 | int i; |
| 29403 | 29987 | sqlite3TreeViewLine(pView, "%s", zLabel); |
| 29404 | 29988 | for(i=0; i<pList->nExpr; i++){ |
| 29405 | 29989 | int j = pList->a[i].u.x.iOrderByCol; |
| 29406 | | - char *zName = pList->a[i].zName; |
| 29990 | + char *zName = pList->a[i].zEName; |
| 29407 | 29991 | int moreToFollow = i<pList->nExpr - 1; |
| 29992 | + if( pList->a[i].eEName!=ENAME_NAME ) zName = 0; |
| 29408 | 29993 | if( j || zName ){ |
| 29409 | 29994 | sqlite3TreeViewPush(pView, moreToFollow); |
| 29410 | 29995 | moreToFollow = 0; |
| 29411 | 29996 | sqlite3TreeViewLine(pView, 0); |
| 29412 | 29997 | if( zName ){ |
| | @@ -30069,13 +30654,15 @@ |
| 30069 | 30654 | assert( pMem->enc!=0 ); |
| 30070 | 30655 | assert( pMem->n>=0 ); |
| 30071 | 30656 | |
| 30072 | 30657 | #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) |
| 30073 | 30658 | { |
| 30074 | | - char zBuf[100]; |
| 30075 | | - sqlite3VdbeMemPrettyPrint(pMem, zBuf); |
| 30076 | | - fprintf(stderr, "INPUT: %s\n", zBuf); |
| 30659 | + StrAccum acc; |
| 30660 | + char zBuf[1000]; |
| 30661 | + sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); |
| 30662 | + sqlite3VdbeMemPrettyPrint(pMem, &acc); |
| 30663 | + fprintf(stderr, "INPUT: %s\n", sqlite3StrAccumFinish(&acc)); |
| 30077 | 30664 | } |
| 30078 | 30665 | #endif |
| 30079 | 30666 | |
| 30080 | 30667 | /* If the translation is between UTF-16 little and big endian, then |
| 30081 | 30668 | ** all that is required is to swap the byte order. This case is handled |
| | @@ -30179,13 +30766,15 @@ |
| 30179 | 30766 | pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z); |
| 30180 | 30767 | |
| 30181 | 30768 | translate_out: |
| 30182 | 30769 | #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) |
| 30183 | 30770 | { |
| 30184 | | - char zBuf[100]; |
| 30185 | | - sqlite3VdbeMemPrettyPrint(pMem, zBuf); |
| 30186 | | - fprintf(stderr, "OUTPUT: %s\n", zBuf); |
| 30771 | + StrAccum acc; |
| 30772 | + char zBuf[1000]; |
| 30773 | + sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); |
| 30774 | + sqlite3VdbeMemPrettyPrint(pMem, &acc); |
| 30775 | + fprintf(stderr, "OUTPUT: %s\n", sqlite3StrAccumFinish(&acc)); |
| 30187 | 30776 | } |
| 30188 | 30777 | #endif |
| 30189 | 30778 | return SQLITE_OK; |
| 30190 | 30779 | } |
| 30191 | 30780 | #endif /* SQLITE_OMIT_UTF16 */ |
| | @@ -30406,11 +30995,13 @@ |
| 30406 | 30995 | ** strings, and stuff like that. |
| 30407 | 30996 | ** |
| 30408 | 30997 | */ |
| 30409 | 30998 | /* #include "sqliteInt.h" */ |
| 30410 | 30999 | /* #include <stdarg.h> */ |
| 31000 | +#ifndef SQLITE_OMIT_FLOATING_POINT |
| 30411 | 31001 | #include <math.h> |
| 31002 | +#endif |
| 30412 | 31003 | |
| 30413 | 31004 | /* |
| 30414 | 31005 | ** Routine needed to support the testcase() macro. |
| 30415 | 31006 | */ |
| 30416 | 31007 | #ifdef SQLITE_COVERAGE_TEST |
| | @@ -30581,10 +31172,11 @@ |
| 30581 | 31172 | }else{ |
| 30582 | 31173 | pParse->nErr++; |
| 30583 | 31174 | sqlite3DbFree(db, pParse->zErrMsg); |
| 30584 | 31175 | pParse->zErrMsg = zMsg; |
| 30585 | 31176 | pParse->rc = SQLITE_ERROR; |
| 31177 | + pParse->pWith = 0; |
| 30586 | 31178 | } |
| 30587 | 31179 | } |
| 30588 | 31180 | |
| 30589 | 31181 | /* |
| 30590 | 31182 | ** If database connection db is currently parsing SQL, then transfer |
| | @@ -30771,14 +31363,17 @@ |
| 30771 | 31363 | ** |
| 30772 | 31364 | ** If some prefix of the input string is a valid number, this routine |
| 30773 | 31365 | ** returns FALSE but it still converts the prefix and writes the result |
| 30774 | 31366 | ** into *pResult. |
| 30775 | 31367 | */ |
| 31368 | +#if defined(_MSC_VER) |
| 31369 | +#pragma warning(disable : 4756) |
| 31370 | +#endif |
| 30776 | 31371 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 30777 | 31372 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 30778 | 31373 | int incr; |
| 30779 | | - const char *zEnd = z + length; |
| 31374 | + const char *zEnd; |
| 30780 | 31375 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 30781 | 31376 | int sign = 1; /* sign of significand */ |
| 30782 | 31377 | i64 s = 0; /* significand */ |
| 30783 | 31378 | int d = 0; /* adjust exponent for shifting decimal point */ |
| 30784 | 31379 | int esign = 1; /* sign of exponent */ |
| | @@ -30788,16 +31383,19 @@ |
| 30788 | 31383 | int nDigit = 0; /* Number of digits processed */ |
| 30789 | 31384 | int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ |
| 30790 | 31385 | |
| 30791 | 31386 | assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); |
| 30792 | 31387 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 31388 | + if( length==0 ) return 0; |
| 30793 | 31389 | |
| 30794 | 31390 | if( enc==SQLITE_UTF8 ){ |
| 30795 | 31391 | incr = 1; |
| 31392 | + zEnd = z + length; |
| 30796 | 31393 | }else{ |
| 30797 | 31394 | int i; |
| 30798 | 31395 | incr = 2; |
| 31396 | + length &= ~1; |
| 30799 | 31397 | assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); |
| 30800 | 31398 | testcase( enc==SQLITE_UTF16LE ); |
| 30801 | 31399 | testcase( enc==SQLITE_UTF16BE ); |
| 30802 | 31400 | for(i=3-enc; i<length && z[i]==0; i+=2){} |
| 30803 | 31401 | if( i<length ) eType = -100; |
| | @@ -30958,10 +31556,13 @@ |
| 30958 | 31556 | } |
| 30959 | 31557 | #else |
| 30960 | 31558 | return !sqlite3Atoi64(z, pResult, length, enc); |
| 30961 | 31559 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 30962 | 31560 | } |
| 31561 | +#if defined(_MSC_VER) |
| 31562 | +#pragma warning(default : 4756) |
| 31563 | +#endif |
| 30963 | 31564 | |
| 30964 | 31565 | /* |
| 30965 | 31566 | ** Compare the 19-character string zNum against the text representation |
| 30966 | 31567 | ** value 2^63: 9223372036854775808. Return negative, zero, or positive |
| 30967 | 31568 | ** if zNum is less than, equal to, or greater than the string. |
| | @@ -32328,120 +32929,120 @@ |
| 32328 | 32929 | /* 21 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"), |
| 32329 | 32930 | /* 22 */ "SeekLT" OpHelp("key=r[P3@P4]"), |
| 32330 | 32931 | /* 23 */ "SeekLE" OpHelp("key=r[P3@P4]"), |
| 32331 | 32932 | /* 24 */ "SeekGE" OpHelp("key=r[P3@P4]"), |
| 32332 | 32933 | /* 25 */ "SeekGT" OpHelp("key=r[P3@P4]"), |
| 32333 | | - /* 26 */ "IfNoHope" OpHelp("key=r[P3@P4]"), |
| 32334 | | - /* 27 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 32335 | | - /* 28 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 32336 | | - /* 29 */ "Found" OpHelp("key=r[P3@P4]"), |
| 32337 | | - /* 30 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 32338 | | - /* 31 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 32339 | | - /* 32 */ "Last" OpHelp(""), |
| 32340 | | - /* 33 */ "IfSmaller" OpHelp(""), |
| 32341 | | - /* 34 */ "SorterSort" OpHelp(""), |
| 32342 | | - /* 35 */ "Sort" OpHelp(""), |
| 32343 | | - /* 36 */ "Rewind" OpHelp(""), |
| 32344 | | - /* 37 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 32345 | | - /* 38 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 32346 | | - /* 39 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 32347 | | - /* 40 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 32348 | | - /* 41 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 32349 | | - /* 42 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 32934 | + /* 26 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"), |
| 32935 | + /* 27 */ "IfNoHope" OpHelp("key=r[P3@P4]"), |
| 32936 | + /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 32937 | + /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 32938 | + /* 30 */ "Found" OpHelp("key=r[P3@P4]"), |
| 32939 | + /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 32940 | + /* 32 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 32941 | + /* 33 */ "Last" OpHelp(""), |
| 32942 | + /* 34 */ "IfSmaller" OpHelp(""), |
| 32943 | + /* 35 */ "SorterSort" OpHelp(""), |
| 32944 | + /* 36 */ "Sort" OpHelp(""), |
| 32945 | + /* 37 */ "Rewind" OpHelp(""), |
| 32946 | + /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 32947 | + /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 32948 | + /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 32949 | + /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 32950 | + /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 32350 | 32951 | /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 32351 | 32952 | /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 32352 | | - /* 45 */ "Program" OpHelp(""), |
| 32353 | | - /* 46 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 32354 | | - /* 47 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 32355 | | - /* 48 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 32356 | | - /* 49 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 32953 | + /* 45 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 32954 | + /* 46 */ "Program" OpHelp(""), |
| 32955 | + /* 47 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 32956 | + /* 48 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 32957 | + /* 49 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 32357 | 32958 | /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 32358 | 32959 | /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 32359 | 32960 | /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 32360 | 32961 | /* 53 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 32361 | 32962 | /* 54 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 32362 | 32963 | /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 32363 | 32964 | /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 32364 | 32965 | /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 32365 | 32966 | /* 58 */ "ElseNotEq" OpHelp(""), |
| 32366 | | - /* 59 */ "IncrVacuum" OpHelp(""), |
| 32367 | | - /* 60 */ "VNext" OpHelp(""), |
| 32368 | | - /* 61 */ "Init" OpHelp("Start at P2"), |
| 32369 | | - /* 62 */ "PureFunc0" OpHelp(""), |
| 32370 | | - /* 63 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 32371 | | - /* 64 */ "PureFunc" OpHelp(""), |
| 32372 | | - /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 32373 | | - /* 66 */ "Return" OpHelp(""), |
| 32374 | | - /* 67 */ "EndCoroutine" OpHelp(""), |
| 32375 | | - /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 32376 | | - /* 69 */ "Halt" OpHelp(""), |
| 32377 | | - /* 70 */ "Integer" OpHelp("r[P2]=P1"), |
| 32378 | | - /* 71 */ "Int64" OpHelp("r[P2]=P4"), |
| 32379 | | - /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 32380 | | - /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 32381 | | - /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 32382 | | - /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 32383 | | - /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 32384 | | - /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 32385 | | - /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 32386 | | - /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 32387 | | - /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 32388 | | - /* 81 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 32389 | | - /* 82 */ "CollSeq" OpHelp(""), |
| 32390 | | - /* 83 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 32391 | | - /* 84 */ "RealAffinity" OpHelp(""), |
| 32392 | | - /* 85 */ "Cast" OpHelp("affinity(r[P1])"), |
| 32393 | | - /* 86 */ "Permutation" OpHelp(""), |
| 32394 | | - /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 32395 | | - /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 32396 | | - /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 32397 | | - /* 90 */ "Column" OpHelp("r[P3]=PX"), |
| 32398 | | - /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 32399 | | - /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 32400 | | - /* 93 */ "Count" OpHelp("r[P2]=count()"), |
| 32401 | | - /* 94 */ "ReadCookie" OpHelp(""), |
| 32402 | | - /* 95 */ "SetCookie" OpHelp(""), |
| 32403 | | - /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 32404 | | - /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 32405 | | - /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 32406 | | - /* 99 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 32407 | | - /* 100 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 32408 | | - /* 101 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 32409 | | - /* 102 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 32410 | | - /* 103 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 32411 | | - /* 104 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 32412 | | - /* 105 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 32413 | | - /* 106 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 32414 | | - /* 107 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 32415 | | - /* 108 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 32416 | | - /* 109 */ "OpenDup" OpHelp(""), |
| 32417 | | - /* 110 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 32418 | | - /* 111 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 32419 | | - /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 32420 | | - /* 113 */ "String8" OpHelp("r[P2]='P4'"), |
| 32421 | | - /* 114 */ "SorterOpen" OpHelp(""), |
| 32422 | | - /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 32423 | | - /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 32424 | | - /* 117 */ "Close" OpHelp(""), |
| 32425 | | - /* 118 */ "ColumnsUsed" OpHelp(""), |
| 32426 | | - /* 119 */ "SeekHit" OpHelp("seekHit=P2"), |
| 32427 | | - /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 32428 | | - /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 32429 | | - /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 32430 | | - /* 123 */ "Delete" OpHelp(""), |
| 32431 | | - /* 124 */ "ResetCount" OpHelp(""), |
| 32432 | | - /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 32433 | | - /* 126 */ "SorterData" OpHelp("r[P2]=data"), |
| 32434 | | - /* 127 */ "RowData" OpHelp("r[P2]=data"), |
| 32435 | | - /* 128 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 32436 | | - /* 129 */ "NullRow" OpHelp(""), |
| 32437 | | - /* 130 */ "SeekEnd" OpHelp(""), |
| 32438 | | - /* 131 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 32439 | | - /* 132 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 32440 | | - /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 32441 | | - /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 32442 | | - /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 32967 | + /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 32968 | + /* 60 */ "IncrVacuum" OpHelp(""), |
| 32969 | + /* 61 */ "VNext" OpHelp(""), |
| 32970 | + /* 62 */ "Init" OpHelp("Start at P2"), |
| 32971 | + /* 63 */ "PureFunc" OpHelp("r[P3]=func(r[P2@P5])"), |
| 32972 | + /* 64 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 32973 | + /* 65 */ "Return" OpHelp(""), |
| 32974 | + /* 66 */ "EndCoroutine" OpHelp(""), |
| 32975 | + /* 67 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 32976 | + /* 68 */ "Halt" OpHelp(""), |
| 32977 | + /* 69 */ "Integer" OpHelp("r[P2]=P1"), |
| 32978 | + /* 70 */ "Int64" OpHelp("r[P2]=P4"), |
| 32979 | + /* 71 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 32980 | + /* 72 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 32981 | + /* 73 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 32982 | + /* 74 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 32983 | + /* 75 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 32984 | + /* 76 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 32985 | + /* 77 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 32986 | + /* 78 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 32987 | + /* 79 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 32988 | + /* 80 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 32989 | + /* 81 */ "CollSeq" OpHelp(""), |
| 32990 | + /* 82 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 32991 | + /* 83 */ "RealAffinity" OpHelp(""), |
| 32992 | + /* 84 */ "Cast" OpHelp("affinity(r[P1])"), |
| 32993 | + /* 85 */ "Permutation" OpHelp(""), |
| 32994 | + /* 86 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 32995 | + /* 87 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 32996 | + /* 88 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 32997 | + /* 89 */ "Column" OpHelp("r[P3]=PX"), |
| 32998 | + /* 90 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 32999 | + /* 91 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 33000 | + /* 92 */ "Count" OpHelp("r[P2]=count()"), |
| 33001 | + /* 93 */ "ReadCookie" OpHelp(""), |
| 33002 | + /* 94 */ "SetCookie" OpHelp(""), |
| 33003 | + /* 95 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 33004 | + /* 96 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 33005 | + /* 97 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 33006 | + /* 98 */ "OpenDup" OpHelp(""), |
| 33007 | + /* 99 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 33008 | + /* 100 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 33009 | + /* 101 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 33010 | + /* 102 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 33011 | + /* 103 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 33012 | + /* 104 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 33013 | + /* 105 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 33014 | + /* 106 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 33015 | + /* 107 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 33016 | + /* 108 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 33017 | + /* 109 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 33018 | + /* 110 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 33019 | + /* 111 */ "SorterOpen" OpHelp(""), |
| 33020 | + /* 112 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 33021 | + /* 113 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 33022 | + /* 114 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 33023 | + /* 115 */ "String8" OpHelp("r[P2]='P4'"), |
| 33024 | + /* 116 */ "Close" OpHelp(""), |
| 33025 | + /* 117 */ "ColumnsUsed" OpHelp(""), |
| 33026 | + /* 118 */ "SeekHit" OpHelp("seekHit=P2"), |
| 33027 | + /* 119 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 33028 | + /* 120 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 33029 | + /* 121 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 33030 | + /* 122 */ "Delete" OpHelp(""), |
| 33031 | + /* 123 */ "ResetCount" OpHelp(""), |
| 33032 | + /* 124 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 33033 | + /* 125 */ "SorterData" OpHelp("r[P2]=data"), |
| 33034 | + /* 126 */ "RowData" OpHelp("r[P2]=data"), |
| 33035 | + /* 127 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 33036 | + /* 128 */ "NullRow" OpHelp(""), |
| 33037 | + /* 129 */ "SeekEnd" OpHelp(""), |
| 33038 | + /* 130 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 33039 | + /* 131 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 33040 | + /* 132 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 33041 | + /* 133 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 33042 | + /* 134 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 33043 | + /* 135 */ "FinishSeek" OpHelp(""), |
| 32443 | 33044 | /* 136 */ "Destroy" OpHelp(""), |
| 32444 | 33045 | /* 137 */ "Clear" OpHelp(""), |
| 32445 | 33046 | /* 138 */ "ResetSorter" OpHelp(""), |
| 32446 | 33047 | /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), |
| 32447 | 33048 | /* 140 */ "SqlExec" OpHelp(""), |
| | @@ -32450,35 +33051,38 @@ |
| 32450 | 33051 | /* 143 */ "DropTable" OpHelp(""), |
| 32451 | 33052 | /* 144 */ "DropIndex" OpHelp(""), |
| 32452 | 33053 | /* 145 */ "DropTrigger" OpHelp(""), |
| 32453 | 33054 | /* 146 */ "IntegrityCk" OpHelp(""), |
| 32454 | 33055 | /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 32455 | | - /* 148 */ "Real" OpHelp("r[P2]=P4"), |
| 32456 | | - /* 149 */ "Param" OpHelp(""), |
| 32457 | | - /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 33056 | + /* 148 */ "Param" OpHelp(""), |
| 33057 | + /* 149 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 33058 | + /* 150 */ "Real" OpHelp("r[P2]=P4"), |
| 32458 | 33059 | /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 32459 | 33060 | /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 32460 | 33061 | /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), |
| 32461 | 33062 | /* 154 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 32462 | 33063 | /* 155 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 32463 | 33064 | /* 156 */ "AggValue" OpHelp("r[P3]=value N=P2"), |
| 32464 | 33065 | /* 157 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 32465 | 33066 | /* 158 */ "Expire" OpHelp(""), |
| 32466 | | - /* 159 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 32467 | | - /* 160 */ "VBegin" OpHelp(""), |
| 32468 | | - /* 161 */ "VCreate" OpHelp(""), |
| 32469 | | - /* 162 */ "VDestroy" OpHelp(""), |
| 32470 | | - /* 163 */ "VOpen" OpHelp(""), |
| 32471 | | - /* 164 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 32472 | | - /* 165 */ "VRename" OpHelp(""), |
| 32473 | | - /* 166 */ "Pagecount" OpHelp(""), |
| 32474 | | - /* 167 */ "MaxPgcnt" OpHelp(""), |
| 32475 | | - /* 168 */ "Trace" OpHelp(""), |
| 32476 | | - /* 169 */ "CursorHint" OpHelp(""), |
| 32477 | | - /* 170 */ "Noop" OpHelp(""), |
| 32478 | | - /* 171 */ "Explain" OpHelp(""), |
| 32479 | | - /* 172 */ "Abortable" OpHelp(""), |
| 33067 | + /* 159 */ "CursorLock" OpHelp(""), |
| 33068 | + /* 160 */ "CursorUnlock" OpHelp(""), |
| 33069 | + /* 161 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 33070 | + /* 162 */ "VBegin" OpHelp(""), |
| 33071 | + /* 163 */ "VCreate" OpHelp(""), |
| 33072 | + /* 164 */ "VDestroy" OpHelp(""), |
| 33073 | + /* 165 */ "VOpen" OpHelp(""), |
| 33074 | + /* 166 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 33075 | + /* 167 */ "VRename" OpHelp(""), |
| 33076 | + /* 168 */ "Pagecount" OpHelp(""), |
| 33077 | + /* 169 */ "MaxPgcnt" OpHelp(""), |
| 33078 | + /* 170 */ "Trace" OpHelp(""), |
| 33079 | + /* 171 */ "CursorHint" OpHelp(""), |
| 33080 | + /* 172 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 33081 | + /* 173 */ "Noop" OpHelp(""), |
| 33082 | + /* 174 */ "Explain" OpHelp(""), |
| 33083 | + /* 175 */ "Abortable" OpHelp(""), |
| 32480 | 33084 | }; |
| 32481 | 33085 | return azName[i]; |
| 32482 | 33086 | } |
| 32483 | 33087 | #endif |
| 32484 | 33088 | |
| | @@ -32838,11 +33442,11 @@ |
| 32838 | 33442 | ** May you share freely, never taking more than you give. |
| 32839 | 33443 | ** |
| 32840 | 33444 | ****************************************************************************** |
| 32841 | 33445 | ** |
| 32842 | 33446 | ** This file contains inline asm code for retrieving "high-performance" |
| 32843 | | -** counters for x86 class CPUs. |
| 33447 | +** counters for x86 and x86_64 class CPUs. |
| 32844 | 33448 | */ |
| 32845 | 33449 | #ifndef SQLITE_HWTIME_H |
| 32846 | 33450 | #define SQLITE_HWTIME_H |
| 32847 | 33451 | |
| 32848 | 33452 | /* |
| | @@ -32849,12 +33453,13 @@ |
| 32849 | 33453 | ** The following routine only works on pentium-class (or newer) processors. |
| 32850 | 33454 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 32851 | 33455 | ** processor and returns that value. This can be used for high-res |
| 32852 | 33456 | ** profiling. |
| 32853 | 33457 | */ |
| 32854 | | -#if (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 32855 | | - (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 33458 | +#if !defined(__STRICT_ANSI__) && \ |
| 33459 | + (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 33460 | + (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 32856 | 33461 | |
| 32857 | 33462 | #if defined(__GNUC__) |
| 32858 | 33463 | |
| 32859 | 33464 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 32860 | 33465 | unsigned int lo, hi; |
| | @@ -32871,19 +33476,19 @@ |
| 32871 | 33476 | } |
| 32872 | 33477 | } |
| 32873 | 33478 | |
| 32874 | 33479 | #endif |
| 32875 | 33480 | |
| 32876 | | -#elif (defined(__GNUC__) && defined(__x86_64__)) |
| 33481 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) |
| 32877 | 33482 | |
| 32878 | 33483 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 32879 | 33484 | unsigned long val; |
| 32880 | 33485 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); |
| 32881 | 33486 | return val; |
| 32882 | 33487 | } |
| 32883 | 33488 | |
| 32884 | | -#elif (defined(__GNUC__) && defined(__ppc__)) |
| 33489 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) |
| 32885 | 33490 | |
| 32886 | 33491 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 32887 | 33492 | unsigned long long retval; |
| 32888 | 33493 | unsigned long junk; |
| 32889 | 33494 | __asm__ __volatile__ ("\n\ |
| | @@ -32896,18 +33501,17 @@ |
| 32896 | 33501 | return retval; |
| 32897 | 33502 | } |
| 32898 | 33503 | |
| 32899 | 33504 | #else |
| 32900 | 33505 | |
| 32901 | | - #error Need implementation of sqlite3Hwtime() for your platform. |
| 32902 | | - |
| 32903 | 33506 | /* |
| 32904 | | - ** To compile without implementing sqlite3Hwtime() for your platform, |
| 32905 | | - ** you can remove the above #error and use the following |
| 32906 | | - ** stub function. You will lose timing support for many |
| 32907 | | - ** of the debugging and testing utilities, but it should at |
| 32908 | | - ** least compile and run. |
| 33507 | + ** asm() is needed for hardware timing support. Without asm(), |
| 33508 | + ** disable the sqlite3Hwtime() routine. |
| 33509 | + ** |
| 33510 | + ** sqlite3Hwtime() is only used for some obscure debugging |
| 33511 | + ** and analysis configurations, not in any deliverable, so this |
| 33512 | + ** should not be a great loss. |
| 32909 | 33513 | */ |
| 32910 | 33514 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 32911 | 33515 | |
| 32912 | 33516 | #endif |
| 32913 | 33517 | |
| | @@ -36367,11 +36971,11 @@ |
| 36367 | 36971 | zDirname[ii] = '\0'; |
| 36368 | 36972 | }else{ |
| 36369 | 36973 | if( zDirname[0]!='/' ) zDirname[0] = '.'; |
| 36370 | 36974 | zDirname[1] = 0; |
| 36371 | 36975 | } |
| 36372 | | - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); |
| 36976 | + fd = robust_open(zDirname, O_RDONLY|O_BINARY|O_NOFOLLOW, 0); |
| 36373 | 36977 | if( fd>=0 ){ |
| 36374 | 36978 | OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); |
| 36375 | 36979 | } |
| 36376 | 36980 | *pFd = fd; |
| 36377 | 36981 | if( fd>=0 ) return SQLITE_OK; |
| | @@ -37258,14 +37862,16 @@ |
| 37258 | 37862 | } |
| 37259 | 37863 | } |
| 37260 | 37864 | |
| 37261 | 37865 | if( pInode->bProcessLock==0 ){ |
| 37262 | 37866 | if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){ |
| 37263 | | - pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777)); |
| 37867 | + pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT|O_NOFOLLOW, |
| 37868 | + (sStat.st_mode&0777)); |
| 37264 | 37869 | } |
| 37265 | 37870 | if( pShmNode->hShm<0 ){ |
| 37266 | | - pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777)); |
| 37871 | + pShmNode->hShm = robust_open(zShm, O_RDONLY|O_NOFOLLOW, |
| 37872 | + (sStat.st_mode&0777)); |
| 37267 | 37873 | if( pShmNode->hShm<0 ){ |
| 37268 | 37874 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm); |
| 37269 | 37875 | goto shm_open_err; |
| 37270 | 37876 | } |
| 37271 | 37877 | pShmNode->isReadonly = 1; |
| | @@ -38611,11 +39217,11 @@ |
| 38611 | 39217 | int *pOutFlags /* Output flags returned to SQLite core */ |
| 38612 | 39218 | ){ |
| 38613 | 39219 | unixFile *p = (unixFile *)pFile; |
| 38614 | 39220 | int fd = -1; /* File descriptor returned by open() */ |
| 38615 | 39221 | int openFlags = 0; /* Flags to pass to open() */ |
| 38616 | | - int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 39222 | + int eType = flags&0x0FFF00; /* Type of file to open */ |
| 38617 | 39223 | int noLock; /* True to omit locking primitives */ |
| 38618 | 39224 | int rc = SQLITE_OK; /* Function Return Code */ |
| 38619 | 39225 | int ctrlFlags = 0; /* UNIXFILE_* flags */ |
| 38620 | 39226 | |
| 38621 | 39227 | int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); |
| | @@ -38721,11 +39327,11 @@ |
| 38721 | 39327 | ** 'conch file' locking functions later on. */ |
| 38722 | 39328 | if( isReadonly ) openFlags |= O_RDONLY; |
| 38723 | 39329 | if( isReadWrite ) openFlags |= O_RDWR; |
| 38724 | 39330 | if( isCreate ) openFlags |= O_CREAT; |
| 38725 | 39331 | if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); |
| 38726 | | - openFlags |= (O_LARGEFILE|O_BINARY); |
| 39332 | + openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW); |
| 38727 | 39333 | |
| 38728 | 39334 | if( fd<0 ){ |
| 38729 | 39335 | mode_t openMode; /* Permissions to create file with */ |
| 38730 | 39336 | uid_t uid; /* Userid for the file */ |
| 38731 | 39337 | gid_t gid; /* Groupid for the file */ |
| | @@ -38939,11 +39545,12 @@ |
| 38939 | 39545 | ** two of them are actually used */ |
| 38940 | 39546 | assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE ); |
| 38941 | 39547 | |
| 38942 | 39548 | if( flags==SQLITE_ACCESS_EXISTS ){ |
| 38943 | 39549 | struct stat buf; |
| 38944 | | - *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0); |
| 39550 | + *pResOut = 0==osStat(zPath, &buf) && |
| 39551 | + (!S_ISREG(buf.st_mode) || buf.st_size>0); |
| 38945 | 39552 | }else{ |
| 38946 | 39553 | *pResOut = osAccess(zPath, W_OK|R_OK)==0; |
| 38947 | 39554 | } |
| 38948 | 39555 | return SQLITE_OK; |
| 38949 | 39556 | } |
| | @@ -38993,11 +39600,11 @@ |
| 38993 | 39600 | #if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT) |
| 38994 | 39601 | return mkFullPathname(zPath, zOut, nOut); |
| 38995 | 39602 | #else |
| 38996 | 39603 | int rc = SQLITE_OK; |
| 38997 | 39604 | int nByte; |
| 38998 | | - int nLink = 1; /* Number of symbolic links followed so far */ |
| 39605 | + int nLink = 0; /* Number of symbolic links followed so far */ |
| 38999 | 39606 | const char *zIn = zPath; /* Input path for each iteration of loop */ |
| 39000 | 39607 | char *zDel = 0; |
| 39001 | 39608 | |
| 39002 | 39609 | assert( pVfs->mxPathname==MAX_PATHNAME ); |
| 39003 | 39610 | UNUSED_PARAMETER(pVfs); |
| | @@ -39022,14 +39629,15 @@ |
| 39022 | 39629 | }else{ |
| 39023 | 39630 | bLink = S_ISLNK(buf.st_mode); |
| 39024 | 39631 | } |
| 39025 | 39632 | |
| 39026 | 39633 | if( bLink ){ |
| 39634 | + nLink++; |
| 39027 | 39635 | if( zDel==0 ){ |
| 39028 | 39636 | zDel = sqlite3_malloc(nOut); |
| 39029 | 39637 | if( zDel==0 ) rc = SQLITE_NOMEM_BKPT; |
| 39030 | | - }else if( ++nLink>SQLITE_MAX_SYMLINKS ){ |
| 39638 | + }else if( nLink>=SQLITE_MAX_SYMLINKS ){ |
| 39031 | 39639 | rc = SQLITE_CANTOPEN_BKPT; |
| 39032 | 39640 | } |
| 39033 | 39641 | |
| 39034 | 39642 | if( rc==SQLITE_OK ){ |
| 39035 | 39643 | nByte = osReadlink(zIn, zDel, nOut-1); |
| | @@ -39061,10 +39669,11 @@ |
| 39061 | 39669 | if( bLink==0 ) break; |
| 39062 | 39670 | zIn = zOut; |
| 39063 | 39671 | }while( rc==SQLITE_OK ); |
| 39064 | 39672 | |
| 39065 | 39673 | sqlite3_free(zDel); |
| 39674 | + if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK; |
| 39066 | 39675 | return rc; |
| 39067 | 39676 | #endif /* HAVE_READLINK && HAVE_LSTAT */ |
| 39068 | 39677 | } |
| 39069 | 39678 | |
| 39070 | 39679 | |
| | @@ -39546,11 +40155,11 @@ |
| 39546 | 40155 | int islockfile /* if non zero missing dirs will be created */ |
| 39547 | 40156 | ) { |
| 39548 | 40157 | int fd = -1; |
| 39549 | 40158 | unixFile *pNew; |
| 39550 | 40159 | int rc = SQLITE_OK; |
| 39551 | | - int openFlags = O_RDWR | O_CREAT; |
| 40160 | + int openFlags = O_RDWR | O_CREAT | O_NOFOLLOW; |
| 39552 | 40161 | sqlite3_vfs dummyVfs; |
| 39553 | 40162 | int terrno = 0; |
| 39554 | 40163 | UnixUnusedFd *pUnused = NULL; |
| 39555 | 40164 | |
| 39556 | 40165 | /* 1. first try to open/create the file |
| | @@ -39576,11 +40185,11 @@ |
| 39576 | 40185 | fd = robust_open(path, openFlags, 0); |
| 39577 | 40186 | } |
| 39578 | 40187 | } |
| 39579 | 40188 | } |
| 39580 | 40189 | if( fd<0 ){ |
| 39581 | | - openFlags = O_RDONLY; |
| 40190 | + openFlags = O_RDONLY | O_NOFOLLOW; |
| 39582 | 40191 | fd = robust_open(path, openFlags, 0); |
| 39583 | 40192 | terrno = errno; |
| 39584 | 40193 | } |
| 39585 | 40194 | if( fd<0 ){ |
| 39586 | 40195 | if( islockfile ){ |
| | @@ -39702,11 +40311,11 @@ |
| 39702 | 40311 | if( readLen<PROXY_PATHINDEX ){ |
| 39703 | 40312 | sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen); |
| 39704 | 40313 | goto end_breaklock; |
| 39705 | 40314 | } |
| 39706 | 40315 | /* write it out to the temporary break file */ |
| 39707 | | - fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0); |
| 40316 | + fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), 0); |
| 39708 | 40317 | if( fd<0 ){ |
| 39709 | 40318 | sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 39710 | 40319 | goto end_breaklock; |
| 39711 | 40320 | } |
| 39712 | 40321 | if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){ |
| | @@ -40660,11 +41269,11 @@ |
| 40660 | 41269 | ** May you share freely, never taking more than you give. |
| 40661 | 41270 | ** |
| 40662 | 41271 | ****************************************************************************** |
| 40663 | 41272 | ** |
| 40664 | 41273 | ** This file contains inline asm code for retrieving "high-performance" |
| 40665 | | -** counters for x86 class CPUs. |
| 41274 | +** counters for x86 and x86_64 class CPUs. |
| 40666 | 41275 | */ |
| 40667 | 41276 | #ifndef SQLITE_HWTIME_H |
| 40668 | 41277 | #define SQLITE_HWTIME_H |
| 40669 | 41278 | |
| 40670 | 41279 | /* |
| | @@ -40671,12 +41280,13 @@ |
| 40671 | 41280 | ** The following routine only works on pentium-class (or newer) processors. |
| 40672 | 41281 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 40673 | 41282 | ** processor and returns that value. This can be used for high-res |
| 40674 | 41283 | ** profiling. |
| 40675 | 41284 | */ |
| 40676 | | -#if (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 40677 | | - (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 41285 | +#if !defined(__STRICT_ANSI__) && \ |
| 41286 | + (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 41287 | + (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 40678 | 41288 | |
| 40679 | 41289 | #if defined(__GNUC__) |
| 40680 | 41290 | |
| 40681 | 41291 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 40682 | 41292 | unsigned int lo, hi; |
| | @@ -40693,19 +41303,19 @@ |
| 40693 | 41303 | } |
| 40694 | 41304 | } |
| 40695 | 41305 | |
| 40696 | 41306 | #endif |
| 40697 | 41307 | |
| 40698 | | -#elif (defined(__GNUC__) && defined(__x86_64__)) |
| 41308 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) |
| 40699 | 41309 | |
| 40700 | 41310 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 40701 | 41311 | unsigned long val; |
| 40702 | 41312 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); |
| 40703 | 41313 | return val; |
| 40704 | 41314 | } |
| 40705 | 41315 | |
| 40706 | | -#elif (defined(__GNUC__) && defined(__ppc__)) |
| 41316 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) |
| 40707 | 41317 | |
| 40708 | 41318 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 40709 | 41319 | unsigned long long retval; |
| 40710 | 41320 | unsigned long junk; |
| 40711 | 41321 | __asm__ __volatile__ ("\n\ |
| | @@ -40718,18 +41328,17 @@ |
| 40718 | 41328 | return retval; |
| 40719 | 41329 | } |
| 40720 | 41330 | |
| 40721 | 41331 | #else |
| 40722 | 41332 | |
| 40723 | | - #error Need implementation of sqlite3Hwtime() for your platform. |
| 40724 | | - |
| 40725 | 41333 | /* |
| 40726 | | - ** To compile without implementing sqlite3Hwtime() for your platform, |
| 40727 | | - ** you can remove the above #error and use the following |
| 40728 | | - ** stub function. You will lose timing support for many |
| 40729 | | - ** of the debugging and testing utilities, but it should at |
| 40730 | | - ** least compile and run. |
| 41334 | + ** asm() is needed for hardware timing support. Without asm(), |
| 41335 | + ** disable the sqlite3Hwtime() routine. |
| 41336 | + ** |
| 41337 | + ** sqlite3Hwtime() is only used for some obscure debugging |
| 41338 | + ** and analysis configurations, not in any deliverable, so this |
| 41339 | + ** should not be a great loss. |
| 40731 | 41340 | */ |
| 40732 | 41341 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 40733 | 41342 | |
| 40734 | 41343 | #endif |
| 40735 | 41344 | |
| | @@ -49293,17 +49902,19 @@ |
| 49293 | 49902 | sqlite3_free(p); |
| 49294 | 49903 | pPg = 0; |
| 49295 | 49904 | } |
| 49296 | 49905 | #else |
| 49297 | 49906 | pPg = pcache1Alloc(pCache->szAlloc); |
| 49298 | | - p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 49299 | 49907 | #endif |
| 49300 | 49908 | if( benignMalloc ){ sqlite3EndBenignMalloc(); } |
| 49301 | 49909 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 49302 | 49910 | pcache1EnterMutex(pCache->pGroup); |
| 49303 | 49911 | #endif |
| 49304 | 49912 | if( pPg==0 ) return 0; |
| 49913 | +#ifndef SQLITE_PCACHE_SEPARATE_HEADER |
| 49914 | + p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 49915 | +#endif |
| 49305 | 49916 | p->page.pBuf = pPg; |
| 49306 | 49917 | p->page.pExtra = &p[1]; |
| 49307 | 49918 | p->isBulkLocal = 0; |
| 49308 | 49919 | p->isAnchor = 0; |
| 49309 | 49920 | } |
| | @@ -51954,10 +52565,11 @@ |
| 51954 | 52565 | if( pPager->eLock!=UNKNOWN_LOCK ){ |
| 51955 | 52566 | pPager->eLock = (u8)eLock; |
| 51956 | 52567 | } |
| 51957 | 52568 | IOTRACE(("UNLOCK %p %d\n", pPager, eLock)) |
| 51958 | 52569 | } |
| 52570 | + pPager->changeCountDone = pPager->tempFile; /* ticket fb3b3024ea238d5c */ |
| 51959 | 52571 | return rc; |
| 51960 | 52572 | } |
| 51961 | 52573 | |
| 51962 | 52574 | /* |
| 51963 | 52575 | ** Lock the database file to level eLock, which must be either SHARED_LOCK, |
| | @@ -52141,10 +52753,11 @@ |
| 52141 | 52753 | ** master-journal filename. |
| 52142 | 52754 | */ |
| 52143 | 52755 | len = 0; |
| 52144 | 52756 | } |
| 52145 | 52757 | zMaster[len] = '\0'; |
| 52758 | + zMaster[len+1] = '\0'; |
| 52146 | 52759 | |
| 52147 | 52760 | return SQLITE_OK; |
| 52148 | 52761 | } |
| 52149 | 52762 | |
| 52150 | 52763 | /* |
| | @@ -52674,11 +53287,10 @@ |
| 52674 | 53287 | /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here |
| 52675 | 53288 | ** without clearing the error code. This is intentional - the error |
| 52676 | 53289 | ** code is cleared and the cache reset in the block below. |
| 52677 | 53290 | */ |
| 52678 | 53291 | assert( pPager->errCode || pPager->eState!=PAGER_ERROR ); |
| 52679 | | - pPager->changeCountDone = 0; |
| 52680 | 53292 | pPager->eState = PAGER_OPEN; |
| 52681 | 53293 | } |
| 52682 | 53294 | |
| 52683 | 53295 | /* If Pager.errCode is set, the contents of the pager cache cannot be |
| 52684 | 53296 | ** trusted. Now that there are no outstanding references to the pager, |
| | @@ -52938,11 +53550,10 @@ |
| 52938 | 53550 | |
| 52939 | 53551 | if( !pPager->exclusiveMode |
| 52940 | 53552 | && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0)) |
| 52941 | 53553 | ){ |
| 52942 | 53554 | rc2 = pagerUnlockDb(pPager, SHARED_LOCK); |
| 52943 | | - pPager->changeCountDone = 0; |
| 52944 | 53555 | } |
| 52945 | 53556 | pPager->eState = PAGER_READER; |
| 52946 | 53557 | pPager->setMaster = 0; |
| 52947 | 53558 | |
| 52948 | 53559 | return (rc==SQLITE_OK?rc2:rc); |
| | @@ -53377,19 +53988,20 @@ |
| 53377 | 53988 | ** journal files extracted from regular rollback-journals. |
| 53378 | 53989 | */ |
| 53379 | 53990 | rc = sqlite3OsFileSize(pMaster, &nMasterJournal); |
| 53380 | 53991 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 53381 | 53992 | nMasterPtr = pVfs->mxPathname+1; |
| 53382 | | - zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1); |
| 53993 | + zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 2); |
| 53383 | 53994 | if( !zMasterJournal ){ |
| 53384 | 53995 | rc = SQLITE_NOMEM_BKPT; |
| 53385 | 53996 | goto delmaster_out; |
| 53386 | 53997 | } |
| 53387 | | - zMasterPtr = &zMasterJournal[nMasterJournal+1]; |
| 53998 | + zMasterPtr = &zMasterJournal[nMasterJournal+2]; |
| 53388 | 53999 | rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); |
| 53389 | 54000 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 53390 | 54001 | zMasterJournal[nMasterJournal] = 0; |
| 54002 | + zMasterJournal[nMasterJournal+1] = 0; |
| 53391 | 54003 | |
| 53392 | 54004 | zJournal = zMasterJournal; |
| 53393 | 54005 | while( (zJournal-zMasterJournal)<nMasterJournal ){ |
| 53394 | 54006 | int exists; |
| 53395 | 54007 | rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists); |
| | @@ -55542,11 +56154,12 @@ |
| 55542 | 56154 | int nPathname = 0; /* Number of bytes in zPathname */ |
| 55543 | 56155 | int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */ |
| 55544 | 56156 | int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ |
| 55545 | 56157 | u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ |
| 55546 | 56158 | const char *zUri = 0; /* URI args to copy */ |
| 55547 | | - int nUri = 0; /* Number of bytes of URI args at *zUri */ |
| 56159 | + int nUriByte = 1; /* Number of bytes of URI args at *zUri */ |
| 56160 | + int nUri = 0; /* Number of URI parameters */ |
| 55548 | 56161 | |
| 55549 | 56162 | /* Figure out how much space is required for each journal file-handle |
| 55550 | 56163 | ** (there are two of them, the main journal and the sub-journal). */ |
| 55551 | 56164 | journalFileSize = ROUND8(sqlite3JournalSize(pVfs)); |
| 55552 | 56165 | |
| | @@ -55576,18 +56189,28 @@ |
| 55576 | 56189 | if( zPathname==0 ){ |
| 55577 | 56190 | return SQLITE_NOMEM_BKPT; |
| 55578 | 56191 | } |
| 55579 | 56192 | zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ |
| 55580 | 56193 | rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname); |
| 56194 | + if( rc!=SQLITE_OK ){ |
| 56195 | + if( rc==SQLITE_OK_SYMLINK ){ |
| 56196 | + if( vfsFlags & SQLITE_OPEN_NOFOLLOW ){ |
| 56197 | + rc = SQLITE_CANTOPEN_SYMLINK; |
| 56198 | + }else{ |
| 56199 | + rc = SQLITE_OK; |
| 56200 | + } |
| 56201 | + } |
| 56202 | + } |
| 55581 | 56203 | nPathname = sqlite3Strlen30(zPathname); |
| 55582 | 56204 | z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; |
| 55583 | 56205 | while( *z ){ |
| 55584 | | - z += sqlite3Strlen30(z)+1; |
| 55585 | | - z += sqlite3Strlen30(z)+1; |
| 56206 | + z += strlen(z)+1; |
| 56207 | + z += strlen(z)+1; |
| 56208 | + nUri++; |
| 55586 | 56209 | } |
| 55587 | | - nUri = (int)(&z[1] - zUri); |
| 55588 | | - assert( nUri>=0 ); |
| 56210 | + nUriByte = (int)(&z[1] - zUri); |
| 56211 | + assert( nUriByte>=1 ); |
| 55589 | 56212 | if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ |
| 55590 | 56213 | /* This branch is taken when the journal path required by |
| 55591 | 56214 | ** the database being opened will be more than pVfs->mxPathname |
| 55592 | 56215 | ** bytes in length. This means the database cannot be opened, |
| 55593 | 56216 | ** as it will not be possible to open the journal file or even |
| | @@ -55608,54 +56231,107 @@ |
| 55608 | 56231 | ** Pager object (sizeof(Pager) bytes) |
| 55609 | 56232 | ** PCache object (sqlite3PcacheSize() bytes) |
| 55610 | 56233 | ** Database file handle (pVfs->szOsFile bytes) |
| 55611 | 56234 | ** Sub-journal file handle (journalFileSize bytes) |
| 55612 | 56235 | ** Main journal file handle (journalFileSize bytes) |
| 56236 | + ** \0\0\0\0 database prefix (4 bytes) |
| 55613 | 56237 | ** Database file name (nPathname+1 bytes) |
| 55614 | | - ** Journal file name (nPathname+8+1 bytes) |
| 56238 | + ** URI query parameters (nUriByte bytes) |
| 56239 | + ** Journal filename (nPathname+8+1 bytes) |
| 56240 | + ** WAL filename (nPathname+4+1 bytes) |
| 56241 | + ** \0\0\0 terminator (3 bytes) |
| 56242 | + ** |
| 56243 | + ** Some 3rd-party software, over which we have no control, depends on |
| 56244 | + ** the specific order of the filenames and the \0 separators between them |
| 56245 | + ** so that it can (for example) find the database filename given the WAL |
| 56246 | + ** filename without using the sqlite3_filename_database() API. This is a |
| 56247 | + ** misuse of SQLite and a bug in the 3rd-party software, but the 3rd-party |
| 56248 | + ** software is in widespread use, so we try to avoid changing the filename |
| 56249 | + ** order and formatting if possible. In particular, the details of the |
| 56250 | + ** filename format expected by 3rd-party software should be as follows: |
| 56251 | + ** |
| 56252 | + ** - Main Database Path |
| 56253 | + ** - \0 |
| 56254 | + ** - Multiple URI components consisting of: |
| 56255 | + ** - Key |
| 56256 | + ** - \0 |
| 56257 | + ** - Value |
| 56258 | + ** - \0 |
| 56259 | + ** - \0 |
| 56260 | + ** - Journal Path |
| 56261 | + ** - \0 |
| 56262 | + ** - WAL Path (zWALName) |
| 56263 | + ** - \0 |
| 55615 | 56264 | */ |
| 55616 | 56265 | pPtr = (u8 *)sqlite3MallocZero( |
| 55617 | | - ROUND8(sizeof(*pPager)) + /* Pager structure */ |
| 55618 | | - ROUND8(pcacheSize) + /* PCache object */ |
| 55619 | | - ROUND8(pVfs->szOsFile) + /* The main db file */ |
| 55620 | | - journalFileSize * 2 + /* The two journal files */ |
| 55621 | | - nPathname + 1 + nUri + /* zFilename */ |
| 55622 | | - nPathname + 8 + 2 /* zJournal */ |
| 56266 | + ROUND8(sizeof(*pPager)) + /* Pager structure */ |
| 56267 | + ROUND8(pcacheSize) + /* PCache object */ |
| 56268 | + ROUND8(pVfs->szOsFile) + /* The main db file */ |
| 56269 | + journalFileSize * 2 + /* The two journal files */ |
| 56270 | + 4 + /* Database prefix */ |
| 56271 | + nPathname + 1 + /* database filename */ |
| 56272 | + nUriByte + /* query parameters */ |
| 56273 | + nPathname + 8 + 1 + /* Journal filename */ |
| 55623 | 56274 | #ifndef SQLITE_OMIT_WAL |
| 55624 | | - + nPathname + 4 + 2 /* zWal */ |
| 56275 | + nPathname + 4 + 1 + /* WAL filename */ |
| 55625 | 56276 | #endif |
| 56277 | + 3 /* Terminator */ |
| 55626 | 56278 | ); |
| 55627 | 56279 | assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); |
| 55628 | 56280 | if( !pPtr ){ |
| 55629 | 56281 | sqlite3DbFree(0, zPathname); |
| 55630 | 56282 | return SQLITE_NOMEM_BKPT; |
| 55631 | 56283 | } |
| 55632 | | - pPager = (Pager*)(pPtr); |
| 55633 | | - pPager->pPCache = (PCache*)(pPtr += ROUND8(sizeof(*pPager))); |
| 55634 | | - pPager->fd = (sqlite3_file*)(pPtr += ROUND8(pcacheSize)); |
| 55635 | | - pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile)); |
| 55636 | | - pPager->jfd = (sqlite3_file*)(pPtr += journalFileSize); |
| 55637 | | - pPager->zFilename = (char*)(pPtr += journalFileSize); |
| 56284 | + pPager = (Pager*)pPtr; pPtr += ROUND8(sizeof(*pPager)); |
| 56285 | + pPager->pPCache = (PCache*)pPtr; pPtr += ROUND8(pcacheSize); |
| 56286 | + pPager->fd = (sqlite3_file*)pPtr; pPtr += ROUND8(pVfs->szOsFile); |
| 56287 | + pPager->sjfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; |
| 56288 | + pPager->jfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; |
| 55638 | 56289 | assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) ); |
| 55639 | 56290 | |
| 55640 | | - /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ |
| 55641 | | - if( zPathname ){ |
| 55642 | | - assert( nPathname>0 ); |
| 55643 | | - pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); |
| 55644 | | - memcpy(pPager->zFilename, zPathname, nPathname); |
| 55645 | | - if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); |
| 55646 | | - memcpy(pPager->zJournal, zPathname, nPathname); |
| 55647 | | - memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+2); |
| 55648 | | - sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); |
| 56291 | + /* Fill in the Pager.zFilename and pPager.zQueryParam fields */ |
| 56292 | + pPtr += 4; /* Skip zero prefix */ |
| 56293 | + pPager->zFilename = (char*)pPtr; |
| 56294 | + if( nPathname>0 ){ |
| 56295 | + memcpy(pPtr, zPathname, nPathname); pPtr += nPathname + 1; |
| 56296 | + if( zUri ){ |
| 56297 | + memcpy(pPtr, zUri, nUriByte); pPtr += nUriByte; |
| 56298 | + }else{ |
| 56299 | + pPtr++; |
| 56300 | + } |
| 56301 | + } |
| 56302 | + |
| 56303 | + |
| 56304 | + /* Fill in Pager.zJournal */ |
| 56305 | + if( nPathname>0 ){ |
| 56306 |