Fossil SCM
Update the built-in SQLite to the latest trunk check-in for beta testing.
Commit
7012444fc25069e1bb091391aa013d68c1d33fcd07cf965b1517f4f1fb579c39
Parent
001420ad783ffae…
2 files changed
+309
-208
+2
-2
+309
-208
| --- 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 | -** 6bdfff7ddb63d0b4f28f6c174a36e81486a6 with changes in files: | |
| 21 | +** fee71cd6f7294ffd02784d26811a9d11d80e 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.54.0" |
| 471 | 471 | #define SQLITE_VERSION_NUMBER 3054000 |
| 472 | -#define SQLITE_SOURCE_ID "2026-08-04 20:40:10 6bdfff7ddb63d0b4f28f6c174a36e81486a652056a4e21644378a22feda780fd" | |
| 472 | +#define SQLITE_SOURCE_ID "2026-08-11 10:46:12 fee71cd6f7294ffd02784d26811a9d11d80e83d4075e1233b8ec0289519bb891" | |
| 473 | 473 | #define SQLITE_SCM_BRANCH "trunk" |
| 474 | 474 | #define SQLITE_SCM_TAGS "" |
| 475 | -#define SQLITE_SCM_DATETIME "2026-08-04T20:40:10.440Z" | |
| 475 | +#define SQLITE_SCM_DATETIME "2026-08-11T10:46:12.896Z" | |
| 476 | 476 | |
| 477 | 477 | /* |
| 478 | 478 | ** CAPI3REF: Run-Time Library Version Numbers |
| 479 | 479 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 480 | 480 | ** |
| @@ -15135,26 +15135,41 @@ | ||
| 15135 | 15135 | # define SQLITE_INT_TO_PTR(X) ((void*)(X)) |
| 15136 | 15136 | # define SQLITE_PTR_TO_INT(X) ((int)(X)) |
| 15137 | 15137 | #endif |
| 15138 | 15138 | |
| 15139 | 15139 | /* |
| 15140 | -** Macros to hint to the compiler that a function should or should not be | |
| 15141 | -** inlined. | |
| 15140 | +** Hint to the compiler that a function should or should not be inlined: | |
| 15141 | +** | |
| 15142 | +** SQLITE_NOINLINE Never in-line this function | |
| 15143 | +** | |
| 15144 | +** SQLITE_INLINE Strive to in-line this function | |
| 15145 | +** | |
| 15146 | +** SQLITE_OPT_INLINE In-line this function if building the | |
| 15147 | +** amalgamation. | |
| 15142 | 15148 | */ |
| 15143 | 15149 | #if defined(__GNUC__) |
| 15144 | -# define SQLITE_NOINLINE __attribute__((noinline)) | |
| 15145 | -# define SQLITE_INLINE __attribute__((always_inline)) inline | |
| 15150 | +# define SQLITE_NOINLINE __attribute__((noinline)) | |
| 15151 | +# define SQLITE_INLINE __attribute__((always_inline)) inline | |
| 15152 | +# define SQLITE_OPT_INLINE __attribute__((always_inline)) inline | |
| 15146 | 15153 | #elif defined(_MSC_VER) && _MSC_VER>=1310 |
| 15147 | -# define SQLITE_NOINLINE __declspec(noinline) | |
| 15148 | -# define SQLITE_INLINE __forceinline | |
| 15154 | +# define SQLITE_NOINLINE __declspec(noinline) | |
| 15155 | +# define SQLITE_INLINE __forceinline | |
| 15156 | +# define SQLITE_OPT_INLINE __forceinline | |
| 15149 | 15157 | #else |
| 15150 | 15158 | # define SQLITE_NOINLINE |
| 15151 | 15159 | # define SQLITE_INLINE |
| 15160 | +# define SQLITE_OPT_INLINE | |
| 15152 | 15161 | #endif |
| 15153 | 15162 | #if defined(SQLITE_COVERAGE_TEST) || defined(__STRICT_ANSI__) |
| 15154 | 15163 | # undef SQLITE_INLINE |
| 15155 | 15164 | # define SQLITE_INLINE |
| 15165 | +# undef SQLITE_OPT_INLINE | |
| 15166 | +# define SQLITE_OPT_INLINE | |
| 15167 | +#endif | |
| 15168 | +#if !defined(SQLITE_AMALGAMATION) | |
| 15169 | +# undef SQLITE_OPT_INLINE | |
| 15170 | +# define SQLITE_OPT_INLINE | |
| 15156 | 15171 | #endif |
| 15157 | 15172 | |
| 15158 | 15173 | /* |
| 15159 | 15174 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 15160 | 15175 | ** compiling with an appropriate version of MSVC unless prevented by |
| @@ -22989,10 +23004,14 @@ | ||
| 22989 | 23004 | #define sqlite3ExprCheckHeight(x,y) |
| 22990 | 23005 | #endif |
| 22991 | 23006 | SQLITE_PRIVATE void sqlite3ExprSetErrorOffset(Expr*,int); |
| 22992 | 23007 | |
| 22993 | 23008 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8*); |
| 23009 | +SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3Get8byte(const u8*); | |
| 23010 | +#if SQLITE_BYTEORDER!=4321 | |
| 23011 | +SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3BSwap64(u64); | |
| 23012 | +#endif | |
| 22994 | 23013 | SQLITE_PRIVATE void sqlite3Put4byte(u8*, u32); |
| 22995 | 23014 | |
| 22996 | 23015 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 22997 | 23016 | SQLITE_PRIVATE void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *); |
| 22998 | 23017 | SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db); |
| @@ -25051,10 +25070,21 @@ | ||
| 25051 | 25070 | */ |
| 25052 | 25071 | #ifndef SQLITE_AMALGAMATION |
| 25053 | 25072 | SQLITE_PRIVATE const u8 sqlite3SmallTypeSizes[]; |
| 25054 | 25073 | #endif |
| 25055 | 25074 | |
| 25075 | +/* Input "x" is a sequence of unsigned characters that represent a | |
| 25076 | +** big-endian integer. Return the equivalent native integer | |
| 25077 | +*/ | |
| 25078 | +#define ONE_BYTE_INT(x) ((i8)(x)[0]) | |
| 25079 | +#define TWO_BYTE_INT(x) (256*(i8)((x)[0])|(x)[1]) | |
| 25080 | +#define THREE_BYTE_INT(x) (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2]) | |
| 25081 | +#define FOUR_BYTE_UINT(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) | |
| 25082 | +#define FOUR_BYTE_U64(x) (((u64)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) | |
| 25083 | +#define FOUR_BYTE_INT(x) ((int)FOUR_BYTE_UINT(x)) | |
| 25084 | +#define SIX_BYTE_INT(x) (FOUR_BYTE_UINT(x+2)+4294967296LL*TWO_BYTE_INT(x)) | |
| 25085 | + | |
| 25056 | 25086 | /* |
| 25057 | 25087 | ** Function prototypes |
| 25058 | 25088 | */ |
| 25059 | 25089 | SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...); |
| 25060 | 25090 | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*); |
| @@ -38533,11 +38563,11 @@ | ||
| 38533 | 38563 | return i; |
| 38534 | 38564 | } |
| 38535 | 38565 | |
| 38536 | 38566 | |
| 38537 | 38567 | /* |
| 38538 | -** Read or write a four-byte big-endian integer value. | |
| 38568 | +** Read an unsigned 32-bit integer from an unaligned big-endian array of bytes. | |
| 38539 | 38569 | */ |
| 38540 | 38570 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 38541 | 38571 | #if SQLITE_BYTEORDER==4321 |
| 38542 | 38572 | u32 x; |
| 38543 | 38573 | memcpy(&x,p,4); |
| @@ -38549,14 +38579,18 @@ | ||
| 38549 | 38579 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38550 | 38580 | u32 x; |
| 38551 | 38581 | memcpy(&x,p,4); |
| 38552 | 38582 | return _byteswap_ulong(x); |
| 38553 | 38583 | #else |
| 38584 | + /* Test this limb using -DSQLITE_BYTEORDER=0 */ | |
| 38554 | 38585 | testcase( p[0]&0x80 ); |
| 38555 | 38586 | return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 38556 | 38587 | #endif |
| 38557 | 38588 | } |
| 38589 | + | |
| 38590 | +/* Write an unsigned 32-bit integer into an unaligned big-endian array of bytes. | |
| 38591 | +*/ | |
| 38558 | 38592 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 38559 | 38593 | #if SQLITE_BYTEORDER==4321 |
| 38560 | 38594 | memcpy(p,&v,4); |
| 38561 | 38595 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 38562 | 38596 | u32 x = __builtin_bswap32(v); |
| @@ -38563,18 +38597,70 @@ | ||
| 38563 | 38597 | memcpy(p,&x,4); |
| 38564 | 38598 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38565 | 38599 | u32 x = _byteswap_ulong(v); |
| 38566 | 38600 | memcpy(p,&x,4); |
| 38567 | 38601 | #else |
| 38602 | + /* Test this limb using -DSQLITE_BYTEORDER=0 */ | |
| 38568 | 38603 | p[0] = (u8)(v>>24); |
| 38569 | 38604 | p[1] = (u8)(v>>16); |
| 38570 | 38605 | p[2] = (u8)(v>>8); |
| 38571 | 38606 | p[3] = (u8)v; |
| 38572 | 38607 | #endif |
| 38573 | 38608 | } |
| 38574 | 38609 | |
| 38610 | +/* | |
| 38611 | +** Read an unsigned 64-bit integer from an unaligned big-endian byte array. | |
| 38612 | +*/ | |
| 38613 | +SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3Get8byte(const u8 *p){ | |
| 38614 | +#if SQLITE_BYTEORDER==4321 | |
| 38615 | + u64 x; | |
| 38616 | + memcpy(&x,p,8); | |
| 38617 | + return x; | |
| 38618 | +#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 | |
| 38619 | + u64 x; | |
| 38620 | + memcpy(&x,p,8); | |
| 38621 | + return __builtin_bswap64(x); | |
| 38622 | +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 | |
| 38623 | + u64 x; | |
| 38624 | + memcpy(&x,p,8); | |
| 38625 | + return _byteswap_uint64(x); | |
| 38626 | +#else | |
| 38627 | + /* Test this limb using -DSQLITE_BYTEORDER=0 */ | |
| 38628 | + testcase( p[0]&0x80 ); | |
| 38629 | + return (u64)( | |
| 38630 | + (((u64)p[0]) << 56) + | |
| 38631 | + (((u64)p[1]) << 48) + | |
| 38632 | + (((u64)p[2]) << 40) + | |
| 38633 | + (((u64)p[3]) << 32) + | |
| 38634 | + (((u64)p[4]) << 24) + | |
| 38635 | + (((u64)p[5]) << 16) + | |
| 38636 | + (((u64)p[6]) << 8) + | |
| 38637 | + (((u64)p[7]) << 0) | |
| 38638 | + ); | |
| 38639 | +#endif | |
| 38640 | +} | |
| 38575 | 38641 | |
| 38642 | +#if SQLITE_BYTEORDER!=4321 /* Only used for little-endian machines */ | |
| 38643 | +/* | |
| 38644 | +** Byte-swap a 64-bit unsigned integer. | |
| 38645 | +*/ | |
| 38646 | +SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3BSwap64(u64 x){ | |
| 38647 | +#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 | |
| 38648 | + return __builtin_bswap64(x); | |
| 38649 | +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 | |
| 38650 | + return _byteswap_uint64(x); | |
| 38651 | +#else | |
| 38652 | + /* Test this limb using -DSQLITE_BYTEORDER=0 */ | |
| 38653 | + x = (x << 32) | (x >> 32); | |
| 38654 | + x = ((x & UINT64_C(0x0000ffff0000ffff)) << 16) | | |
| 38655 | + ((x & UINT64_C(0xffff0000ffff0000)) >> 16); | |
| 38656 | + x = ((x & UINT64_C(0x00ff00ff00ff00ff)) << 8) | | |
| 38657 | + ((x & UINT64_C(0xff00ff00ff00ff00)) >> 8); | |
| 38658 | + return x; | |
| 38659 | +#endif | |
| 38660 | +} | |
| 38661 | +#endif /* SQLITE_BYTEORDER!=4321 */ | |
| 38576 | 38662 | |
| 38577 | 38663 | /* |
| 38578 | 38664 | ** Translate a single byte of Hex into an integer. |
| 38579 | 38665 | ** This routine only works if h really is a valid hexadecimal |
| 38580 | 38666 | ** character: 0..9a..fA..F |
| @@ -57862,12 +57948,15 @@ | ||
| 57862 | 57948 | int createFlag |
| 57863 | 57949 | ){ |
| 57864 | 57950 | PCache1 *pCache = (PCache1 *)p; |
| 57865 | 57951 | PgHdr1 *pPage = 0; |
| 57866 | 57952 | |
| 57867 | - /* Step 1: Search the hash table for an existing entry. */ | |
| 57868 | - pPage = pCache->apHash[iKey % pCache->nHash]; | |
| 57953 | + /* Step 1: Search the hash table for an existing entry. nHash is always | |
| 57954 | + ** a power of two when the cache is in use (see pcache1ResizeHash()), so | |
| 57955 | + ** the modulo reduces to a mask, avoiding a hardware divide. */ | |
| 57956 | + assert( pCache->nHash>0 && (pCache->nHash & (pCache->nHash-1))==0 ); | |
| 57957 | + pPage = pCache->apHash[iKey & (pCache->nHash-1u)]; | |
| 57869 | 57958 | while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; } |
| 57870 | 57959 | |
| 57871 | 57960 | /* Step 2: If the page was found in the hash table, then return it. |
| 57872 | 57961 | ** If the page was not in the hash table and createFlag is 0, abort. |
| 57873 | 57962 | ** Otherwise (page not in hash and createFlag!=0) continue with |
| @@ -91159,71 +91248,20 @@ | ||
| 91159 | 91248 | u.i[1] = t; |
| 91160 | 91249 | return u.r; |
| 91161 | 91250 | } |
| 91162 | 91251 | #endif /* SQLITE_MIXED_ENDIAN_64BIT_FLOAT */ |
| 91163 | 91252 | |
| 91164 | - | |
| 91165 | -/* Input "x" is a sequence of unsigned characters that represent a | |
| 91166 | -** big-endian integer. Return the equivalent native integer | |
| 91167 | -*/ | |
| 91168 | -#define ONE_BYTE_INT(x) ((i8)(x)[0]) | |
| 91169 | -#define TWO_BYTE_INT(x) (256*(i8)((x)[0])|(x)[1]) | |
| 91170 | -#define THREE_BYTE_INT(x) (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2]) | |
| 91171 | -#define FOUR_BYTE_UINT(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) | |
| 91172 | -#define FOUR_BYTE_INT(x) (16777216*(i8)((x)[0])|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) | |
| 91173 | - | |
| 91174 | -/* | |
| 91175 | -** Deserialize the data blob pointed to by buf as serial type serial_type | |
| 91176 | -** and store the result in pMem. | |
| 91177 | -** | |
| 91178 | -** This function is implemented as two separate routines for performance. | |
| 91179 | -** The few cases that require local variables are broken out into a separate | |
| 91180 | -** routine so that in most cases the overhead of moving the stack pointer | |
| 91181 | -** is avoided. | |
| 91182 | -*/ | |
| 91183 | -static void serialGet( | |
| 91184 | - const unsigned char *buf, /* Buffer to deserialize from */ | |
| 91185 | - u32 serial_type, /* Serial type to deserialize */ | |
| 91186 | - Mem *pMem /* Memory cell to write value into */ | |
| 91187 | -){ | |
| 91188 | - u64 x = FOUR_BYTE_UINT(buf); | |
| 91189 | - u32 y = FOUR_BYTE_UINT(buf+4); | |
| 91190 | - x = (x<<32) + y; | |
| 91191 | - if( serial_type==6 ){ | |
| 91192 | - /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit | |
| 91193 | - ** twos-complement integer. */ | |
| 91194 | - pMem->u.i = *(i64*)&x; | |
| 91195 | - pMem->flags = MEM_Int; | |
| 91196 | - testcase( pMem->u.i<0 ); | |
| 91197 | - }else{ | |
| 91198 | - /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit | |
| 91199 | - ** floating point number. */ | |
| 91200 | -#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) | |
| 91201 | - /* Verify that integers and floating point values use the same | |
| 91202 | - ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is | |
| 91203 | - ** defined that 64-bit floating point values really are mixed | |
| 91204 | - ** endian. | |
| 91205 | - */ | |
| 91206 | - static const u64 t1 = ((u64)0x3ff00000)<<32; | |
| 91207 | - static const double r1 = 1.0; | |
| 91208 | - u64 t2 = t1; | |
| 91209 | - swapMixedEndianFloat(t2); | |
| 91210 | - assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); | |
| 91211 | -#endif | |
| 91212 | - assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 ); | |
| 91213 | - swapMixedEndianFloat(x); | |
| 91214 | - memcpy(&pMem->u.r, &x, sizeof(x)); | |
| 91215 | - pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real; | |
| 91216 | - } | |
| 91217 | -} | |
| 91218 | -static int serialGet7( | |
| 91219 | - const unsigned char *buf, /* Buffer to deserialize from */ | |
| 91220 | - Mem *pMem /* Memory cell to write value into */ | |
| 91221 | -){ | |
| 91222 | - u64 x = FOUR_BYTE_UINT(buf); | |
| 91223 | - u32 y = FOUR_BYTE_UINT(buf+4); | |
| 91224 | - x = (x<<32) + y; | |
| 91253 | +/* | |
| 91254 | +** Deserialize the REAL number pointed to by buf and store it in pMem. | |
| 91255 | +*/ | |
| 91256 | +static int sqlite3VdbeSerialGet7( | |
| 91257 | + const unsigned char *buf, /* Buffer to deserialize from */ | |
| 91258 | + Mem *pMem /* Memory cell to write value into */ | |
| 91259 | +){ | |
| 91260 | + /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit | |
| 91261 | + ** floating point number. */ | |
| 91262 | + u64 x = sqlite3Get8byte(buf); | |
| 91225 | 91263 | assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 ); |
| 91226 | 91264 | swapMixedEndianFloat(x); |
| 91227 | 91265 | memcpy(&pMem->u.r, &x, sizeof(x)); |
| 91228 | 91266 | if( IsNaN(x) ){ |
| 91229 | 91267 | pMem->flags = MEM_Null; |
| @@ -91230,10 +91268,17 @@ | ||
| 91230 | 91268 | return 1; |
| 91231 | 91269 | } |
| 91232 | 91270 | pMem->flags = MEM_Real; |
| 91233 | 91271 | return 0; |
| 91234 | 91272 | } |
| 91273 | + | |
| 91274 | +/* | |
| 91275 | +** Deserialize the data blob pointed to by buf as serial type serial_type | |
| 91276 | +** and store the result in pMem. | |
| 91277 | +** | |
| 91278 | +** Similar code is found in the implementation of the OP_Column opcode. | |
| 91279 | +*/ | |
| 91235 | 91280 | SQLITE_PRIVATE void sqlite3VdbeSerialGet( |
| 91236 | 91281 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 91237 | 91282 | u32 serial_type, /* Serial type to deserialize */ |
| 91238 | 91283 | Mem *pMem /* Memory cell to write value into */ |
| 91239 | 91284 | ){ |
| @@ -91288,20 +91333,25 @@ | ||
| 91288 | 91333 | return; |
| 91289 | 91334 | } |
| 91290 | 91335 | case 5: { /* 6-byte signed integer */ |
| 91291 | 91336 | /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit |
| 91292 | 91337 | ** twos-complement integer. */ |
| 91293 | - pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf); | |
| 91338 | + pMem->u.i = SIX_BYTE_INT(buf); | |
| 91339 | + pMem->flags = MEM_Int; | |
| 91340 | + testcase( pMem->u.i<0 ); | |
| 91341 | + return; | |
| 91342 | + } | |
| 91343 | + case 6: { /* 8-byte signed integer */ | |
| 91344 | + /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit | |
| 91345 | + ** twos-complement integer. */ | |
| 91346 | + pMem->u.i = (i64)sqlite3Get8byte(buf); | |
| 91294 | 91347 | pMem->flags = MEM_Int; |
| 91295 | 91348 | testcase( pMem->u.i<0 ); |
| 91296 | 91349 | return; |
| 91297 | 91350 | } |
| 91298 | - case 6: /* 8-byte signed integer */ | |
| 91299 | 91351 | case 7: { /* IEEE floating point */ |
| 91300 | - /* These use local variables, so do them in a separate routine | |
| 91301 | - ** to avoid having to move the frame pointer in the common case */ | |
| 91302 | - serialGet(buf,serial_type,pMem); | |
| 91352 | + sqlite3VdbeSerialGet7(buf, pMem); | |
| 91303 | 91353 | return; |
| 91304 | 91354 | } |
| 91305 | 91355 | case 8: /* Integer 0 */ |
| 91306 | 91356 | case 9: { /* Integer 1 */ |
| 91307 | 91357 | /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */ |
| @@ -91903,11 +91953,11 @@ | ||
| 91903 | 91953 | if( serial_type>=10 ){ |
| 91904 | 91954 | rc = serial_type==10 ? -1 : +1; |
| 91905 | 91955 | }else if( serial_type==0 ){ |
| 91906 | 91956 | rc = -1; |
| 91907 | 91957 | }else if( serial_type==7 ){ |
| 91908 | - serialGet7(&aKey1[d1], &mem1); | |
| 91958 | + sqlite3VdbeSerialGet7(&aKey1[d1], &mem1); | |
| 91909 | 91959 | rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r); |
| 91910 | 91960 | }else{ |
| 91911 | 91961 | i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]); |
| 91912 | 91962 | i64 rhs = pRhs->u.i; |
| 91913 | 91963 | if( lhs<rhs ){ |
| @@ -91929,11 +91979,11 @@ | ||
| 91929 | 91979 | rc = serial_type==10 ? -1 : +1; |
| 91930 | 91980 | }else if( serial_type==0 ){ |
| 91931 | 91981 | rc = -1; |
| 91932 | 91982 | }else{ |
| 91933 | 91983 | if( serial_type==7 ){ |
| 91934 | - if( serialGet7(&aKey1[d1], &mem1) ){ | |
| 91984 | + if( sqlite3VdbeSerialGet7(&aKey1[d1], &mem1) ){ | |
| 91935 | 91985 | rc = -1; /* mem1 is a NaN */ |
| 91936 | 91986 | }else if( mem1.u.r<pRhs->u.r ){ |
| 91937 | 91987 | rc = -1; |
| 91938 | 91988 | }else if( mem1.u.r>pRhs->u.r ){ |
| 91939 | 91989 | rc = +1; |
| @@ -92011,11 +92061,11 @@ | ||
| 92011 | 92061 | /* RHS is null */ |
| 92012 | 92062 | else{ |
| 92013 | 92063 | serial_type = aKey1[idx1]; |
| 92014 | 92064 | if( serial_type==0 |
| 92015 | 92065 | || serial_type==10 |
| 92016 | - || (serial_type==7 && serialGet7(&aKey1[d1], &mem1)!=0) | |
| 92066 | + || (serial_type==7 && sqlite3VdbeSerialGet7(&aKey1[d1], &mem1)!=0) | |
| 92017 | 92067 | ){ |
| 92018 | 92068 | assert( rc==0 ); |
| 92019 | 92069 | }else{ |
| 92020 | 92070 | rc = 1; |
| 92021 | 92071 | } |
| @@ -92085,69 +92135,46 @@ | ||
| 92085 | 92135 | UnpackedRecord *pPKey2 /* Right key */ |
| 92086 | 92136 | ){ |
| 92087 | 92137 | const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F]; |
| 92088 | 92138 | int serial_type = ((const u8*)pKey1)[1]; |
| 92089 | 92139 | int res; |
| 92090 | - u32 y; | |
| 92091 | - u64 x; | |
| 92092 | 92140 | i64 v; |
| 92093 | 92141 | i64 lhs; |
| 92094 | 92142 | |
| 92095 | 92143 | vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo); |
| 92096 | 92144 | assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB ); |
| 92097 | - switch( serial_type ){ | |
| 92098 | - case 1: { /* 1-byte signed integer */ | |
| 92099 | - lhs = ONE_BYTE_INT(aKey); | |
| 92100 | - testcase( lhs<0 ); | |
| 92101 | - break; | |
| 92102 | - } | |
| 92103 | - case 2: { /* 2-byte signed integer */ | |
| 92104 | - lhs = TWO_BYTE_INT(aKey); | |
| 92105 | - testcase( lhs<0 ); | |
| 92106 | - break; | |
| 92107 | - } | |
| 92108 | - case 3: { /* 3-byte signed integer */ | |
| 92109 | - lhs = THREE_BYTE_INT(aKey); | |
| 92110 | - testcase( lhs<0 ); | |
| 92111 | - break; | |
| 92112 | - } | |
| 92113 | - case 4: { /* 4-byte signed integer */ | |
| 92114 | - y = FOUR_BYTE_UINT(aKey); | |
| 92115 | - lhs = (i64)*(int*)&y; | |
| 92116 | - testcase( lhs<0 ); | |
| 92117 | - break; | |
| 92118 | - } | |
| 92119 | - case 5: { /* 6-byte signed integer */ | |
| 92120 | - lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey); | |
| 92121 | - testcase( lhs<0 ); | |
| 92122 | - break; | |
| 92123 | - } | |
| 92124 | - case 6: { /* 8-byte signed integer */ | |
| 92125 | - x = FOUR_BYTE_UINT(aKey); | |
| 92126 | - x = (x<<32) | FOUR_BYTE_UINT(aKey+4); | |
| 92127 | - lhs = *(i64*)&x; | |
| 92128 | - testcase( lhs<0 ); | |
| 92129 | - break; | |
| 92130 | - } | |
| 92131 | - case 8: | |
| 92132 | - lhs = 0; | |
| 92133 | - break; | |
| 92134 | - case 9: | |
| 92135 | - lhs = 1; | |
| 92136 | - break; | |
| 92137 | - | |
| 92138 | - /* This case could be removed without changing the results of running | |
| 92139 | - ** this code. Including it causes gcc to generate a faster switch | |
| 92140 | - ** statement (since the range of switch targets now starts at zero and | |
| 92141 | - ** is contiguous) but does not cause any duplicate code to be generated | |
| 92142 | - ** (as gcc is clever enough to combine the two like cases). Other | |
| 92143 | - ** compilers might be similar. */ | |
| 92144 | - case 0: case 7: | |
| 92145 | - return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2); | |
| 92146 | - | |
| 92147 | - default: | |
| 92148 | - return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2); | |
| 92145 | + | |
| 92146 | + /* Serial types 1 through 6 are big-endian integers of 1, 2, 3, 4, | |
| 92147 | + ** 6, or 8 bytes. Rather than handle each width in its own switch | |
| 92148 | + ** case, read 8 bytes and use an arithmetic right shift to drop the | |
| 92149 | + ** unwanted low-order bytes and sign-extend the value. This helps | |
| 92150 | + ** because the switch tends to mispredict when a key column contains | |
| 92151 | + ** integers of varying sizes. The first entry of aShift[] is a | |
| 92152 | + ** placeholder so that the table can be indexed by serial_type | |
| 92153 | + ** directly. Reading 8 bytes is always safe, because a buffer passed | |
| 92154 | + ** to this routine has at least 74 bytes of padding after it, as | |
| 92155 | + ** explained in sqlite3VdbeFindCompare() below. | |
| 92156 | + */ | |
| 92157 | + if( (u32)(serial_type-1)<=5 ){ | |
| 92158 | + static const u8 aShift[] = { 0, 56, 48, 40, 32, 16, 0 }; | |
| 92159 | + lhs = ((i64)sqlite3Get8byte(aKey)) >> aShift[serial_type]; | |
| 92160 | + /* ^^--- This shift operator | |
| 92161 | + ** needs to be an arithmetic right-shift, which means that | |
| 92162 | + ** if the left-hand operand (LHS) is negative, it will be sign-extended | |
| 92163 | + ** so that the final results is also negative. All modern C | |
| 92164 | + ** compilers work this way as long as the LHS is a signed integer | |
| 92165 | + ** (which is why the unsigned result from sqlite3Get8byte() is cast | |
| 92166 | + ** into i64), but it is not defined by the C standards, or so Claude | |
| 92167 | + ** tells me. That the correct result is obtained is verified by the | |
| 92168 | + ** following assert() and testcase() macros: | |
| 92169 | + */ | |
| 92170 | + assert( 0<=(i64)sqlite3Get8byte(aKey) || lhs<0 ); | |
| 92171 | + testcase( lhs<0 ); | |
| 92172 | + }else if( serial_type==8 || serial_type==9 ){ | |
| 92173 | + lhs = serial_type - 8; | |
| 92174 | + }else{ | |
| 92175 | + return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2); | |
| 92149 | 92176 | } |
| 92150 | 92177 | |
| 92151 | 92178 | assert( pPKey2->u.i == pPKey2->aMem[0].u.i ); |
| 92152 | 92179 | v = pPKey2->u.i; |
| 92153 | 92180 | if( v>lhs ){ |
| @@ -99150,34 +99177,95 @@ | ||
| 99150 | 99177 | sqlite3VdbeMemSetNull(pDest); |
| 99151 | 99178 | } |
| 99152 | 99179 | assert( t==pC->aType[p2] ); |
| 99153 | 99180 | if( pC->szRow>=aOffset[p2+1] ){ |
| 99154 | 99181 | /* This is the common case where the desired content fits on the original |
| 99155 | - ** page - where the content is not on an overflow page */ | |
| 99182 | + ** page - where the content is not on an overflow page. | |
| 99183 | + ** | |
| 99184 | + ** The big switch() is an in-line variant of sqlite3VdbeSerialGet() that | |
| 99185 | + ** has been optimized for the OP_Column opcode. | |
| 99186 | + */ | |
| 99156 | 99187 | zData = pC->aRow + aOffset[p2]; |
| 99157 | - if( t<12 ){ | |
| 99158 | - sqlite3VdbeSerialGet(zData, t, pDest); | |
| 99159 | - }else{ | |
| 99160 | - /* If the column value is a string, we need a persistent value, not | |
| 99161 | - ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent | |
| 99162 | - ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize(). | |
| 99163 | - */ | |
| 99164 | - static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; | |
| 99165 | - pDest->n = len = (t-12)/2; | |
| 99166 | - pDest->enc = encoding; | |
| 99167 | - if( pDest->szMalloc < len+2 ){ | |
| 99168 | - if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big; | |
| 99188 | + switch( t ){ | |
| 99189 | + case 0: | |
| 99190 | + case 11: | |
| 99169 | 99191 | pDest->flags = MEM_Null; |
| 99170 | - if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; | |
| 99171 | - }else{ | |
| 99172 | - pDest->z = pDest->zMalloc; | |
| 99173 | - } | |
| 99174 | - memcpy(pDest->z, zData, len); | |
| 99175 | - pDest->z[len] = 0; | |
| 99176 | - pDest->z[len+1] = 0; | |
| 99177 | - pDest->flags = aFlag[t&1]; | |
| 99178 | - } | |
| 99192 | + break; | |
| 99193 | + case 1: | |
| 99194 | + pDest->u.i = ONE_BYTE_INT(zData); | |
| 99195 | + pDest->flags = MEM_Int; | |
| 99196 | + testcase( pDest->u.i<0 ); | |
| 99197 | + break; | |
| 99198 | + case 2: | |
| 99199 | + pDest->u.i = TWO_BYTE_INT(zData); | |
| 99200 | + pDest->flags = MEM_Int; | |
| 99201 | + testcase( pDest->u.i<0 ); | |
| 99202 | + break; | |
| 99203 | + case 3: | |
| 99204 | + pDest->u.i = THREE_BYTE_INT(zData); | |
| 99205 | + pDest->flags = MEM_Int; | |
| 99206 | + testcase( pDest->u.i<0 ); | |
| 99207 | + break; | |
| 99208 | + case 4: | |
| 99209 | + pDest->u.i = FOUR_BYTE_INT(zData); | |
| 99210 | + pDest->flags = MEM_Int; | |
| 99211 | + testcase( pDest->u.i<0 ); | |
| 99212 | + break; | |
| 99213 | + case 5: | |
| 99214 | + pDest->u.i = SIX_BYTE_INT(zData); | |
| 99215 | + pDest->flags = MEM_Int; | |
| 99216 | + testcase( pDest->u.i<0 ); | |
| 99217 | + break; | |
| 99218 | + case 6: { | |
| 99219 | + pDest->u.i = (i64)sqlite3Get8byte(zData); | |
| 99220 | + pDest->flags = MEM_Int; | |
| 99221 | + testcase( pDest->u.i<0 ); | |
| 99222 | + break; | |
| 99223 | + } | |
| 99224 | + case 7: { | |
| 99225 | + u64 x = sqlite3Get8byte(zData); | |
| 99226 | + swapMixedEndianFloat(x); | |
| 99227 | + pDest->flags = IsNaN(x) ? MEM_Null : MEM_Real; | |
| 99228 | + memcpy(&pDest->u.r, &x, sizeof(x)); | |
| 99229 | + testcase( pDest->u.r<0 ); | |
| 99230 | + break; | |
| 99231 | + } | |
| 99232 | + case 8: | |
| 99233 | + case 9: { | |
| 99234 | + pDest->u.i = t-8; | |
| 99235 | + pDest->flags = MEM_Int; | |
| 99236 | + break; | |
| 99237 | + } | |
| 99238 | + case 10: | |
| 99239 | + /* Internal use only: NULL with virtual table | |
| 99240 | + ** UPDATE no-change flag set */ | |
| 99241 | + pDest->flags = MEM_Null|MEM_Zero; | |
| 99242 | + pDest->u.nZero = 0; | |
| 99243 | + pDest->n = 0; | |
| 99244 | + break; | |
| 99245 | + default: { | |
| 99246 | + /* If the column value is a string or blob, we need a persistent | |
| 99247 | + ** value, not a MEM_Ephem value. This case is a fast short-cut | |
| 99248 | + ** that is equivalent to calling sqlite3VdbeSerialGet() and | |
| 99249 | + ** sqlite3VdbeDeephemeralize(). | |
| 99250 | + */ | |
| 99251 | + static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; | |
| 99252 | + pDest->n = len = (t-12)/2; | |
| 99253 | + pDest->enc = encoding; | |
| 99254 | + if( pDest->szMalloc < len+2 ){ | |
| 99255 | + if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big; | |
| 99256 | + pDest->flags = MEM_Null; | |
| 99257 | + if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; | |
| 99258 | + }else{ | |
| 99259 | + pDest->z = pDest->zMalloc; | |
| 99260 | + } | |
| 99261 | + memcpy(pDest->z, zData, len); | |
| 99262 | + pDest->z[len] = 0; | |
| 99263 | + pDest->z[len+1] = 0; | |
| 99264 | + pDest->flags = aFlag[t&1]; | |
| 99265 | + } | |
| 99266 | + } /* End of switch */ | |
| 99179 | 99267 | }else{ |
| 99180 | 99268 | u8 p5; |
| 99181 | 99269 | pDest->enc = encoding; |
| 99182 | 99270 | assert( pDest->db==db ); |
| 99183 | 99271 | /* This branch happens only when content is on overflow pages */ |
| @@ -99640,27 +99728,39 @@ | ||
| 99640 | 99728 | nVarint = sqlite3VarintLen(nHdr); |
| 99641 | 99729 | nHdr += nVarint; |
| 99642 | 99730 | if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++; |
| 99643 | 99731 | } |
| 99644 | 99732 | nByte = nHdr+nData; |
| 99733 | + | |
| 99734 | + /* If we are able to put an over-run area of 7 bytes on the end of the | |
| 99735 | + ** memory allocation into which the record is being constructed, then | |
| 99736 | + ** the encoding of integer values can go faster. This is only possible | |
| 99737 | + ** if SQLITE_MAX_LENGTH is no with 7 of INT32_MAX and if the host CPU | |
| 99738 | + ** byte-order is known at compile-time. | |
| 99739 | + */ | |
| 99740 | +#if SQLITE_MAX_LENGTH<=2147483640 && SQLITE_BYTEORDER>0 | |
| 99741 | +# define OVERRUN 7 /* We are able to allocate an overrun of 7 bytes */ | |
| 99742 | +#else | |
| 99743 | +# define OVERRUN 0 /* No overrun will be available */ | |
| 99744 | +#endif | |
| 99645 | 99745 | |
| 99646 | 99746 | /* Make sure the output register has a buffer large enough to store |
| 99647 | 99747 | ** the new record. The output register (pOp->p3) is not allowed to |
| 99648 | 99748 | ** be one of the input registers (because the following call to |
| 99649 | 99749 | ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). |
| 99650 | 99750 | */ |
| 99651 | - if( nByte+nZero<=pOut->szMalloc ){ | |
| 99751 | + if( nByte+nZero<=pOut->szMalloc-OVERRUN ){ | |
| 99652 | 99752 | /* The output register is already large enough to hold the record. |
| 99653 | 99753 | ** No error checks or buffer enlargement is required */ |
| 99654 | 99754 | pOut->z = pOut->zMalloc; |
| 99655 | 99755 | }else{ |
| 99656 | 99756 | /* Need to make sure that the output is not too big and then enlarge |
| 99657 | 99757 | ** the output register to hold the full result */ |
| 99658 | 99758 | if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 99659 | 99759 | goto too_big; |
| 99660 | 99760 | } |
| 99661 | - if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){ | |
| 99761 | + if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte+OVERRUN) ){ | |
| 99662 | 99762 | goto no_mem; |
| 99663 | 99763 | } |
| 99664 | 99764 | } |
| 99665 | 99765 | pOut->n = (int)nByte; |
| 99666 | 99766 | pOut->flags = MEM_Blob; |
| @@ -99699,10 +99799,31 @@ | ||
| 99699 | 99799 | }else{ |
| 99700 | 99800 | v = pRec->u.i; |
| 99701 | 99801 | } |
| 99702 | 99802 | len = sqlite3SmallTypeSizes[serial_type]; |
| 99703 | 99803 | assert( len>=1 && len<=8 && len!=5 && len!=7 ); |
| 99804 | +#if SQLITE_BYTEORDER==1234 | |
| 99805 | + v = sqlite3BSwap64(v); | |
| 99806 | + if( OVERRUN ){ | |
| 99807 | + static const u8 aShift[] = { 0, 56, 48, 40, 32, 16, 0, 0 }; | |
| 99808 | + v >>= aShift[serial_type]; | |
| 99809 | + memcpy(zPayload, &v, 8); | |
| 99810 | + }else{ | |
| 99811 | + /* Test this limb by compiling with -DSQLITE_MAX_LENGTH=2147483647 */ | |
| 99812 | + memcpy(zPayload, (u8*)&v + 8 - len, len); | |
| 99813 | + } | |
| 99814 | +#elif SQLITE_BYTEORDER==4321 | |
| 99815 | + if( OVERRUN ){ | |
| 99816 | + static const u8 aShift[] = { 0, 56, 48, 40, 32, 16, 0, 0 }; | |
| 99817 | + v <<= aShift[serial_type]; | |
| 99818 | + memcpy(zPayload, &v, 8); | |
| 99819 | + }else{ | |
| 99820 | + /* Test this limb by compiling with -DSQLITE_MAX_LENGTH=2147483647 */ | |
| 99821 | + memcpy(zPayload, (u8*)&v + 8 - len, len); | |
| 99822 | + } | |
| 99823 | +#else | |
| 99824 | + /* Test this limb by compiling with -DSQLITE_BYTEORDER=0 */ | |
| 99704 | 99825 | switch( len ){ |
| 99705 | 99826 | default: zPayload[7] = (u8)(v&0xff); v >>= 8; |
| 99706 | 99827 | zPayload[6] = (u8)(v&0xff); v >>= 8; |
| 99707 | 99828 | /* no break */ deliberate_fall_through |
| 99708 | 99829 | case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; |
| @@ -99714,10 +99835,12 @@ | ||
| 99714 | 99835 | /* no break */ deliberate_fall_through |
| 99715 | 99836 | case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; |
| 99716 | 99837 | /* no break */ deliberate_fall_through |
| 99717 | 99838 | case 1: zPayload[0] = (u8)(v&0xff); |
| 99718 | 99839 | } |
| 99840 | +#endif | |
| 99841 | +#undef OVERRUN /* We are done with the OVERRUN macro now */ | |
| 99719 | 99842 | zPayload += len; |
| 99720 | 99843 | } |
| 99721 | 99844 | }else if( serial_type<0x80 ){ |
| 99722 | 99845 | *(zHdr++) = serial_type; |
| 99723 | 99846 | if( serial_type>=14 && pRec->n>0 ){ |
| @@ -106883,45 +107006,10 @@ | ||
| 106883 | 107006 | res = res * -1; |
| 106884 | 107007 | } |
| 106885 | 107008 | return res; |
| 106886 | 107009 | } |
| 106887 | 107010 | |
| 106888 | -/* Helper function for vdbeSorterCompareReal(). | |
| 106889 | -** | |
| 106890 | -** Read the bits of an 8-byte big-endian IEEE-754 value and store them | |
| 106891 | -** into a u64. Do any necessary byte-swapping so that the bits are in | |
| 106892 | -** the right order for the host machine. | |
| 106893 | -** | |
| 106894 | -** Copied and slightly modified from the readInt64() routine in rtree.c | |
| 106895 | -*/ | |
| 106896 | -static u64 vdbeSorterDecodeU64(const u8 *p){ | |
| 106897 | -#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 | |
| 106898 | - u64 x; | |
| 106899 | - memcpy(&x, p, 8); | |
| 106900 | - return _byteswap_uint64(x); | |
| 106901 | -#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 | |
| 106902 | - u64 x; | |
| 106903 | - memcpy(&x, p, 8); | |
| 106904 | - return __builtin_bswap64(x); | |
| 106905 | -#elif SQLITE_BYTEORDER==4321 | |
| 106906 | - i64 x; | |
| 106907 | - memcpy(&x, p, 8); | |
| 106908 | - return x; | |
| 106909 | -#else | |
| 106910 | - return (i64)( | |
| 106911 | - (((u64)p[0]) << 56) + | |
| 106912 | - (((u64)p[1]) << 48) + | |
| 106913 | - (((u64)p[2]) << 40) + | |
| 106914 | - (((u64)p[3]) << 32) + | |
| 106915 | - (((u64)p[4]) << 24) + | |
| 106916 | - (((u64)p[5]) << 16) + | |
| 106917 | - (((u64)p[6]) << 8) + | |
| 106918 | - (((u64)p[7]) << 0) | |
| 106919 | - ); | |
| 106920 | -#endif | |
| 106921 | -} | |
| 106922 | - | |
| 106923 | 107011 | /* Helper function for vdbeSorterCompareReal(). |
| 106924 | 107012 | ** |
| 106925 | 107013 | ** Buffer p[] is a record where the first term is guaranteed to be either |
| 106926 | 107014 | ** a floating-point value, or an integer stand-in for a floating point |
| 106927 | 107015 | ** value (a MEM_IntReal). Whatever its format, extract the value and |
| @@ -106932,11 +107020,11 @@ | ||
| 106932 | 107020 | |
| 106933 | 107021 | assert( p[0]<0x80 ); /* 1-byte headers: nAllField<13 */ |
| 106934 | 107022 | assert( p[1]>0 && p[1]<10 ); /* first fields proven numeric */ |
| 106935 | 107023 | |
| 106936 | 107024 | if( p[1]==7 ){ |
| 106937 | - u64 x = vdbeSorterDecodeU64(p + p[0]); | |
| 107025 | + u64 x = sqlite3Get8byte(p + p[0]); | |
| 106938 | 107026 | swapMixedEndianFloat(x); |
| 106939 | 107027 | assert( !IsNaN(x) ); |
| 106940 | 107028 | memcpy(&r, &x, sizeof(r)); |
| 106941 | 107029 | }else{ |
| 106942 | 107030 | Mem m; |
| @@ -107012,15 +107100,15 @@ | ||
| 107012 | 107100 | pbKey2Cached, pKey1,nKey1, pKey2,nKey2 |
| 107013 | 107101 | ); |
| 107014 | 107102 | } |
| 107015 | 107103 | assert( p1[0]<=nKey1-8 && p2[0]<=nKey2-8 ); |
| 107016 | 107104 | |
| 107017 | - x = vdbeSorterDecodeU64(p1 + *p1); | |
| 107105 | + x = sqlite3Get8byte(p1 + *p1); | |
| 107018 | 107106 | swapMixedEndianFloat(x); |
| 107019 | 107107 | assert( !IsNaN(x) ); |
| 107020 | 107108 | memcpy(&r1, &x, sizeof(r1)); |
| 107021 | - x = vdbeSorterDecodeU64(p2 + *p2); | |
| 107109 | + x = sqlite3Get8byte(p2 + *p2); | |
| 107022 | 107110 | swapMixedEndianFloat(x); |
| 107023 | 107111 | assert( !IsNaN(x) ); |
| 107024 | 107112 | memcpy(&r2, &x, sizeof(r2)); |
| 107025 | 107113 | return vdbeSorterFinishRealCompare(pTask, |
| 107026 | 107114 | pbKey2Cached, pKey1,nKey1, pKey2,nKey2, r1, r2 |
| @@ -113105,10 +113193,11 @@ | ||
| 113105 | 113193 | static int exprVectorRegister( |
| 113106 | 113194 | Parse *pParse, /* Parse context */ |
| 113107 | 113195 | Expr *pVector, /* Vector to extract element from */ |
| 113108 | 113196 | int iField, /* Field to extract from pVector */ |
| 113109 | 113197 | int regSelect, /* First in array of registers */ |
| 113198 | + Expr *pTmp, /* Temporary space */ | |
| 113110 | 113199 | Expr **ppExpr, /* OUT: Expression element */ |
| 113111 | 113200 | int *pRegFree /* OUT: Temp register to free */ |
| 113112 | 113201 | ){ |
| 113113 | 113202 | u8 op = pVector->op; |
| 113114 | 113203 | assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR ); |
| @@ -113116,12 +113205,21 @@ | ||
| 113116 | 113205 | *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField); |
| 113117 | 113206 | return pVector->iTable+iField; |
| 113118 | 113207 | } |
| 113119 | 113208 | if( op==TK_SELECT ){ |
| 113120 | 113209 | assert( ExprUseXSelect(pVector) ); |
| 113121 | - *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; | |
| 113122 | - return regSelect+iField; | |
| 113210 | + /* Use the temporary expression node to wrap expression iField of the | |
| 113211 | + ** sub-select in a TK_SELECT_COLUMN node. This causes the caller to | |
| 113212 | + ** use the affinity of the expression in any comparison, but not the | |
| 113213 | + ** collation sequence. */ | |
| 113214 | + memset(pTmp, 0, sizeof(Expr)); | |
| 113215 | + pTmp->op = TK_SELECT_COLUMN; | |
| 113216 | + pTmp->pLeft = pVector; | |
| 113217 | + pTmp->iColumn = iField; | |
| 113218 | + pTmp->iTable = pVector->x.pSelect->pEList->nExpr; | |
| 113219 | + *ppExpr = pTmp; | |
| 113220 | + return regSelect+iField; | |
| 113123 | 113221 | } |
| 113124 | 113222 | if( op==TK_VECTOR ){ |
| 113125 | 113223 | assert( ExprUseXList(pVector) ); |
| 113126 | 113224 | *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 113127 | 113225 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); |
| @@ -113184,15 +113282,16 @@ | ||
| 113184 | 113282 | |
| 113185 | 113283 | sqlite3VdbeAddOp2(v, OP_Integer, 1, dest); |
| 113186 | 113284 | for(i=0; 1 /*Loop exits by "break"*/; i++){ |
| 113187 | 113285 | int regFree1 = 0, regFree2 = 0; |
| 113188 | 113286 | Expr *pL = 0, *pR = 0; |
| 113287 | + Expr tmp1, tmp2; | |
| 113189 | 113288 | int r1, r2; |
| 113190 | 113289 | assert( i>=0 && i<nLeft ); |
| 113191 | 113290 | if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp); |
| 113192 | - r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, ®Free1); | |
| 113193 | - r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, ®Free2); | |
| 113291 | + r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &tmp1, &pL, ®Free1); | |
| 113292 | + r2 = exprVectorRegister(pParse, pRight, i, regRight, &tmp2, &pR, ®Free2); | |
| 113194 | 113293 | addrCmp = sqlite3VdbeCurrentAddr(v); |
| 113195 | 113294 | codeCompare(pParse, pL, pR, opx, r1, r2, addrDone, p5, isCommuted); |
| 113196 | 113295 | testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 113197 | 113296 | testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| 113198 | 113297 | testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); |
| @@ -146405,14 +146504,13 @@ | ||
| 146405 | 146504 | assert( sqlite3SchemaMutexHeld(db, i, 0) ); |
| 146406 | 146505 | pTbls = &db->aDb[i].pSchema->tblHash; |
| 146407 | 146506 | for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ |
| 146408 | 146507 | Table *pTab = sqliteHashData(x); /* Current table */ |
| 146409 | 146508 | Index *pIdx; /* An index on pTab */ |
| 146410 | - int nIdx; /* Number of indexes on pTab */ | |
| 146411 | 146509 | if( tableSkipIntegrityCheck(pTab,pObjTab) ) continue; |
| 146412 | 146510 | if( HasRowid(pTab) ) cnt++; |
| 146413 | - for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; } | |
| 146511 | + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ cnt++; } | |
| 146414 | 146512 | } |
| 146415 | 146513 | if( cnt==0 ) continue; |
| 146416 | 146514 | if( pObjTab ) cnt++; |
| 146417 | 146515 | aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1)); |
| 146418 | 146516 | if( aRoot==0 ) break; |
| @@ -219069,11 +219167,11 @@ | ||
| 219069 | 219167 | ** Macros to determine whether the machine is big or little endian, |
| 219070 | 219168 | ** and whether or not that determination is run-time or compile-time. |
| 219071 | 219169 | ** |
| 219072 | 219170 | ** For best performance, an attempt is made to guess at the byte-order |
| 219073 | 219171 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 219074 | -** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined | |
| 219172 | +** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined | |
| 219075 | 219173 | ** at run-time. |
| 219076 | 219174 | */ |
| 219077 | 219175 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 219078 | 219176 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 219079 | 219177 | # define SQLITE_BYTEORDER 4321 |
| @@ -219125,12 +219223,15 @@ | ||
| 219125 | 219223 | (((u32)p[2]) << 8) + |
| 219126 | 219224 | (((u32)p[3]) << 0) |
| 219127 | 219225 | ); |
| 219128 | 219226 | #endif |
| 219129 | 219227 | } |
| 219228 | + | |
| 219130 | 219229 | static i64 readInt64(u8 *p){ |
| 219131 | -#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 | |
| 219230 | +#if defined(SQLITE_AMALGAMATION) | |
| 219231 | + return (i64)sqlite3Get8byte(p); | |
| 219232 | +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 | |
| 219132 | 219233 | u64 x; |
| 219133 | 219234 | memcpy(&x, p, 8); |
| 219134 | 219235 | return (i64)_byteswap_uint64(x); |
| 219135 | 219236 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 219136 | 219237 | u64 x; |
| @@ -233187,11 +233288,11 @@ | ||
| 233187 | 233288 | zErr = "no such schema"; |
| 233188 | 233289 | goto update_fail; |
| 233189 | 233290 | } |
| 233190 | 233291 | } |
| 233191 | 233292 | pBt = pTab->db->aDb[iDb].pBt; |
| 233192 | - if( pgno64<1 || pgno64>4294967294 || NEVER(pBt==0) ){ | |
| 233293 | + if( pgno64<1 || pgno64>4294967294U || NEVER(pBt==0) ){ | |
| 233193 | 233294 | zErr = "bad page number"; |
| 233194 | 233295 | goto update_fail; |
| 233195 | 233296 | } |
| 233196 | 233297 | pgno = (Pgno)pgno64; |
| 233197 | 233298 | szPage = sqlite3BtreeGetPageSize(pBt); |
| @@ -239398,11 +239499,11 @@ | ||
| 239398 | 239499 | |
| 239399 | 239500 | iUpdate++; |
| 239400 | 239501 | if( rc==SQLITE_OK ){ |
| 239401 | 239502 | sqlite3_step(pInsert); |
| 239402 | 239503 | rc = sqlite3_finalize(pInsert); |
| 239403 | - if( rc==SQLITE_CONSTRAINT ){ | |
| 239504 | + if( (rc&0xff)==SQLITE_CONSTRAINT ){ | |
| 239404 | 239505 | rc = sqlite3_exec(db, "ROLLBACK TO update_op", 0, 0, 0); |
| 239405 | 239506 | sqlite3_free(pApply->constraints.aBuf); |
| 239406 | 239507 | pApply->constraints = cons; |
| 239407 | 239508 | memset(&cons, 0, sizeof(cons)); |
| 239408 | 239509 | }else if( rc==SQLITE_OK ){ |
| @@ -264171,11 +264272,11 @@ | ||
| 264171 | 264272 | int nArg, /* Number of args */ |
| 264172 | 264273 | sqlite3_value **apUnused /* Function arguments */ |
| 264173 | 264274 | ){ |
| 264174 | 264275 | assert( nArg==0 ); |
| 264175 | 264276 | UNUSED_PARAM2(nArg, apUnused); |
| 264176 | - sqlite3_result_text(pCtx, "fts5: 2026-08-04 14:55:51 bdc841de10fef65b627deb8b770702c976174a66af847c96ebecf24d91798744", -1, SQLITE_TRANSIENT); | |
| 264277 | + sqlite3_result_text(pCtx, "fts5: 2026-08-11 10:46:12 fee71cd6f7294ffd02784d26811a9d11d80e83d4075e1233b8ec0289519bb891", -1, SQLITE_TRANSIENT); | |
| 264177 | 264278 | } |
| 264178 | 264279 | |
| 264179 | 264280 | /* |
| 264180 | 264281 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 264181 | 264282 | ** |
| 264182 | 264283 |
| --- 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 | ** 6bdfff7ddb63d0b4f28f6c174a36e81486a6 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.54.0" |
| 471 | #define SQLITE_VERSION_NUMBER 3054000 |
| 472 | #define SQLITE_SOURCE_ID "2026-08-04 20:40:10 6bdfff7ddb63d0b4f28f6c174a36e81486a652056a4e21644378a22feda780fd" |
| 473 | #define SQLITE_SCM_BRANCH "trunk" |
| 474 | #define SQLITE_SCM_TAGS "" |
| 475 | #define SQLITE_SCM_DATETIME "2026-08-04T20:40:10.440Z" |
| 476 | |
| 477 | /* |
| 478 | ** CAPI3REF: Run-Time Library Version Numbers |
| 479 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 480 | ** |
| @@ -15135,26 +15135,41 @@ | |
| 15135 | # define SQLITE_INT_TO_PTR(X) ((void*)(X)) |
| 15136 | # define SQLITE_PTR_TO_INT(X) ((int)(X)) |
| 15137 | #endif |
| 15138 | |
| 15139 | /* |
| 15140 | ** Macros to hint to the compiler that a function should or should not be |
| 15141 | ** inlined. |
| 15142 | */ |
| 15143 | #if defined(__GNUC__) |
| 15144 | # define SQLITE_NOINLINE __attribute__((noinline)) |
| 15145 | # define SQLITE_INLINE __attribute__((always_inline)) inline |
| 15146 | #elif defined(_MSC_VER) && _MSC_VER>=1310 |
| 15147 | # define SQLITE_NOINLINE __declspec(noinline) |
| 15148 | # define SQLITE_INLINE __forceinline |
| 15149 | #else |
| 15150 | # define SQLITE_NOINLINE |
| 15151 | # define SQLITE_INLINE |
| 15152 | #endif |
| 15153 | #if defined(SQLITE_COVERAGE_TEST) || defined(__STRICT_ANSI__) |
| 15154 | # undef SQLITE_INLINE |
| 15155 | # define SQLITE_INLINE |
| 15156 | #endif |
| 15157 | |
| 15158 | /* |
| 15159 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 15160 | ** compiling with an appropriate version of MSVC unless prevented by |
| @@ -22989,10 +23004,14 @@ | |
| 22989 | #define sqlite3ExprCheckHeight(x,y) |
| 22990 | #endif |
| 22991 | SQLITE_PRIVATE void sqlite3ExprSetErrorOffset(Expr*,int); |
| 22992 | |
| 22993 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8*); |
| 22994 | SQLITE_PRIVATE void sqlite3Put4byte(u8*, u32); |
| 22995 | |
| 22996 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 22997 | SQLITE_PRIVATE void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *); |
| 22998 | SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db); |
| @@ -25051,10 +25070,21 @@ | |
| 25051 | */ |
| 25052 | #ifndef SQLITE_AMALGAMATION |
| 25053 | SQLITE_PRIVATE const u8 sqlite3SmallTypeSizes[]; |
| 25054 | #endif |
| 25055 | |
| 25056 | /* |
| 25057 | ** Function prototypes |
| 25058 | */ |
| 25059 | SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...); |
| 25060 | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*); |
| @@ -38533,11 +38563,11 @@ | |
| 38533 | return i; |
| 38534 | } |
| 38535 | |
| 38536 | |
| 38537 | /* |
| 38538 | ** Read or write a four-byte big-endian integer value. |
| 38539 | */ |
| 38540 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 38541 | #if SQLITE_BYTEORDER==4321 |
| 38542 | u32 x; |
| 38543 | memcpy(&x,p,4); |
| @@ -38549,14 +38579,18 @@ | |
| 38549 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38550 | u32 x; |
| 38551 | memcpy(&x,p,4); |
| 38552 | return _byteswap_ulong(x); |
| 38553 | #else |
| 38554 | testcase( p[0]&0x80 ); |
| 38555 | return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 38556 | #endif |
| 38557 | } |
| 38558 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 38559 | #if SQLITE_BYTEORDER==4321 |
| 38560 | memcpy(p,&v,4); |
| 38561 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 38562 | u32 x = __builtin_bswap32(v); |
| @@ -38563,18 +38597,70 @@ | |
| 38563 | memcpy(p,&x,4); |
| 38564 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38565 | u32 x = _byteswap_ulong(v); |
| 38566 | memcpy(p,&x,4); |
| 38567 | #else |
| 38568 | p[0] = (u8)(v>>24); |
| 38569 | p[1] = (u8)(v>>16); |
| 38570 | p[2] = (u8)(v>>8); |
| 38571 | p[3] = (u8)v; |
| 38572 | #endif |
| 38573 | } |
| 38574 | |
| 38575 | |
| 38576 | |
| 38577 | /* |
| 38578 | ** Translate a single byte of Hex into an integer. |
| 38579 | ** This routine only works if h really is a valid hexadecimal |
| 38580 | ** character: 0..9a..fA..F |
| @@ -57862,12 +57948,15 @@ | |
| 57862 | int createFlag |
| 57863 | ){ |
| 57864 | PCache1 *pCache = (PCache1 *)p; |
| 57865 | PgHdr1 *pPage = 0; |
| 57866 | |
| 57867 | /* Step 1: Search the hash table for an existing entry. */ |
| 57868 | pPage = pCache->apHash[iKey % pCache->nHash]; |
| 57869 | while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; } |
| 57870 | |
| 57871 | /* Step 2: If the page was found in the hash table, then return it. |
| 57872 | ** If the page was not in the hash table and createFlag is 0, abort. |
| 57873 | ** Otherwise (page not in hash and createFlag!=0) continue with |
| @@ -91159,71 +91248,20 @@ | |
| 91159 | u.i[1] = t; |
| 91160 | return u.r; |
| 91161 | } |
| 91162 | #endif /* SQLITE_MIXED_ENDIAN_64BIT_FLOAT */ |
| 91163 | |
| 91164 | |
| 91165 | /* Input "x" is a sequence of unsigned characters that represent a |
| 91166 | ** big-endian integer. Return the equivalent native integer |
| 91167 | */ |
| 91168 | #define ONE_BYTE_INT(x) ((i8)(x)[0]) |
| 91169 | #define TWO_BYTE_INT(x) (256*(i8)((x)[0])|(x)[1]) |
| 91170 | #define THREE_BYTE_INT(x) (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2]) |
| 91171 | #define FOUR_BYTE_UINT(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| 91172 | #define FOUR_BYTE_INT(x) (16777216*(i8)((x)[0])|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| 91173 | |
| 91174 | /* |
| 91175 | ** Deserialize the data blob pointed to by buf as serial type serial_type |
| 91176 | ** and store the result in pMem. |
| 91177 | ** |
| 91178 | ** This function is implemented as two separate routines for performance. |
| 91179 | ** The few cases that require local variables are broken out into a separate |
| 91180 | ** routine so that in most cases the overhead of moving the stack pointer |
| 91181 | ** is avoided. |
| 91182 | */ |
| 91183 | static void serialGet( |
| 91184 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 91185 | u32 serial_type, /* Serial type to deserialize */ |
| 91186 | Mem *pMem /* Memory cell to write value into */ |
| 91187 | ){ |
| 91188 | u64 x = FOUR_BYTE_UINT(buf); |
| 91189 | u32 y = FOUR_BYTE_UINT(buf+4); |
| 91190 | x = (x<<32) + y; |
| 91191 | if( serial_type==6 ){ |
| 91192 | /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit |
| 91193 | ** twos-complement integer. */ |
| 91194 | pMem->u.i = *(i64*)&x; |
| 91195 | pMem->flags = MEM_Int; |
| 91196 | testcase( pMem->u.i<0 ); |
| 91197 | }else{ |
| 91198 | /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit |
| 91199 | ** floating point number. */ |
| 91200 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 91201 | /* Verify that integers and floating point values use the same |
| 91202 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 91203 | ** defined that 64-bit floating point values really are mixed |
| 91204 | ** endian. |
| 91205 | */ |
| 91206 | static const u64 t1 = ((u64)0x3ff00000)<<32; |
| 91207 | static const double r1 = 1.0; |
| 91208 | u64 t2 = t1; |
| 91209 | swapMixedEndianFloat(t2); |
| 91210 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 91211 | #endif |
| 91212 | assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 ); |
| 91213 | swapMixedEndianFloat(x); |
| 91214 | memcpy(&pMem->u.r, &x, sizeof(x)); |
| 91215 | pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real; |
| 91216 | } |
| 91217 | } |
| 91218 | static int serialGet7( |
| 91219 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 91220 | Mem *pMem /* Memory cell to write value into */ |
| 91221 | ){ |
| 91222 | u64 x = FOUR_BYTE_UINT(buf); |
| 91223 | u32 y = FOUR_BYTE_UINT(buf+4); |
| 91224 | x = (x<<32) + y; |
| 91225 | assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 ); |
| 91226 | swapMixedEndianFloat(x); |
| 91227 | memcpy(&pMem->u.r, &x, sizeof(x)); |
| 91228 | if( IsNaN(x) ){ |
| 91229 | pMem->flags = MEM_Null; |
| @@ -91230,10 +91268,17 @@ | |
| 91230 | return 1; |
| 91231 | } |
| 91232 | pMem->flags = MEM_Real; |
| 91233 | return 0; |
| 91234 | } |
| 91235 | SQLITE_PRIVATE void sqlite3VdbeSerialGet( |
| 91236 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 91237 | u32 serial_type, /* Serial type to deserialize */ |
| 91238 | Mem *pMem /* Memory cell to write value into */ |
| 91239 | ){ |
| @@ -91288,20 +91333,25 @@ | |
| 91288 | return; |
| 91289 | } |
| 91290 | case 5: { /* 6-byte signed integer */ |
| 91291 | /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit |
| 91292 | ** twos-complement integer. */ |
| 91293 | pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf); |
| 91294 | pMem->flags = MEM_Int; |
| 91295 | testcase( pMem->u.i<0 ); |
| 91296 | return; |
| 91297 | } |
| 91298 | case 6: /* 8-byte signed integer */ |
| 91299 | case 7: { /* IEEE floating point */ |
| 91300 | /* These use local variables, so do them in a separate routine |
| 91301 | ** to avoid having to move the frame pointer in the common case */ |
| 91302 | serialGet(buf,serial_type,pMem); |
| 91303 | return; |
| 91304 | } |
| 91305 | case 8: /* Integer 0 */ |
| 91306 | case 9: { /* Integer 1 */ |
| 91307 | /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */ |
| @@ -91903,11 +91953,11 @@ | |
| 91903 | if( serial_type>=10 ){ |
| 91904 | rc = serial_type==10 ? -1 : +1; |
| 91905 | }else if( serial_type==0 ){ |
| 91906 | rc = -1; |
| 91907 | }else if( serial_type==7 ){ |
| 91908 | serialGet7(&aKey1[d1], &mem1); |
| 91909 | rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r); |
| 91910 | }else{ |
| 91911 | i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]); |
| 91912 | i64 rhs = pRhs->u.i; |
| 91913 | if( lhs<rhs ){ |
| @@ -91929,11 +91979,11 @@ | |
| 91929 | rc = serial_type==10 ? -1 : +1; |
| 91930 | }else if( serial_type==0 ){ |
| 91931 | rc = -1; |
| 91932 | }else{ |
| 91933 | if( serial_type==7 ){ |
| 91934 | if( serialGet7(&aKey1[d1], &mem1) ){ |
| 91935 | rc = -1; /* mem1 is a NaN */ |
| 91936 | }else if( mem1.u.r<pRhs->u.r ){ |
| 91937 | rc = -1; |
| 91938 | }else if( mem1.u.r>pRhs->u.r ){ |
| 91939 | rc = +1; |
| @@ -92011,11 +92061,11 @@ | |
| 92011 | /* RHS is null */ |
| 92012 | else{ |
| 92013 | serial_type = aKey1[idx1]; |
| 92014 | if( serial_type==0 |
| 92015 | || serial_type==10 |
| 92016 | || (serial_type==7 && serialGet7(&aKey1[d1], &mem1)!=0) |
| 92017 | ){ |
| 92018 | assert( rc==0 ); |
| 92019 | }else{ |
| 92020 | rc = 1; |
| 92021 | } |
| @@ -92085,69 +92135,46 @@ | |
| 92085 | UnpackedRecord *pPKey2 /* Right key */ |
| 92086 | ){ |
| 92087 | const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F]; |
| 92088 | int serial_type = ((const u8*)pKey1)[1]; |
| 92089 | int res; |
| 92090 | u32 y; |
| 92091 | u64 x; |
| 92092 | i64 v; |
| 92093 | i64 lhs; |
| 92094 | |
| 92095 | vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo); |
| 92096 | assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB ); |
| 92097 | switch( serial_type ){ |
| 92098 | case 1: { /* 1-byte signed integer */ |
| 92099 | lhs = ONE_BYTE_INT(aKey); |
| 92100 | testcase( lhs<0 ); |
| 92101 | break; |
| 92102 | } |
| 92103 | case 2: { /* 2-byte signed integer */ |
| 92104 | lhs = TWO_BYTE_INT(aKey); |
| 92105 | testcase( lhs<0 ); |
| 92106 | break; |
| 92107 | } |
| 92108 | case 3: { /* 3-byte signed integer */ |
| 92109 | lhs = THREE_BYTE_INT(aKey); |
| 92110 | testcase( lhs<0 ); |
| 92111 | break; |
| 92112 | } |
| 92113 | case 4: { /* 4-byte signed integer */ |
| 92114 | y = FOUR_BYTE_UINT(aKey); |
| 92115 | lhs = (i64)*(int*)&y; |
| 92116 | testcase( lhs<0 ); |
| 92117 | break; |
| 92118 | } |
| 92119 | case 5: { /* 6-byte signed integer */ |
| 92120 | lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey); |
| 92121 | testcase( lhs<0 ); |
| 92122 | break; |
| 92123 | } |
| 92124 | case 6: { /* 8-byte signed integer */ |
| 92125 | x = FOUR_BYTE_UINT(aKey); |
| 92126 | x = (x<<32) | FOUR_BYTE_UINT(aKey+4); |
| 92127 | lhs = *(i64*)&x; |
| 92128 | testcase( lhs<0 ); |
| 92129 | break; |
| 92130 | } |
| 92131 | case 8: |
| 92132 | lhs = 0; |
| 92133 | break; |
| 92134 | case 9: |
| 92135 | lhs = 1; |
| 92136 | break; |
| 92137 | |
| 92138 | /* This case could be removed without changing the results of running |
| 92139 | ** this code. Including it causes gcc to generate a faster switch |
| 92140 | ** statement (since the range of switch targets now starts at zero and |
| 92141 | ** is contiguous) but does not cause any duplicate code to be generated |
| 92142 | ** (as gcc is clever enough to combine the two like cases). Other |
| 92143 | ** compilers might be similar. */ |
| 92144 | case 0: case 7: |
| 92145 | return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2); |
| 92146 | |
| 92147 | default: |
| 92148 | return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2); |
| 92149 | } |
| 92150 | |
| 92151 | assert( pPKey2->u.i == pPKey2->aMem[0].u.i ); |
| 92152 | v = pPKey2->u.i; |
| 92153 | if( v>lhs ){ |
| @@ -99150,34 +99177,95 @@ | |
| 99150 | sqlite3VdbeMemSetNull(pDest); |
| 99151 | } |
| 99152 | assert( t==pC->aType[p2] ); |
| 99153 | if( pC->szRow>=aOffset[p2+1] ){ |
| 99154 | /* This is the common case where the desired content fits on the original |
| 99155 | ** page - where the content is not on an overflow page */ |
| 99156 | zData = pC->aRow + aOffset[p2]; |
| 99157 | if( t<12 ){ |
| 99158 | sqlite3VdbeSerialGet(zData, t, pDest); |
| 99159 | }else{ |
| 99160 | /* If the column value is a string, we need a persistent value, not |
| 99161 | ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent |
| 99162 | ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize(). |
| 99163 | */ |
| 99164 | static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; |
| 99165 | pDest->n = len = (t-12)/2; |
| 99166 | pDest->enc = encoding; |
| 99167 | if( pDest->szMalloc < len+2 ){ |
| 99168 | if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big; |
| 99169 | pDest->flags = MEM_Null; |
| 99170 | if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; |
| 99171 | }else{ |
| 99172 | pDest->z = pDest->zMalloc; |
| 99173 | } |
| 99174 | memcpy(pDest->z, zData, len); |
| 99175 | pDest->z[len] = 0; |
| 99176 | pDest->z[len+1] = 0; |
| 99177 | pDest->flags = aFlag[t&1]; |
| 99178 | } |
| 99179 | }else{ |
| 99180 | u8 p5; |
| 99181 | pDest->enc = encoding; |
| 99182 | assert( pDest->db==db ); |
| 99183 | /* This branch happens only when content is on overflow pages */ |
| @@ -99640,27 +99728,39 @@ | |
| 99640 | nVarint = sqlite3VarintLen(nHdr); |
| 99641 | nHdr += nVarint; |
| 99642 | if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++; |
| 99643 | } |
| 99644 | nByte = nHdr+nData; |
| 99645 | |
| 99646 | /* Make sure the output register has a buffer large enough to store |
| 99647 | ** the new record. The output register (pOp->p3) is not allowed to |
| 99648 | ** be one of the input registers (because the following call to |
| 99649 | ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). |
| 99650 | */ |
| 99651 | if( nByte+nZero<=pOut->szMalloc ){ |
| 99652 | /* The output register is already large enough to hold the record. |
| 99653 | ** No error checks or buffer enlargement is required */ |
| 99654 | pOut->z = pOut->zMalloc; |
| 99655 | }else{ |
| 99656 | /* Need to make sure that the output is not too big and then enlarge |
| 99657 | ** the output register to hold the full result */ |
| 99658 | if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 99659 | goto too_big; |
| 99660 | } |
| 99661 | if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){ |
| 99662 | goto no_mem; |
| 99663 | } |
| 99664 | } |
| 99665 | pOut->n = (int)nByte; |
| 99666 | pOut->flags = MEM_Blob; |
| @@ -99699,10 +99799,31 @@ | |
| 99699 | }else{ |
| 99700 | v = pRec->u.i; |
| 99701 | } |
| 99702 | len = sqlite3SmallTypeSizes[serial_type]; |
| 99703 | assert( len>=1 && len<=8 && len!=5 && len!=7 ); |
| 99704 | switch( len ){ |
| 99705 | default: zPayload[7] = (u8)(v&0xff); v >>= 8; |
| 99706 | zPayload[6] = (u8)(v&0xff); v >>= 8; |
| 99707 | /* no break */ deliberate_fall_through |
| 99708 | case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; |
| @@ -99714,10 +99835,12 @@ | |
| 99714 | /* no break */ deliberate_fall_through |
| 99715 | case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; |
| 99716 | /* no break */ deliberate_fall_through |
| 99717 | case 1: zPayload[0] = (u8)(v&0xff); |
| 99718 | } |
| 99719 | zPayload += len; |
| 99720 | } |
| 99721 | }else if( serial_type<0x80 ){ |
| 99722 | *(zHdr++) = serial_type; |
| 99723 | if( serial_type>=14 && pRec->n>0 ){ |
| @@ -106883,45 +107006,10 @@ | |
| 106883 | res = res * -1; |
| 106884 | } |
| 106885 | return res; |
| 106886 | } |
| 106887 | |
| 106888 | /* Helper function for vdbeSorterCompareReal(). |
| 106889 | ** |
| 106890 | ** Read the bits of an 8-byte big-endian IEEE-754 value and store them |
| 106891 | ** into a u64. Do any necessary byte-swapping so that the bits are in |
| 106892 | ** the right order for the host machine. |
| 106893 | ** |
| 106894 | ** Copied and slightly modified from the readInt64() routine in rtree.c |
| 106895 | */ |
| 106896 | static u64 vdbeSorterDecodeU64(const u8 *p){ |
| 106897 | #if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 106898 | u64 x; |
| 106899 | memcpy(&x, p, 8); |
| 106900 | return _byteswap_uint64(x); |
| 106901 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 106902 | u64 x; |
| 106903 | memcpy(&x, p, 8); |
| 106904 | return __builtin_bswap64(x); |
| 106905 | #elif SQLITE_BYTEORDER==4321 |
| 106906 | i64 x; |
| 106907 | memcpy(&x, p, 8); |
| 106908 | return x; |
| 106909 | #else |
| 106910 | return (i64)( |
| 106911 | (((u64)p[0]) << 56) + |
| 106912 | (((u64)p[1]) << 48) + |
| 106913 | (((u64)p[2]) << 40) + |
| 106914 | (((u64)p[3]) << 32) + |
| 106915 | (((u64)p[4]) << 24) + |
| 106916 | (((u64)p[5]) << 16) + |
| 106917 | (((u64)p[6]) << 8) + |
| 106918 | (((u64)p[7]) << 0) |
| 106919 | ); |
| 106920 | #endif |
| 106921 | } |
| 106922 | |
| 106923 | /* Helper function for vdbeSorterCompareReal(). |
| 106924 | ** |
| 106925 | ** Buffer p[] is a record where the first term is guaranteed to be either |
| 106926 | ** a floating-point value, or an integer stand-in for a floating point |
| 106927 | ** value (a MEM_IntReal). Whatever its format, extract the value and |
| @@ -106932,11 +107020,11 @@ | |
| 106932 | |
| 106933 | assert( p[0]<0x80 ); /* 1-byte headers: nAllField<13 */ |
| 106934 | assert( p[1]>0 && p[1]<10 ); /* first fields proven numeric */ |
| 106935 | |
| 106936 | if( p[1]==7 ){ |
| 106937 | u64 x = vdbeSorterDecodeU64(p + p[0]); |
| 106938 | swapMixedEndianFloat(x); |
| 106939 | assert( !IsNaN(x) ); |
| 106940 | memcpy(&r, &x, sizeof(r)); |
| 106941 | }else{ |
| 106942 | Mem m; |
| @@ -107012,15 +107100,15 @@ | |
| 107012 | pbKey2Cached, pKey1,nKey1, pKey2,nKey2 |
| 107013 | ); |
| 107014 | } |
| 107015 | assert( p1[0]<=nKey1-8 && p2[0]<=nKey2-8 ); |
| 107016 | |
| 107017 | x = vdbeSorterDecodeU64(p1 + *p1); |
| 107018 | swapMixedEndianFloat(x); |
| 107019 | assert( !IsNaN(x) ); |
| 107020 | memcpy(&r1, &x, sizeof(r1)); |
| 107021 | x = vdbeSorterDecodeU64(p2 + *p2); |
| 107022 | swapMixedEndianFloat(x); |
| 107023 | assert( !IsNaN(x) ); |
| 107024 | memcpy(&r2, &x, sizeof(r2)); |
| 107025 | return vdbeSorterFinishRealCompare(pTask, |
| 107026 | pbKey2Cached, pKey1,nKey1, pKey2,nKey2, r1, r2 |
| @@ -113105,10 +113193,11 @@ | |
| 113105 | static int exprVectorRegister( |
| 113106 | Parse *pParse, /* Parse context */ |
| 113107 | Expr *pVector, /* Vector to extract element from */ |
| 113108 | int iField, /* Field to extract from pVector */ |
| 113109 | int regSelect, /* First in array of registers */ |
| 113110 | Expr **ppExpr, /* OUT: Expression element */ |
| 113111 | int *pRegFree /* OUT: Temp register to free */ |
| 113112 | ){ |
| 113113 | u8 op = pVector->op; |
| 113114 | assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR ); |
| @@ -113116,12 +113205,21 @@ | |
| 113116 | *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField); |
| 113117 | return pVector->iTable+iField; |
| 113118 | } |
| 113119 | if( op==TK_SELECT ){ |
| 113120 | assert( ExprUseXSelect(pVector) ); |
| 113121 | *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; |
| 113122 | return regSelect+iField; |
| 113123 | } |
| 113124 | if( op==TK_VECTOR ){ |
| 113125 | assert( ExprUseXList(pVector) ); |
| 113126 | *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 113127 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); |
| @@ -113184,15 +113282,16 @@ | |
| 113184 | |
| 113185 | sqlite3VdbeAddOp2(v, OP_Integer, 1, dest); |
| 113186 | for(i=0; 1 /*Loop exits by "break"*/; i++){ |
| 113187 | int regFree1 = 0, regFree2 = 0; |
| 113188 | Expr *pL = 0, *pR = 0; |
| 113189 | int r1, r2; |
| 113190 | assert( i>=0 && i<nLeft ); |
| 113191 | if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp); |
| 113192 | r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, ®Free1); |
| 113193 | r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, ®Free2); |
| 113194 | addrCmp = sqlite3VdbeCurrentAddr(v); |
| 113195 | codeCompare(pParse, pL, pR, opx, r1, r2, addrDone, p5, isCommuted); |
| 113196 | testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 113197 | testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| 113198 | testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); |
| @@ -146405,14 +146504,13 @@ | |
| 146405 | assert( sqlite3SchemaMutexHeld(db, i, 0) ); |
| 146406 | pTbls = &db->aDb[i].pSchema->tblHash; |
| 146407 | for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ |
| 146408 | Table *pTab = sqliteHashData(x); /* Current table */ |
| 146409 | Index *pIdx; /* An index on pTab */ |
| 146410 | int nIdx; /* Number of indexes on pTab */ |
| 146411 | if( tableSkipIntegrityCheck(pTab,pObjTab) ) continue; |
| 146412 | if( HasRowid(pTab) ) cnt++; |
| 146413 | for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; } |
| 146414 | } |
| 146415 | if( cnt==0 ) continue; |
| 146416 | if( pObjTab ) cnt++; |
| 146417 | aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1)); |
| 146418 | if( aRoot==0 ) break; |
| @@ -219069,11 +219167,11 @@ | |
| 219069 | ** Macros to determine whether the machine is big or little endian, |
| 219070 | ** and whether or not that determination is run-time or compile-time. |
| 219071 | ** |
| 219072 | ** For best performance, an attempt is made to guess at the byte-order |
| 219073 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 219074 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 219075 | ** at run-time. |
| 219076 | */ |
| 219077 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 219078 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 219079 | # define SQLITE_BYTEORDER 4321 |
| @@ -219125,12 +219223,15 @@ | |
| 219125 | (((u32)p[2]) << 8) + |
| 219126 | (((u32)p[3]) << 0) |
| 219127 | ); |
| 219128 | #endif |
| 219129 | } |
| 219130 | static i64 readInt64(u8 *p){ |
| 219131 | #if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 219132 | u64 x; |
| 219133 | memcpy(&x, p, 8); |
| 219134 | return (i64)_byteswap_uint64(x); |
| 219135 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 219136 | u64 x; |
| @@ -233187,11 +233288,11 @@ | |
| 233187 | zErr = "no such schema"; |
| 233188 | goto update_fail; |
| 233189 | } |
| 233190 | } |
| 233191 | pBt = pTab->db->aDb[iDb].pBt; |
| 233192 | if( pgno64<1 || pgno64>4294967294 || NEVER(pBt==0) ){ |
| 233193 | zErr = "bad page number"; |
| 233194 | goto update_fail; |
| 233195 | } |
| 233196 | pgno = (Pgno)pgno64; |
| 233197 | szPage = sqlite3BtreeGetPageSize(pBt); |
| @@ -239398,11 +239499,11 @@ | |
| 239398 | |
| 239399 | iUpdate++; |
| 239400 | if( rc==SQLITE_OK ){ |
| 239401 | sqlite3_step(pInsert); |
| 239402 | rc = sqlite3_finalize(pInsert); |
| 239403 | if( rc==SQLITE_CONSTRAINT ){ |
| 239404 | rc = sqlite3_exec(db, "ROLLBACK TO update_op", 0, 0, 0); |
| 239405 | sqlite3_free(pApply->constraints.aBuf); |
| 239406 | pApply->constraints = cons; |
| 239407 | memset(&cons, 0, sizeof(cons)); |
| 239408 | }else if( rc==SQLITE_OK ){ |
| @@ -264171,11 +264272,11 @@ | |
| 264171 | int nArg, /* Number of args */ |
| 264172 | sqlite3_value **apUnused /* Function arguments */ |
| 264173 | ){ |
| 264174 | assert( nArg==0 ); |
| 264175 | UNUSED_PARAM2(nArg, apUnused); |
| 264176 | sqlite3_result_text(pCtx, "fts5: 2026-08-04 14:55:51 bdc841de10fef65b627deb8b770702c976174a66af847c96ebecf24d91798744", -1, SQLITE_TRANSIENT); |
| 264177 | } |
| 264178 | |
| 264179 | /* |
| 264180 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 264181 | ** |
| 264182 |
| --- 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 | ** fee71cd6f7294ffd02784d26811a9d11d80e 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.54.0" |
| 471 | #define SQLITE_VERSION_NUMBER 3054000 |
| 472 | #define SQLITE_SOURCE_ID "2026-08-11 10:46:12 fee71cd6f7294ffd02784d26811a9d11d80e83d4075e1233b8ec0289519bb891" |
| 473 | #define SQLITE_SCM_BRANCH "trunk" |
| 474 | #define SQLITE_SCM_TAGS "" |
| 475 | #define SQLITE_SCM_DATETIME "2026-08-11T10:46:12.896Z" |
| 476 | |
| 477 | /* |
| 478 | ** CAPI3REF: Run-Time Library Version Numbers |
| 479 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 480 | ** |
| @@ -15135,26 +15135,41 @@ | |
| 15135 | # define SQLITE_INT_TO_PTR(X) ((void*)(X)) |
| 15136 | # define SQLITE_PTR_TO_INT(X) ((int)(X)) |
| 15137 | #endif |
| 15138 | |
| 15139 | /* |
| 15140 | ** Hint to the compiler that a function should or should not be inlined: |
| 15141 | ** |
| 15142 | ** SQLITE_NOINLINE Never in-line this function |
| 15143 | ** |
| 15144 | ** SQLITE_INLINE Strive to in-line this function |
| 15145 | ** |
| 15146 | ** SQLITE_OPT_INLINE In-line this function if building the |
| 15147 | ** amalgamation. |
| 15148 | */ |
| 15149 | #if defined(__GNUC__) |
| 15150 | # define SQLITE_NOINLINE __attribute__((noinline)) |
| 15151 | # define SQLITE_INLINE __attribute__((always_inline)) inline |
| 15152 | # define SQLITE_OPT_INLINE __attribute__((always_inline)) inline |
| 15153 | #elif defined(_MSC_VER) && _MSC_VER>=1310 |
| 15154 | # define SQLITE_NOINLINE __declspec(noinline) |
| 15155 | # define SQLITE_INLINE __forceinline |
| 15156 | # define SQLITE_OPT_INLINE __forceinline |
| 15157 | #else |
| 15158 | # define SQLITE_NOINLINE |
| 15159 | # define SQLITE_INLINE |
| 15160 | # define SQLITE_OPT_INLINE |
| 15161 | #endif |
| 15162 | #if defined(SQLITE_COVERAGE_TEST) || defined(__STRICT_ANSI__) |
| 15163 | # undef SQLITE_INLINE |
| 15164 | # define SQLITE_INLINE |
| 15165 | # undef SQLITE_OPT_INLINE |
| 15166 | # define SQLITE_OPT_INLINE |
| 15167 | #endif |
| 15168 | #if !defined(SQLITE_AMALGAMATION) |
| 15169 | # undef SQLITE_OPT_INLINE |
| 15170 | # define SQLITE_OPT_INLINE |
| 15171 | #endif |
| 15172 | |
| 15173 | /* |
| 15174 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 15175 | ** compiling with an appropriate version of MSVC unless prevented by |
| @@ -22989,10 +23004,14 @@ | |
| 23004 | #define sqlite3ExprCheckHeight(x,y) |
| 23005 | #endif |
| 23006 | SQLITE_PRIVATE void sqlite3ExprSetErrorOffset(Expr*,int); |
| 23007 | |
| 23008 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8*); |
| 23009 | SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3Get8byte(const u8*); |
| 23010 | #if SQLITE_BYTEORDER!=4321 |
| 23011 | SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3BSwap64(u64); |
| 23012 | #endif |
| 23013 | SQLITE_PRIVATE void sqlite3Put4byte(u8*, u32); |
| 23014 | |
| 23015 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 23016 | SQLITE_PRIVATE void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *); |
| 23017 | SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db); |
| @@ -25051,10 +25070,21 @@ | |
| 25070 | */ |
| 25071 | #ifndef SQLITE_AMALGAMATION |
| 25072 | SQLITE_PRIVATE const u8 sqlite3SmallTypeSizes[]; |
| 25073 | #endif |
| 25074 | |
| 25075 | /* Input "x" is a sequence of unsigned characters that represent a |
| 25076 | ** big-endian integer. Return the equivalent native integer |
| 25077 | */ |
| 25078 | #define ONE_BYTE_INT(x) ((i8)(x)[0]) |
| 25079 | #define TWO_BYTE_INT(x) (256*(i8)((x)[0])|(x)[1]) |
| 25080 | #define THREE_BYTE_INT(x) (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2]) |
| 25081 | #define FOUR_BYTE_UINT(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| 25082 | #define FOUR_BYTE_U64(x) (((u64)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) |
| 25083 | #define FOUR_BYTE_INT(x) ((int)FOUR_BYTE_UINT(x)) |
| 25084 | #define SIX_BYTE_INT(x) (FOUR_BYTE_UINT(x+2)+4294967296LL*TWO_BYTE_INT(x)) |
| 25085 | |
| 25086 | /* |
| 25087 | ** Function prototypes |
| 25088 | */ |
| 25089 | SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...); |
| 25090 | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*); |
| @@ -38533,11 +38563,11 @@ | |
| 38563 | return i; |
| 38564 | } |
| 38565 | |
| 38566 | |
| 38567 | /* |
| 38568 | ** Read an unsigned 32-bit integer from an unaligned big-endian array of bytes. |
| 38569 | */ |
| 38570 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 38571 | #if SQLITE_BYTEORDER==4321 |
| 38572 | u32 x; |
| 38573 | memcpy(&x,p,4); |
| @@ -38549,14 +38579,18 @@ | |
| 38579 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38580 | u32 x; |
| 38581 | memcpy(&x,p,4); |
| 38582 | return _byteswap_ulong(x); |
| 38583 | #else |
| 38584 | /* Test this limb using -DSQLITE_BYTEORDER=0 */ |
| 38585 | testcase( p[0]&0x80 ); |
| 38586 | return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 38587 | #endif |
| 38588 | } |
| 38589 | |
| 38590 | /* Write an unsigned 32-bit integer into an unaligned big-endian array of bytes. |
| 38591 | */ |
| 38592 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 38593 | #if SQLITE_BYTEORDER==4321 |
| 38594 | memcpy(p,&v,4); |
| 38595 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 38596 | u32 x = __builtin_bswap32(v); |
| @@ -38563,18 +38597,70 @@ | |
| 38597 | memcpy(p,&x,4); |
| 38598 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38599 | u32 x = _byteswap_ulong(v); |
| 38600 | memcpy(p,&x,4); |
| 38601 | #else |
| 38602 | /* Test this limb using -DSQLITE_BYTEORDER=0 */ |
| 38603 | p[0] = (u8)(v>>24); |
| 38604 | p[1] = (u8)(v>>16); |
| 38605 | p[2] = (u8)(v>>8); |
| 38606 | p[3] = (u8)v; |
| 38607 | #endif |
| 38608 | } |
| 38609 | |
| 38610 | /* |
| 38611 | ** Read an unsigned 64-bit integer from an unaligned big-endian byte array. |
| 38612 | */ |
| 38613 | SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3Get8byte(const u8 *p){ |
| 38614 | #if SQLITE_BYTEORDER==4321 |
| 38615 | u64 x; |
| 38616 | memcpy(&x,p,8); |
| 38617 | return x; |
| 38618 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 38619 | u64 x; |
| 38620 | memcpy(&x,p,8); |
| 38621 | return __builtin_bswap64(x); |
| 38622 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38623 | u64 x; |
| 38624 | memcpy(&x,p,8); |
| 38625 | return _byteswap_uint64(x); |
| 38626 | #else |
| 38627 | /* Test this limb using -DSQLITE_BYTEORDER=0 */ |
| 38628 | testcase( p[0]&0x80 ); |
| 38629 | return (u64)( |
| 38630 | (((u64)p[0]) << 56) + |
| 38631 | (((u64)p[1]) << 48) + |
| 38632 | (((u64)p[2]) << 40) + |
| 38633 | (((u64)p[3]) << 32) + |
| 38634 | (((u64)p[4]) << 24) + |
| 38635 | (((u64)p[5]) << 16) + |
| 38636 | (((u64)p[6]) << 8) + |
| 38637 | (((u64)p[7]) << 0) |
| 38638 | ); |
| 38639 | #endif |
| 38640 | } |
| 38641 | |
| 38642 | #if SQLITE_BYTEORDER!=4321 /* Only used for little-endian machines */ |
| 38643 | /* |
| 38644 | ** Byte-swap a 64-bit unsigned integer. |
| 38645 | */ |
| 38646 | SQLITE_PRIVATE SQLITE_OPT_INLINE u64 sqlite3BSwap64(u64 x){ |
| 38647 | #if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 38648 | return __builtin_bswap64(x); |
| 38649 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 38650 | return _byteswap_uint64(x); |
| 38651 | #else |
| 38652 | /* Test this limb using -DSQLITE_BYTEORDER=0 */ |
| 38653 | x = (x << 32) | (x >> 32); |
| 38654 | x = ((x & UINT64_C(0x0000ffff0000ffff)) << 16) | |
| 38655 | ((x & UINT64_C(0xffff0000ffff0000)) >> 16); |
| 38656 | x = ((x & UINT64_C(0x00ff00ff00ff00ff)) << 8) | |
| 38657 | ((x & UINT64_C(0xff00ff00ff00ff00)) >> 8); |
| 38658 | return x; |
| 38659 | #endif |
| 38660 | } |
| 38661 | #endif /* SQLITE_BYTEORDER!=4321 */ |
| 38662 | |
| 38663 | /* |
| 38664 | ** Translate a single byte of Hex into an integer. |
| 38665 | ** This routine only works if h really is a valid hexadecimal |
| 38666 | ** character: 0..9a..fA..F |
| @@ -57862,12 +57948,15 @@ | |
| 57948 | int createFlag |
| 57949 | ){ |
| 57950 | PCache1 *pCache = (PCache1 *)p; |
| 57951 | PgHdr1 *pPage = 0; |
| 57952 | |
| 57953 | /* Step 1: Search the hash table for an existing entry. nHash is always |
| 57954 | ** a power of two when the cache is in use (see pcache1ResizeHash()), so |
| 57955 | ** the modulo reduces to a mask, avoiding a hardware divide. */ |
| 57956 | assert( pCache->nHash>0 && (pCache->nHash & (pCache->nHash-1))==0 ); |
| 57957 | pPage = pCache->apHash[iKey & (pCache->nHash-1u)]; |
| 57958 | while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; } |
| 57959 | |
| 57960 | /* Step 2: If the page was found in the hash table, then return it. |
| 57961 | ** If the page was not in the hash table and createFlag is 0, abort. |
| 57962 | ** Otherwise (page not in hash and createFlag!=0) continue with |
| @@ -91159,71 +91248,20 @@ | |
| 91248 | u.i[1] = t; |
| 91249 | return u.r; |
| 91250 | } |
| 91251 | #endif /* SQLITE_MIXED_ENDIAN_64BIT_FLOAT */ |
| 91252 | |
| 91253 | /* |
| 91254 | ** Deserialize the REAL number pointed to by buf and store it in pMem. |
| 91255 | */ |
| 91256 | static int sqlite3VdbeSerialGet7( |
| 91257 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 91258 | Mem *pMem /* Memory cell to write value into */ |
| 91259 | ){ |
| 91260 | /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit |
| 91261 | ** floating point number. */ |
| 91262 | u64 x = sqlite3Get8byte(buf); |
| 91263 | assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 ); |
| 91264 | swapMixedEndianFloat(x); |
| 91265 | memcpy(&pMem->u.r, &x, sizeof(x)); |
| 91266 | if( IsNaN(x) ){ |
| 91267 | pMem->flags = MEM_Null; |
| @@ -91230,10 +91268,17 @@ | |
| 91268 | return 1; |
| 91269 | } |
| 91270 | pMem->flags = MEM_Real; |
| 91271 | return 0; |
| 91272 | } |
| 91273 | |
| 91274 | /* |
| 91275 | ** Deserialize the data blob pointed to by buf as serial type serial_type |
| 91276 | ** and store the result in pMem. |
| 91277 | ** |
| 91278 | ** Similar code is found in the implementation of the OP_Column opcode. |
| 91279 | */ |
| 91280 | SQLITE_PRIVATE void sqlite3VdbeSerialGet( |
| 91281 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 91282 | u32 serial_type, /* Serial type to deserialize */ |
| 91283 | Mem *pMem /* Memory cell to write value into */ |
| 91284 | ){ |
| @@ -91288,20 +91333,25 @@ | |
| 91333 | return; |
| 91334 | } |
| 91335 | case 5: { /* 6-byte signed integer */ |
| 91336 | /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit |
| 91337 | ** twos-complement integer. */ |
| 91338 | pMem->u.i = SIX_BYTE_INT(buf); |
| 91339 | pMem->flags = MEM_Int; |
| 91340 | testcase( pMem->u.i<0 ); |
| 91341 | return; |
| 91342 | } |
| 91343 | case 6: { /* 8-byte signed integer */ |
| 91344 | /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit |
| 91345 | ** twos-complement integer. */ |
| 91346 | pMem->u.i = (i64)sqlite3Get8byte(buf); |
| 91347 | pMem->flags = MEM_Int; |
| 91348 | testcase( pMem->u.i<0 ); |
| 91349 | return; |
| 91350 | } |
| 91351 | case 7: { /* IEEE floating point */ |
| 91352 | sqlite3VdbeSerialGet7(buf, pMem); |
| 91353 | return; |
| 91354 | } |
| 91355 | case 8: /* Integer 0 */ |
| 91356 | case 9: { /* Integer 1 */ |
| 91357 | /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */ |
| @@ -91903,11 +91953,11 @@ | |
| 91953 | if( serial_type>=10 ){ |
| 91954 | rc = serial_type==10 ? -1 : +1; |
| 91955 | }else if( serial_type==0 ){ |
| 91956 | rc = -1; |
| 91957 | }else if( serial_type==7 ){ |
| 91958 | sqlite3VdbeSerialGet7(&aKey1[d1], &mem1); |
| 91959 | rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r); |
| 91960 | }else{ |
| 91961 | i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]); |
| 91962 | i64 rhs = pRhs->u.i; |
| 91963 | if( lhs<rhs ){ |
| @@ -91929,11 +91979,11 @@ | |
| 91979 | rc = serial_type==10 ? -1 : +1; |
| 91980 | }else if( serial_type==0 ){ |
| 91981 | rc = -1; |
| 91982 | }else{ |
| 91983 | if( serial_type==7 ){ |
| 91984 | if( sqlite3VdbeSerialGet7(&aKey1[d1], &mem1) ){ |
| 91985 | rc = -1; /* mem1 is a NaN */ |
| 91986 | }else if( mem1.u.r<pRhs->u.r ){ |
| 91987 | rc = -1; |
| 91988 | }else if( mem1.u.r>pRhs->u.r ){ |
| 91989 | rc = +1; |
| @@ -92011,11 +92061,11 @@ | |
| 92061 | /* RHS is null */ |
| 92062 | else{ |
| 92063 | serial_type = aKey1[idx1]; |
| 92064 | if( serial_type==0 |
| 92065 | || serial_type==10 |
| 92066 | || (serial_type==7 && sqlite3VdbeSerialGet7(&aKey1[d1], &mem1)!=0) |
| 92067 | ){ |
| 92068 | assert( rc==0 ); |
| 92069 | }else{ |
| 92070 | rc = 1; |
| 92071 | } |
| @@ -92085,69 +92135,46 @@ | |
| 92135 | UnpackedRecord *pPKey2 /* Right key */ |
| 92136 | ){ |
| 92137 | const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F]; |
| 92138 | int serial_type = ((const u8*)pKey1)[1]; |
| 92139 | int res; |
| 92140 | i64 v; |
| 92141 | i64 lhs; |
| 92142 | |
| 92143 | vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo); |
| 92144 | assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB ); |
| 92145 | |
| 92146 | /* Serial types 1 through 6 are big-endian integers of 1, 2, 3, 4, |
| 92147 | ** 6, or 8 bytes. Rather than handle each width in its own switch |
| 92148 | ** case, read 8 bytes and use an arithmetic right shift to drop the |
| 92149 | ** unwanted low-order bytes and sign-extend the value. This helps |
| 92150 | ** because the switch tends to mispredict when a key column contains |
| 92151 | ** integers of varying sizes. The first entry of aShift[] is a |
| 92152 | ** placeholder so that the table can be indexed by serial_type |
| 92153 | ** directly. Reading 8 bytes is always safe, because a buffer passed |
| 92154 | ** to this routine has at least 74 bytes of padding after it, as |
| 92155 | ** explained in sqlite3VdbeFindCompare() below. |
| 92156 | */ |
| 92157 | if( (u32)(serial_type-1)<=5 ){ |
| 92158 | static const u8 aShift[] = { 0, 56, 48, 40, 32, 16, 0 }; |
| 92159 | lhs = ((i64)sqlite3Get8byte(aKey)) >> aShift[serial_type]; |
| 92160 | /* ^^--- This shift operator |
| 92161 | ** needs to be an arithmetic right-shift, which means that |
| 92162 | ** if the left-hand operand (LHS) is negative, it will be sign-extended |
| 92163 | ** so that the final results is also negative. All modern C |
| 92164 | ** compilers work this way as long as the LHS is a signed integer |
| 92165 | ** (which is why the unsigned result from sqlite3Get8byte() is cast |
| 92166 | ** into i64), but it is not defined by the C standards, or so Claude |
| 92167 | ** tells me. That the correct result is obtained is verified by the |
| 92168 | ** following assert() and testcase() macros: |
| 92169 | */ |
| 92170 | assert( 0<=(i64)sqlite3Get8byte(aKey) || lhs<0 ); |
| 92171 | testcase( lhs<0 ); |
| 92172 | }else if( serial_type==8 || serial_type==9 ){ |
| 92173 | lhs = serial_type - 8; |
| 92174 | }else{ |
| 92175 | return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2); |
| 92176 | } |
| 92177 | |
| 92178 | assert( pPKey2->u.i == pPKey2->aMem[0].u.i ); |
| 92179 | v = pPKey2->u.i; |
| 92180 | if( v>lhs ){ |
| @@ -99150,34 +99177,95 @@ | |
| 99177 | sqlite3VdbeMemSetNull(pDest); |
| 99178 | } |
| 99179 | assert( t==pC->aType[p2] ); |
| 99180 | if( pC->szRow>=aOffset[p2+1] ){ |
| 99181 | /* This is the common case where the desired content fits on the original |
| 99182 | ** page - where the content is not on an overflow page. |
| 99183 | ** |
| 99184 | ** The big switch() is an in-line variant of sqlite3VdbeSerialGet() that |
| 99185 | ** has been optimized for the OP_Column opcode. |
| 99186 | */ |
| 99187 | zData = pC->aRow + aOffset[p2]; |
| 99188 | switch( t ){ |
| 99189 | case 0: |
| 99190 | case 11: |
| 99191 | pDest->flags = MEM_Null; |
| 99192 | break; |
| 99193 | case 1: |
| 99194 | pDest->u.i = ONE_BYTE_INT(zData); |
| 99195 | pDest->flags = MEM_Int; |
| 99196 | testcase( pDest->u.i<0 ); |
| 99197 | break; |
| 99198 | case 2: |
| 99199 | pDest->u.i = TWO_BYTE_INT(zData); |
| 99200 | pDest->flags = MEM_Int; |
| 99201 | testcase( pDest->u.i<0 ); |
| 99202 | break; |
| 99203 | case 3: |
| 99204 | pDest->u.i = THREE_BYTE_INT(zData); |
| 99205 | pDest->flags = MEM_Int; |
| 99206 | testcase( pDest->u.i<0 ); |
| 99207 | break; |
| 99208 | case 4: |
| 99209 | pDest->u.i = FOUR_BYTE_INT(zData); |
| 99210 | pDest->flags = MEM_Int; |
| 99211 | testcase( pDest->u.i<0 ); |
| 99212 | break; |
| 99213 | case 5: |
| 99214 | pDest->u.i = SIX_BYTE_INT(zData); |
| 99215 | pDest->flags = MEM_Int; |
| 99216 | testcase( pDest->u.i<0 ); |
| 99217 | break; |
| 99218 | case 6: { |
| 99219 | pDest->u.i = (i64)sqlite3Get8byte(zData); |
| 99220 | pDest->flags = MEM_Int; |
| 99221 | testcase( pDest->u.i<0 ); |
| 99222 | break; |
| 99223 | } |
| 99224 | case 7: { |
| 99225 | u64 x = sqlite3Get8byte(zData); |
| 99226 | swapMixedEndianFloat(x); |
| 99227 | pDest->flags = IsNaN(x) ? MEM_Null : MEM_Real; |
| 99228 | memcpy(&pDest->u.r, &x, sizeof(x)); |
| 99229 | testcase( pDest->u.r<0 ); |
| 99230 | break; |
| 99231 | } |
| 99232 | case 8: |
| 99233 | case 9: { |
| 99234 | pDest->u.i = t-8; |
| 99235 | pDest->flags = MEM_Int; |
| 99236 | break; |
| 99237 | } |
| 99238 | case 10: |
| 99239 | /* Internal use only: NULL with virtual table |
| 99240 | ** UPDATE no-change flag set */ |
| 99241 | pDest->flags = MEM_Null|MEM_Zero; |
| 99242 | pDest->u.nZero = 0; |
| 99243 | pDest->n = 0; |
| 99244 | break; |
| 99245 | default: { |
| 99246 | /* If the column value is a string or blob, we need a persistent |
| 99247 | ** value, not a MEM_Ephem value. This case is a fast short-cut |
| 99248 | ** that is equivalent to calling sqlite3VdbeSerialGet() and |
| 99249 | ** sqlite3VdbeDeephemeralize(). |
| 99250 | */ |
| 99251 | static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; |
| 99252 | pDest->n = len = (t-12)/2; |
| 99253 | pDest->enc = encoding; |
| 99254 | if( pDest->szMalloc < len+2 ){ |
| 99255 | if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big; |
| 99256 | pDest->flags = MEM_Null; |
| 99257 | if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; |
| 99258 | }else{ |
| 99259 | pDest->z = pDest->zMalloc; |
| 99260 | } |
| 99261 | memcpy(pDest->z, zData, len); |
| 99262 | pDest->z[len] = 0; |
| 99263 | pDest->z[len+1] = 0; |
| 99264 | pDest->flags = aFlag[t&1]; |
| 99265 | } |
| 99266 | } /* End of switch */ |
| 99267 | }else{ |
| 99268 | u8 p5; |
| 99269 | pDest->enc = encoding; |
| 99270 | assert( pDest->db==db ); |
| 99271 | /* This branch happens only when content is on overflow pages */ |
| @@ -99640,27 +99728,39 @@ | |
| 99728 | nVarint = sqlite3VarintLen(nHdr); |
| 99729 | nHdr += nVarint; |
| 99730 | if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++; |
| 99731 | } |
| 99732 | nByte = nHdr+nData; |
| 99733 | |
| 99734 | /* If we are able to put an over-run area of 7 bytes on the end of the |
| 99735 | ** memory allocation into which the record is being constructed, then |
| 99736 | ** the encoding of integer values can go faster. This is only possible |
| 99737 | ** if SQLITE_MAX_LENGTH is no with 7 of INT32_MAX and if the host CPU |
| 99738 | ** byte-order is known at compile-time. |
| 99739 | */ |
| 99740 | #if SQLITE_MAX_LENGTH<=2147483640 && SQLITE_BYTEORDER>0 |
| 99741 | # define OVERRUN 7 /* We are able to allocate an overrun of 7 bytes */ |
| 99742 | #else |
| 99743 | # define OVERRUN 0 /* No overrun will be available */ |
| 99744 | #endif |
| 99745 | |
| 99746 | /* Make sure the output register has a buffer large enough to store |
| 99747 | ** the new record. The output register (pOp->p3) is not allowed to |
| 99748 | ** be one of the input registers (because the following call to |
| 99749 | ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). |
| 99750 | */ |
| 99751 | if( nByte+nZero<=pOut->szMalloc-OVERRUN ){ |
| 99752 | /* The output register is already large enough to hold the record. |
| 99753 | ** No error checks or buffer enlargement is required */ |
| 99754 | pOut->z = pOut->zMalloc; |
| 99755 | }else{ |
| 99756 | /* Need to make sure that the output is not too big and then enlarge |
| 99757 | ** the output register to hold the full result */ |
| 99758 | if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 99759 | goto too_big; |
| 99760 | } |
| 99761 | if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte+OVERRUN) ){ |
| 99762 | goto no_mem; |
| 99763 | } |
| 99764 | } |
| 99765 | pOut->n = (int)nByte; |
| 99766 | pOut->flags = MEM_Blob; |
| @@ -99699,10 +99799,31 @@ | |
| 99799 | }else{ |
| 99800 | v = pRec->u.i; |
| 99801 | } |
| 99802 | len = sqlite3SmallTypeSizes[serial_type]; |
| 99803 | assert( len>=1 && len<=8 && len!=5 && len!=7 ); |
| 99804 | #if SQLITE_BYTEORDER==1234 |
| 99805 | v = sqlite3BSwap64(v); |
| 99806 | if( OVERRUN ){ |
| 99807 | static const u8 aShift[] = { 0, 56, 48, 40, 32, 16, 0, 0 }; |
| 99808 | v >>= aShift[serial_type]; |
| 99809 | memcpy(zPayload, &v, 8); |
| 99810 | }else{ |
| 99811 | /* Test this limb by compiling with -DSQLITE_MAX_LENGTH=2147483647 */ |
| 99812 | memcpy(zPayload, (u8*)&v + 8 - len, len); |
| 99813 | } |
| 99814 | #elif SQLITE_BYTEORDER==4321 |
| 99815 | if( OVERRUN ){ |
| 99816 | static const u8 aShift[] = { 0, 56, 48, 40, 32, 16, 0, 0 }; |
| 99817 | v <<= aShift[serial_type]; |
| 99818 | memcpy(zPayload, &v, 8); |
| 99819 | }else{ |
| 99820 | /* Test this limb by compiling with -DSQLITE_MAX_LENGTH=2147483647 */ |
| 99821 | memcpy(zPayload, (u8*)&v + 8 - len, len); |
| 99822 | } |
| 99823 | #else |
| 99824 | /* Test this limb by compiling with -DSQLITE_BYTEORDER=0 */ |
| 99825 | switch( len ){ |
| 99826 | default: zPayload[7] = (u8)(v&0xff); v >>= 8; |
| 99827 | zPayload[6] = (u8)(v&0xff); v >>= 8; |
| 99828 | /* no break */ deliberate_fall_through |
| 99829 | case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; |
| @@ -99714,10 +99835,12 @@ | |
| 99835 | /* no break */ deliberate_fall_through |
| 99836 | case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; |
| 99837 | /* no break */ deliberate_fall_through |
| 99838 | case 1: zPayload[0] = (u8)(v&0xff); |
| 99839 | } |
| 99840 | #endif |
| 99841 | #undef OVERRUN /* We are done with the OVERRUN macro now */ |
| 99842 | zPayload += len; |
| 99843 | } |
| 99844 | }else if( serial_type<0x80 ){ |
| 99845 | *(zHdr++) = serial_type; |
| 99846 | if( serial_type>=14 && pRec->n>0 ){ |
| @@ -106883,45 +107006,10 @@ | |
| 107006 | res = res * -1; |
| 107007 | } |
| 107008 | return res; |
| 107009 | } |
| 107010 | |
| 107011 | /* Helper function for vdbeSorterCompareReal(). |
| 107012 | ** |
| 107013 | ** Buffer p[] is a record where the first term is guaranteed to be either |
| 107014 | ** a floating-point value, or an integer stand-in for a floating point |
| 107015 | ** value (a MEM_IntReal). Whatever its format, extract the value and |
| @@ -106932,11 +107020,11 @@ | |
| 107020 | |
| 107021 | assert( p[0]<0x80 ); /* 1-byte headers: nAllField<13 */ |
| 107022 | assert( p[1]>0 && p[1]<10 ); /* first fields proven numeric */ |
| 107023 | |
| 107024 | if( p[1]==7 ){ |
| 107025 | u64 x = sqlite3Get8byte(p + p[0]); |
| 107026 | swapMixedEndianFloat(x); |
| 107027 | assert( !IsNaN(x) ); |
| 107028 | memcpy(&r, &x, sizeof(r)); |
| 107029 | }else{ |
| 107030 | Mem m; |
| @@ -107012,15 +107100,15 @@ | |
| 107100 | pbKey2Cached, pKey1,nKey1, pKey2,nKey2 |
| 107101 | ); |
| 107102 | } |
| 107103 | assert( p1[0]<=nKey1-8 && p2[0]<=nKey2-8 ); |
| 107104 | |
| 107105 | x = sqlite3Get8byte(p1 + *p1); |
| 107106 | swapMixedEndianFloat(x); |
| 107107 | assert( !IsNaN(x) ); |
| 107108 | memcpy(&r1, &x, sizeof(r1)); |
| 107109 | x = sqlite3Get8byte(p2 + *p2); |
| 107110 | swapMixedEndianFloat(x); |
| 107111 | assert( !IsNaN(x) ); |
| 107112 | memcpy(&r2, &x, sizeof(r2)); |
| 107113 | return vdbeSorterFinishRealCompare(pTask, |
| 107114 | pbKey2Cached, pKey1,nKey1, pKey2,nKey2, r1, r2 |
| @@ -113105,10 +113193,11 @@ | |
| 113193 | static int exprVectorRegister( |
| 113194 | Parse *pParse, /* Parse context */ |
| 113195 | Expr *pVector, /* Vector to extract element from */ |
| 113196 | int iField, /* Field to extract from pVector */ |
| 113197 | int regSelect, /* First in array of registers */ |
| 113198 | Expr *pTmp, /* Temporary space */ |
| 113199 | Expr **ppExpr, /* OUT: Expression element */ |
| 113200 | int *pRegFree /* OUT: Temp register to free */ |
| 113201 | ){ |
| 113202 | u8 op = pVector->op; |
| 113203 | assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT || op==TK_ERROR ); |
| @@ -113116,12 +113205,21 @@ | |
| 113205 | *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField); |
| 113206 | return pVector->iTable+iField; |
| 113207 | } |
| 113208 | if( op==TK_SELECT ){ |
| 113209 | assert( ExprUseXSelect(pVector) ); |
| 113210 | /* Use the temporary expression node to wrap expression iField of the |
| 113211 | ** sub-select in a TK_SELECT_COLUMN node. This causes the caller to |
| 113212 | ** use the affinity of the expression in any comparison, but not the |
| 113213 | ** collation sequence. */ |
| 113214 | memset(pTmp, 0, sizeof(Expr)); |
| 113215 | pTmp->op = TK_SELECT_COLUMN; |
| 113216 | pTmp->pLeft = pVector; |
| 113217 | pTmp->iColumn = iField; |
| 113218 | pTmp->iTable = pVector->x.pSelect->pEList->nExpr; |
| 113219 | *ppExpr = pTmp; |
| 113220 | return regSelect+iField; |
| 113221 | } |
| 113222 | if( op==TK_VECTOR ){ |
| 113223 | assert( ExprUseXList(pVector) ); |
| 113224 | *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 113225 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); |
| @@ -113184,15 +113282,16 @@ | |
| 113282 | |
| 113283 | sqlite3VdbeAddOp2(v, OP_Integer, 1, dest); |
| 113284 | for(i=0; 1 /*Loop exits by "break"*/; i++){ |
| 113285 | int regFree1 = 0, regFree2 = 0; |
| 113286 | Expr *pL = 0, *pR = 0; |
| 113287 | Expr tmp1, tmp2; |
| 113288 | int r1, r2; |
| 113289 | assert( i>=0 && i<nLeft ); |
| 113290 | if( addrCmp ) sqlite3VdbeJumpHere(v, addrCmp); |
| 113291 | r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &tmp1, &pL, ®Free1); |
| 113292 | r2 = exprVectorRegister(pParse, pRight, i, regRight, &tmp2, &pR, ®Free2); |
| 113293 | addrCmp = sqlite3VdbeCurrentAddr(v); |
| 113294 | codeCompare(pParse, pL, pR, opx, r1, r2, addrDone, p5, isCommuted); |
| 113295 | testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 113296 | testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| 113297 | testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); |
| @@ -146405,14 +146504,13 @@ | |
| 146504 | assert( sqlite3SchemaMutexHeld(db, i, 0) ); |
| 146505 | pTbls = &db->aDb[i].pSchema->tblHash; |
| 146506 | for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ |
| 146507 | Table *pTab = sqliteHashData(x); /* Current table */ |
| 146508 | Index *pIdx; /* An index on pTab */ |
| 146509 | if( tableSkipIntegrityCheck(pTab,pObjTab) ) continue; |
| 146510 | if( HasRowid(pTab) ) cnt++; |
| 146511 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ cnt++; } |
| 146512 | } |
| 146513 | if( cnt==0 ) continue; |
| 146514 | if( pObjTab ) cnt++; |
| 146515 | aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1)); |
| 146516 | if( aRoot==0 ) break; |
| @@ -219069,11 +219167,11 @@ | |
| 219167 | ** Macros to determine whether the machine is big or little endian, |
| 219168 | ** and whether or not that determination is run-time or compile-time. |
| 219169 | ** |
| 219170 | ** For best performance, an attempt is made to guess at the byte-order |
| 219171 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 219172 | ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined |
| 219173 | ** at run-time. |
| 219174 | */ |
| 219175 | #ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ |
| 219176 | # if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ |
| 219177 | # define SQLITE_BYTEORDER 4321 |
| @@ -219125,12 +219223,15 @@ | |
| 219223 | (((u32)p[2]) << 8) + |
| 219224 | (((u32)p[3]) << 0) |
| 219225 | ); |
| 219226 | #endif |
| 219227 | } |
| 219228 | |
| 219229 | static i64 readInt64(u8 *p){ |
| 219230 | #if defined(SQLITE_AMALGAMATION) |
| 219231 | return (i64)sqlite3Get8byte(p); |
| 219232 | #elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 219233 | u64 x; |
| 219234 | memcpy(&x, p, 8); |
| 219235 | return (i64)_byteswap_uint64(x); |
| 219236 | #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 |
| 219237 | u64 x; |
| @@ -233187,11 +233288,11 @@ | |
| 233288 | zErr = "no such schema"; |
| 233289 | goto update_fail; |
| 233290 | } |
| 233291 | } |
| 233292 | pBt = pTab->db->aDb[iDb].pBt; |
| 233293 | if( pgno64<1 || pgno64>4294967294U || NEVER(pBt==0) ){ |
| 233294 | zErr = "bad page number"; |
| 233295 | goto update_fail; |
| 233296 | } |
| 233297 | pgno = (Pgno)pgno64; |
| 233298 | szPage = sqlite3BtreeGetPageSize(pBt); |
| @@ -239398,11 +239499,11 @@ | |
| 239499 | |
| 239500 | iUpdate++; |
| 239501 | if( rc==SQLITE_OK ){ |
| 239502 | sqlite3_step(pInsert); |
| 239503 | rc = sqlite3_finalize(pInsert); |
| 239504 | if( (rc&0xff)==SQLITE_CONSTRAINT ){ |
| 239505 | rc = sqlite3_exec(db, "ROLLBACK TO update_op", 0, 0, 0); |
| 239506 | sqlite3_free(pApply->constraints.aBuf); |
| 239507 | pApply->constraints = cons; |
| 239508 | memset(&cons, 0, sizeof(cons)); |
| 239509 | }else if( rc==SQLITE_OK ){ |
| @@ -264171,11 +264272,11 @@ | |
| 264272 | int nArg, /* Number of args */ |
| 264273 | sqlite3_value **apUnused /* Function arguments */ |
| 264274 | ){ |
| 264275 | assert( nArg==0 ); |
| 264276 | UNUSED_PARAM2(nArg, apUnused); |
| 264277 | sqlite3_result_text(pCtx, "fts5: 2026-08-11 10:46:12 fee71cd6f7294ffd02784d26811a9d11d80e83d4075e1233b8ec0289519bb891", -1, SQLITE_TRANSIENT); |
| 264278 | } |
| 264279 | |
| 264280 | /* |
| 264281 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 264282 | ** |
| 264283 |
+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.54.0" |
| 150 | 150 | #define SQLITE_VERSION_NUMBER 3054000 |
| 151 | -#define SQLITE_SOURCE_ID "2026-08-04 20:40:10 6bdfff7ddb63d0b4f28f6c174a36e81486a652056a4e21644378a22feda780fd" | |
| 151 | +#define SQLITE_SOURCE_ID "2026-08-11 10:46:12 fee71cd6f7294ffd02784d26811a9d11d80e83d4075e1233b8ec0289519bb891" | |
| 152 | 152 | #define SQLITE_SCM_BRANCH "trunk" |
| 153 | 153 | #define SQLITE_SCM_TAGS "" |
| 154 | -#define SQLITE_SCM_DATETIME "2026-08-04T20:40:10.440Z" | |
| 154 | +#define SQLITE_SCM_DATETIME "2026-08-11T10:46:12.896Z" | |
| 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.54.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3054000 |
| 151 | #define SQLITE_SOURCE_ID "2026-08-04 20:40:10 6bdfff7ddb63d0b4f28f6c174a36e81486a652056a4e21644378a22feda780fd" |
| 152 | #define SQLITE_SCM_BRANCH "trunk" |
| 153 | #define SQLITE_SCM_TAGS "" |
| 154 | #define SQLITE_SCM_DATETIME "2026-08-04T20:40:10.440Z" |
| 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.54.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3054000 |
| 151 | #define SQLITE_SOURCE_ID "2026-08-11 10:46:12 fee71cd6f7294ffd02784d26811a9d11d80e83d4075e1233b8ec0289519bb891" |
| 152 | #define SQLITE_SCM_BRANCH "trunk" |
| 153 | #define SQLITE_SCM_TAGS "" |
| 154 | #define SQLITE_SCM_DATETIME "2026-08-11T10:46:12.896Z" |
| 155 | |
| 156 | /* |
| 157 | ** CAPI3REF: Run-Time Library Version Numbers |
| 158 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 159 | ** |
| 160 |