Fossil SCM

Update the built-in SQLite to the latest trunk version.

drh 2025-06-28 23:59 trunk
Commit cdaec3a4312662501ccc8d16396a34b69694fcbfd6073e48c008b8f0615fc737
2 files changed +60 -37 +30 -28
+60 -37
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** 6a5701e6c7be25cba93e55438f950966e1da with changes in files:
21
+** 5508b56fd24016c13981ec280ecdd833007c with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466
** [sqlite_version()] and [sqlite_source_id()].
467467
*/
468468
#define SQLITE_VERSION "3.51.0"
469469
#define SQLITE_VERSION_NUMBER 3051000
470
-#define SQLITE_SOURCE_ID "2025-06-24 15:58:32 6a5701e6c7be25cba93e55438f950966e1dacb32eb2b23a8acc8ac53da6f0a85"
470
+#define SQLITE_SOURCE_ID "2025-06-27 19:02:21 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8"
471471
472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
474474
** KEYWORDS: sqlite3_version sqlite3_sourceid
475475
**
@@ -6355,11 +6355,11 @@
63556355
/*
63566356
** CAPI3REF: Copy And Free SQL Values
63576357
** METHOD: sqlite3_value
63586358
**
63596359
** ^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
63616361
** is a [protected sqlite3_value] object even if the input is not.
63626362
** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
63636363
** memory allocation fails. ^If V is a [pointer value], then the result
63646364
** of sqlite3_value_dup(V) is a NULL value.
63656365
**
@@ -6393,11 +6393,11 @@
63936393
** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
63946394
** when first called if N is less than or equal to zero or if a memory
63956395
** allocation error occurs.
63966396
**
63976397
** ^(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
63996399
** value of N in any subsequent call to sqlite3_aggregate_context() within
64006400
** the same aggregate function instance will not resize the memory
64016401
** allocation.)^ Within the xFinal callback, it is customary to set
64026402
** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
64036403
** pointless memory allocations occur.
@@ -6555,11 +6555,11 @@
65556555
** of as a secret key such that only code that knows the secret key is able
65566556
** to access the associated data.
65576557
**
65586558
** Security Warning: These interfaces should not be exposed in scripting
65596559
** 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
65616561
** can probably also take control of the process.
65626562
**
65636563
** Database connection client data is only available for SQLite
65646564
** version 3.44.0 ([dateof:3.44.0]) and later.
65656565
**
@@ -6669,11 +6669,11 @@
66696669
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
66706670
** is non-negative, then as many bytes (not characters) of the text
66716671
** pointed to by the 2nd parameter are taken as the application-defined
66726672
** function result. If the 3rd parameter is non-negative, then it
66736673
** 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
66756675
** in the string at a byte offset that is less than the value of the 3rd
66766676
** parameter, then the resulting string will contain embedded NULs and the
66776677
** result of expressions operating on strings with embedded NULs is undefined.
66786678
** ^If the 4th parameter to the sqlite3_result_text* interfaces
66796679
** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
@@ -6727,11 +6727,11 @@
67276727
** for the P parameter. ^SQLite invokes D with P as its only argument
67286728
** when SQLite is finished with P. The T parameter should be a static
67296729
** string and preferably a string literal. The sqlite3_result_pointer()
67306730
** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
67316731
**
6732
-** If these routines are called from within the different thread
6732
+** If these routines are called from within a different thread
67336733
** than the one containing the application-defined function that received
67346734
** the [sqlite3_context] pointer, the results are undefined.
67356735
*/
67366736
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
67376737
SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
@@ -7133,11 +7133,11 @@
71337133
/*
71347134
** CAPI3REF: Return The Schema Name For A Database Connection
71357135
** METHOD: sqlite3
71367136
**
71377137
** ^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
71397139
** out of range. An N value of 0 means the main database file. An N of 1 is
71407140
** the "temp" schema. Larger values of N correspond to various ATTACH-ed
71417141
** databases.
71427142
**
71437143
** Space to hold the string that is returned by sqlite3_db_name() is managed
@@ -7228,20 +7228,20 @@
72287228
**
72297229
** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
72307230
** <dd>The SQLITE_TXN_READ state means that the database is currently
72317231
** in a read transaction. Content has been read from the database file
72327232
** 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
72347234
** no other conflicting concurrent write transactions. The transaction
72357235
** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
72367236
** [COMMIT].</dd>
72377237
**
72387238
** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
72397239
** <dd>The SQLITE_TXN_WRITE state means that the database is currently
72407240
** in a write transaction. Content has been written to the database file
72417241
** 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>
72437243
*/
72447244
#define SQLITE_TXN_NONE 0
72457245
#define SQLITE_TXN_READ 1
72467246
#define SQLITE_TXN_WRITE 2
72477247
@@ -7518,11 +7518,11 @@
75187518
75197519
/*
75207520
** CAPI3REF: Impose A Limit On Heap Size
75217521
**
75227522
** 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.
75247524
**
75257525
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
75267526
** soft limit on the amount of heap memory that may be allocated by SQLite.
75277527
** ^SQLite strives to keep heap memory utilization below the soft heap
75287528
** limit by reducing the number of pages held in the page cache
@@ -7576,11 +7576,11 @@
75767576
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
75777577
** from the heap.
75787578
** </ul>)^
75797579
**
75807580
** 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.
75827582
*/
75837583
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
75847584
SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
75857585
75867586
/*
@@ -7691,12 +7691,12 @@
76917691
** be tried also.
76927692
**
76937693
** ^The entry point is zProc.
76947694
** ^(zProc may be 0, in which case SQLite will try to come up with an
76957695
** 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
76987698
** characters in the filename from the last "/" to the first following
76997699
** "." and omitting any initial "lib".)^
77007700
** ^The sqlite3_load_extension() interface returns
77017701
** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
77027702
** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7927,11 +7927,11 @@
79277927
** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
79287928
** is true, then the constraint is assumed to be fully handled by the
79297929
** virtual table and might not be checked again by the byte code.)^ ^(The
79307930
** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
79317931
** 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
79337933
** the constraint may or may not be checked in byte code. In other words,
79347934
** when the omit flag is true there is no guarantee that the constraint will
79357935
** not be checked again using byte code.)^
79367936
**
79377937
** ^The idxNum and idxStr values are recorded and passed into the
@@ -7953,11 +7953,11 @@
79537953
** will be returned by the strategy.
79547954
**
79557955
** The xBestIndex method may optionally populate the idxFlags field with a
79567956
** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
79577957
** [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
79597959
** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
79607960
** return at most one row.
79617961
**
79627962
** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
79637963
** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -8529,11 +8529,11 @@
85298529
** function that calls sqlite3_initialize().
85308530
**
85318531
** ^The sqlite3_mutex_alloc() routine allocates a new
85328532
** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
85338533
** 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
85358535
** integer constants:
85368536
**
85378537
** <ul>
85388538
** <li> SQLITE_MUTEX_FAST
85398539
** <li> SQLITE_MUTEX_RECURSIVE
@@ -8762,11 +8762,11 @@
87628762
87638763
/*
87648764
** CAPI3REF: Retrieve the mutex for a database connection
87658765
** METHOD: sqlite3
87668766
**
8767
-** ^This interface returns a pointer the [sqlite3_mutex] object that
8767
+** ^This interface returns a pointer to the [sqlite3_mutex] object that
87688768
** serializes access to the [database connection] given in the argument
87698769
** when the [threading mode] is Serialized.
87708770
** ^If the [threading mode] is Single-thread or Multi-thread then this
87718771
** routine returns a NULL pointer.
87728772
*/
@@ -8885,11 +8885,11 @@
88858885
88868886
/*
88878887
** CAPI3REF: SQL Keyword Checking
88888888
**
88898889
** 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
88918891
** whether or not a specific identifier needs to be escaped (for example,
88928892
** by enclosing in double-quotes) so as not to confuse the parser.
88938893
**
88948894
** The sqlite3_keyword_count() interface returns the number of distinct
88958895
** keywords understood by SQLite.
@@ -9053,11 +9053,11 @@
90539053
**
90549054
** ^The [sqlite3_str_value(X)] method returns a pointer to the current
90559055
** content of the dynamic string under construction in X. The value
90569056
** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
90579057
** 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
90599059
** [sqlite3_str_value(X)] after any subsequent method call on the same
90609060
** object. ^Applications may change the content of the string returned
90619061
** by [sqlite3_str_value(X)] as long as they do not write into any bytes
90629062
** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
90639063
** write any byte after any subsequent sqlite3_str method call.
@@ -9139,11 +9139,11 @@
91399139
** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
91409140
** <dd>This parameter returns the number of bytes of page cache
91419141
** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
91429142
** buffer and where forced to overflow to [sqlite3_malloc()]. The
91439143
** 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
91459145
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
91469146
** no space was left in the page cache.</dd>)^
91479147
**
91489148
** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
91499149
** <dd>This parameter records the largest memory allocation request
@@ -9223,53 +9223,55 @@
92239223
** checked out.</dd>)^
92249224
**
92259225
** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
92269226
** <dd>This parameter returns the number of malloc attempts that were
92279227
** 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>)^
92299229
**
92309230
** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
92319231
** ^(<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
92339233
** been satisfied using lookaside memory but failed due to the amount of
92349234
** memory requested being larger than the lookaside slot size.
92359235
** Only the high-water value is meaningful;
9236
-** the current value is always zero.)^
9236
+** the current value is always zero.</dd>)^
92379237
**
92389238
** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
92399239
** ^(<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
92419241
** been satisfied using lookaside memory but failed due to all lookaside
92429242
** memory already being in use.
92439243
** Only the high-water value is meaningful;
9244
-** the current value is always zero.)^
9244
+** the current value is always zero.</dd>)^
92459245
**
92469246
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
92479247
** <dd>This parameter returns the approximate number of bytes of heap
92489248
** memory used by all pager caches associated with the database connection.)^
92499249
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
9250
+** </dd>
92509251
**
92519252
** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
92529253
** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
92539254
** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
92549255
** pager cache is shared between two or more connections the bytes of heap
92559256
** memory used by that pager cache is divided evenly between the attached
92569257
** connections.)^ In other words, if none of the pager caches associated
92579258
** 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
92599260
** shared, the value returned by this call will be smaller than that returned
92609261
** 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>
92629263
**
92639264
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
92649265
** <dd>This parameter returns the approximate number of bytes of heap
92659266
** memory used to store the schema for all databases associated
92669267
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
92679268
** ^The full amount of memory used by the schemas is reported, even if the
92689269
** schema memory is shared with other database connections due to
92699270
** [shared cache mode] being enabled.
92709271
** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
9272
+** </dd>
92719273
**
92729274
** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
92739275
** <dd>This parameter returns the approximate number of bytes of heap
92749276
** and lookaside memory used by all prepared statements associated with
92759277
** the database connection.)^
@@ -9302,11 +9304,11 @@
93029304
** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
93039305
** <dd>This parameter returns the number of dirty cache entries that have
93049306
** been written to disk in the middle of a transaction due to the page
93059307
** cache overflowing. Transactions are more efficient if they are written
93069308
** 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
93089310
** inefficiencies that can be resolved by increasing the cache size.
93099311
** </dd>
93109312
**
93119313
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
93129314
** <dd>This parameter returns zero for the current value if and only if
@@ -15440,12 +15442,12 @@
1544015442
/*
1544115443
** Macro SMXV(n) return the maximum value that can be held in variable n,
1544215444
** assuming n is a signed integer type. UMXV(n) is similar for unsigned
1544315445
** integer types.
1544415446
*/
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)
1544715449
1544815450
/*
1544915451
** Round up a number to the next larger multiple of 8. This is used
1545015452
** to force 8-byte alignment on 64-bit architectures.
1545115453
**
@@ -19268,21 +19270,21 @@
1926819270
struct AggInfo {
1926919271
u8 directMode; /* Direct rendering mode means take data directly
1927019272
** from source tables rather than from accumulators */
1927119273
u8 useSortingIdx; /* In direct mode, reference the sorting index rather
1927219274
** than the source table */
19273
- u16 nSortingColumn; /* Number of columns in the sorting index */
19275
+ u32 nSortingColumn; /* Number of columns in the sorting index */
1927419276
int sortingIdx; /* Cursor number of the sorting index */
1927519277
int sortingIdxPTab; /* Cursor number of pseudo-table */
1927619278
int iFirstReg; /* First register in range for aCol[] and aFunc[] */
1927719279
ExprList *pGroupBy; /* The group by clause */
1927819280
struct AggInfo_col { /* For each column used in source tables */
1927919281
Table *pTab; /* Source table */
1928019282
Expr *pCExpr; /* The original expression */
1928119283
int iTable; /* Cursor number of the source table */
19282
- i16 iColumn; /* Column number within the source table */
19283
- i16 iSorterColumn; /* Column number in the sorting index */
19284
+ int iColumn; /* Column number within the source table */
19285
+ int iSorterColumn; /* Column number in the sorting index */
1928419286
} *aCol;
1928519287
int nColumn; /* Number of used entries in aCol[] */
1928619288
int nAccumulator; /* Number of columns that show through to the output.
1928719289
** Additional columns are used only as parameters to
1928819290
** aggregate functions */
@@ -80351,11 +80353,16 @@
8035180353
8035280354
/* If the sibling pages are not leaves, ensure that the right-child pointer
8035380355
** of the right-most new sibling page is set to the value that was
8035480356
** originally in the same field of the right-most old sibling page. */
8035580357
if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){
80356
- MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1];
80358
+ MemPage *pOld;
80359
+ if( nNew>nOld ){
80360
+ pOld = apNew[nOld-1];
80361
+ }else{
80362
+ pOld = apOld[nOld-1];
80363
+ }
8035780364
memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);
8035880365
}
8035980366
8036080367
/* Make any required updates to pointer map entries associated with
8036180368
** cells stored on sibling pages following the balance operation. Pointer
@@ -93911,10 +93918,12 @@
9391193918
rc = SQLITE_MISUSE_BKPT;
9391293919
goto preupdate_new_out;
9391393920
}
9391493921
if( p->pPk && p->op!=SQLITE_UPDATE ){
9391593922
iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
93923
+ }else if( iIdx >= p->pTab->nCol ){
93924
+ return SQLITE_MISUSE_BKPT;
9391693925
}else{
9391793926
iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
9391893927
}
9391993928
9392093929
if( iStore>=p->pCsr->nField || iStore<0 ){
@@ -117522,11 +117531,13 @@
117522117531
AggInfo *pAggInfo, /* The AggInfo object to search and/or modify */
117523117532
Expr *pExpr /* Expr describing the column to find or insert */
117524117533
){
117525117534
struct AggInfo_col *pCol;
117526117535
int k;
117536
+ int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];
117527117537
117538
+ assert( mxTerm <= SMXV(i16) );
117528117539
assert( pAggInfo->iFirstReg==0 );
117529117540
pCol = pAggInfo->aCol;
117530117541
for(k=0; k<pAggInfo->nColumn; k++, pCol++){
117531117542
if( pCol->pCExpr==pExpr ) return;
117532117543
if( pCol->iTable==pExpr->iTable
@@ -117539,10 +117550,14 @@
117539117550
k = addAggInfoColumn(pParse->db, pAggInfo);
117540117551
if( k<0 ){
117541117552
/* OOM on resize */
117542117553
assert( pParse->db->mallocFailed );
117543117554
return;
117555
+ }
117556
+ if( k>mxTerm ){
117557
+ sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm);
117558
+ k = mxTerm;
117544117559
}
117545117560
pCol = &pAggInfo->aCol[k];
117546117561
assert( ExprUseYTab(pExpr) );
117547117562
pCol->pTab = pExpr->y.pTab;
117548117563
pCol->iTable = pExpr->iTable;
@@ -117573,10 +117588,11 @@
117573117588
assert( pExpr->pAggInfo==0 || pExpr->pAggInfo==pAggInfo );
117574117589
pExpr->pAggInfo = pAggInfo;
117575117590
if( pExpr->op==TK_COLUMN ){
117576117591
pExpr->op = TK_AGG_COLUMN;
117577117592
}
117593
+ assert( k <= SMXV(pExpr->iAgg) );
117578117594
pExpr->iAgg = (i16)k;
117579117595
}
117580117596
117581117597
/*
117582117598
** This is the xExprCallback for a tree walker. It is used to
@@ -117657,17 +117673,23 @@
117657117673
){
117658117674
/* Check to see if pExpr is a duplicate of another aggregate
117659117675
** function that is already in the pAggInfo structure
117660117676
*/
117661117677
struct AggInfo_func *pItem = pAggInfo->aFunc;
117678
+ int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];
117679
+ assert( mxTerm <= SMXV(i16) );
117662117680
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
117663117681
if( NEVER(pItem->pFExpr==pExpr) ) break;
117664117682
if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
117665117683
break;
117666117684
}
117667117685
}
117668
- if( i>=pAggInfo->nFunc ){
117686
+ if( i>mxTerm ){
117687
+ sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm);
117688
+ i = mxTerm;
117689
+ assert( i<pAggInfo->nFunc );
117690
+ }else if( i>=pAggInfo->nFunc ){
117669117691
/* pExpr is original. Make a new entry in pAggInfo->aFunc[]
117670117692
*/
117671117693
u8 enc = ENC(pParse->db);
117672117694
i = addAggInfoFunc(pParse->db, pAggInfo);
117673117695
if( i>=0 ){
@@ -117717,10 +117739,11 @@
117717117739
}
117718117740
/* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
117719117741
*/
117720117742
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
117721117743
ExprSetVVAProperty(pExpr, EP_NoReduce);
117744
+ assert( i <= SMXV(pExpr->iAgg) );
117722117745
pExpr->iAgg = (i16)i;
117723117746
pExpr->pAggInfo = pAggInfo;
117724117747
return WRC_Prune;
117725117748
}else{
117726117749
return WRC_Continue;
@@ -257480,11 +257503,11 @@
257480257503
int nArg, /* Number of args */
257481257504
sqlite3_value **apUnused /* Function arguments */
257482257505
){
257483257506
assert( nArg==0 );
257484257507
UNUSED_PARAM2(nArg, apUnused);
257485
- sqlite3_result_text(pCtx, "fts5: 2025-06-24 15:58:32 6a5701e6c7be25cba93e55438f950966e1dacb32eb2b23a8acc8ac53da6f0a85", -1, SQLITE_TRANSIENT);
257508
+ sqlite3_result_text(pCtx, "fts5: 2025-06-27 19:02:21 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8", -1, SQLITE_TRANSIENT);
257486257509
}
257487257510
257488257511
/*
257489257512
** Implementation of fts5_locale(LOCALE, TEXT) function.
257490257513
**
257491257514
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
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 ** The content in this amalgamation comes from Fossil check-in
21 ** 6a5701e6c7be25cba93e55438f950966e1da with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-06-24 15:58:32 6a5701e6c7be25cba93e55438f950966e1dacb32eb2b23a8acc8ac53da6f0a85"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -6355,11 +6355,11 @@
6355 /*
6356 ** CAPI3REF: Copy And Free SQL Values
6357 ** METHOD: sqlite3_value
6358 **
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
6361 ** is a [protected sqlite3_value] object even if the input is not.
6362 ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
6363 ** memory allocation fails. ^If V is a [pointer value], then the result
6364 ** of sqlite3_value_dup(V) is a NULL value.
6365 **
@@ -6393,11 +6393,11 @@
6393 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
6394 ** when first called if N is less than or equal to zero or if a memory
6395 ** allocation error occurs.
6396 **
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
6399 ** value of N in any subsequent call to sqlite3_aggregate_context() within
6400 ** the same aggregate function instance will not resize the memory
6401 ** allocation.)^ Within the xFinal callback, it is customary to set
6402 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6403 ** pointless memory allocations occur.
@@ -6555,11 +6555,11 @@
6555 ** of as a secret key such that only code that knows the secret key is able
6556 ** to access the associated data.
6557 **
6558 ** Security Warning: These interfaces should not be exposed in scripting
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
6561 ** can probably also take control of the process.
6562 **
6563 ** Database connection client data is only available for SQLite
6564 ** version 3.44.0 ([dateof:3.44.0]) and later.
6565 **
@@ -6669,11 +6669,11 @@
6669 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6670 ** is non-negative, then as many bytes (not characters) of the text
6671 ** pointed to by the 2nd parameter are taken as the application-defined
6672 ** function result. If the 3rd parameter is non-negative, then it
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
6675 ** in the string at a byte offset that is less than the value of the 3rd
6676 ** parameter, then the resulting string will contain embedded NULs and the
6677 ** result of expressions operating on strings with embedded NULs is undefined.
6678 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
6679 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
@@ -6727,11 +6727,11 @@
6727 ** for the P parameter. ^SQLite invokes D with P as its only argument
6728 ** when SQLite is finished with P. The T parameter should be a static
6729 ** string and preferably a string literal. The sqlite3_result_pointer()
6730 ** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
6731 **
6732 ** If these routines are called from within the different thread
6733 ** than the one containing the application-defined function that received
6734 ** the [sqlite3_context] pointer, the results are undefined.
6735 */
6736 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
6737 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
@@ -7133,11 +7133,11 @@
7133 /*
7134 ** CAPI3REF: Return The Schema Name For A Database Connection
7135 ** METHOD: sqlite3
7136 **
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
7139 ** out of range. An N value of 0 means the main database file. An N of 1 is
7140 ** the "temp" schema. Larger values of N correspond to various ATTACH-ed
7141 ** databases.
7142 **
7143 ** Space to hold the string that is returned by sqlite3_db_name() is managed
@@ -7228,20 +7228,20 @@
7228 **
7229 ** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
7230 ** <dd>The SQLITE_TXN_READ state means that the database is currently
7231 ** in a read transaction. Content has been read from the database file
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
7234 ** no other conflicting concurrent write transactions. The transaction
7235 ** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
7236 ** [COMMIT].</dd>
7237 **
7238 ** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
7239 ** <dd>The SQLITE_TXN_WRITE state means that the database is currently
7240 ** in a write transaction. Content has been written to the database file
7241 ** but has not yet committed. The transaction state will change to
7242 ** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
7243 */
7244 #define SQLITE_TXN_NONE 0
7245 #define SQLITE_TXN_READ 1
7246 #define SQLITE_TXN_WRITE 2
7247
@@ -7518,11 +7518,11 @@
7518
7519 /*
7520 ** CAPI3REF: Impose A Limit On Heap Size
7521 **
7522 ** These interfaces impose limits on the amount of heap memory that will be
7523 ** by all database connections within a single process.
7524 **
7525 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7526 ** soft limit on the amount of heap memory that may be allocated by SQLite.
7527 ** ^SQLite strives to keep heap memory utilization below the soft heap
7528 ** limit by reducing the number of pages held in the page cache
@@ -7576,11 +7576,11 @@
7576 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
7577 ** from the heap.
7578 ** </ul>)^
7579 **
7580 ** The circumstances under which SQLite will enforce the heap limits may
7581 ** changes in future releases of SQLite.
7582 */
7583 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7584 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
7585
7586 /*
@@ -7691,12 +7691,12 @@
7691 ** be tried also.
7692 **
7693 ** ^The entry point is zProc.
7694 ** ^(zProc may be 0, in which case SQLite will try to come up with an
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
7698 ** characters in the filename from the last "/" to the first following
7699 ** "." and omitting any initial "lib".)^
7700 ** ^The sqlite3_load_extension() interface returns
7701 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7702 ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7927,11 +7927,11 @@
7927 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
7928 ** is true, then the constraint is assumed to be fully handled by the
7929 ** virtual table and might not be checked again by the byte code.)^ ^(The
7930 ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
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
7933 ** the constraint may or may not be checked in byte code. In other words,
7934 ** when the omit flag is true there is no guarantee that the constraint will
7935 ** not be checked again using byte code.)^
7936 **
7937 ** ^The idxNum and idxStr values are recorded and passed into the
@@ -7953,11 +7953,11 @@
7953 ** will be returned by the strategy.
7954 **
7955 ** The xBestIndex method may optionally populate the idxFlags field with a
7956 ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
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
7959 ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7960 ** return at most one row.
7961 **
7962 ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
7963 ** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -8529,11 +8529,11 @@
8529 ** function that calls sqlite3_initialize().
8530 **
8531 ** ^The sqlite3_mutex_alloc() routine allocates a new
8532 ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
8533 ** routine returns NULL if it is unable to allocate the requested
8534 ** mutex. The argument to sqlite3_mutex_alloc() must one of these
8535 ** integer constants:
8536 **
8537 ** <ul>
8538 ** <li> SQLITE_MUTEX_FAST
8539 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -8762,11 +8762,11 @@
8762
8763 /*
8764 ** CAPI3REF: Retrieve the mutex for a database connection
8765 ** METHOD: sqlite3
8766 **
8767 ** ^This interface returns a pointer the [sqlite3_mutex] object that
8768 ** serializes access to the [database connection] given in the argument
8769 ** when the [threading mode] is Serialized.
8770 ** ^If the [threading mode] is Single-thread or Multi-thread then this
8771 ** routine returns a NULL pointer.
8772 */
@@ -8885,11 +8885,11 @@
8885
8886 /*
8887 ** CAPI3REF: SQL Keyword Checking
8888 **
8889 ** These routines provide access to the set of SQL language keywords
8890 ** recognized by SQLite. Applications can uses these routines to determine
8891 ** whether or not a specific identifier needs to be escaped (for example,
8892 ** by enclosing in double-quotes) so as not to confuse the parser.
8893 **
8894 ** The sqlite3_keyword_count() interface returns the number of distinct
8895 ** keywords understood by SQLite.
@@ -9053,11 +9053,11 @@
9053 **
9054 ** ^The [sqlite3_str_value(X)] method returns a pointer to the current
9055 ** content of the dynamic string under construction in X. The value
9056 ** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
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
9059 ** [sqlite3_str_value(X)] after any subsequent method call on the same
9060 ** object. ^Applications may change the content of the string returned
9061 ** by [sqlite3_str_value(X)] as long as they do not write into any bytes
9062 ** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
9063 ** write any byte after any subsequent sqlite3_str method call.
@@ -9139,11 +9139,11 @@
9139 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
9140 ** <dd>This parameter returns the number of bytes of page cache
9141 ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
9142 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
9143 ** returned value includes allocations that overflowed because they
9144 ** where too large (they were larger than the "sz" parameter to
9145 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
9146 ** no space was left in the page cache.</dd>)^
9147 **
9148 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
9149 ** <dd>This parameter records the largest memory allocation request
@@ -9223,53 +9223,55 @@
9223 ** checked out.</dd>)^
9224 **
9225 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
9226 ** <dd>This parameter returns the number of malloc attempts that were
9227 ** satisfied using lookaside memory. Only the high-water value is meaningful;
9228 ** the current value is always zero.)^
9229 **
9230 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
9231 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
9232 ** <dd>This parameter returns the number malloc attempts that might have
9233 ** been satisfied using lookaside memory but failed due to the amount of
9234 ** memory requested being larger than the lookaside slot size.
9235 ** Only the high-water value is meaningful;
9236 ** the current value is always zero.)^
9237 **
9238 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
9239 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
9240 ** <dd>This parameter returns the number malloc attempts that might have
9241 ** been satisfied using lookaside memory but failed due to all lookaside
9242 ** memory already being in use.
9243 ** Only the high-water value is meaningful;
9244 ** the current value is always zero.)^
9245 **
9246 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
9247 ** <dd>This parameter returns the approximate number of bytes of heap
9248 ** memory used by all pager caches associated with the database connection.)^
9249 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
 
9250 **
9251 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
9252 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
9253 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
9254 ** pager cache is shared between two or more connections the bytes of heap
9255 ** memory used by that pager cache is divided evenly between the attached
9256 ** connections.)^ In other words, if none of the pager caches associated
9257 ** 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 ** shared, the value returned by this call will be smaller than that returned
9260 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
9261 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
9262 **
9263 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
9264 ** <dd>This parameter returns the approximate number of bytes of heap
9265 ** memory used to store the schema for all databases associated
9266 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
9267 ** ^The full amount of memory used by the schemas is reported, even if the
9268 ** schema memory is shared with other database connections due to
9269 ** [shared cache mode] being enabled.
9270 ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
 
9271 **
9272 ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
9273 ** <dd>This parameter returns the approximate number of bytes of heap
9274 ** and lookaside memory used by all prepared statements associated with
9275 ** the database connection.)^
@@ -9302,11 +9304,11 @@
9302 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
9303 ** <dd>This parameter returns the number of dirty cache entries that have
9304 ** been written to disk in the middle of a transaction due to the page
9305 ** cache overflowing. Transactions are more efficient if they are written
9306 ** to disk all at once. When pages spill mid-transaction, that introduces
9307 ** additional overhead. This parameter can be used help identify
9308 ** inefficiencies that can be resolved by increasing the cache size.
9309 ** </dd>
9310 **
9311 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
9312 ** <dd>This parameter returns zero for the current value if and only if
@@ -15440,12 +15442,12 @@
15440 /*
15441 ** Macro SMXV(n) return the maximum value that can be held in variable n,
15442 ** assuming n is a signed integer type. UMXV(n) is similar for unsigned
15443 ** integer types.
15444 */
15445 #define SMXV(n) ((((i64)1)<<(sizeof(n)-1))-1)
15446 #define UMXV(n) ((((i64)1)<<(sizeof(n)))-1)
15447
15448 /*
15449 ** Round up a number to the next larger multiple of 8. This is used
15450 ** to force 8-byte alignment on 64-bit architectures.
15451 **
@@ -19268,21 +19270,21 @@
19268 struct AggInfo {
19269 u8 directMode; /* Direct rendering mode means take data directly
19270 ** from source tables rather than from accumulators */
19271 u8 useSortingIdx; /* In direct mode, reference the sorting index rather
19272 ** than the source table */
19273 u16 nSortingColumn; /* Number of columns in the sorting index */
19274 int sortingIdx; /* Cursor number of the sorting index */
19275 int sortingIdxPTab; /* Cursor number of pseudo-table */
19276 int iFirstReg; /* First register in range for aCol[] and aFunc[] */
19277 ExprList *pGroupBy; /* The group by clause */
19278 struct AggInfo_col { /* For each column used in source tables */
19279 Table *pTab; /* Source table */
19280 Expr *pCExpr; /* The original expression */
19281 int iTable; /* Cursor number of the source table */
19282 i16 iColumn; /* Column number within the source table */
19283 i16 iSorterColumn; /* Column number in the sorting index */
19284 } *aCol;
19285 int nColumn; /* Number of used entries in aCol[] */
19286 int nAccumulator; /* Number of columns that show through to the output.
19287 ** Additional columns are used only as parameters to
19288 ** aggregate functions */
@@ -80351,11 +80353,16 @@
80351
80352 /* If the sibling pages are not leaves, ensure that the right-child pointer
80353 ** of the right-most new sibling page is set to the value that was
80354 ** originally in the same field of the right-most old sibling page. */
80355 if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){
80356 MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1];
 
 
 
 
 
80357 memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);
80358 }
80359
80360 /* Make any required updates to pointer map entries associated with
80361 ** cells stored on sibling pages following the balance operation. Pointer
@@ -93911,10 +93918,12 @@
93911 rc = SQLITE_MISUSE_BKPT;
93912 goto preupdate_new_out;
93913 }
93914 if( p->pPk && p->op!=SQLITE_UPDATE ){
93915 iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
 
 
93916 }else{
93917 iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
93918 }
93919
93920 if( iStore>=p->pCsr->nField || iStore<0 ){
@@ -117522,11 +117531,13 @@
117522 AggInfo *pAggInfo, /* The AggInfo object to search and/or modify */
117523 Expr *pExpr /* Expr describing the column to find or insert */
117524 ){
117525 struct AggInfo_col *pCol;
117526 int k;
 
117527
 
117528 assert( pAggInfo->iFirstReg==0 );
117529 pCol = pAggInfo->aCol;
117530 for(k=0; k<pAggInfo->nColumn; k++, pCol++){
117531 if( pCol->pCExpr==pExpr ) return;
117532 if( pCol->iTable==pExpr->iTable
@@ -117539,10 +117550,14 @@
117539 k = addAggInfoColumn(pParse->db, pAggInfo);
117540 if( k<0 ){
117541 /* OOM on resize */
117542 assert( pParse->db->mallocFailed );
117543 return;
 
 
 
 
117544 }
117545 pCol = &pAggInfo->aCol[k];
117546 assert( ExprUseYTab(pExpr) );
117547 pCol->pTab = pExpr->y.pTab;
117548 pCol->iTable = pExpr->iTable;
@@ -117573,10 +117588,11 @@
117573 assert( pExpr->pAggInfo==0 || pExpr->pAggInfo==pAggInfo );
117574 pExpr->pAggInfo = pAggInfo;
117575 if( pExpr->op==TK_COLUMN ){
117576 pExpr->op = TK_AGG_COLUMN;
117577 }
 
117578 pExpr->iAgg = (i16)k;
117579 }
117580
117581 /*
117582 ** This is the xExprCallback for a tree walker. It is used to
@@ -117657,17 +117673,23 @@
117657 ){
117658 /* Check to see if pExpr is a duplicate of another aggregate
117659 ** function that is already in the pAggInfo structure
117660 */
117661 struct AggInfo_func *pItem = pAggInfo->aFunc;
 
 
117662 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
117663 if( NEVER(pItem->pFExpr==pExpr) ) break;
117664 if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
117665 break;
117666 }
117667 }
117668 if( i>=pAggInfo->nFunc ){
 
 
 
 
117669 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
117670 */
117671 u8 enc = ENC(pParse->db);
117672 i = addAggInfoFunc(pParse->db, pAggInfo);
117673 if( i>=0 ){
@@ -117717,10 +117739,11 @@
117717 }
117718 /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
117719 */
117720 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
117721 ExprSetVVAProperty(pExpr, EP_NoReduce);
 
117722 pExpr->iAgg = (i16)i;
117723 pExpr->pAggInfo = pAggInfo;
117724 return WRC_Prune;
117725 }else{
117726 return WRC_Continue;
@@ -257480,11 +257503,11 @@
257480 int nArg, /* Number of args */
257481 sqlite3_value **apUnused /* Function arguments */
257482 ){
257483 assert( nArg==0 );
257484 UNUSED_PARAM2(nArg, apUnused);
257485 sqlite3_result_text(pCtx, "fts5: 2025-06-24 15:58:32 6a5701e6c7be25cba93e55438f950966e1dacb32eb2b23a8acc8ac53da6f0a85", -1, SQLITE_TRANSIENT);
257486 }
257487
257488 /*
257489 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257490 **
257491
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
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 ** The content in this amalgamation comes from Fossil check-in
21 ** 5508b56fd24016c13981ec280ecdd833007c with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-06-27 19:02:21 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -6355,11 +6355,11 @@
6355 /*
6356 ** CAPI3REF: Copy And Free SQL Values
6357 ** METHOD: sqlite3_value
6358 **
6359 ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
6360 ** object V and returns a pointer to that copy. ^The [sqlite3_value] returned
6361 ** is a [protected sqlite3_value] object even if the input is not.
6362 ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
6363 ** memory allocation fails. ^If V is a [pointer value], then the result
6364 ** of sqlite3_value_dup(V) is a NULL value.
6365 **
@@ -6393,11 +6393,11 @@
6393 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
6394 ** when first called if N is less than or equal to zero or if a memory
6395 ** allocation error occurs.
6396 **
6397 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6398 ** determined by the N parameter on the first successful call. Changing the
6399 ** value of N in any subsequent call to sqlite3_aggregate_context() within
6400 ** the same aggregate function instance will not resize the memory
6401 ** allocation.)^ Within the xFinal callback, it is customary to set
6402 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6403 ** pointless memory allocations occur.
@@ -6555,11 +6555,11 @@
6555 ** of as a secret key such that only code that knows the secret key is able
6556 ** to access the associated data.
6557 **
6558 ** Security Warning: These interfaces should not be exposed in scripting
6559 ** languages or in other circumstances where it might be possible for an
6560 ** attacker to invoke them. Any agent that can invoke these interfaces
6561 ** can probably also take control of the process.
6562 **
6563 ** Database connection client data is only available for SQLite
6564 ** version 3.44.0 ([dateof:3.44.0]) and later.
6565 **
@@ -6669,11 +6669,11 @@
6669 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6670 ** is non-negative, then as many bytes (not characters) of the text
6671 ** pointed to by the 2nd parameter are taken as the application-defined
6672 ** function result. If the 3rd parameter is non-negative, then it
6673 ** must be the byte offset into the string where the NUL terminator would
6674 ** appear if the string were NUL terminated. If any NUL characters occur
6675 ** in the string at a byte offset that is less than the value of the 3rd
6676 ** parameter, then the resulting string will contain embedded NULs and the
6677 ** result of expressions operating on strings with embedded NULs is undefined.
6678 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
6679 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
@@ -6727,11 +6727,11 @@
6727 ** for the P parameter. ^SQLite invokes D with P as its only argument
6728 ** when SQLite is finished with P. The T parameter should be a static
6729 ** string and preferably a string literal. The sqlite3_result_pointer()
6730 ** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
6731 **
6732 ** If these routines are called from within a different thread
6733 ** than the one containing the application-defined function that received
6734 ** the [sqlite3_context] pointer, the results are undefined.
6735 */
6736 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
6737 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
@@ -7133,11 +7133,11 @@
7133 /*
7134 ** CAPI3REF: Return The Schema Name For A Database Connection
7135 ** METHOD: sqlite3
7136 **
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 if N is
7139 ** out of range. An N value of 0 means the main database file. An N of 1 is
7140 ** the "temp" schema. Larger values of N correspond to various ATTACH-ed
7141 ** databases.
7142 **
7143 ** Space to hold the string that is returned by sqlite3_db_name() is managed
@@ -7228,20 +7228,20 @@
7228 **
7229 ** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
7230 ** <dd>The SQLITE_TXN_READ state means that the database is currently
7231 ** in a read transaction. Content has been read from the database file
7232 ** but nothing in the database file has changed. The transaction state
7233 ** will be advanced to SQLITE_TXN_WRITE if any changes occur and there are
7234 ** no other conflicting concurrent write transactions. The transaction
7235 ** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
7236 ** [COMMIT].</dd>
7237 **
7238 ** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
7239 ** <dd>The SQLITE_TXN_WRITE state means that the database is currently
7240 ** in a write transaction. Content has been written to the database file
7241 ** but has not yet committed. The transaction state will change to
7242 ** SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
7243 */
7244 #define SQLITE_TXN_NONE 0
7245 #define SQLITE_TXN_READ 1
7246 #define SQLITE_TXN_WRITE 2
7247
@@ -7518,11 +7518,11 @@
7518
7519 /*
7520 ** CAPI3REF: Impose A Limit On Heap Size
7521 **
7522 ** These interfaces impose limits on the amount of heap memory that will be
7523 ** used by all database connections within a single process.
7524 **
7525 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7526 ** soft limit on the amount of heap memory that may be allocated by SQLite.
7527 ** ^SQLite strives to keep heap memory utilization below the soft heap
7528 ** limit by reducing the number of pages held in the page cache
@@ -7576,11 +7576,11 @@
7576 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
7577 ** from the heap.
7578 ** </ul>)^
7579 **
7580 ** The circumstances under which SQLite will enforce the heap limits may
7581 ** change in future releases of SQLite.
7582 */
7583 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7584 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
7585
7586 /*
@@ -7691,12 +7691,12 @@
7691 ** be tried also.
7692 **
7693 ** ^The entry point is zProc.
7694 ** ^(zProc may be 0, in which case SQLite will try to come up with an
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
7697 ** X consists of the lower-case equivalent of all ASCII alphabetic
7698 ** characters in the filename from the last "/" to the first following
7699 ** "." and omitting any initial "lib".)^
7700 ** ^The sqlite3_load_extension() interface returns
7701 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7702 ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7927,11 +7927,11 @@
7927 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
7928 ** is true, then the constraint is assumed to be fully handled by the
7929 ** virtual table and might not be checked again by the byte code.)^ ^(The
7930 ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
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 changed to true, then
7933 ** the constraint may or may not be checked in byte code. In other words,
7934 ** when the omit flag is true there is no guarantee that the constraint will
7935 ** not be checked again using byte code.)^
7936 **
7937 ** ^The idxNum and idxStr values are recorded and passed into the
@@ -7953,11 +7953,11 @@
7953 ** will be returned by the strategy.
7954 **
7955 ** The xBestIndex method may optionally populate the idxFlags field with a
7956 ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
7957 ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7958 ** output to show the idxNum as hex instead of as decimal. Another flag is
7959 ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7960 ** return at most one row.
7961 **
7962 ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
7963 ** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -8529,11 +8529,11 @@
8529 ** function that calls sqlite3_initialize().
8530 **
8531 ** ^The sqlite3_mutex_alloc() routine allocates a new
8532 ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
8533 ** routine returns NULL if it is unable to allocate the requested
8534 ** mutex. The argument to sqlite3_mutex_alloc() must be one of these
8535 ** integer constants:
8536 **
8537 ** <ul>
8538 ** <li> SQLITE_MUTEX_FAST
8539 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -8762,11 +8762,11 @@
8762
8763 /*
8764 ** CAPI3REF: Retrieve the mutex for a database connection
8765 ** METHOD: sqlite3
8766 **
8767 ** ^This interface returns a pointer to the [sqlite3_mutex] object that
8768 ** serializes access to the [database connection] given in the argument
8769 ** when the [threading mode] is Serialized.
8770 ** ^If the [threading mode] is Single-thread or Multi-thread then this
8771 ** routine returns a NULL pointer.
8772 */
@@ -8885,11 +8885,11 @@
8885
8886 /*
8887 ** CAPI3REF: SQL Keyword Checking
8888 **
8889 ** These routines provide access to the set of SQL language keywords
8890 ** recognized by SQLite. Applications can use these routines to determine
8891 ** whether or not a specific identifier needs to be escaped (for example,
8892 ** by enclosing in double-quotes) so as not to confuse the parser.
8893 **
8894 ** The sqlite3_keyword_count() interface returns the number of distinct
8895 ** keywords understood by SQLite.
@@ -9053,11 +9053,11 @@
9053 **
9054 ** ^The [sqlite3_str_value(X)] method returns a pointer to the current
9055 ** content of the dynamic string under construction in X. The value
9056 ** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
9057 ** and might be freed or altered by any subsequent method on the same
9058 ** [sqlite3_str] object. Applications must not use the pointer returned by
9059 ** [sqlite3_str_value(X)] after any subsequent method call on the same
9060 ** object. ^Applications may change the content of the string returned
9061 ** by [sqlite3_str_value(X)] as long as they do not write into any bytes
9062 ** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
9063 ** write any byte after any subsequent sqlite3_str method call.
@@ -9139,11 +9139,11 @@
9139 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
9140 ** <dd>This parameter returns the number of bytes of page cache
9141 ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
9142 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
9143 ** returned value includes allocations that overflowed because they
9144 ** were too large (they were larger than the "sz" parameter to
9145 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
9146 ** no space was left in the page cache.</dd>)^
9147 **
9148 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
9149 ** <dd>This parameter records the largest memory allocation request
@@ -9223,53 +9223,55 @@
9223 ** checked out.</dd>)^
9224 **
9225 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
9226 ** <dd>This parameter returns the number of malloc attempts that were
9227 ** satisfied using lookaside memory. Only the high-water value is meaningful;
9228 ** the current value is always zero.</dd>)^
9229 **
9230 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
9231 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
9232 ** <dd>This parameter returns the number of malloc attempts that might have
9233 ** been satisfied using lookaside memory but failed due to the amount of
9234 ** memory requested being larger than the lookaside slot size.
9235 ** Only the high-water value is meaningful;
9236 ** the current value is always zero.</dd>)^
9237 **
9238 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
9239 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
9240 ** <dd>This parameter returns the number of malloc attempts that might have
9241 ** been satisfied using lookaside memory but failed due to all lookaside
9242 ** memory already being in use.
9243 ** Only the high-water value is meaningful;
9244 ** the current value is always zero.</dd>)^
9245 **
9246 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
9247 ** <dd>This parameter returns the approximate number of bytes of heap
9248 ** memory used by all pager caches associated with the database connection.)^
9249 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
9250 ** </dd>
9251 **
9252 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
9253 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
9254 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
9255 ** pager cache is shared between two or more connections the bytes of heap
9256 ** memory used by that pager cache is divided evenly between the attached
9257 ** connections.)^ In other words, if none of the pager caches associated
9258 ** with the database connection are shared, this request returns the same
9259 ** value as DBSTATUS_CACHE_USED. Or, if one or more of the pager caches are
9260 ** shared, the value returned by this call will be smaller than that returned
9261 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
9262 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</dd>
9263 **
9264 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
9265 ** <dd>This parameter returns the approximate number of bytes of heap
9266 ** memory used to store the schema for all databases associated
9267 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
9268 ** ^The full amount of memory used by the schemas is reported, even if the
9269 ** schema memory is shared with other database connections due to
9270 ** [shared cache mode] being enabled.
9271 ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
9272 ** </dd>
9273 **
9274 ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
9275 ** <dd>This parameter returns the approximate number of bytes of heap
9276 ** and lookaside memory used by all prepared statements associated with
9277 ** the database connection.)^
@@ -9302,11 +9304,11 @@
9304 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
9305 ** <dd>This parameter returns the number of dirty cache entries that have
9306 ** been written to disk in the middle of a transaction due to the page
9307 ** cache overflowing. Transactions are more efficient if they are written
9308 ** to disk all at once. When pages spill mid-transaction, that introduces
9309 ** additional overhead. This parameter can be used to help identify
9310 ** inefficiencies that can be resolved by increasing the cache size.
9311 ** </dd>
9312 **
9313 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
9314 ** <dd>This parameter returns zero for the current value if and only if
@@ -15440,12 +15442,12 @@
15442 /*
15443 ** Macro SMXV(n) return the maximum value that can be held in variable n,
15444 ** assuming n is a signed integer type. UMXV(n) is similar for unsigned
15445 ** integer types.
15446 */
15447 #define SMXV(n) ((((i64)1)<<(sizeof(n)*8-1))-1)
15448 #define UMXV(n) ((((i64)1)<<(sizeof(n)*8))-1)
15449
15450 /*
15451 ** Round up a number to the next larger multiple of 8. This is used
15452 ** to force 8-byte alignment on 64-bit architectures.
15453 **
@@ -19268,21 +19270,21 @@
19270 struct AggInfo {
19271 u8 directMode; /* Direct rendering mode means take data directly
19272 ** from source tables rather than from accumulators */
19273 u8 useSortingIdx; /* In direct mode, reference the sorting index rather
19274 ** than the source table */
19275 u32 nSortingColumn; /* Number of columns in the sorting index */
19276 int sortingIdx; /* Cursor number of the sorting index */
19277 int sortingIdxPTab; /* Cursor number of pseudo-table */
19278 int iFirstReg; /* First register in range for aCol[] and aFunc[] */
19279 ExprList *pGroupBy; /* The group by clause */
19280 struct AggInfo_col { /* For each column used in source tables */
19281 Table *pTab; /* Source table */
19282 Expr *pCExpr; /* The original expression */
19283 int iTable; /* Cursor number of the source table */
19284 int iColumn; /* Column number within the source table */
19285 int iSorterColumn; /* Column number in the sorting index */
19286 } *aCol;
19287 int nColumn; /* Number of used entries in aCol[] */
19288 int nAccumulator; /* Number of columns that show through to the output.
19289 ** Additional columns are used only as parameters to
19290 ** aggregate functions */
@@ -80351,11 +80353,16 @@
80353
80354 /* If the sibling pages are not leaves, ensure that the right-child pointer
80355 ** of the right-most new sibling page is set to the value that was
80356 ** originally in the same field of the right-most old sibling page. */
80357 if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){
80358 MemPage *pOld;
80359 if( nNew>nOld ){
80360 pOld = apNew[nOld-1];
80361 }else{
80362 pOld = apOld[nOld-1];
80363 }
80364 memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);
80365 }
80366
80367 /* Make any required updates to pointer map entries associated with
80368 ** cells stored on sibling pages following the balance operation. Pointer
@@ -93911,10 +93918,12 @@
93918 rc = SQLITE_MISUSE_BKPT;
93919 goto preupdate_new_out;
93920 }
93921 if( p->pPk && p->op!=SQLITE_UPDATE ){
93922 iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
93923 }else if( iIdx >= p->pTab->nCol ){
93924 return SQLITE_MISUSE_BKPT;
93925 }else{
93926 iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
93927 }
93928
93929 if( iStore>=p->pCsr->nField || iStore<0 ){
@@ -117522,11 +117531,13 @@
117531 AggInfo *pAggInfo, /* The AggInfo object to search and/or modify */
117532 Expr *pExpr /* Expr describing the column to find or insert */
117533 ){
117534 struct AggInfo_col *pCol;
117535 int k;
117536 int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];
117537
117538 assert( mxTerm <= SMXV(i16) );
117539 assert( pAggInfo->iFirstReg==0 );
117540 pCol = pAggInfo->aCol;
117541 for(k=0; k<pAggInfo->nColumn; k++, pCol++){
117542 if( pCol->pCExpr==pExpr ) return;
117543 if( pCol->iTable==pExpr->iTable
@@ -117539,10 +117550,14 @@
117550 k = addAggInfoColumn(pParse->db, pAggInfo);
117551 if( k<0 ){
117552 /* OOM on resize */
117553 assert( pParse->db->mallocFailed );
117554 return;
117555 }
117556 if( k>mxTerm ){
117557 sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm);
117558 k = mxTerm;
117559 }
117560 pCol = &pAggInfo->aCol[k];
117561 assert( ExprUseYTab(pExpr) );
117562 pCol->pTab = pExpr->y.pTab;
117563 pCol->iTable = pExpr->iTable;
@@ -117573,10 +117588,11 @@
117588 assert( pExpr->pAggInfo==0 || pExpr->pAggInfo==pAggInfo );
117589 pExpr->pAggInfo = pAggInfo;
117590 if( pExpr->op==TK_COLUMN ){
117591 pExpr->op = TK_AGG_COLUMN;
117592 }
117593 assert( k <= SMXV(pExpr->iAgg) );
117594 pExpr->iAgg = (i16)k;
117595 }
117596
117597 /*
117598 ** This is the xExprCallback for a tree walker. It is used to
@@ -117657,17 +117673,23 @@
117673 ){
117674 /* Check to see if pExpr is a duplicate of another aggregate
117675 ** function that is already in the pAggInfo structure
117676 */
117677 struct AggInfo_func *pItem = pAggInfo->aFunc;
117678 int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];
117679 assert( mxTerm <= SMXV(i16) );
117680 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
117681 if( NEVER(pItem->pFExpr==pExpr) ) break;
117682 if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
117683 break;
117684 }
117685 }
117686 if( i>mxTerm ){
117687 sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm);
117688 i = mxTerm;
117689 assert( i<pAggInfo->nFunc );
117690 }else if( i>=pAggInfo->nFunc ){
117691 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
117692 */
117693 u8 enc = ENC(pParse->db);
117694 i = addAggInfoFunc(pParse->db, pAggInfo);
117695 if( i>=0 ){
@@ -117717,10 +117739,11 @@
117739 }
117740 /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
117741 */
117742 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
117743 ExprSetVVAProperty(pExpr, EP_NoReduce);
117744 assert( i <= SMXV(pExpr->iAgg) );
117745 pExpr->iAgg = (i16)i;
117746 pExpr->pAggInfo = pAggInfo;
117747 return WRC_Prune;
117748 }else{
117749 return WRC_Continue;
@@ -257480,11 +257503,11 @@
257503 int nArg, /* Number of args */
257504 sqlite3_value **apUnused /* Function arguments */
257505 ){
257506 assert( nArg==0 );
257507 UNUSED_PARAM2(nArg, apUnused);
257508 sqlite3_result_text(pCtx, "fts5: 2025-06-27 19:02:21 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8", -1, SQLITE_TRANSIENT);
257509 }
257510
257511 /*
257512 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257513 **
257514
+30 -28
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.51.0"
150150
#define SQLITE_VERSION_NUMBER 3051000
151
-#define SQLITE_SOURCE_ID "2025-06-24 15:58:32 6a5701e6c7be25cba93e55438f950966e1dacb32eb2b23a8acc8ac53da6f0a85"
151
+#define SQLITE_SOURCE_ID "2025-06-27 19:02:21 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -6036,11 +6036,11 @@
60366036
/*
60376037
** CAPI3REF: Copy And Free SQL Values
60386038
** METHOD: sqlite3_value
60396039
**
60406040
** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
6041
-** object D and returns a pointer to that copy. ^The [sqlite3_value] returned
6041
+** object V and returns a pointer to that copy. ^The [sqlite3_value] returned
60426042
** is a [protected sqlite3_value] object even if the input is not.
60436043
** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
60446044
** memory allocation fails. ^If V is a [pointer value], then the result
60456045
** of sqlite3_value_dup(V) is a NULL value.
60466046
**
@@ -6074,11 +6074,11 @@
60746074
** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
60756075
** when first called if N is less than or equal to zero or if a memory
60766076
** allocation error occurs.
60776077
**
60786078
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6079
-** determined by the N parameter on first successful call. Changing the
6079
+** determined by the N parameter on the first successful call. Changing the
60806080
** value of N in any subsequent call to sqlite3_aggregate_context() within
60816081
** the same aggregate function instance will not resize the memory
60826082
** allocation.)^ Within the xFinal callback, it is customary to set
60836083
** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
60846084
** pointless memory allocations occur.
@@ -6236,11 +6236,11 @@
62366236
** of as a secret key such that only code that knows the secret key is able
62376237
** to access the associated data.
62386238
**
62396239
** Security Warning: These interfaces should not be exposed in scripting
62406240
** languages or in other circumstances where it might be possible for an
6241
-** an attacker to invoke them. Any agent that can invoke these interfaces
6241
+** attacker to invoke them. Any agent that can invoke these interfaces
62426242
** can probably also take control of the process.
62436243
**
62446244
** Database connection client data is only available for SQLite
62456245
** version 3.44.0 ([dateof:3.44.0]) and later.
62466246
**
@@ -6350,11 +6350,11 @@
63506350
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
63516351
** is non-negative, then as many bytes (not characters) of the text
63526352
** pointed to by the 2nd parameter are taken as the application-defined
63536353
** function result. If the 3rd parameter is non-negative, then it
63546354
** must be the byte offset into the string where the NUL terminator would
6355
-** appear if the string where NUL terminated. If any NUL characters occur
6355
+** appear if the string were NUL terminated. If any NUL characters occur
63566356
** in the string at a byte offset that is less than the value of the 3rd
63576357
** parameter, then the resulting string will contain embedded NULs and the
63586358
** result of expressions operating on strings with embedded NULs is undefined.
63596359
** ^If the 4th parameter to the sqlite3_result_text* interfaces
63606360
** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
@@ -6408,11 +6408,11 @@
64086408
** for the P parameter. ^SQLite invokes D with P as its only argument
64096409
** when SQLite is finished with P. The T parameter should be a static
64106410
** string and preferably a string literal. The sqlite3_result_pointer()
64116411
** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
64126412
**
6413
-** If these routines are called from within the different thread
6413
+** If these routines are called from within a different thread
64146414
** than the one containing the application-defined function that received
64156415
** the [sqlite3_context] pointer, the results are undefined.
64166416
*/
64176417
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
64186418
SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
@@ -6814,11 +6814,11 @@
68146814
/*
68156815
** CAPI3REF: Return The Schema Name For A Database Connection
68166816
** METHOD: sqlite3
68176817
**
68186818
** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
6819
-** for the N-th database on database connection D, or a NULL pointer of N is
6819
+** for the N-th database on database connection D, or a NULL pointer if N is
68206820
** out of range. An N value of 0 means the main database file. An N of 1 is
68216821
** the "temp" schema. Larger values of N correspond to various ATTACH-ed
68226822
** databases.
68236823
**
68246824
** Space to hold the string that is returned by sqlite3_db_name() is managed
@@ -6909,20 +6909,20 @@
69096909
**
69106910
** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
69116911
** <dd>The SQLITE_TXN_READ state means that the database is currently
69126912
** in a read transaction. Content has been read from the database file
69136913
** but nothing in the database file has changed. The transaction state
6914
-** will advanced to SQLITE_TXN_WRITE if any changes occur and there are
6914
+** will be advanced to SQLITE_TXN_WRITE if any changes occur and there are
69156915
** no other conflicting concurrent write transactions. The transaction
69166916
** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
69176917
** [COMMIT].</dd>
69186918
**
69196919
** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
69206920
** <dd>The SQLITE_TXN_WRITE state means that the database is currently
69216921
** in a write transaction. Content has been written to the database file
69226922
** but has not yet committed. The transaction state will change to
6923
-** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
6923
+** SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
69246924
*/
69256925
#define SQLITE_TXN_NONE 0
69266926
#define SQLITE_TXN_READ 1
69276927
#define SQLITE_TXN_WRITE 2
69286928
@@ -7199,11 +7199,11 @@
71997199
72007200
/*
72017201
** CAPI3REF: Impose A Limit On Heap Size
72027202
**
72037203
** These interfaces impose limits on the amount of heap memory that will be
7204
-** by all database connections within a single process.
7204
+** used by all database connections within a single process.
72057205
**
72067206
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
72077207
** soft limit on the amount of heap memory that may be allocated by SQLite.
72087208
** ^SQLite strives to keep heap memory utilization below the soft heap
72097209
** limit by reducing the number of pages held in the page cache
@@ -7257,11 +7257,11 @@
72577257
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
72587258
** from the heap.
72597259
** </ul>)^
72607260
**
72617261
** The circumstances under which SQLite will enforce the heap limits may
7262
-** changes in future releases of SQLite.
7262
+** change in future releases of SQLite.
72637263
*/
72647264
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
72657265
SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
72667266
72677267
/*
@@ -7372,12 +7372,12 @@
73727372
** be tried also.
73737373
**
73747374
** ^The entry point is zProc.
73757375
** ^(zProc may be 0, in which case SQLite will try to come up with an
73767376
** entry point name on its own. It first tries "sqlite3_extension_init".
7377
-** If that does not work, it constructs a name "sqlite3_X_init" where the
7378
-** X is consists of the lower-case equivalent of all ASCII alphabetic
7377
+** If that does not work, it constructs a name "sqlite3_X_init" where
7378
+** X consists of the lower-case equivalent of all ASCII alphabetic
73797379
** characters in the filename from the last "/" to the first following
73807380
** "." and omitting any initial "lib".)^
73817381
** ^The sqlite3_load_extension() interface returns
73827382
** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
73837383
** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7608,11 +7608,11 @@
76087608
** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
76097609
** is true, then the constraint is assumed to be fully handled by the
76107610
** virtual table and might not be checked again by the byte code.)^ ^(The
76117611
** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
76127612
** is left in its default setting of false, the constraint will always be
7613
-** checked separately in byte code. If the omit flag is change to true, then
7613
+** checked separately in byte code. If the omit flag is changed to true, then
76147614
** the constraint may or may not be checked in byte code. In other words,
76157615
** when the omit flag is true there is no guarantee that the constraint will
76167616
** not be checked again using byte code.)^
76177617
**
76187618
** ^The idxNum and idxStr values are recorded and passed into the
@@ -7634,11 +7634,11 @@
76347634
** will be returned by the strategy.
76357635
**
76367636
** The xBestIndex method may optionally populate the idxFlags field with a
76377637
** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
76387638
** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7639
-** output to show the idxNum has hex instead of as decimal. Another flag is
7639
+** output to show the idxNum as hex instead of as decimal. Another flag is
76407640
** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
76417641
** return at most one row.
76427642
**
76437643
** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
76447644
** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -8210,11 +8210,11 @@
82108210
** function that calls sqlite3_initialize().
82118211
**
82128212
** ^The sqlite3_mutex_alloc() routine allocates a new
82138213
** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
82148214
** routine returns NULL if it is unable to allocate the requested
8215
-** mutex. The argument to sqlite3_mutex_alloc() must one of these
8215
+** mutex. The argument to sqlite3_mutex_alloc() must be one of these
82168216
** integer constants:
82178217
**
82188218
** <ul>
82198219
** <li> SQLITE_MUTEX_FAST
82208220
** <li> SQLITE_MUTEX_RECURSIVE
@@ -8443,11 +8443,11 @@
84438443
84448444
/*
84458445
** CAPI3REF: Retrieve the mutex for a database connection
84468446
** METHOD: sqlite3
84478447
**
8448
-** ^This interface returns a pointer the [sqlite3_mutex] object that
8448
+** ^This interface returns a pointer to the [sqlite3_mutex] object that
84498449
** serializes access to the [database connection] given in the argument
84508450
** when the [threading mode] is Serialized.
84518451
** ^If the [threading mode] is Single-thread or Multi-thread then this
84528452
** routine returns a NULL pointer.
84538453
*/
@@ -8566,11 +8566,11 @@
85668566
85678567
/*
85688568
** CAPI3REF: SQL Keyword Checking
85698569
**
85708570
** These routines provide access to the set of SQL language keywords
8571
-** recognized by SQLite. Applications can uses these routines to determine
8571
+** recognized by SQLite. Applications can use these routines to determine
85728572
** whether or not a specific identifier needs to be escaped (for example,
85738573
** by enclosing in double-quotes) so as not to confuse the parser.
85748574
**
85758575
** The sqlite3_keyword_count() interface returns the number of distinct
85768576
** keywords understood by SQLite.
@@ -8734,11 +8734,11 @@
87348734
**
87358735
** ^The [sqlite3_str_value(X)] method returns a pointer to the current
87368736
** content of the dynamic string under construction in X. The value
87378737
** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
87388738
** and might be freed or altered by any subsequent method on the same
8739
-** [sqlite3_str] object. Applications must not used the pointer returned
8739
+** [sqlite3_str] object. Applications must not use the pointer returned by
87408740
** [sqlite3_str_value(X)] after any subsequent method call on the same
87418741
** object. ^Applications may change the content of the string returned
87428742
** by [sqlite3_str_value(X)] as long as they do not write into any bytes
87438743
** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
87448744
** write any byte after any subsequent sqlite3_str method call.
@@ -8820,11 +8820,11 @@
88208820
** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
88218821
** <dd>This parameter returns the number of bytes of page cache
88228822
** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
88238823
** buffer and where forced to overflow to [sqlite3_malloc()]. The
88248824
** returned value includes allocations that overflowed because they
8825
-** where too large (they were larger than the "sz" parameter to
8825
+** were too large (they were larger than the "sz" parameter to
88268826
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
88278827
** no space was left in the page cache.</dd>)^
88288828
**
88298829
** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
88308830
** <dd>This parameter records the largest memory allocation request
@@ -8904,53 +8904,55 @@
89048904
** checked out.</dd>)^
89058905
**
89068906
** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
89078907
** <dd>This parameter returns the number of malloc attempts that were
89088908
** satisfied using lookaside memory. Only the high-water value is meaningful;
8909
-** the current value is always zero.)^
8909
+** the current value is always zero.</dd>)^
89108910
**
89118911
** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
89128912
** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
8913
-** <dd>This parameter returns the number malloc attempts that might have
8913
+** <dd>This parameter returns the number of malloc attempts that might have
89148914
** been satisfied using lookaside memory but failed due to the amount of
89158915
** memory requested being larger than the lookaside slot size.
89168916
** Only the high-water value is meaningful;
8917
-** the current value is always zero.)^
8917
+** the current value is always zero.</dd>)^
89188918
**
89198919
** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
89208920
** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
8921
-** <dd>This parameter returns the number malloc attempts that might have
8921
+** <dd>This parameter returns the number of malloc attempts that might have
89228922
** been satisfied using lookaside memory but failed due to all lookaside
89238923
** memory already being in use.
89248924
** Only the high-water value is meaningful;
8925
-** the current value is always zero.)^
8925
+** the current value is always zero.</dd>)^
89268926
**
89278927
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
89288928
** <dd>This parameter returns the approximate number of bytes of heap
89298929
** memory used by all pager caches associated with the database connection.)^
89308930
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
8931
+** </dd>
89318932
**
89328933
** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
89338934
** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
89348935
** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
89358936
** pager cache is shared between two or more connections the bytes of heap
89368937
** memory used by that pager cache is divided evenly between the attached
89378938
** connections.)^ In other words, if none of the pager caches associated
89388939
** with the database connection are shared, this request returns the same
8939
-** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
8940
+** value as DBSTATUS_CACHE_USED. Or, if one or more of the pager caches are
89408941
** shared, the value returned by this call will be smaller than that returned
89418942
** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
8942
-** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
8943
+** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</dd>
89438944
**
89448945
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
89458946
** <dd>This parameter returns the approximate number of bytes of heap
89468947
** memory used to store the schema for all databases associated
89478948
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
89488949
** ^The full amount of memory used by the schemas is reported, even if the
89498950
** schema memory is shared with other database connections due to
89508951
** [shared cache mode] being enabled.
89518952
** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
8953
+** </dd>
89528954
**
89538955
** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
89548956
** <dd>This parameter returns the approximate number of bytes of heap
89558957
** and lookaside memory used by all prepared statements associated with
89568958
** the database connection.)^
@@ -8983,11 +8985,11 @@
89838985
** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
89848986
** <dd>This parameter returns the number of dirty cache entries that have
89858987
** been written to disk in the middle of a transaction due to the page
89868988
** cache overflowing. Transactions are more efficient if they are written
89878989
** to disk all at once. When pages spill mid-transaction, that introduces
8988
-** additional overhead. This parameter can be used help identify
8990
+** additional overhead. This parameter can be used to help identify
89898991
** inefficiencies that can be resolved by increasing the cache size.
89908992
** </dd>
89918993
**
89928994
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
89938995
** <dd>This parameter returns zero for the current value if and only if
89948996
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-06-24 15:58:32 6a5701e6c7be25cba93e55438f950966e1dacb32eb2b23a8acc8ac53da6f0a85"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -6036,11 +6036,11 @@
6036 /*
6037 ** CAPI3REF: Copy And Free SQL Values
6038 ** METHOD: sqlite3_value
6039 **
6040 ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
6041 ** object D and returns a pointer to that copy. ^The [sqlite3_value] returned
6042 ** is a [protected sqlite3_value] object even if the input is not.
6043 ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
6044 ** memory allocation fails. ^If V is a [pointer value], then the result
6045 ** of sqlite3_value_dup(V) is a NULL value.
6046 **
@@ -6074,11 +6074,11 @@
6074 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
6075 ** when first called if N is less than or equal to zero or if a memory
6076 ** allocation error occurs.
6077 **
6078 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6079 ** determined by the N parameter on first successful call. Changing the
6080 ** value of N in any subsequent call to sqlite3_aggregate_context() within
6081 ** the same aggregate function instance will not resize the memory
6082 ** allocation.)^ Within the xFinal callback, it is customary to set
6083 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6084 ** pointless memory allocations occur.
@@ -6236,11 +6236,11 @@
6236 ** of as a secret key such that only code that knows the secret key is able
6237 ** to access the associated data.
6238 **
6239 ** Security Warning: These interfaces should not be exposed in scripting
6240 ** languages or in other circumstances where it might be possible for an
6241 ** an attacker to invoke them. Any agent that can invoke these interfaces
6242 ** can probably also take control of the process.
6243 **
6244 ** Database connection client data is only available for SQLite
6245 ** version 3.44.0 ([dateof:3.44.0]) and later.
6246 **
@@ -6350,11 +6350,11 @@
6350 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6351 ** is non-negative, then as many bytes (not characters) of the text
6352 ** pointed to by the 2nd parameter are taken as the application-defined
6353 ** function result. If the 3rd parameter is non-negative, then it
6354 ** must be the byte offset into the string where the NUL terminator would
6355 ** appear if the string where NUL terminated. If any NUL characters occur
6356 ** in the string at a byte offset that is less than the value of the 3rd
6357 ** parameter, then the resulting string will contain embedded NULs and the
6358 ** result of expressions operating on strings with embedded NULs is undefined.
6359 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
6360 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
@@ -6408,11 +6408,11 @@
6408 ** for the P parameter. ^SQLite invokes D with P as its only argument
6409 ** when SQLite is finished with P. The T parameter should be a static
6410 ** string and preferably a string literal. The sqlite3_result_pointer()
6411 ** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
6412 **
6413 ** If these routines are called from within the different thread
6414 ** than the one containing the application-defined function that received
6415 ** the [sqlite3_context] pointer, the results are undefined.
6416 */
6417 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
6418 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
@@ -6814,11 +6814,11 @@
6814 /*
6815 ** CAPI3REF: Return The Schema Name For A Database Connection
6816 ** METHOD: sqlite3
6817 **
6818 ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
6819 ** for the N-th database on database connection D, or a NULL pointer of N is
6820 ** out of range. An N value of 0 means the main database file. An N of 1 is
6821 ** the "temp" schema. Larger values of N correspond to various ATTACH-ed
6822 ** databases.
6823 **
6824 ** Space to hold the string that is returned by sqlite3_db_name() is managed
@@ -6909,20 +6909,20 @@
6909 **
6910 ** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
6911 ** <dd>The SQLITE_TXN_READ state means that the database is currently
6912 ** in a read transaction. Content has been read from the database file
6913 ** but nothing in the database file has changed. The transaction state
6914 ** will advanced to SQLITE_TXN_WRITE if any changes occur and there are
6915 ** no other conflicting concurrent write transactions. The transaction
6916 ** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
6917 ** [COMMIT].</dd>
6918 **
6919 ** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
6920 ** <dd>The SQLITE_TXN_WRITE state means that the database is currently
6921 ** in a write transaction. Content has been written to the database file
6922 ** but has not yet committed. The transaction state will change to
6923 ** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
6924 */
6925 #define SQLITE_TXN_NONE 0
6926 #define SQLITE_TXN_READ 1
6927 #define SQLITE_TXN_WRITE 2
6928
@@ -7199,11 +7199,11 @@
7199
7200 /*
7201 ** CAPI3REF: Impose A Limit On Heap Size
7202 **
7203 ** These interfaces impose limits on the amount of heap memory that will be
7204 ** by all database connections within a single process.
7205 **
7206 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7207 ** soft limit on the amount of heap memory that may be allocated by SQLite.
7208 ** ^SQLite strives to keep heap memory utilization below the soft heap
7209 ** limit by reducing the number of pages held in the page cache
@@ -7257,11 +7257,11 @@
7257 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
7258 ** from the heap.
7259 ** </ul>)^
7260 **
7261 ** The circumstances under which SQLite will enforce the heap limits may
7262 ** changes in future releases of SQLite.
7263 */
7264 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7265 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
7266
7267 /*
@@ -7372,12 +7372,12 @@
7372 ** be tried also.
7373 **
7374 ** ^The entry point is zProc.
7375 ** ^(zProc may be 0, in which case SQLite will try to come up with an
7376 ** entry point name on its own. It first tries "sqlite3_extension_init".
7377 ** If that does not work, it constructs a name "sqlite3_X_init" where the
7378 ** X is consists of the lower-case equivalent of all ASCII alphabetic
7379 ** characters in the filename from the last "/" to the first following
7380 ** "." and omitting any initial "lib".)^
7381 ** ^The sqlite3_load_extension() interface returns
7382 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7383 ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7608,11 +7608,11 @@
7608 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
7609 ** is true, then the constraint is assumed to be fully handled by the
7610 ** virtual table and might not be checked again by the byte code.)^ ^(The
7611 ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
7612 ** is left in its default setting of false, the constraint will always be
7613 ** checked separately in byte code. If the omit flag is change to true, then
7614 ** the constraint may or may not be checked in byte code. In other words,
7615 ** when the omit flag is true there is no guarantee that the constraint will
7616 ** not be checked again using byte code.)^
7617 **
7618 ** ^The idxNum and idxStr values are recorded and passed into the
@@ -7634,11 +7634,11 @@
7634 ** will be returned by the strategy.
7635 **
7636 ** The xBestIndex method may optionally populate the idxFlags field with a
7637 ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
7638 ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7639 ** output to show the idxNum has hex instead of as decimal. Another flag is
7640 ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7641 ** return at most one row.
7642 **
7643 ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
7644 ** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -8210,11 +8210,11 @@
8210 ** function that calls sqlite3_initialize().
8211 **
8212 ** ^The sqlite3_mutex_alloc() routine allocates a new
8213 ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
8214 ** routine returns NULL if it is unable to allocate the requested
8215 ** mutex. The argument to sqlite3_mutex_alloc() must one of these
8216 ** integer constants:
8217 **
8218 ** <ul>
8219 ** <li> SQLITE_MUTEX_FAST
8220 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -8443,11 +8443,11 @@
8443
8444 /*
8445 ** CAPI3REF: Retrieve the mutex for a database connection
8446 ** METHOD: sqlite3
8447 **
8448 ** ^This interface returns a pointer the [sqlite3_mutex] object that
8449 ** serializes access to the [database connection] given in the argument
8450 ** when the [threading mode] is Serialized.
8451 ** ^If the [threading mode] is Single-thread or Multi-thread then this
8452 ** routine returns a NULL pointer.
8453 */
@@ -8566,11 +8566,11 @@
8566
8567 /*
8568 ** CAPI3REF: SQL Keyword Checking
8569 **
8570 ** These routines provide access to the set of SQL language keywords
8571 ** recognized by SQLite. Applications can uses these routines to determine
8572 ** whether or not a specific identifier needs to be escaped (for example,
8573 ** by enclosing in double-quotes) so as not to confuse the parser.
8574 **
8575 ** The sqlite3_keyword_count() interface returns the number of distinct
8576 ** keywords understood by SQLite.
@@ -8734,11 +8734,11 @@
8734 **
8735 ** ^The [sqlite3_str_value(X)] method returns a pointer to the current
8736 ** content of the dynamic string under construction in X. The value
8737 ** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
8738 ** and might be freed or altered by any subsequent method on the same
8739 ** [sqlite3_str] object. Applications must not used the pointer returned
8740 ** [sqlite3_str_value(X)] after any subsequent method call on the same
8741 ** object. ^Applications may change the content of the string returned
8742 ** by [sqlite3_str_value(X)] as long as they do not write into any bytes
8743 ** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
8744 ** write any byte after any subsequent sqlite3_str method call.
@@ -8820,11 +8820,11 @@
8820 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
8821 ** <dd>This parameter returns the number of bytes of page cache
8822 ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
8823 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
8824 ** returned value includes allocations that overflowed because they
8825 ** where too large (they were larger than the "sz" parameter to
8826 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
8827 ** no space was left in the page cache.</dd>)^
8828 **
8829 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
8830 ** <dd>This parameter records the largest memory allocation request
@@ -8904,53 +8904,55 @@
8904 ** checked out.</dd>)^
8905 **
8906 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
8907 ** <dd>This parameter returns the number of malloc attempts that were
8908 ** satisfied using lookaside memory. Only the high-water value is meaningful;
8909 ** the current value is always zero.)^
8910 **
8911 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
8912 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
8913 ** <dd>This parameter returns the number malloc attempts that might have
8914 ** been satisfied using lookaside memory but failed due to the amount of
8915 ** memory requested being larger than the lookaside slot size.
8916 ** Only the high-water value is meaningful;
8917 ** the current value is always zero.)^
8918 **
8919 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
8920 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
8921 ** <dd>This parameter returns the number malloc attempts that might have
8922 ** been satisfied using lookaside memory but failed due to all lookaside
8923 ** memory already being in use.
8924 ** Only the high-water value is meaningful;
8925 ** the current value is always zero.)^
8926 **
8927 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
8928 ** <dd>This parameter returns the approximate number of bytes of heap
8929 ** memory used by all pager caches associated with the database connection.)^
8930 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
 
8931 **
8932 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
8933 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
8934 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
8935 ** pager cache is shared between two or more connections the bytes of heap
8936 ** memory used by that pager cache is divided evenly between the attached
8937 ** connections.)^ In other words, if none of the pager caches associated
8938 ** with the database connection are shared, this request returns the same
8939 ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
8940 ** shared, the value returned by this call will be smaller than that returned
8941 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
8942 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
8943 **
8944 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
8945 ** <dd>This parameter returns the approximate number of bytes of heap
8946 ** memory used to store the schema for all databases associated
8947 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
8948 ** ^The full amount of memory used by the schemas is reported, even if the
8949 ** schema memory is shared with other database connections due to
8950 ** [shared cache mode] being enabled.
8951 ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
 
8952 **
8953 ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
8954 ** <dd>This parameter returns the approximate number of bytes of heap
8955 ** and lookaside memory used by all prepared statements associated with
8956 ** the database connection.)^
@@ -8983,11 +8985,11 @@
8983 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
8984 ** <dd>This parameter returns the number of dirty cache entries that have
8985 ** been written to disk in the middle of a transaction due to the page
8986 ** cache overflowing. Transactions are more efficient if they are written
8987 ** to disk all at once. When pages spill mid-transaction, that introduces
8988 ** additional overhead. This parameter can be used help identify
8989 ** inefficiencies that can be resolved by increasing the cache size.
8990 ** </dd>
8991 **
8992 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
8993 ** <dd>This parameter returns zero for the current value if and only if
8994
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-06-27 19:02:21 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -6036,11 +6036,11 @@
6036 /*
6037 ** CAPI3REF: Copy And Free SQL Values
6038 ** METHOD: sqlite3_value
6039 **
6040 ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
6041 ** object V and returns a pointer to that copy. ^The [sqlite3_value] returned
6042 ** is a [protected sqlite3_value] object even if the input is not.
6043 ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
6044 ** memory allocation fails. ^If V is a [pointer value], then the result
6045 ** of sqlite3_value_dup(V) is a NULL value.
6046 **
@@ -6074,11 +6074,11 @@
6074 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
6075 ** when first called if N is less than or equal to zero or if a memory
6076 ** allocation error occurs.
6077 **
6078 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6079 ** determined by the N parameter on the first successful call. Changing the
6080 ** value of N in any subsequent call to sqlite3_aggregate_context() within
6081 ** the same aggregate function instance will not resize the memory
6082 ** allocation.)^ Within the xFinal callback, it is customary to set
6083 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6084 ** pointless memory allocations occur.
@@ -6236,11 +6236,11 @@
6236 ** of as a secret key such that only code that knows the secret key is able
6237 ** to access the associated data.
6238 **
6239 ** Security Warning: These interfaces should not be exposed in scripting
6240 ** languages or in other circumstances where it might be possible for an
6241 ** attacker to invoke them. Any agent that can invoke these interfaces
6242 ** can probably also take control of the process.
6243 **
6244 ** Database connection client data is only available for SQLite
6245 ** version 3.44.0 ([dateof:3.44.0]) and later.
6246 **
@@ -6350,11 +6350,11 @@
6350 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
6351 ** is non-negative, then as many bytes (not characters) of the text
6352 ** pointed to by the 2nd parameter are taken as the application-defined
6353 ** function result. If the 3rd parameter is non-negative, then it
6354 ** must be the byte offset into the string where the NUL terminator would
6355 ** appear if the string were NUL terminated. If any NUL characters occur
6356 ** in the string at a byte offset that is less than the value of the 3rd
6357 ** parameter, then the resulting string will contain embedded NULs and the
6358 ** result of expressions operating on strings with embedded NULs is undefined.
6359 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
6360 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
@@ -6408,11 +6408,11 @@
6408 ** for the P parameter. ^SQLite invokes D with P as its only argument
6409 ** when SQLite is finished with P. The T parameter should be a static
6410 ** string and preferably a string literal. The sqlite3_result_pointer()
6411 ** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
6412 **
6413 ** If these routines are called from within a different thread
6414 ** than the one containing the application-defined function that received
6415 ** the [sqlite3_context] pointer, the results are undefined.
6416 */
6417 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
6418 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
@@ -6814,11 +6814,11 @@
6814 /*
6815 ** CAPI3REF: Return The Schema Name For A Database Connection
6816 ** METHOD: sqlite3
6817 **
6818 ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
6819 ** for the N-th database on database connection D, or a NULL pointer if N is
6820 ** out of range. An N value of 0 means the main database file. An N of 1 is
6821 ** the "temp" schema. Larger values of N correspond to various ATTACH-ed
6822 ** databases.
6823 **
6824 ** Space to hold the string that is returned by sqlite3_db_name() is managed
@@ -6909,20 +6909,20 @@
6909 **
6910 ** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
6911 ** <dd>The SQLITE_TXN_READ state means that the database is currently
6912 ** in a read transaction. Content has been read from the database file
6913 ** but nothing in the database file has changed. The transaction state
6914 ** will be advanced to SQLITE_TXN_WRITE if any changes occur and there are
6915 ** no other conflicting concurrent write transactions. The transaction
6916 ** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
6917 ** [COMMIT].</dd>
6918 **
6919 ** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
6920 ** <dd>The SQLITE_TXN_WRITE state means that the database is currently
6921 ** in a write transaction. Content has been written to the database file
6922 ** but has not yet committed. The transaction state will change to
6923 ** SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
6924 */
6925 #define SQLITE_TXN_NONE 0
6926 #define SQLITE_TXN_READ 1
6927 #define SQLITE_TXN_WRITE 2
6928
@@ -7199,11 +7199,11 @@
7199
7200 /*
7201 ** CAPI3REF: Impose A Limit On Heap Size
7202 **
7203 ** These interfaces impose limits on the amount of heap memory that will be
7204 ** used by all database connections within a single process.
7205 **
7206 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
7207 ** soft limit on the amount of heap memory that may be allocated by SQLite.
7208 ** ^SQLite strives to keep heap memory utilization below the soft heap
7209 ** limit by reducing the number of pages held in the page cache
@@ -7257,11 +7257,11 @@
7257 ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
7258 ** from the heap.
7259 ** </ul>)^
7260 **
7261 ** The circumstances under which SQLite will enforce the heap limits may
7262 ** change in future releases of SQLite.
7263 */
7264 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
7265 SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N);
7266
7267 /*
@@ -7372,12 +7372,12 @@
7372 ** be tried also.
7373 **
7374 ** ^The entry point is zProc.
7375 ** ^(zProc may be 0, in which case SQLite will try to come up with an
7376 ** entry point name on its own. It first tries "sqlite3_extension_init".
7377 ** If that does not work, it constructs a name "sqlite3_X_init" where
7378 ** X consists of the lower-case equivalent of all ASCII alphabetic
7379 ** characters in the filename from the last "/" to the first following
7380 ** "." and omitting any initial "lib".)^
7381 ** ^The sqlite3_load_extension() interface returns
7382 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7383 ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7608,11 +7608,11 @@
7608 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
7609 ** is true, then the constraint is assumed to be fully handled by the
7610 ** virtual table and might not be checked again by the byte code.)^ ^(The
7611 ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
7612 ** is left in its default setting of false, the constraint will always be
7613 ** checked separately in byte code. If the omit flag is changed to true, then
7614 ** the constraint may or may not be checked in byte code. In other words,
7615 ** when the omit flag is true there is no guarantee that the constraint will
7616 ** not be checked again using byte code.)^
7617 **
7618 ** ^The idxNum and idxStr values are recorded and passed into the
@@ -7634,11 +7634,11 @@
7634 ** will be returned by the strategy.
7635 **
7636 ** The xBestIndex method may optionally populate the idxFlags field with a
7637 ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
7638 ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7639 ** output to show the idxNum as hex instead of as decimal. Another flag is
7640 ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7641 ** return at most one row.
7642 **
7643 ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
7644 ** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -8210,11 +8210,11 @@
8210 ** function that calls sqlite3_initialize().
8211 **
8212 ** ^The sqlite3_mutex_alloc() routine allocates a new
8213 ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
8214 ** routine returns NULL if it is unable to allocate the requested
8215 ** mutex. The argument to sqlite3_mutex_alloc() must be one of these
8216 ** integer constants:
8217 **
8218 ** <ul>
8219 ** <li> SQLITE_MUTEX_FAST
8220 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -8443,11 +8443,11 @@
8443
8444 /*
8445 ** CAPI3REF: Retrieve the mutex for a database connection
8446 ** METHOD: sqlite3
8447 **
8448 ** ^This interface returns a pointer to the [sqlite3_mutex] object that
8449 ** serializes access to the [database connection] given in the argument
8450 ** when the [threading mode] is Serialized.
8451 ** ^If the [threading mode] is Single-thread or Multi-thread then this
8452 ** routine returns a NULL pointer.
8453 */
@@ -8566,11 +8566,11 @@
8566
8567 /*
8568 ** CAPI3REF: SQL Keyword Checking
8569 **
8570 ** These routines provide access to the set of SQL language keywords
8571 ** recognized by SQLite. Applications can use these routines to determine
8572 ** whether or not a specific identifier needs to be escaped (for example,
8573 ** by enclosing in double-quotes) so as not to confuse the parser.
8574 **
8575 ** The sqlite3_keyword_count() interface returns the number of distinct
8576 ** keywords understood by SQLite.
@@ -8734,11 +8734,11 @@
8734 **
8735 ** ^The [sqlite3_str_value(X)] method returns a pointer to the current
8736 ** content of the dynamic string under construction in X. The value
8737 ** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
8738 ** and might be freed or altered by any subsequent method on the same
8739 ** [sqlite3_str] object. Applications must not use the pointer returned by
8740 ** [sqlite3_str_value(X)] after any subsequent method call on the same
8741 ** object. ^Applications may change the content of the string returned
8742 ** by [sqlite3_str_value(X)] as long as they do not write into any bytes
8743 ** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
8744 ** write any byte after any subsequent sqlite3_str method call.
@@ -8820,11 +8820,11 @@
8820 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
8821 ** <dd>This parameter returns the number of bytes of page cache
8822 ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
8823 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
8824 ** returned value includes allocations that overflowed because they
8825 ** were too large (they were larger than the "sz" parameter to
8826 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
8827 ** no space was left in the page cache.</dd>)^
8828 **
8829 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
8830 ** <dd>This parameter records the largest memory allocation request
@@ -8904,53 +8904,55 @@
8904 ** checked out.</dd>)^
8905 **
8906 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
8907 ** <dd>This parameter returns the number of malloc attempts that were
8908 ** satisfied using lookaside memory. Only the high-water value is meaningful;
8909 ** the current value is always zero.</dd>)^
8910 **
8911 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
8912 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
8913 ** <dd>This parameter returns the number of malloc attempts that might have
8914 ** been satisfied using lookaside memory but failed due to the amount of
8915 ** memory requested being larger than the lookaside slot size.
8916 ** Only the high-water value is meaningful;
8917 ** the current value is always zero.</dd>)^
8918 **
8919 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
8920 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
8921 ** <dd>This parameter returns the number of malloc attempts that might have
8922 ** been satisfied using lookaside memory but failed due to all lookaside
8923 ** memory already being in use.
8924 ** Only the high-water value is meaningful;
8925 ** the current value is always zero.</dd>)^
8926 **
8927 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
8928 ** <dd>This parameter returns the approximate number of bytes of heap
8929 ** memory used by all pager caches associated with the database connection.)^
8930 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
8931 ** </dd>
8932 **
8933 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
8934 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
8935 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
8936 ** pager cache is shared between two or more connections the bytes of heap
8937 ** memory used by that pager cache is divided evenly between the attached
8938 ** connections.)^ In other words, if none of the pager caches associated
8939 ** with the database connection are shared, this request returns the same
8940 ** value as DBSTATUS_CACHE_USED. Or, if one or more of the pager caches are
8941 ** shared, the value returned by this call will be smaller than that returned
8942 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
8943 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</dd>
8944 **
8945 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
8946 ** <dd>This parameter returns the approximate number of bytes of heap
8947 ** memory used to store the schema for all databases associated
8948 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
8949 ** ^The full amount of memory used by the schemas is reported, even if the
8950 ** schema memory is shared with other database connections due to
8951 ** [shared cache mode] being enabled.
8952 ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
8953 ** </dd>
8954 **
8955 ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
8956 ** <dd>This parameter returns the approximate number of bytes of heap
8957 ** and lookaside memory used by all prepared statements associated with
8958 ** the database connection.)^
@@ -8983,11 +8985,11 @@
8985 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
8986 ** <dd>This parameter returns the number of dirty cache entries that have
8987 ** been written to disk in the middle of a transaction due to the page
8988 ** cache overflowing. Transactions are more efficient if they are written
8989 ** to disk all at once. When pages spill mid-transaction, that introduces
8990 ** additional overhead. This parameter can be used to help identify
8991 ** inefficiencies that can be resolved by increasing the cache size.
8992 ** </dd>
8993 **
8994 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
8995 ** <dd>This parameter returns zero for the current value if and only if
8996

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button