| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.43.0. By combining all the individual C code files into this |
| 3 | +** version 3.43.1. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -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 | | -** c7eeb055bfb0e5a4467d8a45fa53d84bb8a. |
| 21 | +** d3a40c05c49e1a49264912b1a05bc2143ac. |
| 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 |
| | @@ -457,13 +457,13 @@ |
| 457 | 457 | ** |
| 458 | 458 | ** See also: [sqlite3_libversion()], |
| 459 | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | 461 | */ |
| 462 | | -#define SQLITE_VERSION "3.43.0" |
| 463 | | -#define SQLITE_VERSION_NUMBER 3043000 |
| 464 | | -#define SQLITE_SOURCE_ID "2023-08-18 12:15:44 ec7eeb055bfb0e5a4467d8a45fa53d84bb8ae80ca0474b687e2783e971648008" |
| 462 | +#define SQLITE_VERSION "3.43.1" |
| 463 | +#define SQLITE_VERSION_NUMBER 3043001 |
| 464 | +#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" |
| 465 | 465 | |
| 466 | 466 | /* |
| 467 | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | 469 | ** |
| | @@ -15655,11 +15655,11 @@ |
| 15655 | 15655 | #else |
| 15656 | 15656 | # define disable_simulated_io_errors() |
| 15657 | 15657 | # define enable_simulated_io_errors() |
| 15658 | 15658 | #endif |
| 15659 | 15659 | |
| 15660 | | -#ifdef SQLITE_USE_SEH |
| 15660 | +#if defined(SQLITE_USE_SEH) && !defined(SQLITE_OMIT_WAL) |
| 15661 | 15661 | SQLITE_PRIVATE int sqlite3PagerWalSystemErrno(Pager*); |
| 15662 | 15662 | #endif |
| 15663 | 15663 | |
| 15664 | 15664 | #endif /* SQLITE_PAGER_H */ |
| 15665 | 15665 | |
| | @@ -35178,11 +35178,11 @@ |
| 35178 | 35178 | ** precision. |
| 35179 | 35179 | ** |
| 35180 | 35180 | ** The error terms on constants like 1.0e+100 computed using the |
| 35181 | 35181 | ** decimal extension, for example as follows: |
| 35182 | 35182 | ** |
| 35183 | | - ** SELECT decimal_sci(decimal_sub('1.0e+100',decimal(1.0e+100))); |
| 35183 | + ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); |
| 35184 | 35184 | */ |
| 35185 | 35185 | double rr[2]; |
| 35186 | 35186 | rr[0] = r; |
| 35187 | 35187 | rr[1] = 0.0; |
| 35188 | 35188 | if( rr[0]>1.84e+19 ){ |
| | @@ -53452,18 +53452,28 @@ |
| 53452 | 53452 | |
| 53453 | 53453 | /* |
| 53454 | 53454 | ** Return 1 if pPg is on the dirty list for pCache. Return 0 if not. |
| 53455 | 53455 | ** This routine runs inside of assert() statements only. |
| 53456 | 53456 | */ |
| 53457 | | -#ifdef SQLITE_DEBUG |
| 53457 | +#if defined(SQLITE_ENABLE_EXPENSIVE_ASSERT) |
| 53458 | 53458 | static int pageOnDirtyList(PCache *pCache, PgHdr *pPg){ |
| 53459 | 53459 | PgHdr *p; |
| 53460 | 53460 | for(p=pCache->pDirty; p; p=p->pDirtyNext){ |
| 53461 | 53461 | if( p==pPg ) return 1; |
| 53462 | 53462 | } |
| 53463 | 53463 | return 0; |
| 53464 | 53464 | } |
| 53465 | +static int pageNotOnDirtyList(PCache *pCache, PgHdr *pPg){ |
| 53466 | + PgHdr *p; |
| 53467 | + for(p=pCache->pDirty; p; p=p->pDirtyNext){ |
| 53468 | + if( p==pPg ) return 0; |
| 53469 | + } |
| 53470 | + return 1; |
| 53471 | +} |
| 53472 | +#else |
| 53473 | +# define pageOnDirtyList(A,B) 1 |
| 53474 | +# define pageNotOnDirtyList(A,B) 1 |
| 53465 | 53475 | #endif |
| 53466 | 53476 | |
| 53467 | 53477 | /* |
| 53468 | 53478 | ** Check invariants on a PgHdr entry. Return true if everything is OK. |
| 53469 | 53479 | ** Return false if any invariant is violated. |
| | @@ -53480,11 +53490,11 @@ |
| 53480 | 53490 | assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */ |
| 53481 | 53491 | pCache = pPg->pCache; |
| 53482 | 53492 | assert( pCache!=0 ); /* Every page has an associated PCache */ |
| 53483 | 53493 | if( pPg->flags & PGHDR_CLEAN ){ |
| 53484 | 53494 | assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */ |
| 53485 | | - assert( !pageOnDirtyList(pCache, pPg) );/* CLEAN pages not on dirty list */ |
| 53495 | + assert( pageNotOnDirtyList(pCache, pPg) );/* CLEAN pages not on dirtylist */ |
| 53486 | 53496 | }else{ |
| 53487 | 53497 | assert( (pPg->flags & PGHDR_DIRTY)!=0 );/* If not CLEAN must be DIRTY */ |
| 53488 | 53498 | assert( pPg->pDirtyNext==0 || pPg->pDirtyNext->pDirtyPrev==pPg ); |
| 53489 | 53499 | assert( pPg->pDirtyPrev==0 || pPg->pDirtyPrev->pDirtyNext==pPg ); |
| 53490 | 53500 | assert( pPg->pDirtyPrev!=0 || pCache->pDirty==pPg ); |
| | @@ -56130,10 +56140,11 @@ |
| 56130 | 56140 | # define sqlite3WalExclusiveMode(y,z) 0 |
| 56131 | 56141 | # define sqlite3WalHeapMemory(z) 0 |
| 56132 | 56142 | # define sqlite3WalFramesize(z) 0 |
| 56133 | 56143 | # define sqlite3WalFindFrame(x,y,z) 0 |
| 56134 | 56144 | # define sqlite3WalFile(x) 0 |
| 56145 | +# undef SQLITE_USE_SEH |
| 56135 | 56146 | #else |
| 56136 | 56147 | |
| 56137 | 56148 | #define WAL_SAVEPOINT_NDATA 4 |
| 56138 | 56149 | |
| 56139 | 56150 | /* Connection to a write-ahead log (WAL) file. |
| | @@ -128448,12 +128459,14 @@ |
| 128448 | 128459 | p = sqlite3_aggregate_context(context, 0); |
| 128449 | 128460 | if( p && p->cnt>0 ){ |
| 128450 | 128461 | if( p->approx ){ |
| 128451 | 128462 | if( p->ovrfl ){ |
| 128452 | 128463 | sqlite3_result_error(context,"integer overflow",-1); |
| 128453 | | - }else{ |
| 128464 | + }else if( !sqlite3IsNaN(p->rErr) ){ |
| 128454 | 128465 | sqlite3_result_double(context, p->rSum+p->rErr); |
| 128466 | + }else{ |
| 128467 | + sqlite3_result_double(context, p->rSum); |
| 128455 | 128468 | } |
| 128456 | 128469 | }else{ |
| 128457 | 128470 | sqlite3_result_int64(context, p->iSum); |
| 128458 | 128471 | } |
| 128459 | 128472 | } |
| | @@ -128462,11 +128475,12 @@ |
| 128462 | 128475 | SumCtx *p; |
| 128463 | 128476 | p = sqlite3_aggregate_context(context, 0); |
| 128464 | 128477 | if( p && p->cnt>0 ){ |
| 128465 | 128478 | double r; |
| 128466 | 128479 | if( p->approx ){ |
| 128467 | | - r = p->rSum+p->rErr; |
| 128480 | + r = p->rSum; |
| 128481 | + if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; |
| 128468 | 128482 | }else{ |
| 128469 | 128483 | r = (double)(p->iSum); |
| 128470 | 128484 | } |
| 128471 | 128485 | sqlite3_result_double(context, r/(double)p->cnt); |
| 128472 | 128486 | } |
| | @@ -128475,11 +128489,12 @@ |
| 128475 | 128489 | SumCtx *p; |
| 128476 | 128490 | double r = 0.0; |
| 128477 | 128491 | p = sqlite3_aggregate_context(context, 0); |
| 128478 | 128492 | if( p ){ |
| 128479 | 128493 | if( p->approx ){ |
| 128480 | | - r = p->rSum+p->rErr; |
| 128494 | + r = p->rSum; |
| 128495 | + if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; |
| 128481 | 128496 | }else{ |
| 128482 | 128497 | r = (double)(p->iSum); |
| 128483 | 128498 | } |
| 128484 | 128499 | } |
| 128485 | 128500 | sqlite3_result_double(context, r); |
| | @@ -145678,16 +145693,16 @@ |
| 145678 | 145693 | assert( pItem->pTab!=0 ); |
| 145679 | 145694 | pTab = pItem->pTab; |
| 145680 | 145695 | assert( pItem->pSelect!=0 ); |
| 145681 | 145696 | pSub = pItem->pSelect; |
| 145682 | 145697 | assert( pSub->pEList->nExpr==pTab->nCol ); |
| 145683 | | - if( (pSub->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ |
| 145684 | | - testcase( pSub->selFlags & SF_Distinct ); |
| 145685 | | - testcase( pSub->selFlags & SF_Aggregate ); |
| 145686 | | - return 0; |
| 145687 | | - } |
| 145688 | 145698 | for(pX=pSub; pX; pX=pX->pPrior){ |
| 145699 | + if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ |
| 145700 | + testcase( pX->selFlags & SF_Distinct ); |
| 145701 | + testcase( pX->selFlags & SF_Aggregate ); |
| 145702 | + return 0; |
| 145703 | + } |
| 145689 | 145704 | if( pX->pPrior && pX->op!=TK_ALL ){ |
| 145690 | 145705 | /* This optimization does not work for compound subqueries that |
| 145691 | 145706 | ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ |
| 145692 | 145707 | return 0; |
| 145693 | 145708 | } |
| | @@ -198071,11 +198086,11 @@ |
| 198071 | 198086 | Fts3SegFilter filter; |
| 198072 | 198087 | Fts3MultiSegReader csr; |
| 198073 | 198088 | int rc; |
| 198074 | 198089 | u64 cksum = 0; |
| 198075 | 198090 | |
| 198076 | | - assert( *pRc==SQLITE_OK ); |
| 198091 | + if( *pRc ) return 0; |
| 198077 | 198092 | |
| 198078 | 198093 | memset(&filter, 0, sizeof(filter)); |
| 198079 | 198094 | memset(&csr, 0, sizeof(csr)); |
| 198080 | 198095 | filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY; |
| 198081 | 198096 | filter.flags |= FTS3_SEGMENT_SCAN; |
| | @@ -203701,11 +203716,13 @@ |
| 203701 | 203716 | if( pNode==0 ){ |
| 203702 | 203717 | return; |
| 203703 | 203718 | } |
| 203704 | 203719 | if( pNode->eType==JSON_ARRAY ){ |
| 203705 | 203720 | while( 1 /*exit-by-break*/ ){ |
| 203706 | | - for(i=1; i<=pNode->n; n++){ |
| 203721 | + i = 1; |
| 203722 | + while( i<=pNode->n ){ |
| 203723 | + if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++; |
| 203707 | 203724 | i += jsonNodeSize(&pNode[i]); |
| 203708 | 203725 | } |
| 203709 | 203726 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; |
| 203710 | 203727 | if( p->useMod==0 ) break; |
| 203711 | 203728 | assert( pNode->eU==2 ); |
| | @@ -206989,11 +207006,11 @@ |
| 206989 | 207006 | #ifdef SQLITE_RTREE_INT_ONLY |
| 206990 | 207007 | p->u.rValue = iVal; |
| 206991 | 207008 | #else |
| 206992 | 207009 | p->u.rValue = (double)iVal; |
| 206993 | 207010 | if( iVal>=((sqlite3_int64)1)<<48 |
| 206994 | | - || -iVal>=((sqlite3_int64)1)<<48 |
| 207011 | + || iVal<=-(((sqlite3_int64)1)<<48) |
| 206995 | 207012 | ){ |
| 206996 | 207013 | if( p->op==RTREE_LT ) p->op = RTREE_LE; |
| 206997 | 207014 | if( p->op==RTREE_GT ) p->op = RTREE_GE; |
| 206998 | 207015 | } |
| 206999 | 207016 | #endif |
| | @@ -222973,19 +222990,23 @@ |
| 222973 | 222990 | pIn->iNext += nByte; |
| 222974 | 222991 | } |
| 222975 | 222992 | } |
| 222976 | 222993 | } |
| 222977 | 222994 | if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 222978 | | - sqlite3_int64 v = sessionGetI64(aVal); |
| 222979 | | - if( eType==SQLITE_INTEGER ){ |
| 222980 | | - sqlite3VdbeMemSetInt64(apOut[i], v); |
| 222995 | + if( (pIn->nData-pIn->iNext)<8 ){ |
| 222996 | + rc = SQLITE_CORRUPT_BKPT; |
| 222981 | 222997 | }else{ |
| 222982 | | - double d; |
| 222983 | | - memcpy(&d, &v, 8); |
| 222984 | | - sqlite3VdbeMemSetDouble(apOut[i], d); |
| 222998 | + sqlite3_int64 v = sessionGetI64(aVal); |
| 222999 | + if( eType==SQLITE_INTEGER ){ |
| 223000 | + sqlite3VdbeMemSetInt64(apOut[i], v); |
| 223001 | + }else{ |
| 223002 | + double d; |
| 223003 | + memcpy(&d, &v, 8); |
| 223004 | + sqlite3VdbeMemSetDouble(apOut[i], d); |
| 223005 | + } |
| 223006 | + pIn->iNext += 8; |
| 222985 | 223007 | } |
| 222986 | | - pIn->iNext += 8; |
| 222987 | 223008 | } |
| 222988 | 223009 | } |
| 222989 | 223010 | } |
| 222990 | 223011 | |
| 222991 | 223012 | return rc; |
| | @@ -239807,84 +239828,83 @@ |
| 239807 | 239828 | iOff += nSuffix2; |
| 239808 | 239829 | iNextOff += nSuffix2; |
| 239809 | 239830 | } |
| 239810 | 239831 | } |
| 239811 | 239832 | }else if( iStart==4 ){ |
| 239812 | | - int iPgno; |
| 239813 | | - |
| 239814 | | - assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); |
| 239815 | | - /* The entry being removed may be the only position list in |
| 239816 | | - ** its doclist. */ |
| 239817 | | - for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ |
| 239818 | | - Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); |
| 239819 | | - int bEmpty = (pPg && pPg->nn==4); |
| 239820 | | - fts5DataRelease(pPg); |
| 239821 | | - if( bEmpty==0 ) break; |
| 239822 | | - } |
| 239823 | | - |
| 239824 | | - if( iPgno==pSeg->iTermLeafPgno ){ |
| 239825 | | - i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); |
| 239826 | | - Fts5Data *pTerm = fts5DataRead(p, iId); |
| 239827 | | - if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ |
| 239828 | | - u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; |
| 239829 | | - int nTermIdx = pTerm->nn - pTerm->szLeaf; |
| 239830 | | - int iTermIdx = 0; |
| 239831 | | - int iTermOff = 0; |
| 239832 | | - |
| 239833 | | - while( 1 ){ |
| 239834 | | - u32 iVal = 0; |
| 239835 | | - int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); |
| 239836 | | - iTermOff += iVal; |
| 239837 | | - if( (iTermIdx+nByte)>=nTermIdx ) break; |
| 239838 | | - iTermIdx += nByte; |
| 239839 | | - } |
| 239840 | | - nTermIdx = iTermIdx; |
| 239841 | | - |
| 239842 | | - memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); |
| 239843 | | - fts5PutU16(&pTerm->p[2], iTermOff); |
| 239844 | | - |
| 239845 | | - fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); |
| 239846 | | - if( nTermIdx==0 ){ |
| 239847 | | - fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); |
| 239848 | | - } |
| 239849 | | - } |
| 239850 | | - fts5DataRelease(pTerm); |
| 239851 | | - } |
| 239852 | | - } |
| 239853 | | - |
| 239854 | | - if( p->rc==SQLITE_OK ){ |
| 239855 | | - const int nMove = nPg - iNextOff; |
| 239856 | | - int nShift = 0; |
| 239857 | | - |
| 239858 | | - memmove(&aPg[iOff], &aPg[iNextOff], nMove); |
| 239859 | | - iPgIdx -= (iNextOff - iOff); |
| 239860 | | - nPg = iPgIdx; |
| 239861 | | - fts5PutU16(&aPg[2], iPgIdx); |
| 239862 | | - |
| 239863 | | - nShift = iNextOff - iOff; |
| 239864 | | - for(iIdx=0, iKeyOff=0, iPrevKeyOff=0; iIdx<nIdx; /* no-op */){ |
| 239865 | | - u32 iVal = 0; |
| 239866 | | - iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 239867 | | - iKeyOff += iVal; |
| 239868 | | - if( iKeyOff!=iDelKeyOff ){ |
| 239869 | | - if( iKeyOff>iOff ){ |
| 239870 | | - iKeyOff -= nShift; |
| 239871 | | - nShift = 0; |
| 239872 | | - } |
| 239873 | | - nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOff - iPrevKeyOff); |
| 239874 | | - iPrevKeyOff = iKeyOff; |
| 239875 | | - } |
| 239876 | | - } |
| 239877 | | - |
| 239878 | | - if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ |
| 239879 | | - fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); |
| 239880 | | - } |
| 239881 | | - |
| 239882 | | - assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); |
| 239883 | | - fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg,nPg); |
| 239884 | | - } |
| 239885 | | - sqlite3_free(aIdx); |
| 239833 | + int iPgno; |
| 239834 | + |
| 239835 | + assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); |
| 239836 | + /* The entry being removed may be the only position list in |
| 239837 | + ** its doclist. */ |
| 239838 | + for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ |
| 239839 | + Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); |
| 239840 | + int bEmpty = (pPg && pPg->nn==4); |
| 239841 | + fts5DataRelease(pPg); |
| 239842 | + if( bEmpty==0 ) break; |
| 239843 | + } |
| 239844 | + |
| 239845 | + if( iPgno==pSeg->iTermLeafPgno ){ |
| 239846 | + i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); |
| 239847 | + Fts5Data *pTerm = fts5DataRead(p, iId); |
| 239848 | + if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ |
| 239849 | + u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; |
| 239850 | + int nTermIdx = pTerm->nn - pTerm->szLeaf; |
| 239851 | + int iTermIdx = 0; |
| 239852 | + int iTermOff = 0; |
| 239853 | + |
| 239854 | + while( 1 ){ |
| 239855 | + u32 iVal = 0; |
| 239856 | + int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); |
| 239857 | + iTermOff += iVal; |
| 239858 | + if( (iTermIdx+nByte)>=nTermIdx ) break; |
| 239859 | + iTermIdx += nByte; |
| 239860 | + } |
| 239861 | + nTermIdx = iTermIdx; |
| 239862 | + |
| 239863 | + memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); |
| 239864 | + fts5PutU16(&pTerm->p[2], iTermOff); |
| 239865 | + |
| 239866 | + fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); |
| 239867 | + if( nTermIdx==0 ){ |
| 239868 | + fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); |
| 239869 | + } |
| 239870 | + } |
| 239871 | + fts5DataRelease(pTerm); |
| 239872 | + } |
| 239873 | + } |
| 239874 | + |
| 239875 | + if( p->rc==SQLITE_OK ){ |
| 239876 | + const int nMove = nPg - iNextOff; /* Number of bytes to move */ |
| 239877 | + int nShift = iNextOff - iOff; /* Distance to move them */ |
| 239878 | + |
| 239879 | + int iPrevKeyOut = 0; |
| 239880 | + int iKeyIn = 0; |
| 239881 | + |
| 239882 | + memmove(&aPg[iOff], &aPg[iNextOff], nMove); |
| 239883 | + iPgIdx -= nShift; |
| 239884 | + nPg = iPgIdx; |
| 239885 | + fts5PutU16(&aPg[2], iPgIdx); |
| 239886 | + |
| 239887 | + for(iIdx=0; iIdx<nIdx; /* no-op */){ |
| 239888 | + u32 iVal = 0; |
| 239889 | + iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 239890 | + iKeyIn += iVal; |
| 239891 | + if( iKeyIn!=iDelKeyOff ){ |
| 239892 | + int iKeyOut = (iKeyIn - (iKeyIn>iOff ? nShift : 0)); |
| 239893 | + nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOut - iPrevKeyOut); |
| 239894 | + iPrevKeyOut = iKeyOut; |
| 239895 | + } |
| 239896 | + } |
| 239897 | + |
| 239898 | + if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ |
| 239899 | + fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); |
| 239900 | + } |
| 239901 | + |
| 239902 | + assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); |
| 239903 | + fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg, nPg); |
| 239904 | + } |
| 239905 | + sqlite3_free(aIdx); |
| 239886 | 239906 | } |
| 239887 | 239907 | |
| 239888 | 239908 | /* |
| 239889 | 239909 | ** This is called as part of flushing a delete to disk in 'secure-delete' |
| 239890 | 239910 | ** mode. It edits the segments within the database described by argument |
| | @@ -240030,11 +240050,12 @@ |
| 240030 | 240050 | fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ |
| 240031 | 240051 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); |
| 240032 | 240052 | writer.bFirstRowidInPage = 0; |
| 240033 | 240053 | fts5WriteDlidxAppend(p, &writer, iRowid); |
| 240034 | 240054 | }else{ |
| 240035 | | - pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid-iPrev); |
| 240055 | + u64 iRowidDelta = (u64)iRowid - (u64)iPrev; |
| 240056 | + pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowidDelta); |
| 240036 | 240057 | } |
| 240037 | 240058 | if( p->rc!=SQLITE_OK ) break; |
| 240038 | 240059 | assert( pBuf->n<=pBuf->nSpace ); |
| 240039 | 240060 | iPrev = iRowid; |
| 240040 | 240061 | |
| | @@ -245731,11 +245752,11 @@ |
| 245731 | 245752 | int nArg, /* Number of args */ |
| 245732 | 245753 | sqlite3_value **apUnused /* Function arguments */ |
| 245733 | 245754 | ){ |
| 245734 | 245755 | assert( nArg==0 ); |
| 245735 | 245756 | UNUSED_PARAM2(nArg, apUnused); |
| 245736 | | - sqlite3_result_text(pCtx, "fts5: 2023-08-17 17:48:20 3c06709335eb4b98e3a684e3ebbae69eeb6a21b452bce29159c82bb632d6a042", -1, SQLITE_TRANSIENT); |
| 245757 | + sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); |
| 245737 | 245758 | } |
| 245738 | 245759 | |
| 245739 | 245760 | /* |
| 245740 | 245761 | ** Return true if zName is the extension on one of the shadow tables used |
| 245741 | 245762 | ** by this module. |
| 245742 | 245763 | |