Update SQLITE version to 3.42.0 (#15870)
* Update sqlite version to 3.42.0 Suppress a compilation warning * Enable SQLITE_ENABLE_DBPAGE_VTAB to allow recover code to be embedded in a followup PR Suppress unused parameter warning
Stelios Fragkakis committed
Aug 25, 2023 at 10:52 UTC
0aa3f21e5cdd2fba3fee29d6ae605c7da195425a
2 files changed
+4821
-2346
database/sqlite/sqlite3.c
+4671
-2294
@@ -1,6 +1,6 @@
1
/******************************************************************************
2
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.41.2. By combining all the individual C code files into this
3
+** version 3.42.0. By combining all the individual C code files into this
4
** single large file, the entire code can be compiled as a single translation
5
** unit. This allows many compilers to do optimizations that would not be
6
** possible if the files were compiled separately. Performance improvements
@@ -17,6 +17,9 @@
17
** language. The code for the "sqlite3" command-line shell is also in a
18
** separate file. This file contains only code for the core SQLite library.
19
*/
20
+#pragma GCC diagnostic push
21
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
22
+#pragma GCC diagnostic ignored "-Wunused-parameter"
23
#define SQLITE_CORE 1
24
#define SQLITE_AMALGAMATION 1
25
#ifndef SQLITE_PRIVATE
@@ -26,6 +29,7 @@
29
#define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1
30
#define SQLITE_OMIT_LOAD_EXTENSION 1
31
#define SQLITE_ENABLE_DBSTAT_VTAB 1
32
+#define SQLITE_ENABLE_DBPAGE_VTAB 1
33
/************** Begin file sqliteInt.h ***************************************/
34
/*
35
** 2001 September 15
@@ -127,6 +131,10 @@
131
#define SQLITE_4_BYTE_ALIGNED_MALLOC
132
#endif /* defined(_MSC_VER) && !defined(_WIN64) */
133
134
+#if !defined(HAVE_LOG2) && defined(_MSC_VER) && _MSC_VER<1800
135
+#define HAVE_LOG2 0
136
+#endif /* !defined(HAVE_LOG2) && defined(_MSC_VER) && _MSC_VER<1800 */
137
+
138
#endif /* SQLITE_MSVC_H */
139
140
/************** End of msvc.h ************************************************/
@@ -456,9 +464,9 @@ extern "C" {
464
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
465
** [sqlite_version()] and [sqlite_source_id()].
466
*/
459
-#define SQLITE_VERSION "3.41.2"
460
-#define SQLITE_VERSION_NUMBER 3041002
461
-#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da"
467
+#define SQLITE_VERSION "3.42.0"
468
+#define SQLITE_VERSION_NUMBER 3042000
469
+#define SQLITE_SOURCE_ID "2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0"
470
471
/*
472
** CAPI3REF: Run-Time Library Version Numbers
@@ -1965,20 +1973,23 @@ SQLITE_API int sqlite3_os_end(void);
1973
** must ensure that no other SQLite interfaces are invoked by other
1974
** threads while sqlite3_config() is running.</b>
1975
**
1968
-** The sqlite3_config() interface
1969
-** may only be invoked prior to library initialization using
1970
-** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1971
-** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1972
-** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1973
-** Note, however, that ^sqlite3_config() can be called as part of the
1974
-** implementation of an application-defined [sqlite3_os_init()].
1975
-**
1976
** The first argument to sqlite3_config() is an integer
1977
** [configuration option] that determines
1978
** what property of SQLite is to be configured. Subsequent arguments
1979
** vary depending on the [configuration option]
1980
** in the first argument.
1981
**
1982
+** For most configuration options, the sqlite3_config() interface
1983
+** may only be invoked prior to library initialization using
1984
+** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1985
+** The exceptional configuration options that may be invoked at any time
1986
+** are called "anytime configuration options".
1987
+** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1988
+** [sqlite3_shutdown()] with a first argument that is not an anytime
1989
+** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
1990
+** Note, however, that ^sqlite3_config() can be called as part of the
1991
+** implementation of an application-defined [sqlite3_os_init()].
1992
+**
1993
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1994
** ^If the option is unknown or SQLite is unable to set the option
1995
** then this routine returns a non-zero [error code].
@@ -2086,6 +2097,23 @@ struct sqlite3_mem_methods {
2097
** These constants are the available integer configuration options that
2098
** can be passed as the first argument to the [sqlite3_config()] interface.
2099
**
2100
+** Most of the configuration options for sqlite3_config()
2101
+** will only work if invoked prior to [sqlite3_initialize()] or after
2102
+** [sqlite3_shutdown()]. The few exceptions to this rule are called
2103
+** "anytime configuration options".
2104
+** ^Calling [sqlite3_config()] with a first argument that is not an
2105
+** anytime configuration option in between calls to [sqlite3_initialize()] and
2106
+** [sqlite3_shutdown()] is a no-op that returns SQLITE_MISUSE.
2107
+**
2108
+** The set of anytime configuration options can change (by insertions
2109
+** and/or deletions) from one release of SQLite to the next.
2110
+** As of SQLite version 3.42.0, the complete set of anytime configuration
2111
+** options is:
2112
+** <ul>
2113
+** <li> SQLITE_CONFIG_LOG
2114
+** <li> SQLITE_CONFIG_PCACHE_HDRSZ
2115
+** </ul>
2116
+**
2117
** New configuration options may be added in future releases of SQLite.
2118
** Existing configuration options might be discontinued. Applications
2119
** should check the return code from [sqlite3_config()] to make sure that
@@ -2432,28 +2460,28 @@ struct sqlite3_mem_methods {
2460
** compile-time option is not set, then the default maximum is 1073741824.
2461
** </dl>
2462
*/
2435
-#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2436
-#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2437
-#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2438
-#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
2439
-#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
2440
-#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
2441
-#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
2442
-#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
2443
-#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
2444
-#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
2445
-#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
2446
-/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
2447
-#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
2448
-#define SQLITE_CONFIG_PCACHE 14 /* no-op */
2449
-#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
2450
-#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2451
-#define SQLITE_CONFIG_URI 17 /* int */
2452
-#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2453
-#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2463
+#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2464
+#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2465
+#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2466
+#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
2467
+#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
2468
+#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
2469
+#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
2470
+#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
2471
+#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
2472
+#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
2473
+#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
2474
+/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
2475
+#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
2476
+#define SQLITE_CONFIG_PCACHE 14 /* no-op */
2477
+#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
2478
+#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2479
+#define SQLITE_CONFIG_URI 17 /* int */
2480
+#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2481
+#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2482
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
2455
-#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
2456
-#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
2483
+#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
2484
+#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
2485
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
2486
#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
2487
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
@@ -2688,7 +2716,7 @@ struct sqlite3_mem_methods {
2716
** </dd>
2717
**
2718
** [[SQLITE_DBCONFIG_DQS_DML]]
2691
-** <dt>SQLITE_DBCONFIG_DQS_DML</td>
2719
+** <dt>SQLITE_DBCONFIG_DQS_DML</dt>
2720
** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
2721
** the legacy [double-quoted string literal] misfeature for DML statements
2722
** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
@@ -2697,7 +2725,7 @@ struct sqlite3_mem_methods {
2725
** </dd>
2726
**
2727
** [[SQLITE_DBCONFIG_DQS_DDL]]
2700
-** <dt>SQLITE_DBCONFIG_DQS_DDL</td>
2728
+** <dt>SQLITE_DBCONFIG_DQS_DDL</dt>
2729
** <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates
2730
** the legacy [double-quoted string literal] misfeature for DDL statements,
2731
** such as CREATE TABLE and CREATE INDEX. The
@@ -2706,7 +2734,7 @@ struct sqlite3_mem_methods {
2734
** </dd>
2735
**
2736
** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]]
2709
-** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</td>
2737
+** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</dt>
2738
** <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to
2739
** assume that database schemas are untainted by malicious content.
2740
** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite
@@ -2726,7 +2754,7 @@ struct sqlite3_mem_methods {
2754
** </dd>
2755
**
2756
** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
2729
-** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
2757
+** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt>
2758
** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
2759
** the legacy file format flag. When activated, this flag causes all newly
2760
** created database file to have a schema format version number (the 4-byte
@@ -2735,7 +2763,7 @@ struct sqlite3_mem_methods {
2763
** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
2764
** newly created databases are generally not understandable by SQLite versions
2765
** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
2738
-** is now scarcely any need to generated database files that are compatible
2766
+** is now scarcely any need to generate database files that are compatible
2767
** all the way back to version 3.0.0, and so this setting is of little
2768
** practical use, but is provided so that SQLite can continue to claim the
2769
** ability to generate new database files that are compatible with version
@@ -2746,6 +2774,38 @@ struct sqlite3_mem_methods {
2774
** not considered a bug since SQLite versions 3.3.0 and earlier do not support
2775
** either generated columns or decending indexes.
2776
** </dd>
2777
+**
2778
+** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]]
2779
+** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt>
2780
+** <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in
2781
+** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2782
+** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2783
+** statistics. For statistics to be collected, the flag must be set on
2784
+** the database handle both when the SQL statement is prepared and when it
2785
+** is stepped. The flag is set (collection of statistics is enabled)
2786
+** by default. This option takes two arguments: an integer and a pointer to
2787
+** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2788
+** leave unchanged the statement scanstatus option. If the second argument
2789
+** is not NULL, then the value of the statement scanstatus setting after
2790
+** processing the first argument is written into the integer that the second
2791
+** argument points to.
2792
+** </dd>
2793
+**
2794
+** [[SQLITE_DBCONFIG_REVERSE_SCANORDER]]
2795
+** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2796
+** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2797
+** in which tables and indexes are scanned so that the scans start at the end
2798
+** and work toward the beginning rather than starting at the beginning and
2799
+** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2800
+** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2801
+** two arguments which are an integer and a pointer to an integer. The first
2802
+** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2803
+** reverse scan order flag, respectively. If the second argument is not NULL,
2804
+** then 0 or 1 is written into the integer that the second argument points to
2805
+** depending on if the reverse scan order flag is set after processing the
2806
+** first argument.
2807
+** </dd>
2808
+**
2809
** </dl>
2810
*/
2811
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
@@ -2766,7 +2826,9 @@ struct sqlite3_mem_methods {
2826
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2827
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2828
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2769
-#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */
2829
+#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2830
+#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2831
+#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2832
2833
/*
2834
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -6511,6 +6573,13 @@ SQLITE_API void sqlite3_activate_cerod(
6573
** of the default VFS is not implemented correctly, or not implemented at
6574
** all, then the behavior of sqlite3_sleep() may deviate from the description
6575
** in the previous paragraphs.
6576
+**
6577
+** If a negative argument is passed to sqlite3_sleep() the results vary by
6578
+** VFS and operating system. Some system treat a negative argument as an
6579
+** instruction to sleep forever. Others understand it to mean do not sleep
6580
+** at all. ^In SQLite version 3.42.0 and later, a negative
6581
+** argument passed into sqlite3_sleep() is changed to zero before it is relayed
6582
+** down into the xSleep method of the VFS.
6583
*/
6584
SQLITE_API int sqlite3_sleep(int);
6585
@@ -8138,9 +8207,9 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
8207
** is undefined if the mutex is not currently entered by the
8208
** calling thread or is not currently allocated.
8209
**
8141
-** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
8142
-** sqlite3_mutex_leave() is a NULL pointer, then all three routines
8143
-** behave as no-ops.
8210
+** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(),
8211
+** sqlite3_mutex_leave(), or sqlite3_mutex_free() is a NULL pointer,
8212
+** then any of the four routines behaves as a no-op.
8213
**
8214
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
8215
*/
@@ -9874,18 +9943,28 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
9943
** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
9944
** <dd>Calls of the form
9945
** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9877
-** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9946
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9947
** identify that virtual table as being safe to use from within triggers
9948
** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
9949
** virtual table can do no serious harm even if it is controlled by a
9950
** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9951
** flag unless absolutely necessary.
9952
** </dd>
9953
+**
9954
+** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9955
+** <dd>Calls of the form
9956
+** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9957
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9958
+** instruct the query planner to begin at least a read transaction on
9959
+** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9960
+** virtual table is used.
9961
+** </dd>
9962
** </dl>
9963
*/
9964
#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9965
#define SQLITE_VTAB_INNOCUOUS 2
9966
#define SQLITE_VTAB_DIRECTONLY 3
9967
+#define SQLITE_VTAB_USES_ALL_SCHEMAS 4
9968
9969
/*
9970
** CAPI3REF: Determine The Virtual Table Conflict Policy
@@ -11060,16 +11139,20 @@ SQLITE_API int sqlite3session_create(
11139
SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
11140
11141
/*
11063
-** CAPIREF: Conigure a Session Object
11142
+** CAPI3REF: Configure a Session Object
11143
** METHOD: sqlite3_session
11144
**
11145
** This method is used to configure a session object after it has been
11067
-** created. At present the only valid value for the second parameter is
11068
-** [SQLITE_SESSION_OBJCONFIG_SIZE].
11146
+** created. At present the only valid values for the second parameter are
11147
+** [SQLITE_SESSION_OBJCONFIG_SIZE] and [SQLITE_SESSION_OBJCONFIG_ROWID].
11148
**
11070
-** Arguments for sqlite3session_object_config()
11149
+*/
11150
+SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
11151
+
11152
+/*
11153
+** CAPI3REF: Options for sqlite3session_object_config
11154
**
11072
-** The following values may passed as the the 4th parameter to
11155
+** The following values may passed as the the 2nd parameter to
11156
** sqlite3session_object_config().
11157
**
11158
** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
@@ -11085,12 +11168,21 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
11168
**
11169
** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
11170
** the first table has been attached to the session object.
11171
+**
11172
+** <dt>SQLITE_SESSION_OBJCONFIG_ROWID <dd>
11173
+** This option is used to set, clear or query the flag that enables
11174
+** collection of data for tables with no explicit PRIMARY KEY.
11175
+**
11176
+** Normally, tables with no explicit PRIMARY KEY are simply ignored
11177
+** by the sessions module. However, if this flag is set, it behaves
11178
+** as if such tables have a column "_rowid_ INTEGER PRIMARY KEY" inserted
11179
+** as their leftmost columns.
11180
+**
11181
+** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
11182
+** the first table has been attached to the session object.
11183
*/
11089
-SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
11090
-
11091
-/*
11092
-*/
11093
-#define SQLITE_SESSION_OBJCONFIG_SIZE 1
11184
+#define SQLITE_SESSION_OBJCONFIG_SIZE 1
11185
+#define SQLITE_SESSION_OBJCONFIG_ROWID 2
11186
11187
/*
11188
** CAPI3REF: Enable Or Disable A Session Object
@@ -12223,9 +12315,23 @@ SQLITE_API int sqlite3changeset_apply_v2(
12315
** Invert the changeset before applying it. This is equivalent to inverting
12316
** a changeset using sqlite3changeset_invert() before applying it. It is
12317
** an error to specify this flag with a patchset.
12318
+**
12319
+** <dt>SQLITE_CHANGESETAPPLY_IGNORENOOP <dd>
12320
+** Do not invoke the conflict handler callback for any changes that
12321
+** would not actually modify the database even if they were applied.
12322
+** Specifically, this means that the conflict handler is not invoked
12323
+** for:
12324
+** <ul>
12325
+** <li>a delete change if the row being deleted cannot be found,
12326
+** <li>an update change if the modified fields are already set to
12327
+** their new values in the conflicting row, or
12328
+** <li>an insert change if all fields of the conflicting row match
12329
+** the row being inserted.
12330
+** </ul>
12331
*/
12332
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12333
#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12334
+#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12335
12336
/*
12337
** CAPI3REF: Constants Passed To The Conflict Handler
@@ -13522,8 +13628,8 @@ struct fts5_api {
13628
#endif
13629
13630
/*
13525
-** WAL mode depends on atomic aligned 32-bit loads and stores in a few
13526
-** places. The following macros try to make this explicit.
13631
+** A few places in the code require atomic load/store of aligned
13632
+** integer values.
13633
*/
13634
#ifndef __has_extension
13635
# define __has_extension(x) 0 /* compatibility with non-clang compilers */
@@ -13579,15 +13685,22 @@ struct fts5_api {
13685
#endif
13686
13687
/*
13582
-** A macro to hint to the compiler that a function should not be
13688
+** Macros to hint to the compiler that a function should or should not be
13689
** inlined.
13690
*/
13691
#if defined(__GNUC__)
13692
# define SQLITE_NOINLINE __attribute__((noinline))
13693
+# define SQLITE_INLINE __attribute__((always_inline)) inline
13694
#elif defined(_MSC_VER) && _MSC_VER>=1310
13695
# define SQLITE_NOINLINE __declspec(noinline)
13696
+# define SQLITE_INLINE __forceinline
13697
#else
13698
# define SQLITE_NOINLINE
13699
+# define SQLITE_INLINE
13700
+#endif
13701
+#if defined(SQLITE_COVERAGE_TEST) || defined(__STRICT_ANSI__)
13702
+# undef SQLITE_INLINE
13703
+# define SQLITE_INLINE
13704
#endif
13705
13706
/*
@@ -16548,6 +16661,10 @@ SQLITE_PRIVATE void sqlite3VdbeScanStatusCounters(Vdbe*, int, int, int);
16661
SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
16662
#endif
16663
16664
+#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
16665
+SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr);
16666
+#endif
16667
+
16668
#endif /* SQLITE_VDBE_H */
16669
16670
/************** End of vdbe.h ************************************************/
@@ -17257,7 +17374,7 @@ struct sqlite3 {
17374
#define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
17375
/* result set is empty */
17376
#define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */
17260
-#define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */
17377
+#define SQLITE_StmtScanStatus 0x00000400 /* Enable stmt_scanstats() counters */
17378
#define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */
17379
#define SQLITE_ReverseOrder 0x00001000 /* Reverse unordered SELECTs */
17380
#define SQLITE_RecTriggers 0x00002000 /* Enable recursive triggers */
@@ -17283,6 +17400,7 @@ struct sqlite3 {
17400
/* DELETE, or UPDATE and return */
17401
/* the count using a callback. */
17402
#define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
17403
+#define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */
17404
17405
/* Flags used only if debugging */
17406
#ifdef SQLITE_DEBUG
@@ -17339,6 +17457,7 @@ struct sqlite3 {
17457
/* TH3 expects this value ^^^^^^^^^^ See flatten04.test */
17458
#define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */
17459
#define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
17460
+#define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
17461
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
17462
17463
/*
@@ -17810,6 +17929,7 @@ struct VTable {
17929
sqlite3_vtab *pVtab; /* Pointer to vtab instance */
17930
int nRef; /* Number of pointers to this structure */
17931
u8 bConstraint; /* True if constraints are supported */
17932
+ u8 bAllSchemas; /* True if might use any attached schema */
17933
u8 eVtabRisk; /* Riskiness of allowing hacker access */
17934
int iSavepoint; /* Depth of the SAVEPOINT stack */
17935
VTable *pNext; /* Next in linked list (see above) */
@@ -18190,6 +18310,7 @@ struct Index {
18310
** expression, or a reference to a VIRTUAL column */
18311
#ifdef SQLITE_ENABLE_STAT4
18312
int nSample; /* Number of elements in aSample[] */
18313
+ int mxSample; /* Number of slots allocated to aSample[] */
18314
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
18315
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
18316
IndexSample *aSample; /* Samples of the left-most key */
@@ -19676,6 +19797,7 @@ struct Walker {
19797
struct CoveringIndexCheck *pCovIdxCk; /* Check for covering index */
19798
SrcItem *pSrcItem; /* A single FROM clause item */
19799
DbFixer *pFix; /* See sqlite3FixSelect() */
19800
+ Mem *aMem; /* See sqlite3BtreeCursorHint() */
19801
} u;
19802
};
19803
@@ -19945,6 +20067,8 @@ SQLITE_PRIVATE int sqlite3CorruptPgnoError(int,Pgno);
20067
# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08)
20068
# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)])
20069
# define sqlite3Isquote(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x80)
20070
+# define sqlite3JsonId1(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x42)
20071
+# define sqlite3JsonId2(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x46)
20072
#else
20073
# define sqlite3Toupper(x) toupper((unsigned char)(x))
20074
# define sqlite3Isspace(x) isspace((unsigned char)(x))
@@ -19954,6 +20078,8 @@ SQLITE_PRIVATE int sqlite3CorruptPgnoError(int,Pgno);
20078
# define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
20079
# define sqlite3Tolower(x) tolower((unsigned char)(x))
20080
# define sqlite3Isquote(x) ((x)=='"'||(x)=='\''||(x)=='['||(x)=='`')
20081
+# define sqlite3JsonId1(x) (sqlite3IsIdChar(x)&&(x)<'0')
20082
+# define sqlite3JsonId2(x) sqlite3IsIdChar(x)
20083
#endif
20084
SQLITE_PRIVATE int sqlite3IsIdChar(u8);
20085
@@ -20147,6 +20273,10 @@ SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
20273
SQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);
20274
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse*,int,int);
20275
SQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse*);
20276
+SQLITE_PRIVATE void sqlite3TouchRegister(Parse*,int);
20277
+#if defined(SQLITE_ENABLE_STAT4) || defined(SQLITE_DEBUG)
20278
+SQLITE_PRIVATE int sqlite3FirstAvailableRegister(Parse*,int);
20279
+#endif
20280
#ifdef SQLITE_DEBUG
20281
SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse*,int,int);
20282
#endif
@@ -20297,7 +20427,7 @@ SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList
20427
Expr*,ExprList*,u32,Expr*);
20428
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
20429
SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
20300
-SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
20430
+SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*);
20431
SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
20432
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
20433
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -20386,7 +20516,7 @@ SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
20516
SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);
20517
SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);
20518
SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);
20389
-SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr*,const SrcItem*);
20519
+SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int);
20520
#ifdef SQLITE_ENABLE_CURSOR_HINTS
20521
SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);
20522
#endif
@@ -20834,10 +20964,7 @@ SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
20964
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
20965
20966
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20837
-#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20838
- && !defined(SQLITE_OMIT_VIRTUALTABLE)
20839
-SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*);
20840
-#endif
20967
+SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(Parse*);
20968
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20969
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20970
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
@@ -21084,6 +21211,12 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void);
21211
SQLITE_PRIVATE sqlite3_uint64 sqlite3Hwtime(void);
21212
#endif
21213
21214
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
21215
+# define IS_STMT_SCANSTATUS(db) (db->flags & SQLITE_StmtScanStatus)
21216
+#else
21217
+# define IS_STMT_SCANSTATUS(db) 0
21218
+#endif
21219
+
21220
#endif /* SQLITEINT_H */
21221
21222
/************** End of sqliteInt.h *******************************************/
@@ -22079,7 +22212,7 @@ SQLITE_PRIVATE const unsigned char *sqlite3aGTb = &sqlite3UpperToLower[256+12-OP
22212
** isalnum() 0x06
22213
** isxdigit() 0x08
22214
** toupper() 0x20
22082
-** SQLite identifier character 0x40
22215
+** SQLite identifier character 0x40 $, _, or non-ascii
22216
** Quote character 0x80
22217
**
22218
** Bit 0x20 is set if the mapped character requires translation to upper
@@ -22273,7 +22406,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
22406
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
22407
0, /* iPrngSeed */
22408
#ifdef SQLITE_DEBUG
22276
- {0,0,0,0,0,0} /* aTune */
22409
+ {0,0,0,0,0,0}, /* aTune */
22410
#endif
22411
};
22412
@@ -23572,6 +23705,7 @@ struct DateTime {
23705
char validTZ; /* True (1) if tz is valid */
23706
char tzSet; /* Timezone was set explicitly */
23707
char isError; /* An overflow has occurred */
23708
+ char useSubsec; /* Display subsecond precision */
23709
};
23710
23711
@@ -23886,6 +24020,11 @@ static int parseDateOrTime(
24020
}else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){
24021
setRawDateNumber(p, r);
24022
return 0;
24023
+ }else if( (sqlite3StrICmp(zDate,"subsec")==0
24024
+ || sqlite3StrICmp(zDate,"subsecond")==0)
24025
+ && sqlite3NotPureFunc(context) ){
24026
+ p->useSubsec = 1;
24027
+ return setDateTimeToCurrent(context, p);
24028
}
24029
return 1;
24030
}
@@ -24300,8 +24439,22 @@ static int parseModifier(
24439
**
24440
** Move the date backwards to the beginning of the current day,
24441
** or month or year.
24442
+ **
24443
+ ** subsecond
24444
+ ** subsec
24445
+ **
24446
+ ** Show subsecond precision in the output of datetime() and
24447
+ ** unixepoch() and strftime('%s').
24448
*/
24304
- if( sqlite3_strnicmp(z, "start of ", 9)!=0 ) break;
24449
+ if( sqlite3_strnicmp(z, "start of ", 9)!=0 ){
24450
+ if( sqlite3_stricmp(z, "subsec")==0
24451
+ || sqlite3_stricmp(z, "subsecond")==0
24452
+ ){
24453
+ p->useSubsec = 1;
24454
+ rc = 0;
24455
+ }
24456
+ break;
24457
+ }
24458
if( !p->validJD && !p->validYMD && !p->validHMS ) break;
24459
z += 9;
24460
computeYMD(p);
@@ -24499,7 +24652,11 @@ static void unixepochFunc(
24652
DateTime x;
24653
if( isDate(context, argc, argv, &x)==0 ){
24654
computeJD(&x);
24502
- sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
24655
+ if( x.useSubsec ){
24656
+ sqlite3_result_double(context, (x.iJD - 21086676*(i64)10000000)/1000.0);
24657
+ }else{
24658
+ sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
24659
+ }
24660
}
24661
}
24662
@@ -24515,8 +24672,8 @@ static void datetimeFunc(
24672
){
24673
DateTime x;
24674
if( isDate(context, argc, argv, &x)==0 ){
24518
- int Y, s;
24519
- char zBuf[24];
24675
+ int Y, s, n;
24676
+ char zBuf[32];
24677
computeYMD_HMS(&x);
24678
Y = x.Y;
24679
if( Y<0 ) Y = -Y;
@@ -24537,15 +24694,28 @@ static void datetimeFunc(
24694
zBuf[15] = '0' + (x.m/10)%10;
24695
zBuf[16] = '0' + (x.m)%10;
24696
zBuf[17] = ':';
24540
- s = (int)x.s;
24541
- zBuf[18] = '0' + (s/10)%10;
24542
- zBuf[19] = '0' + (s)%10;
24543
- zBuf[20] = 0;
24697
+ if( x.useSubsec ){
24698
+ s = (int)1000.0*x.s;
24699
+ zBuf[18] = '0' + (s/10000)%10;
24700
+ zBuf[19] = '0' + (s/1000)%10;
24701
+ zBuf[20] = '.';
24702
+ zBuf[21] = '0' + (s/100)%10;
24703
+ zBuf[22] = '0' + (s/10)%10;
24704
+ zBuf[23] = '0' + (s)%10;
24705
+ zBuf[24] = 0;
24706
+ n = 24;
24707
+ }else{
24708
+ s = (int)x.s;
24709
+ zBuf[18] = '0' + (s/10)%10;
24710
+ zBuf[19] = '0' + (s)%10;
24711
+ zBuf[20] = 0;
24712
+ n = 20;
24713
+ }
24714
if( x.Y<0 ){
24715
zBuf[0] = '-';
24546
- sqlite3_result_text(context, zBuf, 20, SQLITE_TRANSIENT);
24716
+ sqlite3_result_text(context, zBuf, n, SQLITE_TRANSIENT);
24717
}else{
24548
- sqlite3_result_text(context, &zBuf[1], 19, SQLITE_TRANSIENT);
24718
+ sqlite3_result_text(context, &zBuf[1], n-1, SQLITE_TRANSIENT);
24719
}
24720
}
24721
}
@@ -24562,7 +24732,7 @@ static void timeFunc(
24732
){
24733
DateTime x;
24734
if( isDate(context, argc, argv, &x)==0 ){
24565
- int s;
24735
+ int s, n;
24736
char zBuf[16];
24737
computeHMS(&x);
24738
zBuf[0] = '0' + (x.h/10)%10;
@@ -24571,11 +24741,24 @@ static void timeFunc(
24741
zBuf[3] = '0' + (x.m/10)%10;
24742
zBuf[4] = '0' + (x.m)%10;
24743
zBuf[5] = ':';
24574
- s = (int)x.s;
24575
- zBuf[6] = '0' + (s/10)%10;
24576
- zBuf[7] = '0' + (s)%10;
24577
- zBuf[8] = 0;
24578
- sqlite3_result_text(context, zBuf, 8, SQLITE_TRANSIENT);
24744
+ if( x.useSubsec ){
24745
+ s = (int)1000.0*x.s;
24746
+ zBuf[6] = '0' + (s/10000)%10;
24747
+ zBuf[7] = '0' + (s/1000)%10;
24748
+ zBuf[8] = '.';
24749
+ zBuf[9] = '0' + (s/100)%10;
24750
+ zBuf[10] = '0' + (s/10)%10;
24751
+ zBuf[11] = '0' + (s)%10;
24752
+ zBuf[12] = 0;
24753
+ n = 12;
24754
+ }else{
24755
+ s = (int)x.s;
24756
+ zBuf[6] = '0' + (s/10)%10;
24757
+ zBuf[7] = '0' + (s)%10;
24758
+ zBuf[8] = 0;
24759
+ n = 8;
24760
+ }
24761
+ sqlite3_result_text(context, zBuf, n, SQLITE_TRANSIENT);
24762
}
24763
}
24764
@@ -24706,8 +24889,13 @@ static void strftimeFunc(
24889
break;
24890
}
24891
case 's': {
24709
- i64 iS = (i64)(x.iJD/1000 - 21086676*(i64)10000);
24710
- sqlite3_str_appendf(&sRes,"%lld",iS);
24892
+ if( x.useSubsec ){
24893
+ sqlite3_str_appendf(&sRes,"%.3f",
24894
+ (x.iJD - 21086676*(i64)10000000)/1000.0);
24895
+ }else{
24896
+ i64 iS = (i64)(x.iJD/1000 - 21086676*(i64)10000);
24897
+ sqlite3_str_appendf(&sRes,"%lld",iS);
24898
+ }
24899
break;
24900
}
24901
case 'S': {
@@ -30078,6 +30266,20 @@ static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
30266
}
30267
#endif /* SQLITE_OMIT_FLOATING_POINT */
30268
30269
+#ifndef SQLITE_OMIT_FLOATING_POINT
30270
+/*
30271
+** "*val" is a u64. *msd is a divisor used to extract the
30272
+** most significant digit of *val. Extract that most significant
30273
+** digit and return it.
30274
+*/
30275
+static char et_getdigit_int(u64 *val, u64 *msd){
30276
+ u64 x = (*val)/(*msd);
30277
+ *val -= x*(*msd);
30278
+ if( *msd>=10 ) *msd /= 10;
30279
+ return '0' + (char)(x & 15);
30280
+}
30281
+#endif /* SQLITE_OMIT_FLOATING_POINT */
30282
+
30283
/*
30284
** Set the StrAccum object to an error mode.
30285
*/
@@ -30170,6 +30372,8 @@ SQLITE_API void sqlite3_str_vappendf(
30372
char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
30373
sqlite_uint64 longvalue; /* Value for integer types */
30374
LONGDOUBLE_TYPE realvalue; /* Value for real types */
30375
+ sqlite_uint64 msd; /* Divisor to get most-significant-digit
30376
+ ** of longvalue */
30377
const et_info *infop; /* Pointer to the appropriate info structure */
30378
char *zOut; /* Rendering buffer */
30379
int nOut; /* Size of the rendering buffer */
@@ -30476,52 +30680,78 @@ SQLITE_API void sqlite3_str_vappendf(
30680
}else{
30681
prefix = flag_prefix;
30682
}
30683
+ exp = 0;
30684
if( xtype==etGENERIC && precision>0 ) precision--;
30685
testcase( precision>0xfff );
30481
- idx = precision & 0xfff;
30482
- rounder = arRound[idx%10];
30483
- while( idx>=10 ){ rounder *= 1.0e-10; idx -= 10; }
30484
- if( xtype==etFLOAT ){
30485
- double rx = (double)realvalue;
30486
- sqlite3_uint64 u;
30487
- int ex;
30488
- memcpy(&u, &rx, sizeof(u));
30489
- ex = -1023 + (int)((u>>52)&0x7ff);
30490
- if( precision+(ex/3) < 15 ) rounder += realvalue*3e-16;
30491
- realvalue += rounder;
30492
- }
30493
- /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
30494
- exp = 0;
30495
- if( sqlite3IsNaN((double)realvalue) ){
30496
- bufpt = "NaN";
30497
- length = 3;
30498
- break;
30499
- }
30500
- if( realvalue>0.0 ){
30501
- LONGDOUBLE_TYPE scale = 1.0;
30502
- while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;}
30503
- while( realvalue>=1e10*scale && exp<=350 ){ scale *= 1e10; exp+=10; }
30504
- while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; }
30505
- realvalue /= scale;
30506
- while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }
30507
- while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }
30508
- if( exp>350 ){
30509
- bufpt = buf;
30510
- buf[0] = prefix;
30511
- memcpy(buf+(prefix!=0),"Inf",4);
30512
- length = 3+(prefix!=0);
30686
+ if( realvalue<1.0e+16
30687
+ && realvalue==(LONGDOUBLE_TYPE)(longvalue = (u64)realvalue)
30688
+ ){
30689
+ /* Number is a pure integer that can be represented as u64 */
30690
+ for(msd=1; msd*10<=longvalue; msd *= 10, exp++){}
30691
+ if( exp>precision && xtype!=etFLOAT ){
30692
+ u64 rnd = msd/2;
30693
+ int kk = precision;
30694
+ while( kk-- > 0 ){ rnd /= 10; }
30695
+ longvalue += rnd;
30696
+ }
30697
+ }else{
30698
+ msd = 0;
30699
+ longvalue = 0; /* To prevent a compiler warning */
30700
+ idx = precision & 0xfff;
30701
+ rounder = arRound[idx%10];
30702
+ while( idx>=10 ){ rounder *= 1.0e-10; idx -= 10; }
30703
+ if( xtype==etFLOAT ){
30704
+ double rx = (double)realvalue;
30705
+ sqlite3_uint64 u;
30706
+ int ex;
30707
+ memcpy(&u, &rx, sizeof(u));
30708
+ ex = -1023 + (int)((u>>52)&0x7ff);
30709
+ if( precision+(ex/3) < 15 ) rounder += realvalue*3e-16;
30710
+ realvalue += rounder;
30711
+ }
30712
+ if( sqlite3IsNaN((double)realvalue) ){
30713
+ if( flag_zeropad ){
30714
+ bufpt = "null";
30715
+ length = 4;
30716
+ }else{
30717
+ bufpt = "NaN";
30718
+ length = 3;
30719
+ }
30720
break;
30721
}
30722
+
30723
+ /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
30724
+ if( ALWAYS(realvalue>0.0) ){
30725
+ LONGDOUBLE_TYPE scale = 1.0;
30726
+ while( realvalue>=1e100*scale && exp<=350){ scale*=1e100;exp+=100;}
30727
+ while( realvalue>=1e10*scale && exp<=350 ){ scale*=1e10; exp+=10; }
30728
+ while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; }
30729
+ realvalue /= scale;
30730
+ while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }
30731
+ while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }
30732
+ if( exp>350 ){
30733
+ if( flag_zeropad ){
30734
+ realvalue = 9.0;
30735
+ exp = 999;
30736
+ }else{
30737
+ bufpt = buf;
30738
+ buf[0] = prefix;
30739
+ memcpy(buf+(prefix!=0),"Inf",4);
30740
+ length = 3+(prefix!=0);
30741
+ break;
30742
+ }
30743
+ }
30744
+ if( xtype!=etFLOAT ){
30745
+ realvalue += rounder;
30746
+ if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }
30747
+ }
30748
+ }
30749
}
30516
- bufpt = buf;
30750
+
30751
/*
30752
** If the field type is etGENERIC, then convert to either etEXP
30753
** or etFLOAT, as appropriate.
30754
*/
30521
- if( xtype!=etFLOAT ){
30522
- realvalue += rounder;
30523
- if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }
30524
- }
30755
if( xtype==etGENERIC ){
30756
flag_rtz = !flag_alternateform;
30757
if( exp<-4 || exp>precision ){
@@ -30538,16 +30768,18 @@ SQLITE_API void sqlite3_str_vappendf(
30768
}else{
30769
e2 = exp;
30770
}
30771
+ nsd = 16 + flag_altform2*10;
30772
+ bufpt = buf;
30773
{
30774
i64 szBufNeeded; /* Size of a temporary buffer needed */
30775
szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
30776
+ if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
30777
if( szBufNeeded > etBUFSIZE ){
30778
bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
30779
if( bufpt==0 ) return;
30780
}
30781
}
30782
zOut = bufpt;
30550
- nsd = 16 + flag_altform2*10;
30783
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
30784
/* The sign in front of the number */
30785
if( prefix ){
@@ -30556,9 +30788,15 @@ SQLITE_API void sqlite3_str_vappendf(
30788
/* Digits prior to the decimal point */
30789
if( e2<0 ){
30790
*(bufpt++) = '0';
30791
+ }else if( msd>0 ){
30792
+ for(; e2>=0; e2--){
30793
+ *(bufpt++) = et_getdigit_int(&longvalue,&msd);
30794
+ if( cThousand && (e2%3)==0 && e2>1 ) *(bufpt++) = ',';
30795
+ }
30796
}else{
30797
for(; e2>=0; e2--){
30798
*(bufpt++) = et_getdigit(&realvalue,&nsd);
30799
+ if( cThousand && (e2%3)==0 && e2>1 ) *(bufpt++) = ',';
30800
}
30801
}
30802
/* The decimal point */
@@ -30572,8 +30810,14 @@ SQLITE_API void sqlite3_str_vappendf(
30810
*(bufpt++) = '0';
30811
}
30812
/* Significant digits after the decimal point */
30575
- while( (precision--)>0 ){
30576
- *(bufpt++) = et_getdigit(&realvalue,&nsd);
30813
+ if( msd>0 ){
30814
+ while( (precision--)>0 ){
30815
+ *(bufpt++) = et_getdigit_int(&longvalue,&msd);
30816
+ }
30817
+ }else{
30818
+ while( (precision--)>0 ){
30819
+ *(bufpt++) = et_getdigit(&realvalue,&nsd);
30820
+ }
30821
}
30822
/* Remove trailing zeros and the "." if no digits follow the "." */
30823
if( flag_rtz && flag_dp ){
@@ -31254,12 +31498,22 @@ SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_li
31498
return zBuf;
31499
}
31500
SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
31257
- char *z;
31501
+ StrAccum acc;
31502
va_list ap;
31503
+ if( n<=0 ) return zBuf;
31504
+#ifdef SQLITE_ENABLE_API_ARMOR
31505
+ if( zBuf==0 || zFormat==0 ) {
31506
+ (void)SQLITE_MISUSE_BKPT;
31507
+ if( zBuf ) zBuf[0] = 0;
31508
+ return zBuf;
31509
+ }
31510
+#endif
31511
+ sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);
31512
va_start(ap,zFormat);
31260
- z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
31513
+ sqlite3_str_vappendf(&acc, zFormat, ap);
31514
va_end(ap);
31262
- return z;
31515
+ zBuf[acc.nChar] = 0;
31516
+ return zBuf;
31517
}
31518
31519
/*
@@ -34289,13 +34543,15 @@ SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
34543
}
34544
i = sizeof(zTemp)-2;
34545
zTemp[sizeof(zTemp)-1] = 0;
34292
- do{
34293
- zTemp[i--] = (x%10) + '0';
34546
+ while( 1 /*exit-by-break*/ ){
34547
+ zTemp[i] = (x%10) + '0';
34548
x = x/10;
34295
- }while( x );
34296
- if( v<0 ) zTemp[i--] = '-';
34297
- memcpy(zOut, &zTemp[i+1], sizeof(zTemp)-1-i);
34298
- return sizeof(zTemp)-2-i;
34549
+ if( x==0 ) break;
34550
+ i--;
34551
+ };
34552
+ if( v<0 ) zTemp[--i] = '-';
34553
+ memcpy(zOut, &zTemp[i], sizeof(zTemp)-i);
34554
+ return sizeof(zTemp)-1-i;
34555
}
34556
34557
/*
@@ -34460,7 +34716,9 @@ SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char *z, i64 *pOut){
34716
u = u*16 + sqlite3HexToInt(z[k]);
34717
}
34718
memcpy(pOut, &u, 8);
34463
- return (z[k]==0 && k-i<=16) ? 0 : 2;
34719
+ if( k-i>16 ) return 2;
34720
+ if( z[k]!=0 ) return 1;
34721
+ return 0;
34722
}else
34723
#endif /* SQLITE_OMIT_HEX_INTEGER */
34724
{
@@ -34496,7 +34754,7 @@ SQLITE_PRIVATE int sqlite3GetInt32(const char *zNum, int *pValue){
34754
u32 u = 0;
34755
zNum += 2;
34756
while( zNum[0]=='0' ) zNum++;
34499
- for(i=0; sqlite3Isxdigit(zNum[i]) && i<8; i++){
34757
+ for(i=0; i<8 && sqlite3Isxdigit(zNum[i]); i++){
34758
u = u*16 + sqlite3HexToInt(zNum[i]);
34759
}
34760
if( (u&0x80000000)==0 && sqlite3Isxdigit(zNum[i])==0 ){
@@ -36992,7 +37250,7 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){
37250
#endif
37251
37252
/* Use pread() and pwrite() if they are available */
36995
-#if defined(__APPLE__)
37253
+#if defined(__APPLE__) || defined(__linux__)
37254
# define HAVE_PREAD 1
37255
# define HAVE_PWRITE 1
37256
#endif
@@ -40242,12 +40500,6 @@ static int nfsUnlock(sqlite3_file *id, int eFileLock){
40500
** Seek to the offset passed as the second argument, then read cnt
40501
** bytes into pBuf. Return the number of bytes actually read.
40502
**
40245
-** NB: If you define USE_PREAD or USE_PREAD64, then it might also
40246
-** be necessary to define _XOPEN_SOURCE to be 500. This varies from
40247
-** one system to another. Since SQLite does not define USE_PREAD
40248
-** in any form by default, we will not attempt to define _XOPEN_SOURCE.
40249
-** See tickets #2741 and #2681.
40250
-**
40503
** To avoid stomping the errno value on a failed read the lastErrno value
40504
** is set before returning.
40505
*/
@@ -50274,7 +50526,7 @@ static int winOpen(
50526
if( isReadWrite ){
50527
int rc2, isRO = 0;
50528
sqlite3BeginBenignMalloc();
50277
- rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);
50529
+ rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO);
50530
sqlite3EndBenignMalloc();
50531
if( rc2==SQLITE_OK && isRO ) break;
50532
}
@@ -50291,7 +50543,7 @@ static int winOpen(
50543
if( isReadWrite ){
50544
int rc2, isRO = 0;
50545
sqlite3BeginBenignMalloc();
50294
- rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);
50546
+ rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO);
50547
sqlite3EndBenignMalloc();
50548
if( rc2==SQLITE_OK && isRO ) break;
50549
}
@@ -50311,7 +50563,7 @@ static int winOpen(
50563
if( isReadWrite ){
50564
int rc2, isRO = 0;
50565
sqlite3BeginBenignMalloc();
50314
- rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);
50566
+ rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO);
50567
sqlite3EndBenignMalloc();
50568
if( rc2==SQLITE_OK && isRO ) break;
50569
}
@@ -50534,6 +50786,13 @@ static int winAccess(
50786
OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n",
50787
zFilename, flags, pResOut));
50788
50789
+ if( zFilename==0 ){
50790
+ *pResOut = 0;
50791
+ OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
50792
+ zFilename, pResOut, *pResOut));
50793
+ return SQLITE_OK;
50794
+ }
50795
+
50796
zConverted = winConvertFromUtf8Filename(zFilename);
50797
if( zConverted==0 ){
50798
OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
@@ -52690,11 +52949,15 @@ struct PCache {
52949
PgHdr *pPg;
52950
unsigned char *a;
52951
int j;
52693
- pPg = (PgHdr*)pLower->pExtra;
52694
- printf("%3lld: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags);
52695
- a = (unsigned char *)pLower->pBuf;
52696
- for(j=0; j<12; j++) printf("%02x", a[j]);
52697
- printf(" ptr %p\n", pPg);
52952
+ if( pLower==0 ){
52953
+ printf("%3d: NULL\n", i);
52954
+ }else{
52955
+ pPg = (PgHdr*)pLower->pExtra;
52956
+ printf("%3d: nRef %2lld flgs %02x data ", i, pPg->nRef, pPg->flags);
52957
+ a = (unsigned char *)pLower->pBuf;
52958
+ for(j=0; j<12; j++) printf("%02x", a[j]);
52959
+ printf(" ptr %p\n", pPg);
52960
+ }
52961
}
52962
static void pcacheDump(PCache *pCache){
52963
int N;
@@ -52707,9 +52970,8 @@ struct PCache {
52970
if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump;
52971
for(i=1; i<=N; i++){
52972
pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0);
52710
- if( pLower==0 ) continue;
52973
pcachePageTrace(i, pLower);
52712
- if( ((PgHdr*)pLower)->pPage==0 ){
52974
+ if( pLower && ((PgHdr*)pLower)->pPage==0 ){
52975
sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0);
52976
}
52977
}
@@ -58097,6 +58359,8 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
58359
int rc = SQLITE_OK;
58360
assert( pPager->eState!=PAGER_ERROR );
58361
assert( pPager->eState!=PAGER_READER );
58362
+ PAGERTRACE(("Truncate %d npage %u\n", PAGERID(pPager), nPage));
58363
+
58364
58365
if( isOpen(pPager->fd)
58366
&& (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
@@ -61014,6 +61278,10 @@ static int getPageNormal(
61278
if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){
61279
if( pgno>pPager->mxPgno ){
61280
rc = SQLITE_FULL;
61281
+ if( pgno<=pPager->dbSize ){
61282
+ sqlite3PcacheRelease(pPg);
61283
+ pPg = 0;
61284
+ }
61285
goto pager_acquire_err;
61286
}
61287
if( noContent ){
@@ -61178,10 +61446,12 @@ SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
61446
/*
61447
** Release a page reference.
61448
**
61181
-** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be
61182
-** used if we know that the page being released is not the last page.
61449
+** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be used
61450
+** if we know that the page being released is not the last reference to page1.
61451
** The btree layer always holds page1 open until the end, so these first
61184
-** to routines can be used to release any page other than BtShared.pPage1.
61452
+** two routines can be used to release any page other than BtShared.pPage1.
61453
+** The assert() at tag-20230419-2 proves that this constraint is always
61454
+** honored.
61455
**
61456
** Use sqlite3PagerUnrefPageOne() to release page1. This latter routine
61457
** checks the total number of outstanding pages and if the number of
@@ -61197,7 +61467,7 @@ SQLITE_PRIVATE void sqlite3PagerUnrefNotNull(DbPage *pPg){
61467
sqlite3PcacheRelease(pPg);
61468
}
61469
/* Do not use this routine to release the last reference to page1 */
61200
- assert( sqlite3PcacheRefCount(pPager->pPCache)>0 );
61470
+ assert( sqlite3PcacheRefCount(pPager->pPCache)>0 ); /* tag-20230419-2 */
61471
}
61472
SQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){
61473
if( pPg ) sqlite3PagerUnrefNotNull(pPg);
@@ -62957,13 +63227,15 @@ SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){
63227
*/
63228
static int pagerExclusiveLock(Pager *pPager){
63229
int rc; /* Return code */
63230
+ u8 eOrigLock; /* Original lock */
63231
62961
- assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );
63232
+ assert( pPager->eLock>=SHARED_LOCK );
63233
+ eOrigLock = pPager->eLock;
63234
rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
63235
if( rc!=SQLITE_OK ){
63236
/* If the attempt to grab the exclusive lock failed, release the
63237
** pending lock that may have been obtained instead. */
62966
- pagerUnlockDb(pPager, SHARED_LOCK);
63238
+ pagerUnlockDb(pPager, eOrigLock);
63239
}
63240
63241
return rc;
@@ -63968,19 +64240,40 @@ static void walChecksumBytes(
64240
assert( nByte>=8 );
64241
assert( (nByte&0x00000007)==0 );
64242
assert( nByte<=65536 );
64243
+ assert( nByte%4==0 );
64244
63972
- if( nativeCksum ){
64245
+ if( !nativeCksum ){
64246
+ do {
64247
+ s1 += BYTESWAP32(aData[0]) + s2;
64248
+ s2 += BYTESWAP32(aData[1]) + s1;
64249
+ aData += 2;
64250
+ }while( aData<aEnd );
64251
+ }else if( nByte%64==0 ){
64252
do {
64253
s1 += *aData++ + s2;
64254
s2 += *aData++ + s1;
64255
+ s1 += *aData++ + s2;
64256
+ s2 += *aData++ + s1;
64257
+ s1 += *aData++ + s2;
64258
+ s2 += *aData++ + s1;
64259
+ s1 += *aData++ + s2;
64260
+ s2 += *aData++ + s1;
64261
+ s1 += *aData++ + s2;
64262
+ s2 += *aData++ + s1;
64263
+ s1 += *aData++ + s2;
64264
+ s2 += *aData++ + s1;
64265
+ s1 += *aData++ + s2;
64266
+ s2 += *aData++ + s1;
64267
+ s1 += *aData++ + s2;
64268
+ s2 += *aData++ + s1;
64269
}while( aData<aEnd );
64270
}else{
64271
do {
63979
- s1 += BYTESWAP32(aData[0]) + s2;
63980
- s2 += BYTESWAP32(aData[1]) + s1;
63981
- aData += 2;
64272
+ s1 += *aData++ + s2;
64273
+ s2 += *aData++ + s1;
64274
}while( aData<aEnd );
64275
}
64276
+ assert( aData==aEnd );
64277
64278
aOut[0] = s1;
64279
aOut[1] = s2;
@@ -66911,7 +67204,9 @@ SQLITE_PRIVATE int sqlite3WalFrames(
67204
if( rc ) return rc;
67205
}
67206
}
66914
- assert( (int)pWal->szPage==szPage );
67207
+ if( (int)pWal->szPage!=szPage ){
67208
+ return SQLITE_CORRUPT_BKPT; /* TH3 test case: cov1/corrupt155.test */
67209
+ }
67210
67211
/* Setup information needed to write frames into the WAL */
67212
w.pWal = pWal;
@@ -67571,7 +67866,7 @@ SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal){
67866
** byte are used. The integer consists of all bytes that have bit 8 set and
67867
** the first byte with bit 8 clear. The most significant byte of the integer
67868
** appears first. A variable-length integer may not be more than 9 bytes long.
67574
-** As a special case, all 8 bytes of the 9th byte are used as data. This
67869
+** As a special case, all 8 bits of the 9th byte are used as data. This
67870
** allows a 64-bit integer to be encoded in 9 bytes.
67871
**
67872
** 0x00 becomes 0x00000000
@@ -67955,7 +68250,7 @@ struct BtCursor {
68250
#define BTCF_WriteFlag 0x01 /* True if a write cursor */
68251
#define BTCF_ValidNKey 0x02 /* True if info.nKey is valid */
68252
#define BTCF_ValidOvfl 0x04 /* True if aOverflow is valid */
67958
-#define BTCF_AtLast 0x08 /* Cursor is pointing ot the last entry */
68253
+#define BTCF_AtLast 0x08 /* Cursor is pointing to the last entry */
68254
#define BTCF_Incrblob 0x10 /* True if an incremental I/O handle */
68255
#define BTCF_Multiple 0x20 /* Maybe another cursor on the same btree */
68256
#define BTCF_Pinned 0x40 /* Cursor is busy and cannot be moved */
@@ -68100,8 +68395,9 @@ struct IntegrityCk {
68395
int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */
68396
u32 nStep; /* Number of steps into the integrity_check process */
68397
const char *zPfx; /* Error message prefix */
68103
- Pgno v1; /* Value for first %u substitution in zPfx */
68104
- int v2; /* Value for second %d substitution in zPfx */
68398
+ Pgno v0; /* Value for first %u substitution in zPfx (root page) */
68399
+ Pgno v1; /* Value for second %u substitution in zPfx (current pg) */
68400
+ int v2; /* Value for third %d substitution in zPfx */
68401
StrAccum errMsg; /* Accumulate the error message text here */
68402
u32 *heap; /* Min-heap used for analyzing cell coverage */
68403
sqlite3 *db; /* Database connection running the check */
@@ -68564,8 +68860,8 @@ SQLITE_PRIVATE sqlite3_uint64 sqlite3BtreeSeekCount(Btree *pBt){
68860
int corruptPageError(int lineno, MemPage *p){
68861
char *zMsg;
68862
sqlite3BeginBenignMalloc();
68567
- zMsg = sqlite3_mprintf("database corruption page %d of %s",
68568
- (int)p->pgno, sqlite3PagerFilename(p->pBt->pPager, 0)
68863
+ zMsg = sqlite3_mprintf("database corruption page %u of %s",
68864
+ p->pgno, sqlite3PagerFilename(p->pBt->pPager, 0)
68865
);
68866
sqlite3EndBenignMalloc();
68867
if( zMsg ){
@@ -69374,8 +69670,25 @@ SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow)
69670
*/
69671
SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){
69672
/* Used only by system that substitute their own storage engine */
69673
+#ifdef SQLITE_DEBUG
69674
+ if( ALWAYS(eHintType==BTREE_HINT_RANGE) ){
69675
+ va_list ap;
69676
+ Expr *pExpr;
69677
+ Walker w;
69678
+ memset(&w, 0, sizeof(w));
69679
+ w.xExprCallback = sqlite3CursorRangeHintExprCheck;
69680
+ va_start(ap, eHintType);
69681
+ pExpr = va_arg(ap, Expr*);
69682
+ w.u.aMem = va_arg(ap, Mem*);
69683
+ va_end(ap);
69684
+ assert( pExpr!=0 );
69685
+ assert( w.u.aMem!=0 );
69686
+ sqlite3WalkExpr(&w, pExpr);
69687
+ }
69688
+#endif /* SQLITE_DEBUG */
69689
}
69378
-#endif
69690
+#endif /* SQLITE_ENABLE_CURSOR_HINTS */
69691
+
69692
69693
/*
69694
** Provide flag hints to the cursor.
@@ -69460,7 +69773,7 @@ static void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){
69773
pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);
69774
69775
if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){
69463
- TRACE(("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent));
69776
+ TRACE(("PTRMAP_UPDATE: %u->(%u,%u)\n", key, eType, parent));
69777
*pRC= rc = sqlite3PagerWrite(pDbPage);
69778
if( rc==SQLITE_OK ){
69779
pPtrmap[offset] = eType;
@@ -69659,27 +69972,31 @@ static void btreeParseCellPtr(
69972
iKey = *pIter;
69973
if( iKey>=0x80 ){
69974
u8 x;
69662
- iKey = ((iKey&0x7f)<<7) | ((x = *++pIter) & 0x7f);
69975
+ iKey = (iKey<<7) ^ (x = *++pIter);
69976
if( x>=0x80 ){
69664
- iKey = (iKey<<7) | ((x =*++pIter) & 0x7f);
69977
+ iKey = (iKey<<7) ^ (x = *++pIter);
69978
if( x>=0x80 ){
69666
- iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
69979
+ iKey = (iKey<<7) ^ 0x10204000 ^ (x = *++pIter);
69980
if( x>=0x80 ){
69668
- iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
69981
+ iKey = (iKey<<7) ^ 0x4000 ^ (x = *++pIter);
69982
if( x>=0x80 ){
69670
- iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
69983
+ iKey = (iKey<<7) ^ 0x4000 ^ (x = *++pIter);
69984
if( x>=0x80 ){
69672
- iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
69985
+ iKey = (iKey<<7) ^ 0x4000 ^ (x = *++pIter);
69986
if( x>=0x80 ){
69674
- iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
69987
+ iKey = (iKey<<7) ^ 0x4000 ^ (x = *++pIter);
69988
if( x>=0x80 ){
69676
- iKey = (iKey<<8) | (*++pIter);
69989
+ iKey = (iKey<<8) ^ 0x8000 ^ (*++pIter);
69990
}
69991
}
69992
}
69993
}
69994
}
69995
+ }else{
69996
+ iKey ^= 0x204000;
69997
}
69998
+ }else{
69999
+ iKey ^= 0x4000;
70000
}
70001
}
70002
pIter++;
@@ -69756,10 +70073,11 @@ static void btreeParseCell(
70073
**
70074
** cellSizePtrNoPayload() => table internal nodes
70075
** cellSizePtrTableLeaf() => table leaf nodes
69759
-** cellSizePtr() => all index nodes & table leaf nodes
70076
+** cellSizePtr() => index internal nodes
70077
+** cellSizeIdxLeaf() => index leaf nodes
70078
*/
70079
static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
69762
- u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */
70080
+ u8 *pIter = pCell + 4; /* For looping over bytes of pCell */
70081
u8 *pEnd; /* End mark for a varint */
70082
u32 nSize; /* Size value to return */
70083
@@ -69772,6 +70090,49 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
70090
pPage->xParseCell(pPage, pCell, &debuginfo);
70091
#endif
70092
70093
+ assert( pPage->childPtrSize==4 );
70094
+ nSize = *pIter;
70095
+ if( nSize>=0x80 ){
70096
+ pEnd = &pIter[8];
70097
+ nSize &= 0x7f;
70098
+ do{
70099
+ nSize = (nSize<<7) | (*++pIter & 0x7f);
70100
+ }while( *(pIter)>=0x80 && pIter<pEnd );
70101
+ }
70102
+ pIter++;
70103
+ testcase( nSize==pPage->maxLocal );
70104
+ testcase( nSize==(u32)pPage->maxLocal+1 );
70105
+ if( nSize<=pPage->maxLocal ){
70106
+ nSize += (u32)(pIter - pCell);
70107
+ assert( nSize>4 );
70108
+ }else{
70109
+ int minLocal = pPage->minLocal;
70110
+ nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
70111
+ testcase( nSize==pPage->maxLocal );
70112
+ testcase( nSize==(u32)pPage->maxLocal+1 );
70113
+ if( nSize>pPage->maxLocal ){
70114
+ nSize = minLocal;
70115
+ }
70116
+ nSize += 4 + (u16)(pIter - pCell);
70117
+ }
70118
+ assert( nSize==debuginfo.nSize || CORRUPT_DB );
70119
+ return (u16)nSize;
70120
+}
70121
+static u16 cellSizePtrIdxLeaf(MemPage *pPage, u8 *pCell){
70122
+ u8 *pIter = pCell; /* For looping over bytes of pCell */
70123
+ u8 *pEnd; /* End mark for a varint */
70124
+ u32 nSize; /* Size value to return */
70125
+
70126
+#ifdef SQLITE_DEBUG
70127
+ /* The value returned by this function should always be the same as
70128
+ ** the (CellInfo.nSize) value found by doing a full parse of the
70129
+ ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of
70130
+ ** this function verifies that this invariant is not violated. */
70131
+ CellInfo debuginfo;
70132
+ pPage->xParseCell(pPage, pCell, &debuginfo);
70133
+#endif
70134
+
70135
+ assert( pPage->childPtrSize==0 );
70136
nSize = *pIter;
70137
if( nSize>=0x80 ){
70138
pEnd = &pIter[8];
@@ -70008,10 +70369,10 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
70369
/* These conditions have already been verified in btreeInitPage()
70370
** if PRAGMA cell_size_check=ON.
70371
*/
70011
- if( pc<iCellStart || pc>iCellLast ){
70372
+ if( pc>iCellLast ){
70373
return SQLITE_CORRUPT_PAGE(pPage);
70374
}
70014
- assert( pc>=iCellStart && pc<=iCellLast );
70375
+ assert( pc>=0 && pc<=iCellLast );
70376
size = pPage->xCellSize(pPage, &src[pc]);
70377
cbrk -= size;
70378
if( cbrk<iCellStart || pc+size>usableSize ){
@@ -70126,7 +70487,7 @@ static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){
70487
** allocation is being made in order to insert a new cell, so we will
70488
** also end up needing a new cell pointer.
70489
*/
70129
-static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70490
+static SQLITE_INLINE int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70491
const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
70492
u8 * const data = pPage->aData; /* Local cache of pPage->aData */
70493
int top; /* First byte of cell content area */
@@ -70152,13 +70513,14 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70513
** integer, so a value of 0 is used in its place. */
70514
pTmp = &data[hdr+5];
70515
top = get2byte(pTmp);
70155
- assert( top<=(int)pPage->pBt->usableSize ); /* by btreeComputeFreeSpace() */
70516
if( gap>top ){
70517
if( top==0 && pPage->pBt->usableSize==65536 ){
70518
top = 65536;
70519
}else{
70520
return SQLITE_CORRUPT_PAGE(pPage);
70521
}
70522
+ }else if( top>(int)pPage->pBt->usableSize ){
70523
+ return SQLITE_CORRUPT_PAGE(pPage);
70524
}
70525
70526
/* If there is enough space between gap and top for one more cell pointer,
@@ -70241,7 +70603,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
70603
assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
70604
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
70605
assert( iSize>=4 ); /* Minimum cell size is 4 */
70244
- assert( iStart<=pPage->pBt->usableSize-4 );
70606
+ assert( CORRUPT_DB || iStart<=pPage->pBt->usableSize-4 );
70607
70608
/* The list of freeblocks must be in ascending order. Find the
70609
** spot on the list where iStart should be inserted.
@@ -70298,6 +70660,11 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
70660
}
70661
pTmp = &data[hdr+5];
70662
x = get2byte(pTmp);
70663
+ if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
70664
+ /* Overwrite deleted information with zeros when the secure_delete
70665
+ ** option is enabled */
70666
+ memset(&data[iStart], 0, iSize);
70667
+ }
70668
if( iStart<=x ){
70669
/* The new freeblock is at the beginning of the cell content area,
70670
** so just extend the cell content area rather than create another
@@ -70309,14 +70676,9 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
70676
}else{
70677
/* Insert the new freeblock into the freelist */
70678
put2byte(&data[iPtr], iStart);
70679
+ put2byte(&data[iStart], iFreeBlk);
70680
+ put2byte(&data[iStart+2], iSize);
70681
}
70313
- if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
70314
- /* Overwrite deleted information with zeros when the secure_delete
70315
- ** option is enabled */
70316
- memset(&data[iStart], 0, iSize);
70317
- }
70318
- put2byte(&data[iStart], iFreeBlk);
70319
- put2byte(&data[iStart+2], iSize);
70682
pPage->nFree += iOrigSize;
70683
return SQLITE_OK;
70684
}
@@ -70353,14 +70715,14 @@ static int decodeFlags(MemPage *pPage, int flagByte){
70715
}else if( flagByte==(PTF_ZERODATA | PTF_LEAF) ){
70716
pPage->intKey = 0;
70717
pPage->intKeyLeaf = 0;
70356
- pPage->xCellSize = cellSizePtr;
70718
+ pPage->xCellSize = cellSizePtrIdxLeaf;
70719
pPage->xParseCell = btreeParseCellPtrIndex;
70720
pPage->maxLocal = pBt->maxLocal;
70721
pPage->minLocal = pBt->minLocal;
70722
}else{
70723
pPage->intKey = 0;
70724
pPage->intKeyLeaf = 0;
70363
- pPage->xCellSize = cellSizePtr;
70725
+ pPage->xCellSize = cellSizePtrIdxLeaf;
70726
pPage->xParseCell = btreeParseCellPtrIndex;
70727
return SQLITE_CORRUPT_PAGE(pPage);
70728
}
@@ -72226,7 +72588,7 @@ static int relocatePage(
72588
if( iDbPage<3 ) return SQLITE_CORRUPT_BKPT;
72589
72590
/* Move page iDbPage from its current location to page number iFreePage */
72229
- TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
72591
+ TRACE(("AUTOVACUUM: Moving %u to free page %u (ptr page %u type %u)\n",
72592
iDbPage, iFreePage, iPtrPage, eType));
72593
rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
72594
if( rc!=SQLITE_OK ){
@@ -74512,7 +74874,8 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
74874
74875
pPage = pCur->pPage;
74876
idx = ++pCur->ix;
74515
- if( !pPage->isInit || sqlite3FaultSim(412) ){
74877
+ if( sqlite3FaultSim(412) ) pPage->isInit = 0;
74878
+ if( !pPage->isInit ){
74879
return SQLITE_CORRUPT_BKPT;
74880
}
74881
@@ -74775,7 +75138,7 @@ static int allocateBtreePage(
75138
memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
75139
*ppPage = pTrunk;
75140
pTrunk = 0;
74778
- TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
75141
+ TRACE(("ALLOCATE: %u trunk - %u free pages left\n", *pPgno, n-1));
75142
}else if( k>(u32)(pBt->usableSize/4 - 2) ){
75143
/* Value of k is out of range. Database corruption */
75144
rc = SQLITE_CORRUPT_PGNO(iTrunk);
@@ -74841,7 +75204,7 @@ static int allocateBtreePage(
75204
}
75205
}
75206
pTrunk = 0;
74844
- TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
75207
+ TRACE(("ALLOCATE: %u trunk - %u free pages left\n", *pPgno, n-1));
75208
#endif
75209
}else if( k>0 ){
75210
/* Extract a leaf from the trunk */
@@ -74886,8 +75249,8 @@ static int allocateBtreePage(
75249
){
75250
int noContent;
75251
*pPgno = iPage;
74889
- TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
74890
- ": %d more free pages\n",
75252
+ TRACE(("ALLOCATE: %u was leaf %u of %u on trunk %u"
75253
+ ": %u more free pages\n",
75254
*pPgno, closest+1, k, pTrunk->pgno, n-1));
75255
rc = sqlite3PagerWrite(pTrunk->pDbPage);
75256
if( rc ) goto end_allocate_page;
@@ -74943,7 +75306,7 @@ static int allocateBtreePage(
75306
** becomes a new pointer-map page, the second is used by the caller.
75307
*/
75308
MemPage *pPg = 0;
74946
- TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", pBt->nPage));
75309
+ TRACE(("ALLOCATE: %u from end of file (pointer-map page)\n", pBt->nPage));
75310
assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );
75311
rc = btreeGetUnusedPage(pBt, pBt->nPage, &pPg, bNoContent);
75312
if( rc==SQLITE_OK ){
@@ -74966,7 +75329,7 @@ static int allocateBtreePage(
75329
releasePage(*ppPage);
75330
*ppPage = 0;
75331
}
74969
- TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
75332
+ TRACE(("ALLOCATE: %u from end of file\n", *pPgno));
75333
}
75334
75335
assert( CORRUPT_DB || *pPgno!=PENDING_BYTE_PAGE(pBt) );
@@ -75094,7 +75457,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
75457
}
75458
rc = btreeSetHasContent(pBt, iPage);
75459
}
75097
- TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno));
75460
+ TRACE(("FREE-PAGE: %u leaf on trunk page %u\n",pPage->pgno,pTrunk->pgno));
75461
goto freepage_out;
75462
}
75463
}
@@ -75115,7 +75478,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
75478
put4byte(pPage->aData, iTrunk);
75479
put4byte(&pPage->aData[4], 0);
75480
put4byte(&pPage1->aData[32], iPage);
75118
- TRACE(("FREE-PAGE: %d new trunk page replacing %d\n", pPage->pgno, iTrunk));
75481
+ TRACE(("FREE-PAGE: %u new trunk page replacing %u\n", pPage->pgno, iTrunk));
75482
75483
freepage_out:
75484
if( pPage ){
@@ -75474,6 +75837,14 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
75837
** in pTemp or the original pCell) and also record its index.
75838
** Allocating a new entry in pPage->aCell[] implies that
75839
** pPage->nOverflow is incremented.
75840
+**
75841
+** The insertCellFast() routine below works exactly the same as
75842
+** insertCell() except that it lacks the pTemp and iChild parameters
75843
+** which are assumed zero. Other than that, the two routines are the
75844
+** same.
75845
+**
75846
+** Fixes or enhancements to this routine should be reflected in
75847
+** insertCellFast()!
75848
*/
75849
static int insertCell(
75850
MemPage *pPage, /* Page into which we are copying */
@@ -75496,14 +75867,103 @@ static int insertCell(
75867
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
75868
assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
75869
assert( pPage->nFree>=0 );
75870
+ assert( iChild>0 );
75871
if( pPage->nOverflow || sz+2>pPage->nFree ){
75872
if( pTemp ){
75873
memcpy(pTemp, pCell, sz);
75874
pCell = pTemp;
75875
}
75504
- if( iChild ){
75505
- put4byte(pCell, iChild);
75876
+ put4byte(pCell, iChild);
75877
+ j = pPage->nOverflow++;
75878
+ /* Comparison against ArraySize-1 since we hold back one extra slot
75879
+ ** as a contingency. In other words, never need more than 3 overflow
75880
+ ** slots but 4 are allocated, just to be safe. */
75881
+ assert( j < ArraySize(pPage->apOvfl)-1 );
75882
+ pPage->apOvfl[j] = pCell;
75883
+ pPage->aiOvfl[j] = (u16)i;
75884
+
75885
+ /* When multiple overflows occur, they are always sequential and in
75886
+ ** sorted order. This invariants arise because multiple overflows can
75887
+ ** only occur when inserting divider cells into the parent page during
75888
+ ** balancing, and the dividers are adjacent and sorted.
75889
+ */
75890
+ assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */
75891
+ assert( j==0 || i==pPage->aiOvfl[j-1]+1 ); /* Overflows are sequential */
75892
+ }else{
75893
+ int rc = sqlite3PagerWrite(pPage->pDbPage);
75894
+ if( NEVER(rc!=SQLITE_OK) ){
75895
+ return rc;
75896
+ }
75897
+ assert( sqlite3PagerIswriteable(pPage->pDbPage) );
75898
+ data = pPage->aData;
75899
+ assert( &data[pPage->cellOffset]==pPage->aCellIdx );
75900
+ rc = allocateSpace(pPage, sz, &idx);
75901
+ if( rc ){ return rc; }
75902
+ /* The allocateSpace() routine guarantees the following properties
75903
+ ** if it returns successfully */
75904
+ assert( idx >= 0 );
75905
+ assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
75906
+ assert( idx+sz <= (int)pPage->pBt->usableSize );
75907
+ pPage->nFree -= (u16)(2 + sz);
75908
+ /* In a corrupt database where an entry in the cell index section of
75909
+ ** a btree page has a value of 3 or less, the pCell value might point
75910
+ ** as many as 4 bytes in front of the start of the aData buffer for
75911
+ ** the source page. Make sure this does not cause problems by not
75912
+ ** reading the first 4 bytes */
75913
+ memcpy(&data[idx+4], pCell+4, sz-4);
75914
+ put4byte(&data[idx], iChild);
75915
+ pIns = pPage->aCellIdx + i*2;
75916
+ memmove(pIns+2, pIns, 2*(pPage->nCell - i));
75917
+ put2byte(pIns, idx);
75918
+ pPage->nCell++;
75919
+ /* increment the cell count */
75920
+ if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;
75921
+ assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell || CORRUPT_DB );
75922
+#ifndef SQLITE_OMIT_AUTOVACUUM
75923
+ if( pPage->pBt->autoVacuum ){
75924
+ int rc2 = SQLITE_OK;
75925
+ /* The cell may contain a pointer to an overflow page. If so, write
75926
+ ** the entry for the overflow page into the pointer map.
75927
+ */
75928
+ ptrmapPutOvflPtr(pPage, pPage, pCell, &rc2);
75929
+ if( rc2 ) return rc2;
75930
}
75931
+#endif
75932
+ }
75933
+ return SQLITE_OK;
75934
+}
75935
+
75936
+/*
75937
+** This variant of insertCell() assumes that the pTemp and iChild
75938
+** parameters are both zero. Use this variant in sqlite3BtreeInsert()
75939
+** for performance improvement, and also so that this variant is only
75940
+** called from that one place, and is thus inlined, and thus runs must
75941
+** faster.
75942
+**
75943
+** Fixes or enhancements to this routine should be reflected into
75944
+** the insertCell() routine.
75945
+*/
75946
+static int insertCellFast(
75947
+ MemPage *pPage, /* Page into which we are copying */
75948
+ int i, /* New cell becomes the i-th cell of the page */
75949
+ u8 *pCell, /* Content of the new cell */
75950
+ int sz /* Bytes of content in pCell */
75951
+){
75952
+ int idx = 0; /* Where to write new cell content in data[] */
75953
+ int j; /* Loop counter */
75954
+ u8 *data; /* The content of the whole page */
75955
+ u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
75956
+
75957
+ assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
75958
+ assert( MX_CELL(pPage->pBt)<=10921 );
75959
+ assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
75960
+ assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
75961
+ assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
75962
+ assert( sqlite3_mutex_held(pPage->pBt->mutex) );
75963
+ assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
75964
+ assert( pPage->nFree>=0 );
75965
+ assert( pPage->nOverflow==0 );
75966
+ if( sz+2>pPage->nFree ){
75967
j = pPage->nOverflow++;
75968
/* Comparison against ArraySize-1 since we hold back one extra slot
75969
** as a contingency. In other words, never need more than 3 overflow
@@ -75535,17 +75995,7 @@ static int insertCell(
75995
assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
75996
assert( idx+sz <= (int)pPage->pBt->usableSize );
75997
pPage->nFree -= (u16)(2 + sz);
75538
- if( iChild ){
75539
- /* In a corrupt database where an entry in the cell index section of
75540
- ** a btree page has a value of 3 or less, the pCell value might point
75541
- ** as many as 4 bytes in front of the start of the aData buffer for
75542
- ** the source page. Make sure this does not cause problems by not
75543
- ** reading the first 4 bytes */
75544
- memcpy(&data[idx+4], pCell+4, sz-4);
75545
- put4byte(&data[idx], iChild);
75546
- }else{
75547
- memcpy(&data[idx], pCell, sz);
75548
- }
75998
+ memcpy(&data[idx], pCell, sz);
75999
pIns = pPage->aCellIdx + i*2;
76000
memmove(pIns+2, pIns, 2*(pPage->nCell - i));
76001
put2byte(pIns, idx);
@@ -75730,7 +76180,7 @@ static int rebuildPage(
76180
76181
assert( i<iEnd );
76182
j = get2byte(&aData[hdr+5]);
75733
- if( j>(u32)usableSize ){ j = 0; }
76183
+ if( NEVER(j>(u32)usableSize) ){ j = 0; }
76184
memcpy(&pTmp[j], &aData[j], usableSize - j);
76185
76186
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
@@ -75874,42 +76324,50 @@ static int pageFreeArray(
76324
u8 * const pEnd = &aData[pPg->pBt->usableSize];
76325
u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];
76326
int nRet = 0;
75877
- int i;
76327
+ int i, j;
76328
int iEnd = iFirst + nCell;
75879
- u8 *pFree = 0; /* \__ Parameters for pending call to */
75880
- int szFree = 0; /* / freeSpace() */
76329
+ int nFree = 0;
76330
+ int aOfst[10];
76331
+ int aAfter[10];
76332
76333
for(i=iFirst; i<iEnd; i++){
76334
u8 *pCell = pCArray->apCell[i];
76335
if( SQLITE_WITHIN(pCell, pStart, pEnd) ){
76336
int sz;
76337
+ int iAfter;
76338
+ int iOfst;
76339
/* No need to use cachedCellSize() here. The sizes of all cells that
76340
** are to be freed have already been computing while deciding which
76341
** cells need freeing */
76342
sz = pCArray->szCell[i]; assert( sz>0 );
75890
- if( pFree!=(pCell + sz) ){
75891
- if( pFree ){
75892
- assert( pFree>aData && (pFree - aData)<65536 );
75893
- freeSpace(pPg, (u16)(pFree - aData), szFree);
75894
- }
75895
- pFree = pCell;
75896
- szFree = sz;
75897
- if( pFree+sz>pEnd ){
75898
- return 0;
76343
+ iOfst = (u16)(pCell - aData);
76344
+ iAfter = iOfst+sz;
76345
+ for(j=0; j<nFree; j++){
76346
+ if( aOfst[j]==iAfter ){
76347
+ aOfst[j] = iOfst;
76348
+ break;
76349
+ }else if( aAfter[j]==iOfst ){
76350
+ aAfter[j] = iAfter;
76351
+ break;
76352
}
75900
- }else{
75901
- /* The current cell is adjacent to and before the pFree cell.
75902
- ** Combine the two regions into one to reduce the number of calls
75903
- ** to freeSpace(). */
75904
- pFree = pCell;
75905
- szFree += sz;
76353
+ }
76354
+ if( j>=nFree ){
76355
+ if( nFree>=(int)(sizeof(aOfst)/sizeof(aOfst[0])) ){
76356
+ for(j=0; j<nFree; j++){
76357
+ freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]);
76358
+ }
76359
+ nFree = 0;
76360
+ }
76361
+ aOfst[nFree] = iOfst;
76362
+ aAfter[nFree] = iAfter;
76363
+ if( &aData[iAfter]>pEnd ) return 0;
76364
+ nFree++;
76365
}
76366
nRet++;
76367
}
76368
}
75910
- if( pFree ){
75911
- assert( pFree>aData && (pFree - aData)<65536 );
75912
- freeSpace(pPg, (u16)(pFree - aData), szFree);
76369
+ for(j=0; j<nFree; j++){
76370
+ freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]);
76371
}
76372
return nRet;
76373
}
@@ -75962,9 +76420,9 @@ static int editPage(
76420
nCell -= nTail;
76421
}
76422
75965
- pData = &aData[get2byteNotZero(&aData[hdr+5])];
76423
+ pData = &aData[get2byte(&aData[hdr+5])];
76424
if( pData<pBegin ) goto editpage_fail;
75967
- if( pData>pPg->aDataEnd ) goto editpage_fail;
76425
+ if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail;
76426
76427
/* Add cells to the start of the page */
76428
if( iNew<iOld ){
@@ -76701,7 +77159,7 @@ static int balance_nonroot(
77159
** that page.
77160
*/
77161
assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) || CORRUPT_DB);
76704
- TRACE(("BALANCE: old: %d(nc=%d) %d(nc=%d) %d(nc=%d)\n",
77162
+ TRACE(("BALANCE: old: %u(nc=%u) %u(nc=%u) %u(nc=%u)\n",
77163
apOld[0]->pgno, apOld[0]->nCell,
77164
nOld>=2 ? apOld[1]->pgno : 0, nOld>=2 ? apOld[1]->nCell : 0,
77165
nOld>=3 ? apOld[2]->pgno : 0, nOld>=3 ? apOld[2]->nCell : 0
@@ -76785,8 +77243,8 @@ static int balance_nonroot(
77243
}
77244
}
77245
76788
- TRACE(("BALANCE: new: %d(%d nc=%d) %d(%d nc=%d) %d(%d nc=%d) "
76789
- "%d(%d nc=%d) %d(%d nc=%d)\n",
77246
+ TRACE(("BALANCE: new: %u(%u nc=%u) %u(%u nc=%u) %u(%u nc=%u) "
77247
+ "%u(%u nc=%u) %u(%u nc=%u)\n",
77248
apNew[0]->pgno, szNew[0], cntNew[0],
77249
nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,
77250
nNew>=2 ? cntNew[1] - cntNew[0] - !leafData : 0,
@@ -77031,7 +77489,7 @@ static int balance_nonroot(
77489
}
77490
77491
assert( pParent->isInit );
77034
- TRACE(("BALANCE: finished: old=%d new=%d cells=%d\n",
77492
+ TRACE(("BALANCE: finished: old=%u new=%u cells=%u\n",
77493
nOld, nNew, b.nCell));
77494
77495
/* Free any old pages that were not reused as new pages.
@@ -77116,7 +77574,7 @@ static int balance_deeper(MemPage *pRoot, MemPage **ppChild){
77574
assert( sqlite3PagerIswriteable(pRoot->pDbPage) );
77575
assert( pChild->nCell==pRoot->nCell || CORRUPT_DB );
77576
77119
- TRACE(("BALANCE: copy root %d into %d\n", pRoot->pgno, pChild->pgno));
77577
+ TRACE(("BALANCE: copy root %u into %u\n", pRoot->pgno, pChild->pgno));
77578
77579
/* Copy the overflow cells from pRoot to pChild */
77580
memcpy(pChild->aiOvfl, pRoot->aiOvfl,
@@ -77599,7 +78057,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
78057
}
78058
}
78059
assert( pCur->eState==CURSOR_VALID
77602
- || (pCur->eState==CURSOR_INVALID && loc) );
78060
+ || (pCur->eState==CURSOR_INVALID && loc) || CORRUPT_DB );
78061
78062
pPage = pCur->pPage;
78063
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
@@ -77614,7 +78072,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
78072
if( rc ) return rc;
78073
}
78074
77617
- TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
78075
+ TRACE(("INSERT: table=%u nkey=%lld ndata=%u page=%u %s\n",
78076
pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,
78077
loc==0 ? "overwrite" : "new entry"));
78078
assert( pPage->isInit || CORRUPT_DB );
@@ -77690,7 +78148,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
78148
}else{
78149
assert( pPage->leaf );
78150
}
77693
- rc = insertCell(pPage, idx, newCell, szNew, 0, 0);
78151
+ rc = insertCellFast(pPage, idx, newCell, szNew);
78152
assert( pPage->nOverflow==0 || rc==SQLITE_OK );
78153
assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
78154
@@ -77914,6 +78372,9 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
78372
if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
78373
return SQLITE_CORRUPT_BKPT;
78374
}
78375
+ if( pCell<&pPage->aCellIdx[pPage->nCell] ){
78376
+ return SQLITE_CORRUPT_BKPT;
78377
+ }
78378
78379
/* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
78380
** be preserved following this delete operation. If the current delete
@@ -78662,7 +79123,8 @@ static void checkAppendMsg(
79123
sqlite3_str_append(&pCheck->errMsg, "\n", 1);
79124
}
79125
if( pCheck->zPfx ){
78665
- sqlite3_str_appendf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
79126
+ sqlite3_str_appendf(&pCheck->errMsg, pCheck->zPfx,
79127
+ pCheck->v0, pCheck->v1, pCheck->v2);
79128
}
79129
sqlite3_str_vappendf(&pCheck->errMsg, zFormat, ap);
79130
va_end(ap);
@@ -78702,11 +79164,11 @@ static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){
79164
*/
79165
static int checkRef(IntegrityCk *pCheck, Pgno iPage){
79166
if( iPage>pCheck->nPage || iPage==0 ){
78705
- checkAppendMsg(pCheck, "invalid page number %d", iPage);
79167
+ checkAppendMsg(pCheck, "invalid page number %u", iPage);
79168
return 1;
79169
}
79170
if( getPageReferenced(pCheck, iPage) ){
78709
- checkAppendMsg(pCheck, "2nd reference to page %d", iPage);
79171
+ checkAppendMsg(pCheck, "2nd reference to page %u", iPage);
79172
return 1;
79173
}
79174
setPageReferenced(pCheck, iPage);
@@ -78732,13 +79194,13 @@ static void checkPtrmap(
79194
rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);
79195
if( rc!=SQLITE_OK ){
79196
if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) checkOom(pCheck);
78735
- checkAppendMsg(pCheck, "Failed to read ptrmap key=%d", iChild);
79197
+ checkAppendMsg(pCheck, "Failed to read ptrmap key=%u", iChild);
79198
return;
79199
}
79200
79201
if( ePtrmapType!=eType || iPtrmapParent!=iParent ){
79202
checkAppendMsg(pCheck,
78741
- "Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)",
79203
+ "Bad ptr map entry key=%u expected=(%u,%u) got=(%u,%u)",
79204
iChild, eType, iParent, ePtrmapType, iPtrmapParent);
79205
}
79206
}
@@ -78763,7 +79225,7 @@ static void checkList(
79225
if( checkRef(pCheck, iPage) ) break;
79226
N--;
79227
if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
78766
- checkAppendMsg(pCheck, "failed to get page %d", iPage);
79228
+ checkAppendMsg(pCheck, "failed to get page %u", iPage);
79229
break;
79230
}
79231
pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
@@ -78776,7 +79238,7 @@ static void checkList(
79238
#endif
79239
if( n>pCheck->pBt->usableSize/4-2 ){
79240
checkAppendMsg(pCheck,
78779
- "freelist leaf count too big on page %d", iPage);
79241
+ "freelist leaf count too big on page %u", iPage);
79242
N--;
79243
}else{
79244
for(i=0; i<(int)n; i++){
@@ -78808,7 +79270,7 @@ static void checkList(
79270
}
79271
if( N && nErrAtStart==pCheck->nErr ){
79272
checkAppendMsg(pCheck,
78811
- "%s is %d but should be %d",
79273
+ "%s is %u but should be %u",
79274
isFreeList ? "size" : "overflow list length",
79275
expected-N, expected);
79276
}
@@ -78923,8 +79385,8 @@ static int checkTreePage(
79385
usableSize = pBt->usableSize;
79386
if( iPage==0 ) return 0;
79387
if( checkRef(pCheck, iPage) ) return 0;
78926
- pCheck->zPfx = "Page %u: ";
78927
- pCheck->v1 = iPage;
79388
+ pCheck->zPfx = "Tree %u page %u: ";
79389
+ pCheck->v0 = pCheck->v1 = iPage;
79390
if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){
79391
checkAppendMsg(pCheck,
79392
"unable to get the page. error code=%d", rc);
@@ -78950,7 +79412,7 @@ static int checkTreePage(
79412
hdr = pPage->hdrOffset;
79413
79414
/* Set up for cell analysis */
78953
- pCheck->zPfx = "On tree page %u cell %d: ";
79415
+ pCheck->zPfx = "Tree %u page %u cell %u: ";
79416
contentOffset = get2byteNotZero(&data[hdr+5]);
79417
assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */
79418
@@ -78970,7 +79432,7 @@ static int checkTreePage(
79432
pgno = get4byte(&data[hdr+8]);
79433
#ifndef SQLITE_OMIT_AUTOVACUUM
79434
if( pBt->autoVacuum ){
78973
- pCheck->zPfx = "On page %u at right child: ";
79435
+ pCheck->zPfx = "Tree %u page %u right child: ";
79436
checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);
79437
}
79438
#endif
@@ -78994,7 +79456,7 @@ static int checkTreePage(
79456
pc = get2byteAligned(pCellIdx);
79457
pCellIdx -= 2;
79458
if( pc<contentOffset || pc>usableSize-4 ){
78997
- checkAppendMsg(pCheck, "Offset %d out of range %d..%d",
79459
+ checkAppendMsg(pCheck, "Offset %u out of range %u..%u",
79460
pc, contentOffset, usableSize-4);
79461
doCoverageCheck = 0;
79462
continue;
@@ -79126,7 +79588,7 @@ static int checkTreePage(
79588
*/
79589
if( heap[0]==0 && nFrag!=data[hdr+7] ){
79590
checkAppendMsg(pCheck,
79129
- "Fragmentation of %d bytes reported as %d on page %u",
79591
+ "Fragmentation of %u bytes reported as %u on page %u",
79592
nFrag, data[hdr+7], iPage);
79593
}
79594
}
@@ -79223,7 +79685,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
79685
/* Check the integrity of the freelist
79686
*/
79687
if( bCkFreelist ){
79226
- sCheck.zPfx = "Main freelist: ";
79688
+ sCheck.zPfx = "Freelist: ";
79689
checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),
79690
get4byte(&pBt->pPage1->aData[36]));
79691
sCheck.zPfx = 0;
@@ -79240,7 +79702,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
79702
mxInHdr = get4byte(&pBt->pPage1->aData[52]);
79703
if( mx!=mxInHdr ){
79704
checkAppendMsg(&sCheck,
79243
- "max rootpage (%d) disagrees with header (%d)",
79705
+ "max rootpage (%u) disagrees with header (%u)",
79706
mx, mxInHdr
79707
);
79708
}
@@ -79271,7 +79733,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
79733
for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){
79734
#ifdef SQLITE_OMIT_AUTOVACUUM
79735
if( getPageReferenced(&sCheck, i)==0 ){
79274
- checkAppendMsg(&sCheck, "Page %d is never used", i);
79736
+ checkAppendMsg(&sCheck, "Page %u: never used", i);
79737
}
79738
#else
79739
/* If the database supports auto-vacuum, make sure no tables contain
@@ -79279,11 +79741,11 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
79741
*/
79742
if( getPageReferenced(&sCheck, i)==0 &&
79743
(PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){
79282
- checkAppendMsg(&sCheck, "Page %d is never used", i);
79744
+ checkAppendMsg(&sCheck, "Page %u: never used", i);
79745
}
79746
if( getPageReferenced(&sCheck, i)!=0 &&
79747
(PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){
79286
- checkAppendMsg(&sCheck, "Pointer map page %d is referenced", i);
79748
+ checkAppendMsg(&sCheck, "Page %u: pointer map referenced", i);
79749
}
79750
#endif
79751
}
@@ -79845,13 +80307,7 @@ static int backupOnePage(
80307
assert( !isFatalError(p->rc) );
80308
assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );
80309
assert( zSrcData );
79848
-
79849
- /* Catch the case where the destination is an in-memory database and the
79850
- ** page sizes of the source and destination differ.
79851
- */
79852
- if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){
79853
- rc = SQLITE_READONLY;
79854
- }
80310
+ assert( nSrcPgsz==nDestPgsz || sqlite3PagerIsMemdb(pDestPager)==0 );
80311
80312
/* This loop runs once for each destination page spanned by the source
80313
** page. For each iteration, variable iOff is set to the byte offset
@@ -79984,7 +80440,10 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
80440
pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
80441
pgszDest = sqlite3BtreeGetPageSize(p->pDest);
80442
destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest));
79987
- if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){
80443
+ if( SQLITE_OK==rc
80444
+ && (destMode==PAGER_JOURNALMODE_WAL || sqlite3PagerIsMemdb(pDestPager))
80445
+ && pgszSrc!=pgszDest
80446
+ ){
80447
rc = SQLITE_READONLY;
80448
}
80449
@@ -80533,6 +80992,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemValidStrRep(Mem *p){
80992
char *z;
80993
int i, j, incr;
80994
if( (p->flags & MEM_Str)==0 ) return 1;
80995
+ if( p->db && p->db->mallocFailed ) return 1;
80996
if( p->flags & MEM_Term ){
80997
/* Insure that the string is properly zero-terminated. Pay particular
80998
** attention to the case where p->n is odd */
@@ -80815,7 +81275,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
81275
81276
vdbeMemRenderNum(nByte, pMem->z, pMem);
81277
assert( pMem->z!=0 );
80818
- assert( pMem->n==sqlite3Strlen30NN(pMem->z) );
81278
+ assert( pMem->n==(int)sqlite3Strlen30NN(pMem->z) );
81279
pMem->enc = SQLITE_UTF8;
81280
pMem->flags |= MEM_Str|MEM_Term;
81281
if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal);
@@ -81859,6 +82319,9 @@ static int valueFromFunction(
82319
if( pList ) nVal = pList->nExpr;
82320
assert( !ExprHasProperty(p, EP_IntValue) );
82321
pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);
82322
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
82323
+ if( pFunc==0 ) return SQLITE_OK;
82324
+#endif
82325
assert( pFunc );
82326
if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
82327
|| (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
@@ -81895,16 +82358,11 @@ static int valueFromFunction(
82358
}else{
82359
sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
82360
assert( rc==SQLITE_OK );
81898
- assert( enc==pVal->enc
81899
- || (pVal->flags & MEM_Str)==0
81900
- || db->mallocFailed );
81901
-#if 0 /* Not reachable except after a prior failure */
82361
rc = sqlite3VdbeChangeEncoding(pVal, enc);
81903
- if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
82362
+ if( NEVER(rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal)) ){
82363
rc = SQLITE_TOOBIG;
82364
pCtx->pParse->nErr++;
82365
}
81907
-#endif
82366
}
82367
82368
value_from_function_out:
@@ -81968,6 +82426,13 @@ static int valueFromExpr(
82426
rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
82427
testcase( rc!=SQLITE_OK );
82428
if( *ppVal ){
82429
+#ifdef SQLITE_ENABLE_STAT4
82430
+ rc = ExpandBlob(*ppVal);
82431
+#else
82432
+ /* zero-blobs only come from functions, not literal values. And
82433
+ ** functions are only processed under STAT4 */
82434
+ assert( (ppVal[0][0].flags & MEM_Zero)==0 );
82435
+#endif
82436
sqlite3VdbeMemCast(*ppVal, aff, enc);
82437
sqlite3ValueApplyAffinity(*ppVal, affinity, enc);
82438
}
@@ -82814,10 +83279,10 @@ SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char *z1, const char *z2){
83279
*/
83280
SQLITE_PRIVATE int sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
83281
int addr = 0;
82817
-#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)
83282
+#if !defined(SQLITE_DEBUG)
83283
/* Always include the OP_Explain opcodes if SQLITE_DEBUG is defined.
83284
** But omit them (for performance) during production builds */
82820
- if( pParse->explain==2 )
83285
+ if( pParse->explain==2 || IS_STMT_SCANSTATUS(pParse->db) )
83286
#endif
83287
{
83288
char *zMsg;
@@ -83191,6 +83656,8 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
83656
Op *pOp;
83657
Parse *pParse = p->pParse;
83658
int *aLabel = pParse->aLabel;
83659
+
83660
+ assert( pParse->db->mallocFailed==0 ); /* tag-20230419-1 */
83661
p->readOnly = 1;
83662
p->bIsReader = 0;
83663
pOp = &p->aOp[p->nOp-1];
@@ -83250,6 +83717,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
83717
** have non-negative values for P2. */
83718
assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );
83719
assert( ADDR(pOp->p2)<-pParse->nLabel );
83720
+ assert( aLabel!=0 ); /* True because of tag-20230419-1 */
83721
pOp->p2 = aLabel[ADDR(pOp->p2)];
83722
}
83723
break;
@@ -83493,18 +83961,20 @@ SQLITE_PRIVATE void sqlite3VdbeScanStatus(
83961
LogEst nEst, /* Estimated number of output rows */
83962
const char *zName /* Name of table or index being scanned */
83963
){
83496
- sqlite3_int64 nByte = (p->nScan+1) * sizeof(ScanStatus);
83497
- ScanStatus *aNew;
83498
- aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);
83499
- if( aNew ){
83500
- ScanStatus *pNew = &aNew[p->nScan++];
83501
- memset(pNew, 0, sizeof(ScanStatus));
83502
- pNew->addrExplain = addrExplain;
83503
- pNew->addrLoop = addrLoop;
83504
- pNew->addrVisit = addrVisit;
83505
- pNew->nEst = nEst;
83506
- pNew->zName = sqlite3DbStrDup(p->db, zName);
83507
- p->aScan = aNew;
83964
+ if( IS_STMT_SCANSTATUS(p->db) ){
83965
+ sqlite3_int64 nByte = (p->nScan+1) * sizeof(ScanStatus);
83966
+ ScanStatus *aNew;
83967
+ aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);
83968
+ if( aNew ){
83969
+ ScanStatus *pNew = &aNew[p->nScan++];
83970
+ memset(pNew, 0, sizeof(ScanStatus));
83971
+ pNew->addrExplain = addrExplain;
83972
+ pNew->addrLoop = addrLoop;
83973
+ pNew->addrVisit = addrVisit;
83974
+ pNew->nEst = nEst;
83975
+ pNew->zName = sqlite3DbStrDup(p->db, zName);
83976
+ p->aScan = aNew;
83977
+ }
83978
}
83979
}
83980
@@ -83521,20 +83991,22 @@ SQLITE_PRIVATE void sqlite3VdbeScanStatusRange(
83991
int addrStart,
83992
int addrEnd
83993
){
83524
- ScanStatus *pScan = 0;
83525
- int ii;
83526
- for(ii=p->nScan-1; ii>=0; ii--){
83527
- pScan = &p->aScan[ii];
83528
- if( pScan->addrExplain==addrExplain ) break;
83529
- pScan = 0;
83530
- }
83531
- if( pScan ){
83532
- if( addrEnd<0 ) addrEnd = sqlite3VdbeCurrentAddr(p)-1;
83533
- for(ii=0; ii<ArraySize(pScan->aAddrRange); ii+=2){
83534
- if( pScan->aAddrRange[ii]==0 ){
83535
- pScan->aAddrRange[ii] = addrStart;
83536
- pScan->aAddrRange[ii+1] = addrEnd;
83537
- break;
83994
+ if( IS_STMT_SCANSTATUS(p->db) ){
83995
+ ScanStatus *pScan = 0;
83996
+ int ii;
83997
+ for(ii=p->nScan-1; ii>=0; ii--){
83998
+ pScan = &p->aScan[ii];
83999
+ if( pScan->addrExplain==addrExplain ) break;
84000
+ pScan = 0;
84001
+ }
84002
+ if( pScan ){
84003
+ if( addrEnd<0 ) addrEnd = sqlite3VdbeCurrentAddr(p)-1;
84004
+ for(ii=0; ii<ArraySize(pScan->aAddrRange); ii+=2){
84005
+ if( pScan->aAddrRange[ii]==0 ){
84006
+ pScan->aAddrRange[ii] = addrStart;
84007
+ pScan->aAddrRange[ii+1] = addrEnd;
84008
+ break;
84009
+ }
84010
}
84011
}
84012
}
@@ -83551,19 +84023,21 @@ SQLITE_PRIVATE void sqlite3VdbeScanStatusCounters(
84023
int addrLoop,
84024
int addrVisit
84025
){
83554
- ScanStatus *pScan = 0;
83555
- int ii;
83556
- for(ii=p->nScan-1; ii>=0; ii--){
83557
- pScan = &p->aScan[ii];
83558
- if( pScan->addrExplain==addrExplain ) break;
83559
- pScan = 0;
83560
- }
83561
- if( pScan ){
83562
- pScan->addrLoop = addrLoop;
83563
- pScan->addrVisit = addrVisit;
84026
+ if( IS_STMT_SCANSTATUS(p->db) ){
84027
+ ScanStatus *pScan = 0;
84028
+ int ii;
84029
+ for(ii=p->nScan-1; ii>=0; ii--){
84030
+ pScan = &p->aScan[ii];
84031
+ if( pScan->addrExplain==addrExplain ) break;
84032
+ pScan = 0;
84033
+ }
84034
+ if( pScan ){
84035
+ pScan->addrLoop = addrLoop;
84036
+ pScan->addrVisit = addrVisit;
84037
+ }
84038
}
84039
}
83566
-#endif
84040
+#endif /* defined(SQLITE_ENABLE_STMT_SCANSTATUS) */
84041
84042
84043
/*
@@ -83987,7 +84461,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
84461
84462
/* Return the most recently added opcode
84463
*/
83990
-VdbeOp * sqlite3VdbeGetLastOp(Vdbe *p){
84464
+SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetLastOp(Vdbe *p){
84465
return sqlite3VdbeGetOp(p, p->nOp - 1);
84466
}
84467
@@ -85691,6 +86165,8 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
86165
db->flags &= ~(u64)SQLITE_DeferFKs;
86166
sqlite3CommitInternalChanges(db);
86167
}
86168
+ }else if( p->rc==SQLITE_SCHEMA && db->nVdbeActive>1 ){
86169
+ p->nChange = 0;
86170
}else{
86171
sqlite3RollbackAll(db, SQLITE_OK);
86172
p->nChange = 0;
@@ -86009,9 +86485,9 @@ static void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
86485
#ifdef SQLITE_ENABLE_NORMALIZE
86486
sqlite3DbFree(db, p->zNormSql);
86487
{
86012
- DblquoteStr *pThis, *pNext;
86013
- for(pThis=p->pDblStr; pThis; pThis=pNext){
86014
- pNext = pThis->pNextStr;
86488
+ DblquoteStr *pThis, *pNxt;
86489
+ for(pThis=p->pDblStr; pThis; pThis=pNxt){
86490
+ pNxt = pThis->pNextStr;
86491
sqlite3DbFree(db, pThis);
86492
}
86493
}
@@ -87638,6 +88114,20 @@ SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){
88114
return 1;
88115
}
88116
88117
+#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
88118
+/*
88119
+** This Walker callback is used to help verify that calls to
88120
+** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
88121
+** byte-code register values correctly initialized.
88122
+*/
88123
+SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr){
88124
+ if( pExpr->op==TK_REGISTER ){
88125
+ assert( (pWalker->u.aMem[pExpr->iTable].flags & MEM_Undefined)==0 );
88126
+ }
88127
+ return WRC_Continue;
88128
+}
88129
+#endif /* SQLITE_ENABLE_CURSOR_HINTS && SQLITE_DEBUG */
88130
+
88131
#ifndef SQLITE_OMIT_VIRTUALTABLE
88132
/*
88133
** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
@@ -87700,6 +88190,16 @@ SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
88190
PreUpdate preupdate;
88191
const char *zTbl = pTab->zName;
88192
static const u8 fakeSortOrder = 0;
88193
+#ifdef SQLITE_DEBUG
88194
+ int nRealCol;
88195
+ if( pTab->tabFlags & TF_WithoutRowid ){
88196
+ nRealCol = sqlite3PrimaryKeyIndex(pTab)->nColumn;
88197
+ }else if( pTab->tabFlags & TF_HasVirtual ){
88198
+ nRealCol = pTab->nNVCol;
88199
+ }else{
88200
+ nRealCol = pTab->nCol;
88201
+ }
88202
+#endif
88203
88204
assert( db->pPreUpdate==0 );
88205
memset(&preupdate, 0, sizeof(PreUpdate));
@@ -87716,8 +88216,8 @@ SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
88216
88217
assert( pCsr!=0 );
88218
assert( pCsr->eCurType==CURTYPE_BTREE );
87719
- assert( pCsr->nField==pTab->nCol
87720
- || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1)
88219
+ assert( pCsr->nField==nRealCol
88220
+ || (pCsr->nField==nRealCol+1 && op==SQLITE_DELETE && iReg==-1)
88221
);
88222
88223
preupdate.v = v;
@@ -88024,7 +88524,7 @@ SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
88524
SQLITE_NULL, /* 0x1f (not possible) */
88525
SQLITE_FLOAT, /* 0x20 INTREAL */
88526
SQLITE_NULL, /* 0x21 (not possible) */
88027
- SQLITE_TEXT, /* 0x22 INTREAL + TEXT */
88527
+ SQLITE_FLOAT, /* 0x22 INTREAL + TEXT */
88528
SQLITE_NULL, /* 0x23 (not possible) */
88529
SQLITE_FLOAT, /* 0x24 (not possible) */
88530
SQLITE_NULL, /* 0x25 (not possible) */
@@ -89090,9 +89590,9 @@ static const void *columnName(
89590
assert( db!=0 );
89591
n = sqlite3_column_count(pStmt);
89592
if( N<n && N>=0 ){
89593
+ u8 prior_mallocFailed = db->mallocFailed;
89594
N += useType*n;
89595
sqlite3_mutex_enter(db->mutex);
89095
- assert( db->mallocFailed==0 );
89596
#ifndef SQLITE_OMIT_UTF16
89597
if( useUtf16 ){
89598
ret = sqlite3_value_text16((sqlite3_value*)&p->aColName[N]);
@@ -89104,7 +89604,8 @@ static const void *columnName(
89604
/* A malloc may have failed inside of the _text() call. If this
89605
** is the case, clear the mallocFailed flag and return NULL.
89606
*/
89107
- if( db->mallocFailed ){
89607
+ assert( db->mallocFailed==0 || db->mallocFailed==1 );
89608
+ if( db->mallocFailed > prior_mallocFailed ){
89609
sqlite3OomClear(db);
89610
ret = 0;
89611
}
@@ -89891,15 +90392,24 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90392
void *pOut /* OUT: Write the answer here */
90393
){
90394
Vdbe *p = (Vdbe*)pStmt;
89894
- ScanStatus *pScan;
90395
+ VdbeOp *aOp = p->aOp;
90396
+ int nOp = p->nOp;
90397
+ ScanStatus *pScan = 0;
90398
int idx;
90399
90400
+ if( p->pFrame ){
90401
+ VdbeFrame *pFrame;
90402
+ for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);
90403
+ aOp = pFrame->aOp;
90404
+ nOp = pFrame->nOp;
90405
+ }
90406
+
90407
if( iScan<0 ){
90408
int ii;
90409
if( iScanStatusOp==SQLITE_SCANSTAT_NCYCLE ){
90410
i64 res = 0;
89901
- for(ii=0; ii<p->nOp; ii++){
89902
- res += p->aOp[ii].nCycle;
90411
+ for(ii=0; ii<nOp; ii++){
90412
+ res += aOp[ii].nCycle;
90413
}
90414
*(i64*)pOut = res;
90415
return 0;
@@ -89925,7 +90435,7 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90435
switch( iScanStatusOp ){
90436
case SQLITE_SCANSTAT_NLOOP: {
90437
if( pScan->addrLoop>0 ){
89928
- *(sqlite3_int64*)pOut = p->aOp[pScan->addrLoop].nExec;
90438
+ *(sqlite3_int64*)pOut = aOp[pScan->addrLoop].nExec;
90439
}else{
90440
*(sqlite3_int64*)pOut = -1;
90441
}
@@ -89933,7 +90443,7 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90443
}
90444
case SQLITE_SCANSTAT_NVISIT: {
90445
if( pScan->addrVisit>0 ){
89936
- *(sqlite3_int64*)pOut = p->aOp[pScan->addrVisit].nExec;
90446
+ *(sqlite3_int64*)pOut = aOp[pScan->addrVisit].nExec;
90447
}else{
90448
*(sqlite3_int64*)pOut = -1;
90449
}
@@ -89955,7 +90465,7 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90465
}
90466
case SQLITE_SCANSTAT_EXPLAIN: {
90467
if( pScan->addrExplain ){
89958
- *(const char**)pOut = p->aOp[ pScan->addrExplain ].p4.z;
90468
+ *(const char**)pOut = aOp[ pScan->addrExplain ].p4.z;
90469
}else{
90470
*(const char**)pOut = 0;
90471
}
@@ -89963,7 +90473,7 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90473
}
90474
case SQLITE_SCANSTAT_SELECTID: {
90475
if( pScan->addrExplain ){
89966
- *(int*)pOut = p->aOp[ pScan->addrExplain ].p1;
90476
+ *(int*)pOut = aOp[ pScan->addrExplain ].p1;
90477
}else{
90478
*(int*)pOut = -1;
90479
}
@@ -89971,7 +90481,7 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90481
}
90482
case SQLITE_SCANSTAT_PARENTID: {
90483
if( pScan->addrExplain ){
89974
- *(int*)pOut = p->aOp[ pScan->addrExplain ].p2;
90484
+ *(int*)pOut = aOp[ pScan->addrExplain ].p2;
90485
}else{
90486
*(int*)pOut = -1;
90487
}
@@ -89989,18 +90499,18 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
90499
if( iIns==0 ) break;
90500
if( iIns>0 ){
90501
while( iIns<=iEnd ){
89992
- res += p->aOp[iIns].nCycle;
90502
+ res += aOp[iIns].nCycle;
90503
iIns++;
90504
}
90505
}else{
90506
int iOp;
89997
- for(iOp=0; iOp<p->nOp; iOp++){
89998
- Op *pOp = &p->aOp[iOp];
90507
+ for(iOp=0; iOp<nOp; iOp++){
90508
+ Op *pOp = &aOp[iOp];
90509
if( pOp->p1!=iEnd ) continue;
90510
if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_NCYCLE)==0 ){
90511
continue;
90512
}
90003
- res += p->aOp[iOp].nCycle;
90513
+ res += aOp[iOp].nCycle;
90514
}
90515
}
90516
}
@@ -90923,7 +91433,10 @@ static u64 filterHash(const Mem *aMem, const Op *pOp){
91433
}else if( p->flags & MEM_Real ){
91434
h += sqlite3VdbeIntValue(p);
91435
}else if( p->flags & (MEM_Str|MEM_Blob) ){
90926
- /* no-op */
91436
+ /* All strings have the same hash and all blobs have the same hash,
91437
+ ** though, at least, those hashes are different from each other and
91438
+ ** from NULL. */
91439
+ h += 4093 + (p->flags & (MEM_Str|MEM_Blob));
91440
}
91441
}
91442
return h;
@@ -90973,6 +91486,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
91486
Mem *pOut = 0; /* Output operand */
91487
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE)
91488
u64 *pnCycle = 0;
91489
+ int bStmtScanStatus = IS_STMT_SCANSTATUS(db)!=0;
91490
#endif
91491
/*** INSERT STACK UNION HERE ***/
91492
@@ -91037,13 +91551,17 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
91551
91552
assert( pOp>=aOp && pOp<&aOp[p->nOp]);
91553
nVmStep++;
91040
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE)
91554
+
91555
+#if defined(VDBE_PROFILE)
91556
pOp->nExec++;
91557
pnCycle = &pOp->nCycle;
91043
-# ifdef VDBE_PROFILE
91044
- if( sqlite3NProfileCnt==0 )
91045
-# endif
91558
+ if( sqlite3NProfileCnt==0 ) *pnCycle -= sqlite3Hwtime();
91559
+#elif defined(SQLITE_ENABLE_STMT_SCANSTATUS)
91560
+ if( bStmtScanStatus ){
91561
+ pOp->nExec++;
91562
+ pnCycle = &pOp->nCycle;
91563
*pnCycle -= sqlite3Hwtime();
91564
+ }
91565
#endif
91566
91567
/* Only allow tracing if SQLITE_DEBUG is defined.
@@ -92631,7 +93149,7 @@ case OP_Compare: {
93149
/* Opcode: Jump P1 P2 P3 * *
93150
**
93151
** Jump to the instruction at address P1, P2, or P3 depending on whether
92634
-** in the most recent OP_Compare instruction the P1 vector was less than
93152
+** in the most recent OP_Compare instruction the P1 vector was less than,
93153
** equal to, or greater than the P2 vector, respectively.
93154
**
93155
** This opcode must immediately follow an OP_Compare opcode.
@@ -92858,6 +93376,12 @@ case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
93376
** (0x01) bit. SQLITE_FLOAT is the 0x02 bit. SQLITE_TEXT is 0x04.
93377
** SQLITE_BLOB is 0x08. SQLITE_NULL is 0x10.
93378
**
93379
+** WARNING: This opcode does not reliably distinguish between NULL and REAL
93380
+** when P1>=0. If the database contains a NaN value, this opcode will think
93381
+** that the datatype is REAL when it should be NULL. When P1<0 and the value
93382
+** is already stored in register P3, then this opcode does reliably
93383
+** distinguish between NULL and REAL. The problem only arises then P1>=0.
93384
+**
93385
** Take the jump to address P2 if and only if the datatype of the
93386
** value determined by P1 and P3 corresponds to one of the bits in the
93387
** P5 bitmask.
@@ -92971,7 +93495,7 @@ case OP_IfNullRow: { /* jump */
93495
VdbeCursor *pC;
93496
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
93497
pC = p->apCsr[pOp->p1];
92974
- if( ALWAYS(pC) && pC->nullRow ){
93498
+ if( pC && pC->nullRow ){
93499
sqlite3VdbeMemSetNull(aMem + pOp->p3);
93500
goto jump_to_p2;
93501
}
@@ -93466,7 +93990,7 @@ case OP_Affinity: {
93990
}else{
93991
pIn1->u.r = (double)pIn1->u.i;
93992
pIn1->flags |= MEM_Real;
93469
- pIn1->flags &= ~MEM_Int;
93993
+ pIn1->flags &= ~(MEM_Int|MEM_Str);
93994
}
93995
}
93996
REGISTER_TRACE((int)(pIn1-aMem), pIn1);
@@ -95205,6 +95729,7 @@ case OP_SeekScan: { /* ncycle */
95729
break;
95730
}
95731
nStep--;
95732
+ pC->cacheStatus = CACHE_STALE;
95733
rc = sqlite3BtreeNext(pC->uc.pCursor, 0);
95734
if( rc ){
95735
if( rc==SQLITE_DONE ){
@@ -97857,6 +98382,7 @@ case OP_AggFinal: {
98382
}
98383
sqlite3VdbeChangeEncoding(pMem, encoding);
98384
UPDATE_MAX_BLOBSIZE(pMem);
98385
+ REGISTER_TRACE((int)(pMem-aMem), pMem);
98386
break;
98387
}
98388
@@ -98995,8 +99521,10 @@ default: { /* This is really OP_Noop, OP_Explain */
99521
*pnCycle += sqlite3NProfileCnt ? sqlite3NProfileCnt : sqlite3Hwtime();
99522
pnCycle = 0;
99523
#elif defined(SQLITE_ENABLE_STMT_SCANSTATUS)
98998
- *pnCycle += sqlite3Hwtime();
98999
- pnCycle = 0;
99524
+ if( pnCycle ){
99525
+ *pnCycle += sqlite3Hwtime();
99526
+ pnCycle = 0;
99527
+ }
99528
#endif
99529
99530
/* The following code adds nothing to the actual functionality
@@ -99475,7 +100003,7 @@ blob_open_out:
100003
if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);
100004
sqlite3DbFree(db, pBlob);
100005
}
99478
- sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
100006
+ sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : (char*)0), zErr);
100007
sqlite3DbFree(db, zErr);
100008
sqlite3ParseObjectReset(&sParse);
100009
rc = sqlite3ApiExit(db, rc);
@@ -99634,7 +100162,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
100162
((Vdbe*)p->pStmt)->rc = SQLITE_OK;
100163
rc = blobSeekToRow(p, iRow, &zErr);
100164
if( rc!=SQLITE_OK ){
99637
- sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
100165
+ sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : (char*)0), zErr);
100166
sqlite3DbFree(db, zErr);
100167
}
100168
assert( rc!=SQLITE_SCHEMA );
@@ -104022,7 +104550,8 @@ static int lookupName(
104550
assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
104551
if( pParse->bReturning ){
104552
if( (pNC->ncFlags & NC_UBaseReg)!=0
104025
- && (zTab==0 || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0)
104553
+ && ALWAYS(zTab==0
104554
+ || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0)
104555
){
104556
pExpr->iTable = op!=TK_DELETE;
104557
pTab = pParse->pTriggerTab;
@@ -105996,11 +106525,10 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){
106525
}else{
106526
Expr *pNext = p->pRight;
106527
/* The Expr.x union is never used at the same time as Expr.pRight */
105999
- assert( ExprUseXList(p) );
106000
- assert( p->x.pList==0 || p->pRight==0 );
106001
- if( p->x.pList!=0 && !db->mallocFailed ){
106528
+ assert( !ExprUseXList(p) || p->x.pList==0 || p->pRight==0 );
106529
+ if( ExprUseXList(p) && p->x.pList!=0 && !db->mallocFailed ){
106530
int i;
106003
- for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
106531
+ for(i=0; i<p->x.pList->nExpr; i++){
106532
if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
106533
pNext = p->x.pList->a[i].pExpr;
106534
break;
@@ -106832,9 +107360,9 @@ SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse *pParse, int nElem, ExprLis
107360
** Join two expressions using an AND operator. If either expression is
107361
** NULL, then just return the other expression.
107362
**
106835
-** If one side or the other of the AND is known to be false, then instead
106836
-** of returning an AND expression, just return a constant expression with
106837
-** a value of false.
107363
+** If one side or the other of the AND is known to be false, and neither side
107364
+** is part of an ON clause, then instead of returning an AND expression,
107365
+** just return a constant expression with a value of false.
107366
*/
107367
SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){
107368
sqlite3 *db = pParse->db;
@@ -106842,14 +107370,17 @@ SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){
107370
return pRight;
107371
}else if( pRight==0 ){
107372
return pLeft;
106845
- }else if( (ExprAlwaysFalse(pLeft) || ExprAlwaysFalse(pRight))
106846
- && !IN_RENAME_OBJECT
106847
- ){
106848
- sqlite3ExprDeferredDelete(pParse, pLeft);
106849
- sqlite3ExprDeferredDelete(pParse, pRight);
106850
- return sqlite3Expr(db, TK_INTEGER, "0");
107373
}else{
106852
- return sqlite3PExpr(pParse, TK_AND, pLeft, pRight);
107374
+ u32 f = pLeft->flags | pRight->flags;
107375
+ if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse))==EP_IsFalse
107376
+ && !IN_RENAME_OBJECT
107377
+ ){
107378
+ sqlite3ExprDeferredDelete(pParse, pLeft);
107379
+ sqlite3ExprDeferredDelete(pParse, pRight);
107380
+ return sqlite3Expr(db, TK_INTEGER, "0");
107381
+ }else{
107382
+ return sqlite3PExpr(pParse, TK_AND, pLeft, pRight);
107383
+ }
107384
}
107385
}
107386
@@ -108094,12 +108625,17 @@ SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
108625
}
108626
108627
/*
108097
-** Check pExpr to see if it is an invariant constraint on data source pSrc.
108628
+** Check pExpr to see if it is an constraint on the single data source
108629
+** pSrc = &pSrcList->a[iSrc]. In other words, check to see if pExpr
108630
+** constrains pSrc but does not depend on any other tables or data
108631
+** sources anywhere else in the query. Return true (non-zero) if pExpr
108632
+** is a constraint on pSrc only.
108633
+**
108634
** This is an optimization. False negatives will perhaps cause slower
108635
** queries, but false positives will yield incorrect answers. So when in
108636
** doubt, return 0.
108637
**
108102
-** To be an invariant constraint, the following must be true:
108638
+** To be an single-source constraint, the following must be true:
108639
**
108640
** (1) pExpr cannot refer to any table other than pSrc->iCursor.
108641
**
@@ -108110,13 +108646,31 @@ SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
108646
**
108647
** (4) If pSrc is the right operand of a LEFT JOIN, then...
108648
** (4a) pExpr must come from an ON clause..
108113
- (4b) and specifically the ON clause associated with the LEFT JOIN.
108649
+** (4b) and specifically the ON clause associated with the LEFT JOIN.
108650
**
108651
** (5) If pSrc is not the right operand of a LEFT JOIN or the left
108652
** operand of a RIGHT JOIN, then pExpr must be from the WHERE
108653
** clause, not an ON clause.
108654
+**
108655
+** (6) Either:
108656
+**
108657
+** (6a) pExpr does not originate in an ON or USING clause, or
108658
+**
108659
+** (6b) The ON or USING clause from which pExpr is derived is
108660
+** not to the left of a RIGHT JOIN (or FULL JOIN).
108661
+**
108662
+** Without this restriction, accepting pExpr as a single-table
108663
+** constraint might move the the ON/USING filter expression
108664
+** from the left side of a RIGHT JOIN over to the right side,
108665
+** which leads to incorrect answers. See also restriction (9)
108666
+** on push-down.
108667
*/
108119
-SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr *pExpr, const SrcItem *pSrc){
108668
+SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(
108669
+ Expr *pExpr, /* The constraint */
108670
+ const SrcList *pSrcList, /* Complete FROM clause */
108671
+ int iSrc /* Which element of pSrcList to use */
108672
+){
108673
+ const SrcItem *pSrc = &pSrcList->a[iSrc];
108674
if( pSrc->fg.jointype & JT_LTORJ ){
108675
return 0; /* rule (3) */
108676
}
@@ -108126,6 +108680,19 @@ SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr *pExpr, const SrcItem *pSrc
108680
}else{
108681
if( ExprHasProperty(pExpr, EP_OuterON) ) return 0; /* rule (5) */
108682
}
108683
+ if( ExprHasProperty(pExpr, EP_OuterON|EP_InnerON) /* (6a) */
108684
+ && (pSrcList->a[0].fg.jointype & JT_LTORJ)!=0 /* Fast pre-test of (6b) */
108685
+ ){
108686
+ int jj;
108687
+ for(jj=0; jj<iSrc; jj++){
108688
+ if( pExpr->w.iJoin==pSrcList->a[jj].iCursor ){
108689
+ if( (pSrcList->a[jj].fg.jointype & JT_LTORJ)!=0 ){
108690
+ return 0; /* restriction (6) */
108691
+ }
108692
+ break;
108693
+ }
108694
+ }
108695
+ }
108696
return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor); /* rules (1), (2) */
108697
}
108698
@@ -108368,7 +108935,7 @@ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){
108935
** pX is the RHS of an IN operator. If pX is a SELECT statement
108936
** that can be simplified to a direct table access, then return
108937
** a pointer to the SELECT statement. If pX is not a SELECT statement,
108371
-** or if the SELECT statement needs to be manifested into a transient
108938
+** or if the SELECT statement needs to be materialized into a transient
108939
** table, then return NULL.
108940
*/
108941
#ifndef SQLITE_OMIT_SUBQUERY
@@ -108654,7 +109221,6 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
109221
CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
109222
int j;
109223
108657
- assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
109224
for(j=0; j<nExpr; j++){
109225
if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
109226
assert( pIdx->azColl[j] );
@@ -109940,7 +110506,19 @@ expr_code_doover:
110506
AggInfo *pAggInfo = pExpr->pAggInfo;
110507
struct AggInfo_col *pCol;
110508
assert( pAggInfo!=0 );
109943
- assert( pExpr->iAgg>=0 && pExpr->iAgg<pAggInfo->nColumn );
110509
+ assert( pExpr->iAgg>=0 );
110510
+ if( pExpr->iAgg>=pAggInfo->nColumn ){
110511
+ /* Happens when the left table of a RIGHT JOIN is null and
110512
+ ** is using an expression index */
110513
+ sqlite3VdbeAddOp2(v, OP_Null, 0, target);
110514
+#ifdef SQLITE_VDBE_COVERAGE
110515
+ /* Verify that the OP_Null above is exercised by tests
110516
+ ** tag-20230325-2 */
110517
+ sqlite3VdbeAddOp2(v, OP_NotNull, target, 1);
110518
+ VdbeCoverageNeverTaken(v);
110519
+#endif
110520
+ break;
110521
+ }
110522
pCol = &pAggInfo->aCol[pExpr->iAgg];
110523
if( !pAggInfo->directMode ){
110524
return AggInfoColumnReg(pAggInfo, pExpr->iAgg);
@@ -110115,11 +110693,8 @@ expr_code_doover:
110693
#ifndef SQLITE_OMIT_CAST
110694
case TK_CAST: {
110695
/* Expressions of the form: CAST(pLeft AS token) */
110118
- inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
110119
- if( inReg!=target ){
110120
- sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
110121
- inReg = target;
110122
- }
110696
+ sqlite3ExprCode(pParse, pExpr->pLeft, target);
110697
+ assert( inReg==target );
110698
assert( !ExprHasProperty(pExpr, EP_IntValue) );
110699
sqlite3VdbeAddOp2(v, OP_Cast, target,
110700
sqlite3AffinityType(pExpr->u.zToken, 0));
@@ -110458,13 +111033,9 @@ expr_code_doover:
111033
** Clear subtypes as subtypes may not cross a subquery boundary.
111034
*/
111035
assert( pExpr->pLeft );
110461
- inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
110462
- if( inReg!=target ){
110463
- sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
110464
- inReg = target;
110465
- }
110466
- sqlite3VdbeAddOp1(v, OP_ClrSubtype, inReg);
110467
- return inReg;
111036
+ sqlite3ExprCode(pParse, pExpr->pLeft, target);
111037
+ sqlite3VdbeAddOp1(v, OP_ClrSubtype, target);
111038
+ return target;
111039
}else{
111040
pExpr = pExpr->pLeft;
111041
goto expr_code_doover; /* 2018-04-28: Prevent deep recursion. */
@@ -110574,12 +111145,9 @@ expr_code_doover:
111145
** "target" and not someplace else.
111146
*/
111147
pParse->okConstFactor = 0; /* note (1) above */
110577
- inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
111148
+ sqlite3ExprCode(pParse, pExpr->pLeft, target);
111149
+ assert( target==inReg );
111150
pParse->okConstFactor = okConstFactor;
110579
- if( inReg!=target ){ /* note (2) above */
110580
- sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
110581
- inReg = target;
110582
- }
111151
sqlite3VdbeJumpHere(v, addrINR);
111152
break;
111153
}
@@ -110817,7 +111385,9 @@ SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
111385
inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
111386
if( inReg!=target ){
111387
u8 op;
110820
- if( ALWAYS(pExpr) && ExprHasProperty(pExpr,EP_Subquery) ){
111388
+ if( ALWAYS(pExpr)
111389
+ && (ExprHasProperty(pExpr,EP_Subquery) || pExpr->op==TK_REGISTER)
111390
+ ){
111391
op = OP_Copy;
111392
}else{
111393
op = OP_SCopy;
@@ -112002,9 +112572,11 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
112572
int iAgg = pExpr->iAgg;
112573
Parse *pParse = pWalker->pParse;
112574
sqlite3 *db = pParse->db;
112575
+ assert( iAgg>=0 );
112576
if( pExpr->op!=TK_AGG_FUNCTION ){
112006
- assert( iAgg>=0 && iAgg<pAggInfo->nColumn );
112007
- if( pAggInfo->aCol[iAgg].pCExpr==pExpr ){
112577
+ if( iAgg<pAggInfo->nColumn
112578
+ && pAggInfo->aCol[iAgg].pCExpr==pExpr
112579
+ ){
112580
pExpr = sqlite3ExprDup(db, pExpr, 0);
112581
if( pExpr ){
112582
pAggInfo->aCol[iAgg].pCExpr = pExpr;
@@ -112013,8 +112585,9 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
112585
}
112586
}else{
112587
assert( pExpr->op==TK_AGG_FUNCTION );
112016
- assert( iAgg>=0 && iAgg<pAggInfo->nFunc );
112017
- if( pAggInfo->aFunc[iAgg].pFExpr==pExpr ){
112588
+ if( ALWAYS(iAgg<pAggInfo->nFunc)
112589
+ && pAggInfo->aFunc[iAgg].pFExpr==pExpr
112590
+ ){
112591
pExpr = sqlite3ExprDup(db, pExpr, 0);
112592
if( pExpr ){
112593
pAggInfo->aFunc[iAgg].pFExpr = pExpr;
@@ -112164,7 +112737,12 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
112737
}
112738
if( pIEpr==0 ) break;
112739
if( NEVER(!ExprUseYTab(pExpr)) ) break;
112167
- if( pExpr->pAggInfo!=0 ) break; /* Already resolved by outer context */
112740
+ for(i=0; i<pSrcList->nSrc; i++){
112741
+ if( pSrcList->a[0].iCursor==pIEpr->iDataCur ) break;
112742
+ }
112743
+ if( i>=pSrcList->nSrc ) break;
112744
+ if( NEVER(pExpr->pAggInfo!=0) ) break; /* Resolved by outer context */
112745
+ if( pParse->nErr ){ return WRC_Abort; }
112746
112747
/* If we reach this point, it means that expression pExpr can be
112748
** translated into a reference to an index column as described by
@@ -112175,6 +112753,9 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
112753
tmp.iTable = pIEpr->iIdxCur;
112754
tmp.iColumn = pIEpr->iIdxCol;
112755
findOrCreateAggInfoColumn(pParse, pAggInfo, &tmp);
112756
+ if( pParse->nErr ){ return WRC_Abort; }
112757
+ assert( pAggInfo->aCol!=0 );
112758
+ assert( tmp.iAgg<pAggInfo->nColumn );
112759
pAggInfo->aCol[tmp.iAgg].pCExpr = pExpr;
112760
pExpr->pAggInfo = pAggInfo;
112761
pExpr->iAgg = tmp.iAgg;
@@ -112198,7 +112779,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
112779
} /* endif pExpr->iTable==pItem->iCursor */
112780
} /* end loop over pSrcList */
112781
}
112201
- return WRC_Prune;
112782
+ return WRC_Continue;
112783
}
112784
case TK_AGG_FUNCTION: {
112785
if( (pNC->ncFlags & NC_InAggFunc)==0
@@ -112351,6 +112932,37 @@ SQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse *pParse){
112932
pParse->nRangeReg = 0;
112933
}
112934
112935
+/*
112936
+** Make sure sufficient registers have been allocated so that
112937
+** iReg is a valid register number.
112938
+*/
112939
+SQLITE_PRIVATE void sqlite3TouchRegister(Parse *pParse, int iReg){
112940
+ if( pParse->nMem<iReg ) pParse->nMem = iReg;
112941
+}
112942
+
112943
+#if defined(SQLITE_ENABLE_STAT4) || defined(SQLITE_DEBUG)
112944
+/*
112945
+** Return the latest reusable register in the set of all registers.
112946
+** The value returned is no less than iMin. If any register iMin or
112947
+** greater is in permanent use, then return one more than that last
112948
+** permanent register.
112949
+*/
112950
+SQLITE_PRIVATE int sqlite3FirstAvailableRegister(Parse *pParse, int iMin){
112951
+ const ExprList *pList = pParse->pConstExpr;
112952
+ if( pList ){
112953
+ int i;
112954
+ for(i=0; i<pList->nExpr; i++){
112955
+ if( pList->a[i].u.iConstExprReg>=iMin ){
112956
+ iMin = pList->a[i].u.iConstExprReg + 1;
112957
+ }
112958
+ }
112959
+ }
112960
+ pParse->nTempReg = 0;
112961
+ pParse->nRangeReg = 0;
112962
+ return iMin;
112963
+}
112964
+#endif /* SQLITE_ENABLE_STAT4 || SQLITE_DEBUG */
112965
+
112966
/*
112967
** Validate that no temporary register falls within the range of
112968
** iFirst..iLast, inclusive. This routine is only call from within assert()
@@ -112370,6 +112982,14 @@ SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
112982
return 0;
112983
}
112984
}
112985
+ if( pParse->pConstExpr ){
112986
+ ExprList *pList = pParse->pConstExpr;
112987
+ for(i=0; i<pList->nExpr; i++){
112988
+ int iReg = pList->a[i].u.iConstExprReg;
112989
+ if( iReg==0 ) continue;
112990
+ if( iReg>=iFirst && iReg<=iLast ) return 0;
112991
+ }
112992
+ }
112993
return 1;
112994
}
112995
#endif /* SQLITE_DEBUG */
@@ -113657,6 +114277,19 @@ static int renameEditSql(
114277
return rc;
114278
}
114279
114280
+/*
114281
+** Set all pEList->a[].fg.eEName fields in the expression-list to val.
114282
+*/
114283
+static void renameSetENames(ExprList *pEList, int val){
114284
+ if( pEList ){
114285
+ int i;
114286
+ for(i=0; i<pEList->nExpr; i++){
114287
+ assert( val==ENAME_NAME || pEList->a[i].fg.eEName==ENAME_NAME );
114288
+ pEList->a[i].fg.eEName = val;
114289
+ }
114290
+ }
114291
+}
114292
+
114293
/*
114294
** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming
114295
** it was read from the schema of database zDb. Return SQLITE_OK if
@@ -113704,7 +114337,17 @@ static int renameResolveTrigger(Parse *pParse){
114337
pSrc = 0;
114338
rc = SQLITE_NOMEM;
114339
}else{
114340
+ /* pStep->pExprList contains an expression-list used for an UPDATE
114341
+ ** statement. So the a[].zEName values are the RHS of the
114342
+ ** "<col> = <expr>" clauses of the UPDATE statement. So, before
114343
+ ** running SelectPrep(), change all the eEName values in
114344
+ ** pStep->pExprList to ENAME_SPAN (from their current value of
114345
+ ** ENAME_NAME). This is to prevent any ids in ON() clauses that are
114346
+ ** part of pSrc from being incorrectly resolved against the
114347
+ ** a[].zEName values as if they were column aliases. */
114348
+ renameSetENames(pStep->pExprList, ENAME_SPAN);
114349
sqlite3SelectPrep(pParse, pSel, 0);
114350
+ renameSetENames(pStep->pExprList, ENAME_NAME);
114351
rc = pParse->nErr ? SQLITE_ERROR : SQLITE_OK;
114352
assert( pStep->pExprList==0 || pStep->pExprList==pSel->pEList );
114353
assert( pSrc==pSel->pSrc );
@@ -115653,11 +116296,15 @@ static void analyzeOneTable(
116296
int regIdxname = iMem++; /* Register containing index name */
116297
int regStat1 = iMem++; /* Value for the stat column of sqlite_stat1 */
116298
int regPrev = iMem; /* MUST BE LAST (see below) */
116299
+#ifdef SQLITE_ENABLE_STAT4
116300
+ int doOnce = 1; /* Flag for a one-time computation */
116301
+#endif
116302
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
116303
Table *pStat1 = 0;
116304
#endif
116305
115660
- pParse->nMem = MAX(pParse->nMem, iMem);
116306
+ sqlite3TouchRegister(pParse, iMem);
116307
+ assert( sqlite3NoTempsInRange(pParse, regNewRowid, iMem) );
116308
v = sqlite3GetVdbe(pParse);
116309
if( v==0 || NEVER(pTab==0) ){
116310
return;
@@ -115763,7 +116410,7 @@ static void analyzeOneTable(
116410
** the regPrev array and a trailing rowid (the rowid slot is required
116411
** when building a record to insert into the sample column of
116412
** the sqlite_stat4 table. */
115766
- pParse->nMem = MAX(pParse->nMem, regPrev+nColTest);
116413
+ sqlite3TouchRegister(pParse, regPrev+nColTest);
116414
116415
/* Open a read-only cursor on the index being analyzed. */
116416
assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
@@ -115935,7 +116582,35 @@ static void analyzeOneTable(
116582
int addrIsNull;
116583
u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
116584
115938
- pParse->nMem = MAX(pParse->nMem, regCol+nCol);
116585
+ if( doOnce ){
116586
+ int mxCol = nCol;
116587
+ Index *pX;
116588
+
116589
+ /* Compute the maximum number of columns in any index */
116590
+ for(pX=pTab->pIndex; pX; pX=pX->pNext){
116591
+ int nColX; /* Number of columns in pX */
116592
+ if( !HasRowid(pTab) && IsPrimaryKeyIndex(pX) ){
116593
+ nColX = pX->nKeyCol;
116594
+ }else{
116595
+ nColX = pX->nColumn;
116596
+ }
116597
+ if( nColX>mxCol ) mxCol = nColX;
116598
+ }
116599
+
116600
+ /* Allocate space to compute results for the largest index */
116601
+ sqlite3TouchRegister(pParse, regCol+mxCol);
116602
+ doOnce = 0;
116603
+#ifdef SQLITE_DEBUG
116604
+ /* Verify that the call to sqlite3ClearTempRegCache() below
116605
+ ** really is needed.
116606
+ ** https://sqlite.org/forum/forumpost/83cb4a95a0 (2023-03-25)
116607
+ */
116608
+ testcase( !sqlite3NoTempsInRange(pParse, regEq, regCol+mxCol) );
116609
+#endif
116610
+ sqlite3ClearTempRegCache(pParse); /* tag-20230325-1 */
116611
+ assert( sqlite3NoTempsInRange(pParse, regEq, regCol+mxCol) );
116612
+ }
116613
+ assert( sqlite3NoTempsInRange(pParse, regEq, regCol+nCol) );
116614
116615
addrNext = sqlite3VdbeCurrentAddr(v);
116616
callStatGet(pParse, regStat, STAT_GET_ROWID, regSampleRowid);
@@ -116016,6 +116691,11 @@ static void analyzeDatabase(Parse *pParse, int iDb){
116691
for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){
116692
Table *pTab = (Table*)sqliteHashData(k);
116693
analyzeOneTable(pParse, pTab, 0, iStatCur, iMem, iTab);
116694
+#ifdef SQLITE_ENABLE_STAT4
116695
+ iMem = sqlite3FirstAvailableRegister(pParse, iMem);
116696
+#else
116697
+ assert( iMem==sqlite3FirstAvailableRegister(pParse,iMem) );
116698
+#endif
116699
}
116700
loadAnalysis(pParse, iDb);
116701
}
@@ -116403,6 +117083,10 @@ static int loadStatTbl(
117083
pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
117084
assert( pIdx==0 || pIdx->nSample==0 );
117085
if( pIdx==0 ) continue;
117086
+ if( pIdx->aSample!=0 ){
117087
+ /* The same index appears in sqlite_stat4 under multiple names */
117088
+ continue;
117089
+ }
117090
assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
117091
if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
117092
nIdxCol = pIdx->nKeyCol;
@@ -116410,6 +117094,7 @@ static int loadStatTbl(
117094
nIdxCol = pIdx->nColumn;
117095
}
117096
pIdx->nSampleCol = nIdxCol;
117097
+ pIdx->mxSample = nSample;
117098
nByte = sizeof(IndexSample) * nSample;
117099
nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;
117100
nByte += nIdxCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */
@@ -116449,6 +117134,11 @@ static int loadStatTbl(
117134
if( zIndex==0 ) continue;
117135
pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
117136
if( pIdx==0 ) continue;
117137
+ if( pIdx->nSample>=pIdx->mxSample ){
117138
+ /* Too many slots used because the same index appears in
117139
+ ** sqlite_stat4 using multiple names */
117140
+ continue;
117141
+ }
117142
/* This next condition is true if data has already been loaded from
117143
** the sqlite_stat4 table. */
117144
nCol = pIdx->nSampleCol;
@@ -116492,11 +117182,12 @@ static int loadStat4(sqlite3 *db, const char *zDb){
117182
const Table *pStat4;
117183
117184
assert( db->lookaside.bDisable );
116495
- if( (pStat4 = sqlite3FindTable(db, "sqlite_stat4", zDb))!=0
117185
+ if( OptimizationEnabled(db, SQLITE_Stat4)
117186
+ && (pStat4 = sqlite3FindTable(db, "sqlite_stat4", zDb))!=0
117187
&& IsOrdinaryTable(pStat4)
117188
){
117189
rc = loadStatTbl(db,
116499
- "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx",
117190
+ "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx COLLATE nocase",
117191
"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4",
117192
zDb
117193
);
@@ -118340,7 +119031,7 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
119031
if( IsOrdinaryTable(pTable) ){
119032
sqlite3FkDelete(db, pTable);
119033
}
118343
-#ifndef SQLITE_OMIT_VIRTUAL_TABLE
119034
+#ifndef SQLITE_OMIT_VIRTUALTABLE
119035
else if( IsVirtual(pTable) ){
119036
sqlite3VtabClear(db, pTable);
119037
}
@@ -123372,6 +124063,7 @@ SQLITE_PRIVATE void sqlite3SetTextEncoding(sqlite3 *db, u8 enc){
124063
** strings is BINARY.
124064
*/
124065
db->pDfltColl = sqlite3FindCollSeq(db, enc, sqlite3StrBINARY, 0);
124066
+ sqlite3ExpirePreparedStatements(db, 1);
124067
}
124068
124069
/*
@@ -123843,13 +124535,15 @@ static int tabIsReadOnly(Parse *pParse, Table *pTab){
124535
** If pTab is writable but other errors have occurred -> return 1.
124536
** If pTab is writable and no prior errors -> return 0;
124537
*/
123846
-SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
124538
+SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, Trigger *pTrigger){
124539
if( tabIsReadOnly(pParse, pTab) ){
124540
sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
124541
return 1;
124542
}
124543
#ifndef SQLITE_OMIT_VIEW
123852
- if( !viewOk && IsView(pTab) ){
124544
+ if( IsView(pTab)
124545
+ && (pTrigger==0 || (pTrigger->bReturning && pTrigger->pNext==0))
124546
+ ){
124547
sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
124548
return 1;
124549
}
@@ -124103,7 +124797,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
124797
goto delete_from_cleanup;
124798
}
124799
124106
- if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){
124800
+ if( sqlite3IsReadOnly(pParse, pTab, pTrigger) ){
124801
goto delete_from_cleanup;
124802
}
124803
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
@@ -126266,7 +126960,7 @@ static void trimFunc(
126960
/*
126961
** The "unknown" function is automatically substituted in place of
126962
** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN
126269
-** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used.
126963
+** when the SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION compile-time option is used.
126964
** When the "sqlite3" command-line shell is built using this functionality,
126965
** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries
126966
** involving application-defined functions to be examined in a generic
@@ -128569,22 +129263,22 @@ static Trigger *fkActionTrigger(
129263
129264
if( action==OE_Restrict ){
129265
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
128572
- Token tFrom;
128573
- Token tDb;
129266
+ SrcList *pSrc;
129267
Expr *pRaise;
129268
128576
- tFrom.z = zFrom;
128577
- tFrom.n = nFrom;
128578
- tDb.z = db->aDb[iDb].zDbSName;
128579
- tDb.n = sqlite3Strlen30(tDb.z);
128580
-
129269
pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed");
129270
if( pRaise ){
129271
pRaise->affExpr = OE_Abort;
129272
}
129273
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
129274
+ if( pSrc ){
129275
+ assert( pSrc->nSrc==1 );
129276
+ pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom);
129277
+ pSrc->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);
129278
+ }
129279
pSelect = sqlite3SelectNew(pParse,
129280
sqlite3ExprListAppend(pParse, 0, pRaise),
128587
- sqlite3SrcListAppend(pParse, 0, &tDb, &tFrom),
129281
+ pSrc,
129282
pWhere,
129283
0, 0, 0, 0, 0
129284
);
@@ -128800,46 +129494,48 @@ SQLITE_PRIVATE void sqlite3OpenTable(
129494
** is managed along with the rest of the Index structure. It will be
129495
** released when sqlite3DeleteIndex() is called.
129496
*/
128803
-SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
129497
+static SQLITE_NOINLINE const char *computeIndexAffStr(sqlite3 *db, Index *pIdx){
129498
+ /* The first time a column affinity string for a particular index is
129499
+ ** required, it is allocated and populated here. It is then stored as
129500
+ ** a member of the Index structure for subsequent use.
129501
+ **
129502
+ ** The column affinity string will eventually be deleted by
129503
+ ** sqliteDeleteIndex() when the Index structure itself is cleaned
129504
+ ** up.
129505
+ */
129506
+ int n;
129507
+ Table *pTab = pIdx->pTable;
129508
+ pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);
129509
if( !pIdx->zColAff ){
128805
- /* The first time a column affinity string for a particular index is
128806
- ** required, it is allocated and populated here. It is then stored as
128807
- ** a member of the Index structure for subsequent use.
128808
- **
128809
- ** The column affinity string will eventually be deleted by
128810
- ** sqliteDeleteIndex() when the Index structure itself is cleaned
128811
- ** up.
128812
- */
128813
- int n;
128814
- Table *pTab = pIdx->pTable;
128815
- pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);
128816
- if( !pIdx->zColAff ){
128817
- sqlite3OomFault(db);
128818
- return 0;
128819
- }
128820
- for(n=0; n<pIdx->nColumn; n++){
128821
- i16 x = pIdx->aiColumn[n];
128822
- char aff;
128823
- if( x>=0 ){
128824
- aff = pTab->aCol[x].affinity;
128825
- }else if( x==XN_ROWID ){
128826
- aff = SQLITE_AFF_INTEGER;
128827
- }else{
128828
- assert( x==XN_EXPR );
128829
- assert( pIdx->bHasExpr );
128830
- assert( pIdx->aColExpr!=0 );
128831
- aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
128832
- }
128833
- if( aff<SQLITE_AFF_BLOB ) aff = SQLITE_AFF_BLOB;
128834
- if( aff>SQLITE_AFF_NUMERIC) aff = SQLITE_AFF_NUMERIC;
128835
- pIdx->zColAff[n] = aff;
129510
+ sqlite3OomFault(db);
129511
+ return 0;
129512
+ }
129513
+ for(n=0; n<pIdx->nColumn; n++){
129514
+ i16 x = pIdx->aiColumn[n];
129515
+ char aff;
129516
+ if( x>=0 ){
129517
+ aff = pTab->aCol[x].affinity;
129518
+ }else if( x==XN_ROWID ){
129519
+ aff = SQLITE_AFF_INTEGER;
129520
+ }else{
129521
+ assert( x==XN_EXPR );
129522
+ assert( pIdx->bHasExpr );
129523
+ assert( pIdx->aColExpr!=0 );
129524
+ aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
129525
}
128837
- pIdx->zColAff[n] = 0;
129526
+ if( aff<SQLITE_AFF_BLOB ) aff = SQLITE_AFF_BLOB;
129527
+ if( aff>SQLITE_AFF_NUMERIC) aff = SQLITE_AFF_NUMERIC;
129528
+ pIdx->zColAff[n] = aff;
129529
}
128839
-
129530
+ pIdx->zColAff[n] = 0;
129531
+ return pIdx->zColAff;
129532
+}
129533
+SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
129534
+ if( !pIdx->zColAff ) return computeIndexAffStr(db, pIdx);
129535
return pIdx->zColAff;
129536
}
129537
129538
+
129539
/*
129540
** Compute an affinity string for a table. Space is obtained
129541
** from sqlite3DbMalloc(). The caller is responsible for freeing
@@ -129524,7 +130220,7 @@ SQLITE_PRIVATE void sqlite3Insert(
130220
130221
/* Cannot insert into a read-only table.
130222
*/
129527
- if( sqlite3IsReadOnly(pParse, pTab, tmask) ){
130223
+ if( sqlite3IsReadOnly(pParse, pTab, pTrigger) ){
130224
goto insert_cleanup;
130225
}
130226
@@ -129971,7 +130667,7 @@ SQLITE_PRIVATE void sqlite3Insert(
130667
}
130668
130669
/* Copy the new data already generated. */
129974
- assert( pTab->nNVCol>0 );
130670
+ assert( pTab->nNVCol>0 || pParse->nErr>0 );
130671
sqlite3VdbeAddOp3(v, OP_Copy, regRowid+1, regCols+1, pTab->nNVCol-1);
130672
130673
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
@@ -133334,7 +134030,11 @@ static int sqlite3LoadExtension(
134030
/* tag-20210611-1. Some dlopen() implementations will segfault if given
134031
** an oversize filename. Most filesystems have a pathname limit of 4K,
134032
** so limit the extension filename length to about twice that.
133337
- ** https://sqlite.org/forum/forumpost/08a0d6d9bf */
134033
+ ** https://sqlite.org/forum/forumpost/08a0d6d9bf
134034
+ **
134035
+ ** Later (2023-03-25): Save an extra 6 bytes for the filename suffix.
134036
+ ** See https://sqlite.org/forum/forumpost/24083b579d.
134037
+ */
134038
if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found;
134039
134040
handle = sqlite3OsDlOpen(pVfs, zFile);
@@ -133342,7 +134042,9 @@ static int sqlite3LoadExtension(
134042
for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
134043
char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
134044
if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
133345
- handle = sqlite3OsDlOpen(pVfs, zAltFile);
134045
+ if( nMsg+strlen(azEndings[ii])+1<=SQLITE_MAX_PATHLEN ){
134046
+ handle = sqlite3OsDlOpen(pVfs, zAltFile);
134047
+ }
134048
sqlite3_free(zAltFile);
134049
}
134050
#endif
@@ -135837,7 +136539,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
136539
zDb = db->aDb[iDb].zDbSName;
136540
sqlite3CodeVerifySchema(pParse, iDb);
136541
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
135840
- if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
136542
+ sqlite3TouchRegister(pParse, pTab->nCol+regRow);
136543
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
136544
sqlite3VdbeLoadString(v, regResult, pTab->zName);
136545
assert( IsOrdinaryTable(pTab) );
@@ -135878,7 +136580,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
136580
** regRow..regRow+n. If any of the child key values are NULL, this
136581
** row cannot cause an FK violation. Jump directly to addrOk in
136582
** this case. */
135881
- if( regRow+pFK->nCol>pParse->nMem ) pParse->nMem = regRow+pFK->nCol;
136583
+ sqlite3TouchRegister(pParse, regRow + pFK->nCol);
136584
for(j=0; j<pFK->nCol; j++){
136585
int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;
136586
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);
@@ -136007,6 +136709,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
136709
if( iDb>=0 && i!=iDb ) continue;
136710
136711
sqlite3CodeVerifySchema(pParse, i);
136712
+ pParse->okConstFactor = 0; /* tag-20230327-1 */
136713
136714
/* Do an integrity check of the B-Tree
136715
**
@@ -136042,7 +136745,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
136745
aRoot[0] = cnt;
136746
136747
/* Make sure sufficient number of registers have been allocated */
136045
- pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
136748
+ sqlite3TouchRegister(pParse, 8+mxIdx);
136749
sqlite3ClearTempRegCache(pParse);
136750
136751
/* Do the b-tree integrity checks */
@@ -136192,15 +136895,29 @@ SQLITE_PRIVATE void sqlite3Pragma(
136895
labelOk = sqlite3VdbeMakeLabel(pParse);
136896
if( pCol->notNull ){
136897
/* (1) NOT NULL columns may not contain a NULL */
136898
+ int jmp3;
136899
int jmp2 = sqlite3VdbeAddOp4Int(v, OP_IsType, p1, labelOk, p3, p4);
136196
- sqlite3VdbeChangeP5(v, 0x0f);
136900
VdbeCoverage(v);
136901
+ if( p1<0 ){
136902
+ sqlite3VdbeChangeP5(v, 0x0f); /* INT, REAL, TEXT, or BLOB */
136903
+ jmp3 = jmp2;
136904
+ }else{
136905
+ sqlite3VdbeChangeP5(v, 0x0d); /* INT, TEXT, or BLOB */
136906
+ /* OP_IsType does not detect NaN values in the database file
136907
+ ** which should be treated as a NULL. So if the header type
136908
+ ** is REAL, we have to load the actual data using OP_Column
136909
+ ** to reliably determine if the value is a NULL. */
136910
+ sqlite3VdbeAddOp3(v, OP_Column, p1, p3, 3);
136911
+ jmp3 = sqlite3VdbeAddOp2(v, OP_NotNull, 3, labelOk);
136912
+ VdbeCoverage(v);
136913
+ }
136914
zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
136915
pCol->zCnName);
136916
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
136917
if( doTypeCheck ){
136918
sqlite3VdbeGoto(v, labelError);
136919
sqlite3VdbeJumpHere(v, jmp2);
136920
+ sqlite3VdbeJumpHere(v, jmp3);
136921
}else{
136922
/* VDBE byte code will fall thru */
136923
}
@@ -136308,7 +137025,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
137025
int jmp7;
137026
sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur+j, 3);
137027
jmp7 = sqlite3VdbeAddOp3(v, OP_Eq, 3, 0, r1+pIdx->nColumn-1);
136311
- VdbeCoverage(v);
137028
+ VdbeCoverageNeverNull(v);
137029
sqlite3VdbeLoadString(v, 3,
137030
"rowid not at end-of-record for row ");
137031
sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
@@ -137514,7 +138231,9 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
138231
#else
138232
encoding = SQLITE_UTF8;
138233
#endif
137517
- if( db->nVdbeActive>0 && encoding!=ENC(db) ){
138234
+ if( db->nVdbeActive>0 && encoding!=ENC(db)
138235
+ && (db->mDbFlags & DBFLAG_Vacuum)==0
138236
+ ){
138237
rc = SQLITE_LOCKED;
138238
goto initone_error_out;
138239
}else{
@@ -137908,7 +138627,11 @@ static int sqlite3Prepare(
138627
sParse.db = db;
138628
sParse.pReprepare = pReprepare;
138629
assert( ppStmt && *ppStmt==0 );
137911
- if( db->mallocFailed ) sqlite3ErrorMsg(&sParse, "out of memory");
138630
+ if( db->mallocFailed ){
138631
+ sqlite3ErrorMsg(&sParse, "out of memory");
138632
+ db->errCode = rc = SQLITE_NOMEM;
138633
+ goto end_prepare;
138634
+ }
138635
assert( sqlite3_mutex_held(db->mutex) );
138636
138637
/* For a long-term use prepared statement avoid the use of
@@ -138997,7 +139720,7 @@ static void pushOntoSorter(
139720
** (2) All output columns are included in the sort record. In that
139721
** case regData==regOrigData.
139722
** (3) Some output columns are omitted from the sort record due to
139000
- ** the SQLITE_ENABLE_SORTER_REFERENCE optimization, or due to the
139723
+ ** the SQLITE_ENABLE_SORTER_REFERENCES optimization, or due to the
139724
** SQLITE_ECEL_OMITREF optimization, or due to the
139725
** SortCtx.pDeferredRowLoad optimiation. In any of these cases
139726
** regOrigData is 0 to prevent this routine from trying to copy
@@ -140598,7 +141321,7 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
141321
assert( (pSelect->selFlags & SF_Resolved)!=0 );
141322
assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
141323
assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
140601
- if( db->mallocFailed ) return;
141324
+ if( db->mallocFailed || IN_RENAME_OBJECT ) return;
141325
while( pSelect->pPrior ) pSelect = pSelect->pPrior;
141326
a = pSelect->pEList->a;
141327
memset(&sNC, 0, sizeof(sNC));
@@ -140643,18 +141366,16 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
141366
break;
141367
}
141368
}
140646
- }
140647
- }
140648
- if( zType ){
140649
- i64 m = sqlite3Strlen30(zType);
140650
- n = sqlite3Strlen30(pCol->zCnName);
140651
- pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2);
140652
- if( pCol->zCnName ){
140653
- memcpy(&pCol->zCnName[n+1], zType, m+1);
140654
- pCol->colFlags |= COLFLAG_HASTYPE;
140655
- }else{
140656
- testcase( pCol->colFlags & COLFLAG_HASTYPE );
140657
- pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL);
141369
+ }
141370
+ }
141371
+ if( zType ){
141372
+ i64 m = sqlite3Strlen30(zType);
141373
+ n = sqlite3Strlen30(pCol->zCnName);
141374
+ pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2);
141375
+ pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL);
141376
+ if( pCol->zCnName ){
141377
+ memcpy(&pCol->zCnName[n+1], zType, m+1);
141378
+ pCol->colFlags |= COLFLAG_HASTYPE;
141379
}
141380
}
141381
pColl = sqlite3ExprCollSeq(pParse, p);
@@ -142521,8 +143242,7 @@ static int compoundHasDifferentAffinities(Select *p){
143242
** query or there are no RIGHT or FULL JOINs in any arm
143243
** of the subquery. (This is a duplicate of condition (27b).)
143244
** (17h) The corresponding result set expressions in all arms of the
142524
-** compound must have the same affinity. (See restriction (9)
142525
-** on the push-down optimization.)
143245
+** compound must have the same affinity.
143246
**
143247
** The parent and sub-query may contain WHERE clauses. Subject to
143248
** rules (11), (13) and (14), they may also contain ORDER BY,
@@ -143390,10 +144110,24 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){
144110
** or EXCEPT, then all of the result set columns for all arms of
144111
** the compound must use the BINARY collating sequence.
144112
**
143393
-** (9) If the subquery is a compound, then all arms of the compound must
143394
-** have the same affinity. (This is the same as restriction (17h)
143395
-** for query flattening.)
144113
+** (9) All three of the following are true:
144114
**
144115
+** (9a) The WHERE clause expression originates in the ON or USING clause
144116
+** of a join (either an INNER or an OUTER join), and
144117
+**
144118
+** (9b) The subquery is to the right of the ON/USING clause
144119
+**
144120
+** (9c) There is a RIGHT JOIN (or FULL JOIN) in between the ON/USING
144121
+** clause and the subquery.
144122
+**
144123
+** Without this restriction, the push-down optimization might move
144124
+** the ON/USING filter expression from the left side of a RIGHT JOIN
144125
+** over to the right side, which leads to incorrect answers. See
144126
+** also restriction (6) in sqlite3ExprIsSingleTableConstraint().
144127
+**
144128
+** (10) The inner query is not the right-hand table of a RIGHT JOIN.
144129
+**
144130
+** (11) The subquery is not a VALUES clause
144131
**
144132
** Return 0 if no changes are made and non-zero if one or more WHERE clause
144133
** terms are duplicated into the subquery.
@@ -143402,13 +144136,20 @@ static int pushDownWhereTerms(
144136
Parse *pParse, /* Parse context (for malloc() and error reporting) */
144137
Select *pSubq, /* The subquery whose WHERE clause is to be augmented */
144138
Expr *pWhere, /* The WHERE clause of the outer query */
143405
- SrcItem *pSrc /* The subquery term of the outer FROM clause */
144139
+ SrcList *pSrcList, /* The complete from clause of the outer query */
144140
+ int iSrc /* Which FROM clause term to try to push into */
144141
){
144142
Expr *pNew;
144143
+ SrcItem *pSrc; /* The subquery FROM term into which WHERE is pushed */
144144
int nChng = 0;
144145
+ pSrc = &pSrcList->a[iSrc];
144146
if( pWhere==0 ) return 0;
143410
- if( pSubq->selFlags & (SF_Recursive|SF_MultiPart) ) return 0;
143411
- if( pSrc->fg.jointype & (JT_LTORJ|JT_RIGHT) ) return 0;
144147
+ if( pSubq->selFlags & (SF_Recursive|SF_MultiPart) ){
144148
+ return 0; /* restrictions (2) and (11) */
144149
+ }
144150
+ if( pSrc->fg.jointype & (JT_LTORJ|JT_RIGHT) ){
144151
+ return 0; /* restrictions (10) */
144152
+ }
144153
144154
if( pSubq->pPrior ){
144155
Select *pSel;
@@ -143424,9 +144165,6 @@ static int pushDownWhereTerms(
144165
if( pSel->pWin ) return 0; /* restriction (6b) */
144166
#endif
144167
}
143427
- if( compoundHasDifferentAffinities(pSubq) ){
143428
- return 0; /* restriction (9) */
143429
- }
144168
if( notUnionAll ){
144169
/* If any of the compound arms are connected using UNION, INTERSECT,
144170
** or EXCEPT, then we must ensure that none of the columns use a
@@ -143466,11 +144204,28 @@ static int pushDownWhereTerms(
144204
return 0; /* restriction (3) */
144205
}
144206
while( pWhere->op==TK_AND ){
143469
- nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, pSrc);
144207
+ nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, pSrcList, iSrc);
144208
pWhere = pWhere->pLeft;
144209
}
144210
143473
-#if 0 /* Legacy code. Checks now done by sqlite3ExprIsTableConstraint() */
144211
+#if 0 /* These checks now done by sqlite3ExprIsSingleTableConstraint() */
144212
+ if( ExprHasProperty(pWhere, EP_OuterON|EP_InnerON) /* (9a) */
144213
+ && (pSrcList->a[0].fg.jointype & JT_LTORJ)!=0 /* Fast pre-test of (9c) */
144214
+ ){
144215
+ int jj;
144216
+ for(jj=0; jj<iSrc; jj++){
144217
+ if( pWhere->w.iJoin==pSrcList->a[jj].iCursor ){
144218
+ /* If we reach this point, both (9a) and (9b) are satisfied.
144219
+ ** The following loop checks (9c):
144220
+ */
144221
+ for(jj++; jj<iSrc; jj++){
144222
+ if( (pSrcList->a[jj].fg.jointype & JT_RIGHT)!=0 ){
144223
+ return 0; /* restriction (9) */
144224
+ }
144225
+ }
144226
+ }
144227
+ }
144228
+ }
144229
if( isLeftJoin
144230
&& (ExprHasProperty(pWhere,EP_OuterON)==0
144231
|| pWhere->w.iJoin!=iCursor)
@@ -143484,7 +144239,7 @@ static int pushDownWhereTerms(
144239
}
144240
#endif
144241
143487
- if( sqlite3ExprIsTableConstraint(pWhere, pSrc) ){
144242
+ if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc) ){
144243
nChng++;
144244
pSubq->selFlags |= SF_PushDown;
144245
while( pSubq ){
@@ -143518,6 +144273,78 @@ static int pushDownWhereTerms(
144273
}
144274
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
144275
144276
+/*
144277
+** Check to see if a subquery contains result-set columns that are
144278
+** never used. If it does, change the value of those result-set columns
144279
+** to NULL so that they do not cause unnecessary work to compute.
144280
+**
144281
+** Return the number of column that were changed to NULL.
144282
+*/
144283
+static int disableUnusedSubqueryResultColumns(SrcItem *pItem){
144284
+ int nCol;
144285
+ Select *pSub; /* The subquery to be simplified */
144286
+ Select *pX; /* For looping over compound elements of pSub */
144287
+ Table *pTab; /* The table that describes the subquery */
144288
+ int j; /* Column number */
144289
+ int nChng = 0; /* Number of columns converted to NULL */
144290
+ Bitmask colUsed; /* Columns that may not be NULLed out */
144291
+
144292
+ assert( pItem!=0 );
144293
+ if( pItem->fg.isCorrelated || pItem->fg.isCte ){
144294
+ return 0;
144295
+ }
144296
+ assert( pItem->pTab!=0 );
144297
+ pTab = pItem->pTab;
144298
+ assert( pItem->pSelect!=0 );
144299
+ pSub = pItem->pSelect;
144300
+ assert( pSub->pEList->nExpr==pTab->nCol );
144301
+ if( (pSub->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){
144302
+ testcase( pSub->selFlags & SF_Distinct );
144303
+ testcase( pSub->selFlags & SF_Aggregate );
144304
+ return 0;
144305
+ }
144306
+ for(pX=pSub; pX; pX=pX->pPrior){
144307
+ if( pX->pPrior && pX->op!=TK_ALL ){
144308
+ /* This optimization does not work for compound subqueries that
144309
+ ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */
144310
+ return 0;
144311
+ }
144312
+#ifndef SQLITE_OMIT_WINDOWFUNC
144313
+ if( pX->pWin ){
144314
+ /* This optimization does not work for subqueries that use window
144315
+ ** functions. */
144316
+ return 0;
144317
+ }
144318
+#endif
144319
+ }
144320
+ colUsed = pItem->colUsed;
144321
+ if( pSub->pOrderBy ){
144322
+ ExprList *pList = pSub->pOrderBy;
144323
+ for(j=0; j<pList->nExpr; j++){
144324
+ u16 iCol = pList->a[j].u.x.iOrderByCol;
144325
+ if( iCol>0 ){
144326
+ iCol--;
144327
+ colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
144328
+ }
144329
+ }
144330
+ }
144331
+ nCol = pTab->nCol;
144332
+ for(j=0; j<nCol; j++){
144333
+ Bitmask m = j<BMS-1 ? MASKBIT(j) : TOPBIT;
144334
+ if( (m & colUsed)!=0 ) continue;
144335
+ for(pX=pSub; pX; pX=pX->pPrior) {
144336
+ Expr *pY = pX->pEList->a[j].pExpr;
144337
+ if( pY->op==TK_NULL ) continue;
144338
+ pY->op = TK_NULL;
144339
+ ExprClearProperty(pY, EP_Skip|EP_Unlikely);
144340
+ pX->selFlags |= SF_PushDown;
144341
+ nChng++;
144342
+ }
144343
+ }
144344
+ return nChng;
144345
+}
144346
+
144347
+
144348
/*
144349
** The pFunc is the only aggregate function in the query. Check to see
144350
** if the query is a candidate for the min/max optimization.
@@ -144664,12 +145491,13 @@ static void optimizeAggregateUseOfIndexedExpr(
145491
assert( pSelect->pGroupBy!=0 );
145492
pAggInfo->nColumn = pAggInfo->nAccumulator;
145493
if( ALWAYS(pAggInfo->nSortingColumn>0) ){
144667
- if( pAggInfo->nColumn==0 ){
144668
- pAggInfo->nSortingColumn = pSelect->pGroupBy->nExpr;
144669
- }else{
144670
- pAggInfo->nSortingColumn =
144671
- pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1;
145494
+ int mx = pSelect->pGroupBy->nExpr - 1;
145495
+ int j, k;
145496
+ for(j=0; j<pAggInfo->nColumn; j++){
145497
+ k = pAggInfo->aCol[j].iSorterColumn;
145498
+ if( k>mx ) mx = k;
145499
}
145500
+ pAggInfo->nSortingColumn = mx+1;
145501
}
145502
analyzeAggFuncArgs(pAggInfo, pNC);
145503
#if TREETRACE_ENABLED
@@ -144703,11 +145531,13 @@ static int aggregateIdxEprRefToColCallback(Walker *pWalker, Expr *pExpr){
145531
if( pExpr->op==TK_AGG_FUNCTION ) return WRC_Continue;
145532
if( pExpr->op==TK_IF_NULL_ROW ) return WRC_Continue;
145533
pAggInfo = pExpr->pAggInfo;
144706
- assert( pExpr->iAgg>=0 && pExpr->iAgg<pAggInfo->nColumn );
145534
+ if( NEVER(pExpr->iAgg>=pAggInfo->nColumn) ) return WRC_Continue;
145535
+ assert( pExpr->iAgg>=0 );
145536
pCol = &pAggInfo->aCol[pExpr->iAgg];
145537
pExpr->op = TK_AGG_COLUMN;
145538
pExpr->iTable = pCol->iTable;
145539
pExpr->iColumn = pCol->iColumn;
145540
+ ExprClearProperty(pExpr, EP_Skip|EP_Collate);
145541
return WRC_Prune;
145542
}
145543
@@ -145061,7 +145891,6 @@ static void agginfoFree(sqlite3 *db, AggInfo *p){
145891
sqlite3DbFreeNN(db, p);
145892
}
145893
145064
-#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
145894
/*
145895
** Attempt to transform a query of the form
145896
**
@@ -145089,6 +145918,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145918
if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */
145919
if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
145920
if( p->pWhere ) return 0;
145921
+ if( p->pHaving ) return 0;
145922
if( p->pGroupBy ) return 0;
145923
if( p->pOrderBy ) return 0;
145924
pExpr = p->pEList->a[0].pExpr;
@@ -145108,7 +145938,8 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145938
if( pSub->pWhere ) return 0; /* No WHERE clause */
145939
if( pSub->pLimit ) return 0; /* No LIMIT clause */
145940
if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
145111
- pSub = pSub->pPrior; /* Repeat over compound */
145941
+ assert( pSub->pHaving==0 ); /* Due to the previous */
145942
+ pSub = pSub->pPrior; /* Repeat over compound */
145943
}while( pSub );
145944
145945
/* If we reach this point then it is OK to perform the transformation */
@@ -145151,7 +145982,6 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145982
#endif
145983
return 1;
145984
}
145154
-#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */
145985
145986
/*
145987
** If any term of pSrc, or any SF_NestedFrom sub-query, is not the same
@@ -145407,7 +146237,7 @@ SQLITE_PRIVATE int sqlite3Select(
146237
pTabList->a[0].fg.jointype & JT_LTORJ);
146238
}
146239
145410
- /* No futher action if this term of the FROM clause is no a subquery */
146240
+ /* No futher action if this term of the FROM clause is not a subquery */
146241
if( pSub==0 ) continue;
146242
146243
/* Catch mismatch in the declared columns of a view and the number of
@@ -145540,14 +146370,12 @@ SQLITE_PRIVATE int sqlite3Select(
146370
TREETRACE(0x2000,pParse,p,("Constant propagation not helpful\n"));
146371
}
146372
145543
-#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
146373
if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)
146374
&& countOfViewOptimization(pParse, p)
146375
){
146376
if( db->mallocFailed ) goto select_end;
146377
pTabList = p->pSrc;
146378
}
145550
-#endif
146379
146380
/* For each term in the FROM clause, do two things:
146381
** (1) Authorized unreferenced tables
@@ -145606,7 +146434,7 @@ SQLITE_PRIVATE int sqlite3Select(
146434
if( OptimizationEnabled(db, SQLITE_PushDown)
146435
&& (pItem->fg.isCte==0
146436
|| (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2))
145609
- && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem)
146437
+ && pushDownWhereTerms(pParse, pSub, p->pWhere, pTabList, i)
146438
){
146439
#if TREETRACE_ENABLED
146440
if( sqlite3TreeTrace & 0x4000 ){
@@ -145620,6 +146448,22 @@ SQLITE_PRIVATE int sqlite3Select(
146448
TREETRACE(0x4000,pParse,p,("Push-down not possible\n"));
146449
}
146450
146451
+ /* Convert unused result columns of the subquery into simple NULL
146452
+ ** expressions, to avoid unneeded searching and computation.
146453
+ */
146454
+ if( OptimizationEnabled(db, SQLITE_NullUnusedCols)
146455
+ && disableUnusedSubqueryResultColumns(pItem)
146456
+ ){
146457
+#if TREETRACE_ENABLED
146458
+ if( sqlite3TreeTrace & 0x4000 ){
146459
+ TREETRACE(0x4000,pParse,p,
146460
+ ("Change unused result columns to NULL for subquery %d:\n",
146461
+ pSub->selId));
146462
+ sqlite3TreeViewSelect(0, p, 0);
146463
+ }
146464
+#endif
146465
+ }
146466
+
146467
zSavedAuthContext = pParse->zAuthContext;
146468
pParse->zAuthContext = pItem->zName;
146469
@@ -148157,6 +149001,9 @@ SQLITE_PRIVATE u32 sqlite3TriggerColmask(
149001
Trigger *p;
149002
149003
assert( isNew==1 || isNew==0 );
149004
+ if( IsView(pTab) ){
149005
+ return 0xffffffff;
149006
+ }
149007
for(p=pTrigger; p; p=p->pNext){
149008
if( p->op==op
149009
&& (tr_tm&p->tr_tm)
@@ -148591,7 +149438,7 @@ SQLITE_PRIVATE void sqlite3Update(
149438
if( sqlite3ViewGetColumnNames(pParse, pTab) ){
149439
goto update_cleanup;
149440
}
148594
- if( sqlite3IsReadOnly(pParse, pTab, tmask) ){
149441
+ if( sqlite3IsReadOnly(pParse, pTab, pTrigger) ){
149442
goto update_cleanup;
149443
}
149444
@@ -151382,7 +152229,10 @@ SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
152229
break;
152230
}
152231
if( xMethod && pVTab->iSavepoint>iSavepoint ){
152232
+ u64 savedFlags = (db->flags & SQLITE_Defensive);
152233
+ db->flags &= ~(u64)SQLITE_Defensive;
152234
rc = xMethod(pVTab->pVtab, iSavepoint);
152235
+ db->flags |= savedFlags;
152236
}
152237
sqlite3VtabUnlock(pVTab);
152238
}
@@ -151611,6 +152461,10 @@ SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){
152461
p->pVTable->eVtabRisk = SQLITE_VTABRISK_High;
152462
break;
152463
}
152464
+ case SQLITE_VTAB_USES_ALL_SCHEMAS: {
152465
+ p->pVTable->bAllSchemas = 1;
152466
+ break;
152467
+ }
152468
default: {
152469
rc = SQLITE_MISUSE_BKPT;
152470
break;
@@ -152384,9 +153238,9 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){
153238
153239
/*
153240
** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
152387
-** command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was
152388
-** defined at compile-time. If it is not a no-op, a single OP_Explain opcode
152389
-** is added to the output to describe the table scan strategy in pLevel.
153241
+** command, or if stmt_scanstatus_v2() stats are enabled, or if SQLITE_DEBUG
153242
+** was defined at compile-time. If it is not a no-op, a single OP_Explain
153243
+** opcode is added to the output to describe the table scan strategy in pLevel.
153244
**
153245
** If an OP_Explain opcode is added to the VM, its address is returned.
153246
** Otherwise, if no OP_Explain is coded, zero is returned.
@@ -152398,8 +153252,8 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
153252
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
153253
){
153254
int ret = 0;
152401
-#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)
152402
- if( sqlite3ParseToplevel(pParse)->explain==2 )
153255
+#if !defined(SQLITE_DEBUG)
153256
+ if( sqlite3ParseToplevel(pParse)->explain==2 || IS_STMT_SCANSTATUS(pParse->db) )
153257
#endif
153258
{
153259
SrcItem *pItem = &pTabList->a[pLevel->iFrom];
@@ -152565,27 +153419,29 @@ SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
153419
WhereLevel *pLvl, /* Level to add scanstatus() entry for */
153420
int addrExplain /* Address of OP_Explain (or 0) */
153421
){
152568
- const char *zObj = 0;
152569
- WhereLoop *pLoop = pLvl->pWLoop;
152570
- int wsFlags = pLoop->wsFlags;
152571
- int viaCoroutine = 0;
152572
-
152573
- if( (wsFlags & WHERE_VIRTUALTABLE)==0 && pLoop->u.btree.pIndex!=0 ){
152574
- zObj = pLoop->u.btree.pIndex->zName;
152575
- }else{
152576
- zObj = pSrclist->a[pLvl->iFrom].zName;
152577
- viaCoroutine = pSrclist->a[pLvl->iFrom].fg.viaCoroutine;
152578
- }
152579
- sqlite3VdbeScanStatus(
152580
- v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj
152581
- );
153422
+ if( IS_STMT_SCANSTATUS( sqlite3VdbeDb(v) ) ){
153423
+ const char *zObj = 0;
153424
+ WhereLoop *pLoop = pLvl->pWLoop;
153425
+ int wsFlags = pLoop->wsFlags;
153426
+ int viaCoroutine = 0;
153427
152583
- if( viaCoroutine==0 ){
152584
- if( (wsFlags & (WHERE_MULTI_OR|WHERE_AUTO_INDEX))==0 ){
152585
- sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iTabCur);
153428
+ if( (wsFlags & WHERE_VIRTUALTABLE)==0 && pLoop->u.btree.pIndex!=0 ){
153429
+ zObj = pLoop->u.btree.pIndex->zName;
153430
+ }else{
153431
+ zObj = pSrclist->a[pLvl->iFrom].zName;
153432
+ viaCoroutine = pSrclist->a[pLvl->iFrom].fg.viaCoroutine;
153433
}
152587
- if( wsFlags & WHERE_INDEXED ){
152588
- sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iIdxCur);
153434
+ sqlite3VdbeScanStatus(
153435
+ v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj
153436
+ );
153437
+
153438
+ if( viaCoroutine==0 ){
153439
+ if( (wsFlags & (WHERE_MULTI_OR|WHERE_AUTO_INDEX))==0 ){
153440
+ sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iTabCur);
153441
+ }
153442
+ if( wsFlags & WHERE_INDEXED ){
153443
+ sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iIdxCur);
153444
+ }
153445
}
153446
}
153447
}
@@ -153282,11 +154138,12 @@ static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
154138
*/
154139
static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
154140
int rc = WRC_Continue;
154141
+ int reg;
154142
struct CCurHint *pHint = pWalker->u.pCCurHint;
154143
if( pExpr->op==TK_COLUMN ){
154144
if( pExpr->iTable!=pHint->iTabCur ){
153288
- int reg = ++pWalker->pParse->nMem; /* Register for column value */
153289
- sqlite3ExprCode(pWalker->pParse, pExpr, reg);
154145
+ reg = ++pWalker->pParse->nMem; /* Register for column value */
154146
+ reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
154147
pExpr->op = TK_REGISTER;
154148
pExpr->iTable = reg;
154149
}else if( pHint->pIdx!=0 ){
@@ -153294,15 +154151,15 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
154151
pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
154152
assert( pExpr->iColumn>=0 );
154153
}
153297
- }else if( pExpr->op==TK_AGG_FUNCTION ){
153298
- /* An aggregate function in the WHERE clause of a query means this must
153299
- ** be a correlated sub-query, and expression pExpr is an aggregate from
153300
- ** the parent context. Do not walk the function arguments in this case.
153301
- **
153302
- ** todo: It should be possible to replace this node with a TK_REGISTER
153303
- ** expression, as the result of the expression must be stored in a
153304
- ** register at this point. The same holds for TK_AGG_COLUMN nodes. */
154154
+ }else if( pExpr->pAggInfo ){
154155
rc = WRC_Prune;
154156
+ reg = ++pWalker->pParse->nMem; /* Register for column value */
154157
+ reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
154158
+ pExpr->op = TK_REGISTER;
154159
+ pExpr->iTable = reg;
154160
+ }else if( pExpr->op==TK_TRUEFALSE ){
154161
+ /* Do not walk disabled expressions. tag-20230504-1 */
154162
+ return WRC_Prune;
154163
}
154164
return rc;
154165
}
@@ -153404,7 +154261,7 @@ static void codeCursorHint(
154261
}
154262
if( pExpr!=0 ){
154263
sWalker.xExprCallback = codeCursorHintFixExpr;
153407
- sqlite3WalkExpr(&sWalker, pExpr);
154264
+ if( pParse->nErr==0 ) sqlite3WalkExpr(&sWalker, pExpr);
154265
sqlite3VdbeAddOp4(v, OP_CursorHint,
154266
(sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
154267
(const char*)pExpr, P4_EXPR);
@@ -154198,7 +155055,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
155055
** guess. */
155056
addrSeekScan = sqlite3VdbeAddOp1(v, OP_SeekScan,
155057
(pIdx->aiRowLogEst[0]+9)/10);
154201
- if( pRangeStart ){
155058
+ if( pRangeStart || pRangeEnd ){
155059
sqlite3VdbeChangeP5(v, 1);
155060
sqlite3VdbeChangeP2(v, addrSeekScan, sqlite3VdbeCurrentAddr(v)+1);
155061
addrSeekScan = 0;
@@ -154239,16 +155096,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
155096
assert( pLevel->p2==0 );
155097
if( pRangeEnd ){
155098
Expr *pRight = pRangeEnd->pExpr->pRight;
154242
- if( addrSeekScan ){
154243
- /* For a seek-scan that has a range on the lowest term of the index,
154244
- ** we have to make the top of the loop be code that sets the end
154245
- ** condition of the range. Otherwise, the OP_SeekScan might jump
154246
- ** over that initialization, leaving the range-end value set to the
154247
- ** range-start value, resulting in a wrong answer.
154248
- ** See ticket 5981a8c041a3c2f3 (2021-11-02).
154249
- */
154250
- pLevel->p2 = sqlite3VdbeCurrentAddr(v);
154251
- }
155099
+ assert( addrSeekScan==0 );
155100
codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
155101
whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
155102
if( (pRangeEnd->wtFlags & TERM_VNULL)==0
@@ -154282,7 +155130,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
155130
if( zEndAff ) sqlite3DbNNFreeNN(db, zEndAff);
155131
155132
/* Top of the loop body */
154285
- if( pLevel->p2==0 ) pLevel->p2 = sqlite3VdbeCurrentAddr(v);
155133
+ pLevel->p2 = sqlite3VdbeCurrentAddr(v);
155134
155135
/* Check if the index cursor is past the end of the range. */
155136
if( nConstraint ){
@@ -156279,7 +157127,7 @@ static void exprAnalyze(
157127
&& 0==sqlite3ExprCanBeNull(pLeft)
157128
){
157129
assert( !ExprHasProperty(pExpr, EP_IntValue) );
156282
- pExpr->op = TK_TRUEFALSE;
157130
+ pExpr->op = TK_TRUEFALSE; /* See tag-20230504-1 */
157131
pExpr->u.zToken = "false";
157132
ExprSetProperty(pExpr, EP_IsFalse);
157133
pTerm->prereqAll = 0;
@@ -156924,9 +157772,12 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
157772
pRhs = sqlite3PExpr(pParse, TK_UPLUS,
157773
sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
157774
pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
156927
- if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT) ){
157775
+ if( pItem->fg.jointype & (JT_LEFT|JT_RIGHT) ){
157776
+ testcase( pItem->fg.jointype & JT_LEFT ); /* testtag-20230227a */
157777
+ testcase( pItem->fg.jointype & JT_RIGHT ); /* testtag-20230227b */
157778
joinType = EP_OuterON;
157779
}else{
157780
+ testcase( pItem->fg.jointype & JT_LTORJ ); /* testtag-20230227c */
157781
joinType = EP_InnerON;
157782
}
157783
sqlite3SetJoinExpr(pTerm, pItem->iCursor, joinType);
@@ -157769,7 +158620,7 @@ static void explainAutomaticIndex(
158620
int bPartial, /* True if pIdx is a partial index */
158621
int *pAddrExplain /* OUT: Address of OP_Explain */
158622
){
157772
- if( pParse->explain!=2 ){
158623
+ if( IS_STMT_SCANSTATUS(pParse->db) && pParse->explain!=2 ){
158624
Table *pTab = pIdx->pTable;
158625
const char *zSep = "";
158626
char *zText = 0;
@@ -157808,8 +158659,7 @@ static void explainAutomaticIndex(
158659
*/
158660
static SQLITE_NOINLINE void constructAutomaticIndex(
158661
Parse *pParse, /* The parsing context */
157811
- const WhereClause *pWC, /* The WHERE clause */
157812
- const SrcItem *pSrc, /* The FROM clause term to get the next index */
158662
+ WhereClause *pWC, /* The WHERE clause */
158663
const Bitmask notReady, /* Mask of cursors that are not available */
158664
WhereLevel *pLevel /* Write new index here */
158665
){
@@ -157830,10 +158680,12 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158680
char *zNotUsed; /* Extra space on the end of pIdx */
158681
Bitmask idxCols; /* Bitmap of columns used for indexing */
158682
Bitmask extraCols; /* Bitmap of additional columns */
157833
- u8 sentWarning = 0; /* True if a warnning has been issued */
158683
+ u8 sentWarning = 0; /* True if a warning has been issued */
158684
+ u8 useBloomFilter = 0; /* True to also add a Bloom filter */
158685
Expr *pPartial = 0; /* Partial Index Expression */
158686
int iContinue = 0; /* Jump here to skip excluded rows */
157836
- SrcItem *pTabItem; /* FROM clause term being indexed */
158687
+ SrcList *pTabList; /* The complete FROM clause */
158688
+ SrcItem *pSrc; /* The FROM clause term to get the next index */
158689
int addrCounter = 0; /* Address where integer counter is initialized */
158690
int regBase; /* Array of registers where record is assembled */
158691
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
@@ -157849,6 +158701,8 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158701
/* Count the number of columns that will be added to the index
158702
** and used to match WHERE clause constraints */
158703
nKeyCol = 0;
158704
+ pTabList = pWC->pWInfo->pTabList;
158705
+ pSrc = &pTabList->a[pLevel->iFrom];
158706
pTable = pSrc->pTab;
158707
pWCEnd = &pWC->a[pWC->nTerm];
158708
pLoop = pLevel->pWLoop;
@@ -157859,7 +158713,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158713
** WHERE clause (or the ON clause of a LEFT join) that constrain which
158714
** rows of the target table (pSrc) that can be used. */
158715
if( (pTerm->wtFlags & TERM_VIRTUAL)==0
157862
- && sqlite3ExprIsTableConstraint(pExpr, pSrc)
158716
+ && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom)
158717
){
158718
pPartial = sqlite3ExprAnd(pParse, pPartial,
158719
sqlite3ExprDup(pParse->db, pExpr, 0));
@@ -157900,7 +158754,11 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158754
** original table changes and the index and table cannot both be used
158755
** if they go out of sync.
158756
*/
157903
- extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
158757
+ if( IsView(pTable) ){
158758
+ extraCols = ALLBITS;
158759
+ }else{
158760
+ extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
158761
+ }
158762
mxBitCol = MIN(BMS-1,pTable->nCol);
158763
testcase( pTable->nCol==BMS-1 );
158764
testcase( pTable->nCol==BMS-2 );
@@ -157936,6 +158794,16 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158794
assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */
158795
pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
158796
n++;
158797
+ if( ALWAYS(pX->pLeft!=0)
158798
+ && sqlite3ExprAffinity(pX->pLeft)!=SQLITE_AFF_TEXT
158799
+ ){
158800
+ /* TUNING: only use a Bloom filter on an automatic index
158801
+ ** if one or more key columns has the ability to hold numeric
158802
+ ** values, since strings all have the same hash in the Bloom
158803
+ ** filter implementation and hence a Bloom filter on a text column
158804
+ ** is not usually helpful. */
158805
+ useBloomFilter = 1;
158806
+ }
158807
}
158808
}
158809
}
@@ -157968,20 +158836,21 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158836
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
158837
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
158838
VdbeComment((v, "for %s", pTable->zName));
157971
- if( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){
158839
+ if( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) && useBloomFilter ){
158840
+ sqlite3WhereExplainBloomFilter(pParse, pWC->pWInfo, pLevel);
158841
pLevel->regFilter = ++pParse->nMem;
158842
sqlite3VdbeAddOp2(v, OP_Blob, 10000, pLevel->regFilter);
158843
}
158844
158845
/* Fill the automatic index with content */
157977
- pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
157978
- if( pTabItem->fg.viaCoroutine ){
157979
- int regYield = pTabItem->regReturn;
158846
+ assert( pSrc == &pWC->pWInfo->pTabList->a[pLevel->iFrom] );
158847
+ if( pSrc->fg.viaCoroutine ){
158848
+ int regYield = pSrc->regReturn;
158849
addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
157981
- sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
158850
+ sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSrc->addrFillSub);
158851
addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
158852
VdbeCoverage(v);
157984
- VdbeComment((v, "next row of %s", pTabItem->pTab->zName));
158853
+ VdbeComment((v, "next row of %s", pSrc->pTab->zName));
158854
}else{
158855
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
158856
}
@@ -158002,14 +158871,14 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
158871
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
158872
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
158873
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
158005
- if( pTabItem->fg.viaCoroutine ){
158874
+ if( pSrc->fg.viaCoroutine ){
158875
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
158876
testcase( pParse->db->mallocFailed );
158877
assert( pLevel->iIdxCur>0 );
158878
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
158010
- pTabItem->regResult, pLevel->iIdxCur);
158879
+ pSrc->regResult, pLevel->iIdxCur);
158880
sqlite3VdbeGoto(v, addrTop);
158012
- pTabItem->fg.viaCoroutine = 0;
158881
+ pSrc->fg.viaCoroutine = 0;
158882
}else{
158883
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
158884
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
@@ -158072,9 +158941,11 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
158941
158942
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
158943
do{
158944
+ const SrcList *pTabList;
158945
const SrcItem *pItem;
158946
const Table *pTab;
158947
u64 sz;
158948
+ int iSrc;
158949
sqlite3WhereExplainBloomFilter(pParse, pWInfo, pLevel);
158950
addrCont = sqlite3VdbeMakeLabel(pParse);
158951
iCur = pLevel->iTabCur;
@@ -158088,7 +158959,9 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
158959
** testing complicated. By basing the blob size on the value in the
158960
** sqlite_stat1 table, testing is much easier.
158961
*/
158091
- pItem = &pWInfo->pTabList->a[pLevel->iFrom];
158962
+ pTabList = pWInfo->pTabList;
158963
+ iSrc = pLevel->iFrom;
158964
+ pItem = &pTabList->a[iSrc];
158965
assert( pItem!=0 );
158966
pTab = pItem->pTab;
158967
assert( pTab!=0 );
@@ -158105,7 +158978,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
158978
for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
158979
Expr *pExpr = pTerm->pExpr;
158980
if( (pTerm->wtFlags & TERM_VIRTUAL)==0
158108
- && sqlite3ExprIsTableConstraint(pExpr, pItem)
158981
+ && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc)
158982
){
158983
sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
158984
}
@@ -158409,6 +159282,9 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
159282
sqlite3ErrorMsg(pParse, "%s", pVtab->zErrMsg);
159283
}
159284
}
159285
+ if( pTab->u.vtab.p->bAllSchemas ){
159286
+ sqlite3VtabUsesAllSchemas(pParse);
159287
+ }
159288
sqlite3_free(pVtab->zErrMsg);
159289
pVtab->zErrMsg = 0;
159290
return rc;
@@ -158939,7 +159815,7 @@ static int whereRangeScanEst(
159815
UNUSED_PARAMETER(pBuilder);
159816
assert( pLower || pUpper );
159817
#endif
158942
- assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 );
159818
+ assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 || pParse->nErr>0 );
159819
nNew = whereRangeAdjust(pLower, nOut);
159820
nNew = whereRangeAdjust(pUpper, nNew);
159821
@@ -161040,8 +161916,6 @@ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
161916
return pHidden->eDistinct;
161917
}
161918
161043
-#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
161044
- && !defined(SQLITE_OMIT_VIRTUALTABLE)
161919
/*
161920
** Cause the prepared statement that is associated with a call to
161921
** xBestIndex to potentially use all schemas. If the statement being
@@ -161051,9 +161925,7 @@ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
161925
**
161926
** This is used by the (built-in) sqlite_dbpage virtual table.
161927
*/
161054
-SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info *pIdxInfo){
161055
- HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
161056
- Parse *pParse = pHidden->pParse;
161928
+SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(Parse *pParse){
161929
int nDb = pParse->db->nDb;
161930
int i;
161931
for(i=0; i<nDb; i++){
@@ -161065,7 +161937,6 @@ SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info *pIdxInfo){
161937
}
161938
}
161939
}
161068
-#endif
161940
161941
/*
161942
** Add all WhereLoop objects for a table of the join identified by
@@ -162446,6 +163317,13 @@ static void showAllWhereLoops(WhereInfo *pWInfo, WhereClause *pWC){
163317
** at most a single row.
163318
** 4) The table must not be referenced by any part of the query apart
163319
** from its own USING or ON clause.
163320
+** 5) The table must not have an inner-join ON or USING clause if there is
163321
+** a RIGHT JOIN anywhere in the query. Otherwise the ON/USING clause
163322
+** might move from the right side to the left side of the RIGHT JOIN.
163323
+** Note: Due to (2), this condition can only arise if the table is
163324
+** the right-most table of a subquery that was flattened into the
163325
+** main query and that subquery was the right-hand operand of an
163326
+** inner join that held an ON or USING clause.
163327
**
163328
** For example, given:
163329
**
@@ -162471,6 +163349,7 @@ static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
163349
){
163350
int i;
163351
Bitmask tabUsed;
163352
+ int hasRightJoin;
163353
163354
/* Preconditions checked by the caller */
163355
assert( pWInfo->nLevel>=2 );
@@ -162485,6 +163364,7 @@ static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
163364
if( pWInfo->pOrderBy ){
163365
tabUsed |= sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pOrderBy);
163366
}
163367
+ hasRightJoin = (pWInfo->pTabList->a[0].fg.jointype & JT_LTORJ)!=0;
163368
for(i=pWInfo->nLevel-1; i>=1; i--){
163369
WhereTerm *pTerm, *pEnd;
163370
SrcItem *pItem;
@@ -162507,6 +163387,12 @@ static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
163387
break;
163388
}
163389
}
163390
+ if( hasRightJoin
163391
+ && ExprHasProperty(pTerm->pExpr, EP_InnerON)
163392
+ && pTerm->pExpr->w.iJoin==pItem->iCursor
163393
+ ){
163394
+ break; /* restriction (5) */
163395
+ }
163396
}
163397
if( pTerm<pEnd ) continue;
163398
WHERETRACE(0xffffffff, ("-> drop loop %c not used\n", pLoop->cId));
@@ -162906,22 +163792,45 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
163792
}
163793
if( pParse->nErr ) goto whereBeginError;
163794
162909
- /* Special case: WHERE terms that do not refer to any tables in the join
162910
- ** (constant expressions). Evaluate each such term, and jump over all the
162911
- ** generated code if the result is not true.
163795
+ /* The False-WHERE-Term-Bypass optimization:
163796
+ **
163797
+ ** If there are WHERE terms that are false, then no rows will be output,
163798
+ ** so skip over all of the code generated here.
163799
+ **
163800
+ ** Conditions:
163801
+ **
163802
+ ** (1) The WHERE term must not refer to any tables in the join.
163803
+ ** (2) The term must not come from an ON clause on the
163804
+ ** right-hand side of a LEFT or FULL JOIN.
163805
+ ** (3) The term must not come from an ON clause, or there must be
163806
+ ** no RIGHT or FULL OUTER joins in pTabList.
163807
+ ** (4) If the expression contains non-deterministic functions
163808
+ ** that are not within a sub-select. This is not required
163809
+ ** for correctness but rather to preserves SQLite's legacy
163810
+ ** behaviour in the following two cases:
163811
**
162913
- ** Do not do this if the expression contains non-deterministic functions
162914
- ** that are not within a sub-select. This is not strictly required, but
162915
- ** preserves SQLite's legacy behaviour in the following two cases:
163812
+ ** WHERE random()>0; -- eval random() once per row
163813
+ ** WHERE (SELECT random())>0; -- eval random() just once overall
163814
**
162917
- ** FROM ... WHERE random()>0; -- eval random() once per row
162918
- ** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
163815
+ ** Note that the Where term need not be a constant in order for this
163816
+ ** optimization to apply, though it does need to be constant relative to
163817
+ ** the current subquery (condition 1). The term might include variables
163818
+ ** from outer queries so that the value of the term changes from one
163819
+ ** invocation of the current subquery to the next.
163820
*/
163821
for(ii=0; ii<sWLB.pWC->nBase; ii++){
162921
- WhereTerm *pT = &sWLB.pWC->a[ii];
163822
+ WhereTerm *pT = &sWLB.pWC->a[ii]; /* A term of the WHERE clause */
163823
+ Expr *pX; /* The expression of pT */
163824
if( pT->wtFlags & TERM_VIRTUAL ) continue;
162923
- if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
162924
- sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);
163825
+ pX = pT->pExpr;
163826
+ assert( pX!=0 );
163827
+ assert( pT->prereqAll!=0 || !ExprHasProperty(pX, EP_OuterON) );
163828
+ if( pT->prereqAll==0 /* Conditions (1) and (2) */
163829
+ && (nTabList==0 || exprIsDeterministic(pX)) /* Condition (4) */
163830
+ && !(ExprHasProperty(pX, EP_InnerON) /* Condition (3) */
163831
+ && (pTabList->a[0].fg.jointype & JT_LTORJ)!=0 )
163832
+ ){
163833
+ sqlite3ExprIfFalse(pParse, pX, pWInfo->iBreak, SQLITE_JUMPIFNULL);
163834
pT->wtFlags |= TERM_CODED;
163835
}
163836
}
@@ -163164,7 +164073,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
164073
assert( n<=pTab->nCol );
164074
}
164075
#ifdef SQLITE_ENABLE_CURSOR_HINTS
163167
- if( pLoop->u.btree.pIndex!=0 ){
164076
+ if( pLoop->u.btree.pIndex!=0 && (pTab->tabFlags & TF_WithoutRowid)==0 ){
164077
sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ|bFordelete);
164078
}else
164079
#endif
@@ -163301,11 +164210,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
164210
sqlite3VdbeJumpHere(v, iOnce);
164211
}
164212
}
164213
+ assert( pTabList == pWInfo->pTabList );
164214
if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){
164215
if( (wsFlags & WHERE_AUTO_INDEX)!=0 ){
164216
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
163307
- constructAutomaticIndex(pParse, &pWInfo->sWC,
163308
- &pTabList->a[pLevel->iFrom], notReady, pLevel);
164217
+ constructAutomaticIndex(pParse, &pWInfo->sWC, notReady, pLevel);
164218
#endif
164219
}else{
164220
sqlite3ConstructBloomFilter(pWInfo, ii, pLevel, notReady);
@@ -163622,7 +164531,8 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
164531
k = pLevel->addrBody + 1;
164532
#ifdef SQLITE_DEBUG
164533
if( db->flags & SQLITE_VdbeAddopTrace ){
163625
- printf("TRANSLATE opcodes in range %d..%d\n", k, last-1);
164534
+ printf("TRANSLATE cursor %d->%d in opcode range %d..%d\n",
164535
+ pLevel->iTabCur, pLevel->iIdxCur, k, last-1);
164536
}
164537
/* Proof that the "+1" on the k value above is safe */
164538
pOp = sqlite3VdbeGetOp(v, k - 1);
@@ -164497,6 +165407,7 @@ static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
165407
}
165408
/* no break */ deliberate_fall_through
165409
165410
+ case TK_IF_NULL_ROW:
165411
case TK_AGG_FUNCTION:
165412
case TK_COLUMN: {
165413
int iCol = -1;
@@ -167325,18 +168236,18 @@ typedef union {
168236
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
168237
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
168238
#define YYFALLBACK 1
167328
-#define YYNSTATE 580
167329
-#define YYNRULE 405
167330
-#define YYNRULE_WITH_ACTION 342
168239
+#define YYNSTATE 579
168240
+#define YYNRULE 403
168241
+#define YYNRULE_WITH_ACTION 340
168242
#define YYNTOKEN 185
167332
-#define YY_MAX_SHIFT 579
167333
-#define YY_MIN_SHIFTREDUCE 839
167334
-#define YY_MAX_SHIFTREDUCE 1243
167335
-#define YY_ERROR_ACTION 1244
167336
-#define YY_ACCEPT_ACTION 1245
167337
-#define YY_NO_ACTION 1246
167338
-#define YY_MIN_REDUCE 1247
167339
-#define YY_MAX_REDUCE 1651
168243
+#define YY_MAX_SHIFT 578
168244
+#define YY_MIN_SHIFTREDUCE 837
168245
+#define YY_MAX_SHIFTREDUCE 1239
168246
+#define YY_ERROR_ACTION 1240
168247
+#define YY_ACCEPT_ACTION 1241
168248
+#define YY_NO_ACTION 1242
168249
+#define YY_MIN_REDUCE 1243
168250
+#define YY_MAX_REDUCE 1645
168251
/************* End control #defines *******************************************/
168252
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
168253
@@ -167403,219 +168314,218 @@ typedef union {
168314
** yy_default[] Default action for each state.
168315
**
168316
*********** Begin parsing tables **********************************************/
167406
-#define YY_ACTTAB_COUNT (2101)
168317
+#define YY_ACTTAB_COUNT (2096)
168318
static const YYACTIONTYPE yy_action[] = {
168319
/* 0 */ 572, 208, 572, 118, 115, 229, 572, 118, 115, 229,
167409
- /* 10 */ 572, 1318, 381, 1297, 412, 566, 566, 566, 572, 413,
167410
- /* 20 */ 382, 1318, 1280, 41, 41, 41, 41, 208, 1530, 71,
167411
- /* 30 */ 71, 975, 423, 41, 41, 495, 303, 279, 303, 976,
167412
- /* 40 */ 401, 71, 71, 125, 126, 80, 1221, 1221, 1054, 1057,
167413
- /* 50 */ 1044, 1044, 123, 123, 124, 124, 124, 124, 480, 413,
167414
- /* 60 */ 1245, 1, 1, 579, 2, 1249, 554, 118, 115, 229,
167415
- /* 70 */ 317, 484, 146, 484, 528, 118, 115, 229, 533, 1331,
167416
- /* 80 */ 421, 527, 142, 125, 126, 80, 1221, 1221, 1054, 1057,
167417
- /* 90 */ 1044, 1044, 123, 123, 124, 124, 124, 124, 118, 115,
168320
+ /* 10 */ 572, 1314, 381, 1293, 412, 566, 566, 566, 572, 413,
168321
+ /* 20 */ 382, 1314, 1276, 41, 41, 41, 41, 208, 1524, 71,
168322
+ /* 30 */ 71, 973, 423, 41, 41, 495, 303, 279, 303, 974,
168323
+ /* 40 */ 401, 71, 71, 125, 126, 80, 1216, 1216, 1051, 1054,
168324
+ /* 50 */ 1041, 1041, 123, 123, 124, 124, 124, 124, 480, 413,
168325
+ /* 60 */ 1241, 1, 1, 578, 2, 1245, 554, 118, 115, 229,
168326
+ /* 70 */ 317, 484, 146, 484, 528, 118, 115, 229, 533, 1327,
168327
+ /* 80 */ 421, 527, 142, 125, 126, 80, 1216, 1216, 1051, 1054,
168328
+ /* 90 */ 1041, 1041, 123, 123, 124, 124, 124, 124, 118, 115,
168329
/* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120,
168330
/* 110 */ 120, 119, 116, 448, 284, 284, 284, 284, 446, 446,
167420
- /* 120 */ 446, 1571, 380, 1573, 1196, 379, 1167, 569, 1167, 569,
167421
- /* 130 */ 413, 1571, 541, 259, 226, 448, 101, 145, 453, 316,
168331
+ /* 120 */ 446, 1565, 380, 1567, 1192, 379, 1163, 569, 1163, 569,
168332
+ /* 130 */ 413, 1565, 541, 259, 226, 448, 101, 145, 453, 316,
168333
/* 140 */ 563, 240, 122, 122, 122, 122, 121, 121, 120, 120,
167423
- /* 150 */ 120, 119, 116, 448, 125, 126, 80, 1221, 1221, 1054,
167424
- /* 160 */ 1057, 1044, 1044, 123, 123, 124, 124, 124, 124, 142,
167425
- /* 170 */ 294, 1196, 343, 452, 120, 120, 120, 119, 116, 448,
167426
- /* 180 */ 127, 1196, 1197, 1198, 148, 445, 444, 572, 119, 116,
168334
+ /* 150 */ 120, 119, 116, 448, 125, 126, 80, 1216, 1216, 1051,
168335
+ /* 160 */ 1054, 1041, 1041, 123, 123, 124, 124, 124, 124, 142,
168336
+ /* 170 */ 294, 1192, 343, 452, 120, 120, 120, 119, 116, 448,
168337
+ /* 180 */ 127, 1192, 1193, 1192, 148, 445, 444, 572, 119, 116,
168338
/* 190 */ 448, 124, 124, 124, 124, 117, 122, 122, 122, 122,
168339
/* 200 */ 121, 121, 120, 120, 120, 119, 116, 448, 458, 113,
168340
/* 210 */ 13, 13, 550, 122, 122, 122, 122, 121, 121, 120,
167430
- /* 220 */ 120, 120, 119, 116, 448, 426, 316, 563, 1196, 1197,
167431
- /* 230 */ 1198, 149, 1228, 413, 1228, 124, 124, 124, 124, 122,
168341
+ /* 220 */ 120, 120, 119, 116, 448, 426, 316, 563, 1192, 1193,
168342
+ /* 230 */ 1192, 149, 1224, 413, 1224, 124, 124, 124, 124, 122,
168343
/* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116,
167433
- /* 250 */ 448, 469, 346, 1041, 1041, 1055, 1058, 125, 126, 80,
167434
- /* 260 */ 1221, 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124,
167435
- /* 270 */ 124, 124, 1283, 526, 222, 1196, 572, 413, 224, 518,
168344
+ /* 250 */ 448, 469, 346, 1038, 1038, 1052, 1055, 125, 126, 80,
168345
+ /* 260 */ 1216, 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124,
168346
+ /* 270 */ 124, 124, 1279, 526, 222, 1192, 572, 413, 224, 518,
168347
/* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120,
167437
- /* 290 */ 120, 120, 119, 116, 448, 1011, 16, 16, 1196, 133,
167438
- /* 300 */ 133, 125, 126, 80, 1221, 1221, 1054, 1057, 1044, 1044,
168348
+ /* 290 */ 120, 120, 119, 116, 448, 1009, 16, 16, 1192, 133,
168349
+ /* 300 */ 133, 125, 126, 80, 1216, 1216, 1051, 1054, 1041, 1041,
168350
/* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122,
167440
- /* 320 */ 121, 121, 120, 120, 120, 119, 116, 448, 1045, 550,
167441
- /* 330 */ 1196, 377, 1196, 1197, 1198, 252, 1438, 403, 508, 505,
167442
- /* 340 */ 504, 111, 564, 570, 4, 930, 930, 437, 503, 344,
167443
- /* 350 */ 464, 330, 364, 398, 1241, 1196, 1197, 1198, 567, 572,
168351
+ /* 320 */ 121, 121, 120, 120, 120, 119, 116, 448, 1042, 550,
168352
+ /* 330 */ 1192, 377, 1192, 1193, 1192, 252, 1433, 403, 508, 505,
168353
+ /* 340 */ 504, 111, 564, 570, 4, 928, 928, 437, 503, 344,
168354
+ /* 350 */ 464, 330, 364, 398, 1237, 1192, 1193, 1192, 567, 572,
168355
/* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119,
167445
- /* 370 */ 116, 448, 284, 284, 373, 1584, 1611, 445, 444, 154,
167446
- /* 380 */ 413, 449, 71, 71, 1290, 569, 1225, 1196, 1197, 1198,
167447
- /* 390 */ 85, 1227, 271, 561, 547, 519, 1565, 572, 98, 1226,
167448
- /* 400 */ 6, 1282, 476, 142, 125, 126, 80, 1221, 1221, 1054,
167449
- /* 410 */ 1057, 1044, 1044, 123, 123, 124, 124, 124, 124, 554,
167450
- /* 420 */ 13, 13, 1031, 511, 1228, 1196, 1228, 553, 109, 109,
167451
- /* 430 */ 222, 572, 1242, 175, 572, 431, 110, 197, 449, 574,
167452
- /* 440 */ 573, 434, 1556, 1021, 325, 555, 1196, 270, 287, 372,
168356
+ /* 370 */ 116, 448, 284, 284, 373, 1578, 1604, 445, 444, 154,
168357
+ /* 380 */ 413, 449, 71, 71, 1286, 569, 1221, 1192, 1193, 1192,
168358
+ /* 390 */ 85, 1223, 271, 561, 547, 519, 1559, 572, 98, 1222,
168359
+ /* 400 */ 6, 1278, 476, 142, 125, 126, 80, 1216, 1216, 1051,
168360
+ /* 410 */ 1054, 1041, 1041, 123, 123, 124, 124, 124, 124, 554,
168361
+ /* 420 */ 13, 13, 1028, 511, 1224, 1192, 1224, 553, 109, 109,
168362
+ /* 430 */ 222, 572, 1238, 175, 572, 431, 110, 197, 449, 573,
168363
+ /* 440 */ 449, 434, 1550, 1018, 325, 555, 1192, 270, 287, 372,
168364
/* 450 */ 514, 367, 513, 257, 71, 71, 547, 71, 71, 363,
167454
- /* 460 */ 316, 563, 1617, 122, 122, 122, 122, 121, 121, 120,
167455
- /* 470 */ 120, 120, 119, 116, 448, 1021, 1021, 1023, 1024, 27,
167456
- /* 480 */ 284, 284, 1196, 1197, 1198, 1162, 572, 1616, 413, 905,
167457
- /* 490 */ 190, 554, 360, 569, 554, 941, 537, 521, 1162, 520,
167458
- /* 500 */ 417, 1162, 556, 1196, 1197, 1198, 572, 548, 1558, 51,
167459
- /* 510 */ 51, 214, 125, 126, 80, 1221, 1221, 1054, 1057, 1044,
167460
- /* 520 */ 1044, 123, 123, 124, 124, 124, 124, 1196, 478, 135,
167461
- /* 530 */ 135, 413, 284, 284, 1494, 509, 121, 121, 120, 120,
167462
- /* 540 */ 120, 119, 116, 448, 1011, 569, 522, 217, 545, 1565,
167463
- /* 550 */ 316, 563, 142, 6, 536, 125, 126, 80, 1221, 1221,
167464
- /* 560 */ 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124, 124,
167465
- /* 570 */ 1559, 122, 122, 122, 122, 121, 121, 120, 120, 120,
167466
- /* 580 */ 119, 116, 448, 489, 1196, 1197, 1198, 486, 281, 1271,
167467
- /* 590 */ 961, 252, 1196, 377, 508, 505, 504, 1196, 344, 575,
167468
- /* 600 */ 1196, 575, 413, 292, 503, 961, 880, 191, 484, 316,
168365
+ /* 460 */ 316, 563, 1610, 122, 122, 122, 122, 121, 121, 120,
168366
+ /* 470 */ 120, 120, 119, 116, 448, 1018, 1018, 1020, 1021, 27,
168367
+ /* 480 */ 284, 284, 1192, 1193, 1192, 1158, 572, 1609, 413, 903,
168368
+ /* 490 */ 190, 554, 360, 569, 554, 939, 537, 521, 1158, 520,
168369
+ /* 500 */ 417, 1158, 556, 1192, 1193, 1192, 572, 548, 1552, 51,
168370
+ /* 510 */ 51, 214, 125, 126, 80, 1216, 1216, 1051, 1054, 1041,
168371
+ /* 520 */ 1041, 123, 123, 124, 124, 124, 124, 1192, 478, 135,
168372
+ /* 530 */ 135, 413, 284, 284, 1488, 509, 121, 121, 120, 120,
168373
+ /* 540 */ 120, 119, 116, 448, 1009, 569, 522, 217, 545, 1559,
168374
+ /* 550 */ 316, 563, 142, 6, 536, 125, 126, 80, 1216, 1216,
168375
+ /* 560 */ 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124, 124,
168376
+ /* 570 */ 1553, 122, 122, 122, 122, 121, 121, 120, 120, 120,
168377
+ /* 580 */ 119, 116, 448, 489, 1192, 1193, 1192, 486, 281, 1267,
168378
+ /* 590 */ 959, 252, 1192, 377, 508, 505, 504, 1192, 344, 574,
168379
+ /* 600 */ 1192, 574, 413, 292, 503, 959, 878, 191, 484, 316,
168380
/* 610 */ 563, 388, 290, 384, 122, 122, 122, 122, 121, 121,
167470
- /* 620 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1221,
167471
- /* 630 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167472
- /* 640 */ 124, 413, 398, 1140, 1196, 873, 100, 284, 284, 1196,
167473
- /* 650 */ 1197, 1198, 377, 1097, 1196, 1197, 1198, 1196, 1197, 1198,
167474
- /* 660 */ 569, 459, 32, 377, 233, 125, 126, 80, 1221, 1221,
167475
- /* 670 */ 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124, 124,
167476
- /* 680 */ 1437, 963, 572, 228, 962, 122, 122, 122, 122, 121,
167477
- /* 690 */ 121, 120, 120, 120, 119, 116, 448, 1162, 228, 1196,
167478
- /* 700 */ 157, 1196, 1197, 1198, 1557, 13, 13, 301, 961, 1236,
167479
- /* 710 */ 1162, 153, 413, 1162, 377, 1587, 1180, 5, 373, 1584,
167480
- /* 720 */ 433, 1242, 3, 961, 122, 122, 122, 122, 121, 121,
167481
- /* 730 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1221,
167482
- /* 740 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167483
- /* 750 */ 124, 413, 208, 571, 1196, 1032, 1196, 1197, 1198, 1196,
167484
- /* 760 */ 392, 856, 155, 1556, 286, 406, 1102, 1102, 492, 572,
167485
- /* 770 */ 469, 346, 1323, 1323, 1556, 125, 126, 80, 1221, 1221,
167486
- /* 780 */ 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124, 124,
168381
+ /* 620 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1216,
168382
+ /* 630 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168383
+ /* 640 */ 124, 413, 398, 1136, 1192, 871, 100, 284, 284, 1192,
168384
+ /* 650 */ 1193, 1192, 377, 1093, 1192, 1193, 1192, 1192, 1193, 1192,
168385
+ /* 660 */ 569, 459, 32, 377, 233, 125, 126, 80, 1216, 1216,
168386
+ /* 670 */ 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124, 124,
168387
+ /* 680 */ 1432, 961, 572, 228, 960, 122, 122, 122, 122, 121,
168388
+ /* 690 */ 121, 120, 120, 120, 119, 116, 448, 1158, 228, 1192,
168389
+ /* 700 */ 157, 1192, 1193, 1192, 1551, 13, 13, 301, 959, 1232,
168390
+ /* 710 */ 1158, 153, 413, 1158, 377, 1581, 1176, 5, 373, 1578,
168391
+ /* 720 */ 433, 1238, 3, 959, 122, 122, 122, 122, 121, 121,
168392
+ /* 730 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1216,
168393
+ /* 740 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168394
+ /* 750 */ 124, 413, 208, 571, 1192, 1029, 1192, 1193, 1192, 1192,
168395
+ /* 760 */ 392, 854, 155, 1550, 286, 406, 1098, 1098, 492, 572,
168396
+ /* 770 */ 469, 346, 1319, 1319, 1550, 125, 126, 80, 1216, 1216,
168397
+ /* 780 */ 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124, 124,
168398
/* 790 */ 129, 572, 13, 13, 378, 122, 122, 122, 122, 121,
168399
/* 800 */ 121, 120, 120, 120, 119, 116, 448, 302, 572, 457,
167489
- /* 810 */ 532, 1196, 1197, 1198, 13, 13, 1196, 1197, 1198, 1301,
167490
- /* 820 */ 467, 1271, 413, 1321, 1321, 1556, 1016, 457, 456, 200,
167491
- /* 830 */ 299, 71, 71, 1269, 122, 122, 122, 122, 121, 121,
167492
- /* 840 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1221,
167493
- /* 850 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167494
- /* 860 */ 124, 413, 227, 1077, 1162, 284, 284, 423, 312, 278,
167495
- /* 870 */ 278, 285, 285, 1423, 410, 409, 386, 1162, 569, 572,
167496
- /* 880 */ 1162, 1200, 569, 1604, 569, 125, 126, 80, 1221, 1221,
167497
- /* 890 */ 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124, 124,
167498
- /* 900 */ 457, 1486, 13, 13, 1540, 122, 122, 122, 122, 121,
168400
+ /* 810 */ 532, 1192, 1193, 1192, 13, 13, 1192, 1193, 1192, 1297,
168401
+ /* 820 */ 467, 1267, 413, 1317, 1317, 1550, 1014, 457, 456, 200,
168402
+ /* 830 */ 299, 71, 71, 1265, 122, 122, 122, 122, 121, 121,
168403
+ /* 840 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1216,
168404
+ /* 850 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168405
+ /* 860 */ 124, 413, 227, 1073, 1158, 284, 284, 423, 312, 278,
168406
+ /* 870 */ 278, 285, 285, 1419, 410, 409, 386, 1158, 569, 572,
168407
+ /* 880 */ 1158, 1195, 569, 1598, 569, 125, 126, 80, 1216, 1216,
168408
+ /* 890 */ 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124, 124,
168409
+ /* 900 */ 457, 1480, 13, 13, 1534, 122, 122, 122, 122, 121,
168410
/* 910 */ 121, 120, 120, 120, 119, 116, 448, 201, 572, 358,
167500
- /* 920 */ 1590, 579, 2, 1249, 844, 845, 846, 1566, 317, 1216,
167501
- /* 930 */ 146, 6, 413, 255, 254, 253, 206, 1331, 9, 1200,
168411
+ /* 920 */ 1584, 578, 2, 1245, 842, 843, 844, 1560, 317, 1211,
168412
+ /* 930 */ 146, 6, 413, 255, 254, 253, 206, 1327, 9, 1195,
168413
/* 940 */ 262, 71, 71, 428, 122, 122, 122, 122, 121, 121,
167503
- /* 950 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1221,
167504
- /* 960 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167505
- /* 970 */ 124, 572, 284, 284, 572, 1217, 413, 578, 313, 1249,
167506
- /* 980 */ 353, 1300, 356, 423, 317, 569, 146, 495, 529, 1647,
167507
- /* 990 */ 399, 375, 495, 1331, 70, 70, 1299, 71, 71, 240,
167508
- /* 1000 */ 1329, 104, 80, 1221, 1221, 1054, 1057, 1044, 1044, 123,
168414
+ /* 950 */ 120, 120, 120, 119, 116, 448, 125, 126, 80, 1216,
168415
+ /* 960 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168416
+ /* 970 */ 124, 572, 284, 284, 572, 1212, 413, 577, 313, 1245,
168417
+ /* 980 */ 353, 1296, 356, 423, 317, 569, 146, 495, 529, 1641,
168418
+ /* 990 */ 399, 375, 495, 1327, 70, 70, 1295, 71, 71, 240,
168419
+ /* 1000 */ 1325, 104, 80, 1216, 1216, 1051, 1054, 1041, 1041, 123,
168420
/* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121,
167510
- /* 1020 */ 121, 120, 120, 120, 119, 116, 448, 1118, 284, 284,
167511
- /* 1030 */ 432, 452, 1529, 1217, 443, 284, 284, 1493, 1356, 311,
167512
- /* 1040 */ 478, 569, 1119, 975, 495, 495, 217, 1267, 569, 1542,
167513
- /* 1050 */ 572, 976, 207, 572, 1031, 240, 387, 1120, 523, 122,
168421
+ /* 1020 */ 121, 120, 120, 120, 119, 116, 448, 1114, 284, 284,
168422
+ /* 1030 */ 432, 452, 1523, 1212, 443, 284, 284, 1487, 1352, 311,
168423
+ /* 1040 */ 478, 569, 1115, 973, 495, 495, 217, 1263, 569, 1536,
168424
+ /* 1050 */ 572, 974, 207, 572, 1028, 240, 387, 1116, 523, 122,
168425
/* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116,
167515
- /* 1070 */ 448, 1022, 107, 71, 71, 1021, 13, 13, 916, 572,
167516
- /* 1080 */ 1499, 572, 284, 284, 97, 530, 495, 452, 917, 1330,
167517
- /* 1090 */ 1326, 549, 413, 284, 284, 569, 151, 209, 1499, 1501,
167518
- /* 1100 */ 262, 454, 55, 55, 56, 56, 569, 1021, 1021, 1023,
167519
- /* 1110 */ 447, 336, 413, 531, 12, 295, 125, 126, 80, 1221,
167520
- /* 1120 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167521
- /* 1130 */ 124, 351, 413, 868, 1538, 1217, 125, 126, 80, 1221,
167522
- /* 1140 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167523
- /* 1150 */ 124, 1141, 1645, 478, 1645, 375, 125, 114, 80, 1221,
167524
- /* 1160 */ 1221, 1054, 1057, 1044, 1044, 123, 123, 124, 124, 124,
167525
- /* 1170 */ 124, 1499, 333, 478, 335, 122, 122, 122, 122, 121,
167526
- /* 1180 */ 121, 120, 120, 120, 119, 116, 448, 203, 1423, 572,
167527
- /* 1190 */ 1298, 868, 468, 1217, 440, 122, 122, 122, 122, 121,
167528
- /* 1200 */ 121, 120, 120, 120, 119, 116, 448, 557, 1141, 1646,
167529
- /* 1210 */ 543, 1646, 15, 15, 896, 122, 122, 122, 122, 121,
168426
+ /* 1070 */ 448, 1019, 107, 71, 71, 1018, 13, 13, 914, 572,
168427
+ /* 1080 */ 1493, 572, 284, 284, 97, 530, 495, 452, 915, 1326,
168428
+ /* 1090 */ 1322, 549, 413, 284, 284, 569, 151, 209, 1493, 1495,
168429
+ /* 1100 */ 262, 454, 55, 55, 56, 56, 569, 1018, 1018, 1020,
168430
+ /* 1110 */ 447, 336, 413, 531, 12, 295, 125, 126, 80, 1216,
168431
+ /* 1120 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168432
+ /* 1130 */ 124, 351, 413, 866, 1532, 1212, 125, 126, 80, 1216,
168433
+ /* 1140 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168434
+ /* 1150 */ 124, 1137, 1639, 478, 1639, 375, 125, 114, 80, 1216,
168435
+ /* 1160 */ 1216, 1051, 1054, 1041, 1041, 123, 123, 124, 124, 124,
168436
+ /* 1170 */ 124, 1493, 333, 478, 335, 122, 122, 122, 122, 121,
168437
+ /* 1180 */ 121, 120, 120, 120, 119, 116, 448, 203, 1419, 572,
168438
+ /* 1190 */ 1294, 866, 468, 1212, 440, 122, 122, 122, 122, 121,
168439
+ /* 1200 */ 121, 120, 120, 120, 119, 116, 448, 557, 1137, 1640,
168440
+ /* 1210 */ 543, 1640, 15, 15, 894, 122, 122, 122, 122, 121,
168441
/* 1220 */ 121, 120, 120, 120, 119, 116, 448, 572, 298, 542,
167531
- /* 1230 */ 1139, 1423, 1563, 1564, 1335, 413, 6, 6, 1173, 1272,
167532
- /* 1240 */ 419, 320, 284, 284, 1423, 512, 569, 529, 300, 461,
167533
- /* 1250 */ 43, 43, 572, 897, 12, 569, 334, 482, 429, 411,
167534
- /* 1260 */ 126, 80, 1221, 1221, 1054, 1057, 1044, 1044, 123, 123,
167535
- /* 1270 */ 124, 124, 124, 124, 572, 57, 57, 288, 1196, 1423,
167536
- /* 1280 */ 500, 462, 396, 396, 395, 273, 393, 1139, 1562, 853,
167537
- /* 1290 */ 1173, 411, 6, 572, 321, 1162, 474, 44, 44, 1561,
167538
- /* 1300 */ 1118, 430, 234, 6, 323, 256, 544, 256, 1162, 435,
167539
- /* 1310 */ 572, 1162, 322, 17, 491, 1119, 58, 58, 122, 122,
168442
+ /* 1230 */ 1135, 1419, 1557, 1558, 1331, 413, 6, 6, 1169, 1268,
168443
+ /* 1240 */ 419, 320, 284, 284, 1419, 512, 569, 529, 300, 461,
168444
+ /* 1250 */ 43, 43, 572, 895, 12, 569, 334, 482, 429, 411,
168445
+ /* 1260 */ 126, 80, 1216, 1216, 1051, 1054, 1041, 1041, 123, 123,
168446
+ /* 1270 */ 124, 124, 124, 124, 572, 57, 57, 288, 1192, 1419,
168447
+ /* 1280 */ 500, 462, 396, 396, 395, 273, 393, 1135, 1556, 851,
168448
+ /* 1290 */ 1169, 411, 6, 572, 321, 1158, 474, 44, 44, 1555,
168449
+ /* 1300 */ 1114, 430, 234, 6, 323, 256, 544, 256, 1158, 435,
168450
+ /* 1310 */ 572, 1158, 322, 17, 491, 1115, 58, 58, 122, 122,
168451
/* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 448,
167541
- /* 1330 */ 1120, 216, 485, 59, 59, 1196, 1197, 1198, 111, 564,
168452
+ /* 1330 */ 1116, 216, 485, 59, 59, 1192, 1193, 1192, 111, 564,
168453
/* 1340 */ 324, 4, 236, 460, 530, 572, 237, 460, 572, 441,
167543
- /* 1350 */ 168, 560, 424, 141, 483, 567, 572, 293, 572, 1099,
167544
- /* 1360 */ 572, 293, 572, 1099, 535, 572, 876, 8, 60, 60,
168454
+ /* 1350 */ 168, 560, 424, 141, 483, 567, 572, 293, 572, 1095,
168455
+ /* 1360 */ 572, 293, 572, 1095, 535, 572, 874, 8, 60, 60,
168456
/* 1370 */ 235, 61, 61, 572, 418, 572, 418, 572, 449, 62,
168457
/* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49,
168458
/* 1390 */ 561, 572, 363, 572, 100, 490, 50, 50, 63, 63,
167548
- /* 1400 */ 64, 64, 565, 419, 539, 414, 572, 1031, 572, 538,
167549
- /* 1410 */ 316, 563, 316, 563, 65, 65, 14, 14, 572, 1031,
167550
- /* 1420 */ 572, 516, 936, 876, 1022, 109, 109, 935, 1021, 66,
167551
- /* 1430 */ 66, 131, 131, 110, 455, 449, 574, 573, 420, 177,
167552
- /* 1440 */ 1021, 132, 132, 67, 67, 572, 471, 572, 936, 475,
167553
- /* 1450 */ 1368, 283, 226, 935, 315, 1367, 411, 572, 463, 411,
167554
- /* 1460 */ 1021, 1021, 1023, 239, 411, 86, 213, 1354, 52, 52,
167555
- /* 1470 */ 68, 68, 1021, 1021, 1023, 1024, 27, 1589, 1184, 451,
167556
- /* 1480 */ 69, 69, 288, 97, 108, 1545, 106, 396, 396, 395,
167557
- /* 1490 */ 273, 393, 572, 883, 853, 887, 572, 111, 564, 470,
167558
- /* 1500 */ 4, 572, 152, 30, 38, 572, 1136, 234, 400, 323,
168459
+ /* 1400 */ 64, 64, 565, 419, 539, 414, 572, 1028, 572, 538,
168460
+ /* 1410 */ 316, 563, 316, 563, 65, 65, 14, 14, 572, 1028,
168461
+ /* 1420 */ 572, 516, 934, 874, 1019, 109, 109, 933, 1018, 66,
168462
+ /* 1430 */ 66, 131, 131, 110, 455, 449, 573, 449, 420, 177,
168463
+ /* 1440 */ 1018, 132, 132, 67, 67, 572, 471, 572, 934, 475,
168464
+ /* 1450 */ 1364, 283, 226, 933, 315, 1363, 411, 572, 463, 411,
168465
+ /* 1460 */ 1018, 1018, 1020, 239, 411, 86, 213, 1350, 52, 52,
168466
+ /* 1470 */ 68, 68, 1018, 1018, 1020, 1021, 27, 1583, 1180, 451,
168467
+ /* 1480 */ 69, 69, 288, 97, 108, 1539, 106, 396, 396, 395,
168468
+ /* 1490 */ 273, 393, 572, 881, 851, 885, 572, 111, 564, 470,
168469
+ /* 1500 */ 4, 572, 152, 30, 38, 572, 1132, 234, 400, 323,
168470
/* 1510 */ 111, 564, 531, 4, 567, 53, 53, 322, 572, 163,
168471
/* 1520 */ 163, 572, 341, 472, 164, 164, 337, 567, 76, 76,
167561
- /* 1530 */ 572, 289, 1518, 572, 31, 1517, 572, 449, 342, 487,
167562
- /* 1540 */ 100, 54, 54, 348, 72, 72, 296, 236, 1084, 561,
167563
- /* 1550 */ 449, 883, 1364, 134, 134, 168, 73, 73, 141, 161,
167564
- /* 1560 */ 161, 1578, 561, 539, 572, 319, 572, 352, 540, 1013,
167565
- /* 1570 */ 477, 261, 261, 895, 894, 235, 539, 572, 1031, 572,
168472
+ /* 1530 */ 572, 289, 1512, 572, 31, 1511, 572, 449, 342, 487,
168473
+ /* 1540 */ 100, 54, 54, 348, 72, 72, 296, 236, 1080, 561,
168474
+ /* 1550 */ 449, 881, 1360, 134, 134, 168, 73, 73, 141, 161,
168475
+ /* 1560 */ 161, 1572, 561, 539, 572, 319, 572, 352, 540, 1011,
168476
+ /* 1570 */ 477, 261, 261, 893, 892, 235, 539, 572, 1028, 572,
168477
/* 1580 */ 479, 538, 261, 371, 109, 109, 525, 136, 136, 130,
167567
- /* 1590 */ 130, 1031, 110, 370, 449, 574, 573, 109, 109, 1021,
167568
- /* 1600 */ 162, 162, 156, 156, 572, 110, 1084, 449, 574, 573,
167569
- /* 1610 */ 414, 355, 1021, 572, 357, 316, 563, 572, 347, 572,
167570
- /* 1620 */ 100, 501, 361, 258, 100, 902, 903, 140, 140, 359,
167571
- /* 1630 */ 1314, 1021, 1021, 1023, 1024, 27, 139, 139, 366, 455,
167572
- /* 1640 */ 137, 137, 138, 138, 1021, 1021, 1023, 1024, 27, 1184,
167573
- /* 1650 */ 451, 572, 376, 288, 111, 564, 1025, 4, 396, 396,
167574
- /* 1660 */ 395, 273, 393, 572, 1145, 853, 572, 1080, 572, 258,
167575
- /* 1670 */ 496, 567, 572, 211, 75, 75, 559, 966, 234, 261,
167576
- /* 1680 */ 323, 111, 564, 933, 4, 113, 77, 77, 322, 74,
167577
- /* 1690 */ 74, 42, 42, 1377, 449, 48, 48, 1422, 567, 978,
167578
- /* 1700 */ 979, 1096, 1095, 1096, 1095, 866, 561, 150, 934, 1350,
167579
- /* 1710 */ 113, 1362, 558, 1428, 1025, 1279, 1270, 1258, 236, 1257,
167580
- /* 1720 */ 1259, 449, 1597, 1347, 308, 276, 168, 309, 11, 141,
167581
- /* 1730 */ 397, 310, 232, 561, 1409, 1031, 339, 291, 329, 219,
167582
- /* 1740 */ 340, 109, 109, 940, 297, 1414, 235, 345, 481, 110,
167583
- /* 1750 */ 506, 449, 574, 573, 332, 1413, 1021, 404, 1297, 369,
167584
- /* 1760 */ 223, 1490, 1031, 1489, 1359, 1360, 1358, 1357, 109, 109,
167585
- /* 1770 */ 204, 1600, 1236, 562, 265, 218, 110, 205, 449, 574,
167586
- /* 1780 */ 573, 414, 391, 1021, 1537, 179, 316, 563, 1021, 1021,
167587
- /* 1790 */ 1023, 1024, 27, 230, 1535, 1233, 79, 564, 85, 4,
167588
- /* 1800 */ 422, 215, 552, 81, 84, 188, 1410, 128, 1404, 550,
167589
- /* 1810 */ 455, 35, 328, 567, 173, 1021, 1021, 1023, 1024, 27,
167590
- /* 1820 */ 181, 1495, 1397, 331, 465, 183, 184, 185, 186, 466,
167591
- /* 1830 */ 499, 242, 98, 402, 1416, 1418, 449, 1415, 473, 36,
167592
- /* 1840 */ 192, 488, 405, 1506, 246, 91, 494, 196, 561, 1484,
167593
- /* 1850 */ 350, 497, 277, 354, 248, 249, 111, 564, 1260, 4,
167594
- /* 1860 */ 250, 407, 515, 436, 1317, 1308, 93, 1316, 1315, 887,
167595
- /* 1870 */ 1307, 224, 1583, 567, 438, 524, 439, 1031, 263, 264,
167596
- /* 1880 */ 442, 1615, 10, 109, 109, 1287, 408, 1614, 1286, 368,
167597
- /* 1890 */ 1285, 110, 1613, 449, 574, 573, 449, 306, 1021, 307,
167598
- /* 1900 */ 374, 1382, 1569, 1470, 1381, 385, 105, 314, 561, 99,
167599
- /* 1910 */ 1568, 534, 34, 576, 1190, 272, 1340, 551, 383, 274,
167600
- /* 1920 */ 1339, 210, 389, 390, 275, 577, 1255, 1250, 415, 165,
167601
- /* 1930 */ 1021, 1021, 1023, 1024, 27, 147, 1522, 1031, 166, 1523,
167602
- /* 1940 */ 416, 1521, 178, 109, 109, 1520, 304, 167, 840, 450,
167603
- /* 1950 */ 220, 110, 221, 449, 574, 573, 212, 78, 1021, 318,
167604
- /* 1960 */ 231, 1094, 1092, 144, 180, 326, 169, 1216, 241, 182,
167605
- /* 1970 */ 919, 338, 238, 1108, 187, 170, 171, 425, 427, 189,
167606
- /* 1980 */ 87, 88, 89, 90, 172, 1111, 243, 1107, 244, 158,
167607
- /* 1990 */ 1021, 1021, 1023, 1024, 27, 18, 245, 1230, 493, 349,
167608
- /* 2000 */ 1100, 261, 247, 193, 194, 37, 370, 855, 498, 251,
167609
- /* 2010 */ 195, 510, 92, 19, 174, 362, 502, 20, 507, 885,
167610
- /* 2020 */ 365, 898, 94, 305, 159, 95, 517, 96, 1178, 160,
167611
- /* 2030 */ 1060, 1147, 39, 1146, 225, 280, 282, 970, 198, 964,
167612
- /* 2040 */ 113, 1164, 1168, 260, 1166, 21, 1172, 7, 22, 1152,
167613
- /* 2050 */ 33, 23, 24, 25, 1171, 546, 26, 202, 100, 102,
167614
- /* 2060 */ 1075, 103, 1061, 1059, 1063, 1117, 1064, 1116, 266, 267,
167615
- /* 2070 */ 28, 40, 929, 1026, 867, 112, 29, 568, 394, 143,
167616
- /* 2080 */ 1186, 268, 176, 1185, 269, 1246, 1246, 1246, 1246, 1246,
167617
- /* 2090 */ 1246, 1246, 1246, 1246, 1246, 1606, 1246, 1246, 1246, 1246,
167618
- /* 2100 */ 1605,
168478
+ /* 1590 */ 130, 1028, 110, 370, 449, 573, 449, 109, 109, 1018,
168479
+ /* 1600 */ 162, 162, 156, 156, 572, 110, 1080, 449, 573, 449,
168480
+ /* 1610 */ 414, 355, 1018, 572, 357, 316, 563, 572, 347, 572,
168481
+ /* 1620 */ 100, 501, 361, 258, 100, 900, 901, 140, 140, 359,
168482
+ /* 1630 */ 1310, 1018, 1018, 1020, 1021, 27, 139, 139, 366, 455,
168483
+ /* 1640 */ 137, 137, 138, 138, 1018, 1018, 1020, 1021, 27, 1180,
168484
+ /* 1650 */ 451, 572, 376, 288, 111, 564, 1022, 4, 396, 396,
168485
+ /* 1660 */ 395, 273, 393, 572, 1141, 851, 572, 1076, 572, 258,
168486
+ /* 1670 */ 496, 567, 572, 211, 75, 75, 559, 964, 234, 261,
168487
+ /* 1680 */ 323, 111, 564, 931, 4, 113, 77, 77, 322, 74,
168488
+ /* 1690 */ 74, 42, 42, 1373, 449, 48, 48, 1418, 567, 976,
168489
+ /* 1700 */ 977, 1092, 1091, 1092, 1091, 864, 561, 150, 932, 1346,
168490
+ /* 1710 */ 113, 1358, 558, 1423, 1022, 1275, 1266, 1254, 236, 1253,
168491
+ /* 1720 */ 1255, 449, 1591, 1343, 308, 276, 168, 309, 11, 141,
168492
+ /* 1730 */ 397, 310, 232, 561, 1405, 1028, 339, 291, 329, 219,
168493
+ /* 1740 */ 340, 109, 109, 938, 297, 1410, 235, 345, 481, 110,
168494
+ /* 1750 */ 506, 449, 573, 449, 332, 1409, 1018, 404, 1293, 369,
168495
+ /* 1760 */ 223, 1484, 1028, 1483, 1355, 1356, 1354, 1353, 109, 109,
168496
+ /* 1770 */ 204, 1594, 1232, 562, 265, 218, 110, 205, 449, 573,
168497
+ /* 1780 */ 449, 414, 391, 1018, 1531, 179, 316, 563, 1018, 1018,
168498
+ /* 1790 */ 1020, 1021, 27, 230, 1529, 1229, 79, 564, 85, 4,
168499
+ /* 1800 */ 422, 215, 552, 81, 84, 188, 1406, 128, 1400, 550,
168500
+ /* 1810 */ 455, 35, 328, 567, 173, 1018, 1018, 1020, 1021, 27,
168501
+ /* 1820 */ 181, 1489, 1393, 331, 465, 183, 184, 185, 186, 466,
168502
+ /* 1830 */ 499, 242, 98, 402, 1412, 1414, 449, 1411, 473, 36,
168503
+ /* 1840 */ 192, 488, 405, 1500, 246, 91, 494, 196, 561, 1478,
168504
+ /* 1850 */ 350, 497, 277, 354, 248, 249, 111, 564, 1256, 4,
168505
+ /* 1860 */ 250, 407, 515, 436, 1313, 1304, 93, 1312, 1311, 885,
168506
+ /* 1870 */ 1303, 224, 1577, 567, 438, 524, 439, 1028, 263, 264,
168507
+ /* 1880 */ 442, 1608, 10, 109, 109, 1283, 408, 1607, 1282, 368,
168508
+ /* 1890 */ 1281, 110, 1606, 449, 573, 449, 449, 306, 1018, 307,
168509
+ /* 1900 */ 374, 1378, 1563, 1465, 1377, 385, 105, 314, 561, 99,
168510
+ /* 1910 */ 1562, 534, 34, 575, 1186, 272, 1336, 551, 383, 274,
168511
+ /* 1920 */ 1335, 210, 389, 390, 275, 576, 1251, 1246, 415, 165,
168512
+ /* 1930 */ 1018, 1018, 1020, 1021, 27, 147, 1516, 1028, 166, 1517,
168513
+ /* 1940 */ 416, 1515, 178, 109, 109, 1514, 304, 167, 838, 450,
168514
+ /* 1950 */ 220, 110, 221, 449, 573, 449, 212, 78, 1018, 318,
168515
+ /* 1960 */ 231, 1090, 1088, 144, 180, 326, 169, 1211, 241, 182,
168516
+ /* 1970 */ 917, 338, 238, 1104, 187, 170, 171, 425, 427, 189,
168517
+ /* 1980 */ 87, 88, 89, 90, 172, 1107, 243, 1103, 244, 158,
168518
+ /* 1990 */ 1018, 1018, 1020, 1021, 27, 18, 245, 1226, 493, 349,
168519
+ /* 2000 */ 1096, 261, 247, 193, 194, 37, 370, 853, 498, 251,
168520
+ /* 2010 */ 195, 510, 92, 19, 174, 362, 502, 20, 507, 883,
168521
+ /* 2020 */ 365, 896, 94, 305, 159, 95, 517, 96, 1174, 160,
168522
+ /* 2030 */ 1057, 1143, 39, 1142, 225, 280, 282, 968, 198, 962,
168523
+ /* 2040 */ 113, 1160, 1164, 260, 1162, 21, 1168, 7, 22, 1148,
168524
+ /* 2050 */ 33, 23, 24, 25, 1167, 546, 26, 202, 100, 102,
168525
+ /* 2060 */ 1071, 103, 1058, 1056, 1060, 1113, 1061, 1112, 266, 267,
168526
+ /* 2070 */ 28, 40, 927, 1023, 865, 112, 29, 568, 394, 143,
168527
+ /* 2080 */ 1182, 268, 176, 1181, 269, 1242, 1242, 1242, 1242, 1242,
168528
+ /* 2090 */ 1242, 1242, 1242, 1242, 1242, 1599,
168529
};
168530
static const YYCODETYPE yy_lookahead[] = {
168531
/* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276,
@@ -167828,7 +168738,7 @@ static const YYCODETYPE yy_lookahead[] = {
168738
/* 2070 */ 22, 22, 135, 23, 23, 22, 22, 25, 15, 23,
168739
/* 2080 */ 1, 141, 25, 1, 141, 319, 319, 319, 319, 319,
168740
/* 2090 */ 319, 319, 319, 319, 319, 141, 319, 319, 319, 319,
167831
- /* 2100 */ 141, 319, 319, 319, 319, 319, 319, 319, 319, 319,
168741
+ /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
168742
/* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
168743
/* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
168744
/* 2130 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
@@ -167846,9 +168756,9 @@ static const YYCODETYPE yy_lookahead[] = {
168756
/* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
168757
/* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
168758
/* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
167849
- /* 2280 */ 319, 319, 319, 319, 319, 319,
168759
+ /* 2280 */ 319,
168760
};
167851
-#define YY_SHIFT_COUNT (579)
168761
+#define YY_SHIFT_COUNT (578)
168762
#define YY_SHIFT_MIN (0)
168763
#define YY_SHIFT_MAX (2082)
168764
static const unsigned short int yy_shift_ofst[] = {
@@ -167868,12 +168778,12 @@ static const unsigned short int yy_shift_ofst[] = {
168778
/* 130 */ 137, 181, 181, 181, 181, 181, 181, 181, 94, 430,
168779
/* 140 */ 66, 65, 112, 366, 533, 533, 740, 1261, 533, 533,
168780
/* 150 */ 79, 79, 533, 412, 412, 412, 77, 412, 123, 113,
167871
- /* 160 */ 113, 22, 22, 2101, 2101, 328, 328, 328, 239, 468,
168781
+ /* 160 */ 113, 22, 22, 2096, 2096, 328, 328, 328, 239, 468,
168782
/* 170 */ 468, 468, 468, 1015, 1015, 409, 366, 1129, 1186, 533,
168783
/* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533,
168784
/* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 969,
168785
/* 200 */ 621, 621, 533, 642, 788, 788, 1228, 1228, 822, 822,
167876
- /* 210 */ 67, 1274, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 1307,
168786
+ /* 210 */ 67, 1274, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 1307,
168787
/* 220 */ 954, 954, 585, 472, 640, 387, 695, 538, 541, 700,
168788
/* 230 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533,
168789
/* 240 */ 222, 533, 533, 533, 533, 533, 533, 533, 533, 533,
@@ -167891,9 +168801,9 @@ static const unsigned short int yy_shift_ofst[] = {
168801
/* 360 */ 1747, 1747, 1747, 1799, 1844, 1844, 1825, 1747, 1743, 1747,
168802
/* 370 */ 1799, 1747, 1747, 1706, 1850, 1763, 1763, 1825, 1633, 1788,
168803
/* 380 */ 1788, 1798, 1798, 1659, 1664, 1860, 1633, 1748, 1659, 1762,
167894
- /* 390 */ 1765, 1683, 1887, 1901, 1901, 1918, 1918, 1918, 2101, 2101,
167895
- /* 400 */ 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101,
167896
- /* 410 */ 2101, 2101, 2101, 207, 1095, 331, 620, 903, 806, 1074,
168804
+ /* 390 */ 1765, 1683, 1887, 1901, 1901, 1918, 1918, 1918, 2096, 2096,
168805
+ /* 400 */ 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096,
168806
+ /* 410 */ 2096, 2096, 2096, 207, 1095, 331, 620, 903, 806, 1074,
168807
/* 420 */ 1483, 1432, 1481, 1322, 1370, 1394, 1515, 1291, 1546, 1547,
168808
/* 430 */ 1557, 1595, 1598, 1599, 1434, 1453, 1618, 1462, 1567, 1489,
168809
/* 440 */ 1644, 1654, 1616, 1660, 1548, 1549, 1682, 1685, 1597, 742,
@@ -167909,7 +168819,7 @@ static const unsigned short int yy_shift_ofst[] = {
168819
/* 540 */ 1958, 2003, 1971, 1961, 2019, 2026, 2028, 2031, 2032, 2033,
168820
/* 550 */ 2022, 1917, 1919, 2037, 2015, 2039, 2040, 2041, 2042, 2043,
168821
/* 560 */ 2044, 2047, 2055, 2048, 2049, 2050, 2051, 2053, 2054, 2052,
167912
- /* 570 */ 1937, 1940, 1943, 1954, 1959, 2057, 2056, 2063, 2079, 2082,
168822
+ /* 570 */ 1937, 1940, 1943, 1954, 2057, 2056, 2063, 2079, 2082,
168823
};
168824
#define YY_REDUCE_COUNT (412)
168825
#define YY_REDUCE_MIN (-271)
@@ -167959,64 +168869,64 @@ static const short yy_reduce_ofst[] = {
168869
/* 410 */ 1738, 1744, 1740,
168870
};
168871
static const YYACTIONTYPE yy_default[] = {
167962
- /* 0 */ 1651, 1651, 1651, 1479, 1244, 1355, 1244, 1244, 1244, 1479,
167963
- /* 10 */ 1479, 1479, 1244, 1385, 1385, 1532, 1277, 1244, 1244, 1244,
167964
- /* 20 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1478, 1244, 1244,
167965
- /* 30 */ 1244, 1244, 1567, 1567, 1244, 1244, 1244, 1244, 1244, 1244,
167966
- /* 40 */ 1244, 1244, 1394, 1244, 1401, 1244, 1244, 1244, 1244, 1244,
167967
- /* 50 */ 1480, 1481, 1244, 1244, 1244, 1531, 1533, 1496, 1408, 1407,
167968
- /* 60 */ 1406, 1405, 1514, 1373, 1399, 1392, 1396, 1474, 1475, 1473,
167969
- /* 70 */ 1477, 1481, 1480, 1244, 1395, 1442, 1458, 1441, 1244, 1244,
167970
- /* 80 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167971
- /* 90 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167972
- /* 100 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167973
- /* 110 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167974
- /* 120 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167975
- /* 130 */ 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443, 1445,
167976
- /* 140 */ 1446, 1244, 1244, 1268, 1244, 1244, 1265, 1319, 1244, 1244,
167977
- /* 150 */ 1244, 1244, 1244, 1551, 1550, 1244, 1447, 1244, 1277, 1436,
167978
- /* 160 */ 1435, 1461, 1448, 1460, 1459, 1539, 1603, 1602, 1497, 1244,
167979
- /* 170 */ 1244, 1244, 1244, 1244, 1244, 1567, 1244, 1244, 1244, 1244,
167980
- /* 180 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167981
- /* 190 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1375,
167982
- /* 200 */ 1567, 1567, 1244, 1277, 1567, 1567, 1376, 1376, 1273, 1273,
167983
- /* 210 */ 1379, 1244, 1546, 1346, 1346, 1346, 1346, 1355, 1346, 1244,
167984
- /* 220 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167985
- /* 230 */ 1244, 1244, 1244, 1244, 1536, 1534, 1244, 1244, 1244, 1244,
167986
- /* 240 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167987
- /* 250 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
167988
- /* 260 */ 1244, 1244, 1244, 1351, 1244, 1244, 1244, 1244, 1244, 1244,
167989
- /* 270 */ 1244, 1244, 1244, 1244, 1244, 1596, 1244, 1509, 1333, 1351,
167990
- /* 280 */ 1351, 1351, 1351, 1353, 1334, 1332, 1345, 1278, 1251, 1643,
167991
- /* 290 */ 1411, 1400, 1352, 1400, 1640, 1398, 1411, 1411, 1398, 1411,
167992
- /* 300 */ 1352, 1640, 1294, 1619, 1289, 1385, 1385, 1385, 1375, 1375,
167993
- /* 310 */ 1375, 1375, 1379, 1379, 1476, 1352, 1345, 1244, 1643, 1643,
167994
- /* 320 */ 1361, 1361, 1642, 1642, 1361, 1497, 1627, 1420, 1393, 1379,
167995
- /* 330 */ 1322, 1393, 1379, 1328, 1328, 1328, 1328, 1361, 1262, 1398,
167996
- /* 340 */ 1627, 1627, 1398, 1420, 1322, 1398, 1322, 1398, 1361, 1262,
167997
- /* 350 */ 1513, 1637, 1361, 1262, 1487, 1361, 1262, 1361, 1262, 1487,
167998
- /* 360 */ 1320, 1320, 1320, 1309, 1244, 1244, 1487, 1320, 1294, 1320,
167999
- /* 370 */ 1309, 1320, 1320, 1585, 1244, 1491, 1491, 1487, 1361, 1577,
168000
- /* 380 */ 1577, 1388, 1388, 1393, 1379, 1482, 1361, 1244, 1393, 1391,
168001
- /* 390 */ 1389, 1398, 1312, 1599, 1599, 1595, 1595, 1595, 1648, 1648,
168002
- /* 400 */ 1546, 1612, 1277, 1277, 1277, 1277, 1612, 1296, 1296, 1278,
168003
- /* 410 */ 1278, 1277, 1612, 1244, 1244, 1244, 1244, 1244, 1244, 1607,
168004
- /* 420 */ 1244, 1541, 1498, 1365, 1244, 1244, 1244, 1244, 1244, 1244,
168005
- /* 430 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1552, 1244,
168006
- /* 440 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1425,
168007
- /* 450 */ 1244, 1247, 1543, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
168008
- /* 460 */ 1244, 1402, 1403, 1366, 1244, 1244, 1244, 1244, 1244, 1244,
168009
- /* 470 */ 1244, 1417, 1244, 1244, 1244, 1412, 1244, 1244, 1244, 1244,
168010
- /* 480 */ 1244, 1244, 1244, 1244, 1639, 1244, 1244, 1244, 1244, 1244,
168011
- /* 490 */ 1244, 1512, 1511, 1244, 1244, 1363, 1244, 1244, 1244, 1244,
168012
- /* 500 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1292,
168013
- /* 510 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
168014
- /* 520 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244,
168015
- /* 530 */ 1244, 1244, 1244, 1390, 1244, 1244, 1244, 1244, 1244, 1244,
168016
- /* 540 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1582, 1380,
168017
- /* 550 */ 1244, 1244, 1244, 1244, 1630, 1244, 1244, 1244, 1244, 1244,
168018
- /* 560 */ 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1623,
168019
- /* 570 */ 1336, 1427, 1244, 1426, 1430, 1266, 1244, 1256, 1244, 1244,
168872
+ /* 0 */ 1645, 1645, 1645, 1473, 1240, 1351, 1240, 1240, 1240, 1473,
168873
+ /* 10 */ 1473, 1473, 1240, 1381, 1381, 1526, 1273, 1240, 1240, 1240,
168874
+ /* 20 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1472, 1240, 1240,
168875
+ /* 30 */ 1240, 1240, 1561, 1561, 1240, 1240, 1240, 1240, 1240, 1240,
168876
+ /* 40 */ 1240, 1240, 1390, 1240, 1397, 1240, 1240, 1240, 1240, 1240,
168877
+ /* 50 */ 1474, 1475, 1240, 1240, 1240, 1525, 1527, 1490, 1404, 1403,
168878
+ /* 60 */ 1402, 1401, 1508, 1369, 1395, 1388, 1392, 1469, 1470, 1468,
168879
+ /* 70 */ 1623, 1475, 1474, 1240, 1391, 1437, 1453, 1436, 1240, 1240,
168880
+ /* 80 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168881
+ /* 90 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168882
+ /* 100 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168883
+ /* 110 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168884
+ /* 120 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168885
+ /* 130 */ 1445, 1452, 1451, 1450, 1459, 1449, 1446, 1439, 1438, 1440,
168886
+ /* 140 */ 1441, 1240, 1240, 1264, 1240, 1240, 1261, 1315, 1240, 1240,
168887
+ /* 150 */ 1240, 1240, 1240, 1545, 1544, 1240, 1442, 1240, 1273, 1431,
168888
+ /* 160 */ 1430, 1456, 1443, 1455, 1454, 1533, 1597, 1596, 1491, 1240,
168889
+ /* 170 */ 1240, 1240, 1240, 1240, 1240, 1561, 1240, 1240, 1240, 1240,
168890
+ /* 180 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168891
+ /* 190 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1371,
168892
+ /* 200 */ 1561, 1561, 1240, 1273, 1561, 1561, 1372, 1372, 1269, 1269,
168893
+ /* 210 */ 1375, 1240, 1540, 1342, 1342, 1342, 1342, 1351, 1342, 1240,
168894
+ /* 220 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168895
+ /* 230 */ 1240, 1240, 1240, 1240, 1530, 1528, 1240, 1240, 1240, 1240,
168896
+ /* 240 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168897
+ /* 250 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168898
+ /* 260 */ 1240, 1240, 1240, 1347, 1240, 1240, 1240, 1240, 1240, 1240,
168899
+ /* 270 */ 1240, 1240, 1240, 1240, 1240, 1590, 1240, 1503, 1329, 1347,
168900
+ /* 280 */ 1347, 1347, 1347, 1349, 1330, 1328, 1341, 1274, 1247, 1637,
168901
+ /* 290 */ 1407, 1396, 1348, 1396, 1634, 1394, 1407, 1407, 1394, 1407,
168902
+ /* 300 */ 1348, 1634, 1290, 1612, 1285, 1381, 1381, 1381, 1371, 1371,
168903
+ /* 310 */ 1371, 1371, 1375, 1375, 1471, 1348, 1341, 1240, 1637, 1637,
168904
+ /* 320 */ 1357, 1357, 1636, 1636, 1357, 1491, 1620, 1416, 1389, 1375,
168905
+ /* 330 */ 1318, 1389, 1375, 1324, 1324, 1324, 1324, 1357, 1258, 1394,
168906
+ /* 340 */ 1620, 1620, 1394, 1416, 1318, 1394, 1318, 1394, 1357, 1258,
168907
+ /* 350 */ 1507, 1631, 1357, 1258, 1481, 1357, 1258, 1357, 1258, 1481,
168908
+ /* 360 */ 1316, 1316, 1316, 1305, 1240, 1240, 1481, 1316, 1290, 1316,
168909
+ /* 370 */ 1305, 1316, 1316, 1579, 1240, 1485, 1485, 1481, 1357, 1571,
168910
+ /* 380 */ 1571, 1384, 1384, 1389, 1375, 1476, 1357, 1240, 1389, 1387,
168911
+ /* 390 */ 1385, 1394, 1308, 1593, 1593, 1589, 1589, 1589, 1642, 1642,
168912
+ /* 400 */ 1540, 1605, 1273, 1273, 1273, 1273, 1605, 1292, 1292, 1274,
168913
+ /* 410 */ 1274, 1273, 1605, 1240, 1240, 1240, 1240, 1240, 1240, 1600,
168914
+ /* 420 */ 1240, 1535, 1492, 1361, 1240, 1240, 1240, 1240, 1240, 1240,
168915
+ /* 430 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1546, 1240,
168916
+ /* 440 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1421,
168917
+ /* 450 */ 1240, 1243, 1537, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168918
+ /* 460 */ 1240, 1398, 1399, 1362, 1240, 1240, 1240, 1240, 1240, 1240,
168919
+ /* 470 */ 1240, 1413, 1240, 1240, 1240, 1408, 1240, 1240, 1240, 1240,
168920
+ /* 480 */ 1240, 1240, 1240, 1240, 1633, 1240, 1240, 1240, 1240, 1240,
168921
+ /* 490 */ 1240, 1506, 1505, 1240, 1240, 1359, 1240, 1240, 1240, 1240,
168922
+ /* 500 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1288,
168923
+ /* 510 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168924
+ /* 520 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
168925
+ /* 530 */ 1240, 1240, 1240, 1386, 1240, 1240, 1240, 1240, 1240, 1240,
168926
+ /* 540 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1576, 1376,
168927
+ /* 550 */ 1240, 1240, 1240, 1240, 1624, 1240, 1240, 1240, 1240, 1240,
168928
+ /* 560 */ 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1616,
168929
+ /* 570 */ 1332, 1422, 1240, 1425, 1262, 1240, 1252, 1240, 1240,
168930
};
168931
/********** End of lemon-generated parsing tables *****************************/
168932
@@ -168813,233 +169723,231 @@ static const char *const yyRuleName[] = {
169723
/* 175 */ "idlist ::= idlist COMMA nm",
169724
/* 176 */ "idlist ::= nm",
169725
/* 177 */ "expr ::= LP expr RP",
168816
- /* 178 */ "expr ::= ID|INDEXED",
168817
- /* 179 */ "expr ::= JOIN_KW",
168818
- /* 180 */ "expr ::= nm DOT nm",
168819
- /* 181 */ "expr ::= nm DOT nm DOT nm",
168820
- /* 182 */ "term ::= NULL|FLOAT|BLOB",
168821
- /* 183 */ "term ::= STRING",
168822
- /* 184 */ "term ::= INTEGER",
168823
- /* 185 */ "expr ::= VARIABLE",
168824
- /* 186 */ "expr ::= expr COLLATE ID|STRING",
168825
- /* 187 */ "expr ::= CAST LP expr AS typetoken RP",
168826
- /* 188 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
168827
- /* 189 */ "expr ::= ID|INDEXED LP STAR RP",
168828
- /* 190 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over",
168829
- /* 191 */ "expr ::= ID|INDEXED LP STAR RP filter_over",
168830
- /* 192 */ "term ::= CTIME_KW",
168831
- /* 193 */ "expr ::= LP nexprlist COMMA expr RP",
168832
- /* 194 */ "expr ::= expr AND expr",
168833
- /* 195 */ "expr ::= expr OR expr",
168834
- /* 196 */ "expr ::= expr LT|GT|GE|LE expr",
168835
- /* 197 */ "expr ::= expr EQ|NE expr",
168836
- /* 198 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
168837
- /* 199 */ "expr ::= expr PLUS|MINUS expr",
168838
- /* 200 */ "expr ::= expr STAR|SLASH|REM expr",
168839
- /* 201 */ "expr ::= expr CONCAT expr",
168840
- /* 202 */ "likeop ::= NOT LIKE_KW|MATCH",
168841
- /* 203 */ "expr ::= expr likeop expr",
168842
- /* 204 */ "expr ::= expr likeop expr ESCAPE expr",
168843
- /* 205 */ "expr ::= expr ISNULL|NOTNULL",
168844
- /* 206 */ "expr ::= expr NOT NULL",
168845
- /* 207 */ "expr ::= expr IS expr",
168846
- /* 208 */ "expr ::= expr IS NOT expr",
168847
- /* 209 */ "expr ::= expr IS NOT DISTINCT FROM expr",
168848
- /* 210 */ "expr ::= expr IS DISTINCT FROM expr",
168849
- /* 211 */ "expr ::= NOT expr",
168850
- /* 212 */ "expr ::= BITNOT expr",
168851
- /* 213 */ "expr ::= PLUS|MINUS expr",
168852
- /* 214 */ "expr ::= expr PTR expr",
168853
- /* 215 */ "between_op ::= BETWEEN",
168854
- /* 216 */ "between_op ::= NOT BETWEEN",
168855
- /* 217 */ "expr ::= expr between_op expr AND expr",
168856
- /* 218 */ "in_op ::= IN",
168857
- /* 219 */ "in_op ::= NOT IN",
168858
- /* 220 */ "expr ::= expr in_op LP exprlist RP",
168859
- /* 221 */ "expr ::= LP select RP",
168860
- /* 222 */ "expr ::= expr in_op LP select RP",
168861
- /* 223 */ "expr ::= expr in_op nm dbnm paren_exprlist",
168862
- /* 224 */ "expr ::= EXISTS LP select RP",
168863
- /* 225 */ "expr ::= CASE case_operand case_exprlist case_else END",
168864
- /* 226 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
168865
- /* 227 */ "case_exprlist ::= WHEN expr THEN expr",
168866
- /* 228 */ "case_else ::= ELSE expr",
168867
- /* 229 */ "case_else ::=",
168868
- /* 230 */ "case_operand ::= expr",
168869
- /* 231 */ "case_operand ::=",
168870
- /* 232 */ "exprlist ::=",
168871
- /* 233 */ "nexprlist ::= nexprlist COMMA expr",
This file is too large to show in full.
database/sqlite/sqlite3.h
+150
-52
@@ -146,9 +146,9 @@ extern "C" {
146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
** [sqlite_version()] and [sqlite_source_id()].
148
*/
149
-#define SQLITE_VERSION "3.41.2"
150
-#define SQLITE_VERSION_NUMBER 3041002
151
-#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da"
149
+#define SQLITE_VERSION "3.42.0"
150
+#define SQLITE_VERSION_NUMBER 3042000
151
+#define SQLITE_SOURCE_ID "2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0"
152
153
/*
154
** CAPI3REF: Run-Time Library Version Numbers
@@ -1655,20 +1655,23 @@ SQLITE_API int sqlite3_os_end(void);
1655
** must ensure that no other SQLite interfaces are invoked by other
1656
** threads while sqlite3_config() is running.</b>
1657
**
1658
-** The sqlite3_config() interface
1659
-** may only be invoked prior to library initialization using
1660
-** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1661
-** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1662
-** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1663
-** Note, however, that ^sqlite3_config() can be called as part of the
1664
-** implementation of an application-defined [sqlite3_os_init()].
1665
-**
1658
** The first argument to sqlite3_config() is an integer
1659
** [configuration option] that determines
1660
** what property of SQLite is to be configured. Subsequent arguments
1661
** vary depending on the [configuration option]
1662
** in the first argument.
1663
**
1664
+** For most configuration options, the sqlite3_config() interface
1665
+** may only be invoked prior to library initialization using
1666
+** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1667
+** The exceptional configuration options that may be invoked at any time
1668
+** are called "anytime configuration options".
1669
+** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1670
+** [sqlite3_shutdown()] with a first argument that is not an anytime
1671
+** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
1672
+** Note, however, that ^sqlite3_config() can be called as part of the
1673
+** implementation of an application-defined [sqlite3_os_init()].
1674
+**
1675
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1676
** ^If the option is unknown or SQLite is unable to set the option
1677
** then this routine returns a non-zero [error code].
@@ -1776,6 +1779,23 @@ struct sqlite3_mem_methods {
1779
** These constants are the available integer configuration options that
1780
** can be passed as the first argument to the [sqlite3_config()] interface.
1781
**
1782
+** Most of the configuration options for sqlite3_config()
1783
+** will only work if invoked prior to [sqlite3_initialize()] or after
1784
+** [sqlite3_shutdown()]. The few exceptions to this rule are called
1785
+** "anytime configuration options".
1786
+** ^Calling [sqlite3_config()] with a first argument that is not an
1787
+** anytime configuration option in between calls to [sqlite3_initialize()] and
1788
+** [sqlite3_shutdown()] is a no-op that returns SQLITE_MISUSE.
1789
+**
1790
+** The set of anytime configuration options can change (by insertions
1791
+** and/or deletions) from one release of SQLite to the next.
1792
+** As of SQLite version 3.42.0, the complete set of anytime configuration
1793
+** options is:
1794
+** <ul>
1795
+** <li> SQLITE_CONFIG_LOG
1796
+** <li> SQLITE_CONFIG_PCACHE_HDRSZ
1797
+** </ul>
1798
+**
1799
** New configuration options may be added in future releases of SQLite.
1800
** Existing configuration options might be discontinued. Applications
1801
** should check the return code from [sqlite3_config()] to make sure that
@@ -2122,28 +2142,28 @@ struct sqlite3_mem_methods {
2142
** compile-time option is not set, then the default maximum is 1073741824.
2143
** </dl>
2144
*/
2125
-#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2126
-#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2127
-#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2128
-#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
2129
-#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
2130
-#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
2131
-#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
2132
-#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
2133
-#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
2134
-#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
2135
-#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
2136
-/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
2137
-#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
2138
-#define SQLITE_CONFIG_PCACHE 14 /* no-op */
2139
-#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
2140
-#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2141
-#define SQLITE_CONFIG_URI 17 /* int */
2142
-#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2143
-#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2145
+#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2146
+#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2147
+#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2148
+#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
2149
+#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
2150
+#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
2151
+#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
2152
+#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
2153
+#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
2154
+#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
2155
+#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
2156
+/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
2157
+#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
2158
+#define SQLITE_CONFIG_PCACHE 14 /* no-op */
2159
+#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
2160
+#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2161
+#define SQLITE_CONFIG_URI 17 /* int */
2162
+#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2163
+#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2164
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
2145
-#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
2146
-#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
2165
+#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
2166
+#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
2167
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
2168
#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
2169
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
@@ -2378,7 +2398,7 @@ struct sqlite3_mem_methods {
2398
** </dd>
2399
**
2400
** [[SQLITE_DBCONFIG_DQS_DML]]
2381
-** <dt>SQLITE_DBCONFIG_DQS_DML</td>
2401
+** <dt>SQLITE_DBCONFIG_DQS_DML</dt>
2402
** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
2403
** the legacy [double-quoted string literal] misfeature for DML statements
2404
** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
@@ -2387,7 +2407,7 @@ struct sqlite3_mem_methods {
2407
** </dd>
2408
**
2409
** [[SQLITE_DBCONFIG_DQS_DDL]]
2390
-** <dt>SQLITE_DBCONFIG_DQS_DDL</td>
2410
+** <dt>SQLITE_DBCONFIG_DQS_DDL</dt>
2411
** <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates
2412
** the legacy [double-quoted string literal] misfeature for DDL statements,
2413
** such as CREATE TABLE and CREATE INDEX. The
@@ -2396,7 +2416,7 @@ struct sqlite3_mem_methods {
2416
** </dd>
2417
**
2418
** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]]
2399
-** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</td>
2419
+** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</dt>
2420
** <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to
2421
** assume that database schemas are untainted by malicious content.
2422
** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite
@@ -2416,7 +2436,7 @@ struct sqlite3_mem_methods {
2436
** </dd>
2437
**
2438
** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
2419
-** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td>
2439
+** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt>
2440
** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
2441
** the legacy file format flag. When activated, this flag causes all newly
2442
** created database file to have a schema format version number (the 4-byte
@@ -2425,7 +2445,7 @@ struct sqlite3_mem_methods {
2445
** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
2446
** newly created databases are generally not understandable by SQLite versions
2447
** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
2428
-** is now scarcely any need to generated database files that are compatible
2448
+** is now scarcely any need to generate database files that are compatible
2449
** all the way back to version 3.0.0, and so this setting is of little
2450
** practical use, but is provided so that SQLite can continue to claim the
2451
** ability to generate new database files that are compatible with version
@@ -2436,6 +2456,38 @@ struct sqlite3_mem_methods {
2456
** not considered a bug since SQLite versions 3.3.0 and earlier do not support
2457
** either generated columns or decending indexes.
2458
** </dd>
2459
+**
2460
+** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]]
2461
+** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt>
2462
+** <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in
2463
+** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2464
+** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2465
+** statistics. For statistics to be collected, the flag must be set on
2466
+** the database handle both when the SQL statement is prepared and when it
2467
+** is stepped. The flag is set (collection of statistics is enabled)
2468
+** by default. This option takes two arguments: an integer and a pointer to
2469
+** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2470
+** leave unchanged the statement scanstatus option. If the second argument
2471
+** is not NULL, then the value of the statement scanstatus setting after
2472
+** processing the first argument is written into the integer that the second
2473
+** argument points to.
2474
+** </dd>
2475
+**
2476
+** [[SQLITE_DBCONFIG_REVERSE_SCANORDER]]
2477
+** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2478
+** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2479
+** in which tables and indexes are scanned so that the scans start at the end
2480
+** and work toward the beginning rather than starting at the beginning and
2481
+** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2482
+** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2483
+** two arguments which are an integer and a pointer to an integer. The first
2484
+** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2485
+** reverse scan order flag, respectively. If the second argument is not NULL,
2486
+** then 0 or 1 is written into the integer that the second argument points to
2487
+** depending on if the reverse scan order flag is set after processing the
2488
+** first argument.
2489
+** </dd>
2490
+**
2491
** </dl>
2492
*/
2493
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
@@ -2456,7 +2508,9 @@ struct sqlite3_mem_methods {
2508
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2509
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2510
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2459
-#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */
2511
+#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2512
+#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2513
+#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2514
2515
/*
2516
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -6201,6 +6255,13 @@ SQLITE_API void sqlite3_activate_cerod(
6255
** of the default VFS is not implemented correctly, or not implemented at
6256
** all, then the behavior of sqlite3_sleep() may deviate from the description
6257
** in the previous paragraphs.
6258
+**
6259
+** If a negative argument is passed to sqlite3_sleep() the results vary by
6260
+** VFS and operating system. Some system treat a negative argument as an
6261
+** instruction to sleep forever. Others understand it to mean do not sleep
6262
+** at all. ^In SQLite version 3.42.0 and later, a negative
6263
+** argument passed into sqlite3_sleep() is changed to zero before it is relayed
6264
+** down into the xSleep method of the VFS.
6265
*/
6266
SQLITE_API int sqlite3_sleep(int);
6267
@@ -7828,9 +7889,9 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
7889
** is undefined if the mutex is not currently entered by the
7890
** calling thread or is not currently allocated.
7891
**
7831
-** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
7832
-** sqlite3_mutex_leave() is a NULL pointer, then all three routines
7833
-** behave as no-ops.
7892
+** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(),
7893
+** sqlite3_mutex_leave(), or sqlite3_mutex_free() is a NULL pointer,
7894
+** then any of the four routines behaves as a no-op.
7895
**
7896
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
7897
*/
@@ -9564,18 +9625,28 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
9625
** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
9626
** <dd>Calls of the form
9627
** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9567
-** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9628
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9629
** identify that virtual table as being safe to use from within triggers
9630
** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
9631
** virtual table can do no serious harm even if it is controlled by a
9632
** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9633
** flag unless absolutely necessary.
9634
** </dd>
9635
+**
9636
+** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9637
+** <dd>Calls of the form
9638
+** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9639
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9640
+** instruct the query planner to begin at least a read transaction on
9641
+** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9642
+** virtual table is used.
9643
+** </dd>
9644
** </dl>
9645
*/
9646
#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9647
#define SQLITE_VTAB_INNOCUOUS 2
9648
#define SQLITE_VTAB_DIRECTONLY 3
9649
+#define SQLITE_VTAB_USES_ALL_SCHEMAS 4
9650
9651
/*
9652
** CAPI3REF: Determine The Virtual Table Conflict Policy
@@ -10750,16 +10821,20 @@ SQLITE_API int sqlite3session_create(
10821
SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
10822
10823
/*
10753
-** CAPIREF: Conigure a Session Object
10824
+** CAPI3REF: Configure a Session Object
10825
** METHOD: sqlite3_session
10826
**
10827
** This method is used to configure a session object after it has been
10757
-** created. At present the only valid value for the second parameter is
10758
-** [SQLITE_SESSION_OBJCONFIG_SIZE].
10828
+** created. At present the only valid values for the second parameter are
10829
+** [SQLITE_SESSION_OBJCONFIG_SIZE] and [SQLITE_SESSION_OBJCONFIG_ROWID].
10830
**
10760
-** Arguments for sqlite3session_object_config()
10831
+*/
10832
+SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
10833
+
10834
+/*
10835
+** CAPI3REF: Options for sqlite3session_object_config
10836
**
10762
-** The following values may passed as the the 4th parameter to
10837
+** The following values may passed as the the 2nd parameter to
10838
** sqlite3session_object_config().
10839
**
10840
** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
@@ -10775,12 +10850,21 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
10850
**
10851
** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
10852
** the first table has been attached to the session object.
10853
+**
10854
+** <dt>SQLITE_SESSION_OBJCONFIG_ROWID <dd>
10855
+** This option is used to set, clear or query the flag that enables
10856
+** collection of data for tables with no explicit PRIMARY KEY.
10857
+**
10858
+** Normally, tables with no explicit PRIMARY KEY are simply ignored
10859
+** by the sessions module. However, if this flag is set, it behaves
10860
+** as if such tables have a column "_rowid_ INTEGER PRIMARY KEY" inserted
10861
+** as their leftmost columns.
10862
+**
10863
+** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
10864
+** the first table has been attached to the session object.
10865
*/
10779
-SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg);
10780
-
10781
-/*
10782
-*/
10783
-#define SQLITE_SESSION_OBJCONFIG_SIZE 1
10866
+#define SQLITE_SESSION_OBJCONFIG_SIZE 1
10867
+#define SQLITE_SESSION_OBJCONFIG_ROWID 2
10868
10869
/*
10870
** CAPI3REF: Enable Or Disable A Session Object
@@ -11913,9 +11997,23 @@ SQLITE_API int sqlite3changeset_apply_v2(
11997
** Invert the changeset before applying it. This is equivalent to inverting
11998
** a changeset using sqlite3changeset_invert() before applying it. It is
11999
** an error to specify this flag with a patchset.
12000
+**
12001
+** <dt>SQLITE_CHANGESETAPPLY_IGNORENOOP <dd>
12002
+** Do not invoke the conflict handler callback for any changes that
12003
+** would not actually modify the database even if they were applied.
12004
+** Specifically, this means that the conflict handler is not invoked
12005
+** for:
12006
+** <ul>
12007
+** <li>a delete change if the row being deleted cannot be found,
12008
+** <li>an update change if the modified fields are already set to
12009
+** their new values in the conflicting row, or
12010
+** <li>an insert change if all fields of the conflicting row match
12011
+** the row being inserted.
12012
+** </ul>
12013
*/
12014
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12015
#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12016
+#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12017
12018
/*
12019
** CAPI3REF: Constants Passed To The Conflict Handler