Fossil SCM

Update the built-in SQLite to include the latest enhancements and optimizations.

drh 2026-02-17 12:08 trunk
Commit b10ff3809e1033e77e530002d6639a857a87639f651733e3aa987fa1b58e6f66
2 files changed +207 -155 +2 -2
+207 -155
--- 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
-** b5ebbd004183f81902fa79a143222204b33d with changes in files:
21
+** 2610105a439e25c050b2deb32953861187c8 with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470470
#define SQLITE_VERSION "3.52.0"
471471
#define SQLITE_VERSION_NUMBER 3052000
472
-#define SQLITE_SOURCE_ID "2026-02-16 11:14:59 b5ebbd004183f81902fa79a143222204b33dbe1cacb918194556b8dac67bd567"
472
+#define SQLITE_SOURCE_ID "2026-02-17 11:28:48 2610105a439e25c050b2deb32953861187c81b1d97407f41dc188e6627e0ac4d"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2026-02-16T11:14:59.370Z"
475
+#define SQLITE_SCM_DATETIME "2026-02-17T11:28:48.505Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -21804,10 +21804,11 @@
2180421804
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
2180521805
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
2180621806
Expr*,ExprList*,u32,Expr*);
2180721807
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
2180821808
SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3*,void*);
21809
+SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect);
2180921810
SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
2181021811
SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*);
2181121812
SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
2181221813
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
2181321814
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -22025,11 +22026,11 @@
2202522026
SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
2202622027
2202722028
SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
2202822029
SQLITE_PRIVATE i64 sqlite3RealToI64(double);
2202922030
SQLITE_PRIVATE int sqlite3Int64ToText(i64,char*);
22030
-SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
22031
+SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*);
2203122032
SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
2203222033
SQLITE_PRIVATE int sqlite3GetUInt32(const char*, u32*);
2203322034
SQLITE_PRIVATE int sqlite3Atoi(const char*);
2203422035
#ifndef SQLITE_OMIT_UTF16
2203522036
SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nByte, int nChar);
@@ -24609,17 +24610,18 @@
2460924610
#endif
2461024611
#ifdef SQLITE_DEBUG
2461124612
SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
2461224613
#endif
2461324614
SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
24614
-SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem*);
24615
+SQLITE_PRIVATE int sqlite3VdbeMemZeroTerminateIfAble(Mem*);
2461524616
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
2461624617
SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
2461724618
SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
2461824619
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*);
2461924620
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
2462024621
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
24622
+SQLITE_PRIVATE SQLITE_NOINLINE double sqlite3MemRealValueRC(Mem*, int*);
2462124623
SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
2462224624
SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
2462324625
SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
2462424626
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
2462524627
SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
@@ -25575,11 +25577,11 @@
2557525577
return 0;
2557625578
}else if( parseHhMmSs(zDate, p)==0 ){
2557725579
return 0;
2557825580
}else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
2557925581
return setDateTimeToCurrent(context, p);
25580
- }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){
25582
+ }else if( sqlite3AtoF(zDate, &r)>0 ){
2558125583
setRawDateNumber(p, r);
2558225584
return 0;
2558325585
}else if( (sqlite3StrICmp(zDate,"subsec")==0
2558425586
|| sqlite3StrICmp(zDate,"subsecond")==0)
2558525587
&& sqlite3NotPureFunc(context) ){
@@ -26021,11 +26023,11 @@
2602126023
** Move the date to the same time on the next occurrence of
2602226024
** weekday N where 0==Sunday, 1==Monday, and so forth. If the
2602326025
** date is already on the appropriate weekday, this is a no-op.
2602426026
*/
2602526027
if( sqlite3_strnicmp(z, "weekday ", 8)==0
26026
- && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)>0
26028
+ && sqlite3AtoF(&z[8], &r)>0
2602726029
&& r>=0.0 && r<7.0 && (n=(int)r)==r ){
2602826030
sqlite3_int64 Z;
2602926031
computeYMD_HMS(p);
2603026032
p->tz = 0;
2603126033
p->validJD = 0;
@@ -26092,23 +26094,29 @@
2609226094
case '6':
2609326095
case '7':
2609426096
case '8':
2609526097
case '9': {
2609626098
double rRounder;
26097
- int i;
26099
+ int i, rx;
2609826100
int Y,M,D,h,m,x;
2609926101
const char *z2 = z;
26102
+ char *zCopy;
26103
+ sqlite3 *db = sqlite3_context_db_handle(pCtx);
2610026104
char z0 = z[0];
2610126105
for(n=1; z[n]; n++){
2610226106
if( z[n]==':' ) break;
2610326107
if( sqlite3Isspace(z[n]) ) break;
2610426108
if( z[n]=='-' ){
2610526109
if( n==5 && getDigits(&z[1], "40f", &Y)==1 ) break;
2610626110
if( n==6 && getDigits(&z[1], "50f", &Y)==1 ) break;
2610726111
}
2610826112
}
26109
- if( sqlite3AtoF(z, &r, n, SQLITE_UTF8)<=0 ){
26113
+ zCopy = sqlite3DbStrNDup(db, z, n);
26114
+ if( zCopy==0 ) break;
26115
+ rx = sqlite3AtoF(zCopy, &r)<=0;
26116
+ sqlite3DbFree(db, zCopy);
26117
+ if( rx ){
2611026118
assert( rc==1 );
2611126119
break;
2611226120
}
2611326121
if( z[n]=='-' ){
2611426122
/* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the
@@ -36705,12 +36713,11 @@
3670536713
3670636714
/*
3670736715
** The string z[] is an text representation of a real number.
3670836716
** Convert this string to a double and write it into *pResult.
3670936717
**
36710
-** The string z[] is length bytes in length (bytes, not characters) and
36711
-** uses the encoding enc. The string is not necessarily zero-terminated.
36718
+** z[] must be UTF-8 and zero-terminated.
3671236719
**
3671336720
** Return TRUE if the result is a valid real number (or integer) and FALSE
3671436721
** if the string is empty or contains extraneous text. More specifically
3671536722
** return
3671636723
** 1 => The input string is a pure integer
@@ -36733,144 +36740,134 @@
3673336740
** into *pResult.
3673436741
*/
3673536742
#if defined(_MSC_VER)
3673636743
#pragma warning(disable : 4756)
3673736744
#endif
36738
-SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
36745
+SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){
3673936746
#ifndef SQLITE_OMIT_FLOATING_POINT
36740
- int incr;
36741
- const char *zEnd;
3674236747
/* sign * significand * (10 ^ (esign * exponent)) */
36743
- int sign = 1; /* sign of significand */
36744
- u64 s = 0; /* significand */
36745
- int d = 0; /* adjust exponent for shifting decimal point */
36746
- int esign = 1; /* sign of exponent */
36747
- int e = 0; /* exponent */
36748
- int eValid = 1; /* True exponent is either not used or is well-formed */
36748
+ int neg = 0; /* True for a negative value */
36749
+ u64 s = 0; /* mantissa */
36750
+ int d = 0; /* Value is s * pow(10,d) */
3674936751
int nDigit = 0; /* Number of digits processed */
36750
- int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
36751
-
36752
- assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
36753
- *pResult = 0.0; /* Default return value, in case of an error */
36754
- if( length==0 ) return 0;
36755
-
36756
- if( enc==SQLITE_UTF8 ){
36757
- incr = 1;
36758
- zEnd = z + length;
36759
- }else{
36760
- int i;
36761
- incr = 2;
36762
- length &= ~1;
36763
- assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
36764
- testcase( enc==SQLITE_UTF16LE );
36765
- testcase( enc==SQLITE_UTF16BE );
36766
- for(i=3-enc; i<length && z[i]==0; i+=2){}
36767
- if( i<length ) eType = -100;
36768
- zEnd = &z[i^1];
36769
- z += (enc&1);
36770
- }
36752
+ int eType = 1; /* 1: pure integer, 2+: fractional */
36753
+
36754
+ *pResult = 0.0; /* Default return value, in case of an error */
3677136755
3677236756
/* skip leading spaces */
36773
- while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
36774
- if( z>=zEnd ) return 0;
36757
+ while( sqlite3Isspace(*z) ) z++;
3677536758
3677636759
/* get sign of significand */
3677736760
if( *z=='-' ){
36778
- sign = -1;
36779
- z+=incr;
36761
+ neg = 1;
36762
+ z++;
3678036763
}else if( *z=='+' ){
36781
- z+=incr;
36764
+ z++;
3678236765
}
3678336766
3678436767
/* copy max significant digits to significand */
36785
- while( z<zEnd && sqlite3Isdigit(*z) ){
36768
+ while( sqlite3Isdigit(*z) ){
3678636769
s = s*10 + (*z - '0');
36787
- z+=incr; nDigit++;
36770
+ z++; nDigit++;
3678836771
if( s>=((LARGEST_INT64-9)/10) ){
3678936772
/* skip non-significant significand digits
3679036773
** (increase exponent by d to shift decimal left) */
36791
- while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; }
36774
+ while( sqlite3Isdigit(*z) ){ z++; d++; }
3679236775
}
3679336776
}
36794
- if( z>=zEnd ) goto do_atof_calc;
3679536777
3679636778
/* if decimal point is present */
3679736779
if( *z=='.' ){
36798
- z+=incr;
36780
+ z++;
3679936781
eType++;
3680036782
/* copy digits from after decimal to significand
3680136783
** (decrease exponent by d to shift decimal right) */
36802
- while( z<zEnd && sqlite3Isdigit(*z) ){
36784
+ while( sqlite3Isdigit(*z) ){
3680336785
if( s<((LARGEST_INT64-9)/10) ){
3680436786
s = s*10 + (*z - '0');
3680536787
d--;
3680636788
nDigit++;
3680736789
}
36808
- z+=incr;
36790
+ z++;
3680936791
}
3681036792
}
36811
- if( z>=zEnd ) goto do_atof_calc;
3681236793
3681336794
/* if exponent is present */
3681436795
if( *z=='e' || *z=='E' ){
36815
- z+=incr;
36816
- eValid = 0;
36796
+ int esign = 1; /* sign of exponent */
36797
+ z++;
3681736798
eType++;
3681836799
36819
- /* This branch is needed to avoid a (harmless) buffer overread. The
36820
- ** special comment alerts the mutation tester that the correct answer
36821
- ** is obtained even if the branch is omitted */
36822
- if( z>=zEnd ) goto do_atof_calc; /*PREVENTS-HARMLESS-OVERREAD*/
36823
-
3682436800
/* get sign of exponent */
3682536801
if( *z=='-' ){
3682636802
esign = -1;
36827
- z+=incr;
36803
+ z++;
3682836804
}else if( *z=='+' ){
36829
- z+=incr;
36805
+ z++;
3683036806
}
3683136807
/* copy digits to exponent */
36832
- while( z<zEnd && sqlite3Isdigit(*z) ){
36833
- e = e<10000 ? (e*10 + (*z - '0')) : 10000;
36834
- z+=incr;
36835
- eValid = 1;
36808
+ if( sqlite3Isdigit(*z) ){
36809
+ int exp = *z - '0';
36810
+ z++;
36811
+ while( sqlite3Isdigit(*z) ){
36812
+ exp = exp<10000 ? (exp*10 + (*z - '0')) : 10000;
36813
+ z++;
36814
+ }
36815
+ d += esign*exp;
36816
+ }else{
36817
+ eType = -1;
3683636818
}
3683736819
}
3683836820
3683936821
/* skip trailing spaces */
36840
- while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
36822
+ while( sqlite3Isspace(*z) ) z++;
3684136823
36842
-do_atof_calc:
3684336824
/* Zero is a special case */
3684436825
if( s==0 ){
36845
- *pResult = sign<0 ? -0.0 : +0.0;
36846
- goto atof_return;
36826
+ *pResult = neg ? -0.0 : +0.0;
36827
+ }else{
36828
+ *pResult = sqlite3Fp10Convert2(s,d);
36829
+ if( neg ) *pResult = -*pResult;
36830
+ assert( !sqlite3IsNaN(*pResult) );
3684736831
}
3684836832
36849
- /* adjust exponent by d, and update sign */
36850
- e = (e*esign) + d;
36851
-
36852
- *pResult = sqlite3Fp10Convert2(s,e);
36853
- if( sign<0 ) *pResult = -*pResult;
36854
- assert( !sqlite3IsNaN(*pResult) );
36855
-
36856
-atof_return:
3685736833
/* return true if number and no extra non-whitespace characters after */
36858
- if( z==zEnd && nDigit>0 && eValid && eType>0 ){
36834
+ if( z[0]==0 && nDigit>0 ){
3685936835
return eType;
36860
- }else if( eType>=2 && (eType==3 || eValid) && nDigit>0 ){
36836
+ }else if( eType>=2 && nDigit>0 ){
3686136837
return -1;
3686236838
}else{
3686336839
return 0;
3686436840
}
3686536841
#else
36866
- return !sqlite3Atoi64(z, pResult, length, enc);
36842
+ return !sqlite3Atoi64(z, pResult, strlen(z), SQLITE_UTF8);
3686736843
#endif /* SQLITE_OMIT_FLOATING_POINT */
3686836844
}
3686936845
#if defined(_MSC_VER)
3687036846
#pragma warning(default : 4756)
3687136847
#endif
36848
+
36849
+/*
36850
+** Digit pairs used to convert a U64 or I64 into text, two digits
36851
+** at a time.
36852
+*/
36853
+static const union {
36854
+ char a[200];
36855
+ short int forceAlignment;
36856
+} sqlite3DigitPairs = {
36857
+ "00010203040506070809"
36858
+ "10111213141516171819"
36859
+ "20212223242526272829"
36860
+ "30313233343536373839"
36861
+ "40414243444546474849"
36862
+ "50515253545556575859"
36863
+ "60616263646566676869"
36864
+ "70717273747576777879"
36865
+ "80818283848586878889"
36866
+ "90919293949596979899"
36867
+};
36868
+
3687236869
3687336870
/*
3687436871
** Render an signed 64-bit integer as text. Store the result in zOut[] and
3687536872
** return the length of the string that was stored, in bytes. The value
3687636873
** returned does not include the zero terminator at the end of the output
@@ -36879,27 +36876,39 @@
3687936876
** The caller must ensure that zOut[] is at least 21 bytes in size.
3688036877
*/
3688136878
SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
3688236879
int i;
3688336880
u64 x;
36884
- char zTemp[22];
36885
- if( v<0 ){
36886
- x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
36887
- }else{
36881
+ union {
36882
+ char a[23];
36883
+ u16 forceAlignment;
36884
+ } u;
36885
+ if( v>0 ){
3688836886
x = v;
36889
- }
36890
- i = sizeof(zTemp)-2;
36891
- zTemp[sizeof(zTemp)-1] = 0;
36892
- while( 1 /*exit-by-break*/ ){
36893
- zTemp[i] = (x%10) + '0';
36894
- x = x/10;
36895
- if( x==0 ) break;
36896
- i--;
36897
- };
36898
- if( v<0 ) zTemp[--i] = '-';
36899
- memcpy(zOut, &zTemp[i], sizeof(zTemp)-i);
36900
- return sizeof(zTemp)-1-i;
36887
+ }else if( v==0 ){
36888
+ zOut[0] = '0';
36889
+ zOut[1] = 0;
36890
+ return 1;
36891
+ }else{
36892
+ x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
36893
+ }
36894
+ i = sizeof(u.a)-1;
36895
+ u.a[i] = 0;
36896
+ while( x>=10 ){
36897
+ int kk = (x%100)*2;
36898
+ assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
36899
+ assert( TWO_BYTE_ALIGNMENT(&u.a[i-2]) );
36900
+ *(u16*)(&u.a[i-2]) = *(u16*)&sqlite3DigitPairs.a[kk];
36901
+ i -= 2;
36902
+ x /= 100;
36903
+ }
36904
+ if( x ){
36905
+ u.a[--i] = x + '0';
36906
+ }
36907
+ if( v<0 ) u.a[--i] = '-';
36908
+ memcpy(zOut, &u.a[i], sizeof(u.a)-i);
36909
+ return sizeof(u.a)-1-i;
3690136910
}
3690236911
3690336912
/*
3690436913
** Compare the 19-character string zNum against the text representation
3690536914
** value 2^63: 9223372036854775808. Return negative, zero, or positive
@@ -37210,29 +37219,14 @@
3721037219
3721137220
/* Extract significant digits. */
3721237221
i = sizeof(p->zBuf)-1;
3721337222
assert( v>0 );
3721437223
while( v>=10 ){
37215
- static const union {
37216
- char a[200];
37217
- short int forAlignment;
37218
- } dig = {
37219
- "00010203040506070809"
37220
- "10111213141516171819"
37221
- "20212223242526272829"
37222
- "30313233343536373839"
37223
- "40414243444546474849"
37224
- "50515253545556575859"
37225
- "60616263646566676869"
37226
- "70717273747576777879"
37227
- "80818283848586878889"
37228
- "90919293949596979899"
37229
- };
3723037224
int kk = (v%100)*2;
37231
- assert( TWO_BYTE_ALIGNMENT(&dig.a[kk]) );
37225
+ assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
3723237226
assert( TWO_BYTE_ALIGNMENT(&p->zBuf[i-1]) );
37233
- *(u16*)(&p->zBuf[i-1]) = *(u16*)&dig.a[kk];
37227
+ *(u16*)(&p->zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
3723437228
i -= 2;
3723537229
v /= 100;
3723637230
}
3723737231
if( v ){
3723837232
assert( v<10 );
@@ -85157,36 +85151,40 @@
8515785151
** If pMem is already a string, detect if it is a zero-terminated
8515885152
** string, or make it into one if possible, and mark it as such.
8515985153
**
8516085154
** This is an optimization. Correct operation continues even if
8516185155
** this routine is a no-op.
85156
+**
85157
+** Return true if the strig is zero-terminated after this routine is
85158
+** called and false if it is not.
8516285159
*/
85163
-SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){
85160
+SQLITE_PRIVATE int sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){
8516485161
if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){
8516585162
/* pMem must be a string, and it cannot be an ephemeral or static string */
85166
- return;
85163
+ return 0;
8516785164
}
85168
- if( pMem->enc!=SQLITE_UTF8 ) return;
85165
+ if( pMem->enc!=SQLITE_UTF8 ) return 0;
8516985166
assert( pMem->z!=0 );
8517085167
if( pMem->flags & MEM_Dyn ){
8517185168
if( pMem->xDel==sqlite3_free
8517285169
&& sqlite3_msize(pMem->z) >= (u64)(pMem->n+1)
8517385170
){
8517485171
pMem->z[pMem->n] = 0;
8517585172
pMem->flags |= MEM_Term;
85176
- return;
85173
+ return 1;
8517785174
}
8517885175
if( pMem->xDel==sqlite3RCStrUnref ){
8517985176
/* Blindly assume that all RCStr objects are zero-terminated */
8518085177
pMem->flags |= MEM_Term;
85181
- return;
85178
+ return 1;
8518285179
}
8518385180
}else if( pMem->szMalloc >= pMem->n+1 ){
8518485181
pMem->z[pMem->n] = 0;
8518585182
pMem->flags |= MEM_Term;
85186
- return;
85183
+ return 1;
8518785184
}
85185
+ return 0;
8518885186
}
8518985187
8519085188
/*
8519185189
** It is already known that pMem contains an unterminated string.
8519285190
** Add the zero terminator.
@@ -85479,23 +85477,75 @@
8547985477
return memIntValue(pMem);
8548085478
}else{
8548185479
return 0;
8548285480
}
8548385481
}
85482
+
85483
+/*
85484
+** Invoke sqlite3AtoF() on the text value of pMem and return the
85485
+** double result. If sqlite3AtoF() returns an error code, write
85486
+** that code into *pRC if (*pRC)!=NULL.
85487
+**
85488
+** The caller must ensure that pMem->db!=0 and that pMem is in
85489
+** mode MEM_Str or MEM_Blob.
85490
+*/
85491
+SQLITE_PRIVATE SQLITE_NOINLINE double sqlite3MemRealValueRC(Mem *pMem, int *pRC){
85492
+ double val = (double)0;
85493
+ int rc = 0;
85494
+ assert( pMem->db!=0 );
85495
+ assert( pMem->flags & (MEM_Str|MEM_Blob) );
85496
+ if( pMem->z==0 ){
85497
+ /* no-op */
85498
+ }else if( pMem->enc==SQLITE_UTF8
85499
+ && ((pMem->flags & MEM_Term)!=0 || sqlite3VdbeMemZeroTerminateIfAble(pMem))
85500
+ ){
85501
+ rc = sqlite3AtoF(pMem->z, &val);
85502
+ }else if( pMem->n==0 ){
85503
+ /* no-op */
85504
+ }else if( pMem->enc==SQLITE_UTF8 ){
85505
+ char *zCopy = sqlite3DbStrNDup(pMem->db, pMem->z, pMem->n);
85506
+ if( zCopy ){
85507
+ rc = sqlite3AtoF(zCopy, &val);
85508
+ sqlite3DbFree(pMem->db, zCopy);
85509
+ }
85510
+ }else{
85511
+ int n, i, j;
85512
+ char *zCopy;
85513
+ const char *z;
85514
+
85515
+ n = pMem->n & ~1;
85516
+ zCopy = sqlite3DbMallocRaw(pMem->db, n/2 + 2);
85517
+ if( zCopy ){
85518
+ z = pMem->z;
85519
+ if( pMem->enc==SQLITE_UTF16LE ){
85520
+ for(i=j=0; i<n-1; i+=2, j++){
85521
+ zCopy[j] = z[i];
85522
+ if( z[i+1]!=0 ) break;
85523
+ }
85524
+ }else{
85525
+ for(i=j=0; i<n-1; i+=2, j++){
85526
+ if( z[i]!=0 ) break;
85527
+ zCopy[j] = z[i+1];
85528
+ }
85529
+ }
85530
+ assert( j<=n/2 );
85531
+ zCopy[j] = 0;
85532
+ rc = sqlite3AtoF(zCopy, &val);
85533
+ if( i<n ) rc = -100;
85534
+ sqlite3DbFree(pMem->db, zCopy);
85535
+ }
85536
+ }
85537
+ if( pRC ) *pRC = rc;
85538
+ return val;
85539
+}
8548485540
8548585541
/*
8548685542
** Return the best representation of pMem that we can get into a
8548785543
** double. If pMem is already a double or an integer, return its
8548885544
** value. If it is a string or blob, try to convert it to a double.
8548985545
** If it is a NULL, return 0.0.
8549085546
*/
85491
-static SQLITE_NOINLINE double memRealValue(Mem *pMem){
85492
- /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
85493
- double val = (double)0;
85494
- sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
85495
- return val;
85496
-}
8549785547
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
8549885548
assert( pMem!=0 );
8549985549
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
8550085550
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
8550185551
if( pMem->flags & MEM_Real ){
@@ -85502,11 +85552,11 @@
8550285552
return pMem->u.r;
8550385553
}else if( pMem->flags & (MEM_Int|MEM_IntReal) ){
8550485554
testcase( pMem->flags & MEM_IntReal );
8550585555
return (double)pMem->u.i;
8550685556
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
85507
- return memRealValue(pMem);
85557
+ return sqlite3MemRealValueRC(pMem, 0);
8550885558
}else{
8550985559
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
8551085560
return (double)0;
8551185561
}
8551285562
}
@@ -85626,11 +85676,11 @@
8562685676
if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){
8562785677
int rc;
8562885678
sqlite3_int64 ix;
8562985679
assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
8563085680
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
85631
- rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
85681
+ pMem->u.r = sqlite3MemRealValueRC(pMem, &rc);
8563285682
if( ((rc==0 || rc==1) && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1)
8563385683
|| sqlite3RealSameAsInt(pMem->u.r, (ix = sqlite3RealToI64(pMem->u.r)))
8563485684
){
8563585685
pMem->u.i = ix;
8563685686
MemSetTypeFlag(pMem, MEM_Int);
@@ -86597,11 +86647,11 @@
8659786647
}
8659886648
}
8659986649
if( affinity==SQLITE_AFF_BLOB ){
8660086650
if( op==TK_FLOAT ){
8660186651
assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) );
86602
- sqlite3AtoF(pVal->z, &pVal->u.r, pVal->n, SQLITE_UTF8);
86652
+ sqlite3AtoF(pVal->z, &pVal->u.r);
8660386653
pVal->flags = MEM_Real;
8660486654
}else if( op==TK_INTEGER ){
8660586655
/* This case is required by -9223372036854775808 and other strings
8660686656
** that look like integers but cannot be handled by the
8660786657
** sqlite3DecOrHexToI64() call above. */
@@ -95843,14 +95893,13 @@
9584395893
** point or exponential notation, the result is only MEM_Real, even
9584495894
** if there is an exact integer representation of the quantity.
9584595895
*/
9584695896
static void applyNumericAffinity(Mem *pRec, int bTryForInt){
9584795897
double rValue;
95848
- u8 enc = pRec->enc;
9584995898
int rc;
9585095899
assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str );
95851
- rc = sqlite3AtoF(pRec->z, &rValue, pRec->n, enc);
95900
+ rValue = sqlite3MemRealValueRC(pRec, &rc);
9585295901
if( rc<=0 ) return;
9585395902
if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){
9585495903
pRec->flags |= MEM_Int;
9585595904
}else{
9585695905
pRec->u.r = rValue;
@@ -95928,11 +95977,14 @@
9592895977
*/
9592995978
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
9593095979
int eType = sqlite3_value_type(pVal);
9593195980
if( eType==SQLITE_TEXT ){
9593295981
Mem *pMem = (Mem*)pVal;
95982
+ assert( pMem->db!=0 );
95983
+ sqlite3_mutex_enter(pMem->db->mutex);
9593395984
applyNumericAffinity(pMem, 0);
95985
+ sqlite3_mutex_leave(pMem->db->mutex);
9593495986
eType = sqlite3_value_type(pVal);
9593595987
}
9593695988
return eType;
9593795989
}
9593895990
@@ -95961,11 +96013,11 @@
9596196013
assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
9596296014
if( ExpandBlob(pMem) ){
9596396015
pMem->u.i = 0;
9596496016
return MEM_Int;
9596596017
}
95966
- rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
96018
+ pMem->u.r = sqlite3MemRealValueRC(pMem, &rc);
9596796019
if( rc<=0 ){
9596896020
if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){
9596996021
pMem->u.i = ix;
9597096022
return MEM_Int;
9597196023
}else{
@@ -110238,11 +110290,11 @@
110238110290
*/
110239110291
static int exprProbability(Expr *p){
110240110292
double r = -1.0;
110241110293
if( p->op!=TK_FLOAT ) return -1;
110242110294
assert( !ExprHasProperty(p, EP_IntValue) );
110243
- sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);
110295
+ sqlite3AtoF(p->u.zToken, &r);
110244110296
assert( r>=0.0 );
110245110297
if( r>1.0 ) return -1;
110246110298
return (int)(r*134217728.0);
110247110299
}
110248110300
@@ -111374,10 +111426,18 @@
111374111426
** number of expressions in the select list. */
111375111427
if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
111376111428
sqlite3SelectWrongNumTermsError(pParse, p->pNext);
111377111429
return WRC_Abort;
111378111430
}
111431
+
111432
+ /* If the SELECT statement contains ON clauses that were moved into
111433
+ ** the WHERE clause, go through and verify that none of the terms
111434
+ ** in the ON clauses reference tables to the right of the ON clause. */
111435
+ if( (p->selFlags & SF_OnToWhere) ){
111436
+ sqlite3SelectCheckOnClauses(pParse, p);
111437
+ if( pParse->nErr ) return WRC_Abort;
111438
+ }
111379111439
111380111440
/* Advance to the next term of the compound
111381111441
*/
111382111442
p = p->pPrior;
111383111443
nCompound++;
@@ -115919,11 +115979,11 @@
115919115979
** like the continuation of the number.
115920115980
*/
115921115981
static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
115922115982
if( ALWAYS(z!=0) ){
115923115983
double value;
115924
- sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);
115984
+ sqlite3AtoF(z, &value);
115925115985
assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */
115926115986
if( negateFlag ) value = -value;
115927115987
sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);
115928115988
}
115929115989
}
@@ -125769,10 +125829,11 @@
125769125829
SrcItem *p
125770125830
){
125771125831
const char *zDb;
125772125832
if( p->fg.fixedSchema ){
125773125833
int iDb = sqlite3SchemaToIndex(pParse->db, p->u4.pSchema);
125834
+ assert( iDb>=0 && iDb<pParse->db->nDb );
125774125835
zDb = pParse->db->aDb[iDb].zDbSName;
125775125836
}else{
125776125837
assert( !p->fg.isSubquery );
125777125838
zDb = p->u4.zDatabase;
125778125839
}
@@ -128013,10 +128074,11 @@
128013128074
}
128014128075
p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
128015128076
convertToWithoutRowidTable(pParse, p);
128016128077
}
128017128078
iDb = sqlite3SchemaToIndex(db, p->pSchema);
128079
+ assert( iDb>=0 && iDb<=db->nDb );
128018128080
128019128081
#ifndef SQLITE_OMIT_CHECK
128020128082
/* Resolve names in all CHECK constraint expressions.
128021128083
*/
128022128084
if( p->pCheck ){
@@ -128308,10 +128370,11 @@
128308128370
p->tabFlags |= TF_NoVisibleRowid; /* Never allow rowid in view */
128309128371
#endif
128310128372
128311128373
sqlite3TwoPartName(pParse, pName1, pName2, &pName);
128312128374
iDb = sqlite3SchemaToIndex(db, p->pSchema);
128375
+ assert( iDb>=0 && iDb<db->nDb );
128313128376
sqlite3FixInit(&sFix, pParse, iDb, "view", pName);
128314128377
if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;
128315128378
128316128379
/* Make a copy of the entire SELECT statement that defines the view.
128317128380
** This will force all the Expr.token.z values to be dynamically
@@ -133151,11 +133214,11 @@
133151133214
zBuf = sqlite3_mprintf("%!.*f",(int)n,r);
133152133215
if( zBuf==0 ){
133153133216
sqlite3_result_error_nomem(context);
133154133217
return;
133155133218
}
133156
- sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
133219
+ sqlite3AtoF(zBuf, &r);
133157133220
sqlite3_free(zBuf);
133158133221
}
133159133222
sqlite3_result_double(context, r);
133160133223
}
133161133224
#endif
@@ -133789,11 +133852,11 @@
133789133852
const char *zVal;
133790133853
r1 = sqlite3_value_double(pValue);
133791133854
sqlite3_str_appendf(pStr, "%!0.15g", r1);
133792133855
zVal = sqlite3_str_value(pStr);
133793133856
if( zVal ){
133794
- sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
133857
+ sqlite3AtoF(zVal, &r2);
133795133858
if( r1!=r2 ){
133796133859
sqlite3_str_reset(pStr);
133797133860
sqlite3_str_appendf(pStr, "%!0.20e", r1);
133798133861
}
133799133862
}
@@ -155216,11 +155279,11 @@
155216155279
155217155280
/*
155218155281
** Check all ON clauses in pSelect to verify that they do not reference
155219155282
** columns to the right.
155220155283
*/
155221
-static void selectCheckOnClauses(Parse *pParse, Select *pSelect){
155284
+SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect){
155222155285
Walker w;
155223155286
CheckOnCtx sCtx;
155224155287
int ii;
155225155288
assert( pSelect->selFlags & SF_OnToWhere );
155226155289
assert( pSelect->pSrc!=0 && pSelect->pSrc->nSrc>=2 );
@@ -155396,22 +155459,10 @@
155396155459
TREETRACE(0x10,pParse,p, ("after name resolution:\n"));
155397155460
sqlite3TreeViewSelect(0, p, 0);
155398155461
}
155399155462
#endif
155400155463
155401
- /* If the SELECT statement contains ON clauses that were moved into
155402
- ** the WHERE clause, go through and verify that none of the terms
155403
- ** in the ON clauses reference tables to the right of the ON clause.
155404
- ** Do this now, after name resolution, but before query flattening
155405
- */
155406
- if( p->selFlags & SF_OnToWhere ){
155407
- selectCheckOnClauses(pParse, p);
155408
- if( pParse->nErr ){
155409
- goto select_end;
155410
- }
155411
- }
155412
-
155413155464
/* If the SF_UFSrcCheck flag is set, then this function is being called
155414155465
** as part of populating the temp table for an UPDATE...FROM statement.
155415155466
** In this case, it is an error if the target object (pSrc->a[0]) name
155416155467
** or alias is duplicated within FROM clause (pSrc->a[1..n]).
155417155468
**
@@ -165902,17 +165953,18 @@
165902165953
&& ALWAYS(pLeft->y.pTab)
165903165954
&& IsVirtual(pLeft->y.pTab)) /* Might be numeric */
165904165955
){
165905165956
int isNum;
165906165957
double rDummy;
165907
- isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8);
165958
+ assert( zNew[iTo]==0 );
165959
+ isNum = sqlite3AtoF(zNew, &rDummy);
165908165960
if( isNum<=0 ){
165909165961
if( iTo==1 && zNew[0]=='-' ){
165910165962
isNum = +1;
165911165963
}else{
165912165964
zNew[iTo-1]++;
165913
- isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8);
165965
+ isNum = sqlite3AtoF(zNew, &rDummy);
165914165966
zNew[iTo-1]--;
165915165967
}
165916165968
}
165917165969
if( isNum>0 ){
165918165970
sqlite3ExprDelete(db, pPrefix);
@@ -214611,11 +214663,11 @@
214611214663
char *z;
214612214664
if( sz==0 ) goto returnfromblob_malformed;
214613214665
to_double:
214614214666
z = sqlite3DbStrNDup(db, (const char*)&pParse->aBlob[i+n], (int)sz);
214615214667
if( z==0 ) goto returnfromblob_oom;
214616
- rc = sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8);
214668
+ rc = sqlite3AtoF(z, &r);
214617214669
sqlite3DbFree(db, z);
214618214670
if( rc<=0 ) goto returnfromblob_malformed;
214619214671
sqlite3_result_double(pCtx, r);
214620214672
break;
214621214673
}
@@ -221490,11 +221542,11 @@
221490221542
if( pVal ){
221491221543
#ifdef SQLITE_AMALGAMATION
221492221544
/* The sqlite3AtoF() routine is much much faster than atof(), if it
221493221545
** is available */
221494221546
double r;
221495
- (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8);
221547
+ (void)sqlite3AtoF((const char*)p->z, &r);
221496221548
*pVal = r;
221497221549
#else
221498221550
*pVal = (GeoCoord)atof((const char*)p->z);
221499221551
#endif
221500221552
}
@@ -261698,11 +261750,11 @@
261698261750
int nArg, /* Number of args */
261699261751
sqlite3_value **apUnused /* Function arguments */
261700261752
){
261701261753
assert( nArg==0 );
261702261754
UNUSED_PARAM2(nArg, apUnused);
261703
- sqlite3_result_text(pCtx, "fts5: 2026-02-13 16:02:27 d62999907d5f5987fe0030e1a4a7144c898e55595ac116eec966741a5099322b", -1, SQLITE_TRANSIENT);
261755
+ sqlite3_result_text(pCtx, "fts5: 2026-02-17 01:04:23 dd5af703e1082951a4295a3453611db12b23cfbcfee4258ec3985abe96ab54ba", -1, SQLITE_TRANSIENT);
261704261756
}
261705261757
261706261758
/*
261707261759
** Implementation of fts5_locale(LOCALE, TEXT) function.
261708261760
**
261709261761
--- 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 ** b5ebbd004183f81902fa79a143222204b33d with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2026-02-16 11:14:59 b5ebbd004183f81902fa79a143222204b33dbe1cacb918194556b8dac67bd567"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-02-16T11:14:59.370Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -21804,10 +21804,11 @@
21804 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
21805 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
21806 Expr*,ExprList*,u32,Expr*);
21807 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
21808 SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3*,void*);
 
21809 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
21810 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*);
21811 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
21812 #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
21813 SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -22025,11 +22026,11 @@
22025 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
22026
22027 SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
22028 SQLITE_PRIVATE i64 sqlite3RealToI64(double);
22029 SQLITE_PRIVATE int sqlite3Int64ToText(i64,char*);
22030 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
22031 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
22032 SQLITE_PRIVATE int sqlite3GetUInt32(const char*, u32*);
22033 SQLITE_PRIVATE int sqlite3Atoi(const char*);
22034 #ifndef SQLITE_OMIT_UTF16
22035 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nByte, int nChar);
@@ -24609,17 +24610,18 @@
24609 #endif
24610 #ifdef SQLITE_DEBUG
24611 SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
24612 #endif
24613 SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
24614 SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem*);
24615 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
24616 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
24617 SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
24618 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*);
24619 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
24620 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
 
24621 SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
24622 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
24623 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
24624 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
24625 SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
@@ -25575,11 +25577,11 @@
25575 return 0;
25576 }else if( parseHhMmSs(zDate, p)==0 ){
25577 return 0;
25578 }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
25579 return setDateTimeToCurrent(context, p);
25580 }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){
25581 setRawDateNumber(p, r);
25582 return 0;
25583 }else if( (sqlite3StrICmp(zDate,"subsec")==0
25584 || sqlite3StrICmp(zDate,"subsecond")==0)
25585 && sqlite3NotPureFunc(context) ){
@@ -26021,11 +26023,11 @@
26021 ** Move the date to the same time on the next occurrence of
26022 ** weekday N where 0==Sunday, 1==Monday, and so forth. If the
26023 ** date is already on the appropriate weekday, this is a no-op.
26024 */
26025 if( sqlite3_strnicmp(z, "weekday ", 8)==0
26026 && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)>0
26027 && r>=0.0 && r<7.0 && (n=(int)r)==r ){
26028 sqlite3_int64 Z;
26029 computeYMD_HMS(p);
26030 p->tz = 0;
26031 p->validJD = 0;
@@ -26092,23 +26094,29 @@
26092 case '6':
26093 case '7':
26094 case '8':
26095 case '9': {
26096 double rRounder;
26097 int i;
26098 int Y,M,D,h,m,x;
26099 const char *z2 = z;
 
 
26100 char z0 = z[0];
26101 for(n=1; z[n]; n++){
26102 if( z[n]==':' ) break;
26103 if( sqlite3Isspace(z[n]) ) break;
26104 if( z[n]=='-' ){
26105 if( n==5 && getDigits(&z[1], "40f", &Y)==1 ) break;
26106 if( n==6 && getDigits(&z[1], "50f", &Y)==1 ) break;
26107 }
26108 }
26109 if( sqlite3AtoF(z, &r, n, SQLITE_UTF8)<=0 ){
 
 
 
 
26110 assert( rc==1 );
26111 break;
26112 }
26113 if( z[n]=='-' ){
26114 /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the
@@ -36705,12 +36713,11 @@
36705
36706 /*
36707 ** The string z[] is an text representation of a real number.
36708 ** Convert this string to a double and write it into *pResult.
36709 **
36710 ** The string z[] is length bytes in length (bytes, not characters) and
36711 ** uses the encoding enc. The string is not necessarily zero-terminated.
36712 **
36713 ** Return TRUE if the result is a valid real number (or integer) and FALSE
36714 ** if the string is empty or contains extraneous text. More specifically
36715 ** return
36716 ** 1 => The input string is a pure integer
@@ -36733,144 +36740,134 @@
36733 ** into *pResult.
36734 */
36735 #if defined(_MSC_VER)
36736 #pragma warning(disable : 4756)
36737 #endif
36738 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
36739 #ifndef SQLITE_OMIT_FLOATING_POINT
36740 int incr;
36741 const char *zEnd;
36742 /* sign * significand * (10 ^ (esign * exponent)) */
36743 int sign = 1; /* sign of significand */
36744 u64 s = 0; /* significand */
36745 int d = 0; /* adjust exponent for shifting decimal point */
36746 int esign = 1; /* sign of exponent */
36747 int e = 0; /* exponent */
36748 int eValid = 1; /* True exponent is either not used or is well-formed */
36749 int nDigit = 0; /* Number of digits processed */
36750 int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
36751
36752 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
36753 *pResult = 0.0; /* Default return value, in case of an error */
36754 if( length==0 ) return 0;
36755
36756 if( enc==SQLITE_UTF8 ){
36757 incr = 1;
36758 zEnd = z + length;
36759 }else{
36760 int i;
36761 incr = 2;
36762 length &= ~1;
36763 assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
36764 testcase( enc==SQLITE_UTF16LE );
36765 testcase( enc==SQLITE_UTF16BE );
36766 for(i=3-enc; i<length && z[i]==0; i+=2){}
36767 if( i<length ) eType = -100;
36768 zEnd = &z[i^1];
36769 z += (enc&1);
36770 }
36771
36772 /* skip leading spaces */
36773 while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
36774 if( z>=zEnd ) return 0;
36775
36776 /* get sign of significand */
36777 if( *z=='-' ){
36778 sign = -1;
36779 z+=incr;
36780 }else if( *z=='+' ){
36781 z+=incr;
36782 }
36783
36784 /* copy max significant digits to significand */
36785 while( z<zEnd && sqlite3Isdigit(*z) ){
36786 s = s*10 + (*z - '0');
36787 z+=incr; nDigit++;
36788 if( s>=((LARGEST_INT64-9)/10) ){
36789 /* skip non-significant significand digits
36790 ** (increase exponent by d to shift decimal left) */
36791 while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; }
36792 }
36793 }
36794 if( z>=zEnd ) goto do_atof_calc;
36795
36796 /* if decimal point is present */
36797 if( *z=='.' ){
36798 z+=incr;
36799 eType++;
36800 /* copy digits from after decimal to significand
36801 ** (decrease exponent by d to shift decimal right) */
36802 while( z<zEnd && sqlite3Isdigit(*z) ){
36803 if( s<((LARGEST_INT64-9)/10) ){
36804 s = s*10 + (*z - '0');
36805 d--;
36806 nDigit++;
36807 }
36808 z+=incr;
36809 }
36810 }
36811 if( z>=zEnd ) goto do_atof_calc;
36812
36813 /* if exponent is present */
36814 if( *z=='e' || *z=='E' ){
36815 z+=incr;
36816 eValid = 0;
36817 eType++;
36818
36819 /* This branch is needed to avoid a (harmless) buffer overread. The
36820 ** special comment alerts the mutation tester that the correct answer
36821 ** is obtained even if the branch is omitted */
36822 if( z>=zEnd ) goto do_atof_calc; /*PREVENTS-HARMLESS-OVERREAD*/
36823
36824 /* get sign of exponent */
36825 if( *z=='-' ){
36826 esign = -1;
36827 z+=incr;
36828 }else if( *z=='+' ){
36829 z+=incr;
36830 }
36831 /* copy digits to exponent */
36832 while( z<zEnd && sqlite3Isdigit(*z) ){
36833 e = e<10000 ? (e*10 + (*z - '0')) : 10000;
36834 z+=incr;
36835 eValid = 1;
 
 
 
 
 
 
36836 }
36837 }
36838
36839 /* skip trailing spaces */
36840 while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
36841
36842 do_atof_calc:
36843 /* Zero is a special case */
36844 if( s==0 ){
36845 *pResult = sign<0 ? -0.0 : +0.0;
36846 goto atof_return;
 
 
 
36847 }
36848
36849 /* adjust exponent by d, and update sign */
36850 e = (e*esign) + d;
36851
36852 *pResult = sqlite3Fp10Convert2(s,e);
36853 if( sign<0 ) *pResult = -*pResult;
36854 assert( !sqlite3IsNaN(*pResult) );
36855
36856 atof_return:
36857 /* return true if number and no extra non-whitespace characters after */
36858 if( z==zEnd && nDigit>0 && eValid && eType>0 ){
36859 return eType;
36860 }else if( eType>=2 && (eType==3 || eValid) && nDigit>0 ){
36861 return -1;
36862 }else{
36863 return 0;
36864 }
36865 #else
36866 return !sqlite3Atoi64(z, pResult, length, enc);
36867 #endif /* SQLITE_OMIT_FLOATING_POINT */
36868 }
36869 #if defined(_MSC_VER)
36870 #pragma warning(default : 4756)
36871 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36872
36873 /*
36874 ** Render an signed 64-bit integer as text. Store the result in zOut[] and
36875 ** return the length of the string that was stored, in bytes. The value
36876 ** returned does not include the zero terminator at the end of the output
@@ -36879,27 +36876,39 @@
36879 ** The caller must ensure that zOut[] is at least 21 bytes in size.
36880 */
36881 SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
36882 int i;
36883 u64 x;
36884 char zTemp[22];
36885 if( v<0 ){
36886 x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
36887 }else{
 
36888 x = v;
36889 }
36890 i = sizeof(zTemp)-2;
36891 zTemp[sizeof(zTemp)-1] = 0;
36892 while( 1 /*exit-by-break*/ ){
36893 zTemp[i] = (x%10) + '0';
36894 x = x/10;
36895 if( x==0 ) break;
36896 i--;
36897 };
36898 if( v<0 ) zTemp[--i] = '-';
36899 memcpy(zOut, &zTemp[i], sizeof(zTemp)-i);
36900 return sizeof(zTemp)-1-i;
 
 
 
 
 
 
 
 
 
 
 
36901 }
36902
36903 /*
36904 ** Compare the 19-character string zNum against the text representation
36905 ** value 2^63: 9223372036854775808. Return negative, zero, or positive
@@ -37210,29 +37219,14 @@
37210
37211 /* Extract significant digits. */
37212 i = sizeof(p->zBuf)-1;
37213 assert( v>0 );
37214 while( v>=10 ){
37215 static const union {
37216 char a[200];
37217 short int forAlignment;
37218 } dig = {
37219 "00010203040506070809"
37220 "10111213141516171819"
37221 "20212223242526272829"
37222 "30313233343536373839"
37223 "40414243444546474849"
37224 "50515253545556575859"
37225 "60616263646566676869"
37226 "70717273747576777879"
37227 "80818283848586878889"
37228 "90919293949596979899"
37229 };
37230 int kk = (v%100)*2;
37231 assert( TWO_BYTE_ALIGNMENT(&dig.a[kk]) );
37232 assert( TWO_BYTE_ALIGNMENT(&p->zBuf[i-1]) );
37233 *(u16*)(&p->zBuf[i-1]) = *(u16*)&dig.a[kk];
37234 i -= 2;
37235 v /= 100;
37236 }
37237 if( v ){
37238 assert( v<10 );
@@ -85157,36 +85151,40 @@
85157 ** If pMem is already a string, detect if it is a zero-terminated
85158 ** string, or make it into one if possible, and mark it as such.
85159 **
85160 ** This is an optimization. Correct operation continues even if
85161 ** this routine is a no-op.
 
 
 
85162 */
85163 SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){
85164 if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){
85165 /* pMem must be a string, and it cannot be an ephemeral or static string */
85166 return;
85167 }
85168 if( pMem->enc!=SQLITE_UTF8 ) return;
85169 assert( pMem->z!=0 );
85170 if( pMem->flags & MEM_Dyn ){
85171 if( pMem->xDel==sqlite3_free
85172 && sqlite3_msize(pMem->z) >= (u64)(pMem->n+1)
85173 ){
85174 pMem->z[pMem->n] = 0;
85175 pMem->flags |= MEM_Term;
85176 return;
85177 }
85178 if( pMem->xDel==sqlite3RCStrUnref ){
85179 /* Blindly assume that all RCStr objects are zero-terminated */
85180 pMem->flags |= MEM_Term;
85181 return;
85182 }
85183 }else if( pMem->szMalloc >= pMem->n+1 ){
85184 pMem->z[pMem->n] = 0;
85185 pMem->flags |= MEM_Term;
85186 return;
85187 }
 
85188 }
85189
85190 /*
85191 ** It is already known that pMem contains an unterminated string.
85192 ** Add the zero terminator.
@@ -85479,23 +85477,75 @@
85479 return memIntValue(pMem);
85480 }else{
85481 return 0;
85482 }
85483 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85484
85485 /*
85486 ** Return the best representation of pMem that we can get into a
85487 ** double. If pMem is already a double or an integer, return its
85488 ** value. If it is a string or blob, try to convert it to a double.
85489 ** If it is a NULL, return 0.0.
85490 */
85491 static SQLITE_NOINLINE double memRealValue(Mem *pMem){
85492 /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
85493 double val = (double)0;
85494 sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
85495 return val;
85496 }
85497 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
85498 assert( pMem!=0 );
85499 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
85500 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
85501 if( pMem->flags & MEM_Real ){
@@ -85502,11 +85552,11 @@
85502 return pMem->u.r;
85503 }else if( pMem->flags & (MEM_Int|MEM_IntReal) ){
85504 testcase( pMem->flags & MEM_IntReal );
85505 return (double)pMem->u.i;
85506 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
85507 return memRealValue(pMem);
85508 }else{
85509 /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
85510 return (double)0;
85511 }
85512 }
@@ -85626,11 +85676,11 @@
85626 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){
85627 int rc;
85628 sqlite3_int64 ix;
85629 assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
85630 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
85631 rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
85632 if( ((rc==0 || rc==1) && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1)
85633 || sqlite3RealSameAsInt(pMem->u.r, (ix = sqlite3RealToI64(pMem->u.r)))
85634 ){
85635 pMem->u.i = ix;
85636 MemSetTypeFlag(pMem, MEM_Int);
@@ -86597,11 +86647,11 @@
86597 }
86598 }
86599 if( affinity==SQLITE_AFF_BLOB ){
86600 if( op==TK_FLOAT ){
86601 assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) );
86602 sqlite3AtoF(pVal->z, &pVal->u.r, pVal->n, SQLITE_UTF8);
86603 pVal->flags = MEM_Real;
86604 }else if( op==TK_INTEGER ){
86605 /* This case is required by -9223372036854775808 and other strings
86606 ** that look like integers but cannot be handled by the
86607 ** sqlite3DecOrHexToI64() call above. */
@@ -95843,14 +95893,13 @@
95843 ** point or exponential notation, the result is only MEM_Real, even
95844 ** if there is an exact integer representation of the quantity.
95845 */
95846 static void applyNumericAffinity(Mem *pRec, int bTryForInt){
95847 double rValue;
95848 u8 enc = pRec->enc;
95849 int rc;
95850 assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str );
95851 rc = sqlite3AtoF(pRec->z, &rValue, pRec->n, enc);
95852 if( rc<=0 ) return;
95853 if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){
95854 pRec->flags |= MEM_Int;
95855 }else{
95856 pRec->u.r = rValue;
@@ -95928,11 +95977,14 @@
95928 */
95929 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
95930 int eType = sqlite3_value_type(pVal);
95931 if( eType==SQLITE_TEXT ){
95932 Mem *pMem = (Mem*)pVal;
 
 
95933 applyNumericAffinity(pMem, 0);
 
95934 eType = sqlite3_value_type(pVal);
95935 }
95936 return eType;
95937 }
95938
@@ -95961,11 +96013,11 @@
95961 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
95962 if( ExpandBlob(pMem) ){
95963 pMem->u.i = 0;
95964 return MEM_Int;
95965 }
95966 rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
95967 if( rc<=0 ){
95968 if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){
95969 pMem->u.i = ix;
95970 return MEM_Int;
95971 }else{
@@ -110238,11 +110290,11 @@
110238 */
110239 static int exprProbability(Expr *p){
110240 double r = -1.0;
110241 if( p->op!=TK_FLOAT ) return -1;
110242 assert( !ExprHasProperty(p, EP_IntValue) );
110243 sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);
110244 assert( r>=0.0 );
110245 if( r>1.0 ) return -1;
110246 return (int)(r*134217728.0);
110247 }
110248
@@ -111374,10 +111426,18 @@
111374 ** number of expressions in the select list. */
111375 if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
111376 sqlite3SelectWrongNumTermsError(pParse, p->pNext);
111377 return WRC_Abort;
111378 }
 
 
 
 
 
 
 
 
111379
111380 /* Advance to the next term of the compound
111381 */
111382 p = p->pPrior;
111383 nCompound++;
@@ -115919,11 +115979,11 @@
115919 ** like the continuation of the number.
115920 */
115921 static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
115922 if( ALWAYS(z!=0) ){
115923 double value;
115924 sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);
115925 assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */
115926 if( negateFlag ) value = -value;
115927 sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);
115928 }
115929 }
@@ -125769,10 +125829,11 @@
125769 SrcItem *p
125770 ){
125771 const char *zDb;
125772 if( p->fg.fixedSchema ){
125773 int iDb = sqlite3SchemaToIndex(pParse->db, p->u4.pSchema);
 
125774 zDb = pParse->db->aDb[iDb].zDbSName;
125775 }else{
125776 assert( !p->fg.isSubquery );
125777 zDb = p->u4.zDatabase;
125778 }
@@ -128013,10 +128074,11 @@
128013 }
128014 p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
128015 convertToWithoutRowidTable(pParse, p);
128016 }
128017 iDb = sqlite3SchemaToIndex(db, p->pSchema);
 
128018
128019 #ifndef SQLITE_OMIT_CHECK
128020 /* Resolve names in all CHECK constraint expressions.
128021 */
128022 if( p->pCheck ){
@@ -128308,10 +128370,11 @@
128308 p->tabFlags |= TF_NoVisibleRowid; /* Never allow rowid in view */
128309 #endif
128310
128311 sqlite3TwoPartName(pParse, pName1, pName2, &pName);
128312 iDb = sqlite3SchemaToIndex(db, p->pSchema);
 
128313 sqlite3FixInit(&sFix, pParse, iDb, "view", pName);
128314 if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;
128315
128316 /* Make a copy of the entire SELECT statement that defines the view.
128317 ** This will force all the Expr.token.z values to be dynamically
@@ -133151,11 +133214,11 @@
133151 zBuf = sqlite3_mprintf("%!.*f",(int)n,r);
133152 if( zBuf==0 ){
133153 sqlite3_result_error_nomem(context);
133154 return;
133155 }
133156 sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
133157 sqlite3_free(zBuf);
133158 }
133159 sqlite3_result_double(context, r);
133160 }
133161 #endif
@@ -133789,11 +133852,11 @@
133789 const char *zVal;
133790 r1 = sqlite3_value_double(pValue);
133791 sqlite3_str_appendf(pStr, "%!0.15g", r1);
133792 zVal = sqlite3_str_value(pStr);
133793 if( zVal ){
133794 sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
133795 if( r1!=r2 ){
133796 sqlite3_str_reset(pStr);
133797 sqlite3_str_appendf(pStr, "%!0.20e", r1);
133798 }
133799 }
@@ -155216,11 +155279,11 @@
155216
155217 /*
155218 ** Check all ON clauses in pSelect to verify that they do not reference
155219 ** columns to the right.
155220 */
155221 static void selectCheckOnClauses(Parse *pParse, Select *pSelect){
155222 Walker w;
155223 CheckOnCtx sCtx;
155224 int ii;
155225 assert( pSelect->selFlags & SF_OnToWhere );
155226 assert( pSelect->pSrc!=0 && pSelect->pSrc->nSrc>=2 );
@@ -155396,22 +155459,10 @@
155396 TREETRACE(0x10,pParse,p, ("after name resolution:\n"));
155397 sqlite3TreeViewSelect(0, p, 0);
155398 }
155399 #endif
155400
155401 /* If the SELECT statement contains ON clauses that were moved into
155402 ** the WHERE clause, go through and verify that none of the terms
155403 ** in the ON clauses reference tables to the right of the ON clause.
155404 ** Do this now, after name resolution, but before query flattening
155405 */
155406 if( p->selFlags & SF_OnToWhere ){
155407 selectCheckOnClauses(pParse, p);
155408 if( pParse->nErr ){
155409 goto select_end;
155410 }
155411 }
155412
155413 /* If the SF_UFSrcCheck flag is set, then this function is being called
155414 ** as part of populating the temp table for an UPDATE...FROM statement.
155415 ** In this case, it is an error if the target object (pSrc->a[0]) name
155416 ** or alias is duplicated within FROM clause (pSrc->a[1..n]).
155417 **
@@ -165902,17 +165953,18 @@
165902 && ALWAYS(pLeft->y.pTab)
165903 && IsVirtual(pLeft->y.pTab)) /* Might be numeric */
165904 ){
165905 int isNum;
165906 double rDummy;
165907 isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8);
 
165908 if( isNum<=0 ){
165909 if( iTo==1 && zNew[0]=='-' ){
165910 isNum = +1;
165911 }else{
165912 zNew[iTo-1]++;
165913 isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8);
165914 zNew[iTo-1]--;
165915 }
165916 }
165917 if( isNum>0 ){
165918 sqlite3ExprDelete(db, pPrefix);
@@ -214611,11 +214663,11 @@
214611 char *z;
214612 if( sz==0 ) goto returnfromblob_malformed;
214613 to_double:
214614 z = sqlite3DbStrNDup(db, (const char*)&pParse->aBlob[i+n], (int)sz);
214615 if( z==0 ) goto returnfromblob_oom;
214616 rc = sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8);
214617 sqlite3DbFree(db, z);
214618 if( rc<=0 ) goto returnfromblob_malformed;
214619 sqlite3_result_double(pCtx, r);
214620 break;
214621 }
@@ -221490,11 +221542,11 @@
221490 if( pVal ){
221491 #ifdef SQLITE_AMALGAMATION
221492 /* The sqlite3AtoF() routine is much much faster than atof(), if it
221493 ** is available */
221494 double r;
221495 (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8);
221496 *pVal = r;
221497 #else
221498 *pVal = (GeoCoord)atof((const char*)p->z);
221499 #endif
221500 }
@@ -261698,11 +261750,11 @@
261698 int nArg, /* Number of args */
261699 sqlite3_value **apUnused /* Function arguments */
261700 ){
261701 assert( nArg==0 );
261702 UNUSED_PARAM2(nArg, apUnused);
261703 sqlite3_result_text(pCtx, "fts5: 2026-02-13 16:02:27 d62999907d5f5987fe0030e1a4a7144c898e55595ac116eec966741a5099322b", -1, SQLITE_TRANSIENT);
261704 }
261705
261706 /*
261707 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261708 **
261709
--- 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 ** 2610105a439e25c050b2deb32953861187c8 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2026-02-17 11:28:48 2610105a439e25c050b2deb32953861187c81b1d97407f41dc188e6627e0ac4d"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-02-17T11:28:48.505Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -21804,10 +21804,11 @@
21804 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
21805 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
21806 Expr*,ExprList*,u32,Expr*);
21807 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
21808 SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3*,void*);
21809 SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect);
21810 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
21811 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*);
21812 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
21813 #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
21814 SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -22025,11 +22026,11 @@
22026 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
22027
22028 SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
22029 SQLITE_PRIVATE i64 sqlite3RealToI64(double);
22030 SQLITE_PRIVATE int sqlite3Int64ToText(i64,char*);
22031 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*);
22032 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
22033 SQLITE_PRIVATE int sqlite3GetUInt32(const char*, u32*);
22034 SQLITE_PRIVATE int sqlite3Atoi(const char*);
22035 #ifndef SQLITE_OMIT_UTF16
22036 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nByte, int nChar);
@@ -24609,17 +24610,18 @@
24610 #endif
24611 #ifdef SQLITE_DEBUG
24612 SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
24613 #endif
24614 SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
24615 SQLITE_PRIVATE int sqlite3VdbeMemZeroTerminateIfAble(Mem*);
24616 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
24617 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
24618 SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
24619 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*);
24620 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
24621 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
24622 SQLITE_PRIVATE SQLITE_NOINLINE double sqlite3MemRealValueRC(Mem*, int*);
24623 SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
24624 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
24625 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
24626 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
24627 SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
@@ -25575,11 +25577,11 @@
25577 return 0;
25578 }else if( parseHhMmSs(zDate, p)==0 ){
25579 return 0;
25580 }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
25581 return setDateTimeToCurrent(context, p);
25582 }else if( sqlite3AtoF(zDate, &r)>0 ){
25583 setRawDateNumber(p, r);
25584 return 0;
25585 }else if( (sqlite3StrICmp(zDate,"subsec")==0
25586 || sqlite3StrICmp(zDate,"subsecond")==0)
25587 && sqlite3NotPureFunc(context) ){
@@ -26021,11 +26023,11 @@
26023 ** Move the date to the same time on the next occurrence of
26024 ** weekday N where 0==Sunday, 1==Monday, and so forth. If the
26025 ** date is already on the appropriate weekday, this is a no-op.
26026 */
26027 if( sqlite3_strnicmp(z, "weekday ", 8)==0
26028 && sqlite3AtoF(&z[8], &r)>0
26029 && r>=0.0 && r<7.0 && (n=(int)r)==r ){
26030 sqlite3_int64 Z;
26031 computeYMD_HMS(p);
26032 p->tz = 0;
26033 p->validJD = 0;
@@ -26092,23 +26094,29 @@
26094 case '6':
26095 case '7':
26096 case '8':
26097 case '9': {
26098 double rRounder;
26099 int i, rx;
26100 int Y,M,D,h,m,x;
26101 const char *z2 = z;
26102 char *zCopy;
26103 sqlite3 *db = sqlite3_context_db_handle(pCtx);
26104 char z0 = z[0];
26105 for(n=1; z[n]; n++){
26106 if( z[n]==':' ) break;
26107 if( sqlite3Isspace(z[n]) ) break;
26108 if( z[n]=='-' ){
26109 if( n==5 && getDigits(&z[1], "40f", &Y)==1 ) break;
26110 if( n==6 && getDigits(&z[1], "50f", &Y)==1 ) break;
26111 }
26112 }
26113 zCopy = sqlite3DbStrNDup(db, z, n);
26114 if( zCopy==0 ) break;
26115 rx = sqlite3AtoF(zCopy, &r)<=0;
26116 sqlite3DbFree(db, zCopy);
26117 if( rx ){
26118 assert( rc==1 );
26119 break;
26120 }
26121 if( z[n]=='-' ){
26122 /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the
@@ -36705,12 +36713,11 @@
36713
36714 /*
36715 ** The string z[] is an text representation of a real number.
36716 ** Convert this string to a double and write it into *pResult.
36717 **
36718 ** z[] must be UTF-8 and zero-terminated.
 
36719 **
36720 ** Return TRUE if the result is a valid real number (or integer) and FALSE
36721 ** if the string is empty or contains extraneous text. More specifically
36722 ** return
36723 ** 1 => The input string is a pure integer
@@ -36733,144 +36740,134 @@
36740 ** into *pResult.
36741 */
36742 #if defined(_MSC_VER)
36743 #pragma warning(disable : 4756)
36744 #endif
36745 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){
36746 #ifndef SQLITE_OMIT_FLOATING_POINT
 
 
36747 /* sign * significand * (10 ^ (esign * exponent)) */
36748 int neg = 0; /* True for a negative value */
36749 u64 s = 0; /* mantissa */
36750 int d = 0; /* Value is s * pow(10,d) */
 
 
 
36751 int nDigit = 0; /* Number of digits processed */
36752 int eType = 1; /* 1: pure integer, 2+: fractional */
36753
36754 *pResult = 0.0; /* Default return value, in case of an error */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36755
36756 /* skip leading spaces */
36757 while( sqlite3Isspace(*z) ) z++;
 
36758
36759 /* get sign of significand */
36760 if( *z=='-' ){
36761 neg = 1;
36762 z++;
36763 }else if( *z=='+' ){
36764 z++;
36765 }
36766
36767 /* copy max significant digits to significand */
36768 while( sqlite3Isdigit(*z) ){
36769 s = s*10 + (*z - '0');
36770 z++; nDigit++;
36771 if( s>=((LARGEST_INT64-9)/10) ){
36772 /* skip non-significant significand digits
36773 ** (increase exponent by d to shift decimal left) */
36774 while( sqlite3Isdigit(*z) ){ z++; d++; }
36775 }
36776 }
 
36777
36778 /* if decimal point is present */
36779 if( *z=='.' ){
36780 z++;
36781 eType++;
36782 /* copy digits from after decimal to significand
36783 ** (decrease exponent by d to shift decimal right) */
36784 while( sqlite3Isdigit(*z) ){
36785 if( s<((LARGEST_INT64-9)/10) ){
36786 s = s*10 + (*z - '0');
36787 d--;
36788 nDigit++;
36789 }
36790 z++;
36791 }
36792 }
 
36793
36794 /* if exponent is present */
36795 if( *z=='e' || *z=='E' ){
36796 int esign = 1; /* sign of exponent */
36797 z++;
36798 eType++;
36799
 
 
 
 
 
36800 /* get sign of exponent */
36801 if( *z=='-' ){
36802 esign = -1;
36803 z++;
36804 }else if( *z=='+' ){
36805 z++;
36806 }
36807 /* copy digits to exponent */
36808 if( sqlite3Isdigit(*z) ){
36809 int exp = *z - '0';
36810 z++;
36811 while( sqlite3Isdigit(*z) ){
36812 exp = exp<10000 ? (exp*10 + (*z - '0')) : 10000;
36813 z++;
36814 }
36815 d += esign*exp;
36816 }else{
36817 eType = -1;
36818 }
36819 }
36820
36821 /* skip trailing spaces */
36822 while( sqlite3Isspace(*z) ) z++;
36823
 
36824 /* Zero is a special case */
36825 if( s==0 ){
36826 *pResult = neg ? -0.0 : +0.0;
36827 }else{
36828 *pResult = sqlite3Fp10Convert2(s,d);
36829 if( neg ) *pResult = -*pResult;
36830 assert( !sqlite3IsNaN(*pResult) );
36831 }
36832
 
 
 
 
 
 
 
 
36833 /* return true if number and no extra non-whitespace characters after */
36834 if( z[0]==0 && nDigit>0 ){
36835 return eType;
36836 }else if( eType>=2 && nDigit>0 ){
36837 return -1;
36838 }else{
36839 return 0;
36840 }
36841 #else
36842 return !sqlite3Atoi64(z, pResult, strlen(z), SQLITE_UTF8);
36843 #endif /* SQLITE_OMIT_FLOATING_POINT */
36844 }
36845 #if defined(_MSC_VER)
36846 #pragma warning(default : 4756)
36847 #endif
36848
36849 /*
36850 ** Digit pairs used to convert a U64 or I64 into text, two digits
36851 ** at a time.
36852 */
36853 static const union {
36854 char a[200];
36855 short int forceAlignment;
36856 } sqlite3DigitPairs = {
36857 "00010203040506070809"
36858 "10111213141516171819"
36859 "20212223242526272829"
36860 "30313233343536373839"
36861 "40414243444546474849"
36862 "50515253545556575859"
36863 "60616263646566676869"
36864 "70717273747576777879"
36865 "80818283848586878889"
36866 "90919293949596979899"
36867 };
36868
36869
36870 /*
36871 ** Render an signed 64-bit integer as text. Store the result in zOut[] and
36872 ** return the length of the string that was stored, in bytes. The value
36873 ** returned does not include the zero terminator at the end of the output
@@ -36879,27 +36876,39 @@
36876 ** The caller must ensure that zOut[] is at least 21 bytes in size.
36877 */
36878 SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
36879 int i;
36880 u64 x;
36881 union {
36882 char a[23];
36883 u16 forceAlignment;
36884 } u;
36885 if( v>0 ){
36886 x = v;
36887 }else if( v==0 ){
36888 zOut[0] = '0';
36889 zOut[1] = 0;
36890 return 1;
36891 }else{
36892 x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
36893 }
36894 i = sizeof(u.a)-1;
36895 u.a[i] = 0;
36896 while( x>=10 ){
36897 int kk = (x%100)*2;
36898 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
36899 assert( TWO_BYTE_ALIGNMENT(&u.a[i-2]) );
36900 *(u16*)(&u.a[i-2]) = *(u16*)&sqlite3DigitPairs.a[kk];
36901 i -= 2;
36902 x /= 100;
36903 }
36904 if( x ){
36905 u.a[--i] = x + '0';
36906 }
36907 if( v<0 ) u.a[--i] = '-';
36908 memcpy(zOut, &u.a[i], sizeof(u.a)-i);
36909 return sizeof(u.a)-1-i;
36910 }
36911
36912 /*
36913 ** Compare the 19-character string zNum against the text representation
36914 ** value 2^63: 9223372036854775808. Return negative, zero, or positive
@@ -37210,29 +37219,14 @@
37219
37220 /* Extract significant digits. */
37221 i = sizeof(p->zBuf)-1;
37222 assert( v>0 );
37223 while( v>=10 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37224 int kk = (v%100)*2;
37225 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37226 assert( TWO_BYTE_ALIGNMENT(&p->zBuf[i-1]) );
37227 *(u16*)(&p->zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
37228 i -= 2;
37229 v /= 100;
37230 }
37231 if( v ){
37232 assert( v<10 );
@@ -85157,36 +85151,40 @@
85151 ** If pMem is already a string, detect if it is a zero-terminated
85152 ** string, or make it into one if possible, and mark it as such.
85153 **
85154 ** This is an optimization. Correct operation continues even if
85155 ** this routine is a no-op.
85156 **
85157 ** Return true if the strig is zero-terminated after this routine is
85158 ** called and false if it is not.
85159 */
85160 SQLITE_PRIVATE int sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){
85161 if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){
85162 /* pMem must be a string, and it cannot be an ephemeral or static string */
85163 return 0;
85164 }
85165 if( pMem->enc!=SQLITE_UTF8 ) return 0;
85166 assert( pMem->z!=0 );
85167 if( pMem->flags & MEM_Dyn ){
85168 if( pMem->xDel==sqlite3_free
85169 && sqlite3_msize(pMem->z) >= (u64)(pMem->n+1)
85170 ){
85171 pMem->z[pMem->n] = 0;
85172 pMem->flags |= MEM_Term;
85173 return 1;
85174 }
85175 if( pMem->xDel==sqlite3RCStrUnref ){
85176 /* Blindly assume that all RCStr objects are zero-terminated */
85177 pMem->flags |= MEM_Term;
85178 return 1;
85179 }
85180 }else if( pMem->szMalloc >= pMem->n+1 ){
85181 pMem->z[pMem->n] = 0;
85182 pMem->flags |= MEM_Term;
85183 return 1;
85184 }
85185 return 0;
85186 }
85187
85188 /*
85189 ** It is already known that pMem contains an unterminated string.
85190 ** Add the zero terminator.
@@ -85479,23 +85477,75 @@
85477 return memIntValue(pMem);
85478 }else{
85479 return 0;
85480 }
85481 }
85482
85483 /*
85484 ** Invoke sqlite3AtoF() on the text value of pMem and return the
85485 ** double result. If sqlite3AtoF() returns an error code, write
85486 ** that code into *pRC if (*pRC)!=NULL.
85487 **
85488 ** The caller must ensure that pMem->db!=0 and that pMem is in
85489 ** mode MEM_Str or MEM_Blob.
85490 */
85491 SQLITE_PRIVATE SQLITE_NOINLINE double sqlite3MemRealValueRC(Mem *pMem, int *pRC){
85492 double val = (double)0;
85493 int rc = 0;
85494 assert( pMem->db!=0 );
85495 assert( pMem->flags & (MEM_Str|MEM_Blob) );
85496 if( pMem->z==0 ){
85497 /* no-op */
85498 }else if( pMem->enc==SQLITE_UTF8
85499 && ((pMem->flags & MEM_Term)!=0 || sqlite3VdbeMemZeroTerminateIfAble(pMem))
85500 ){
85501 rc = sqlite3AtoF(pMem->z, &val);
85502 }else if( pMem->n==0 ){
85503 /* no-op */
85504 }else if( pMem->enc==SQLITE_UTF8 ){
85505 char *zCopy = sqlite3DbStrNDup(pMem->db, pMem->z, pMem->n);
85506 if( zCopy ){
85507 rc = sqlite3AtoF(zCopy, &val);
85508 sqlite3DbFree(pMem->db, zCopy);
85509 }
85510 }else{
85511 int n, i, j;
85512 char *zCopy;
85513 const char *z;
85514
85515 n = pMem->n & ~1;
85516 zCopy = sqlite3DbMallocRaw(pMem->db, n/2 + 2);
85517 if( zCopy ){
85518 z = pMem->z;
85519 if( pMem->enc==SQLITE_UTF16LE ){
85520 for(i=j=0; i<n-1; i+=2, j++){
85521 zCopy[j] = z[i];
85522 if( z[i+1]!=0 ) break;
85523 }
85524 }else{
85525 for(i=j=0; i<n-1; i+=2, j++){
85526 if( z[i]!=0 ) break;
85527 zCopy[j] = z[i+1];
85528 }
85529 }
85530 assert( j<=n/2 );
85531 zCopy[j] = 0;
85532 rc = sqlite3AtoF(zCopy, &val);
85533 if( i<n ) rc = -100;
85534 sqlite3DbFree(pMem->db, zCopy);
85535 }
85536 }
85537 if( pRC ) *pRC = rc;
85538 return val;
85539 }
85540
85541 /*
85542 ** Return the best representation of pMem that we can get into a
85543 ** double. If pMem is already a double or an integer, return its
85544 ** value. If it is a string or blob, try to convert it to a double.
85545 ** If it is a NULL, return 0.0.
85546 */
 
 
 
 
 
 
85547 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
85548 assert( pMem!=0 );
85549 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
85550 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
85551 if( pMem->flags & MEM_Real ){
@@ -85502,11 +85552,11 @@
85552 return pMem->u.r;
85553 }else if( pMem->flags & (MEM_Int|MEM_IntReal) ){
85554 testcase( pMem->flags & MEM_IntReal );
85555 return (double)pMem->u.i;
85556 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
85557 return sqlite3MemRealValueRC(pMem, 0);
85558 }else{
85559 /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
85560 return (double)0;
85561 }
85562 }
@@ -85626,11 +85676,11 @@
85676 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){
85677 int rc;
85678 sqlite3_int64 ix;
85679 assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
85680 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
85681 pMem->u.r = sqlite3MemRealValueRC(pMem, &rc);
85682 if( ((rc==0 || rc==1) && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1)
85683 || sqlite3RealSameAsInt(pMem->u.r, (ix = sqlite3RealToI64(pMem->u.r)))
85684 ){
85685 pMem->u.i = ix;
85686 MemSetTypeFlag(pMem, MEM_Int);
@@ -86597,11 +86647,11 @@
86647 }
86648 }
86649 if( affinity==SQLITE_AFF_BLOB ){
86650 if( op==TK_FLOAT ){
86651 assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) );
86652 sqlite3AtoF(pVal->z, &pVal->u.r);
86653 pVal->flags = MEM_Real;
86654 }else if( op==TK_INTEGER ){
86655 /* This case is required by -9223372036854775808 and other strings
86656 ** that look like integers but cannot be handled by the
86657 ** sqlite3DecOrHexToI64() call above. */
@@ -95843,14 +95893,13 @@
95893 ** point or exponential notation, the result is only MEM_Real, even
95894 ** if there is an exact integer representation of the quantity.
95895 */
95896 static void applyNumericAffinity(Mem *pRec, int bTryForInt){
95897 double rValue;
 
95898 int rc;
95899 assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str );
95900 rValue = sqlite3MemRealValueRC(pRec, &rc);
95901 if( rc<=0 ) return;
95902 if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){
95903 pRec->flags |= MEM_Int;
95904 }else{
95905 pRec->u.r = rValue;
@@ -95928,11 +95977,14 @@
95977 */
95978 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
95979 int eType = sqlite3_value_type(pVal);
95980 if( eType==SQLITE_TEXT ){
95981 Mem *pMem = (Mem*)pVal;
95982 assert( pMem->db!=0 );
95983 sqlite3_mutex_enter(pMem->db->mutex);
95984 applyNumericAffinity(pMem, 0);
95985 sqlite3_mutex_leave(pMem->db->mutex);
95986 eType = sqlite3_value_type(pVal);
95987 }
95988 return eType;
95989 }
95990
@@ -95961,11 +96013,11 @@
96013 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
96014 if( ExpandBlob(pMem) ){
96015 pMem->u.i = 0;
96016 return MEM_Int;
96017 }
96018 pMem->u.r = sqlite3MemRealValueRC(pMem, &rc);
96019 if( rc<=0 ){
96020 if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){
96021 pMem->u.i = ix;
96022 return MEM_Int;
96023 }else{
@@ -110238,11 +110290,11 @@
110290 */
110291 static int exprProbability(Expr *p){
110292 double r = -1.0;
110293 if( p->op!=TK_FLOAT ) return -1;
110294 assert( !ExprHasProperty(p, EP_IntValue) );
110295 sqlite3AtoF(p->u.zToken, &r);
110296 assert( r>=0.0 );
110297 if( r>1.0 ) return -1;
110298 return (int)(r*134217728.0);
110299 }
110300
@@ -111374,10 +111426,18 @@
111426 ** number of expressions in the select list. */
111427 if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
111428 sqlite3SelectWrongNumTermsError(pParse, p->pNext);
111429 return WRC_Abort;
111430 }
111431
111432 /* If the SELECT statement contains ON clauses that were moved into
111433 ** the WHERE clause, go through and verify that none of the terms
111434 ** in the ON clauses reference tables to the right of the ON clause. */
111435 if( (p->selFlags & SF_OnToWhere) ){
111436 sqlite3SelectCheckOnClauses(pParse, p);
111437 if( pParse->nErr ) return WRC_Abort;
111438 }
111439
111440 /* Advance to the next term of the compound
111441 */
111442 p = p->pPrior;
111443 nCompound++;
@@ -115919,11 +115979,11 @@
115979 ** like the continuation of the number.
115980 */
115981 static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
115982 if( ALWAYS(z!=0) ){
115983 double value;
115984 sqlite3AtoF(z, &value);
115985 assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */
115986 if( negateFlag ) value = -value;
115987 sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);
115988 }
115989 }
@@ -125769,10 +125829,11 @@
125829 SrcItem *p
125830 ){
125831 const char *zDb;
125832 if( p->fg.fixedSchema ){
125833 int iDb = sqlite3SchemaToIndex(pParse->db, p->u4.pSchema);
125834 assert( iDb>=0 && iDb<pParse->db->nDb );
125835 zDb = pParse->db->aDb[iDb].zDbSName;
125836 }else{
125837 assert( !p->fg.isSubquery );
125838 zDb = p->u4.zDatabase;
125839 }
@@ -128013,10 +128074,11 @@
128074 }
128075 p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
128076 convertToWithoutRowidTable(pParse, p);
128077 }
128078 iDb = sqlite3SchemaToIndex(db, p->pSchema);
128079 assert( iDb>=0 && iDb<=db->nDb );
128080
128081 #ifndef SQLITE_OMIT_CHECK
128082 /* Resolve names in all CHECK constraint expressions.
128083 */
128084 if( p->pCheck ){
@@ -128308,10 +128370,11 @@
128370 p->tabFlags |= TF_NoVisibleRowid; /* Never allow rowid in view */
128371 #endif
128372
128373 sqlite3TwoPartName(pParse, pName1, pName2, &pName);
128374 iDb = sqlite3SchemaToIndex(db, p->pSchema);
128375 assert( iDb>=0 && iDb<db->nDb );
128376 sqlite3FixInit(&sFix, pParse, iDb, "view", pName);
128377 if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;
128378
128379 /* Make a copy of the entire SELECT statement that defines the view.
128380 ** This will force all the Expr.token.z values to be dynamically
@@ -133151,11 +133214,11 @@
133214 zBuf = sqlite3_mprintf("%!.*f",(int)n,r);
133215 if( zBuf==0 ){
133216 sqlite3_result_error_nomem(context);
133217 return;
133218 }
133219 sqlite3AtoF(zBuf, &r);
133220 sqlite3_free(zBuf);
133221 }
133222 sqlite3_result_double(context, r);
133223 }
133224 #endif
@@ -133789,11 +133852,11 @@
133852 const char *zVal;
133853 r1 = sqlite3_value_double(pValue);
133854 sqlite3_str_appendf(pStr, "%!0.15g", r1);
133855 zVal = sqlite3_str_value(pStr);
133856 if( zVal ){
133857 sqlite3AtoF(zVal, &r2);
133858 if( r1!=r2 ){
133859 sqlite3_str_reset(pStr);
133860 sqlite3_str_appendf(pStr, "%!0.20e", r1);
133861 }
133862 }
@@ -155216,11 +155279,11 @@
155279
155280 /*
155281 ** Check all ON clauses in pSelect to verify that they do not reference
155282 ** columns to the right.
155283 */
155284 SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect){
155285 Walker w;
155286 CheckOnCtx sCtx;
155287 int ii;
155288 assert( pSelect->selFlags & SF_OnToWhere );
155289 assert( pSelect->pSrc!=0 && pSelect->pSrc->nSrc>=2 );
@@ -155396,22 +155459,10 @@
155459 TREETRACE(0x10,pParse,p, ("after name resolution:\n"));
155460 sqlite3TreeViewSelect(0, p, 0);
155461 }
155462 #endif
155463
 
 
 
 
 
 
 
 
 
 
 
 
155464 /* If the SF_UFSrcCheck flag is set, then this function is being called
155465 ** as part of populating the temp table for an UPDATE...FROM statement.
155466 ** In this case, it is an error if the target object (pSrc->a[0]) name
155467 ** or alias is duplicated within FROM clause (pSrc->a[1..n]).
155468 **
@@ -165902,17 +165953,18 @@
165953 && ALWAYS(pLeft->y.pTab)
165954 && IsVirtual(pLeft->y.pTab)) /* Might be numeric */
165955 ){
165956 int isNum;
165957 double rDummy;
165958 assert( zNew[iTo]==0 );
165959 isNum = sqlite3AtoF(zNew, &rDummy);
165960 if( isNum<=0 ){
165961 if( iTo==1 && zNew[0]=='-' ){
165962 isNum = +1;
165963 }else{
165964 zNew[iTo-1]++;
165965 isNum = sqlite3AtoF(zNew, &rDummy);
165966 zNew[iTo-1]--;
165967 }
165968 }
165969 if( isNum>0 ){
165970 sqlite3ExprDelete(db, pPrefix);
@@ -214611,11 +214663,11 @@
214663 char *z;
214664 if( sz==0 ) goto returnfromblob_malformed;
214665 to_double:
214666 z = sqlite3DbStrNDup(db, (const char*)&pParse->aBlob[i+n], (int)sz);
214667 if( z==0 ) goto returnfromblob_oom;
214668 rc = sqlite3AtoF(z, &r);
214669 sqlite3DbFree(db, z);
214670 if( rc<=0 ) goto returnfromblob_malformed;
214671 sqlite3_result_double(pCtx, r);
214672 break;
214673 }
@@ -221490,11 +221542,11 @@
221542 if( pVal ){
221543 #ifdef SQLITE_AMALGAMATION
221544 /* The sqlite3AtoF() routine is much much faster than atof(), if it
221545 ** is available */
221546 double r;
221547 (void)sqlite3AtoF((const char*)p->z, &r);
221548 *pVal = r;
221549 #else
221550 *pVal = (GeoCoord)atof((const char*)p->z);
221551 #endif
221552 }
@@ -261698,11 +261750,11 @@
261750 int nArg, /* Number of args */
261751 sqlite3_value **apUnused /* Function arguments */
261752 ){
261753 assert( nArg==0 );
261754 UNUSED_PARAM2(nArg, apUnused);
261755 sqlite3_result_text(pCtx, "fts5: 2026-02-17 01:04:23 dd5af703e1082951a4295a3453611db12b23cfbcfee4258ec3985abe96ab54ba", -1, SQLITE_TRANSIENT);
261756 }
261757
261758 /*
261759 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261760 **
261761
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.52.0"
150150
#define SQLITE_VERSION_NUMBER 3052000
151
-#define SQLITE_SOURCE_ID "2026-02-16 11:14:59 b5ebbd004183f81902fa79a143222204b33dbe1cacb918194556b8dac67bd567"
151
+#define SQLITE_SOURCE_ID "2026-02-17 11:28:48 2610105a439e25c050b2deb32953861187c81b1d97407f41dc188e6627e0ac4d"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2026-02-16T11:14:59.370Z"
154
+#define SQLITE_SCM_DATETIME "2026-02-17T11:28:48.505Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
160160
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2026-02-16 11:14:59 b5ebbd004183f81902fa79a143222204b33dbe1cacb918194556b8dac67bd567"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-02-16T11:14:59.370Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
160
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2026-02-17 11:28:48 2610105a439e25c050b2deb32953861187c81b1d97407f41dc188e6627e0ac4d"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-02-17T11:28:48.505Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
160

Keyboard Shortcuts

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