Fossil SCM
Update the built-in SQLite to include the latest enhancements and optimizations.
Commit
b10ff3809e1033e77e530002d6639a857a87639f651733e3aa987fa1b58e6f66
Parent
2e2932f6f384d6f…
2 files changed
+207
-155
+2
-2
+207
-155
| --- extsrc/sqlite3.c | ||
| +++ extsrc/sqlite3.c | ||
| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | -** b5ebbd004183f81902fa79a143222204b33d with changes in files: | |
| 21 | +** 2610105a439e25c050b2deb32953861187c8 with changes in files: | |
| 22 | 22 | ** |
| 23 | 23 | ** |
| 24 | 24 | */ |
| 25 | 25 | #ifndef SQLITE_AMALGAMATION |
| 26 | 26 | #define SQLITE_CORE 1 |
| @@ -467,14 +467,14 @@ | ||
| 467 | 467 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 468 | 468 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 469 | 469 | */ |
| 470 | 470 | #define SQLITE_VERSION "3.52.0" |
| 471 | 471 | #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" | |
| 473 | 473 | #define SQLITE_SCM_BRANCH "trunk" |
| 474 | 474 | #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" | |
| 476 | 476 | |
| 477 | 477 | /* |
| 478 | 478 | ** CAPI3REF: Run-Time Library Version Numbers |
| 479 | 479 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 480 | 480 | ** |
| @@ -21804,10 +21804,11 @@ | ||
| 21804 | 21804 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 21805 | 21805 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 21806 | 21806 | Expr*,ExprList*,u32,Expr*); |
| 21807 | 21807 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 21808 | 21808 | SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3*,void*); |
| 21809 | +SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect); | |
| 21809 | 21810 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 21810 | 21811 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*); |
| 21811 | 21812 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 21812 | 21813 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| 21813 | 21814 | SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*); |
| @@ -22025,11 +22026,11 @@ | ||
| 22025 | 22026 | SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); |
| 22026 | 22027 | |
| 22027 | 22028 | SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64); |
| 22028 | 22029 | SQLITE_PRIVATE i64 sqlite3RealToI64(double); |
| 22029 | 22030 | 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*); | |
| 22031 | 22032 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 22032 | 22033 | SQLITE_PRIVATE int sqlite3GetUInt32(const char*, u32*); |
| 22033 | 22034 | SQLITE_PRIVATE int sqlite3Atoi(const char*); |
| 22034 | 22035 | #ifndef SQLITE_OMIT_UTF16 |
| 22035 | 22036 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nByte, int nChar); |
| @@ -24609,17 +24610,18 @@ | ||
| 24609 | 24610 | #endif |
| 24610 | 24611 | #ifdef SQLITE_DEBUG |
| 24611 | 24612 | SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); |
| 24612 | 24613 | #endif |
| 24613 | 24614 | SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); |
| 24614 | -SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem*); | |
| 24615 | +SQLITE_PRIVATE int sqlite3VdbeMemZeroTerminateIfAble(Mem*); | |
| 24615 | 24616 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| 24616 | 24617 | SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); |
| 24617 | 24618 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double); |
| 24618 | 24619 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*); |
| 24619 | 24620 | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*); |
| 24620 | 24621 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); |
| 24622 | +SQLITE_PRIVATE SQLITE_NOINLINE double sqlite3MemRealValueRC(Mem*, int*); | |
| 24621 | 24623 | SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull); |
| 24622 | 24624 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); |
| 24623 | 24625 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); |
| 24624 | 24626 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
| 24625 | 24627 | SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8); |
| @@ -25575,11 +25577,11 @@ | ||
| 25575 | 25577 | return 0; |
| 25576 | 25578 | }else if( parseHhMmSs(zDate, p)==0 ){ |
| 25577 | 25579 | return 0; |
| 25578 | 25580 | }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){ |
| 25579 | 25581 | return setDateTimeToCurrent(context, p); |
| 25580 | - }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){ | |
| 25582 | + }else if( sqlite3AtoF(zDate, &r)>0 ){ | |
| 25581 | 25583 | setRawDateNumber(p, r); |
| 25582 | 25584 | return 0; |
| 25583 | 25585 | }else if( (sqlite3StrICmp(zDate,"subsec")==0 |
| 25584 | 25586 | || sqlite3StrICmp(zDate,"subsecond")==0) |
| 25585 | 25587 | && sqlite3NotPureFunc(context) ){ |
| @@ -26021,11 +26023,11 @@ | ||
| 26021 | 26023 | ** Move the date to the same time on the next occurrence of |
| 26022 | 26024 | ** weekday N where 0==Sunday, 1==Monday, and so forth. If the |
| 26023 | 26025 | ** date is already on the appropriate weekday, this is a no-op. |
| 26024 | 26026 | */ |
| 26025 | 26027 | if( sqlite3_strnicmp(z, "weekday ", 8)==0 |
| 26026 | - && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)>0 | |
| 26028 | + && sqlite3AtoF(&z[8], &r)>0 | |
| 26027 | 26029 | && r>=0.0 && r<7.0 && (n=(int)r)==r ){ |
| 26028 | 26030 | sqlite3_int64 Z; |
| 26029 | 26031 | computeYMD_HMS(p); |
| 26030 | 26032 | p->tz = 0; |
| 26031 | 26033 | p->validJD = 0; |
| @@ -26092,23 +26094,29 @@ | ||
| 26092 | 26094 | case '6': |
| 26093 | 26095 | case '7': |
| 26094 | 26096 | case '8': |
| 26095 | 26097 | case '9': { |
| 26096 | 26098 | double rRounder; |
| 26097 | - int i; | |
| 26099 | + int i, rx; | |
| 26098 | 26100 | int Y,M,D,h,m,x; |
| 26099 | 26101 | const char *z2 = z; |
| 26102 | + char *zCopy; | |
| 26103 | + sqlite3 *db = sqlite3_context_db_handle(pCtx); | |
| 26100 | 26104 | char z0 = z[0]; |
| 26101 | 26105 | for(n=1; z[n]; n++){ |
| 26102 | 26106 | if( z[n]==':' ) break; |
| 26103 | 26107 | if( sqlite3Isspace(z[n]) ) break; |
| 26104 | 26108 | if( z[n]=='-' ){ |
| 26105 | 26109 | if( n==5 && getDigits(&z[1], "40f", &Y)==1 ) break; |
| 26106 | 26110 | if( n==6 && getDigits(&z[1], "50f", &Y)==1 ) break; |
| 26107 | 26111 | } |
| 26108 | 26112 | } |
| 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 ){ | |
| 26110 | 26118 | assert( rc==1 ); |
| 26111 | 26119 | break; |
| 26112 | 26120 | } |
| 26113 | 26121 | if( z[n]=='-' ){ |
| 26114 | 26122 | /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the |
| @@ -36705,12 +36713,11 @@ | ||
| 36705 | 36713 | |
| 36706 | 36714 | /* |
| 36707 | 36715 | ** The string z[] is an text representation of a real number. |
| 36708 | 36716 | ** Convert this string to a double and write it into *pResult. |
| 36709 | 36717 | ** |
| 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. | |
| 36712 | 36719 | ** |
| 36713 | 36720 | ** Return TRUE if the result is a valid real number (or integer) and FALSE |
| 36714 | 36721 | ** if the string is empty or contains extraneous text. More specifically |
| 36715 | 36722 | ** return |
| 36716 | 36723 | ** 1 => The input string is a pure integer |
| @@ -36733,144 +36740,134 @@ | ||
| 36733 | 36740 | ** into *pResult. |
| 36734 | 36741 | */ |
| 36735 | 36742 | #if defined(_MSC_VER) |
| 36736 | 36743 | #pragma warning(disable : 4756) |
| 36737 | 36744 | #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){ | |
| 36739 | 36746 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 36740 | - int incr; | |
| 36741 | - const char *zEnd; | |
| 36742 | 36747 | /* 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) */ | |
| 36749 | 36751 | 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 */ | |
| 36771 | 36755 | |
| 36772 | 36756 | /* skip leading spaces */ |
| 36773 | - while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; | |
| 36774 | - if( z>=zEnd ) return 0; | |
| 36757 | + while( sqlite3Isspace(*z) ) z++; | |
| 36775 | 36758 | |
| 36776 | 36759 | /* get sign of significand */ |
| 36777 | 36760 | if( *z=='-' ){ |
| 36778 | - sign = -1; | |
| 36779 | - z+=incr; | |
| 36761 | + neg = 1; | |
| 36762 | + z++; | |
| 36780 | 36763 | }else if( *z=='+' ){ |
| 36781 | - z+=incr; | |
| 36764 | + z++; | |
| 36782 | 36765 | } |
| 36783 | 36766 | |
| 36784 | 36767 | /* copy max significant digits to significand */ |
| 36785 | - while( z<zEnd && sqlite3Isdigit(*z) ){ | |
| 36768 | + while( sqlite3Isdigit(*z) ){ | |
| 36786 | 36769 | s = s*10 + (*z - '0'); |
| 36787 | - z+=incr; nDigit++; | |
| 36770 | + z++; nDigit++; | |
| 36788 | 36771 | if( s>=((LARGEST_INT64-9)/10) ){ |
| 36789 | 36772 | /* skip non-significant significand digits |
| 36790 | 36773 | ** (increase exponent by d to shift decimal left) */ |
| 36791 | - while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; } | |
| 36774 | + while( sqlite3Isdigit(*z) ){ z++; d++; } | |
| 36792 | 36775 | } |
| 36793 | 36776 | } |
| 36794 | - if( z>=zEnd ) goto do_atof_calc; | |
| 36795 | 36777 | |
| 36796 | 36778 | /* if decimal point is present */ |
| 36797 | 36779 | if( *z=='.' ){ |
| 36798 | - z+=incr; | |
| 36780 | + z++; | |
| 36799 | 36781 | eType++; |
| 36800 | 36782 | /* copy digits from after decimal to significand |
| 36801 | 36783 | ** (decrease exponent by d to shift decimal right) */ |
| 36802 | - while( z<zEnd && sqlite3Isdigit(*z) ){ | |
| 36784 | + while( sqlite3Isdigit(*z) ){ | |
| 36803 | 36785 | if( s<((LARGEST_INT64-9)/10) ){ |
| 36804 | 36786 | s = s*10 + (*z - '0'); |
| 36805 | 36787 | d--; |
| 36806 | 36788 | nDigit++; |
| 36807 | 36789 | } |
| 36808 | - z+=incr; | |
| 36790 | + z++; | |
| 36809 | 36791 | } |
| 36810 | 36792 | } |
| 36811 | - if( z>=zEnd ) goto do_atof_calc; | |
| 36812 | 36793 | |
| 36813 | 36794 | /* if exponent is present */ |
| 36814 | 36795 | if( *z=='e' || *z=='E' ){ |
| 36815 | - z+=incr; | |
| 36816 | - eValid = 0; | |
| 36796 | + int esign = 1; /* sign of exponent */ | |
| 36797 | + z++; | |
| 36817 | 36798 | eType++; |
| 36818 | 36799 | |
| 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 | 36800 | /* get sign of exponent */ |
| 36825 | 36801 | if( *z=='-' ){ |
| 36826 | 36802 | esign = -1; |
| 36827 | - z+=incr; | |
| 36803 | + z++; | |
| 36828 | 36804 | }else if( *z=='+' ){ |
| 36829 | - z+=incr; | |
| 36805 | + z++; | |
| 36830 | 36806 | } |
| 36831 | 36807 | /* 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; | |
| 36836 | 36818 | } |
| 36837 | 36819 | } |
| 36838 | 36820 | |
| 36839 | 36821 | /* skip trailing spaces */ |
| 36840 | - while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; | |
| 36822 | + while( sqlite3Isspace(*z) ) z++; | |
| 36841 | 36823 | |
| 36842 | -do_atof_calc: | |
| 36843 | 36824 | /* Zero is a special case */ |
| 36844 | 36825 | 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) ); | |
| 36847 | 36831 | } |
| 36848 | 36832 | |
| 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 | 36833 | /* 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 ){ | |
| 36859 | 36835 | return eType; |
| 36860 | - }else if( eType>=2 && (eType==3 || eValid) && nDigit>0 ){ | |
| 36836 | + }else if( eType>=2 && nDigit>0 ){ | |
| 36861 | 36837 | return -1; |
| 36862 | 36838 | }else{ |
| 36863 | 36839 | return 0; |
| 36864 | 36840 | } |
| 36865 | 36841 | #else |
| 36866 | - return !sqlite3Atoi64(z, pResult, length, enc); | |
| 36842 | + return !sqlite3Atoi64(z, pResult, strlen(z), SQLITE_UTF8); | |
| 36867 | 36843 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 36868 | 36844 | } |
| 36869 | 36845 | #if defined(_MSC_VER) |
| 36870 | 36846 | #pragma warning(default : 4756) |
| 36871 | 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 | + | |
| 36872 | 36869 | |
| 36873 | 36870 | /* |
| 36874 | 36871 | ** Render an signed 64-bit integer as text. Store the result in zOut[] and |
| 36875 | 36872 | ** return the length of the string that was stored, in bytes. The value |
| 36876 | 36873 | ** returned does not include the zero terminator at the end of the output |
| @@ -36879,27 +36876,39 @@ | ||
| 36879 | 36876 | ** The caller must ensure that zOut[] is at least 21 bytes in size. |
| 36880 | 36877 | */ |
| 36881 | 36878 | SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){ |
| 36882 | 36879 | int i; |
| 36883 | 36880 | 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 ){ | |
| 36888 | 36886 | 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; | |
| 36901 | 36910 | } |
| 36902 | 36911 | |
| 36903 | 36912 | /* |
| 36904 | 36913 | ** Compare the 19-character string zNum against the text representation |
| 36905 | 36914 | ** value 2^63: 9223372036854775808. Return negative, zero, or positive |
| @@ -37210,29 +37219,14 @@ | ||
| 37210 | 37219 | |
| 37211 | 37220 | /* Extract significant digits. */ |
| 37212 | 37221 | i = sizeof(p->zBuf)-1; |
| 37213 | 37222 | assert( v>0 ); |
| 37214 | 37223 | 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 | 37224 | int kk = (v%100)*2; |
| 37231 | - assert( TWO_BYTE_ALIGNMENT(&dig.a[kk]) ); | |
| 37225 | + assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) ); | |
| 37232 | 37226 | 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]; | |
| 37234 | 37228 | i -= 2; |
| 37235 | 37229 | v /= 100; |
| 37236 | 37230 | } |
| 37237 | 37231 | if( v ){ |
| 37238 | 37232 | assert( v<10 ); |
| @@ -85157,36 +85151,40 @@ | ||
| 85157 | 85151 | ** If pMem is already a string, detect if it is a zero-terminated |
| 85158 | 85152 | ** string, or make it into one if possible, and mark it as such. |
| 85159 | 85153 | ** |
| 85160 | 85154 | ** This is an optimization. Correct operation continues even if |
| 85161 | 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. | |
| 85162 | 85159 | */ |
| 85163 | -SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){ | |
| 85160 | +SQLITE_PRIVATE int sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){ | |
| 85164 | 85161 | if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){ |
| 85165 | 85162 | /* pMem must be a string, and it cannot be an ephemeral or static string */ |
| 85166 | - return; | |
| 85163 | + return 0; | |
| 85167 | 85164 | } |
| 85168 | - if( pMem->enc!=SQLITE_UTF8 ) return; | |
| 85165 | + if( pMem->enc!=SQLITE_UTF8 ) return 0; | |
| 85169 | 85166 | assert( pMem->z!=0 ); |
| 85170 | 85167 | if( pMem->flags & MEM_Dyn ){ |
| 85171 | 85168 | if( pMem->xDel==sqlite3_free |
| 85172 | 85169 | && sqlite3_msize(pMem->z) >= (u64)(pMem->n+1) |
| 85173 | 85170 | ){ |
| 85174 | 85171 | pMem->z[pMem->n] = 0; |
| 85175 | 85172 | pMem->flags |= MEM_Term; |
| 85176 | - return; | |
| 85173 | + return 1; | |
| 85177 | 85174 | } |
| 85178 | 85175 | if( pMem->xDel==sqlite3RCStrUnref ){ |
| 85179 | 85176 | /* Blindly assume that all RCStr objects are zero-terminated */ |
| 85180 | 85177 | pMem->flags |= MEM_Term; |
| 85181 | - return; | |
| 85178 | + return 1; | |
| 85182 | 85179 | } |
| 85183 | 85180 | }else if( pMem->szMalloc >= pMem->n+1 ){ |
| 85184 | 85181 | pMem->z[pMem->n] = 0; |
| 85185 | 85182 | pMem->flags |= MEM_Term; |
| 85186 | - return; | |
| 85183 | + return 1; | |
| 85187 | 85184 | } |
| 85185 | + return 0; | |
| 85188 | 85186 | } |
| 85189 | 85187 | |
| 85190 | 85188 | /* |
| 85191 | 85189 | ** It is already known that pMem contains an unterminated string. |
| 85192 | 85190 | ** Add the zero terminator. |
| @@ -85479,23 +85477,75 @@ | ||
| 85479 | 85477 | return memIntValue(pMem); |
| 85480 | 85478 | }else{ |
| 85481 | 85479 | return 0; |
| 85482 | 85480 | } |
| 85483 | 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 | +} | |
| 85484 | 85540 | |
| 85485 | 85541 | /* |
| 85486 | 85542 | ** Return the best representation of pMem that we can get into a |
| 85487 | 85543 | ** double. If pMem is already a double or an integer, return its |
| 85488 | 85544 | ** value. If it is a string or blob, try to convert it to a double. |
| 85489 | 85545 | ** If it is a NULL, return 0.0. |
| 85490 | 85546 | */ |
| 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 | 85547 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){ |
| 85498 | 85548 | assert( pMem!=0 ); |
| 85499 | 85549 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 85500 | 85550 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 85501 | 85551 | if( pMem->flags & MEM_Real ){ |
| @@ -85502,11 +85552,11 @@ | ||
| 85502 | 85552 | return pMem->u.r; |
| 85503 | 85553 | }else if( pMem->flags & (MEM_Int|MEM_IntReal) ){ |
| 85504 | 85554 | testcase( pMem->flags & MEM_IntReal ); |
| 85505 | 85555 | return (double)pMem->u.i; |
| 85506 | 85556 | }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ |
| 85507 | - return memRealValue(pMem); | |
| 85557 | + return sqlite3MemRealValueRC(pMem, 0); | |
| 85508 | 85558 | }else{ |
| 85509 | 85559 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 85510 | 85560 | return (double)0; |
| 85511 | 85561 | } |
| 85512 | 85562 | } |
| @@ -85626,11 +85676,11 @@ | ||
| 85626 | 85676 | if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){ |
| 85627 | 85677 | int rc; |
| 85628 | 85678 | sqlite3_int64 ix; |
| 85629 | 85679 | assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); |
| 85630 | 85680 | 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); | |
| 85632 | 85682 | if( ((rc==0 || rc==1) && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1) |
| 85633 | 85683 | || sqlite3RealSameAsInt(pMem->u.r, (ix = sqlite3RealToI64(pMem->u.r))) |
| 85634 | 85684 | ){ |
| 85635 | 85685 | pMem->u.i = ix; |
| 85636 | 85686 | MemSetTypeFlag(pMem, MEM_Int); |
| @@ -86597,11 +86647,11 @@ | ||
| 86597 | 86647 | } |
| 86598 | 86648 | } |
| 86599 | 86649 | if( affinity==SQLITE_AFF_BLOB ){ |
| 86600 | 86650 | if( op==TK_FLOAT ){ |
| 86601 | 86651 | 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); | |
| 86603 | 86653 | pVal->flags = MEM_Real; |
| 86604 | 86654 | }else if( op==TK_INTEGER ){ |
| 86605 | 86655 | /* This case is required by -9223372036854775808 and other strings |
| 86606 | 86656 | ** that look like integers but cannot be handled by the |
| 86607 | 86657 | ** sqlite3DecOrHexToI64() call above. */ |
| @@ -95843,14 +95893,13 @@ | ||
| 95843 | 95893 | ** point or exponential notation, the result is only MEM_Real, even |
| 95844 | 95894 | ** if there is an exact integer representation of the quantity. |
| 95845 | 95895 | */ |
| 95846 | 95896 | static void applyNumericAffinity(Mem *pRec, int bTryForInt){ |
| 95847 | 95897 | double rValue; |
| 95848 | - u8 enc = pRec->enc; | |
| 95849 | 95898 | int rc; |
| 95850 | 95899 | 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); | |
| 95852 | 95901 | if( rc<=0 ) return; |
| 95853 | 95902 | if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){ |
| 95854 | 95903 | pRec->flags |= MEM_Int; |
| 95855 | 95904 | }else{ |
| 95856 | 95905 | pRec->u.r = rValue; |
| @@ -95928,11 +95977,14 @@ | ||
| 95928 | 95977 | */ |
| 95929 | 95978 | SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){ |
| 95930 | 95979 | int eType = sqlite3_value_type(pVal); |
| 95931 | 95980 | if( eType==SQLITE_TEXT ){ |
| 95932 | 95981 | Mem *pMem = (Mem*)pVal; |
| 95982 | + assert( pMem->db!=0 ); | |
| 95983 | + sqlite3_mutex_enter(pMem->db->mutex); | |
| 95933 | 95984 | applyNumericAffinity(pMem, 0); |
| 95985 | + sqlite3_mutex_leave(pMem->db->mutex); | |
| 95934 | 95986 | eType = sqlite3_value_type(pVal); |
| 95935 | 95987 | } |
| 95936 | 95988 | return eType; |
| 95937 | 95989 | } |
| 95938 | 95990 | |
| @@ -95961,11 +96013,11 @@ | ||
| 95961 | 96013 | assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ); |
| 95962 | 96014 | if( ExpandBlob(pMem) ){ |
| 95963 | 96015 | pMem->u.i = 0; |
| 95964 | 96016 | return MEM_Int; |
| 95965 | 96017 | } |
| 95966 | - rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); | |
| 96018 | + pMem->u.r = sqlite3MemRealValueRC(pMem, &rc); | |
| 95967 | 96019 | if( rc<=0 ){ |
| 95968 | 96020 | if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){ |
| 95969 | 96021 | pMem->u.i = ix; |
| 95970 | 96022 | return MEM_Int; |
| 95971 | 96023 | }else{ |
| @@ -110238,11 +110290,11 @@ | ||
| 110238 | 110290 | */ |
| 110239 | 110291 | static int exprProbability(Expr *p){ |
| 110240 | 110292 | double r = -1.0; |
| 110241 | 110293 | if( p->op!=TK_FLOAT ) return -1; |
| 110242 | 110294 | assert( !ExprHasProperty(p, EP_IntValue) ); |
| 110243 | - sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8); | |
| 110295 | + sqlite3AtoF(p->u.zToken, &r); | |
| 110244 | 110296 | assert( r>=0.0 ); |
| 110245 | 110297 | if( r>1.0 ) return -1; |
| 110246 | 110298 | return (int)(r*134217728.0); |
| 110247 | 110299 | } |
| 110248 | 110300 | |
| @@ -111374,10 +111426,18 @@ | ||
| 111374 | 111426 | ** number of expressions in the select list. */ |
| 111375 | 111427 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ |
| 111376 | 111428 | sqlite3SelectWrongNumTermsError(pParse, p->pNext); |
| 111377 | 111429 | return WRC_Abort; |
| 111378 | 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 | + } | |
| 111379 | 111439 | |
| 111380 | 111440 | /* Advance to the next term of the compound |
| 111381 | 111441 | */ |
| 111382 | 111442 | p = p->pPrior; |
| 111383 | 111443 | nCompound++; |
| @@ -115919,11 +115979,11 @@ | ||
| 115919 | 115979 | ** like the continuation of the number. |
| 115920 | 115980 | */ |
| 115921 | 115981 | static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){ |
| 115922 | 115982 | if( ALWAYS(z!=0) ){ |
| 115923 | 115983 | double value; |
| 115924 | - sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); | |
| 115984 | + sqlite3AtoF(z, &value); | |
| 115925 | 115985 | assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */ |
| 115926 | 115986 | if( negateFlag ) value = -value; |
| 115927 | 115987 | sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL); |
| 115928 | 115988 | } |
| 115929 | 115989 | } |
| @@ -125769,10 +125829,11 @@ | ||
| 125769 | 125829 | SrcItem *p |
| 125770 | 125830 | ){ |
| 125771 | 125831 | const char *zDb; |
| 125772 | 125832 | if( p->fg.fixedSchema ){ |
| 125773 | 125833 | int iDb = sqlite3SchemaToIndex(pParse->db, p->u4.pSchema); |
| 125834 | + assert( iDb>=0 && iDb<pParse->db->nDb ); | |
| 125774 | 125835 | zDb = pParse->db->aDb[iDb].zDbSName; |
| 125775 | 125836 | }else{ |
| 125776 | 125837 | assert( !p->fg.isSubquery ); |
| 125777 | 125838 | zDb = p->u4.zDatabase; |
| 125778 | 125839 | } |
| @@ -128013,10 +128074,11 @@ | ||
| 128013 | 128074 | } |
| 128014 | 128075 | p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid; |
| 128015 | 128076 | convertToWithoutRowidTable(pParse, p); |
| 128016 | 128077 | } |
| 128017 | 128078 | iDb = sqlite3SchemaToIndex(db, p->pSchema); |
| 128079 | + assert( iDb>=0 && iDb<=db->nDb ); | |
| 128018 | 128080 | |
| 128019 | 128081 | #ifndef SQLITE_OMIT_CHECK |
| 128020 | 128082 | /* Resolve names in all CHECK constraint expressions. |
| 128021 | 128083 | */ |
| 128022 | 128084 | if( p->pCheck ){ |
| @@ -128308,10 +128370,11 @@ | ||
| 128308 | 128370 | p->tabFlags |= TF_NoVisibleRowid; /* Never allow rowid in view */ |
| 128309 | 128371 | #endif |
| 128310 | 128372 | |
| 128311 | 128373 | sqlite3TwoPartName(pParse, pName1, pName2, &pName); |
| 128312 | 128374 | iDb = sqlite3SchemaToIndex(db, p->pSchema); |
| 128375 | + assert( iDb>=0 && iDb<db->nDb ); | |
| 128313 | 128376 | sqlite3FixInit(&sFix, pParse, iDb, "view", pName); |
| 128314 | 128377 | if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail; |
| 128315 | 128378 | |
| 128316 | 128379 | /* Make a copy of the entire SELECT statement that defines the view. |
| 128317 | 128380 | ** This will force all the Expr.token.z values to be dynamically |
| @@ -133151,11 +133214,11 @@ | ||
| 133151 | 133214 | zBuf = sqlite3_mprintf("%!.*f",(int)n,r); |
| 133152 | 133215 | if( zBuf==0 ){ |
| 133153 | 133216 | sqlite3_result_error_nomem(context); |
| 133154 | 133217 | return; |
| 133155 | 133218 | } |
| 133156 | - sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8); | |
| 133219 | + sqlite3AtoF(zBuf, &r); | |
| 133157 | 133220 | sqlite3_free(zBuf); |
| 133158 | 133221 | } |
| 133159 | 133222 | sqlite3_result_double(context, r); |
| 133160 | 133223 | } |
| 133161 | 133224 | #endif |
| @@ -133789,11 +133852,11 @@ | ||
| 133789 | 133852 | const char *zVal; |
| 133790 | 133853 | r1 = sqlite3_value_double(pValue); |
| 133791 | 133854 | sqlite3_str_appendf(pStr, "%!0.15g", r1); |
| 133792 | 133855 | zVal = sqlite3_str_value(pStr); |
| 133793 | 133856 | if( zVal ){ |
| 133794 | - sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8); | |
| 133857 | + sqlite3AtoF(zVal, &r2); | |
| 133795 | 133858 | if( r1!=r2 ){ |
| 133796 | 133859 | sqlite3_str_reset(pStr); |
| 133797 | 133860 | sqlite3_str_appendf(pStr, "%!0.20e", r1); |
| 133798 | 133861 | } |
| 133799 | 133862 | } |
| @@ -155216,11 +155279,11 @@ | ||
| 155216 | 155279 | |
| 155217 | 155280 | /* |
| 155218 | 155281 | ** Check all ON clauses in pSelect to verify that they do not reference |
| 155219 | 155282 | ** columns to the right. |
| 155220 | 155283 | */ |
| 155221 | -static void selectCheckOnClauses(Parse *pParse, Select *pSelect){ | |
| 155284 | +SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect){ | |
| 155222 | 155285 | Walker w; |
| 155223 | 155286 | CheckOnCtx sCtx; |
| 155224 | 155287 | int ii; |
| 155225 | 155288 | assert( pSelect->selFlags & SF_OnToWhere ); |
| 155226 | 155289 | assert( pSelect->pSrc!=0 && pSelect->pSrc->nSrc>=2 ); |
| @@ -155396,22 +155459,10 @@ | ||
| 155396 | 155459 | TREETRACE(0x10,pParse,p, ("after name resolution:\n")); |
| 155397 | 155460 | sqlite3TreeViewSelect(0, p, 0); |
| 155398 | 155461 | } |
| 155399 | 155462 | #endif |
| 155400 | 155463 | |
| 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 | 155464 | /* If the SF_UFSrcCheck flag is set, then this function is being called |
| 155414 | 155465 | ** as part of populating the temp table for an UPDATE...FROM statement. |
| 155415 | 155466 | ** In this case, it is an error if the target object (pSrc->a[0]) name |
| 155416 | 155467 | ** or alias is duplicated within FROM clause (pSrc->a[1..n]). |
| 155417 | 155468 | ** |
| @@ -165902,17 +165953,18 @@ | ||
| 165902 | 165953 | && ALWAYS(pLeft->y.pTab) |
| 165903 | 165954 | && IsVirtual(pLeft->y.pTab)) /* Might be numeric */ |
| 165904 | 165955 | ){ |
| 165905 | 165956 | int isNum; |
| 165906 | 165957 | double rDummy; |
| 165907 | - isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8); | |
| 165958 | + assert( zNew[iTo]==0 ); | |
| 165959 | + isNum = sqlite3AtoF(zNew, &rDummy); | |
| 165908 | 165960 | if( isNum<=0 ){ |
| 165909 | 165961 | if( iTo==1 && zNew[0]=='-' ){ |
| 165910 | 165962 | isNum = +1; |
| 165911 | 165963 | }else{ |
| 165912 | 165964 | zNew[iTo-1]++; |
| 165913 | - isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8); | |
| 165965 | + isNum = sqlite3AtoF(zNew, &rDummy); | |
| 165914 | 165966 | zNew[iTo-1]--; |
| 165915 | 165967 | } |
| 165916 | 165968 | } |
| 165917 | 165969 | if( isNum>0 ){ |
| 165918 | 165970 | sqlite3ExprDelete(db, pPrefix); |
| @@ -214611,11 +214663,11 @@ | ||
| 214611 | 214663 | char *z; |
| 214612 | 214664 | if( sz==0 ) goto returnfromblob_malformed; |
| 214613 | 214665 | to_double: |
| 214614 | 214666 | z = sqlite3DbStrNDup(db, (const char*)&pParse->aBlob[i+n], (int)sz); |
| 214615 | 214667 | if( z==0 ) goto returnfromblob_oom; |
| 214616 | - rc = sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); | |
| 214668 | + rc = sqlite3AtoF(z, &r); | |
| 214617 | 214669 | sqlite3DbFree(db, z); |
| 214618 | 214670 | if( rc<=0 ) goto returnfromblob_malformed; |
| 214619 | 214671 | sqlite3_result_double(pCtx, r); |
| 214620 | 214672 | break; |
| 214621 | 214673 | } |
| @@ -221490,11 +221542,11 @@ | ||
| 221490 | 221542 | if( pVal ){ |
| 221491 | 221543 | #ifdef SQLITE_AMALGAMATION |
| 221492 | 221544 | /* The sqlite3AtoF() routine is much much faster than atof(), if it |
| 221493 | 221545 | ** is available */ |
| 221494 | 221546 | double r; |
| 221495 | - (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8); | |
| 221547 | + (void)sqlite3AtoF((const char*)p->z, &r); | |
| 221496 | 221548 | *pVal = r; |
| 221497 | 221549 | #else |
| 221498 | 221550 | *pVal = (GeoCoord)atof((const char*)p->z); |
| 221499 | 221551 | #endif |
| 221500 | 221552 | } |
| @@ -261698,11 +261750,11 @@ | ||
| 261698 | 261750 | int nArg, /* Number of args */ |
| 261699 | 261751 | sqlite3_value **apUnused /* Function arguments */ |
| 261700 | 261752 | ){ |
| 261701 | 261753 | assert( nArg==0 ); |
| 261702 | 261754 | 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); | |
| 261704 | 261756 | } |
| 261705 | 261757 | |
| 261706 | 261758 | /* |
| 261707 | 261759 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 261708 | 261760 | ** |
| 261709 | 261761 |
| --- 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 |
+2
-2
| --- extsrc/sqlite3.h | ||
| +++ extsrc/sqlite3.h | ||
| @@ -146,14 +146,14 @@ | ||
| 146 | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | 148 | */ |
| 149 | 149 | #define SQLITE_VERSION "3.52.0" |
| 150 | 150 | #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" | |
| 152 | 152 | #define SQLITE_SCM_BRANCH "trunk" |
| 153 | 153 | #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" | |
| 155 | 155 | |
| 156 | 156 | /* |
| 157 | 157 | ** CAPI3REF: Run-Time Library Version Numbers |
| 158 | 158 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 159 | 159 | ** |
| 160 | 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-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 |