@op-engineering/op-sqlite 14.1.2 → 14.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cpp/sqlite3.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /******************************************************************************
2
2
  ** This file is an amalgamation of many separate C source files from SQLite
3
- ** version 3.50.0. By combining all the individual C code files into this
3
+ ** version 3.50.4. By combining all the individual C code files into this
4
4
  ** single large file, the entire code can be compiled as a single translation
5
5
  ** unit. This allows many compilers to do optimizations that would not be
6
6
  ** possible if the files were compiled separately. Performance improvements
@@ -18,7 +18,7 @@
18
18
  ** separate file. This file contains only code for the core SQLite library.
19
19
  **
20
20
  ** The content in this amalgamation comes from Fossil check-in
21
- ** dfc790f998f450d9c35e3ba1c8c89c17466c with changes in files:
21
+ ** 4d8adfb30e03f9cf27f800a2c1ba3c48fb4c with changes in files:
22
22
  **
23
23
  **
24
24
  */
@@ -465,9 +465,9 @@ extern "C" {
465
465
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466
466
  ** [sqlite_version()] and [sqlite_source_id()].
467
467
  */
468
- #define SQLITE_VERSION "3.50.0"
469
- #define SQLITE_VERSION_NUMBER 3050000
470
- #define SQLITE_SOURCE_ID "2025-05-29 14:26:00 dfc790f998f450d9c35e3ba1c8c89c17466cb559f87b0239e4aab9d34e28f742"
468
+ #define SQLITE_VERSION "3.50.4"
469
+ #define SQLITE_VERSION_NUMBER 3050004
470
+ #define SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45e20a3"
471
471
 
472
472
  /*
473
473
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -4398,7 +4398,7 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*);
4398
4398
  **
4399
4399
  ** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of
4400
4400
  ** database filename D with corresponding journal file J and WAL file W and
4401
- ** with N URI parameters key/values pairs in the array P. The result from
4401
+ ** an array P of N URI Key/Value pairs. The result from
4402
4402
  ** sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that
4403
4403
  ** is safe to pass to routines like:
4404
4404
  ** <ul>
@@ -5079,7 +5079,7 @@ typedef struct sqlite3_context sqlite3_context;
5079
5079
  ** METHOD: sqlite3_stmt
5080
5080
  **
5081
5081
  ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
5082
- ** literals may be replaced by a [parameter] that matches one of following
5082
+ ** literals may be replaced by a [parameter] that matches one of the following
5083
5083
  ** templates:
5084
5084
  **
5085
5085
  ** <ul>
@@ -5124,7 +5124,7 @@ typedef struct sqlite3_context sqlite3_context;
5124
5124
  **
5125
5125
  ** [[byte-order determination rules]] ^The byte-order of
5126
5126
  ** UTF16 input text is determined by the byte-order mark (BOM, U+FEFF)
5127
- ** found in first character, which is removed, or in the absence of a BOM
5127
+ ** found in the first character, which is removed, or in the absence of a BOM
5128
5128
  ** the byte order is the native byte order of the host
5129
5129
  ** machine for sqlite3_bind_text16() or the byte order specified in
5130
5130
  ** the 6th parameter for sqlite3_bind_text64().)^
@@ -5144,7 +5144,7 @@ typedef struct sqlite3_context sqlite3_context;
5144
5144
  ** or sqlite3_bind_text16() or sqlite3_bind_text64() then
5145
5145
  ** that parameter must be the byte offset
5146
5146
  ** where the NUL terminator would occur assuming the string were NUL
5147
- ** terminated. If any NUL characters occurs at byte offsets less than
5147
+ ** terminated. If any NUL characters occur at byte offsets less than
5148
5148
  ** the value of the fourth parameter then the resulting string value will
5149
5149
  ** contain embedded NULs. The result of expressions involving strings
5150
5150
  ** with embedded NULs is undefined.
@@ -5356,7 +5356,7 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
5356
5356
  ** METHOD: sqlite3_stmt
5357
5357
  **
5358
5358
  ** ^These routines provide a means to determine the database, table, and
5359
- ** table column that is the origin of a particular result column in
5359
+ ** table column that is the origin of a particular result column in a
5360
5360
  ** [SELECT] statement.
5361
5361
  ** ^The name of the database or table or column can be returned as
5362
5362
  ** either a UTF-8 or UTF-16 string. ^The _database_ routines return
@@ -5925,8 +5925,8 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
5925
5925
  **
5926
5926
  ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for
5927
5927
  ** all application-defined SQL functions that do not need to be
5928
- ** used inside of triggers, view, CHECK constraints, or other elements of
5929
- ** the database schema. This flags is especially recommended for SQL
5928
+ ** used inside of triggers, views, CHECK constraints, or other elements of
5929
+ ** the database schema. This flag is especially recommended for SQL
5930
5930
  ** functions that have side effects or reveal internal application state.
5931
5931
  ** Without this flag, an attacker might be able to modify the schema of
5932
5932
  ** a database file to include invocations of the function with parameters
@@ -5957,7 +5957,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
5957
5957
  ** [user-defined window functions|available here].
5958
5958
  **
5959
5959
  ** ^(If the final parameter to sqlite3_create_function_v2() or
5960
- ** sqlite3_create_window_function() is not NULL, then it is destructor for
5960
+ ** sqlite3_create_window_function() is not NULL, then it is the destructor for
5961
5961
  ** the application data pointer. The destructor is invoked when the function
5962
5962
  ** is deleted, either by being overloaded or when the database connection
5963
5963
  ** closes.)^ ^The destructor is also invoked if the call to
@@ -6357,7 +6357,7 @@ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
6357
6357
  ** METHOD: sqlite3_value
6358
6358
  **
6359
6359
  ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
6360
- ** object D and returns a pointer to that copy. ^The [sqlite3_value] returned
6360
+ ** object V and returns a pointer to that copy. ^The [sqlite3_value] returned
6361
6361
  ** is a [protected sqlite3_value] object even if the input is not.
6362
6362
  ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
6363
6363
  ** memory allocation fails. ^If V is a [pointer value], then the result
@@ -6395,7 +6395,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*);
6395
6395
  ** allocation error occurs.
6396
6396
  **
6397
6397
  ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6398
- ** determined by the N parameter on first successful call. Changing the
6398
+ ** determined by the N parameter on the first successful call. Changing the
6399
6399
  ** value of N in any subsequent call to sqlite3_aggregate_context() within
6400
6400
  ** the same aggregate function instance will not resize the memory
6401
6401
  ** allocation.)^ Within the xFinal callback, it is customary to set
@@ -6557,7 +6557,7 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi
6557
6557
  **
6558
6558
  ** Security Warning: These interfaces should not be exposed in scripting
6559
6559
  ** languages or in other circumstances where it might be possible for an
6560
- ** an attacker to invoke them. Any agent that can invoke these interfaces
6560
+ ** attacker to invoke them. Any agent that can invoke these interfaces
6561
6561
  ** can probably also take control of the process.
6562
6562
  **
6563
6563
  ** Database connection client data is only available for SQLite
@@ -6671,7 +6671,7 @@ typedef void (*sqlite3_destructor_type)(void*);
6671
6671
  ** pointed to by the 2nd parameter are taken as the application-defined
6672
6672
  ** function result. If the 3rd parameter is non-negative, then it
6673
6673
  ** must be the byte offset into the string where the NUL terminator would
6674
- ** appear if the string where NUL terminated. If any NUL characters occur
6674
+ ** appear if the string were NUL terminated. If any NUL characters occur
6675
6675
  ** in the string at a byte offset that is less than the value of the 3rd
6676
6676
  ** parameter, then the resulting string will contain embedded NULs and the
6677
6677
  ** result of expressions operating on strings with embedded NULs is undefined.
@@ -6729,7 +6729,7 @@ typedef void (*sqlite3_destructor_type)(void*);
6729
6729
  ** string and preferably a string literal. The sqlite3_result_pointer()
6730
6730
  ** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
6731
6731
  **
6732
- ** If these routines are called from within the different thread
6732
+ ** If these routines are called from within a different thread
6733
6733
  ** than the one containing the application-defined function that received
6734
6734
  ** the [sqlite3_context] pointer, the results are undefined.
6735
6735
  */
@@ -7135,7 +7135,7 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
7135
7135
  ** METHOD: sqlite3
7136
7136
  **
7137
7137
  ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
7138
- ** for the N-th database on database connection D, or a NULL pointer of N is
7138
+ ** for the N-th database on database connection D, or a NULL pointer if N is
7139
7139
  ** out of range. An N value of 0 means the main database file. An N of 1 is
7140
7140
  ** the "temp" schema. Larger values of N correspond to various ATTACH-ed
7141
7141
  ** databases.
@@ -7230,7 +7230,7 @@ SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
7230
7230
  ** <dd>The SQLITE_TXN_READ state means that the database is currently
7231
7231
  ** in a read transaction. Content has been read from the database file
7232
7232
  ** but nothing in the database file has changed. The transaction state
7233
- ** will advanced to SQLITE_TXN_WRITE if any changes occur and there are
7233
+ ** will be advanced to SQLITE_TXN_WRITE if any changes occur and there are
7234
7234
  ** no other conflicting concurrent write transactions. The transaction
7235
7235
  ** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
7236
7236
  ** [COMMIT].</dd>
@@ -7239,7 +7239,7 @@ SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
7239
7239
  ** <dd>The SQLITE_TXN_WRITE state means that the database is currently
7240
7240
  ** in a write transaction. Content has been written to the database file
7241
7241
  ** but has not yet committed. The transaction state will change to
7242
- ** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
7242
+ ** SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
7243
7243
  */
7244
7244
  #define SQLITE_TXN_NONE 0
7245
7245
  #define SQLITE_TXN_READ 1
@@ -7520,7 +7520,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
7520
7520
  ** CAPI3REF: Impose A Limit On Heap Size
7521
7521
  **
7522
7522
  ** These interfaces impose limits on the amount of heap memory that will be
7523
- ** by all database connections within a single process.
7523
+ ** used by all database connections within a single process.
7524
7524
  **
7525
7525
  ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7526
7526
  ** soft limit on the amount of heap memory that may be allocated by SQLite.
@@ -7578,7 +7578,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
7578
7578
  ** </ul>)^
7579
7579
  **
7580
7580
  ** The circumstances under which SQLite will enforce the heap limits may
7581
- ** changes in future releases of SQLite.
7581
+ ** change in future releases of SQLite.
7582
7582
  */
7583
7583
  SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7584
7584
  SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
@@ -7693,8 +7693,8 @@ SQLITE_API int sqlite3_table_column_metadata(
7693
7693
  ** ^The entry point is zProc.
7694
7694
  ** ^(zProc may be 0, in which case SQLite will try to come up with an
7695
7695
  ** entry point name on its own. It first tries "sqlite3_extension_init".
7696
- ** If that does not work, it constructs a name "sqlite3_X_init" where the
7697
- ** X is consists of the lower-case equivalent of all ASCII alphabetic
7696
+ ** If that does not work, it constructs a name "sqlite3_X_init" where
7697
+ ** X consists of the lower-case equivalent of all ASCII alphabetic
7698
7698
  ** characters in the filename from the last "/" to the first following
7699
7699
  ** "." and omitting any initial "lib".)^
7700
7700
  ** ^The sqlite3_load_extension() interface returns
@@ -7765,7 +7765,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
7765
7765
  ** ^(Even though the function prototype shows that xEntryPoint() takes
7766
7766
  ** no arguments and returns void, SQLite invokes xEntryPoint() with three
7767
7767
  ** arguments and expects an integer result as if the signature of the
7768
- ** entry point where as follows:
7768
+ ** entry point were as follows:
7769
7769
  **
7770
7770
  ** <blockquote><pre>
7771
7771
  ** &nbsp; int xEntryPoint(
@@ -7929,7 +7929,7 @@ struct sqlite3_module {
7929
7929
  ** virtual table and might not be checked again by the byte code.)^ ^(The
7930
7930
  ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
7931
7931
  ** is left in its default setting of false, the constraint will always be
7932
- ** checked separately in byte code. If the omit flag is change to true, then
7932
+ ** checked separately in byte code. If the omit flag is changed to true, then
7933
7933
  ** the constraint may or may not be checked in byte code. In other words,
7934
7934
  ** when the omit flag is true there is no guarantee that the constraint will
7935
7935
  ** not be checked again using byte code.)^
@@ -7955,7 +7955,7 @@ struct sqlite3_module {
7955
7955
  ** The xBestIndex method may optionally populate the idxFlags field with a
7956
7956
  ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
7957
7957
  ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7958
- ** output to show the idxNum has hex instead of as decimal. Another flag is
7958
+ ** output to show the idxNum as hex instead of as decimal. Another flag is
7959
7959
  ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7960
7960
  ** return at most one row.
7961
7961
  **
@@ -8096,7 +8096,7 @@ struct sqlite3_index_info {
8096
8096
  ** the implementation of the [virtual table module]. ^The fourth
8097
8097
  ** parameter is an arbitrary client data pointer that is passed through
8098
8098
  ** into the [xCreate] and [xConnect] methods of the virtual table module
8099
- ** when a new virtual table is be being created or reinitialized.
8099
+ ** when a new virtual table is being created or reinitialized.
8100
8100
  **
8101
8101
  ** ^The sqlite3_create_module_v2() interface has a fifth parameter which
8102
8102
  ** is a pointer to a destructor for the pClientData. ^SQLite will
@@ -8261,7 +8261,7 @@ typedef struct sqlite3_blob sqlite3_blob;
8261
8261
  ** in *ppBlob. Otherwise an [error code] is returned and, unless the error
8262
8262
  ** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
8263
8263
  ** the API is not misused, it is always safe to call [sqlite3_blob_close()]
8264
- ** on *ppBlob after this function it returns.
8264
+ ** on *ppBlob after this function returns.
8265
8265
  **
8266
8266
  ** This function fails with SQLITE_ERROR if any of the following are true:
8267
8267
  ** <ul>
@@ -8381,7 +8381,7 @@ SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
8381
8381
  **
8382
8382
  ** ^Returns the size in bytes of the BLOB accessible via the
8383
8383
  ** successfully opened [BLOB handle] in its only argument. ^The
8384
- ** incremental blob I/O routines can only read or overwriting existing
8384
+ ** incremental blob I/O routines can only read or overwrite existing
8385
8385
  ** blob content; they cannot change the size of a blob.
8386
8386
  **
8387
8387
  ** This routine only works on a [BLOB handle] which has been created
@@ -8531,7 +8531,7 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
8531
8531
  ** ^The sqlite3_mutex_alloc() routine allocates a new
8532
8532
  ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
8533
8533
  ** routine returns NULL if it is unable to allocate the requested
8534
- ** mutex. The argument to sqlite3_mutex_alloc() must one of these
8534
+ ** mutex. The argument to sqlite3_mutex_alloc() must be one of these
8535
8535
  ** integer constants:
8536
8536
  **
8537
8537
  ** <ul>
@@ -8764,7 +8764,7 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
8764
8764
  ** CAPI3REF: Retrieve the mutex for a database connection
8765
8765
  ** METHOD: sqlite3
8766
8766
  **
8767
- ** ^This interface returns a pointer the [sqlite3_mutex] object that
8767
+ ** ^This interface returns a pointer to the [sqlite3_mutex] object that
8768
8768
  ** serializes access to the [database connection] given in the argument
8769
8769
  ** when the [threading mode] is Serialized.
8770
8770
  ** ^If the [threading mode] is Single-thread or Multi-thread then this
@@ -8887,7 +8887,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8887
8887
  ** CAPI3REF: SQL Keyword Checking
8888
8888
  **
8889
8889
  ** These routines provide access to the set of SQL language keywords
8890
- ** recognized by SQLite. Applications can uses these routines to determine
8890
+ ** recognized by SQLite. Applications can use these routines to determine
8891
8891
  ** whether or not a specific identifier needs to be escaped (for example,
8892
8892
  ** by enclosing in double-quotes) so as not to confuse the parser.
8893
8893
  **
@@ -9055,7 +9055,7 @@ SQLITE_API void sqlite3_str_reset(sqlite3_str*);
9055
9055
  ** content of the dynamic string under construction in X. The value
9056
9056
  ** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
9057
9057
  ** and might be freed or altered by any subsequent method on the same
9058
- ** [sqlite3_str] object. Applications must not used the pointer returned
9058
+ ** [sqlite3_str] object. Applications must not use the pointer returned by
9059
9059
  ** [sqlite3_str_value(X)] after any subsequent method call on the same
9060
9060
  ** object. ^Applications may change the content of the string returned
9061
9061
  ** by [sqlite3_str_value(X)] as long as they do not write into any bytes
@@ -9141,7 +9141,7 @@ SQLITE_API int sqlite3_status64(
9141
9141
  ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
9142
9142
  ** buffer and where forced to overflow to [sqlite3_malloc()]. The
9143
9143
  ** returned value includes allocations that overflowed because they
9144
- ** where too large (they were larger than the "sz" parameter to
9144
+ ** were too large (they were larger than the "sz" parameter to
9145
9145
  ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
9146
9146
  ** no space was left in the page cache.</dd>)^
9147
9147
  **
@@ -9225,28 +9225,29 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
9225
9225
  ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
9226
9226
  ** <dd>This parameter returns the number of malloc attempts that were
9227
9227
  ** satisfied using lookaside memory. Only the high-water value is meaningful;
9228
- ** the current value is always zero.)^
9228
+ ** the current value is always zero.</dd>)^
9229
9229
  **
9230
9230
  ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
9231
9231
  ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
9232
- ** <dd>This parameter returns the number malloc attempts that might have
9232
+ ** <dd>This parameter returns the number of malloc attempts that might have
9233
9233
  ** been satisfied using lookaside memory but failed due to the amount of
9234
9234
  ** memory requested being larger than the lookaside slot size.
9235
9235
  ** Only the high-water value is meaningful;
9236
- ** the current value is always zero.)^
9236
+ ** the current value is always zero.</dd>)^
9237
9237
  **
9238
9238
  ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
9239
9239
  ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
9240
- ** <dd>This parameter returns the number malloc attempts that might have
9240
+ ** <dd>This parameter returns the number of malloc attempts that might have
9241
9241
  ** been satisfied using lookaside memory but failed due to all lookaside
9242
9242
  ** memory already being in use.
9243
9243
  ** Only the high-water value is meaningful;
9244
- ** the current value is always zero.)^
9244
+ ** the current value is always zero.</dd>)^
9245
9245
  **
9246
9246
  ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
9247
9247
  ** <dd>This parameter returns the approximate number of bytes of heap
9248
9248
  ** memory used by all pager caches associated with the database connection.)^
9249
9249
  ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
9250
+ ** </dd>
9250
9251
  **
9251
9252
  ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
9252
9253
  ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
@@ -9255,10 +9256,10 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
9255
9256
  ** memory used by that pager cache is divided evenly between the attached
9256
9257
  ** connections.)^ In other words, if none of the pager caches associated
9257
9258
  ** with the database connection are shared, this request returns the same
9258
- ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
9259
+ ** value as DBSTATUS_CACHE_USED. Or, if one or more of the pager caches are
9259
9260
  ** shared, the value returned by this call will be smaller than that returned
9260
9261
  ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
9261
- ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
9262
+ ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</dd>
9262
9263
  **
9263
9264
  ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
9264
9265
  ** <dd>This parameter returns the approximate number of bytes of heap
@@ -9268,6 +9269,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
9268
9269
  ** schema memory is shared with other database connections due to
9269
9270
  ** [shared cache mode] being enabled.
9270
9271
  ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
9272
+ ** </dd>
9271
9273
  **
9272
9274
  ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
9273
9275
  ** <dd>This parameter returns the approximate number of bytes of heap
@@ -9304,7 +9306,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
9304
9306
  ** been written to disk in the middle of a transaction due to the page
9305
9307
  ** cache overflowing. Transactions are more efficient if they are written
9306
9308
  ** to disk all at once. When pages spill mid-transaction, that introduces
9307
- ** additional overhead. This parameter can be used help identify
9309
+ ** additional overhead. This parameter can be used to help identify
9308
9310
  ** inefficiencies that can be resolved by increasing the cache size.
9309
9311
  ** </dd>
9310
9312
  **
@@ -9375,13 +9377,13 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
9375
9377
  ** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>
9376
9378
  ** <dd>^This is the number of sort operations that have occurred.
9377
9379
  ** A non-zero value in this counter may indicate an opportunity to
9378
- ** improvement performance through careful use of indices.</dd>
9380
+ ** improve performance through careful use of indices.</dd>
9379
9381
  **
9380
9382
  ** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
9381
9383
  ** <dd>^This is the number of rows inserted into transient indices that
9382
9384
  ** were created automatically in order to help joins run faster.
9383
9385
  ** A non-zero value in this counter may indicate an opportunity to
9384
- ** improvement performance by adding permanent indices that do not
9386
+ ** improve performance by adding permanent indices that do not
9385
9387
  ** need to be reinitialized each time the statement is run.</dd>
9386
9388
  **
9387
9389
  ** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>
@@ -9390,19 +9392,19 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
9390
9392
  ** to 2147483647. The number of virtual machine operations can be
9391
9393
  ** used as a proxy for the total work done by the prepared statement.
9392
9394
  ** If the number of virtual machine operations exceeds 2147483647
9393
- ** then the value returned by this statement status code is undefined.
9395
+ ** then the value returned by this statement status code is undefined.</dd>
9394
9396
  **
9395
9397
  ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
9396
9398
  ** <dd>^This is the number of times that the prepare statement has been
9397
9399
  ** automatically regenerated due to schema changes or changes to
9398
- ** [bound parameters] that might affect the query plan.
9400
+ ** [bound parameters] that might affect the query plan.</dd>
9399
9401
  **
9400
9402
  ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
9401
9403
  ** <dd>^This is the number of times that the prepared statement has
9402
9404
  ** been run. A single "run" for the purposes of this counter is one
9403
9405
  ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
9404
9406
  ** The counter is incremented on the first [sqlite3_step()] call of each
9405
- ** cycle.
9407
+ ** cycle.</dd>
9406
9408
  **
9407
9409
  ** [[SQLITE_STMTSTATUS_FILTER_MISS]]
9408
9410
  ** [[SQLITE_STMTSTATUS_FILTER HIT]]
@@ -9412,7 +9414,7 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
9412
9414
  ** step was bypassed because a Bloom filter returned not-found. The
9413
9415
  ** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
9414
9416
  ** times that the Bloom filter returned a find, and thus the join step
9415
- ** had to be processed as normal.
9417
+ ** had to be processed as normal.</dd>
9416
9418
  **
9417
9419
  ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
9418
9420
  ** <dd>^This is the approximate number of bytes of heap memory
@@ -9517,9 +9519,9 @@ struct sqlite3_pcache_page {
9517
9519
  ** SQLite will typically create one cache instance for each open database file,
9518
9520
  ** though this is not guaranteed. ^The
9519
9521
  ** first parameter, szPage, is the size in bytes of the pages that must
9520
- ** be allocated by the cache. ^szPage will always a power of two. ^The
9522
+ ** be allocated by the cache. ^szPage will always be a power of two. ^The
9521
9523
  ** second parameter szExtra is a number of bytes of extra storage
9522
- ** associated with each page cache entry. ^The szExtra parameter will
9524
+ ** associated with each page cache entry. ^The szExtra parameter will be
9523
9525
  ** a number less than 250. SQLite will use the
9524
9526
  ** extra szExtra bytes on each page to store metadata about the underlying
9525
9527
  ** database page on disk. The value passed into szExtra depends
@@ -9527,17 +9529,17 @@ struct sqlite3_pcache_page {
9527
9529
  ** ^The third argument to xCreate(), bPurgeable, is true if the cache being
9528
9530
  ** created will be used to cache database pages of a file stored on disk, or
9529
9531
  ** false if it is used for an in-memory database. The cache implementation
9530
- ** does not have to do anything special based with the value of bPurgeable;
9532
+ ** does not have to do anything special based upon the value of bPurgeable;
9531
9533
  ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
9532
9534
  ** never invoke xUnpin() except to deliberately delete a page.
9533
9535
  ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to
9534
9536
  ** false will always have the "discard" flag set to true.
9535
- ** ^Hence, a cache created with bPurgeable false will
9537
+ ** ^Hence, a cache created with bPurgeable set to false will
9536
9538
  ** never contain any unpinned pages.
9537
9539
  **
9538
9540
  ** [[the xCachesize() page cache method]]
9539
9541
  ** ^(The xCachesize() method may be called at any time by SQLite to set the
9540
- ** suggested maximum cache-size (number of pages stored by) the cache
9542
+ ** suggested maximum cache-size (number of pages stored) for the cache
9541
9543
  ** instance passed as the first argument. This is the value configured using
9542
9544
  ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable
9543
9545
  ** parameter, the implementation is not required to do anything with this
@@ -9564,12 +9566,12 @@ struct sqlite3_pcache_page {
9564
9566
  ** implementation must return a pointer to the page buffer with its content
9565
9567
  ** intact. If the requested page is not already in the cache, then the
9566
9568
  ** cache implementation should use the value of the createFlag
9567
- ** parameter to help it determined what action to take:
9569
+ ** parameter to help it determine what action to take:
9568
9570
  **
9569
9571
  ** <table border=1 width=85% align=center>
9570
9572
  ** <tr><th> createFlag <th> Behavior when page is not already in cache
9571
9573
  ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
9572
- ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
9574
+ ** <tr><td> 1 <td> Allocate a new page if it is easy and convenient to do so.
9573
9575
  ** Otherwise return NULL.
9574
9576
  ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
9575
9577
  ** NULL if allocating a new page is effectively impossible.
@@ -9586,7 +9588,7 @@ struct sqlite3_pcache_page {
9586
9588
  ** as its second argument. If the third parameter, discard, is non-zero,
9587
9589
  ** then the page must be evicted from the cache.
9588
9590
  ** ^If the discard parameter is
9589
- ** zero, then the page may be discarded or retained at the discretion of
9591
+ ** zero, then the page may be discarded or retained at the discretion of the
9590
9592
  ** page cache implementation. ^The page cache implementation
9591
9593
  ** may choose to evict unpinned pages at any time.
9592
9594
  **
@@ -9604,7 +9606,7 @@ struct sqlite3_pcache_page {
9604
9606
  ** When SQLite calls the xTruncate() method, the cache must discard all
9605
9607
  ** existing cache entries with page numbers (keys) greater than or equal
9606
9608
  ** to the value of the iLimit parameter passed to xTruncate(). If any
9607
- ** of these pages are pinned, they are implicitly unpinned, meaning that
9609
+ ** of these pages are pinned, they become implicitly unpinned, meaning that
9608
9610
  ** they can be safely discarded.
9609
9611
  **
9610
9612
  ** [[the xDestroy() page cache method]]
@@ -9784,7 +9786,7 @@ typedef struct sqlite3_backup sqlite3_backup;
9784
9786
  ** external process or via a database connection other than the one being
9785
9787
  ** used by the backup operation, then the backup will be automatically
9786
9788
  ** restarted by the next call to sqlite3_backup_step(). ^If the source
9787
- ** database is modified by the using the same database connection as is used
9789
+ ** database is modified by using the same database connection as is used
9788
9790
  ** by the backup operation, then the backup database is automatically
9789
9791
  ** updated at the same time.
9790
9792
  **
@@ -9801,7 +9803,7 @@ typedef struct sqlite3_backup sqlite3_backup;
9801
9803
  ** and may not be used following a call to sqlite3_backup_finish().
9802
9804
  **
9803
9805
  ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
9804
- ** sqlite3_backup_step() errors occurred, regardless or whether or not
9806
+ ** sqlite3_backup_step() errors occurred, regardless of whether or not
9805
9807
  ** sqlite3_backup_step() completed.
9806
9808
  ** ^If an out-of-memory condition or IO error occurred during any prior
9807
9809
  ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
@@ -9903,7 +9905,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
9903
9905
  ** application receives an SQLITE_LOCKED error, it may call the
9904
9906
  ** sqlite3_unlock_notify() method with the blocked connection handle as
9905
9907
  ** the first argument to register for a callback that will be invoked
9906
- ** when the blocking connections current transaction is concluded. ^The
9908
+ ** when the blocking connection's current transaction is concluded. ^The
9907
9909
  ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
9908
9910
  ** call that concludes the blocking connection's transaction.
9909
9911
  **
@@ -9923,7 +9925,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
9923
9925
  ** blocked connection already has a registered unlock-notify callback,
9924
9926
  ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
9925
9927
  ** called with a NULL pointer as its second argument, then any existing
9926
- ** unlock-notify callback is canceled. ^The blocked connections
9928
+ ** unlock-notify callback is canceled. ^The blocked connection's
9927
9929
  ** unlock-notify callback may also be canceled by closing the blocked
9928
9930
  ** connection using [sqlite3_close()].
9929
9931
  **
@@ -10321,7 +10323,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
10321
10323
  ** support constraints. In this configuration (which is the default) if
10322
10324
  ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire
10323
10325
  ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been
10324
- ** specified as part of the users SQL statement, regardless of the actual
10326
+ ** specified as part of the user's SQL statement, regardless of the actual
10325
10327
  ** ON CONFLICT mode specified.
10326
10328
  **
10327
10329
  ** If X is non-zero, then the virtual table implementation guarantees
@@ -10355,7 +10357,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
10355
10357
  ** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
10356
10358
  ** <dd>Calls of the form
10357
10359
  ** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
10358
- ** the [xConnect] or [xCreate] methods of a [virtual table] implementation
10360
+ ** [xConnect] or [xCreate] methods of a [virtual table] implementation
10359
10361
  ** identify that virtual table as being safe to use from within triggers
10360
10362
  ** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
10361
10363
  ** virtual table can do no serious harm even if it is controlled by a
@@ -10523,7 +10525,7 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10523
10525
  ** </table>
10524
10526
  **
10525
10527
  ** ^For the purposes of comparing virtual table output values to see if the
10526
- ** values are same value for sorting purposes, two NULL values are considered
10528
+ ** values are the same value for sorting purposes, two NULL values are considered
10527
10529
  ** to be the same. In other words, the comparison operator is "IS"
10528
10530
  ** (or "IS NOT DISTINCT FROM") and not "==".
10529
10531
  **
@@ -10533,7 +10535,7 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10533
10535
  **
10534
10536
  ** ^A virtual table implementation is always free to return rows in any order
10535
10537
  ** it wants, as long as the "orderByConsumed" flag is not set. ^When the
10536
- ** the "orderByConsumed" flag is unset, the query planner will add extra
10538
+ ** "orderByConsumed" flag is unset, the query planner will add extra
10537
10539
  ** [bytecode] to ensure that the final results returned by the SQL query are
10538
10540
  ** ordered correctly. The use of the "orderByConsumed" flag and the
10539
10541
  ** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
@@ -10630,7 +10632,7 @@ SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
10630
10632
  ** sqlite3_vtab_in_next(X,P) should be one of the parameters to the
10631
10633
  ** xFilter method which invokes these routines, and specifically
10632
10634
  ** a parameter that was previously selected for all-at-once IN constraint
10633
- ** processing use the [sqlite3_vtab_in()] interface in the
10635
+ ** processing using the [sqlite3_vtab_in()] interface in the
10634
10636
  ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
10635
10637
  ** an xFilter argument that was selected for all-at-once IN constraint
10636
10638
  ** processing, then these routines return [SQLITE_ERROR].)^
@@ -10685,7 +10687,7 @@ SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
10685
10687
  ** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
10686
10688
  ** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
10687
10689
  ** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
10688
- ** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
10690
+ ** can return a result code other than SQLITE_OK or SQLITE_NOTFOUND if
10689
10691
  ** something goes wrong.
10690
10692
  **
10691
10693
  ** The sqlite3_vtab_rhs_value() interface is usually only successful if
@@ -10713,8 +10715,8 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10713
10715
  ** KEYWORDS: {conflict resolution mode}
10714
10716
  **
10715
10717
  ** These constants are returned by [sqlite3_vtab_on_conflict()] to
10716
- ** inform a [virtual table] implementation what the [ON CONFLICT] mode
10717
- ** is for the SQL statement being evaluated.
10718
+ ** inform a [virtual table] implementation of the [ON CONFLICT] mode
10719
+ ** for the SQL statement being evaluated.
10718
10720
  **
10719
10721
  ** Note that the [SQLITE_IGNORE] constant is also used as a potential
10720
10722
  ** return value from the [sqlite3_set_authorizer()] callback and that
@@ -10754,39 +10756,39 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10754
10756
  ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
10755
10757
  ** <dd>^The "double" variable pointed to by the V parameter will be set to the
10756
10758
  ** query planner's estimate for the average number of rows output from each
10757
- ** iteration of the X-th loop. If the query planner's estimates was accurate,
10759
+ ** iteration of the X-th loop. If the query planner's estimate was accurate,
10758
10760
  ** then this value will approximate the quotient NVISIT/NLOOP and the
10759
10761
  ** product of this value for all prior loops with the same SELECTID will
10760
- ** be the NLOOP value for the current loop.
10762
+ ** be the NLOOP value for the current loop.</dd>
10761
10763
  **
10762
10764
  ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
10763
10765
  ** <dd>^The "const char *" variable pointed to by the V parameter will be set
10764
10766
  ** to a zero-terminated UTF-8 string containing the name of the index or table
10765
- ** used for the X-th loop.
10767
+ ** used for the X-th loop.</dd>
10766
10768
  **
10767
10769
  ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
10768
10770
  ** <dd>^The "const char *" variable pointed to by the V parameter will be set
10769
10771
  ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
10770
- ** description for the X-th loop.
10772
+ ** description for the X-th loop.</dd>
10771
10773
  **
10772
10774
  ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECTID</dt>
10773
10775
  ** <dd>^The "int" variable pointed to by the V parameter will be set to the
10774
10776
  ** id for the X-th query plan element. The id value is unique within the
10775
10777
  ** statement. The select-id is the same value as is output in the first
10776
- ** column of an [EXPLAIN QUERY PLAN] query.
10778
+ ** column of an [EXPLAIN QUERY PLAN] query.</dd>
10777
10779
  **
10778
10780
  ** [[SQLITE_SCANSTAT_PARENTID]] <dt>SQLITE_SCANSTAT_PARENTID</dt>
10779
10781
  ** <dd>The "int" variable pointed to by the V parameter will be set to the
10780
- ** the id of the parent of the current query element, if applicable, or
10782
+ ** id of the parent of the current query element, if applicable, or
10781
10783
  ** to zero if the query element has no parent. This is the same value as
10782
- ** returned in the second column of an [EXPLAIN QUERY PLAN] query.
10784
+ ** returned in the second column of an [EXPLAIN QUERY PLAN] query.</dd>
10783
10785
  **
10784
10786
  ** [[SQLITE_SCANSTAT_NCYCLE]] <dt>SQLITE_SCANSTAT_NCYCLE</dt>
10785
10787
  ** <dd>The sqlite3_int64 output value is set to the number of cycles,
10786
10788
  ** according to the processor time-stamp counter, that elapsed while the
10787
10789
  ** query element was being processed. This value is not available for
10788
10790
  ** all query elements - if it is unavailable the output variable is
10789
- ** set to -1.
10791
+ ** set to -1.</dd>
10790
10792
  ** </dl>
10791
10793
  */
10792
10794
  #define SQLITE_SCANSTAT_NLOOP 0
@@ -10827,8 +10829,8 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10827
10829
  ** sqlite3_stmt_scanstatus_v2() with a zeroed flags parameter.
10828
10830
  **
10829
10831
  ** Parameter "idx" identifies the specific query element to retrieve statistics
10830
- ** for. Query elements are numbered starting from zero. A value of -1 may be
10831
- ** to query for statistics regarding the entire query. ^If idx is out of range
10832
+ ** for. Query elements are numbered starting from zero. A value of -1 may
10833
+ ** retrieve statistics for the entire query. ^If idx is out of range
10832
10834
  ** - less than -1 or greater than or equal to the total number of query
10833
10835
  ** elements used to implement the statement - a non-zero value is returned and
10834
10836
  ** the variable that pOut points to is unchanged.
@@ -10871,7 +10873,7 @@ SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
10871
10873
  ** METHOD: sqlite3
10872
10874
  **
10873
10875
  ** ^If a write-transaction is open on [database connection] D when the
10874
- ** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
10876
+ ** [sqlite3_db_cacheflush(D)] interface is invoked, any dirty
10875
10877
  ** pages in the pager-cache that are not currently in use are written out
10876
10878
  ** to disk. A dirty page may be in use if a database cursor created by an
10877
10879
  ** active SQL statement is reading from it, or if it is page 1 of a database
@@ -10985,8 +10987,8 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*);
10985
10987
  ** triggers; and so forth.
10986
10988
  **
10987
10989
  ** When the [sqlite3_blob_write()] API is used to update a blob column,
10988
- ** the pre-update hook is invoked with SQLITE_DELETE. This is because the
10989
- ** in this case the new values are not available. In this case, when a
10990
+ ** the pre-update hook is invoked with SQLITE_DELETE, because
10991
+ ** the new values are not yet available. In this case, when a
10990
10992
  ** callback made with op==SQLITE_DELETE is actually a write using the
10991
10993
  ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
10992
10994
  ** the index of the column being written. In other cases, where the
@@ -11239,7 +11241,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
11239
11241
  ** For an ordinary on-disk database file, the serialization is just a
11240
11242
  ** copy of the disk file. For an in-memory database or a "TEMP" database,
11241
11243
  ** the serialization is the same sequence of bytes which would be written
11242
- ** to disk if that database where backed up to disk.
11244
+ ** to disk if that database were backed up to disk.
11243
11245
  **
11244
11246
  ** The usual case is that sqlite3_serialize() copies the serialization of
11245
11247
  ** the database into memory obtained from [sqlite3_malloc64()] and returns
@@ -11248,7 +11250,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
11248
11250
  ** contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations
11249
11251
  ** are made, and the sqlite3_serialize() function will return a pointer
11250
11252
  ** to the contiguous memory representation of the database that SQLite
11251
- ** is currently using for that database, or NULL if the no such contiguous
11253
+ ** is currently using for that database, or NULL if no such contiguous
11252
11254
  ** memory representation of the database exists. A contiguous memory
11253
11255
  ** representation of the database will usually only exist if there has
11254
11256
  ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same
@@ -11319,7 +11321,7 @@ SQLITE_API unsigned char *sqlite3_serialize(
11319
11321
  ** database is currently in a read transaction or is involved in a backup
11320
11322
  ** operation.
11321
11323
  **
11322
- ** It is not possible to deserialized into the TEMP database. If the
11324
+ ** It is not possible to deserialize into the TEMP database. If the
11323
11325
  ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
11324
11326
  ** function returns SQLITE_ERROR.
11325
11327
  **
@@ -11341,7 +11343,7 @@ SQLITE_API int sqlite3_deserialize(
11341
11343
  sqlite3 *db, /* The database connection */
11342
11344
  const char *zSchema, /* Which DB to reopen with the deserialization */
11343
11345
  unsigned char *pData, /* The serialized database content */
11344
- sqlite3_int64 szDb, /* Number bytes in the deserialization */
11346
+ sqlite3_int64 szDb, /* Number of bytes in the deserialization */
11345
11347
  sqlite3_int64 szBuf, /* Total size of buffer pData[] */
11346
11348
  unsigned mFlags /* Zero or more SQLITE_DESERIALIZE_* flags */
11347
11349
  );
@@ -11349,7 +11351,7 @@ SQLITE_API int sqlite3_deserialize(
11349
11351
  /*
11350
11352
  ** CAPI3REF: Flags for sqlite3_deserialize()
11351
11353
  **
11352
- ** The following are allowed values for 6th argument (the F argument) to
11354
+ ** The following are allowed values for the 6th argument (the F argument) to
11353
11355
  ** the [sqlite3_deserialize(D,S,P,N,M,F)] interface.
11354
11356
  **
11355
11357
  ** The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization
@@ -15442,8 +15444,8 @@ typedef INT16_TYPE LogEst;
15442
15444
  ** assuming n is a signed integer type. UMXV(n) is similar for unsigned
15443
15445
  ** integer types.
15444
15446
  */
15445
- #define SMXV(n) ((((i64)1)<<(sizeof(n)-1))-1)
15446
- #define UMXV(n) ((((i64)1)<<(sizeof(n)))-1)
15447
+ #define SMXV(n) ((((i64)1)<<(sizeof(n)*8-1))-1)
15448
+ #define UMXV(n) ((((i64)1)<<(sizeof(n)*8))-1)
15447
15449
 
15448
15450
  /*
15449
15451
  ** Round up a number to the next larger multiple of 8. This is used
@@ -18703,6 +18705,7 @@ struct CollSeq {
18703
18705
  #define SQLITE_AFF_INTEGER 0x44 /* 'D' */
18704
18706
  #define SQLITE_AFF_REAL 0x45 /* 'E' */
18705
18707
  #define SQLITE_AFF_FLEXNUM 0x46 /* 'F' */
18708
+ #define SQLITE_AFF_DEFER 0x58 /* 'X' - defer computation until later */
18706
18709
 
18707
18710
  #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
18708
18711
 
@@ -19165,7 +19168,6 @@ struct Index {
19165
19168
  unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
19166
19169
  unsigned bNoQuery:1; /* Do not use this index to optimize queries */
19167
19170
  unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19168
- unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
19169
19171
  unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
19170
19172
  unsigned bHasExpr:1; /* Index contains an expression, either a literal
19171
19173
  ** expression, or a reference to a VIRTUAL column */
@@ -19253,7 +19255,7 @@ struct AggInfo {
19253
19255
  ** from source tables rather than from accumulators */
19254
19256
  u8 useSortingIdx; /* In direct mode, reference the sorting index rather
19255
19257
  ** than the source table */
19256
- u16 nSortingColumn; /* Number of columns in the sorting index */
19258
+ u32 nSortingColumn; /* Number of columns in the sorting index */
19257
19259
  int sortingIdx; /* Cursor number of the sorting index */
19258
19260
  int sortingIdxPTab; /* Cursor number of pseudo-table */
19259
19261
  int iFirstReg; /* First register in range for aCol[] and aFunc[] */
@@ -19262,8 +19264,8 @@ struct AggInfo {
19262
19264
  Table *pTab; /* Source table */
19263
19265
  Expr *pCExpr; /* The original expression */
19264
19266
  int iTable; /* Cursor number of the source table */
19265
- i16 iColumn; /* Column number within the source table */
19266
- i16 iSorterColumn; /* Column number in the sorting index */
19267
+ int iColumn; /* Column number within the source table */
19268
+ int iSorterColumn; /* Column number in the sorting index */
19267
19269
  } *aCol;
19268
19270
  int nColumn; /* Number of used entries in aCol[] */
19269
19271
  int nAccumulator; /* Number of columns that show through to the output.
@@ -19438,6 +19440,7 @@ struct Expr {
19438
19440
  Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
19439
19441
  ** for a column of an index on an expression */
19440
19442
  Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
19443
+ int nReg; /* TK_NULLS: Number of registers to NULL out */
19441
19444
  struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
19442
19445
  int iAddr; /* Subroutine entry address */
19443
19446
  int regReturn; /* Register used to hold return address */
@@ -21472,6 +21475,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int)
21472
21475
  SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
21473
21476
  SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
21474
21477
  SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce(Parse*, Expr*, int);
21478
+ SQLITE_PRIVATE void sqlite3ExprNullRegisterRange(Parse*, int, int);
21475
21479
  SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
21476
21480
  SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
21477
21481
  SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
@@ -43874,21 +43878,20 @@ static int unixShmLock(
43874
43878
  /* Check that, if this to be a blocking lock, no locks that occur later
43875
43879
  ** in the following list than the lock being obtained are already held:
43876
43880
  **
43877
- ** 1. Checkpointer lock (ofst==1).
43878
- ** 2. Write lock (ofst==0).
43879
- ** 3. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
43881
+ ** 1. Recovery lock (ofst==2).
43882
+ ** 2. Checkpointer lock (ofst==1).
43883
+ ** 3. Write lock (ofst==0).
43884
+ ** 4. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
43880
43885
  **
43881
43886
  ** In other words, if this is a blocking lock, none of the locks that
43882
43887
  ** occur later in the above list than the lock being obtained may be
43883
43888
  ** held.
43884
- **
43885
- ** It is not permitted to block on the RECOVER lock.
43886
43889
  */
43887
43890
  #if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && defined(SQLITE_DEBUG)
43888
43891
  {
43889
43892
  u16 lockMask = (p->exclMask|p->sharedMask);
43890
43893
  assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || (
43891
- (ofst!=2) /* not RECOVER */
43894
+ (ofst!=2 || lockMask==0)
43892
43895
  && (ofst!=1 || lockMask==0 || lockMask==2)
43893
43896
  && (ofst!=0 || lockMask<3)
43894
43897
  && (ofst<3 || lockMask<(1<<ofst))
@@ -49849,7 +49852,11 @@ static int winHandleLockTimeout(
49849
49852
  if( res==WAIT_OBJECT_0 ){
49850
49853
  ret = TRUE;
49851
49854
  }else if( res==WAIT_TIMEOUT ){
49855
+ #if SQLITE_ENABLE_SETLK_TIMEOUT==1
49852
49856
  rc = SQLITE_BUSY_TIMEOUT;
49857
+ #else
49858
+ rc = SQLITE_BUSY;
49859
+ #endif
49853
49860
  }else{
49854
49861
  /* Some other error has occurred */
49855
49862
  rc = SQLITE_IOERR_LOCK;
@@ -51660,21 +51667,20 @@ static int winShmLock(
51660
51667
  /* Check that, if this to be a blocking lock, no locks that occur later
51661
51668
  ** in the following list than the lock being obtained are already held:
51662
51669
  **
51663
- ** 1. Checkpointer lock (ofst==1).
51664
- ** 2. Write lock (ofst==0).
51665
- ** 3. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
51670
+ ** 1. Recovery lock (ofst==2).
51671
+ ** 2. Checkpointer lock (ofst==1).
51672
+ ** 3. Write lock (ofst==0).
51673
+ ** 4. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
51666
51674
  **
51667
51675
  ** In other words, if this is a blocking lock, none of the locks that
51668
51676
  ** occur later in the above list than the lock being obtained may be
51669
51677
  ** held.
51670
- **
51671
- ** It is not permitted to block on the RECOVER lock.
51672
51678
  */
51673
51679
  #if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && defined(SQLITE_DEBUG)
51674
51680
  {
51675
51681
  u16 lockMask = (p->exclMask|p->sharedMask);
51676
51682
  assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || (
51677
- (ofst!=2) /* not RECOVER */
51683
+ (ofst!=2 || lockMask==0)
51678
51684
  && (ofst!=1 || lockMask==0 || lockMask==2)
51679
51685
  && (ofst!=0 || lockMask<3)
51680
51686
  && (ofst<3 || lockMask<(1<<ofst))
@@ -54963,7 +54969,9 @@ bitvec_set_rehash:
54963
54969
  }else{
54964
54970
  memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));
54965
54971
  memset(p->u.apSub, 0, sizeof(p->u.apSub));
54966
- p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR;
54972
+ p->iDivisor = p->iSize/BITVEC_NPTR;
54973
+ if( (p->iSize%BITVEC_NPTR)!=0 ) p->iDivisor++;
54974
+ if( p->iDivisor<BITVEC_NBIT ) p->iDivisor = BITVEC_NBIT;
54967
54975
  rc = sqlite3BitvecSet(p, i);
54968
54976
  for(j=0; j<BITVEC_NINT; j++){
54969
54977
  if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);
@@ -58750,6 +58758,9 @@ struct Pager {
58750
58758
  Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
58751
58759
  char *zWal; /* File name for write-ahead log */
58752
58760
  #endif
58761
+ #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
58762
+ sqlite3 *dbWal;
58763
+ #endif
58753
58764
  };
58754
58765
 
58755
58766
  /*
@@ -65631,6 +65642,11 @@ static int pagerOpenWal(Pager *pPager){
65631
65642
  pPager->fd, pPager->zWal, pPager->exclusiveMode,
65632
65643
  pPager->journalSizeLimit, &pPager->pWal
65633
65644
  );
65645
+ #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
65646
+ if( rc==SQLITE_OK ){
65647
+ sqlite3WalDb(pPager->pWal, pPager->dbWal);
65648
+ }
65649
+ #endif
65634
65650
  }
65635
65651
  pagerFixMaplimit(pPager);
65636
65652
 
@@ -65750,6 +65766,7 @@ SQLITE_PRIVATE int sqlite3PagerWalWriteLock(Pager *pPager, int bLock){
65750
65766
  ** blocking locks are required.
65751
65767
  */
65752
65768
  SQLITE_PRIVATE void sqlite3PagerWalDb(Pager *pPager, sqlite3 *db){
65769
+ pPager->dbWal = db;
65753
65770
  if( pagerUseWal(pPager) ){
65754
65771
  sqlite3WalDb(pPager->pWal, db);
65755
65772
  }
@@ -68923,7 +68940,6 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
68923
68940
  rc = walIndexReadHdr(pWal, pChanged);
68924
68941
  }
68925
68942
  #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68926
- walDisableBlocking(pWal);
68927
68943
  if( rc==SQLITE_BUSY_TIMEOUT ){
68928
68944
  rc = SQLITE_BUSY;
68929
68945
  *pCnt |= WAL_RETRY_BLOCKED_MASK;
@@ -68938,6 +68954,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
68938
68954
  ** WAL_RETRY this routine will be called again and will probably be
68939
68955
  ** right on the second iteration.
68940
68956
  */
68957
+ (void)walEnableBlocking(pWal);
68941
68958
  if( pWal->apWiData[0]==0 ){
68942
68959
  /* This branch is taken when the xShmMap() method returns SQLITE_BUSY.
68943
68960
  ** We assume this is a transient condition, so return WAL_RETRY. The
@@ -68954,6 +68971,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
68954
68971
  rc = SQLITE_BUSY_RECOVERY;
68955
68972
  }
68956
68973
  }
68974
+ walDisableBlocking(pWal);
68957
68975
  if( rc!=SQLITE_OK ){
68958
68976
  return rc;
68959
68977
  }
@@ -69641,6 +69659,7 @@ SQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *p
69641
69659
  if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);
69642
69660
  }
69643
69661
  SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; )
69662
+ pWal->iReCksum = 0;
69644
69663
  }
69645
69664
  return rc;
69646
69665
  }
@@ -69688,6 +69707,9 @@ SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
69688
69707
  walCleanupHash(pWal);
69689
69708
  }
69690
69709
  SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; )
69710
+ if( pWal->iReCksum>pWal->hdr.mxFrame ){
69711
+ pWal->iReCksum = 0;
69712
+ }
69691
69713
  }
69692
69714
 
69693
69715
  return rc;
@@ -75228,6 +75250,13 @@ static SQLITE_NOINLINE int btreeBeginTrans(
75228
75250
  (void)sqlite3PagerWalWriteLock(pPager, 0);
75229
75251
  unlockBtreeIfUnused(pBt);
75230
75252
  }
75253
+ #if defined(SQLITE_ENABLE_SETLK_TIMEOUT)
75254
+ if( rc==SQLITE_BUSY_TIMEOUT ){
75255
+ /* If a blocking lock timed out, break out of the loop here so that
75256
+ ** the busy-handler is not invoked. */
75257
+ break;
75258
+ }
75259
+ #endif
75231
75260
  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
75232
75261
  btreeInvokeBusyHandler(pBt) );
75233
75262
  sqlite3PagerWalDb(pPager, 0);
@@ -105039,7 +105068,7 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
105039
105068
  assert( pCsr->eCurType==CURTYPE_SORTER );
105040
105069
  assert( sizeof(KeyInfo) + UMXV(pCsr->pKeyInfo->nKeyField)*sizeof(CollSeq*)
105041
105070
  < 0x7fffffff );
105042
- szKeyInfo = SZ_KEYINFO(pCsr->pKeyInfo->nKeyField+1);
105071
+ szKeyInfo = SZ_KEYINFO(pCsr->pKeyInfo->nKeyField);
105043
105072
  sz = SZ_VDBESORTER(nWorker+1);
105044
105073
 
105045
105074
  pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);
@@ -110389,7 +110418,9 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){
110389
110418
  pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
110390
110419
  );
110391
110420
  }
110392
- if( op==TK_VECTOR ){
110421
+ if( op==TK_VECTOR
110422
+ || (op==TK_FUNCTION && pExpr->affExpr==SQLITE_AFF_DEFER)
110423
+ ){
110393
110424
  assert( ExprUseXList(pExpr) );
110394
110425
  return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr);
110395
110426
  }
@@ -110582,7 +110613,9 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){
110582
110613
  p = p->pLeft;
110583
110614
  continue;
110584
110615
  }
110585
- if( op==TK_VECTOR ){
110616
+ if( op==TK_VECTOR
110617
+ || (op==TK_FUNCTION && p->affExpr==SQLITE_AFF_DEFER)
110618
+ ){
110586
110619
  assert( ExprUseXList(p) );
110587
110620
  p = p->x.pList->a[0].pExpr;
110588
110621
  continue;
@@ -111456,7 +111489,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){
111456
111489
  return pLeft;
111457
111490
  }else{
111458
111491
  u32 f = pLeft->flags | pRight->flags;
111459
- if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse))==EP_IsFalse
111492
+ if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse|EP_HasFunc))==EP_IsFalse
111460
111493
  && !IN_RENAME_OBJECT
111461
111494
  ){
111462
111495
  sqlite3ExprDeferredDelete(pParse, pLeft);
@@ -115210,6 +115243,12 @@ expr_code_doover:
115210
115243
  sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
115211
115244
  return target;
115212
115245
  }
115246
+ case TK_NULLS: {
115247
+ /* Set a range of registers to NULL. pExpr->y.nReg registers starting
115248
+ ** with target */
115249
+ sqlite3VdbeAddOp3(v, OP_Null, 0, target, target + pExpr->y.nReg - 1);
115250
+ return target;
115251
+ }
115213
115252
  default: {
115214
115253
  /* Make NULL the default case so that if a bug causes an illegal
115215
115254
  ** Expr node to be passed into this function, it will be handled
@@ -115894,6 +115933,25 @@ SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce(
115894
115933
  return regDest;
115895
115934
  }
115896
115935
 
115936
+ /*
115937
+ ** Make arrangements to invoke OP_Null on a range of registers
115938
+ ** during initialization.
115939
+ */
115940
+ SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3ExprNullRegisterRange(
115941
+ Parse *pParse, /* Parsing context */
115942
+ int iReg, /* First register to set to NULL */
115943
+ int nReg /* Number of sequential registers to NULL out */
115944
+ ){
115945
+ u8 okConstFactor = pParse->okConstFactor;
115946
+ Expr t;
115947
+ memset(&t, 0, sizeof(t));
115948
+ t.op = TK_NULLS;
115949
+ t.y.nReg = nReg;
115950
+ pParse->okConstFactor = 1;
115951
+ sqlite3ExprCodeRunJustOnce(pParse, &t, iReg);
115952
+ pParse->okConstFactor = okConstFactor;
115953
+ }
115954
+
115897
115955
  /*
115898
115956
  ** Generate code to evaluate an expression and store the results
115899
115957
  ** into a register. Return the register number where the results
@@ -117322,7 +117380,9 @@ static void findOrCreateAggInfoColumn(
117322
117380
  ){
117323
117381
  struct AggInfo_col *pCol;
117324
117382
  int k;
117383
+ int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];
117325
117384
 
117385
+ assert( mxTerm <= SMXV(i16) );
117326
117386
  assert( pAggInfo->iFirstReg==0 );
117327
117387
  pCol = pAggInfo->aCol;
117328
117388
  for(k=0; k<pAggInfo->nColumn; k++, pCol++){
@@ -117340,6 +117400,10 @@ static void findOrCreateAggInfoColumn(
117340
117400
  assert( pParse->db->mallocFailed );
117341
117401
  return;
117342
117402
  }
117403
+ if( k>mxTerm ){
117404
+ sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm);
117405
+ k = mxTerm;
117406
+ }
117343
117407
  pCol = &pAggInfo->aCol[k];
117344
117408
  assert( ExprUseYTab(pExpr) );
117345
117409
  pCol->pTab = pExpr->y.pTab;
@@ -117373,6 +117437,7 @@ fix_up_expr:
117373
117437
  if( pExpr->op==TK_COLUMN ){
117374
117438
  pExpr->op = TK_AGG_COLUMN;
117375
117439
  }
117440
+ assert( k <= SMXV(pExpr->iAgg) );
117376
117441
  pExpr->iAgg = (i16)k;
117377
117442
  }
117378
117443
 
@@ -117457,13 +117522,19 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
117457
117522
  ** function that is already in the pAggInfo structure
117458
117523
  */
117459
117524
  struct AggInfo_func *pItem = pAggInfo->aFunc;
117525
+ int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];
117526
+ assert( mxTerm <= SMXV(i16) );
117460
117527
  for(i=0; i<pAggInfo->nFunc; i++, pItem++){
117461
117528
  if( NEVER(pItem->pFExpr==pExpr) ) break;
117462
117529
  if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
117463
117530
  break;
117464
117531
  }
117465
117532
  }
117466
- if( i>=pAggInfo->nFunc ){
117533
+ if( i>mxTerm ){
117534
+ sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm);
117535
+ i = mxTerm;
117536
+ assert( i<pAggInfo->nFunc );
117537
+ }else if( i>=pAggInfo->nFunc ){
117467
117538
  /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
117468
117539
  */
117469
117540
  u8 enc = ENC(pParse->db);
@@ -117517,6 +117588,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
117517
117588
  */
117518
117589
  assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
117519
117590
  ExprSetVVAProperty(pExpr, EP_NoReduce);
117591
+ assert( i <= SMXV(pExpr->iAgg) );
117520
117592
  pExpr->iAgg = (i16)i;
117521
117593
  pExpr->pAggInfo = pAggInfo;
117522
117594
  return WRC_Prune;
@@ -127150,7 +127222,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
127150
127222
  assert( j<=0x7fff );
127151
127223
  if( j<0 ){
127152
127224
  j = pTab->iPKey;
127153
- pIndex->bIdxRowid = 1;
127154
127225
  }else{
127155
127226
  if( pTab->aCol[j].notNull==0 ){
127156
127227
  pIndex->uniqNotNull = 0;
@@ -131975,7 +132046,7 @@ static void concatFuncCore(
131975
132046
  int nSep,
131976
132047
  const char *zSep
131977
132048
  ){
131978
- i64 j, k, n = 0;
132049
+ i64 j, n = 0;
131979
132050
  int i;
131980
132051
  char *z;
131981
132052
  for(i=0; i<argc; i++){
@@ -131989,8 +132060,8 @@ static void concatFuncCore(
131989
132060
  }
131990
132061
  j = 0;
131991
132062
  for(i=0; i<argc; i++){
131992
- k = sqlite3_value_bytes(argv[i]);
131993
- if( k>0 ){
132063
+ if( sqlite3_value_type(argv[i])!=SQLITE_NULL ){
132064
+ int k = sqlite3_value_bytes(argv[i]);
131994
132065
  const char *v = (const char*)sqlite3_value_text(argv[i]);
131995
132066
  if( v!=0 ){
131996
132067
  if( j>0 && nSep>0 ){
@@ -145364,7 +145435,7 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){
145364
145435
  }
145365
145436
  pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iLeftCol);
145366
145437
  sqlite3SrcItemColumnUsed(&pSrc->a[iLeft], iLeftCol);
145367
- if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){
145438
+ if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 && pParse->nErr==0 ){
145368
145439
  /* This branch runs if the query contains one or more RIGHT or FULL
145369
145440
  ** JOINs. If only a single table on the left side of this join
145370
145441
  ** contains the zName column, then this branch is a no-op.
@@ -145380,6 +145451,8 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){
145380
145451
  */
145381
145452
  ExprList *pFuncArgs = 0; /* Arguments to the coalesce() */
145382
145453
  static const Token tkCoalesce = { "coalesce", 8 };
145454
+ assert( pE1!=0 );
145455
+ ExprSetProperty(pE1, EP_CanBeNull);
145383
145456
  while( tableAndColumnIndex(pSrc, iLeft+1, i, zName, &iLeft, &iLeftCol,
145384
145457
  pRight->fg.isSynthUsing)!=0 ){
145385
145458
  if( pSrc->a[iLeft].fg.isUsing==0
@@ -145396,7 +145469,13 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){
145396
145469
  if( pFuncArgs ){
145397
145470
  pFuncArgs = sqlite3ExprListAppend(pParse, pFuncArgs, pE1);
145398
145471
  pE1 = sqlite3ExprFunction(pParse, pFuncArgs, &tkCoalesce, 0);
145472
+ if( pE1 ){
145473
+ pE1->affExpr = SQLITE_AFF_DEFER;
145474
+ }
145399
145475
  }
145476
+ }else if( (pSrc->a[i+1].fg.jointype & JT_LEFT)!=0 && pParse->nErr==0 ){
145477
+ assert( pE1!=0 );
145478
+ ExprSetProperty(pE1, EP_CanBeNull);
145400
145479
  }
145401
145480
  pE2 = sqlite3CreateColumnExpr(db, pSrc, i+1, iRightCol);
145402
145481
  sqlite3SrcItemColumnUsed(pRight, iRightCol);
@@ -149004,9 +149083,9 @@ static int compoundHasDifferentAffinities(Select *p){
149004
149083
  ** from 2015-02-09.)
149005
149084
  **
149006
149085
  ** (3) If the subquery is the right operand of a LEFT JOIN then
149007
- ** (3a) the subquery may not be a join and
149008
- ** (3b) the FROM clause of the subquery may not contain a virtual
149009
- ** table and
149086
+ ** (3a) the subquery may not be a join
149087
+ ** (**) Was (3b): "the FROM clause of the subquery may not contain
149088
+ ** a virtual table"
149010
149089
  ** (**) Was: "The outer query may not have a GROUP BY." This case
149011
149090
  ** is now managed correctly
149012
149091
  ** (3d) the outer query may not be DISTINCT.
@@ -149222,7 +149301,7 @@ static int flattenSubquery(
149222
149301
  */
149223
149302
  if( (pSubitem->fg.jointype & (JT_OUTER|JT_LTORJ))!=0 ){
149224
149303
  if( pSubSrc->nSrc>1 /* (3a) */
149225
- || IsVirtual(pSubSrc->a[0].pSTab) /* (3b) */
149304
+ /**** || IsVirtual(pSubSrc->a[0].pSTab) (3b)-omitted */
149226
149305
  || (p->selFlags & SF_Distinct)!=0 /* (3d) */
149227
149306
  || (pSubitem->fg.jointype & JT_RIGHT)!=0 /* (26) */
149228
149307
  ){
@@ -153123,6 +153202,7 @@ SQLITE_PRIVATE int sqlite3Select(
153123
153202
  sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
153124
153203
  VdbeComment((v, "clear abort flag"));
153125
153204
  sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
153205
+ sqlite3ExprNullRegisterRange(pParse, iAMem, pGroupBy->nExpr);
153126
153206
 
153127
153207
  /* Begin a loop that will extract all source rows in GROUP BY order.
153128
153208
  ** This might involve two separate loops with an OP_Sort in between, or
@@ -160119,7 +160199,9 @@ static Expr *removeUnindexableInClauseTerms(
160119
160199
  int iField;
160120
160200
  assert( (pLoop->aLTerm[i]->eOperator & (WO_OR|WO_AND))==0 );
160121
160201
  iField = pLoop->aLTerm[i]->u.x.iField - 1;
160122
- if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
160202
+ if( NEVER(pOrigRhs->a[iField].pExpr==0) ){
160203
+ continue; /* Duplicate PK column */
160204
+ }
160123
160205
  pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
160124
160206
  pOrigRhs->a[iField].pExpr = 0;
160125
160207
  if( pRhs ) pRhs->a[pRhs->nExpr-1].u.x.iOrderByCol = iField+1;
@@ -160216,7 +160298,7 @@ static SQLITE_NOINLINE void codeINTerm(
160216
160298
  return;
160217
160299
  }
160218
160300
  }
160219
- for(i=iEq;i<pLoop->nLTerm; i++){
160301
+ for(i=iEq; i<pLoop->nLTerm; i++){
160220
160302
  assert( pLoop->aLTerm[i]!=0 );
160221
160303
  if( pLoop->aLTerm[i]->pExpr==pX ) nEq++;
160222
160304
  }
@@ -160225,22 +160307,13 @@ static SQLITE_NOINLINE void codeINTerm(
160225
160307
  if( !ExprUseXSelect(pX) || pX->x.pSelect->pEList->nExpr==1 ){
160226
160308
  eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab);
160227
160309
  }else{
160228
- Expr *pExpr = pTerm->pExpr;
160229
- if( pExpr->iTable==0 || !ExprHasProperty(pExpr, EP_Subrtn) ){
160230
- sqlite3 *db = pParse->db;
160231
- pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX);
160232
- if( !db->mallocFailed ){
160233
- aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq);
160234
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap,&iTab);
160235
- pExpr->iTable = iTab;
160236
- }
160237
- sqlite3ExprDelete(db, pX);
160238
- }else{
160239
- int n = sqlite3ExprVectorSize(pX->pLeft);
160240
- aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*MAX(nEq,n));
160241
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab);
160310
+ sqlite3 *db = pParse->db;
160311
+ Expr *pXMod = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX);
160312
+ if( !db->mallocFailed ){
160313
+ aiMap = (int*)sqlite3DbMallocZero(db, sizeof(int)*nEq);
160314
+ eType = sqlite3FindInIndex(pParse, pXMod, IN_INDEX_LOOP, 0, aiMap, &iTab);
160242
160315
  }
160243
- pX = pExpr;
160316
+ sqlite3ExprDelete(db, pXMod);
160244
160317
  }
160245
160318
 
160246
160319
  if( eType==IN_INDEX_INDEX_DESC ){
@@ -160270,7 +160343,7 @@ static SQLITE_NOINLINE void codeINTerm(
160270
160343
  if( pIn ){
160271
160344
  int iMap = 0; /* Index in aiMap[] */
160272
160345
  pIn += i;
160273
- for(i=iEq;i<pLoop->nLTerm; i++){
160346
+ for(i=iEq; i<pLoop->nLTerm; i++){
160274
160347
  if( pLoop->aLTerm[i]->pExpr==pX ){
160275
160348
  int iOut = iTarget + i - iEq;
160276
160349
  if( eType==IN_INDEX_ROWID ){
@@ -161722,12 +161795,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
161722
161795
  if( pLevel->iLeftJoin==0 ){
161723
161796
  /* If a partial index is driving the loop, try to eliminate WHERE clause
161724
161797
  ** terms from the query that must be true due to the WHERE clause of
161725
- ** the partial index.
161798
+ ** the partial index. This optimization does not work on an outer join,
161799
+ ** as shown by:
161726
161800
  **
161727
- ** 2019-11-02 ticket 623eff57e76d45f6: This optimization does not work
161728
- ** for a LEFT JOIN.
161801
+ ** 2019-11-02 ticket 623eff57e76d45f6 (LEFT JOIN)
161802
+ ** 2025-05-29 forum post 7dee41d32506c4ae (RIGHT JOIN)
161729
161803
  */
161730
- if( pIdx->pPartIdxWhere ){
161804
+ if( pIdx->pPartIdxWhere && pLevel->pRJ==0 ){
161731
161805
  whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
161732
161806
  }
161733
161807
  }else{
@@ -163400,30 +163474,42 @@ static void exprAnalyzeOrTerm(
163400
163474
  ** 1. The SQLITE_Transitive optimization must be enabled
163401
163475
  ** 2. Must be either an == or an IS operator
163402
163476
  ** 3. Not originating in the ON clause of an OUTER JOIN
163403
- ** 4. The affinities of A and B must be compatible
163404
- ** 5a. Both operands use the same collating sequence OR
163405
- ** 5b. The overall collating sequence is BINARY
163477
+ ** 4. The operator is not IS or else the query does not contain RIGHT JOIN
163478
+ ** 5. The affinities of A and B must be compatible
163479
+ ** 6a. Both operands use the same collating sequence OR
163480
+ ** 6b. The overall collating sequence is BINARY
163406
163481
  ** If this routine returns TRUE, that means that the RHS can be substituted
163407
163482
  ** for the LHS anyplace else in the WHERE clause where the LHS column occurs.
163408
163483
  ** This is an optimization. No harm comes from returning 0. But if 1 is
163409
163484
  ** returned when it should not be, then incorrect answers might result.
163410
163485
  */
163411
- static int termIsEquivalence(Parse *pParse, Expr *pExpr){
163486
+ static int termIsEquivalence(Parse *pParse, Expr *pExpr, SrcList *pSrc){
163412
163487
  char aff1, aff2;
163413
163488
  CollSeq *pColl;
163414
- if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0;
163415
- if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0;
163416
- if( ExprHasProperty(pExpr, EP_OuterON) ) return 0;
163489
+ if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0; /* (1) */
163490
+ if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0; /* (2) */
163491
+ if( ExprHasProperty(pExpr, EP_OuterON) ) return 0; /* (3) */
163492
+ assert( pSrc!=0 );
163493
+ if( pExpr->op==TK_IS
163494
+ && pSrc->nSrc
163495
+ && (pSrc->a[0].fg.jointype & JT_LTORJ)!=0
163496
+ ){
163497
+ return 0; /* (4) */
163498
+ }
163417
163499
  aff1 = sqlite3ExprAffinity(pExpr->pLeft);
163418
163500
  aff2 = sqlite3ExprAffinity(pExpr->pRight);
163419
163501
  if( aff1!=aff2
163420
163502
  && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
163421
163503
  ){
163422
- return 0;
163504
+ return 0; /* (5) */
163423
163505
  }
163424
163506
  pColl = sqlite3ExprCompareCollSeq(pParse, pExpr);
163425
- if( sqlite3IsBinary(pColl) ) return 1;
163426
- return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
163507
+ if( !sqlite3IsBinary(pColl)
163508
+ && !sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight)
163509
+ ){
163510
+ return 0; /* (6) */
163511
+ }
163512
+ return 1;
163427
163513
  }
163428
163514
 
163429
163515
  /*
@@ -163688,8 +163774,8 @@ static void exprAnalyze(
163688
163774
  if( op==TK_IS ) pNew->wtFlags |= TERM_IS;
163689
163775
  pTerm = &pWC->a[idxTerm];
163690
163776
  pTerm->wtFlags |= TERM_COPIED;
163691
-
163692
- if( termIsEquivalence(pParse, pDup) ){
163777
+ assert( pWInfo->pTabList!=0 );
163778
+ if( termIsEquivalence(pParse, pDup, pWInfo->pTabList) ){
163693
163779
  pTerm->eOperator |= WO_EQUIV;
163694
163780
  eExtraOp = WO_EQUIV;
163695
163781
  }
@@ -167615,6 +167701,7 @@ static int whereLoopAddBtreeIndex(
167615
167701
  if( ExprUseXSelect(pExpr) ){
167616
167702
  /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
167617
167703
  int i;
167704
+ int bRedundant = 0;
167618
167705
  nIn = 46; assert( 46==sqlite3LogEst(25) );
167619
167706
 
167620
167707
  /* The expression may actually be of the form (x, y) IN (SELECT...).
@@ -167623,7 +167710,20 @@ static int whereLoopAddBtreeIndex(
167623
167710
  ** for each such term. The following loop checks that pTerm is the
167624
167711
  ** first such term in use, and sets nIn back to 0 if it is not. */
167625
167712
  for(i=0; i<pNew->nLTerm-1; i++){
167626
- if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
167713
+ if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ){
167714
+ nIn = 0;
167715
+ if( pNew->aLTerm[i]->u.x.iField == pTerm->u.x.iField ){
167716
+ /* Detect when two or more columns of an index match the same
167717
+ ** column of a vector IN operater, and avoid adding the column
167718
+ ** to the WhereLoop more than once. See tag-20250707-01
167719
+ ** in test/rowvalue.test */
167720
+ bRedundant = 1;
167721
+ }
167722
+ }
167723
+ }
167724
+ if( bRedundant ){
167725
+ pNew->nLTerm--;
167726
+ continue;
167627
167727
  }
167628
167728
  }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
167629
167729
  /* "x IN (value, value, ...)" */
@@ -167855,7 +167955,7 @@ static int whereLoopAddBtreeIndex(
167855
167955
  if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
167856
167956
  && pNew->u.btree.nEq<pProbe->nColumn
167857
167957
  && (pNew->u.btree.nEq<pProbe->nKeyCol ||
167858
- (pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY && !pProbe->bIdxRowid))
167958
+ pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
167859
167959
  ){
167860
167960
  if( pNew->u.btree.nEq>3 ){
167861
167961
  sqlite3ProgressCheck(pParse);
@@ -168398,6 +168498,7 @@ static int whereLoopAddBtree(
168398
168498
  pNew->u.btree.nEq = 0;
168399
168499
  pNew->u.btree.nBtm = 0;
168400
168500
  pNew->u.btree.nTop = 0;
168501
+ pNew->u.btree.nDistinctCol = 0;
168401
168502
  pNew->nSkip = 0;
168402
168503
  pNew->nLTerm = 0;
168403
168504
  pNew->iSortIdx = 0;
@@ -169466,8 +169567,6 @@ static i8 wherePathSatisfiesOrderBy(
169466
169567
  obSat = obDone;
169467
169568
  }
169468
169569
  break;
169469
- }else if( wctrlFlags & WHERE_DISTINCTBY ){
169470
- pLoop->u.btree.nDistinctCol = 0;
169471
169570
  }
169472
169571
  iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
169473
169572
 
@@ -179830,12 +179929,21 @@ static YYACTIONTYPE yy_reduce(
179830
179929
  ** expr1 IN ()
179831
179930
  ** expr1 NOT IN ()
179832
179931
  **
179833
- ** simplify to constants 0 (false) and 1 (true), respectively,
179834
- ** regardless of the value of expr1.
179932
+ ** simplify to constants 0 (false) and 1 (true), respectively.
179933
+ **
179934
+ ** Except, do not apply this optimization if expr1 contains a function
179935
+ ** because that function might be an aggregate (we don't know yet whether
179936
+ ** it is or not) and if it is an aggregate, that could change the meaning
179937
+ ** of the whole query.
179835
179938
  */
179836
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
179837
- yymsp[-4].minor.yy590 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
179838
- if( yymsp[-4].minor.yy590 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy590);
179939
+ Expr *pB = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
179940
+ if( pB ) sqlite3ExprIdToTrueFalse(pB);
179941
+ if( !ExprHasProperty(yymsp[-4].minor.yy590, EP_HasFunc) ){
179942
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
179943
+ yymsp[-4].minor.yy590 = pB;
179944
+ }else{
179945
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_OR : TK_AND, pB, yymsp[-4].minor.yy590);
179946
+ }
179839
179947
  }else{
179840
179948
  Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
179841
179949
  if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
@@ -181441,7 +181549,7 @@ static int getToken(const unsigned char **pz){
181441
181549
  int t; /* Token type to return */
181442
181550
  do {
181443
181551
  z += sqlite3GetToken(z, &t);
181444
- }while( t==TK_SPACE );
181552
+ }while( t==TK_SPACE || t==TK_COMMENT );
181445
181553
  if( t==TK_ID
181446
181554
  || t==TK_STRING
181447
181555
  || t==TK_JOIN_KW
@@ -184391,6 +184499,7 @@ SQLITE_API int sqlite3_setlk_timeout(sqlite3 *db, int ms, int flags){
184391
184499
  #endif
184392
184500
  if( ms<-1 ) return SQLITE_RANGE;
184393
184501
  #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
184502
+ sqlite3_mutex_enter(db->mutex);
184394
184503
  db->setlkTimeout = ms;
184395
184504
  db->setlkFlags = flags;
184396
184505
  sqlite3BtreeEnterAll(db);
@@ -184402,6 +184511,7 @@ SQLITE_API int sqlite3_setlk_timeout(sqlite3 *db, int ms, int flags){
184402
184511
  }
184403
184512
  }
184404
184513
  sqlite3BtreeLeaveAll(db);
184514
+ sqlite3_mutex_leave(db->mutex);
184405
184515
  #endif
184406
184516
  #if !defined(SQLITE_ENABLE_API_ARMOR) && !defined(SQLITE_ENABLE_SETLK_TIMEOUT)
184407
184517
  UNUSED_PARAMETER(db);
@@ -209021,8 +209131,10 @@ static int jsonBlobChangePayloadSize(
209021
209131
  nExtra = 1;
209022
209132
  }else if( szType==13 ){
209023
209133
  nExtra = 2;
209024
- }else{
209134
+ }else if( szType==14 ){
209025
209135
  nExtra = 4;
209136
+ }else{
209137
+ nExtra = 8;
209026
209138
  }
209027
209139
  if( szPayload<=11 ){
209028
209140
  nNeeded = 0;
@@ -213407,6 +213519,8 @@ SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3 *db){
213407
213519
  #endif
213408
213520
  SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */
213409
213521
 
213522
+ /* #include <stddef.h> */
213523
+
213410
213524
  /*
213411
213525
  ** If building separately, we will need some setup that is normally
213412
213526
  ** found in sqliteInt.h
@@ -235449,6 +235563,7 @@ SQLITE_EXTENSION_INIT1
235449
235563
 
235450
235564
  /* #include <string.h> */
235451
235565
  /* #include <assert.h> */
235566
+ /* #include <stddef.h> */
235452
235567
 
235453
235568
  #ifndef SQLITE_AMALGAMATION
235454
235569
 
@@ -246089,9 +246204,9 @@ static void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){
246089
246204
  ** leave an error in the Fts5Index object.
246090
246205
  */
246091
246206
  static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){
246092
- const int nTomb = pIter->pSeg->nPgTombstone;
246207
+ const i64 nTomb = (i64)pIter->pSeg->nPgTombstone;
246093
246208
  if( nTomb>0 ){
246094
- int nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1);
246209
+ i64 nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1);
246095
246210
  Fts5TombstoneArray *pNew;
246096
246211
  pNew = (Fts5TombstoneArray*)sqlite3Fts5MallocZero(&p->rc, nByte);
246097
246212
  if( pNew ){
@@ -257192,7 +257307,7 @@ static void fts5SourceIdFunc(
257192
257307
  ){
257193
257308
  assert( nArg==0 );
257194
257309
  UNUSED_PARAM2(nArg, apUnused);
257195
- sqlite3_result_text(pCtx, "fts5: 2025-05-29 14:26:00 dfc790f998f450d9c35e3ba1c8c89c17466cb559f87b0239e4aab9d34e28f742", -1, SQLITE_TRANSIENT);
257310
+ sqlite3_result_text(pCtx, "fts5: 2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45e20a3", -1, SQLITE_TRANSIENT);
257196
257311
  }
257197
257312
 
257198
257313
  /*
@@ -258007,6 +258122,7 @@ static int fts5StorageDeleteFromIndex(
258007
258122
  for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){
258008
258123
  if( pConfig->abUnindexed[iCol-1]==0 ){
258009
258124
  sqlite3_value *pVal = 0;
258125
+ sqlite3_value *pFree = 0;
258010
258126
  const char *pText = 0;
258011
258127
  int nText = 0;
258012
258128
  const char *pLoc = 0;
@@ -258023,11 +258139,22 @@ static int fts5StorageDeleteFromIndex(
258023
258139
  if( pConfig->bLocale && sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
258024
258140
  rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
258025
258141
  }else{
258026
- pText = (const char*)sqlite3_value_text(pVal);
258027
- nText = sqlite3_value_bytes(pVal);
258028
- if( pConfig->bLocale && pSeek ){
258029
- pLoc = (const char*)sqlite3_column_text(pSeek, iCol + pConfig->nCol);
258030
- nLoc = sqlite3_column_bytes(pSeek, iCol + pConfig->nCol);
258142
+ if( sqlite3_value_type(pVal)!=SQLITE_TEXT ){
258143
+ /* Make a copy of the value to work with. This is because the call
258144
+ ** to sqlite3_value_text() below forces the type of the value to
258145
+ ** SQLITE_TEXT, and we may need to use it again later. */
258146
+ pFree = pVal = sqlite3_value_dup(pVal);
258147
+ if( pVal==0 ){
258148
+ rc = SQLITE_NOMEM;
258149
+ }
258150
+ }
258151
+ if( rc==SQLITE_OK ){
258152
+ pText = (const char*)sqlite3_value_text(pVal);
258153
+ nText = sqlite3_value_bytes(pVal);
258154
+ if( pConfig->bLocale && pSeek ){
258155
+ pLoc = (const char*)sqlite3_column_text(pSeek, iCol+pConfig->nCol);
258156
+ nLoc = sqlite3_column_bytes(pSeek, iCol + pConfig->nCol);
258157
+ }
258031
258158
  }
258032
258159
  }
258033
258160
 
@@ -258043,6 +258170,7 @@ static int fts5StorageDeleteFromIndex(
258043
258170
  }
258044
258171
  sqlite3Fts5ClearLocale(pConfig);
258045
258172
  }
258173
+ sqlite3_value_free(pFree);
258046
258174
  }
258047
258175
  }
258048
258176
  if( rc==SQLITE_OK && p->nTotalRow<1 ){