Fossil SCM

Update the built-in SQLite to the latest trunk check-in for beta testing of SQLite.

drh 2025-10-15 11:52 trunk
Commit 3c639f742096eea432d96964551dee48334bf7e96f2834d832f0153596fbac3b
3 files changed +66 -18 +137 -144 +31 -5
+66 -18
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3724,11 +3724,12 @@
37243724
iExp -= p->nFrac;
37253725
p->nFrac = 0;
37263726
}
37273727
}
37283728
if( iExp>0 ){
3729
- p->a = sqlite3_realloc64(p->a, p->nDigit + iExp + 1 );
3729
+ p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
3730
+ + (sqlite3_int64)iExp + 1 );
37303731
if( p->a==0 ) goto new_from_text_failed;
37313732
memset(p->a+p->nDigit, 0, iExp);
37323733
p->nDigit += iExp;
37333734
}
37343735
}else if( iExp<0 ){
@@ -3743,11 +3744,12 @@
37433744
iExp -= nExtra;
37443745
p->nFrac = p->nDigit - 1;
37453746
}
37463747
}
37473748
if( iExp>0 ){
3748
- p->a = sqlite3_realloc64(p->a, p->nDigit + iExp + 1 );
3749
+ p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
3750
+ + (sqlite3_int64)iExp + 1 );
37493751
if( p->a==0 ) goto new_from_text_failed;
37503752
memmove(p->a+iExp, p->a, p->nDigit);
37513753
memset(p->a, 0, iExp);
37523754
p->nDigit += iExp;
37533755
p->nFrac += iExp;
@@ -3847,11 +3849,11 @@
38473849
}
38483850
if( p->isNull ){
38493851
sqlite3_result_null(pCtx);
38503852
return;
38513853
}
3852
- z = sqlite3_malloc( p->nDigit+4 );
3854
+ z = sqlite3_malloc64( (sqlite3_int64)p->nDigit+4 );
38533855
if( z==0 ){
38543856
sqlite3_result_error_nomem(pCtx);
38553857
return;
38563858
}
38573859
i = 0;
@@ -3912,11 +3914,11 @@
39123914
}
39133915
for(nDigit=p->nDigit; nDigit>0 && p->a[nDigit-1]==0; nDigit--){}
39143916
for(nZero=0; nZero<nDigit && p->a[nZero]==0; nZero++){}
39153917
nFrac = p->nFrac + (nDigit - p->nDigit);
39163918
nDigit -= nZero;
3917
- z = sqlite3_malloc( nDigit+20 );
3919
+ z = sqlite3_malloc64( (sqlite3_int64)nDigit+20 );
39183920
if( z==0 ){
39193921
sqlite3_result_error_nomem(pCtx);
39203922
return;
39213923
}
39223924
if( nDigit==0 ){
@@ -4133,11 +4135,12 @@
41334135
if( pA==0 || pA->oom || pA->isNull
41344136
|| pB==0 || pB->oom || pB->isNull
41354137
){
41364138
goto mul_end;
41374139
}
4138
- acc = sqlite3_malloc64( pA->nDigit + pB->nDigit + 2 );
4140
+ acc = sqlite3_malloc64( (sqlite3_int64)pA->nDigit +
4141
+ (sqlite3_int64)pB->nDigit + 2 );
41394142
if( acc==0 ){
41404143
pA->oom = 1;
41414144
goto mul_end;
41424145
}
41434146
memset(acc, 0, pA->nDigit + pB->nDigit + 2);
@@ -5951,10 +5954,49 @@
59515954
assert( pCur->iBase <= pCur->iTerm );
59525955
return span64(pCur->iTerm, pCur->iBase)/pCur->iStep;
59535956
}
59545957
}
59555958
5959
+#if defined(SQLITE_ENABLE_MATH_FUNCTIONS) || defined(_WIN32)
5960
+/*
5961
+** Case 1 (the most common case):
5962
+** The standard math library is available so use ceil() and floor() from there.
5963
+*/
5964
+static double seriesCeil(double r){ return ceil(r); }
5965
+static double seriesFloor(double r){ return floor(r); }
5966
+#elif defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)
5967
+/*
5968
+** Case 2 (2nd most common): Use GCC/Clang builtins
5969
+*/
5970
+static double seriesCeil(double r){ return __builtin_ceil(r); }
5971
+static double seriesFloor(double r){ return __builtin_floor(r); }
5972
+#else
5973
+/*
5974
+** Case 3 (rarely happens): Use home-grown ceil() and floor() routines.
5975
+*/
5976
+static double seriesCeil(double r){
5977
+ sqlite3_int64 x;
5978
+ if( r!=r ) return r;
5979
+ if( r<=(-4503599627370496.0) ) return r;
5980
+ if( r>=(+4503599627370496.0) ) return r;
5981
+ x = (sqlite3_int64)r;
5982
+ if( r==(double)x ) return r;
5983
+ if( r>(double)x ) x++;
5984
+ return (double)x;
5985
+}
5986
+static double seriesFloor(double r){
5987
+ sqlite3_int64 x;
5988
+ if( r!=r ) return r;
5989
+ if( r<=(-4503599627370496.0) ) return r;
5990
+ if( r>=(+4503599627370496.0) ) return r;
5991
+ x = (sqlite3_int64)r;
5992
+ if( r==(double)x ) return r;
5993
+ if( r<(double)x ) x--;
5994
+ return (double)x;
5995
+}
5996
+#endif
5997
+
59565998
/*
59575999
** This method is called to "rewind" the series_cursor object back
59586000
** to the first row of output. This method is always called at least
59596001
** once prior to any call to seriesColumn() or seriesRowid() or
59606002
** seriesEof().
@@ -6069,11 +6111,11 @@
60696111
*/
60706112
if( idxNum & 0x3380 ){
60716113
if( idxNum & 0x0080 ){ /* value=X */
60726114
if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
60736115
double r = sqlite3_value_double(argv[iArg++]);
6074
- if( r==ceil(r)
6116
+ if( r==seriesCeil(r)
60756117
&& r>=(double)SMALLEST_INT64
60766118
&& r<=(double)LARGEST_INT64
60776119
){
60786120
iMin = iMax = (sqlite3_int64)r;
60796121
}else{
@@ -6086,14 +6128,14 @@
60866128
if( idxNum & 0x0300 ){ /* value>X or value>=X */
60876129
if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
60886130
double r = sqlite3_value_double(argv[iArg++]);
60896131
if( r<(double)SMALLEST_INT64 ){
60906132
iMin = SMALLEST_INT64;
6091
- }else if( (idxNum & 0x0200)!=0 && r==ceil(r) ){
6092
- iMin = (sqlite3_int64)ceil(r+1.0);
6133
+ }else if( (idxNum & 0x0200)!=0 && r==seriesCeil(r) ){
6134
+ iMin = (sqlite3_int64)seriesCeil(r+1.0);
60936135
}else{
6094
- iMin = (sqlite3_int64)ceil(r);
6136
+ iMin = (sqlite3_int64)seriesCeil(r);
60956137
}
60966138
}else{
60976139
iMin = sqlite3_value_int64(argv[iArg++]);
60986140
if( (idxNum & 0x0200)!=0 ){
60996141
if( iMin==LARGEST_INT64 ){
@@ -6107,14 +6149,14 @@
61076149
if( idxNum & 0x3000 ){ /* value<X or value<=X */
61086150
if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
61096151
double r = sqlite3_value_double(argv[iArg++]);
61106152
if( r>(double)LARGEST_INT64 ){
61116153
iMax = LARGEST_INT64;
6112
- }else if( (idxNum & 0x2000)!=0 && r==floor(r) ){
6154
+ }else if( (idxNum & 0x2000)!=0 && r==seriesFloor(r) ){
61136155
iMax = (sqlite3_int64)(r-1.0);
61146156
}else{
6115
- iMax = (sqlite3_int64)floor(r);
6157
+ iMax = (sqlite3_int64)seriesFloor(r);
61166158
}
61176159
}else{
61186160
iMax = sqlite3_value_int64(argv[iArg++]);
61196161
if( idxNum & 0x2000 ){
61206162
if( iMax==SMALLEST_INT64 ){
@@ -6193,21 +6235,20 @@
61936235
}
61946236
61956237
/* Apply LIMIT and OFFSET constraints, if any */
61966238
assert( pCur->iStep!=0 );
61976239
if( idxNum & 0x20 ){
6198
- sqlite3_uint64 nStep;
61996240
if( iOffset>0 ){
62006241
if( seriesSteps(pCur) < (sqlite3_uint64)iOffset ){
62016242
goto series_no_rows;
62026243
}else if( pCur->bDesc ){
62036244
pCur->iBase = sub64(pCur->iBase, pCur->iStep*iOffset);
62046245
}else{
62056246
pCur->iBase = add64(pCur->iBase, pCur->iStep*iOffset);
62066247
}
62076248
}
6208
- if( iLimit>=0 && (nStep = seriesSteps(pCur)) > (sqlite3_uint64)iLimit ){
6249
+ if( iLimit>=0 && seriesSteps(pCur) > (sqlite3_uint64)iLimit ){
62096250
pCur->iTerm = add64(pCur->iBase, (iLimit - 1)*pCur->iStep);
62106251
}
62116252
}
62126253
pCur->iValue = pCur->iBase;
62136254
pCur->bDone = 0;
@@ -23156,12 +23197,12 @@
2315623197
static int display_stats(
2315723198
sqlite3 *db, /* Database to query */
2315823199
ShellState *pArg, /* Pointer to ShellState */
2315923200
int bReset /* True to reset the stats */
2316023201
){
23161
- int iCur;
23162
- int iHiwtr;
23202
+ int iCur, iHiwtr;
23203
+ sqlite3_int64 iCur64, iHiwtr64;
2316323204
FILE *out;
2316423205
if( pArg==0 || pArg->out==0 ) return 0;
2316523206
out = pArg->out;
2316623207
2316723208
if( pArg->pStmt && pArg->statsOn==2 ){
@@ -23246,18 +23287,25 @@
2324623287
"Page cache hits: %d\n", iCur);
2324723288
iHiwtr = iCur = -1;
2324823289
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
2324923290
sqlite3_fprintf(out,
2325023291
"Page cache misses: %d\n", iCur);
23292
+ iHiwtr64 = iCur64 = -1;
23293
+ sqlite3_db_status64(db, SQLITE_DBSTATUS_TEMPBUF_SPILL, &iCur64, &iHiwtr64,
23294
+ 0);
2325123295
iHiwtr = iCur = -1;
2325223296
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
2325323297
sqlite3_fprintf(out,
2325423298
"Page cache writes: %d\n", iCur);
2325523299
iHiwtr = iCur = -1;
2325623300
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_SPILL, &iCur, &iHiwtr, 1);
2325723301
sqlite3_fprintf(out,
2325823302
"Page cache spills: %d\n", iCur);
23303
+ sqlite3_fprintf(out,
23304
+ "Temporary data spilled to disk: %lld\n", iCur64);
23305
+ sqlite3_db_status64(db, SQLITE_DBSTATUS_TEMPBUF_SPILL, &iCur64, &iHiwtr64,
23306
+ 1);
2325923307
iHiwtr = iCur = -1;
2326023308
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
2326123309
sqlite3_fprintf(out,
2326223310
"Schema Heap Usage: %d bytes\n", iCur);
2326323311
iHiwtr = iCur = -1;
@@ -24962,11 +25010,11 @@
2496225010
" from the \".mode\" output mode",
2496325011
" * If FILE begins with \"|\" then it is a command that generates the",
2496425012
" input text.",
2496525013
#endif
2496625014
#ifndef SQLITE_OMIT_TEST_CONTROL
24967
- ",imposter INDEX TABLE Create imposter table TABLE on index INDEX",
25015
+ ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
2496825016
#endif
2496925017
".indexes ?TABLE? Show names of indexes",
2497025018
" If TABLE is specified, only show indexes for",
2497125019
" tables matching TABLE using the LIKE operator.",
2497225020
".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db",
@@ -31402,14 +31450,14 @@
3140231450
sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
3140331451
}
3140431452
while( sqlite3_step(pStmt)==SQLITE_ROW ){
3140531453
if( nRow>=nAlloc ){
3140631454
char **azNew;
31407
- int n2 = nAlloc*2 + 10;
31455
+ sqlite3_int64 n2 = 2*(sqlite3_int64)nAlloc + 10;
3140831456
azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
3140931457
shell_check_oom(azNew);
31410
- nAlloc = n2;
31458
+ nAlloc = (int)n2;
3141131459
azResult = azNew;
3141231460
}
3141331461
azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
3141431462
shell_check_oom(azResult[nRow]);
3141531463
nRow++;
3141631464
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3724,11 +3724,12 @@
3724 iExp -= p->nFrac;
3725 p->nFrac = 0;
3726 }
3727 }
3728 if( iExp>0 ){
3729 p->a = sqlite3_realloc64(p->a, p->nDigit + iExp + 1 );
 
3730 if( p->a==0 ) goto new_from_text_failed;
3731 memset(p->a+p->nDigit, 0, iExp);
3732 p->nDigit += iExp;
3733 }
3734 }else if( iExp<0 ){
@@ -3743,11 +3744,12 @@
3743 iExp -= nExtra;
3744 p->nFrac = p->nDigit - 1;
3745 }
3746 }
3747 if( iExp>0 ){
3748 p->a = sqlite3_realloc64(p->a, p->nDigit + iExp + 1 );
 
3749 if( p->a==0 ) goto new_from_text_failed;
3750 memmove(p->a+iExp, p->a, p->nDigit);
3751 memset(p->a, 0, iExp);
3752 p->nDigit += iExp;
3753 p->nFrac += iExp;
@@ -3847,11 +3849,11 @@
3847 }
3848 if( p->isNull ){
3849 sqlite3_result_null(pCtx);
3850 return;
3851 }
3852 z = sqlite3_malloc( p->nDigit+4 );
3853 if( z==0 ){
3854 sqlite3_result_error_nomem(pCtx);
3855 return;
3856 }
3857 i = 0;
@@ -3912,11 +3914,11 @@
3912 }
3913 for(nDigit=p->nDigit; nDigit>0 && p->a[nDigit-1]==0; nDigit--){}
3914 for(nZero=0; nZero<nDigit && p->a[nZero]==0; nZero++){}
3915 nFrac = p->nFrac + (nDigit - p->nDigit);
3916 nDigit -= nZero;
3917 z = sqlite3_malloc( nDigit+20 );
3918 if( z==0 ){
3919 sqlite3_result_error_nomem(pCtx);
3920 return;
3921 }
3922 if( nDigit==0 ){
@@ -4133,11 +4135,12 @@
4133 if( pA==0 || pA->oom || pA->isNull
4134 || pB==0 || pB->oom || pB->isNull
4135 ){
4136 goto mul_end;
4137 }
4138 acc = sqlite3_malloc64( pA->nDigit + pB->nDigit + 2 );
 
4139 if( acc==0 ){
4140 pA->oom = 1;
4141 goto mul_end;
4142 }
4143 memset(acc, 0, pA->nDigit + pB->nDigit + 2);
@@ -5951,10 +5954,49 @@
5951 assert( pCur->iBase <= pCur->iTerm );
5952 return span64(pCur->iTerm, pCur->iBase)/pCur->iStep;
5953 }
5954 }
5955
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5956 /*
5957 ** This method is called to "rewind" the series_cursor object back
5958 ** to the first row of output. This method is always called at least
5959 ** once prior to any call to seriesColumn() or seriesRowid() or
5960 ** seriesEof().
@@ -6069,11 +6111,11 @@
6069 */
6070 if( idxNum & 0x3380 ){
6071 if( idxNum & 0x0080 ){ /* value=X */
6072 if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
6073 double r = sqlite3_value_double(argv[iArg++]);
6074 if( r==ceil(r)
6075 && r>=(double)SMALLEST_INT64
6076 && r<=(double)LARGEST_INT64
6077 ){
6078 iMin = iMax = (sqlite3_int64)r;
6079 }else{
@@ -6086,14 +6128,14 @@
6086 if( idxNum & 0x0300 ){ /* value>X or value>=X */
6087 if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
6088 double r = sqlite3_value_double(argv[iArg++]);
6089 if( r<(double)SMALLEST_INT64 ){
6090 iMin = SMALLEST_INT64;
6091 }else if( (idxNum & 0x0200)!=0 && r==ceil(r) ){
6092 iMin = (sqlite3_int64)ceil(r+1.0);
6093 }else{
6094 iMin = (sqlite3_int64)ceil(r);
6095 }
6096 }else{
6097 iMin = sqlite3_value_int64(argv[iArg++]);
6098 if( (idxNum & 0x0200)!=0 ){
6099 if( iMin==LARGEST_INT64 ){
@@ -6107,14 +6149,14 @@
6107 if( idxNum & 0x3000 ){ /* value<X or value<=X */
6108 if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
6109 double r = sqlite3_value_double(argv[iArg++]);
6110 if( r>(double)LARGEST_INT64 ){
6111 iMax = LARGEST_INT64;
6112 }else if( (idxNum & 0x2000)!=0 && r==floor(r) ){
6113 iMax = (sqlite3_int64)(r-1.0);
6114 }else{
6115 iMax = (sqlite3_int64)floor(r);
6116 }
6117 }else{
6118 iMax = sqlite3_value_int64(argv[iArg++]);
6119 if( idxNum & 0x2000 ){
6120 if( iMax==SMALLEST_INT64 ){
@@ -6193,21 +6235,20 @@
6193 }
6194
6195 /* Apply LIMIT and OFFSET constraints, if any */
6196 assert( pCur->iStep!=0 );
6197 if( idxNum & 0x20 ){
6198 sqlite3_uint64 nStep;
6199 if( iOffset>0 ){
6200 if( seriesSteps(pCur) < (sqlite3_uint64)iOffset ){
6201 goto series_no_rows;
6202 }else if( pCur->bDesc ){
6203 pCur->iBase = sub64(pCur->iBase, pCur->iStep*iOffset);
6204 }else{
6205 pCur->iBase = add64(pCur->iBase, pCur->iStep*iOffset);
6206 }
6207 }
6208 if( iLimit>=0 && (nStep = seriesSteps(pCur)) > (sqlite3_uint64)iLimit ){
6209 pCur->iTerm = add64(pCur->iBase, (iLimit - 1)*pCur->iStep);
6210 }
6211 }
6212 pCur->iValue = pCur->iBase;
6213 pCur->bDone = 0;
@@ -23156,12 +23197,12 @@
23156 static int display_stats(
23157 sqlite3 *db, /* Database to query */
23158 ShellState *pArg, /* Pointer to ShellState */
23159 int bReset /* True to reset the stats */
23160 ){
23161 int iCur;
23162 int iHiwtr;
23163 FILE *out;
23164 if( pArg==0 || pArg->out==0 ) return 0;
23165 out = pArg->out;
23166
23167 if( pArg->pStmt && pArg->statsOn==2 ){
@@ -23246,18 +23287,25 @@
23246 "Page cache hits: %d\n", iCur);
23247 iHiwtr = iCur = -1;
23248 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
23249 sqlite3_fprintf(out,
23250 "Page cache misses: %d\n", iCur);
 
 
 
23251 iHiwtr = iCur = -1;
23252 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
23253 sqlite3_fprintf(out,
23254 "Page cache writes: %d\n", iCur);
23255 iHiwtr = iCur = -1;
23256 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_SPILL, &iCur, &iHiwtr, 1);
23257 sqlite3_fprintf(out,
23258 "Page cache spills: %d\n", iCur);
 
 
 
 
23259 iHiwtr = iCur = -1;
23260 sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
23261 sqlite3_fprintf(out,
23262 "Schema Heap Usage: %d bytes\n", iCur);
23263 iHiwtr = iCur = -1;
@@ -24962,11 +25010,11 @@
24962 " from the \".mode\" output mode",
24963 " * If FILE begins with \"|\" then it is a command that generates the",
24964 " input text.",
24965 #endif
24966 #ifndef SQLITE_OMIT_TEST_CONTROL
24967 ",imposter INDEX TABLE Create imposter table TABLE on index INDEX",
24968 #endif
24969 ".indexes ?TABLE? Show names of indexes",
24970 " If TABLE is specified, only show indexes for",
24971 " tables matching TABLE using the LIKE operator.",
24972 ".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db",
@@ -31402,14 +31450,14 @@
31402 sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
31403 }
31404 while( sqlite3_step(pStmt)==SQLITE_ROW ){
31405 if( nRow>=nAlloc ){
31406 char **azNew;
31407 int n2 = nAlloc*2 + 10;
31408 azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
31409 shell_check_oom(azNew);
31410 nAlloc = n2;
31411 azResult = azNew;
31412 }
31413 azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
31414 shell_check_oom(azResult[nRow]);
31415 nRow++;
31416
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3724,11 +3724,12 @@
3724 iExp -= p->nFrac;
3725 p->nFrac = 0;
3726 }
3727 }
3728 if( iExp>0 ){
3729 p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
3730 + (sqlite3_int64)iExp + 1 );
3731 if( p->a==0 ) goto new_from_text_failed;
3732 memset(p->a+p->nDigit, 0, iExp);
3733 p->nDigit += iExp;
3734 }
3735 }else if( iExp<0 ){
@@ -3743,11 +3744,12 @@
3744 iExp -= nExtra;
3745 p->nFrac = p->nDigit - 1;
3746 }
3747 }
3748 if( iExp>0 ){
3749 p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
3750 + (sqlite3_int64)iExp + 1 );
3751 if( p->a==0 ) goto new_from_text_failed;
3752 memmove(p->a+iExp, p->a, p->nDigit);
3753 memset(p->a, 0, iExp);
3754 p->nDigit += iExp;
3755 p->nFrac += iExp;
@@ -3847,11 +3849,11 @@
3849 }
3850 if( p->isNull ){
3851 sqlite3_result_null(pCtx);
3852 return;
3853 }
3854 z = sqlite3_malloc64( (sqlite3_int64)p->nDigit+4 );
3855 if( z==0 ){
3856 sqlite3_result_error_nomem(pCtx);
3857 return;
3858 }
3859 i = 0;
@@ -3912,11 +3914,11 @@
3914 }
3915 for(nDigit=p->nDigit; nDigit>0 && p->a[nDigit-1]==0; nDigit--){}
3916 for(nZero=0; nZero<nDigit && p->a[nZero]==0; nZero++){}
3917 nFrac = p->nFrac + (nDigit - p->nDigit);
3918 nDigit -= nZero;
3919 z = sqlite3_malloc64( (sqlite3_int64)nDigit+20 );
3920 if( z==0 ){
3921 sqlite3_result_error_nomem(pCtx);
3922 return;
3923 }
3924 if( nDigit==0 ){
@@ -4133,11 +4135,12 @@
4135 if( pA==0 || pA->oom || pA->isNull
4136 || pB==0 || pB->oom || pB->isNull
4137 ){
4138 goto mul_end;
4139 }
4140 acc = sqlite3_malloc64( (sqlite3_int64)pA->nDigit +
4141 (sqlite3_int64)pB->nDigit + 2 );
4142 if( acc==0 ){
4143 pA->oom = 1;
4144 goto mul_end;
4145 }
4146 memset(acc, 0, pA->nDigit + pB->nDigit + 2);
@@ -5951,10 +5954,49 @@
5954 assert( pCur->iBase <= pCur->iTerm );
5955 return span64(pCur->iTerm, pCur->iBase)/pCur->iStep;
5956 }
5957 }
5958
5959 #if defined(SQLITE_ENABLE_MATH_FUNCTIONS) || defined(_WIN32)
5960 /*
5961 ** Case 1 (the most common case):
5962 ** The standard math library is available so use ceil() and floor() from there.
5963 */
5964 static double seriesCeil(double r){ return ceil(r); }
5965 static double seriesFloor(double r){ return floor(r); }
5966 #elif defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)
5967 /*
5968 ** Case 2 (2nd most common): Use GCC/Clang builtins
5969 */
5970 static double seriesCeil(double r){ return __builtin_ceil(r); }
5971 static double seriesFloor(double r){ return __builtin_floor(r); }
5972 #else
5973 /*
5974 ** Case 3 (rarely happens): Use home-grown ceil() and floor() routines.
5975 */
5976 static double seriesCeil(double r){
5977 sqlite3_int64 x;
5978 if( r!=r ) return r;
5979 if( r<=(-4503599627370496.0) ) return r;
5980 if( r>=(+4503599627370496.0) ) return r;
5981 x = (sqlite3_int64)r;
5982 if( r==(double)x ) return r;
5983 if( r>(double)x ) x++;
5984 return (double)x;
5985 }
5986 static double seriesFloor(double r){
5987 sqlite3_int64 x;
5988 if( r!=r ) return r;
5989 if( r<=(-4503599627370496.0) ) return r;
5990 if( r>=(+4503599627370496.0) ) return r;
5991 x = (sqlite3_int64)r;
5992 if( r==(double)x ) return r;
5993 if( r<(double)x ) x--;
5994 return (double)x;
5995 }
5996 #endif
5997
5998 /*
5999 ** This method is called to "rewind" the series_cursor object back
6000 ** to the first row of output. This method is always called at least
6001 ** once prior to any call to seriesColumn() or seriesRowid() or
6002 ** seriesEof().
@@ -6069,11 +6111,11 @@
6111 */
6112 if( idxNum & 0x3380 ){
6113 if( idxNum & 0x0080 ){ /* value=X */
6114 if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
6115 double r = sqlite3_value_double(argv[iArg++]);
6116 if( r==seriesCeil(r)
6117 && r>=(double)SMALLEST_INT64
6118 && r<=(double)LARGEST_INT64
6119 ){
6120 iMin = iMax = (sqlite3_int64)r;
6121 }else{
@@ -6086,14 +6128,14 @@
6128 if( idxNum & 0x0300 ){ /* value>X or value>=X */
6129 if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
6130 double r = sqlite3_value_double(argv[iArg++]);
6131 if( r<(double)SMALLEST_INT64 ){
6132 iMin = SMALLEST_INT64;
6133 }else if( (idxNum & 0x0200)!=0 && r==seriesCeil(r) ){
6134 iMin = (sqlite3_int64)seriesCeil(r+1.0);
6135 }else{
6136 iMin = (sqlite3_int64)seriesCeil(r);
6137 }
6138 }else{
6139 iMin = sqlite3_value_int64(argv[iArg++]);
6140 if( (idxNum & 0x0200)!=0 ){
6141 if( iMin==LARGEST_INT64 ){
@@ -6107,14 +6149,14 @@
6149 if( idxNum & 0x3000 ){ /* value<X or value<=X */
6150 if( sqlite3_value_numeric_type(argv[iArg])==SQLITE_FLOAT ){
6151 double r = sqlite3_value_double(argv[iArg++]);
6152 if( r>(double)LARGEST_INT64 ){
6153 iMax = LARGEST_INT64;
6154 }else if( (idxNum & 0x2000)!=0 && r==seriesFloor(r) ){
6155 iMax = (sqlite3_int64)(r-1.0);
6156 }else{
6157 iMax = (sqlite3_int64)seriesFloor(r);
6158 }
6159 }else{
6160 iMax = sqlite3_value_int64(argv[iArg++]);
6161 if( idxNum & 0x2000 ){
6162 if( iMax==SMALLEST_INT64 ){
@@ -6193,21 +6235,20 @@
6235 }
6236
6237 /* Apply LIMIT and OFFSET constraints, if any */
6238 assert( pCur->iStep!=0 );
6239 if( idxNum & 0x20 ){
 
6240 if( iOffset>0 ){
6241 if( seriesSteps(pCur) < (sqlite3_uint64)iOffset ){
6242 goto series_no_rows;
6243 }else if( pCur->bDesc ){
6244 pCur->iBase = sub64(pCur->iBase, pCur->iStep*iOffset);
6245 }else{
6246 pCur->iBase = add64(pCur->iBase, pCur->iStep*iOffset);
6247 }
6248 }
6249 if( iLimit>=0 && seriesSteps(pCur) > (sqlite3_uint64)iLimit ){
6250 pCur->iTerm = add64(pCur->iBase, (iLimit - 1)*pCur->iStep);
6251 }
6252 }
6253 pCur->iValue = pCur->iBase;
6254 pCur->bDone = 0;
@@ -23156,12 +23197,12 @@
23197 static int display_stats(
23198 sqlite3 *db, /* Database to query */
23199 ShellState *pArg, /* Pointer to ShellState */
23200 int bReset /* True to reset the stats */
23201 ){
23202 int iCur, iHiwtr;
23203 sqlite3_int64 iCur64, iHiwtr64;
23204 FILE *out;
23205 if( pArg==0 || pArg->out==0 ) return 0;
23206 out = pArg->out;
23207
23208 if( pArg->pStmt && pArg->statsOn==2 ){
@@ -23246,18 +23287,25 @@
23287 "Page cache hits: %d\n", iCur);
23288 iHiwtr = iCur = -1;
23289 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
23290 sqlite3_fprintf(out,
23291 "Page cache misses: %d\n", iCur);
23292 iHiwtr64 = iCur64 = -1;
23293 sqlite3_db_status64(db, SQLITE_DBSTATUS_TEMPBUF_SPILL, &iCur64, &iHiwtr64,
23294 0);
23295 iHiwtr = iCur = -1;
23296 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
23297 sqlite3_fprintf(out,
23298 "Page cache writes: %d\n", iCur);
23299 iHiwtr = iCur = -1;
23300 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_SPILL, &iCur, &iHiwtr, 1);
23301 sqlite3_fprintf(out,
23302 "Page cache spills: %d\n", iCur);
23303 sqlite3_fprintf(out,
23304 "Temporary data spilled to disk: %lld\n", iCur64);
23305 sqlite3_db_status64(db, SQLITE_DBSTATUS_TEMPBUF_SPILL, &iCur64, &iHiwtr64,
23306 1);
23307 iHiwtr = iCur = -1;
23308 sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
23309 sqlite3_fprintf(out,
23310 "Schema Heap Usage: %d bytes\n", iCur);
23311 iHiwtr = iCur = -1;
@@ -24962,11 +25010,11 @@
25010 " from the \".mode\" output mode",
25011 " * If FILE begins with \"|\" then it is a command that generates the",
25012 " input text.",
25013 #endif
25014 #ifndef SQLITE_OMIT_TEST_CONTROL
25015 ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
25016 #endif
25017 ".indexes ?TABLE? Show names of indexes",
25018 " If TABLE is specified, only show indexes for",
25019 " tables matching TABLE using the LIKE operator.",
25020 ".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db",
@@ -31402,14 +31450,14 @@
31450 sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
31451 }
31452 while( sqlite3_step(pStmt)==SQLITE_ROW ){
31453 if( nRow>=nAlloc ){
31454 char **azNew;
31455 sqlite3_int64 n2 = 2*(sqlite3_int64)nAlloc + 10;
31456 azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
31457 shell_check_oom(azNew);
31458 nAlloc = (int)n2;
31459 azResult = azNew;
31460 }
31461 azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
31462 shell_check_oom(azResult[nRow]);
31463 nRow++;
31464
+137 -144
--- 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
-** 4966d7a1ce42af8b1c50fdd40e651e80d0ee with changes in files:
21
+** 5cbccab499bc3983aac1f57355552db607de with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -463,18 +463,18 @@
463463
** been edited in any way since it was last checked in, then the last
464464
** four hexadecimal digits of the hash may be modified.
465465
**
466466
** See also: [sqlite3_libversion()],
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468
-** [sqlite_version()] and [sqlite_sourceid()].
468
+** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470470
#define SQLITE_VERSION "3.51.0"
471471
#define SQLITE_VERSION_NUMBER 3051000
472
-#define SQLITE_SOURCE_ID "2025-10-10 14:31:46 4966d7a1ce42af8b1c50fdd40e651e80d0eeb8cb62dd882950cab275f98aba88"
472
+#define SQLITE_SOURCE_ID "2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2025-10-10T14:31:46.035Z"
475
+#define SQLITE_SCM_DATETIME "2025-10-15T10:52:45.276Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -502,11 +502,11 @@
502502
** a pointer to a string constant whose value is the same as the
503503
** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
504504
** using an edited copy of [the amalgamation], then the last four characters
505505
** of the hash might be different from [SQLITE_SOURCE_ID].)^
506506
**
507
-** See also: [sqlite_version()] and [sqlite_sourceid()].
507
+** See also: [sqlite_version()] and [sqlite_source_id()].
508508
*/
509509
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
510510
SQLITE_API const char *sqlite3_libversion(void);
511511
SQLITE_API const char *sqlite3_sourceid(void);
512512
SQLITE_API int sqlite3_libversion_number(void);
@@ -9239,14 +9239,23 @@
92399239
** the resetFlg is true, then the highest instantaneous value is
92409240
** reset back down to the current value.
92419241
**
92429242
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
92439243
** non-zero [error code] on failure.
9244
+**
9245
+** ^The sqlite3_db_status64(D,O,C,H,R) routine works exactly the same
9246
+** way as sqlite3_db_status(D,O,C,H,R) routine except that the C and H
9247
+** parameters are pointer to 64-bit integers (type: sqlite3_int64) instead
9248
+** of pointers to 32-bit integers, which allows larger status values
9249
+** to be returned. If a status value exceeds 2,147,483,647 then
9250
+** sqlite3_db_status() will truncate the value whereas sqlite3_db_status64()
9251
+** will return the full value.
92449252
**
92459253
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
92469254
*/
92479255
SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
9256
+SQLITE_API int sqlite3_db_status64(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
92489257
92499258
/*
92509259
** CAPI3REF: Status Parameters for database connections
92519260
** KEYWORDS: {SQLITE_DBSTATUS options}
92529261
**
@@ -9339,10 +9348,14 @@
93399348
** database file in rollback mode databases. Any pages written as part of
93409349
** transaction rollback or database recovery operations are not included.
93419350
** If an IO or other error occurs while writing a page to disk, the effect
93429351
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
93439352
** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
9353
+** <p>
9354
+** ^(There is overlap between the quantities measured by this parameter
9355
+** (SQLITE_DBSTATUS_CACHE_WRITE) and SQLITE_DBSTATUS_TEMPBUF_SPILL.
9356
+** Resetting one will reduce the other.)^
93449357
** </dd>
93459358
**
93469359
** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
93479360
** <dd>This parameter returns the number of dirty cache entries that have
93489361
** been written to disk in the middle of a transaction due to the page
@@ -9354,10 +9367,22 @@
93549367
**
93559368
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
93569369
** <dd>This parameter returns zero for the current value if and only if
93579370
** all foreign key constraints (deferred or immediate) have been
93589371
** resolved.)^ ^The highwater mark is always 0.
9372
+**
9373
+** [[SQLITE_DBSTATUS_TEMPBUF_SPILL] ^(<dt>SQLITE_DBSTATUS_TEMPBUF_SPILL</dt>
9374
+** <dd>^(This parameter returns the number of bytes written to temporary
9375
+** files on disk that could have been kept in memory had sufficient memory
9376
+** been available. This value includes writes to intermediate tables that
9377
+** are part of complex queries, external sorts that spill to disk, and
9378
+** writes to TEMP tables.)^
9379
+** ^The highwater mark is always 0.
9380
+** <p>
9381
+** ^(There is overlap between the quantities measured by this parameter
9382
+** (SQLITE_DBSTATUS_TEMPBUF_SPILL) and SQLITE_DBSTATUS_CACHE_WRITE.
9383
+** Resetting one will reduce the other.)^
93599384
** </dd>
93609385
** </dl>
93619386
*/
93629387
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
93639388
#define SQLITE_DBSTATUS_CACHE_USED 1
@@ -9370,11 +9395,12 @@
93709395
#define SQLITE_DBSTATUS_CACHE_MISS 8
93719396
#define SQLITE_DBSTATUS_CACHE_WRITE 9
93729397
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
93739398
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
93749399
#define SQLITE_DBSTATUS_CACHE_SPILL 12
9375
-#define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
9400
+#define SQLITE_DBSTATUS_TEMPBUF_SPILL 13
9401
+#define SQLITE_DBSTATUS_MAX 13 /* Largest defined DBSTATUS */
93769402
93779403
93789404
/*
93799405
** CAPI3REF: Prepared Statement Status
93809406
** METHOD: sqlite3_stmt
@@ -18320,10 +18346,11 @@
1832018346
int nStatement; /* Number of nested statement-transactions */
1832118347
i64 nDeferredCons; /* Net deferred constraints this transaction. */
1832218348
i64 nDeferredImmCons; /* Net deferred immediate constraints */
1832318349
int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
1832418350
DbClientData *pDbData; /* sqlite3_set_clientdata() content */
18351
+ u64 nSpill; /* TEMP content spilled to disk */
1832518352
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
1832618353
/* The following variables are all protected by the STATIC_MAIN
1832718354
** mutex, not by sqlite3.mutex. They are used by code in notify.c.
1832818355
**
1832918356
** When X.pUnlockConnection==Y, that means that X is waiting for Y to
@@ -24712,27 +24739,29 @@
2471224739
}
2471324740
2471424741
/*
2471524742
** Query status information for a single database connection
2471624743
*/
24717
-SQLITE_API int sqlite3_db_status(
24718
- sqlite3 *db, /* The database connection whose status is desired */
24719
- int op, /* Status verb */
24720
- int *pCurrent, /* Write current value here */
24721
- int *pHighwater, /* Write high-water mark here */
24722
- int resetFlag /* Reset high-water mark if true */
24744
+SQLITE_API int sqlite3_db_status64(
24745
+ sqlite3 *db, /* The database connection whose status is desired */
24746
+ int op, /* Status verb */
24747
+ sqlite3_int64 *pCurrent, /* Write current value here */
24748
+ sqlite3_int64 *pHighwtr, /* Write high-water mark here */
24749
+ int resetFlag /* Reset high-water mark if true */
2472324750
){
2472424751
int rc = SQLITE_OK; /* Return code */
2472524752
#ifdef SQLITE_ENABLE_API_ARMOR
24726
- if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){
24753
+ if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwtr==0 ){
2472724754
return SQLITE_MISUSE_BKPT;
2472824755
}
2472924756
#endif
2473024757
sqlite3_mutex_enter(db->mutex);
2473124758
switch( op ){
2473224759
case SQLITE_DBSTATUS_LOOKASIDE_USED: {
24733
- *pCurrent = sqlite3LookasideUsed(db, pHighwater);
24760
+ int H = 0;
24761
+ *pCurrent = sqlite3LookasideUsed(db, &H);
24762
+ *pHighwtr = H;
2473424763
if( resetFlag ){
2473524764
LookasideSlot *p = db->lookaside.pFree;
2473624765
if( p ){
2473724766
while( p->pNext ) p = p->pNext;
2473824767
p->pNext = db->lookaside.pInit;
@@ -24759,11 +24788,11 @@
2475924788
testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );
2476024789
testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );
2476124790
assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );
2476224791
assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );
2476324792
*pCurrent = 0;
24764
- *pHighwater = (int)db->lookaside.anStat[op-SQLITE_DBSTATUS_LOOKASIDE_HIT];
24793
+ *pHighwtr = db->lookaside.anStat[op-SQLITE_DBSTATUS_LOOKASIDE_HIT];
2476524794
if( resetFlag ){
2476624795
db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;
2476724796
}
2476824797
break;
2476924798
}
@@ -24773,11 +24802,11 @@
2477324802
** by all pagers associated with the given database connection. The
2477424803
** highwater mark is meaningless and is returned as zero.
2477524804
*/
2477624805
case SQLITE_DBSTATUS_CACHE_USED_SHARED:
2477724806
case SQLITE_DBSTATUS_CACHE_USED: {
24778
- int totalUsed = 0;
24807
+ sqlite3_int64 totalUsed = 0;
2477924808
int i;
2478024809
sqlite3BtreeEnterAll(db);
2478124810
for(i=0; i<db->nDb; i++){
2478224811
Btree *pBt = db->aDb[i].pBt;
2478324812
if( pBt ){
@@ -24789,22 +24818,22 @@
2478924818
totalUsed += nByte;
2479024819
}
2479124820
}
2479224821
sqlite3BtreeLeaveAll(db);
2479324822
*pCurrent = totalUsed;
24794
- *pHighwater = 0;
24823
+ *pHighwtr = 0;
2479524824
break;
2479624825
}
2479724826
2479824827
/*
2479924828
** *pCurrent gets an accurate estimate of the amount of memory used
2480024829
** to store the schema for all databases (main, temp, and any ATTACHed
24801
- ** databases. *pHighwater is set to zero.
24830
+ ** databases. *pHighwtr is set to zero.
2480224831
*/
2480324832
case SQLITE_DBSTATUS_SCHEMA_USED: {
24804
- int i; /* Used to iterate through schemas */
24805
- int nByte = 0; /* Used to accumulate return value */
24833
+ int i; /* Used to iterate through schemas */
24834
+ int nByte = 0; /* Used to accumulate return value */
2480624835
2480724836
sqlite3BtreeEnterAll(db);
2480824837
db->pnBytesFreed = &nByte;
2480924838
assert( db->lookaside.pEnd==db->lookaside.pTrueEnd );
2481024839
db->lookaside.pEnd = db->lookaside.pStart;
@@ -24834,19 +24863,19 @@
2483424863
}
2483524864
db->pnBytesFreed = 0;
2483624865
db->lookaside.pEnd = db->lookaside.pTrueEnd;
2483724866
sqlite3BtreeLeaveAll(db);
2483824867
24839
- *pHighwater = 0;
24868
+ *pHighwtr = 0;
2484024869
*pCurrent = nByte;
2484124870
break;
2484224871
}
2484324872
2484424873
/*
2484524874
** *pCurrent gets an accurate estimate of the amount of memory used
2484624875
** to store all prepared statements.
24847
- ** *pHighwater is set to zero.
24876
+ ** *pHighwtr is set to zero.
2484824877
*/
2484924878
case SQLITE_DBSTATUS_STMT_USED: {
2485024879
struct Vdbe *pVdbe; /* Used to iterate through VMs */
2485124880
int nByte = 0; /* Used to accumulate return value */
2485224881
@@ -24857,19 +24886,19 @@
2485724886
sqlite3VdbeDelete(pVdbe);
2485824887
}
2485924888
db->lookaside.pEnd = db->lookaside.pTrueEnd;
2486024889
db->pnBytesFreed = 0;
2486124890
24862
- *pHighwater = 0; /* IMP: R-64479-57858 */
24891
+ *pHighwtr = 0; /* IMP: R-64479-57858 */
2486324892
*pCurrent = nByte;
2486424893
2486524894
break;
2486624895
}
2486724896
2486824897
/*
2486924898
** Set *pCurrent to the total cache hits or misses encountered by all
24870
- ** pagers the database handle is connected to. *pHighwater is always set
24899
+ ** pagers the database handle is connected to. *pHighwtr is always set
2487124900
** to zero.
2487224901
*/
2487324902
case SQLITE_DBSTATUS_CACHE_SPILL:
2487424903
op = SQLITE_DBSTATUS_CACHE_WRITE+1;
2487524904
/* no break */ deliberate_fall_through
@@ -24885,23 +24914,43 @@
2488524914
if( db->aDb[i].pBt ){
2488624915
Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
2488724916
sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
2488824917
}
2488924918
}
24890
- *pHighwater = 0; /* IMP: R-42420-56072 */
24919
+ *pHighwtr = 0; /* IMP: R-42420-56072 */
2489124920
/* IMP: R-54100-20147 */
2489224921
/* IMP: R-29431-39229 */
24893
- *pCurrent = (int)nRet & 0x7fffffff;
24922
+ *pCurrent = nRet;
24923
+ break;
24924
+ }
24925
+
24926
+ /* Set *pCurrent to the number of bytes that the db database connection
24927
+ ** has spilled to the filesystem in temporary files that could have been
24928
+ ** stored in memory, had sufficient memory been available.
24929
+ ** The *pHighwater is always set to zero.
24930
+ */
24931
+ case SQLITE_DBSTATUS_TEMPBUF_SPILL: {
24932
+ u64 nRet = 0;
24933
+ if( db->aDb[1].pBt ){
24934
+ Pager *pPager = sqlite3BtreePager(db->aDb[1].pBt);
24935
+ sqlite3PagerCacheStat(pPager, SQLITE_DBSTATUS_CACHE_WRITE,
24936
+ resetFlag, &nRet);
24937
+ nRet *= sqlite3BtreeGetPageSize(db->aDb[1].pBt);
24938
+ }
24939
+ nRet += db->nSpill;
24940
+ if( resetFlag ) db->nSpill = 0;
24941
+ *pHighwtr = 0;
24942
+ *pCurrent = nRet;
2489424943
break;
2489524944
}
2489624945
2489724946
/* Set *pCurrent to non-zero if there are unresolved deferred foreign
2489824947
** key constraints. Set *pCurrent to zero if all foreign key constraints
24899
- ** have been satisfied. The *pHighwater is always set to zero.
24948
+ ** have been satisfied. The *pHighwtr is always set to zero.
2490024949
*/
2490124950
case SQLITE_DBSTATUS_DEFERRED_FKS: {
24902
- *pHighwater = 0; /* IMP: R-11967-56545 */
24951
+ *pHighwtr = 0; /* IMP: R-11967-56545 */
2490324952
*pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;
2490424953
break;
2490524954
}
2490624955
2490724956
default: {
@@ -24909,10 +24958,35 @@
2490924958
}
2491024959
}
2491124960
sqlite3_mutex_leave(db->mutex);
2491224961
return rc;
2491324962
}
24963
+
24964
+/*
24965
+** 32-bit variant of sqlite3_db_status64()
24966
+*/
24967
+SQLITE_API int sqlite3_db_status(
24968
+ sqlite3 *db, /* The database connection whose status is desired */
24969
+ int op, /* Status verb */
24970
+ int *pCurrent, /* Write current value here */
24971
+ int *pHighwtr, /* Write high-water mark here */
24972
+ int resetFlag /* Reset high-water mark if true */
24973
+){
24974
+ sqlite3_int64 C = 0, H = 0;
24975
+ int rc;
24976
+#ifdef SQLITE_ENABLE_API_ARMOR
24977
+ if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwtr==0 ){
24978
+ return SQLITE_MISUSE_BKPT;
24979
+ }
24980
+#endif
24981
+ rc = sqlite3_db_status64(db, op, &C, &H, resetFlag);
24982
+ if( rc==0 ){
24983
+ *pCurrent = C & 0x7fffffff;
24984
+ *pHighwtr = H & 0x7fffffff;
24985
+ }
24986
+ return rc;
24987
+}
2491424988
2491524989
/************** End of status.c **********************************************/
2491624990
/************** Begin file date.c ********************************************/
2491724991
/*
2491824992
** 2003 October 31
@@ -95636,11 +95710,11 @@
9563695710
** to run faster.
9563795711
*/
9563895712
static SQLITE_NOINLINE int vdbeColumnFromOverflow(
9563995713
VdbeCursor *pC, /* The BTree cursor from which we are reading */
9564095714
int iCol, /* The column to read */
95641
- int t, /* The serial-type code for the column value */
95715
+ u32 t, /* The serial-type code for the column value */
9564295716
i64 iOffset, /* Offset to the start of the content value */
9564395717
u32 cacheStatus, /* Current Vdbe.cacheCtr value */
9564495718
u32 colCacheCtr, /* Current value of the column cache counter */
9564595719
Mem *pDest /* Store the value into this register. */
9564695720
){
@@ -96737,11 +96811,12 @@
9673796811
flags2 = pIn2->flags & ~MEM_Str;
9673896812
}else if( (flags2 & MEM_Zero)!=0 ){
9673996813
if( sqlite3VdbeMemExpandBlob(pIn2) ) goto no_mem;
9674096814
flags2 = pIn2->flags & ~MEM_Str;
9674196815
}
96742
- nByte = pIn1->n + pIn2->n;
96816
+ nByte = pIn1->n;
96817
+ nByte += pIn2->n;
9674396818
if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
9674496819
goto too_big;
9674596820
}
9674696821
if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
9674796822
goto no_mem;
@@ -98562,11 +98637,11 @@
9856298637
assert( db->mallocFailed || pRec->flags&(MEM_Str|MEM_Blob) );
9856398638
assert( pRec->n>=0 );
9856498639
len = (u32)pRec->n;
9856598640
serial_type = (len*2) + 12 + ((pRec->flags & MEM_Str)!=0);
9856698641
if( pRec->flags & MEM_Zero ){
98567
- serial_type += pRec->u.nZero*2;
98642
+ serial_type += (u32)pRec->u.nZero*2;
9856898643
if( nData ){
9856998644
if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
9857098645
len += pRec->u.nZero;
9857198646
}else{
9857298647
nZero += pRec->u.nZero;
@@ -105079,10 +105154,11 @@
105079105154
UnpackedRecord *pUnpacked; /* Space to unpack a record */
105080105155
SorterList list; /* List for thread to write to a PMA */
105081105156
SorterCompare xCompare; /* Compare function to use */
105082105157
SorterFile file; /* Temp file for level-0 PMAs */
105083105158
SorterFile file2; /* Space for other PMAs */
105159
+ u64 nSpill; /* Total bytes written by this task */
105084105160
};
105085105161
105086105162
105087105163
/*
105088105164
** Main sorter structure. A single instance of this is allocated for each
@@ -105199,10 +105275,11 @@
105199105275
int nBuffer; /* Size of write buffer in bytes */
105200105276
int iBufStart; /* First byte of buffer to write */
105201105277
int iBufEnd; /* Last byte of buffer to write */
105202105278
i64 iWriteOff; /* Offset of start of buffer in file */
105203105279
sqlite3_file *pFd; /* File handle to write to */
105280
+ u64 nPmaSpill; /* Total number of bytes written */
105204105281
};
105205105282
105206105283
/*
105207105284
** This object is the header on a single record while that record is being
105208105285
** held in memory and prior to being written out as part of a PMA.
@@ -106057,10 +106134,16 @@
106057106134
SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){
106058106135
VdbeSorter *pSorter;
106059106136
assert( pCsr->eCurType==CURTYPE_SORTER );
106060106137
pSorter = pCsr->uc.pSorter;
106061106138
if( pSorter ){
106139
+ /* Increment db->nSpill by the total number of bytes of data written
106140
+ ** to temp files by this sort operation. */
106141
+ int ii;
106142
+ for(ii=0; ii<pSorter->nTask; ii++){
106143
+ db->nSpill += pSorter->aTask[ii].nSpill;
106144
+ }
106062106145
sqlite3VdbeSorterReset(db, pSorter);
106063106146
sqlite3_free(pSorter->list.aMemory);
106064106147
sqlite3DbFree(db, pSorter);
106065106148
pCsr->uc.pSorter = 0;
106066106149
}
@@ -106282,10 +106365,11 @@
106282106365
if( p->iBufEnd==p->nBuffer ){
106283106366
p->eFWErr = sqlite3OsWrite(p->pFd,
106284106367
&p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart,
106285106368
p->iWriteOff + p->iBufStart
106286106369
);
106370
+ p->nPmaSpill += (p->iBufEnd - p->iBufStart);
106287106371
p->iBufStart = p->iBufEnd = 0;
106288106372
p->iWriteOff += p->nBuffer;
106289106373
}
106290106374
assert( p->iBufEnd<p->nBuffer );
106291106375
@@ -106298,21 +106382,24 @@
106298106382
** The results of using the PMA-writer after this call are undefined.
106299106383
** Return SQLITE_OK if flushing the buffered data succeeds or is not
106300106384
** required. Otherwise, return an SQLite error code.
106301106385
**
106302106386
** Before returning, set *piEof to the offset immediately following the
106303
-** last byte written to the file.
106387
+** last byte written to the file. Also, increment (*pnSpill) by the total
106388
+** number of bytes written to the file.
106304106389
*/
106305
-static int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof){
106390
+static int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof, u64 *pnSpill){
106306106391
int rc;
106307106392
if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){
106308106393
p->eFWErr = sqlite3OsWrite(p->pFd,
106309106394
&p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart,
106310106395
p->iWriteOff + p->iBufStart
106311106396
);
106397
+ p->nPmaSpill += (p->iBufEnd - p->iBufStart);
106312106398
}
106313106399
*piEof = (p->iWriteOff + p->iBufEnd);
106400
+ *pnSpill += p->nPmaSpill;
106314106401
sqlite3_free(p->aBuffer);
106315106402
rc = p->eFWErr;
106316106403
memset(p, 0, sizeof(PmaWriter));
106317106404
return rc;
106318106405
}
@@ -106388,11 +106475,11 @@
106388106475
vdbePmaWriteVarint(&writer, p->nVal);
106389106476
vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);
106390106477
if( pList->aMemory==0 ) sqlite3_free(p);
106391106478
}
106392106479
pList->pList = p;
106393
- rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);
106480
+ rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof, &pTask->nSpill);
106394106481
}
106395106482
106396106483
vdbeSorterWorkDebug(pTask, "exit");
106397106484
assert( rc!=SQLITE_OK || pList->pList==0 );
106398106485
assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );
@@ -106702,11 +106789,11 @@
106702106789
vdbePmaWriteBlob(&writer, pReader->aKey, nKey);
106703106790
assert( pIncr->pMerger->pTask==pTask );
106704106791
rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);
106705106792
}
106706106793
106707
- rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof);
106794
+ rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof, &pTask->nSpill);
106708106795
if( rc==SQLITE_OK ) rc = rc2;
106709106796
vdbeSorterPopulateDebug(pTask, "exit");
106710106797
return rc;
106711106798
}
106712106799
@@ -133012,10 +133099,11 @@
133012133099
int nSep,
133013133100
const char *zSep
133014133101
){
133015133102
i64 j, n = 0;
133016133103
int i;
133104
+ int bNotNull = 0; /* True after at least NOT NULL argument seen */
133017133105
char *z;
133018133106
for(i=0; i<argc; i++){
133019133107
n += sqlite3_value_bytes(argv[i]);
133020133108
}
133021133109
n += (argc-1)*(i64)nSep;
@@ -133028,16 +133116,17 @@
133028133116
for(i=0; i<argc; i++){
133029133117
if( sqlite3_value_type(argv[i])!=SQLITE_NULL ){
133030133118
int k = sqlite3_value_bytes(argv[i]);
133031133119
const char *v = (const char*)sqlite3_value_text(argv[i]);
133032133120
if( v!=0 ){
133033
- if( j>0 && nSep>0 ){
133121
+ if( bNotNull && nSep>0 ){
133034133122
memcpy(&z[j], zSep, nSep);
133035133123
j += nSep;
133036133124
}
133037133125
memcpy(&z[j], v, k);
133038133126
j += k;
133127
+ bNotNull = 1;
133039133128
}
133040133129
}
133041133130
}
133042133131
z[j] = 0;
133043133132
assert( j<=n );
@@ -140169,10 +140258,12 @@
140169140258
int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
140170140259
/* Version 3.50.0 and later */
140171140260
int (*setlk_timeout)(sqlite3*,int,int);
140172140261
/* Version 3.51.0 and later */
140173140262
int (*set_errmsg)(sqlite3*,int,const char*);
140263
+ int (*db_status64)(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
140264
+
140174140265
};
140175140266
140176140267
/*
140177140268
** This is the function signature used for all extension entry points. It
140178140269
** is also defined in the file "loadext.c".
@@ -140506,10 +140597,11 @@
140506140597
#define sqlite3_set_clientdata sqlite3_api->set_clientdata
140507140598
/* Version 3.50.0 and later */
140508140599
#define sqlite3_setlk_timeout sqlite3_api->setlk_timeout
140509140600
/* Version 3.51.0 and later */
140510140601
#define sqlite3_set_errmsg sqlite3_api->set_errmsg
140602
+#define sqlite3_db_status64 sqlite3_api->db_status64
140511140603
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
140512140604
140513140605
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
140514140606
/* This case when the file really is being compiled as a loadable
140515140607
** extension */
@@ -141031,11 +141123,12 @@
141031141123
sqlite3_get_clientdata,
141032141124
sqlite3_set_clientdata,
141033141125
/* Version 3.50.0 and later */
141034141126
sqlite3_setlk_timeout,
141035141127
/* Version 3.51.0 and later */
141036
- sqlite3_set_errmsg
141128
+ sqlite3_set_errmsg,
141129
+ sqlite3_db_status64
141037141130
};
141038141131
141039141132
/* True if x is the directory separator character
141040141133
*/
141041141134
#if SQLITE_OS_WIN
@@ -247573,13 +247666,13 @@
247573247666
** backing store corruption. */
247574247667
if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT_ROWID(p, iRowid);
247575247668
247576247669
if( rc==SQLITE_OK ){
247577247670
u8 *aOut = 0; /* Read blob data into this buffer */
247578
- int nByte = sqlite3_blob_bytes(p->pReader);
247579
- int szData = (sizeof(Fts5Data) + 7) & ~7;
247580
- sqlite3_int64 nAlloc = szData + nByte + FTS5_DATA_PADDING;
247671
+ i64 nByte = sqlite3_blob_bytes(p->pReader);
247672
+ i64 szData = (sizeof(Fts5Data) + 7) & ~7;
247673
+ i64 nAlloc = szData + nByte + FTS5_DATA_PADDING;
247581247674
pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);
247582247675
if( pRet ){
247583247676
pRet->nn = nByte;
247584247677
aOut = pRet->p = (u8*)pRet + szData;
247585247678
}else{
@@ -259833,11 +259926,11 @@
259833259926
int nArg, /* Number of args */
259834259927
sqlite3_value **apUnused /* Function arguments */
259835259928
){
259836259929
assert( nArg==0 );
259837259930
UNUSED_PARAM2(nArg, apUnused);
259838
- sqlite3_result_text(pCtx, "fts5: 2025-10-10 14:22:05 fe9cf68b513d1e8cfcde90f1982a7f4123f54e3ebb004d961a99bdf6bec03a32", -1, SQLITE_TRANSIENT);
259931
+ sqlite3_result_text(pCtx, "fts5: 2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70", -1, SQLITE_TRANSIENT);
259839259932
}
259840259933
259841259934
/*
259842259935
** Implementation of fts5_locale(LOCALE, TEXT) function.
259843259936
**
@@ -260150,20 +260243,20 @@
260150260243
** must be read from the saved row stored in Fts5Storage.pSavedRow.
260151260244
**
260152260245
** This is necessary - using sqlite3_value_nochange() instead of just having
260153260246
** SQLite pass the original value back via xUpdate() - so as not to discard
260154260247
** any locale information associated with such values.
260248
+**
260155260249
*/
260156260250
struct Fts5Storage {
260157260251
Fts5Config *pConfig;
260158260252
Fts5Index *pIndex;
260159
- int db_enc; /* Database encoding */
260160260253
int bTotalsValid; /* True if nTotalRow/aTotalSize[] are valid */
260161260254
i64 nTotalRow; /* Total number of rows in FTS table */
260162260255
i64 *aTotalSize; /* Total sizes of each column */
260163260256
sqlite3_stmt *pSavedRow;
260164
- sqlite3_stmt *aStmt[13];
260257
+ sqlite3_stmt *aStmt[12];
260165260258
};
260166260259
260167260260
260168260261
#if FTS5_STMT_SCAN_ASC!=0
260169260262
# error "FTS5_STMT_SCAN_ASC mismatch"
@@ -260182,11 +260275,10 @@
260182260275
#define FTS5_STMT_REPLACE_DOCSIZE 7
260183260276
#define FTS5_STMT_DELETE_DOCSIZE 8
260184260277
#define FTS5_STMT_LOOKUP_DOCSIZE 9
260185260278
#define FTS5_STMT_REPLACE_CONFIG 10
260186260279
#define FTS5_STMT_SCAN 11
260187
-#define FTS5_STMT_ENC_CONVERT 12
260188260280
260189260281
/*
260190260282
** Prepare the two insert statements - Fts5Storage.pInsertContent and
260191260283
** Fts5Storage.pInsertDocsize - if they have not already been prepared.
260192260284
** Return SQLITE_OK if successful, or an SQLite error code if an error
@@ -260224,11 +260316,10 @@
260224260316
260225260317
"SELECT sz%s FROM %Q.'%q_docsize' WHERE id=?", /* LOOKUP_DOCSIZE */
260226260318
260227260319
"REPLACE INTO %Q.'%q_config' VALUES(?,?)", /* REPLACE_CONFIG */
260228260320
"SELECT %s FROM %s AS T", /* SCAN */
260229
- "SELECT substr(?, 1)", /* ENC_CONVERT */
260230260321
};
260231260322
Fts5Config *pC = p->pConfig;
260232260323
char *zSql = 0;
260233260324
260234260325
assert( ArraySize(azStmt)==ArraySize(p->aStmt) );
@@ -260445,40 +260536,10 @@
260445260536
}
260446260537
260447260538
return rc;
260448260539
}
260449260540
260450
-/*
260451
-** Set the value of Fts5Storage.db_enc to the db encoding. Return SQLITE_OK
260452
-** if successful, or an SQLite error code otherwise.
260453
-*/
260454
-static int fts5StorageFindDbEnc(Fts5Storage *p){
260455
- const char *zSql = "PRAGMA encoding";
260456
- sqlite3_stmt *pStmt = 0;
260457
- int rc = SQLITE_OK;
260458
-
260459
- rc = sqlite3_prepare(p->pConfig->db, zSql, -1, &pStmt, 0);
260460
- if( rc==SQLITE_OK ){
260461
- if( SQLITE_ROW==sqlite3_step(pStmt) ){
260462
- static const char *aEnc[] = {
260463
- "UTF-8", "UTF-16le", "UTF-16be"
260464
- };
260465
- const char *zEnc = (const char*)sqlite3_column_text(pStmt, 0);
260466
- int ii;
260467
- for(ii=0; ii<ArraySize(aEnc); ii++){
260468
- if( sqlite3_stricmp(aEnc[ii], zEnc)==0 ){
260469
- p->db_enc = ii+1;
260470
- break;
260471
- }
260472
- }
260473
- }
260474
- rc = sqlite3_finalize(pStmt);
260475
- }
260476
-
260477
- return rc;
260478
-}
260479
-
260480260541
/*
260481260542
** Open a new Fts5Index handle. If the bCreate argument is true, create
260482260543
** and initialize the underlying tables
260483260544
**
260484260545
** If successful, set *pp to point to the new object and return SQLITE_OK.
@@ -260503,13 +260564,11 @@
260503260564
memset(p, 0, (size_t)nByte);
260504260565
p->aTotalSize = (i64*)&p[1];
260505260566
p->pConfig = pConfig;
260506260567
p->pIndex = pIndex;
260507260568
260508
- rc = fts5StorageFindDbEnc(p);
260509
-
260510
- if( rc==SQLITE_OK && bCreate ){
260569
+ if( bCreate ){
260511260570
if( pConfig->eContent==FTS5_CONTENT_NORMAL
260512260571
|| pConfig->eContent==FTS5_CONTENT_UNINDEXED
260513260572
){
260514260573
int nDefn = 32 + pConfig->nCol*10;
260515260574
char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 20);
@@ -261175,63 +261234,10 @@
261175261234
}
261176261235
261177261236
return rc;
261178261237
}
261179261238
261180
-/*
261181
-** Argument pVal is a blob value for which the internal encoding does not
261182
-** match the database encoding. This happens when using sqlite3_bind_blob()
261183
-** (which always sets encoding=utf8) with a utf-16 database. The problem
261184
-** is that fts5 is about to call sqlite3_column_text() on the value to
261185
-** obtain text for tokenization. And the conversion between text and blob
261186
-** must take place assuming the blob is encoded in database encoding -
261187
-** otherwise it won't match the text extracted from the same blob if it
261188
-** is read from the db later on.
261189
-**
261190
-** This function attempts to create a new value containing a copy of
261191
-** the blob in pVal, but with the encoding set to the database encoding.
261192
-** If successful, it sets (*ppOut) to point to the new value and returns
261193
-** SQLITE_OK. It is the responsibility of the caller to eventually free
261194
-** this value using sqlite3_value_free(). Or, if an error occurs, (*ppOut)
261195
-** is set to NULL and an SQLite error code returned.
261196
-*/
261197
-static int fts5EncodingFix(
261198
- Fts5Storage *p,
261199
- sqlite3_value *pVal,
261200
- sqlite3_value **ppOut
261201
-){
261202
- sqlite3_stmt *pStmt = 0;
261203
- int rc = fts5StorageGetStmt(
261204
- p, FTS5_STMT_ENC_CONVERT, &pStmt, p->pConfig->pzErrmsg
261205
- );
261206
- if( rc==SQLITE_OK ){
261207
- sqlite3_value *pDup = 0;
261208
- const char *pBlob = sqlite3_value_blob(pVal);
261209
- int nBlob = sqlite3_value_bytes(pVal);
261210
-
261211
- sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC);
261212
-
261213
- if( SQLITE_ROW==sqlite3_step(pStmt) ){
261214
- sqlite3_value *pX = sqlite3_column_value(pStmt, 0);
261215
- pDup = sqlite3_value_dup(pX);
261216
- if( pDup==0 ){
261217
- rc = SQLITE_NOMEM;
261218
- }else{
261219
- *ppOut = pX;
261220
- }
261221
- }
261222
- rc = sqlite3_reset(pStmt);
261223
- if( rc!=SQLITE_OK ){
261224
- sqlite3_value_free(pDup);
261225
- }else{
261226
- *ppOut = pDup;
261227
- }
261228
- }
261229
-
261230
- return rc;
261231
-}
261232
-
261233261239
/*
261234261240
** Insert new entries into the FTS index and %_docsize table.
261235261241
*/
261236261242
static int sqlite3Fts5StorageIndexInsert(
261237261243
Fts5Storage *p,
@@ -261255,11 +261261,10 @@
261255261261
if( pConfig->abUnindexed[ctx.iCol]==0 ){
261256261262
int nText = 0; /* Size of pText in bytes */
261257261263
const char *pText = 0; /* Pointer to buffer containing text value */
261258261264
int nLoc = 0; /* Size of pText in bytes */
261259261265
const char *pLoc = 0; /* Pointer to buffer containing text value */
261260
- sqlite3_value *pFree = 0;
261261261266
261262261267
sqlite3_value *pVal = apVal[ctx.iCol+2];
261263261268
if( p->pSavedRow && sqlite3_value_nochange(pVal) ){
261264261269
pVal = sqlite3_column_value(p->pSavedRow, ctx.iCol+1);
261265261270
if( pConfig->eContent==FTS5_CONTENT_NORMAL && pConfig->bLocale ){
@@ -261272,19 +261277,10 @@
261272261277
}
261273261278
261274261279
if( pConfig->bLocale && sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
261275261280
rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
261276261281
}else{
261277
- if( sqlite3_value_type(pVal)==SQLITE_BLOB
261278
- && sqlite3_value_encoding(pVal)!=p->db_enc
261279
- ){
261280
- rc = fts5EncodingFix(p, pVal, &pFree);
261281
- if( pFree ){
261282
- assert( rc==SQLITE_OK );
261283
- pVal = pFree;
261284
- }
261285
- }
261286261282
pText = (const char*)sqlite3_value_text(pVal);
261287261283
nText = sqlite3_value_bytes(pVal);
261288261284
}
261289261285
261290261286
if( rc==SQLITE_OK ){
@@ -261293,13 +261289,10 @@
261293261289
FTS5_TOKENIZE_DOCUMENT, pText, nText, (void*)&ctx,
261294261290
fts5StorageInsertCallback
261295261291
);
261296261292
sqlite3Fts5ClearLocale(pConfig);
261297261293
}
261298
- if( pFree ){
261299
- sqlite3_value_free(pFree);
261300
- }
261301261294
}
261302261295
sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
261303261296
p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;
261304261297
}
261305261298
p->nTotalRow++;
261306261299
--- 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 ** 4966d7a1ce42af8b1c50fdd40e651e80d0ee with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -463,18 +463,18 @@
463 ** been edited in any way since it was last checked in, then the last
464 ** four hexadecimal digits of the hash may be modified.
465 **
466 ** See also: [sqlite3_libversion()],
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_sourceid()].
469 */
470 #define SQLITE_VERSION "3.51.0"
471 #define SQLITE_VERSION_NUMBER 3051000
472 #define SQLITE_SOURCE_ID "2025-10-10 14:31:46 4966d7a1ce42af8b1c50fdd40e651e80d0eeb8cb62dd882950cab275f98aba88"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2025-10-10T14:31:46.035Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -502,11 +502,11 @@
502 ** a pointer to a string constant whose value is the same as the
503 ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
504 ** using an edited copy of [the amalgamation], then the last four characters
505 ** of the hash might be different from [SQLITE_SOURCE_ID].)^
506 **
507 ** See also: [sqlite_version()] and [sqlite_sourceid()].
508 */
509 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
510 SQLITE_API const char *sqlite3_libversion(void);
511 SQLITE_API const char *sqlite3_sourceid(void);
512 SQLITE_API int sqlite3_libversion_number(void);
@@ -9239,14 +9239,23 @@
9239 ** the resetFlg is true, then the highest instantaneous value is
9240 ** reset back down to the current value.
9241 **
9242 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
9243 ** non-zero [error code] on failure.
 
 
 
 
 
 
 
 
9244 **
9245 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
9246 */
9247 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 
9248
9249 /*
9250 ** CAPI3REF: Status Parameters for database connections
9251 ** KEYWORDS: {SQLITE_DBSTATUS options}
9252 **
@@ -9339,10 +9348,14 @@
9339 ** database file in rollback mode databases. Any pages written as part of
9340 ** transaction rollback or database recovery operations are not included.
9341 ** If an IO or other error occurs while writing a page to disk, the effect
9342 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
9343 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
 
 
 
 
9344 ** </dd>
9345 **
9346 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
9347 ** <dd>This parameter returns the number of dirty cache entries that have
9348 ** been written to disk in the middle of a transaction due to the page
@@ -9354,10 +9367,22 @@
9354 **
9355 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
9356 ** <dd>This parameter returns zero for the current value if and only if
9357 ** all foreign key constraints (deferred or immediate) have been
9358 ** resolved.)^ ^The highwater mark is always 0.
 
 
 
 
 
 
 
 
 
 
 
 
9359 ** </dd>
9360 ** </dl>
9361 */
9362 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
9363 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -9370,11 +9395,12 @@
9370 #define SQLITE_DBSTATUS_CACHE_MISS 8
9371 #define SQLITE_DBSTATUS_CACHE_WRITE 9
9372 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
9373 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
9374 #define SQLITE_DBSTATUS_CACHE_SPILL 12
9375 #define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
 
9376
9377
9378 /*
9379 ** CAPI3REF: Prepared Statement Status
9380 ** METHOD: sqlite3_stmt
@@ -18320,10 +18346,11 @@
18320 int nStatement; /* Number of nested statement-transactions */
18321 i64 nDeferredCons; /* Net deferred constraints this transaction. */
18322 i64 nDeferredImmCons; /* Net deferred immediate constraints */
18323 int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
18324 DbClientData *pDbData; /* sqlite3_set_clientdata() content */
 
18325 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
18326 /* The following variables are all protected by the STATIC_MAIN
18327 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
18328 **
18329 ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
@@ -24712,27 +24739,29 @@
24712 }
24713
24714 /*
24715 ** Query status information for a single database connection
24716 */
24717 SQLITE_API int sqlite3_db_status(
24718 sqlite3 *db, /* The database connection whose status is desired */
24719 int op, /* Status verb */
24720 int *pCurrent, /* Write current value here */
24721 int *pHighwater, /* Write high-water mark here */
24722 int resetFlag /* Reset high-water mark if true */
24723 ){
24724 int rc = SQLITE_OK; /* Return code */
24725 #ifdef SQLITE_ENABLE_API_ARMOR
24726 if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){
24727 return SQLITE_MISUSE_BKPT;
24728 }
24729 #endif
24730 sqlite3_mutex_enter(db->mutex);
24731 switch( op ){
24732 case SQLITE_DBSTATUS_LOOKASIDE_USED: {
24733 *pCurrent = sqlite3LookasideUsed(db, pHighwater);
 
 
24734 if( resetFlag ){
24735 LookasideSlot *p = db->lookaside.pFree;
24736 if( p ){
24737 while( p->pNext ) p = p->pNext;
24738 p->pNext = db->lookaside.pInit;
@@ -24759,11 +24788,11 @@
24759 testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );
24760 testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );
24761 assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );
24762 assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );
24763 *pCurrent = 0;
24764 *pHighwater = (int)db->lookaside.anStat[op-SQLITE_DBSTATUS_LOOKASIDE_HIT];
24765 if( resetFlag ){
24766 db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;
24767 }
24768 break;
24769 }
@@ -24773,11 +24802,11 @@
24773 ** by all pagers associated with the given database connection. The
24774 ** highwater mark is meaningless and is returned as zero.
24775 */
24776 case SQLITE_DBSTATUS_CACHE_USED_SHARED:
24777 case SQLITE_DBSTATUS_CACHE_USED: {
24778 int totalUsed = 0;
24779 int i;
24780 sqlite3BtreeEnterAll(db);
24781 for(i=0; i<db->nDb; i++){
24782 Btree *pBt = db->aDb[i].pBt;
24783 if( pBt ){
@@ -24789,22 +24818,22 @@
24789 totalUsed += nByte;
24790 }
24791 }
24792 sqlite3BtreeLeaveAll(db);
24793 *pCurrent = totalUsed;
24794 *pHighwater = 0;
24795 break;
24796 }
24797
24798 /*
24799 ** *pCurrent gets an accurate estimate of the amount of memory used
24800 ** to store the schema for all databases (main, temp, and any ATTACHed
24801 ** databases. *pHighwater is set to zero.
24802 */
24803 case SQLITE_DBSTATUS_SCHEMA_USED: {
24804 int i; /* Used to iterate through schemas */
24805 int nByte = 0; /* Used to accumulate return value */
24806
24807 sqlite3BtreeEnterAll(db);
24808 db->pnBytesFreed = &nByte;
24809 assert( db->lookaside.pEnd==db->lookaside.pTrueEnd );
24810 db->lookaside.pEnd = db->lookaside.pStart;
@@ -24834,19 +24863,19 @@
24834 }
24835 db->pnBytesFreed = 0;
24836 db->lookaside.pEnd = db->lookaside.pTrueEnd;
24837 sqlite3BtreeLeaveAll(db);
24838
24839 *pHighwater = 0;
24840 *pCurrent = nByte;
24841 break;
24842 }
24843
24844 /*
24845 ** *pCurrent gets an accurate estimate of the amount of memory used
24846 ** to store all prepared statements.
24847 ** *pHighwater is set to zero.
24848 */
24849 case SQLITE_DBSTATUS_STMT_USED: {
24850 struct Vdbe *pVdbe; /* Used to iterate through VMs */
24851 int nByte = 0; /* Used to accumulate return value */
24852
@@ -24857,19 +24886,19 @@
24857 sqlite3VdbeDelete(pVdbe);
24858 }
24859 db->lookaside.pEnd = db->lookaside.pTrueEnd;
24860 db->pnBytesFreed = 0;
24861
24862 *pHighwater = 0; /* IMP: R-64479-57858 */
24863 *pCurrent = nByte;
24864
24865 break;
24866 }
24867
24868 /*
24869 ** Set *pCurrent to the total cache hits or misses encountered by all
24870 ** pagers the database handle is connected to. *pHighwater is always set
24871 ** to zero.
24872 */
24873 case SQLITE_DBSTATUS_CACHE_SPILL:
24874 op = SQLITE_DBSTATUS_CACHE_WRITE+1;
24875 /* no break */ deliberate_fall_through
@@ -24885,23 +24914,43 @@
24885 if( db->aDb[i].pBt ){
24886 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
24887 sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
24888 }
24889 }
24890 *pHighwater = 0; /* IMP: R-42420-56072 */
24891 /* IMP: R-54100-20147 */
24892 /* IMP: R-29431-39229 */
24893 *pCurrent = (int)nRet & 0x7fffffff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24894 break;
24895 }
24896
24897 /* Set *pCurrent to non-zero if there are unresolved deferred foreign
24898 ** key constraints. Set *pCurrent to zero if all foreign key constraints
24899 ** have been satisfied. The *pHighwater is always set to zero.
24900 */
24901 case SQLITE_DBSTATUS_DEFERRED_FKS: {
24902 *pHighwater = 0; /* IMP: R-11967-56545 */
24903 *pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;
24904 break;
24905 }
24906
24907 default: {
@@ -24909,10 +24958,35 @@
24909 }
24910 }
24911 sqlite3_mutex_leave(db->mutex);
24912 return rc;
24913 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24914
24915 /************** End of status.c **********************************************/
24916 /************** Begin file date.c ********************************************/
24917 /*
24918 ** 2003 October 31
@@ -95636,11 +95710,11 @@
95636 ** to run faster.
95637 */
95638 static SQLITE_NOINLINE int vdbeColumnFromOverflow(
95639 VdbeCursor *pC, /* The BTree cursor from which we are reading */
95640 int iCol, /* The column to read */
95641 int t, /* The serial-type code for the column value */
95642 i64 iOffset, /* Offset to the start of the content value */
95643 u32 cacheStatus, /* Current Vdbe.cacheCtr value */
95644 u32 colCacheCtr, /* Current value of the column cache counter */
95645 Mem *pDest /* Store the value into this register. */
95646 ){
@@ -96737,11 +96811,12 @@
96737 flags2 = pIn2->flags & ~MEM_Str;
96738 }else if( (flags2 & MEM_Zero)!=0 ){
96739 if( sqlite3VdbeMemExpandBlob(pIn2) ) goto no_mem;
96740 flags2 = pIn2->flags & ~MEM_Str;
96741 }
96742 nByte = pIn1->n + pIn2->n;
 
96743 if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
96744 goto too_big;
96745 }
96746 if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
96747 goto no_mem;
@@ -98562,11 +98637,11 @@
98562 assert( db->mallocFailed || pRec->flags&(MEM_Str|MEM_Blob) );
98563 assert( pRec->n>=0 );
98564 len = (u32)pRec->n;
98565 serial_type = (len*2) + 12 + ((pRec->flags & MEM_Str)!=0);
98566 if( pRec->flags & MEM_Zero ){
98567 serial_type += pRec->u.nZero*2;
98568 if( nData ){
98569 if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
98570 len += pRec->u.nZero;
98571 }else{
98572 nZero += pRec->u.nZero;
@@ -105079,10 +105154,11 @@
105079 UnpackedRecord *pUnpacked; /* Space to unpack a record */
105080 SorterList list; /* List for thread to write to a PMA */
105081 SorterCompare xCompare; /* Compare function to use */
105082 SorterFile file; /* Temp file for level-0 PMAs */
105083 SorterFile file2; /* Space for other PMAs */
 
105084 };
105085
105086
105087 /*
105088 ** Main sorter structure. A single instance of this is allocated for each
@@ -105199,10 +105275,11 @@
105199 int nBuffer; /* Size of write buffer in bytes */
105200 int iBufStart; /* First byte of buffer to write */
105201 int iBufEnd; /* Last byte of buffer to write */
105202 i64 iWriteOff; /* Offset of start of buffer in file */
105203 sqlite3_file *pFd; /* File handle to write to */
 
105204 };
105205
105206 /*
105207 ** This object is the header on a single record while that record is being
105208 ** held in memory and prior to being written out as part of a PMA.
@@ -106057,10 +106134,16 @@
106057 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){
106058 VdbeSorter *pSorter;
106059 assert( pCsr->eCurType==CURTYPE_SORTER );
106060 pSorter = pCsr->uc.pSorter;
106061 if( pSorter ){
 
 
 
 
 
 
106062 sqlite3VdbeSorterReset(db, pSorter);
106063 sqlite3_free(pSorter->list.aMemory);
106064 sqlite3DbFree(db, pSorter);
106065 pCsr->uc.pSorter = 0;
106066 }
@@ -106282,10 +106365,11 @@
106282 if( p->iBufEnd==p->nBuffer ){
106283 p->eFWErr = sqlite3OsWrite(p->pFd,
106284 &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart,
106285 p->iWriteOff + p->iBufStart
106286 );
 
106287 p->iBufStart = p->iBufEnd = 0;
106288 p->iWriteOff += p->nBuffer;
106289 }
106290 assert( p->iBufEnd<p->nBuffer );
106291
@@ -106298,21 +106382,24 @@
106298 ** The results of using the PMA-writer after this call are undefined.
106299 ** Return SQLITE_OK if flushing the buffered data succeeds or is not
106300 ** required. Otherwise, return an SQLite error code.
106301 **
106302 ** Before returning, set *piEof to the offset immediately following the
106303 ** last byte written to the file.
 
106304 */
106305 static int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof){
106306 int rc;
106307 if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){
106308 p->eFWErr = sqlite3OsWrite(p->pFd,
106309 &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart,
106310 p->iWriteOff + p->iBufStart
106311 );
 
106312 }
106313 *piEof = (p->iWriteOff + p->iBufEnd);
 
106314 sqlite3_free(p->aBuffer);
106315 rc = p->eFWErr;
106316 memset(p, 0, sizeof(PmaWriter));
106317 return rc;
106318 }
@@ -106388,11 +106475,11 @@
106388 vdbePmaWriteVarint(&writer, p->nVal);
106389 vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);
106390 if( pList->aMemory==0 ) sqlite3_free(p);
106391 }
106392 pList->pList = p;
106393 rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);
106394 }
106395
106396 vdbeSorterWorkDebug(pTask, "exit");
106397 assert( rc!=SQLITE_OK || pList->pList==0 );
106398 assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );
@@ -106702,11 +106789,11 @@
106702 vdbePmaWriteBlob(&writer, pReader->aKey, nKey);
106703 assert( pIncr->pMerger->pTask==pTask );
106704 rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);
106705 }
106706
106707 rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof);
106708 if( rc==SQLITE_OK ) rc = rc2;
106709 vdbeSorterPopulateDebug(pTask, "exit");
106710 return rc;
106711 }
106712
@@ -133012,10 +133099,11 @@
133012 int nSep,
133013 const char *zSep
133014 ){
133015 i64 j, n = 0;
133016 int i;
 
133017 char *z;
133018 for(i=0; i<argc; i++){
133019 n += sqlite3_value_bytes(argv[i]);
133020 }
133021 n += (argc-1)*(i64)nSep;
@@ -133028,16 +133116,17 @@
133028 for(i=0; i<argc; i++){
133029 if( sqlite3_value_type(argv[i])!=SQLITE_NULL ){
133030 int k = sqlite3_value_bytes(argv[i]);
133031 const char *v = (const char*)sqlite3_value_text(argv[i]);
133032 if( v!=0 ){
133033 if( j>0 && nSep>0 ){
133034 memcpy(&z[j], zSep, nSep);
133035 j += nSep;
133036 }
133037 memcpy(&z[j], v, k);
133038 j += k;
 
133039 }
133040 }
133041 }
133042 z[j] = 0;
133043 assert( j<=n );
@@ -140169,10 +140258,12 @@
140169 int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
140170 /* Version 3.50.0 and later */
140171 int (*setlk_timeout)(sqlite3*,int,int);
140172 /* Version 3.51.0 and later */
140173 int (*set_errmsg)(sqlite3*,int,const char*);
 
 
140174 };
140175
140176 /*
140177 ** This is the function signature used for all extension entry points. It
140178 ** is also defined in the file "loadext.c".
@@ -140506,10 +140597,11 @@
140506 #define sqlite3_set_clientdata sqlite3_api->set_clientdata
140507 /* Version 3.50.0 and later */
140508 #define sqlite3_setlk_timeout sqlite3_api->setlk_timeout
140509 /* Version 3.51.0 and later */
140510 #define sqlite3_set_errmsg sqlite3_api->set_errmsg
 
140511 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
140512
140513 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
140514 /* This case when the file really is being compiled as a loadable
140515 ** extension */
@@ -141031,11 +141123,12 @@
141031 sqlite3_get_clientdata,
141032 sqlite3_set_clientdata,
141033 /* Version 3.50.0 and later */
141034 sqlite3_setlk_timeout,
141035 /* Version 3.51.0 and later */
141036 sqlite3_set_errmsg
 
141037 };
141038
141039 /* True if x is the directory separator character
141040 */
141041 #if SQLITE_OS_WIN
@@ -247573,13 +247666,13 @@
247573 ** backing store corruption. */
247574 if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT_ROWID(p, iRowid);
247575
247576 if( rc==SQLITE_OK ){
247577 u8 *aOut = 0; /* Read blob data into this buffer */
247578 int nByte = sqlite3_blob_bytes(p->pReader);
247579 int szData = (sizeof(Fts5Data) + 7) & ~7;
247580 sqlite3_int64 nAlloc = szData + nByte + FTS5_DATA_PADDING;
247581 pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);
247582 if( pRet ){
247583 pRet->nn = nByte;
247584 aOut = pRet->p = (u8*)pRet + szData;
247585 }else{
@@ -259833,11 +259926,11 @@
259833 int nArg, /* Number of args */
259834 sqlite3_value **apUnused /* Function arguments */
259835 ){
259836 assert( nArg==0 );
259837 UNUSED_PARAM2(nArg, apUnused);
259838 sqlite3_result_text(pCtx, "fts5: 2025-10-10 14:22:05 fe9cf68b513d1e8cfcde90f1982a7f4123f54e3ebb004d961a99bdf6bec03a32", -1, SQLITE_TRANSIENT);
259839 }
259840
259841 /*
259842 ** Implementation of fts5_locale(LOCALE, TEXT) function.
259843 **
@@ -260150,20 +260243,20 @@
260150 ** must be read from the saved row stored in Fts5Storage.pSavedRow.
260151 **
260152 ** This is necessary - using sqlite3_value_nochange() instead of just having
260153 ** SQLite pass the original value back via xUpdate() - so as not to discard
260154 ** any locale information associated with such values.
 
260155 */
260156 struct Fts5Storage {
260157 Fts5Config *pConfig;
260158 Fts5Index *pIndex;
260159 int db_enc; /* Database encoding */
260160 int bTotalsValid; /* True if nTotalRow/aTotalSize[] are valid */
260161 i64 nTotalRow; /* Total number of rows in FTS table */
260162 i64 *aTotalSize; /* Total sizes of each column */
260163 sqlite3_stmt *pSavedRow;
260164 sqlite3_stmt *aStmt[13];
260165 };
260166
260167
260168 #if FTS5_STMT_SCAN_ASC!=0
260169 # error "FTS5_STMT_SCAN_ASC mismatch"
@@ -260182,11 +260275,10 @@
260182 #define FTS5_STMT_REPLACE_DOCSIZE 7
260183 #define FTS5_STMT_DELETE_DOCSIZE 8
260184 #define FTS5_STMT_LOOKUP_DOCSIZE 9
260185 #define FTS5_STMT_REPLACE_CONFIG 10
260186 #define FTS5_STMT_SCAN 11
260187 #define FTS5_STMT_ENC_CONVERT 12
260188
260189 /*
260190 ** Prepare the two insert statements - Fts5Storage.pInsertContent and
260191 ** Fts5Storage.pInsertDocsize - if they have not already been prepared.
260192 ** Return SQLITE_OK if successful, or an SQLite error code if an error
@@ -260224,11 +260316,10 @@
260224
260225 "SELECT sz%s FROM %Q.'%q_docsize' WHERE id=?", /* LOOKUP_DOCSIZE */
260226
260227 "REPLACE INTO %Q.'%q_config' VALUES(?,?)", /* REPLACE_CONFIG */
260228 "SELECT %s FROM %s AS T", /* SCAN */
260229 "SELECT substr(?, 1)", /* ENC_CONVERT */
260230 };
260231 Fts5Config *pC = p->pConfig;
260232 char *zSql = 0;
260233
260234 assert( ArraySize(azStmt)==ArraySize(p->aStmt) );
@@ -260445,40 +260536,10 @@
260445 }
260446
260447 return rc;
260448 }
260449
260450 /*
260451 ** Set the value of Fts5Storage.db_enc to the db encoding. Return SQLITE_OK
260452 ** if successful, or an SQLite error code otherwise.
260453 */
260454 static int fts5StorageFindDbEnc(Fts5Storage *p){
260455 const char *zSql = "PRAGMA encoding";
260456 sqlite3_stmt *pStmt = 0;
260457 int rc = SQLITE_OK;
260458
260459 rc = sqlite3_prepare(p->pConfig->db, zSql, -1, &pStmt, 0);
260460 if( rc==SQLITE_OK ){
260461 if( SQLITE_ROW==sqlite3_step(pStmt) ){
260462 static const char *aEnc[] = {
260463 "UTF-8", "UTF-16le", "UTF-16be"
260464 };
260465 const char *zEnc = (const char*)sqlite3_column_text(pStmt, 0);
260466 int ii;
260467 for(ii=0; ii<ArraySize(aEnc); ii++){
260468 if( sqlite3_stricmp(aEnc[ii], zEnc)==0 ){
260469 p->db_enc = ii+1;
260470 break;
260471 }
260472 }
260473 }
260474 rc = sqlite3_finalize(pStmt);
260475 }
260476
260477 return rc;
260478 }
260479
260480 /*
260481 ** Open a new Fts5Index handle. If the bCreate argument is true, create
260482 ** and initialize the underlying tables
260483 **
260484 ** If successful, set *pp to point to the new object and return SQLITE_OK.
@@ -260503,13 +260564,11 @@
260503 memset(p, 0, (size_t)nByte);
260504 p->aTotalSize = (i64*)&p[1];
260505 p->pConfig = pConfig;
260506 p->pIndex = pIndex;
260507
260508 rc = fts5StorageFindDbEnc(p);
260509
260510 if( rc==SQLITE_OK && bCreate ){
260511 if( pConfig->eContent==FTS5_CONTENT_NORMAL
260512 || pConfig->eContent==FTS5_CONTENT_UNINDEXED
260513 ){
260514 int nDefn = 32 + pConfig->nCol*10;
260515 char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 20);
@@ -261175,63 +261234,10 @@
261175 }
261176
261177 return rc;
261178 }
261179
261180 /*
261181 ** Argument pVal is a blob value for which the internal encoding does not
261182 ** match the database encoding. This happens when using sqlite3_bind_blob()
261183 ** (which always sets encoding=utf8) with a utf-16 database. The problem
261184 ** is that fts5 is about to call sqlite3_column_text() on the value to
261185 ** obtain text for tokenization. And the conversion between text and blob
261186 ** must take place assuming the blob is encoded in database encoding -
261187 ** otherwise it won't match the text extracted from the same blob if it
261188 ** is read from the db later on.
261189 **
261190 ** This function attempts to create a new value containing a copy of
261191 ** the blob in pVal, but with the encoding set to the database encoding.
261192 ** If successful, it sets (*ppOut) to point to the new value and returns
261193 ** SQLITE_OK. It is the responsibility of the caller to eventually free
261194 ** this value using sqlite3_value_free(). Or, if an error occurs, (*ppOut)
261195 ** is set to NULL and an SQLite error code returned.
261196 */
261197 static int fts5EncodingFix(
261198 Fts5Storage *p,
261199 sqlite3_value *pVal,
261200 sqlite3_value **ppOut
261201 ){
261202 sqlite3_stmt *pStmt = 0;
261203 int rc = fts5StorageGetStmt(
261204 p, FTS5_STMT_ENC_CONVERT, &pStmt, p->pConfig->pzErrmsg
261205 );
261206 if( rc==SQLITE_OK ){
261207 sqlite3_value *pDup = 0;
261208 const char *pBlob = sqlite3_value_blob(pVal);
261209 int nBlob = sqlite3_value_bytes(pVal);
261210
261211 sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC);
261212
261213 if( SQLITE_ROW==sqlite3_step(pStmt) ){
261214 sqlite3_value *pX = sqlite3_column_value(pStmt, 0);
261215 pDup = sqlite3_value_dup(pX);
261216 if( pDup==0 ){
261217 rc = SQLITE_NOMEM;
261218 }else{
261219 *ppOut = pX;
261220 }
261221 }
261222 rc = sqlite3_reset(pStmt);
261223 if( rc!=SQLITE_OK ){
261224 sqlite3_value_free(pDup);
261225 }else{
261226 *ppOut = pDup;
261227 }
261228 }
261229
261230 return rc;
261231 }
261232
261233 /*
261234 ** Insert new entries into the FTS index and %_docsize table.
261235 */
261236 static int sqlite3Fts5StorageIndexInsert(
261237 Fts5Storage *p,
@@ -261255,11 +261261,10 @@
261255 if( pConfig->abUnindexed[ctx.iCol]==0 ){
261256 int nText = 0; /* Size of pText in bytes */
261257 const char *pText = 0; /* Pointer to buffer containing text value */
261258 int nLoc = 0; /* Size of pText in bytes */
261259 const char *pLoc = 0; /* Pointer to buffer containing text value */
261260 sqlite3_value *pFree = 0;
261261
261262 sqlite3_value *pVal = apVal[ctx.iCol+2];
261263 if( p->pSavedRow && sqlite3_value_nochange(pVal) ){
261264 pVal = sqlite3_column_value(p->pSavedRow, ctx.iCol+1);
261265 if( pConfig->eContent==FTS5_CONTENT_NORMAL && pConfig->bLocale ){
@@ -261272,19 +261277,10 @@
261272 }
261273
261274 if( pConfig->bLocale && sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
261275 rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
261276 }else{
261277 if( sqlite3_value_type(pVal)==SQLITE_BLOB
261278 && sqlite3_value_encoding(pVal)!=p->db_enc
261279 ){
261280 rc = fts5EncodingFix(p, pVal, &pFree);
261281 if( pFree ){
261282 assert( rc==SQLITE_OK );
261283 pVal = pFree;
261284 }
261285 }
261286 pText = (const char*)sqlite3_value_text(pVal);
261287 nText = sqlite3_value_bytes(pVal);
261288 }
261289
261290 if( rc==SQLITE_OK ){
@@ -261293,13 +261289,10 @@
261293 FTS5_TOKENIZE_DOCUMENT, pText, nText, (void*)&ctx,
261294 fts5StorageInsertCallback
261295 );
261296 sqlite3Fts5ClearLocale(pConfig);
261297 }
261298 if( pFree ){
261299 sqlite3_value_free(pFree);
261300 }
261301 }
261302 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
261303 p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;
261304 }
261305 p->nTotalRow++;
261306
--- 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 ** 5cbccab499bc3983aac1f57355552db607de with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -463,18 +463,18 @@
463 ** been edited in any way since it was last checked in, then the last
464 ** four hexadecimal digits of the hash may be modified.
465 **
466 ** See also: [sqlite3_libversion()],
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.51.0"
471 #define SQLITE_VERSION_NUMBER 3051000
472 #define SQLITE_SOURCE_ID "2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2025-10-15T10:52:45.276Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -502,11 +502,11 @@
502 ** a pointer to a string constant whose value is the same as the
503 ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
504 ** using an edited copy of [the amalgamation], then the last four characters
505 ** of the hash might be different from [SQLITE_SOURCE_ID].)^
506 **
507 ** See also: [sqlite_version()] and [sqlite_source_id()].
508 */
509 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
510 SQLITE_API const char *sqlite3_libversion(void);
511 SQLITE_API const char *sqlite3_sourceid(void);
512 SQLITE_API int sqlite3_libversion_number(void);
@@ -9239,14 +9239,23 @@
9239 ** the resetFlg is true, then the highest instantaneous value is
9240 ** reset back down to the current value.
9241 **
9242 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
9243 ** non-zero [error code] on failure.
9244 **
9245 ** ^The sqlite3_db_status64(D,O,C,H,R) routine works exactly the same
9246 ** way as sqlite3_db_status(D,O,C,H,R) routine except that the C and H
9247 ** parameters are pointer to 64-bit integers (type: sqlite3_int64) instead
9248 ** of pointers to 32-bit integers, which allows larger status values
9249 ** to be returned. If a status value exceeds 2,147,483,647 then
9250 ** sqlite3_db_status() will truncate the value whereas sqlite3_db_status64()
9251 ** will return the full value.
9252 **
9253 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
9254 */
9255 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
9256 SQLITE_API int sqlite3_db_status64(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
9257
9258 /*
9259 ** CAPI3REF: Status Parameters for database connections
9260 ** KEYWORDS: {SQLITE_DBSTATUS options}
9261 **
@@ -9339,10 +9348,14 @@
9348 ** database file in rollback mode databases. Any pages written as part of
9349 ** transaction rollback or database recovery operations are not included.
9350 ** If an IO or other error occurs while writing a page to disk, the effect
9351 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
9352 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
9353 ** <p>
9354 ** ^(There is overlap between the quantities measured by this parameter
9355 ** (SQLITE_DBSTATUS_CACHE_WRITE) and SQLITE_DBSTATUS_TEMPBUF_SPILL.
9356 ** Resetting one will reduce the other.)^
9357 ** </dd>
9358 **
9359 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
9360 ** <dd>This parameter returns the number of dirty cache entries that have
9361 ** been written to disk in the middle of a transaction due to the page
@@ -9354,10 +9367,22 @@
9367 **
9368 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
9369 ** <dd>This parameter returns zero for the current value if and only if
9370 ** all foreign key constraints (deferred or immediate) have been
9371 ** resolved.)^ ^The highwater mark is always 0.
9372 **
9373 ** [[SQLITE_DBSTATUS_TEMPBUF_SPILL] ^(<dt>SQLITE_DBSTATUS_TEMPBUF_SPILL</dt>
9374 ** <dd>^(This parameter returns the number of bytes written to temporary
9375 ** files on disk that could have been kept in memory had sufficient memory
9376 ** been available. This value includes writes to intermediate tables that
9377 ** are part of complex queries, external sorts that spill to disk, and
9378 ** writes to TEMP tables.)^
9379 ** ^The highwater mark is always 0.
9380 ** <p>
9381 ** ^(There is overlap between the quantities measured by this parameter
9382 ** (SQLITE_DBSTATUS_TEMPBUF_SPILL) and SQLITE_DBSTATUS_CACHE_WRITE.
9383 ** Resetting one will reduce the other.)^
9384 ** </dd>
9385 ** </dl>
9386 */
9387 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
9388 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -9370,11 +9395,12 @@
9395 #define SQLITE_DBSTATUS_CACHE_MISS 8
9396 #define SQLITE_DBSTATUS_CACHE_WRITE 9
9397 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
9398 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
9399 #define SQLITE_DBSTATUS_CACHE_SPILL 12
9400 #define SQLITE_DBSTATUS_TEMPBUF_SPILL 13
9401 #define SQLITE_DBSTATUS_MAX 13 /* Largest defined DBSTATUS */
9402
9403
9404 /*
9405 ** CAPI3REF: Prepared Statement Status
9406 ** METHOD: sqlite3_stmt
@@ -18320,10 +18346,11 @@
18346 int nStatement; /* Number of nested statement-transactions */
18347 i64 nDeferredCons; /* Net deferred constraints this transaction. */
18348 i64 nDeferredImmCons; /* Net deferred immediate constraints */
18349 int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
18350 DbClientData *pDbData; /* sqlite3_set_clientdata() content */
18351 u64 nSpill; /* TEMP content spilled to disk */
18352 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
18353 /* The following variables are all protected by the STATIC_MAIN
18354 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
18355 **
18356 ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
@@ -24712,27 +24739,29 @@
24739 }
24740
24741 /*
24742 ** Query status information for a single database connection
24743 */
24744 SQLITE_API int sqlite3_db_status64(
24745 sqlite3 *db, /* The database connection whose status is desired */
24746 int op, /* Status verb */
24747 sqlite3_int64 *pCurrent, /* Write current value here */
24748 sqlite3_int64 *pHighwtr, /* Write high-water mark here */
24749 int resetFlag /* Reset high-water mark if true */
24750 ){
24751 int rc = SQLITE_OK; /* Return code */
24752 #ifdef SQLITE_ENABLE_API_ARMOR
24753 if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwtr==0 ){
24754 return SQLITE_MISUSE_BKPT;
24755 }
24756 #endif
24757 sqlite3_mutex_enter(db->mutex);
24758 switch( op ){
24759 case SQLITE_DBSTATUS_LOOKASIDE_USED: {
24760 int H = 0;
24761 *pCurrent = sqlite3LookasideUsed(db, &H);
24762 *pHighwtr = H;
24763 if( resetFlag ){
24764 LookasideSlot *p = db->lookaside.pFree;
24765 if( p ){
24766 while( p->pNext ) p = p->pNext;
24767 p->pNext = db->lookaside.pInit;
@@ -24759,11 +24788,11 @@
24788 testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );
24789 testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );
24790 assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );
24791 assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );
24792 *pCurrent = 0;
24793 *pHighwtr = db->lookaside.anStat[op-SQLITE_DBSTATUS_LOOKASIDE_HIT];
24794 if( resetFlag ){
24795 db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;
24796 }
24797 break;
24798 }
@@ -24773,11 +24802,11 @@
24802 ** by all pagers associated with the given database connection. The
24803 ** highwater mark is meaningless and is returned as zero.
24804 */
24805 case SQLITE_DBSTATUS_CACHE_USED_SHARED:
24806 case SQLITE_DBSTATUS_CACHE_USED: {
24807 sqlite3_int64 totalUsed = 0;
24808 int i;
24809 sqlite3BtreeEnterAll(db);
24810 for(i=0; i<db->nDb; i++){
24811 Btree *pBt = db->aDb[i].pBt;
24812 if( pBt ){
@@ -24789,22 +24818,22 @@
24818 totalUsed += nByte;
24819 }
24820 }
24821 sqlite3BtreeLeaveAll(db);
24822 *pCurrent = totalUsed;
24823 *pHighwtr = 0;
24824 break;
24825 }
24826
24827 /*
24828 ** *pCurrent gets an accurate estimate of the amount of memory used
24829 ** to store the schema for all databases (main, temp, and any ATTACHed
24830 ** databases. *pHighwtr is set to zero.
24831 */
24832 case SQLITE_DBSTATUS_SCHEMA_USED: {
24833 int i; /* Used to iterate through schemas */
24834 int nByte = 0; /* Used to accumulate return value */
24835
24836 sqlite3BtreeEnterAll(db);
24837 db->pnBytesFreed = &nByte;
24838 assert( db->lookaside.pEnd==db->lookaside.pTrueEnd );
24839 db->lookaside.pEnd = db->lookaside.pStart;
@@ -24834,19 +24863,19 @@
24863 }
24864 db->pnBytesFreed = 0;
24865 db->lookaside.pEnd = db->lookaside.pTrueEnd;
24866 sqlite3BtreeLeaveAll(db);
24867
24868 *pHighwtr = 0;
24869 *pCurrent = nByte;
24870 break;
24871 }
24872
24873 /*
24874 ** *pCurrent gets an accurate estimate of the amount of memory used
24875 ** to store all prepared statements.
24876 ** *pHighwtr is set to zero.
24877 */
24878 case SQLITE_DBSTATUS_STMT_USED: {
24879 struct Vdbe *pVdbe; /* Used to iterate through VMs */
24880 int nByte = 0; /* Used to accumulate return value */
24881
@@ -24857,19 +24886,19 @@
24886 sqlite3VdbeDelete(pVdbe);
24887 }
24888 db->lookaside.pEnd = db->lookaside.pTrueEnd;
24889 db->pnBytesFreed = 0;
24890
24891 *pHighwtr = 0; /* IMP: R-64479-57858 */
24892 *pCurrent = nByte;
24893
24894 break;
24895 }
24896
24897 /*
24898 ** Set *pCurrent to the total cache hits or misses encountered by all
24899 ** pagers the database handle is connected to. *pHighwtr is always set
24900 ** to zero.
24901 */
24902 case SQLITE_DBSTATUS_CACHE_SPILL:
24903 op = SQLITE_DBSTATUS_CACHE_WRITE+1;
24904 /* no break */ deliberate_fall_through
@@ -24885,23 +24914,43 @@
24914 if( db->aDb[i].pBt ){
24915 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
24916 sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
24917 }
24918 }
24919 *pHighwtr = 0; /* IMP: R-42420-56072 */
24920 /* IMP: R-54100-20147 */
24921 /* IMP: R-29431-39229 */
24922 *pCurrent = nRet;
24923 break;
24924 }
24925
24926 /* Set *pCurrent to the number of bytes that the db database connection
24927 ** has spilled to the filesystem in temporary files that could have been
24928 ** stored in memory, had sufficient memory been available.
24929 ** The *pHighwater is always set to zero.
24930 */
24931 case SQLITE_DBSTATUS_TEMPBUF_SPILL: {
24932 u64 nRet = 0;
24933 if( db->aDb[1].pBt ){
24934 Pager *pPager = sqlite3BtreePager(db->aDb[1].pBt);
24935 sqlite3PagerCacheStat(pPager, SQLITE_DBSTATUS_CACHE_WRITE,
24936 resetFlag, &nRet);
24937 nRet *= sqlite3BtreeGetPageSize(db->aDb[1].pBt);
24938 }
24939 nRet += db->nSpill;
24940 if( resetFlag ) db->nSpill = 0;
24941 *pHighwtr = 0;
24942 *pCurrent = nRet;
24943 break;
24944 }
24945
24946 /* Set *pCurrent to non-zero if there are unresolved deferred foreign
24947 ** key constraints. Set *pCurrent to zero if all foreign key constraints
24948 ** have been satisfied. The *pHighwtr is always set to zero.
24949 */
24950 case SQLITE_DBSTATUS_DEFERRED_FKS: {
24951 *pHighwtr = 0; /* IMP: R-11967-56545 */
24952 *pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;
24953 break;
24954 }
24955
24956 default: {
@@ -24909,10 +24958,35 @@
24958 }
24959 }
24960 sqlite3_mutex_leave(db->mutex);
24961 return rc;
24962 }
24963
24964 /*
24965 ** 32-bit variant of sqlite3_db_status64()
24966 */
24967 SQLITE_API int sqlite3_db_status(
24968 sqlite3 *db, /* The database connection whose status is desired */
24969 int op, /* Status verb */
24970 int *pCurrent, /* Write current value here */
24971 int *pHighwtr, /* Write high-water mark here */
24972 int resetFlag /* Reset high-water mark if true */
24973 ){
24974 sqlite3_int64 C = 0, H = 0;
24975 int rc;
24976 #ifdef SQLITE_ENABLE_API_ARMOR
24977 if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwtr==0 ){
24978 return SQLITE_MISUSE_BKPT;
24979 }
24980 #endif
24981 rc = sqlite3_db_status64(db, op, &C, &H, resetFlag);
24982 if( rc==0 ){
24983 *pCurrent = C & 0x7fffffff;
24984 *pHighwtr = H & 0x7fffffff;
24985 }
24986 return rc;
24987 }
24988
24989 /************** End of status.c **********************************************/
24990 /************** Begin file date.c ********************************************/
24991 /*
24992 ** 2003 October 31
@@ -95636,11 +95710,11 @@
95710 ** to run faster.
95711 */
95712 static SQLITE_NOINLINE int vdbeColumnFromOverflow(
95713 VdbeCursor *pC, /* The BTree cursor from which we are reading */
95714 int iCol, /* The column to read */
95715 u32 t, /* The serial-type code for the column value */
95716 i64 iOffset, /* Offset to the start of the content value */
95717 u32 cacheStatus, /* Current Vdbe.cacheCtr value */
95718 u32 colCacheCtr, /* Current value of the column cache counter */
95719 Mem *pDest /* Store the value into this register. */
95720 ){
@@ -96737,11 +96811,12 @@
96811 flags2 = pIn2->flags & ~MEM_Str;
96812 }else if( (flags2 & MEM_Zero)!=0 ){
96813 if( sqlite3VdbeMemExpandBlob(pIn2) ) goto no_mem;
96814 flags2 = pIn2->flags & ~MEM_Str;
96815 }
96816 nByte = pIn1->n;
96817 nByte += pIn2->n;
96818 if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
96819 goto too_big;
96820 }
96821 if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
96822 goto no_mem;
@@ -98562,11 +98637,11 @@
98637 assert( db->mallocFailed || pRec->flags&(MEM_Str|MEM_Blob) );
98638 assert( pRec->n>=0 );
98639 len = (u32)pRec->n;
98640 serial_type = (len*2) + 12 + ((pRec->flags & MEM_Str)!=0);
98641 if( pRec->flags & MEM_Zero ){
98642 serial_type += (u32)pRec->u.nZero*2;
98643 if( nData ){
98644 if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;
98645 len += pRec->u.nZero;
98646 }else{
98647 nZero += pRec->u.nZero;
@@ -105079,10 +105154,11 @@
105154 UnpackedRecord *pUnpacked; /* Space to unpack a record */
105155 SorterList list; /* List for thread to write to a PMA */
105156 SorterCompare xCompare; /* Compare function to use */
105157 SorterFile file; /* Temp file for level-0 PMAs */
105158 SorterFile file2; /* Space for other PMAs */
105159 u64 nSpill; /* Total bytes written by this task */
105160 };
105161
105162
105163 /*
105164 ** Main sorter structure. A single instance of this is allocated for each
@@ -105199,10 +105275,11 @@
105275 int nBuffer; /* Size of write buffer in bytes */
105276 int iBufStart; /* First byte of buffer to write */
105277 int iBufEnd; /* Last byte of buffer to write */
105278 i64 iWriteOff; /* Offset of start of buffer in file */
105279 sqlite3_file *pFd; /* File handle to write to */
105280 u64 nPmaSpill; /* Total number of bytes written */
105281 };
105282
105283 /*
105284 ** This object is the header on a single record while that record is being
105285 ** held in memory and prior to being written out as part of a PMA.
@@ -106057,10 +106134,16 @@
106134 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){
106135 VdbeSorter *pSorter;
106136 assert( pCsr->eCurType==CURTYPE_SORTER );
106137 pSorter = pCsr->uc.pSorter;
106138 if( pSorter ){
106139 /* Increment db->nSpill by the total number of bytes of data written
106140 ** to temp files by this sort operation. */
106141 int ii;
106142 for(ii=0; ii<pSorter->nTask; ii++){
106143 db->nSpill += pSorter->aTask[ii].nSpill;
106144 }
106145 sqlite3VdbeSorterReset(db, pSorter);
106146 sqlite3_free(pSorter->list.aMemory);
106147 sqlite3DbFree(db, pSorter);
106148 pCsr->uc.pSorter = 0;
106149 }
@@ -106282,10 +106365,11 @@
106365 if( p->iBufEnd==p->nBuffer ){
106366 p->eFWErr = sqlite3OsWrite(p->pFd,
106367 &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart,
106368 p->iWriteOff + p->iBufStart
106369 );
106370 p->nPmaSpill += (p->iBufEnd - p->iBufStart);
106371 p->iBufStart = p->iBufEnd = 0;
106372 p->iWriteOff += p->nBuffer;
106373 }
106374 assert( p->iBufEnd<p->nBuffer );
106375
@@ -106298,21 +106382,24 @@
106382 ** The results of using the PMA-writer after this call are undefined.
106383 ** Return SQLITE_OK if flushing the buffered data succeeds or is not
106384 ** required. Otherwise, return an SQLite error code.
106385 **
106386 ** Before returning, set *piEof to the offset immediately following the
106387 ** last byte written to the file. Also, increment (*pnSpill) by the total
106388 ** number of bytes written to the file.
106389 */
106390 static int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof, u64 *pnSpill){
106391 int rc;
106392 if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){
106393 p->eFWErr = sqlite3OsWrite(p->pFd,
106394 &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart,
106395 p->iWriteOff + p->iBufStart
106396 );
106397 p->nPmaSpill += (p->iBufEnd - p->iBufStart);
106398 }
106399 *piEof = (p->iWriteOff + p->iBufEnd);
106400 *pnSpill += p->nPmaSpill;
106401 sqlite3_free(p->aBuffer);
106402 rc = p->eFWErr;
106403 memset(p, 0, sizeof(PmaWriter));
106404 return rc;
106405 }
@@ -106388,11 +106475,11 @@
106475 vdbePmaWriteVarint(&writer, p->nVal);
106476 vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);
106477 if( pList->aMemory==0 ) sqlite3_free(p);
106478 }
106479 pList->pList = p;
106480 rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof, &pTask->nSpill);
106481 }
106482
106483 vdbeSorterWorkDebug(pTask, "exit");
106484 assert( rc!=SQLITE_OK || pList->pList==0 );
106485 assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );
@@ -106702,11 +106789,11 @@
106789 vdbePmaWriteBlob(&writer, pReader->aKey, nKey);
106790 assert( pIncr->pMerger->pTask==pTask );
106791 rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);
106792 }
106793
106794 rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof, &pTask->nSpill);
106795 if( rc==SQLITE_OK ) rc = rc2;
106796 vdbeSorterPopulateDebug(pTask, "exit");
106797 return rc;
106798 }
106799
@@ -133012,10 +133099,11 @@
133099 int nSep,
133100 const char *zSep
133101 ){
133102 i64 j, n = 0;
133103 int i;
133104 int bNotNull = 0; /* True after at least NOT NULL argument seen */
133105 char *z;
133106 for(i=0; i<argc; i++){
133107 n += sqlite3_value_bytes(argv[i]);
133108 }
133109 n += (argc-1)*(i64)nSep;
@@ -133028,16 +133116,17 @@
133116 for(i=0; i<argc; i++){
133117 if( sqlite3_value_type(argv[i])!=SQLITE_NULL ){
133118 int k = sqlite3_value_bytes(argv[i]);
133119 const char *v = (const char*)sqlite3_value_text(argv[i]);
133120 if( v!=0 ){
133121 if( bNotNull && nSep>0 ){
133122 memcpy(&z[j], zSep, nSep);
133123 j += nSep;
133124 }
133125 memcpy(&z[j], v, k);
133126 j += k;
133127 bNotNull = 1;
133128 }
133129 }
133130 }
133131 z[j] = 0;
133132 assert( j<=n );
@@ -140169,10 +140258,12 @@
140258 int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
140259 /* Version 3.50.0 and later */
140260 int (*setlk_timeout)(sqlite3*,int,int);
140261 /* Version 3.51.0 and later */
140262 int (*set_errmsg)(sqlite3*,int,const char*);
140263 int (*db_status64)(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
140264
140265 };
140266
140267 /*
140268 ** This is the function signature used for all extension entry points. It
140269 ** is also defined in the file "loadext.c".
@@ -140506,10 +140597,11 @@
140597 #define sqlite3_set_clientdata sqlite3_api->set_clientdata
140598 /* Version 3.50.0 and later */
140599 #define sqlite3_setlk_timeout sqlite3_api->setlk_timeout
140600 /* Version 3.51.0 and later */
140601 #define sqlite3_set_errmsg sqlite3_api->set_errmsg
140602 #define sqlite3_db_status64 sqlite3_api->db_status64
140603 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
140604
140605 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
140606 /* This case when the file really is being compiled as a loadable
140607 ** extension */
@@ -141031,11 +141123,12 @@
141123 sqlite3_get_clientdata,
141124 sqlite3_set_clientdata,
141125 /* Version 3.50.0 and later */
141126 sqlite3_setlk_timeout,
141127 /* Version 3.51.0 and later */
141128 sqlite3_set_errmsg,
141129 sqlite3_db_status64
141130 };
141131
141132 /* True if x is the directory separator character
141133 */
141134 #if SQLITE_OS_WIN
@@ -247573,13 +247666,13 @@
247666 ** backing store corruption. */
247667 if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT_ROWID(p, iRowid);
247668
247669 if( rc==SQLITE_OK ){
247670 u8 *aOut = 0; /* Read blob data into this buffer */
247671 i64 nByte = sqlite3_blob_bytes(p->pReader);
247672 i64 szData = (sizeof(Fts5Data) + 7) & ~7;
247673 i64 nAlloc = szData + nByte + FTS5_DATA_PADDING;
247674 pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);
247675 if( pRet ){
247676 pRet->nn = nByte;
247677 aOut = pRet->p = (u8*)pRet + szData;
247678 }else{
@@ -259833,11 +259926,11 @@
259926 int nArg, /* Number of args */
259927 sqlite3_value **apUnused /* Function arguments */
259928 ){
259929 assert( nArg==0 );
259930 UNUSED_PARAM2(nArg, apUnused);
259931 sqlite3_result_text(pCtx, "fts5: 2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70", -1, SQLITE_TRANSIENT);
259932 }
259933
259934 /*
259935 ** Implementation of fts5_locale(LOCALE, TEXT) function.
259936 **
@@ -260150,20 +260243,20 @@
260243 ** must be read from the saved row stored in Fts5Storage.pSavedRow.
260244 **
260245 ** This is necessary - using sqlite3_value_nochange() instead of just having
260246 ** SQLite pass the original value back via xUpdate() - so as not to discard
260247 ** any locale information associated with such values.
260248 **
260249 */
260250 struct Fts5Storage {
260251 Fts5Config *pConfig;
260252 Fts5Index *pIndex;
 
260253 int bTotalsValid; /* True if nTotalRow/aTotalSize[] are valid */
260254 i64 nTotalRow; /* Total number of rows in FTS table */
260255 i64 *aTotalSize; /* Total sizes of each column */
260256 sqlite3_stmt *pSavedRow;
260257 sqlite3_stmt *aStmt[12];
260258 };
260259
260260
260261 #if FTS5_STMT_SCAN_ASC!=0
260262 # error "FTS5_STMT_SCAN_ASC mismatch"
@@ -260182,11 +260275,10 @@
260275 #define FTS5_STMT_REPLACE_DOCSIZE 7
260276 #define FTS5_STMT_DELETE_DOCSIZE 8
260277 #define FTS5_STMT_LOOKUP_DOCSIZE 9
260278 #define FTS5_STMT_REPLACE_CONFIG 10
260279 #define FTS5_STMT_SCAN 11
 
260280
260281 /*
260282 ** Prepare the two insert statements - Fts5Storage.pInsertContent and
260283 ** Fts5Storage.pInsertDocsize - if they have not already been prepared.
260284 ** Return SQLITE_OK if successful, or an SQLite error code if an error
@@ -260224,11 +260316,10 @@
260316
260317 "SELECT sz%s FROM %Q.'%q_docsize' WHERE id=?", /* LOOKUP_DOCSIZE */
260318
260319 "REPLACE INTO %Q.'%q_config' VALUES(?,?)", /* REPLACE_CONFIG */
260320 "SELECT %s FROM %s AS T", /* SCAN */
 
260321 };
260322 Fts5Config *pC = p->pConfig;
260323 char *zSql = 0;
260324
260325 assert( ArraySize(azStmt)==ArraySize(p->aStmt) );
@@ -260445,40 +260536,10 @@
260536 }
260537
260538 return rc;
260539 }
260540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260541 /*
260542 ** Open a new Fts5Index handle. If the bCreate argument is true, create
260543 ** and initialize the underlying tables
260544 **
260545 ** If successful, set *pp to point to the new object and return SQLITE_OK.
@@ -260503,13 +260564,11 @@
260564 memset(p, 0, (size_t)nByte);
260565 p->aTotalSize = (i64*)&p[1];
260566 p->pConfig = pConfig;
260567 p->pIndex = pIndex;
260568
260569 if( bCreate ){
 
 
260570 if( pConfig->eContent==FTS5_CONTENT_NORMAL
260571 || pConfig->eContent==FTS5_CONTENT_UNINDEXED
260572 ){
260573 int nDefn = 32 + pConfig->nCol*10;
260574 char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 20);
@@ -261175,63 +261234,10 @@
261234 }
261235
261236 return rc;
261237 }
261238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261239 /*
261240 ** Insert new entries into the FTS index and %_docsize table.
261241 */
261242 static int sqlite3Fts5StorageIndexInsert(
261243 Fts5Storage *p,
@@ -261255,11 +261261,10 @@
261261 if( pConfig->abUnindexed[ctx.iCol]==0 ){
261262 int nText = 0; /* Size of pText in bytes */
261263 const char *pText = 0; /* Pointer to buffer containing text value */
261264 int nLoc = 0; /* Size of pText in bytes */
261265 const char *pLoc = 0; /* Pointer to buffer containing text value */
 
261266
261267 sqlite3_value *pVal = apVal[ctx.iCol+2];
261268 if( p->pSavedRow && sqlite3_value_nochange(pVal) ){
261269 pVal = sqlite3_column_value(p->pSavedRow, ctx.iCol+1);
261270 if( pConfig->eContent==FTS5_CONTENT_NORMAL && pConfig->bLocale ){
@@ -261272,19 +261277,10 @@
261277 }
261278
261279 if( pConfig->bLocale && sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
261280 rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
261281 }else{
 
 
 
 
 
 
 
 
 
261282 pText = (const char*)sqlite3_value_text(pVal);
261283 nText = sqlite3_value_bytes(pVal);
261284 }
261285
261286 if( rc==SQLITE_OK ){
@@ -261293,13 +261289,10 @@
261289 FTS5_TOKENIZE_DOCUMENT, pText, nText, (void*)&ctx,
261290 fts5StorageInsertCallback
261291 );
261292 sqlite3Fts5ClearLocale(pConfig);
261293 }
 
 
 
261294 }
261295 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
261296 p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;
261297 }
261298 p->nTotalRow++;
261299
+31 -5
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -142,18 +142,18 @@
142142
** been edited in any way since it was last checked in, then the last
143143
** four hexadecimal digits of the hash may be modified.
144144
**
145145
** See also: [sqlite3_libversion()],
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
-** [sqlite_version()] and [sqlite_sourceid()].
147
+** [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-10-10 14:31:46 4966d7a1ce42af8b1c50fdd40e651e80d0eeb8cb62dd882950cab275f98aba88"
151
+#define SQLITE_SOURCE_ID "2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2025-10-10T14:31:46.035Z"
154
+#define SQLITE_SCM_DATETIME "2025-10-15T10:52:45.276Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
@@ -181,11 +181,11 @@
181181
** a pointer to a string constant whose value is the same as the
182182
** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
183183
** using an edited copy of [the amalgamation], then the last four characters
184184
** of the hash might be different from [SQLITE_SOURCE_ID].)^
185185
**
186
-** See also: [sqlite_version()] and [sqlite_sourceid()].
186
+** See also: [sqlite_version()] and [sqlite_source_id()].
187187
*/
188188
SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
189189
SQLITE_API const char *sqlite3_libversion(void);
190190
SQLITE_API const char *sqlite3_sourceid(void);
191191
SQLITE_API int sqlite3_libversion_number(void);
@@ -8918,14 +8918,23 @@
89188918
** the resetFlg is true, then the highest instantaneous value is
89198919
** reset back down to the current value.
89208920
**
89218921
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
89228922
** non-zero [error code] on failure.
8923
+**
8924
+** ^The sqlite3_db_status64(D,O,C,H,R) routine works exactly the same
8925
+** way as sqlite3_db_status(D,O,C,H,R) routine except that the C and H
8926
+** parameters are pointer to 64-bit integers (type: sqlite3_int64) instead
8927
+** of pointers to 32-bit integers, which allows larger status values
8928
+** to be returned. If a status value exceeds 2,147,483,647 then
8929
+** sqlite3_db_status() will truncate the value whereas sqlite3_db_status64()
8930
+** will return the full value.
89238931
**
89248932
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
89258933
*/
89268934
SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
8935
+SQLITE_API int sqlite3_db_status64(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
89278936
89288937
/*
89298938
** CAPI3REF: Status Parameters for database connections
89308939
** KEYWORDS: {SQLITE_DBSTATUS options}
89318940
**
@@ -9018,10 +9027,14 @@
90189027
** database file in rollback mode databases. Any pages written as part of
90199028
** transaction rollback or database recovery operations are not included.
90209029
** If an IO or other error occurs while writing a page to disk, the effect
90219030
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
90229031
** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
9032
+** <p>
9033
+** ^(There is overlap between the quantities measured by this parameter
9034
+** (SQLITE_DBSTATUS_CACHE_WRITE) and SQLITE_DBSTATUS_TEMPBUF_SPILL.
9035
+** Resetting one will reduce the other.)^
90239036
** </dd>
90249037
**
90259038
** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
90269039
** <dd>This parameter returns the number of dirty cache entries that have
90279040
** been written to disk in the middle of a transaction due to the page
@@ -9033,10 +9046,22 @@
90339046
**
90349047
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
90359048
** <dd>This parameter returns zero for the current value if and only if
90369049
** all foreign key constraints (deferred or immediate) have been
90379050
** resolved.)^ ^The highwater mark is always 0.
9051
+**
9052
+** [[SQLITE_DBSTATUS_TEMPBUF_SPILL] ^(<dt>SQLITE_DBSTATUS_TEMPBUF_SPILL</dt>
9053
+** <dd>^(This parameter returns the number of bytes written to temporary
9054
+** files on disk that could have been kept in memory had sufficient memory
9055
+** been available. This value includes writes to intermediate tables that
9056
+** are part of complex queries, external sorts that spill to disk, and
9057
+** writes to TEMP tables.)^
9058
+** ^The highwater mark is always 0.
9059
+** <p>
9060
+** ^(There is overlap between the quantities measured by this parameter
9061
+** (SQLITE_DBSTATUS_TEMPBUF_SPILL) and SQLITE_DBSTATUS_CACHE_WRITE.
9062
+** Resetting one will reduce the other.)^
90389063
** </dd>
90399064
** </dl>
90409065
*/
90419066
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
90429067
#define SQLITE_DBSTATUS_CACHE_USED 1
@@ -9049,11 +9074,12 @@
90499074
#define SQLITE_DBSTATUS_CACHE_MISS 8
90509075
#define SQLITE_DBSTATUS_CACHE_WRITE 9
90519076
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
90529077
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
90539078
#define SQLITE_DBSTATUS_CACHE_SPILL 12
9054
-#define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
9079
+#define SQLITE_DBSTATUS_TEMPBUF_SPILL 13
9080
+#define SQLITE_DBSTATUS_MAX 13 /* Largest defined DBSTATUS */
90559081
90569082
90579083
/*
90589084
** CAPI3REF: Prepared Statement Status
90599085
** METHOD: sqlite3_stmt
90609086
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -142,18 +142,18 @@
142 ** been edited in any way since it was last checked in, then the last
143 ** four hexadecimal digits of the hash may be modified.
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_sourceid()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-10-10 14:31:46 4966d7a1ce42af8b1c50fdd40e651e80d0eeb8cb62dd882950cab275f98aba88"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2025-10-10T14:31:46.035Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -181,11 +181,11 @@
181 ** a pointer to a string constant whose value is the same as the
182 ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
183 ** using an edited copy of [the amalgamation], then the last four characters
184 ** of the hash might be different from [SQLITE_SOURCE_ID].)^
185 **
186 ** See also: [sqlite_version()] and [sqlite_sourceid()].
187 */
188 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
189 SQLITE_API const char *sqlite3_libversion(void);
190 SQLITE_API const char *sqlite3_sourceid(void);
191 SQLITE_API int sqlite3_libversion_number(void);
@@ -8918,14 +8918,23 @@
8918 ** the resetFlg is true, then the highest instantaneous value is
8919 ** reset back down to the current value.
8920 **
8921 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
8922 ** non-zero [error code] on failure.
 
 
 
 
 
 
 
 
8923 **
8924 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
8925 */
8926 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 
8927
8928 /*
8929 ** CAPI3REF: Status Parameters for database connections
8930 ** KEYWORDS: {SQLITE_DBSTATUS options}
8931 **
@@ -9018,10 +9027,14 @@
9018 ** database file in rollback mode databases. Any pages written as part of
9019 ** transaction rollback or database recovery operations are not included.
9020 ** If an IO or other error occurs while writing a page to disk, the effect
9021 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
9022 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
 
 
 
 
9023 ** </dd>
9024 **
9025 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
9026 ** <dd>This parameter returns the number of dirty cache entries that have
9027 ** been written to disk in the middle of a transaction due to the page
@@ -9033,10 +9046,22 @@
9033 **
9034 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
9035 ** <dd>This parameter returns zero for the current value if and only if
9036 ** all foreign key constraints (deferred or immediate) have been
9037 ** resolved.)^ ^The highwater mark is always 0.
 
 
 
 
 
 
 
 
 
 
 
 
9038 ** </dd>
9039 ** </dl>
9040 */
9041 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
9042 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -9049,11 +9074,12 @@
9049 #define SQLITE_DBSTATUS_CACHE_MISS 8
9050 #define SQLITE_DBSTATUS_CACHE_WRITE 9
9051 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
9052 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
9053 #define SQLITE_DBSTATUS_CACHE_SPILL 12
9054 #define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
 
9055
9056
9057 /*
9058 ** CAPI3REF: Prepared Statement Status
9059 ** METHOD: sqlite3_stmt
9060
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -142,18 +142,18 @@
142 ** been edited in any way since it was last checked in, then the last
143 ** four hexadecimal digits of the hash may be modified.
144 **
145 ** See also: [sqlite3_libversion()],
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-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2025-10-15T10:52:45.276Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -181,11 +181,11 @@
181 ** a pointer to a string constant whose value is the same as the
182 ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
183 ** using an edited copy of [the amalgamation], then the last four characters
184 ** of the hash might be different from [SQLITE_SOURCE_ID].)^
185 **
186 ** See also: [sqlite_version()] and [sqlite_source_id()].
187 */
188 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
189 SQLITE_API const char *sqlite3_libversion(void);
190 SQLITE_API const char *sqlite3_sourceid(void);
191 SQLITE_API int sqlite3_libversion_number(void);
@@ -8918,14 +8918,23 @@
8918 ** the resetFlg is true, then the highest instantaneous value is
8919 ** reset back down to the current value.
8920 **
8921 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
8922 ** non-zero [error code] on failure.
8923 **
8924 ** ^The sqlite3_db_status64(D,O,C,H,R) routine works exactly the same
8925 ** way as sqlite3_db_status(D,O,C,H,R) routine except that the C and H
8926 ** parameters are pointer to 64-bit integers (type: sqlite3_int64) instead
8927 ** of pointers to 32-bit integers, which allows larger status values
8928 ** to be returned. If a status value exceeds 2,147,483,647 then
8929 ** sqlite3_db_status() will truncate the value whereas sqlite3_db_status64()
8930 ** will return the full value.
8931 **
8932 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
8933 */
8934 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
8935 SQLITE_API int sqlite3_db_status64(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
8936
8937 /*
8938 ** CAPI3REF: Status Parameters for database connections
8939 ** KEYWORDS: {SQLITE_DBSTATUS options}
8940 **
@@ -9018,10 +9027,14 @@
9027 ** database file in rollback mode databases. Any pages written as part of
9028 ** transaction rollback or database recovery operations are not included.
9029 ** If an IO or other error occurs while writing a page to disk, the effect
9030 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
9031 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
9032 ** <p>
9033 ** ^(There is overlap between the quantities measured by this parameter
9034 ** (SQLITE_DBSTATUS_CACHE_WRITE) and SQLITE_DBSTATUS_TEMPBUF_SPILL.
9035 ** Resetting one will reduce the other.)^
9036 ** </dd>
9037 **
9038 ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
9039 ** <dd>This parameter returns the number of dirty cache entries that have
9040 ** been written to disk in the middle of a transaction due to the page
@@ -9033,10 +9046,22 @@
9046 **
9047 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
9048 ** <dd>This parameter returns zero for the current value if and only if
9049 ** all foreign key constraints (deferred or immediate) have been
9050 ** resolved.)^ ^The highwater mark is always 0.
9051 **
9052 ** [[SQLITE_DBSTATUS_TEMPBUF_SPILL] ^(<dt>SQLITE_DBSTATUS_TEMPBUF_SPILL</dt>
9053 ** <dd>^(This parameter returns the number of bytes written to temporary
9054 ** files on disk that could have been kept in memory had sufficient memory
9055 ** been available. This value includes writes to intermediate tables that
9056 ** are part of complex queries, external sorts that spill to disk, and
9057 ** writes to TEMP tables.)^
9058 ** ^The highwater mark is always 0.
9059 ** <p>
9060 ** ^(There is overlap between the quantities measured by this parameter
9061 ** (SQLITE_DBSTATUS_TEMPBUF_SPILL) and SQLITE_DBSTATUS_CACHE_WRITE.
9062 ** Resetting one will reduce the other.)^
9063 ** </dd>
9064 ** </dl>
9065 */
9066 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
9067 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -9049,11 +9074,12 @@
9074 #define SQLITE_DBSTATUS_CACHE_MISS 8
9075 #define SQLITE_DBSTATUS_CACHE_WRITE 9
9076 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
9077 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
9078 #define SQLITE_DBSTATUS_CACHE_SPILL 12
9079 #define SQLITE_DBSTATUS_TEMPBUF_SPILL 13
9080 #define SQLITE_DBSTATUS_MAX 13 /* Largest defined DBSTATUS */
9081
9082
9083 /*
9084 ** CAPI3REF: Prepared Statement Status
9085 ** METHOD: sqlite3_stmt
9086

Keyboard Shortcuts

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