| | @@ -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 | | -** b7814350381a2929e9fa6444867a80437291. |
| 21 | +** 9f642b3dbc8febfacad97076030f44e9b400. |
| 22 | 22 | */ |
| 23 | 23 | #define SQLITE_CORE 1 |
| 24 | 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | 25 | #ifndef SQLITE_PRIVATE |
| 26 | 26 | # define SQLITE_PRIVATE static |
| | @@ -462,11 +462,11 @@ |
| 462 | 462 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 463 | 463 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 464 | 464 | */ |
| 465 | 465 | #define SQLITE_VERSION "3.47.0" |
| 466 | 466 | #define SQLITE_VERSION_NUMBER 3047000 |
| 467 | | -#define SQLITE_SOURCE_ID "2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c" |
| 467 | +#define SQLITE_SOURCE_ID "2024-10-21 10:47:24 9f642b3dbc8febfacad97076030f44e9b40067e27222f2bcb84813c5765d3d2a" |
| 468 | 468 | |
| 469 | 469 | /* |
| 470 | 470 | ** CAPI3REF: Run-Time Library Version Numbers |
| 471 | 471 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 472 | 472 | ** |
| | @@ -13543,11 +13543,10 @@ |
| 13543 | 13543 | ** CUSTOM TOKENIZERS |
| 13544 | 13544 | ** |
| 13545 | 13545 | ** Applications may also register custom tokenizer types. A tokenizer |
| 13546 | 13546 | ** is registered by providing fts5 with a populated instance of the |
| 13547 | 13547 | ** following structure. All structure methods must be defined, setting |
| 13548 | | -** |
| 13549 | 13548 | ** any member of the fts5_tokenizer struct to NULL leads to undefined |
| 13550 | 13549 | ** behaviour. The structure methods are expected to function as follows: |
| 13551 | 13550 | ** |
| 13552 | 13551 | ** xCreate: |
| 13553 | 13552 | ** This function is used to allocate and initialize a tokenizer instance. |
| | @@ -16410,10 +16409,13 @@ |
| 16410 | 16409 | struct KeyInfo*, /* First argument to compare function */ |
| 16411 | 16410 | BtCursor *pCursor /* Space to write cursor structure */ |
| 16412 | 16411 | ); |
| 16413 | 16412 | SQLITE_PRIVATE BtCursor *sqlite3BtreeFakeValidCursor(void); |
| 16414 | 16413 | SQLITE_PRIVATE int sqlite3BtreeCursorSize(void); |
| 16414 | +#ifdef SQLITE_DEBUG |
| 16415 | +SQLITE_PRIVATE int sqlite3BtreeClosesWithCursor(Btree*,BtCursor*); |
| 16416 | +#endif |
| 16415 | 16417 | SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*); |
| 16416 | 16418 | SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned); |
| 16417 | 16419 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 16418 | 16420 | SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...); |
| 16419 | 16421 | #endif |
| | @@ -19796,11 +19798,11 @@ |
| 19796 | 19798 | ** |
| 19797 | 19799 | ** SRT_Set The result must be a single column. Store each |
| 19798 | 19800 | ** row of result as the key in table pDest->iSDParm. |
| 19799 | 19801 | ** Apply the affinity pDest->affSdst before storing |
| 19800 | 19802 | ** results. if pDest->iSDParm2 is positive, then it is |
| 19801 | | -** a regsiter holding a Bloom filter for the IN operator |
| 19803 | +** a register holding a Bloom filter for the IN operator |
| 19802 | 19804 | ** that should be populated in addition to the |
| 19803 | 19805 | ** pDest->iSDParm table. This SRT is used to |
| 19804 | 19806 | ** implement "IN (SELECT ...)". |
| 19805 | 19807 | ** |
| 19806 | 19808 | ** SRT_EphemTab Create an temporary table pDest->iSDParm and store |
| | @@ -36991,108 +36993,10 @@ |
| 36991 | 36993 | i += pIn[i+1]; |
| 36992 | 36994 | }while( i<mx ); |
| 36993 | 36995 | return 0; |
| 36994 | 36996 | } |
| 36995 | 36997 | |
| 36996 | | -/* |
| 36997 | | -** High-resolution hardware timer used for debugging and testing only. |
| 36998 | | -*/ |
| 36999 | | -#if defined(VDBE_PROFILE) \ |
| 37000 | | - || defined(SQLITE_PERFORMANCE_TRACE) \ |
| 37001 | | - || defined(SQLITE_ENABLE_STMT_SCANSTATUS) |
| 37002 | | -/************** Include hwtime.h in the middle of util.c *********************/ |
| 37003 | | -/************** Begin file hwtime.h ******************************************/ |
| 37004 | | -/* |
| 37005 | | -** 2008 May 27 |
| 37006 | | -** |
| 37007 | | -** The author disclaims copyright to this source code. In place of |
| 37008 | | -** a legal notice, here is a blessing: |
| 37009 | | -** |
| 37010 | | -** May you do good and not evil. |
| 37011 | | -** May you find forgiveness for yourself and forgive others. |
| 37012 | | -** May you share freely, never taking more than you give. |
| 37013 | | -** |
| 37014 | | -****************************************************************************** |
| 37015 | | -** |
| 37016 | | -** This file contains inline asm code for retrieving "high-performance" |
| 37017 | | -** counters for x86 and x86_64 class CPUs. |
| 37018 | | -*/ |
| 37019 | | -#ifndef SQLITE_HWTIME_H |
| 37020 | | -#define SQLITE_HWTIME_H |
| 37021 | | - |
| 37022 | | -/* |
| 37023 | | -** The following routine only works on Pentium-class (or newer) processors. |
| 37024 | | -** It uses the RDTSC opcode to read the cycle count value out of the |
| 37025 | | -** processor and returns that value. This can be used for high-res |
| 37026 | | -** profiling. |
| 37027 | | -*/ |
| 37028 | | -#if !defined(__STRICT_ANSI__) && \ |
| 37029 | | - (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 37030 | | - (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 37031 | | - |
| 37032 | | - #if defined(__GNUC__) |
| 37033 | | - |
| 37034 | | - __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 37035 | | - unsigned int lo, hi; |
| 37036 | | - __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); |
| 37037 | | - return (sqlite_uint64)hi << 32 | lo; |
| 37038 | | - } |
| 37039 | | - |
| 37040 | | - #elif defined(_MSC_VER) |
| 37041 | | - |
| 37042 | | - __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ |
| 37043 | | - __asm { |
| 37044 | | - rdtsc |
| 37045 | | - ret ; return value at EDX:EAX |
| 37046 | | - } |
| 37047 | | - } |
| 37048 | | - |
| 37049 | | - #endif |
| 37050 | | - |
| 37051 | | -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) |
| 37052 | | - |
| 37053 | | - __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 37054 | | - unsigned int lo, hi; |
| 37055 | | - __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); |
| 37056 | | - return (sqlite_uint64)hi << 32 | lo; |
| 37057 | | - } |
| 37058 | | - |
| 37059 | | -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) |
| 37060 | | - |
| 37061 | | - __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 37062 | | - unsigned long long retval; |
| 37063 | | - unsigned long junk; |
| 37064 | | - __asm__ __volatile__ ("\n\ |
| 37065 | | - 1: mftbu %1\n\ |
| 37066 | | - mftb %L0\n\ |
| 37067 | | - mftbu %0\n\ |
| 37068 | | - cmpw %0,%1\n\ |
| 37069 | | - bne 1b" |
| 37070 | | - : "=r" (retval), "=r" (junk)); |
| 37071 | | - return retval; |
| 37072 | | - } |
| 37073 | | - |
| 37074 | | -#else |
| 37075 | | - |
| 37076 | | - /* |
| 37077 | | - ** asm() is needed for hardware timing support. Without asm(), |
| 37078 | | - ** disable the sqlite3Hwtime() routine. |
| 37079 | | - ** |
| 37080 | | - ** sqlite3Hwtime() is only used for some obscure debugging |
| 37081 | | - ** and analysis configurations, not in any deliverable, so this |
| 37082 | | - ** should not be a great loss. |
| 37083 | | - */ |
| 37084 | | -SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 37085 | | - |
| 37086 | | -#endif |
| 37087 | | - |
| 37088 | | -#endif /* !defined(SQLITE_HWTIME_H) */ |
| 37089 | | - |
| 37090 | | -/************** End of hwtime.h **********************************************/ |
| 37091 | | -/************** Continuing where we left off in util.c ***********************/ |
| 37092 | | -#endif |
| 37093 | | - |
| 37094 | 36998 | /************** End of util.c ************************************************/ |
| 37095 | 36999 | /************** Begin file hash.c ********************************************/ |
| 37096 | 37000 | /* |
| 37097 | 37001 | ** 2001 September 22 |
| 37098 | 37002 | ** |
| | @@ -67523,11 +67427,11 @@ |
| 67523 | 67427 | return SQLITE_IOERR_IN_PAGE; |
| 67524 | 67428 | } |
| 67525 | 67429 | |
| 67526 | 67430 | /* |
| 67527 | 67431 | ** Assert that the Wal.lockMask mask, which indicates the locks held |
| 67528 | | -** by the connenction, is consistent with the Wal.readLock, Wal.writeLock |
| 67432 | +** by the connection, is consistent with the Wal.readLock, Wal.writeLock |
| 67529 | 67433 | ** and Wal.ckptLock variables. To be used as: |
| 67530 | 67434 | ** |
| 67531 | 67435 | ** assert( walAssertLockmask(pWal) ); |
| 67532 | 67436 | */ |
| 67533 | 67437 | static int walAssertLockmask(Wal *pWal){ |
| | @@ -75480,10 +75384,29 @@ |
| 75480 | 75384 | ** this routine. |
| 75481 | 75385 | */ |
| 75482 | 75386 | SQLITE_PRIVATE int sqlite3BtreeCursorSize(void){ |
| 75483 | 75387 | return ROUND8(sizeof(BtCursor)); |
| 75484 | 75388 | } |
| 75389 | + |
| 75390 | +#ifdef SQLITE_DEBUG |
| 75391 | +/* |
| 75392 | +** Return true if and only if the Btree object will be automatically |
| 75393 | +** closed with the BtCursor closes. This is used within assert() statements |
| 75394 | +** only. |
| 75395 | +*/ |
| 75396 | +SQLITE_PRIVATE int sqlite3BtreeClosesWithCursor( |
| 75397 | + Btree *pBtree, /* the btree object */ |
| 75398 | + BtCursor *pCur /* Corresponding cursor */ |
| 75399 | +){ |
| 75400 | + BtShared *pBt = pBtree->pBt; |
| 75401 | + if( (pBt->openFlags & BTREE_SINGLE)==0 ) return 0; |
| 75402 | + if( pBt->pCursor!=pCur ) return 0; |
| 75403 | + if( pCur->pNext!=0 ) return 0; |
| 75404 | + if( pCur->pBtree!=pBtree ) return 0; |
| 75405 | + return 1; |
| 75406 | +} |
| 75407 | +#endif |
| 75485 | 75408 | |
| 75486 | 75409 | /* |
| 75487 | 75410 | ** Initialize memory that will be converted into a BtCursor object. |
| 75488 | 75411 | ** |
| 75489 | 75412 | ** The simple approach here would be to memset() the entire object |
| | @@ -93384,10 +93307,108 @@ |
| 93384 | 93307 | ** commenting and indentation practices when changing or adding code. |
| 93385 | 93308 | */ |
| 93386 | 93309 | /* #include "sqliteInt.h" */ |
| 93387 | 93310 | /* #include "vdbeInt.h" */ |
| 93388 | 93311 | |
| 93312 | +/* |
| 93313 | +** High-resolution hardware timer used for debugging and testing only. |
| 93314 | +*/ |
| 93315 | +#if defined(VDBE_PROFILE) \ |
| 93316 | + || defined(SQLITE_PERFORMANCE_TRACE) \ |
| 93317 | + || defined(SQLITE_ENABLE_STMT_SCANSTATUS) |
| 93318 | +/************** Include hwtime.h in the middle of vdbe.c *********************/ |
| 93319 | +/************** Begin file hwtime.h ******************************************/ |
| 93320 | +/* |
| 93321 | +** 2008 May 27 |
| 93322 | +** |
| 93323 | +** The author disclaims copyright to this source code. In place of |
| 93324 | +** a legal notice, here is a blessing: |
| 93325 | +** |
| 93326 | +** May you do good and not evil. |
| 93327 | +** May you find forgiveness for yourself and forgive others. |
| 93328 | +** May you share freely, never taking more than you give. |
| 93329 | +** |
| 93330 | +****************************************************************************** |
| 93331 | +** |
| 93332 | +** This file contains inline asm code for retrieving "high-performance" |
| 93333 | +** counters for x86 and x86_64 class CPUs. |
| 93334 | +*/ |
| 93335 | +#ifndef SQLITE_HWTIME_H |
| 93336 | +#define SQLITE_HWTIME_H |
| 93337 | + |
| 93338 | +/* |
| 93339 | +** The following routine only works on Pentium-class (or newer) processors. |
| 93340 | +** It uses the RDTSC opcode to read the cycle count value out of the |
| 93341 | +** processor and returns that value. This can be used for high-res |
| 93342 | +** profiling. |
| 93343 | +*/ |
| 93344 | +#if !defined(__STRICT_ANSI__) && \ |
| 93345 | + (defined(__GNUC__) || defined(_MSC_VER)) && \ |
| 93346 | + (defined(i386) || defined(__i386__) || defined(_M_IX86)) |
| 93347 | + |
| 93348 | + #if defined(__GNUC__) |
| 93349 | + |
| 93350 | + __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 93351 | + unsigned int lo, hi; |
| 93352 | + __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); |
| 93353 | + return (sqlite_uint64)hi << 32 | lo; |
| 93354 | + } |
| 93355 | + |
| 93356 | + #elif defined(_MSC_VER) |
| 93357 | + |
| 93358 | + __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ |
| 93359 | + __asm { |
| 93360 | + rdtsc |
| 93361 | + ret ; return value at EDX:EAX |
| 93362 | + } |
| 93363 | + } |
| 93364 | + |
| 93365 | + #endif |
| 93366 | + |
| 93367 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) |
| 93368 | + |
| 93369 | + __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 93370 | + unsigned int lo, hi; |
| 93371 | + __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); |
| 93372 | + return (sqlite_uint64)hi << 32 | lo; |
| 93373 | + } |
| 93374 | + |
| 93375 | +#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) |
| 93376 | + |
| 93377 | + __inline__ sqlite_uint64 sqlite3Hwtime(void){ |
| 93378 | + unsigned long long retval; |
| 93379 | + unsigned long junk; |
| 93380 | + __asm__ __volatile__ ("\n\ |
| 93381 | + 1: mftbu %1\n\ |
| 93382 | + mftb %L0\n\ |
| 93383 | + mftbu %0\n\ |
| 93384 | + cmpw %0,%1\n\ |
| 93385 | + bne 1b" |
| 93386 | + : "=r" (retval), "=r" (junk)); |
| 93387 | + return retval; |
| 93388 | + } |
| 93389 | + |
| 93390 | +#else |
| 93391 | + |
| 93392 | + /* |
| 93393 | + ** asm() is needed for hardware timing support. Without asm(), |
| 93394 | + ** disable the sqlite3Hwtime() routine. |
| 93395 | + ** |
| 93396 | + ** sqlite3Hwtime() is only used for some obscure debugging |
| 93397 | + ** and analysis configurations, not in any deliverable, so this |
| 93398 | + ** should not be a great loss. |
| 93399 | + */ |
| 93400 | +SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 93401 | + |
| 93402 | +#endif |
| 93403 | + |
| 93404 | +#endif /* !defined(SQLITE_HWTIME_H) */ |
| 93405 | + |
| 93406 | +/************** End of hwtime.h **********************************************/ |
| 93407 | +/************** Continuing where we left off in vdbe.c ***********************/ |
| 93408 | +#endif |
| 93409 | + |
| 93389 | 93410 | /* |
| 93390 | 93411 | ** Invoke this macro on memory cells just prior to changing the |
| 93391 | 93412 | ** value of the cell. This macro verifies that shallow copies are |
| 93392 | 93413 | ** not misused. A shallow copy of a string or blob just copies a |
| 93393 | 93414 | ** pointer to the string or blob, not the content. If the original |
| | @@ -97893,11 +97914,14 @@ |
| 97893 | 97914 | pCx->isTable = 1; |
| 97894 | 97915 | } |
| 97895 | 97916 | } |
| 97896 | 97917 | pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED); |
| 97897 | 97918 | if( rc ){ |
| 97919 | + assert( !sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) ); |
| 97898 | 97920 | sqlite3BtreeClose(pCx->ub.pBtx); |
| 97921 | + }else{ |
| 97922 | + assert( sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) ); |
| 97899 | 97923 | } |
| 97900 | 97924 | } |
| 97901 | 97925 | } |
| 97902 | 97926 | if( rc ) goto abort_due_to_error; |
| 97903 | 97927 | pCx->nullRow = 1; |
| | @@ -102411,11 +102435,11 @@ |
| 102411 | 102435 | ** element. |
| 102412 | 102436 | ** |
| 102413 | 102437 | ** As with all opcodes, the meanings of the parameters for OP_Explain |
| 102414 | 102438 | ** are subject to change from one release to the next. Applications |
| 102415 | 102439 | ** should not attempt to interpret or use any of the information |
| 102416 | | -** contined in the OP_Explain opcode. The information provided by this |
| 102440 | +** contained in the OP_Explain opcode. The information provided by this |
| 102417 | 102441 | ** opcode is intended for testing and debugging use only. |
| 102418 | 102442 | */ |
| 102419 | 102443 | default: { /* This is really OP_Noop, OP_Explain */ |
| 102420 | 102444 | assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain ); |
| 102421 | 102445 | |
| | @@ -120790,12 +120814,12 @@ |
| 120790 | 120814 | int nIdxCol = 1; /* Number of columns in stat4 records */ |
| 120791 | 120815 | |
| 120792 | 120816 | char *zIndex; /* Index name */ |
| 120793 | 120817 | Index *pIdx; /* Pointer to the index object */ |
| 120794 | 120818 | int nSample; /* Number of samples */ |
| 120795 | | - int nByte; /* Bytes of space required */ |
| 120796 | | - int i; /* Bytes of space required */ |
| 120819 | + i64 nByte; /* Bytes of space required */ |
| 120820 | + i64 i; /* Bytes of space required */ |
| 120797 | 120821 | tRowcnt *pSpace; /* Available allocated memory space */ |
| 120798 | 120822 | u8 *pPtr; /* Available memory as a u8 for easier manipulation */ |
| 120799 | 120823 | |
| 120800 | 120824 | zIndex = (char *)sqlite3_column_text(pStmt, 0); |
| 120801 | 120825 | if( zIndex==0 ) continue; |
| | @@ -165729,11 +165753,11 @@ |
| 165729 | 165753 | ** Return TRUE if X is a proper subset of Y but is of equal or less cost. |
| 165730 | 165754 | ** In other words, return true if all constraints of X are also part of Y |
| 165731 | 165755 | ** and Y has additional constraints that might speed the search that X lacks |
| 165732 | 165756 | ** but the cost of running X is not more than the cost of running Y. |
| 165733 | 165757 | ** |
| 165734 | | -** In other words, return true if the cost relationwship between X and Y |
| 165758 | +** In other words, return true if the cost relationship between X and Y |
| 165735 | 165759 | ** is inverted and needs to be adjusted. |
| 165736 | 165760 | ** |
| 165737 | 165761 | ** Case 1: |
| 165738 | 165762 | ** |
| 165739 | 165763 | ** (1a) X and Y use the same index. |
| | @@ -233188,11 +233212,10 @@ |
| 233188 | 233212 | ** CUSTOM TOKENIZERS |
| 233189 | 233213 | ** |
| 233190 | 233214 | ** Applications may also register custom tokenizer types. A tokenizer |
| 233191 | 233215 | ** is registered by providing fts5 with a populated instance of the |
| 233192 | 233216 | ** following structure. All structure methods must be defined, setting |
| 233193 | | -** |
| 233194 | 233217 | ** any member of the fts5_tokenizer struct to NULL leads to undefined |
| 233195 | 233218 | ** behaviour. The structure methods are expected to function as follows: |
| 233196 | 233219 | ** |
| 233197 | 233220 | ** xCreate: |
| 233198 | 233221 | ** This function is used to allocate and initialize a tokenizer instance. |
| | @@ -254863,11 +254886,11 @@ |
| 254863 | 254886 | int nArg, /* Number of args */ |
| 254864 | 254887 | sqlite3_value **apUnused /* Function arguments */ |
| 254865 | 254888 | ){ |
| 254866 | 254889 | assert( nArg==0 ); |
| 254867 | 254890 | UNUSED_PARAM2(nArg, apUnused); |
| 254868 | | - sqlite3_result_text(pCtx, "fts5: 2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c", -1, SQLITE_TRANSIENT); |
| 254891 | + sqlite3_result_text(pCtx, "fts5: 2024-10-21 10:47:24 9f642b3dbc8febfacad97076030f44e9b40067e27222f2bcb84813c5765d3d2a", -1, SQLITE_TRANSIENT); |
| 254869 | 254892 | } |
| 254870 | 254893 | |
| 254871 | 254894 | /* |
| 254872 | 254895 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 254873 | 254896 | ** |
| 254874 | 254897 | |