| | @@ -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 | | -** 69ec714b2d698acf9e37635256c01b233ce3. |
| 21 | +** 5dede50d9e7b6942df9f7b00fbfeaa2103c3. |
| 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 |
| | @@ -459,11 +459,11 @@ |
| 459 | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | 461 | */ |
| 462 | 462 | #define SQLITE_VERSION "3.46.0" |
| 463 | 463 | #define SQLITE_VERSION_NUMBER 3046000 |
| 464 | | -#define SQLITE_SOURCE_ID "2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940" |
| 464 | +#define SQLITE_SOURCE_ID "2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d" |
| 465 | 465 | |
| 466 | 466 | /* |
| 467 | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | 469 | ** |
| | @@ -64141,11 +64141,11 @@ |
| 64141 | 64141 | /* |
| 64142 | 64142 | ** Return the file handle for the journal file (if it exists). |
| 64143 | 64143 | ** This will be either the rollback journal or the WAL file. |
| 64144 | 64144 | */ |
| 64145 | 64145 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ |
| 64146 | | -#if SQLITE_OMIT_WAL |
| 64146 | +#ifdef SQLITE_OMIT_WAL |
| 64147 | 64147 | return pPager->jfd; |
| 64148 | 64148 | #else |
| 64149 | 64149 | return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd; |
| 64150 | 64150 | #endif |
| 64151 | 64151 | } |
| | @@ -75632,10 +75632,14 @@ |
| 75632 | 75632 | } |
| 75633 | 75633 | } |
| 75634 | 75634 | memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); |
| 75635 | 75635 | pCur->curFlags |= BTCF_ValidOvfl; |
| 75636 | 75636 | }else{ |
| 75637 | + /* Sanity check the validity of the overflow page cache */ |
| 75638 | + assert( pCur->aOverflow[0]==nextPage || pCur->aOverflow[0]==0 ); |
| 75639 | + assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 ); |
| 75640 | + |
| 75637 | 75641 | /* If the overflow page-list cache has been allocated and the |
| 75638 | 75642 | ** entry for the first required overflow page is valid, skip |
| 75639 | 75643 | ** directly to it. |
| 75640 | 75644 | */ |
| 75641 | 75645 | if( pCur->aOverflow[offset/ovflSize] ){ |
| | @@ -76112,10 +76116,27 @@ |
| 76112 | 76116 | *pRes = 1; |
| 76113 | 76117 | rc = SQLITE_OK; |
| 76114 | 76118 | } |
| 76115 | 76119 | return rc; |
| 76116 | 76120 | } |
| 76121 | + |
| 76122 | +#ifdef SQLITE_DEBUG |
| 76123 | +/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that |
| 76124 | +** this flags are true for a consistent database. |
| 76125 | +** |
| 76126 | +** This routine is is called from within assert() statements only. |
| 76127 | +** It is an internal verification routine and does not appear in production |
| 76128 | +** builds. |
| 76129 | +*/ |
| 76130 | +static int cursorIsAtLastEntry(BtCursor *pCur){ |
| 76131 | + int ii; |
| 76132 | + for(ii=0; ii<pCur->iPage; ii++){ |
| 76133 | + if( pCur->aiIdx[ii]!=pCur->apPage[ii]->nCell ) return 0; |
| 76134 | + } |
| 76135 | + return pCur->ix==pCur->pPage->nCell-1 && pCur->pPage->leaf!=0; |
| 76136 | +} |
| 76137 | +#endif |
| 76117 | 76138 | |
| 76118 | 76139 | /* Move the cursor to the last entry in the table. Return SQLITE_OK |
| 76119 | 76140 | ** on success. Set *pRes to 0 if the cursor actually points to something |
| 76120 | 76141 | ** or set *pRes to 1 if the table is empty. |
| 76121 | 76142 | */ |
| | @@ -76141,22 +76162,11 @@ |
| 76141 | 76162 | assert( cursorOwnsBtShared(pCur) ); |
| 76142 | 76163 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 76143 | 76164 | |
| 76144 | 76165 | /* If the cursor already points to the last entry, this is a no-op. */ |
| 76145 | 76166 | if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){ |
| 76146 | | -#ifdef SQLITE_DEBUG |
| 76147 | | - /* This block serves to assert() that the cursor really does point |
| 76148 | | - ** to the last entry in the b-tree. */ |
| 76149 | | - int ii; |
| 76150 | | - for(ii=0; ii<pCur->iPage; ii++){ |
| 76151 | | - assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); |
| 76152 | | - } |
| 76153 | | - assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB ); |
| 76154 | | - testcase( pCur->ix!=pCur->pPage->nCell-1 ); |
| 76155 | | - /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */ |
| 76156 | | - assert( pCur->pPage->leaf ); |
| 76157 | | -#endif |
| 76167 | + assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB ); |
| 76158 | 76168 | *pRes = 0; |
| 76159 | 76169 | return SQLITE_OK; |
| 76160 | 76170 | } |
| 76161 | 76171 | return btreeLast(pCur, pRes); |
| 76162 | 76172 | } |
| | @@ -76205,10 +76215,11 @@ |
| 76205 | 76215 | *pRes = 0; |
| 76206 | 76216 | return SQLITE_OK; |
| 76207 | 76217 | } |
| 76208 | 76218 | if( pCur->info.nKey<intKey ){ |
| 76209 | 76219 | if( (pCur->curFlags & BTCF_AtLast)!=0 ){ |
| 76220 | + assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB ); |
| 76210 | 76221 | *pRes = -1; |
| 76211 | 76222 | return SQLITE_OK; |
| 76212 | 76223 | } |
| 76213 | 76224 | /* If the requested key is one more than the previous key, then |
| 76214 | 76225 | ** try to get there using sqlite3BtreeNext() rather than a full |
| | @@ -80010,11 +80021,11 @@ |
| 80010 | 80021 | dropCell(pPage, idx, info.nSize, &rc); |
| 80011 | 80022 | if( rc ) goto end_insert; |
| 80012 | 80023 | }else if( loc<0 && pPage->nCell>0 ){ |
| 80013 | 80024 | assert( pPage->leaf ); |
| 80014 | 80025 | idx = ++pCur->ix; |
| 80015 | | - pCur->curFlags &= ~BTCF_ValidNKey; |
| 80026 | + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 80016 | 80027 | }else{ |
| 80017 | 80028 | assert( pPage->leaf ); |
| 80018 | 80029 | } |
| 80019 | 80030 | rc = insertCellFast(pPage, idx, newCell, szNew); |
| 80020 | 80031 | assert( pPage->nOverflow==0 || rc==SQLITE_OK ); |
| | @@ -80040,11 +80051,11 @@ |
| 80040 | 80051 | ** larger than the largest existing key, it is possible to insert the |
| 80041 | 80052 | ** row without seeking the cursor. This can be a big performance boost. |
| 80042 | 80053 | */ |
| 80043 | 80054 | if( pPage->nOverflow ){ |
| 80044 | 80055 | assert( rc==SQLITE_OK ); |
| 80045 | | - pCur->curFlags &= ~(BTCF_ValidNKey); |
| 80056 | + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 80046 | 80057 | rc = balance(pCur); |
| 80047 | 80058 | |
| 80048 | 80059 | /* Must make sure nOverflow is reset to zero even if the balance() |
| 80049 | 80060 | ** fails. Internal data structure corruption will result otherwise. |
| 80050 | 80061 | ** Also, set the cursor state to invalid. This stops saveCursorPosition() |
| | @@ -135985,11 +135996,14 @@ |
| 135985 | 135996 | ** further downstream. */ |
| 135986 | 135997 | return 0; /* Corrupt schema - two indexes on the same btree */ |
| 135987 | 135998 | } |
| 135988 | 135999 | } |
| 135989 | 136000 | #ifndef SQLITE_OMIT_CHECK |
| 135990 | | - if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){ |
| 136001 | + if( pDest->pCheck |
| 136002 | + && (db->mDbFlags & DBFLAG_Vacuum)==0 |
| 136003 | + && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) |
| 136004 | + ){ |
| 135991 | 136005 | return 0; /* Tables have different CHECK constraints. Ticket #2252 */ |
| 135992 | 136006 | } |
| 135993 | 136007 | #endif |
| 135994 | 136008 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 135995 | 136009 | /* Disallow the transfer optimization if the destination table contains |
| | @@ -202436,11 +202450,11 @@ |
| 202436 | 202450 | }else{ |
| 202437 | 202451 | iScore += 1000; |
| 202438 | 202452 | } |
| 202439 | 202453 | mCover |= mPhrase; |
| 202440 | 202454 | |
| 202441 | | - for(j=0; j<pPhrase->nToken; j++){ |
| 202455 | + for(j=0; j<pPhrase->nToken && j<pIter->nSnippet; j++){ |
| 202442 | 202456 | mHighlight |= (mPos>>j); |
| 202443 | 202457 | } |
| 202444 | 202458 | |
| 202445 | 202459 | if( 0==(*pCsr & 0x0FE) ) break; |
| 202446 | 202460 | fts3GetDeltaPosition(&pCsr, &iCsr); |
| | @@ -252156,11 +252170,11 @@ |
| 252156 | 252170 | int nArg, /* Number of args */ |
| 252157 | 252171 | sqlite3_value **apUnused /* Function arguments */ |
| 252158 | 252172 | ){ |
| 252159 | 252173 | assert( nArg==0 ); |
| 252160 | 252174 | UNUSED_PARAM2(nArg, apUnused); |
| 252161 | | - sqlite3_result_text(pCtx, "fts5: 2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940", -1, SQLITE_TRANSIENT); |
| 252175 | + sqlite3_result_text(pCtx, "fts5: 2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d", -1, SQLITE_TRANSIENT); |
| 252162 | 252176 | } |
| 252163 | 252177 | |
| 252164 | 252178 | /* |
| 252165 | 252179 | ** Return true if zName is the extension on one of the shadow tables used |
| 252166 | 252180 | ** by this module. |
| 252167 | 252181 | |