From 43f0227d31417a632b232472f7c53840b7e74a17 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 18 Oct 2026 00:54:35 +0000 Subject: [PATCH] deps: update sqlite to 3.54.1 --- deps/sqlite/sqlite3.c | 375 ++++++++++++++++++++++++------------------ deps/sqlite/sqlite3.h | 12 +- 2 files changed, 223 insertions(+), 164 deletions(-) diff --git a/deps/sqlite/sqlite3.c b/deps/sqlite/sqlite3.c index 79280989734f..ac7549011639 100644 --- a/deps/sqlite/sqlite3.c +++ b/deps/sqlite/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.54.0. By combining all the individual C code files into this +** version 3.54.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** be8d059e9a49089ab2dce5ed26dd87aaf598 with changes in files: +** 555e07ef33f69a0957d24d8e555b702464a1 with changes in files: ** ** */ @@ -467,12 +467,12 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.54.0" -#define SQLITE_VERSION_NUMBER 3054000 -#define SQLITE_SOURCE_ID "2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3" -#define SQLITE_SCM_BRANCH "trunk" -#define SQLITE_SCM_TAGS "release major-release version-3.54.0" -#define SQLITE_SCM_DATETIME "2026-10-09T15:46:58.543Z" +#define SQLITE_VERSION "3.54.1" +#define SQLITE_VERSION_NUMBER 3054001 +#define SQLITE_SOURCE_ID "2026-10-16 14:45:20 555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76" +#define SQLITE_SCM_BRANCH "branch-3.54" +#define SQLITE_SCM_TAGS "release version-3.54.1" +#define SQLITE_SCM_DATETIME "2026-10-16T14:45:20.546Z" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -21121,6 +21121,7 @@ struct Parse { int nErr; /* Number of errors seen */ int nTab; /* Number of previously allocated VDBE cursors */ int nMem; /* Number of memory cells used so far */ + int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ int iSelfTab; /* Table associated with an index on expr, or negative ** of the base register during check-constraint eval */ int nNestSel; /* Number of nested SELECT statements and/or VIEWs */ @@ -26058,6 +26059,21 @@ static void computeJD(DateTime *p){ } } +/* +** Return the number of dates in a specific month. +*/ +static int daysOfMonth(int Y, int M){ + if( (1<validYMD || p->isError ); - assert( p->D>=0 && p->D<=31 ); + assert( p->D>=0 && p->D<=32 ); assert( p->M>=0 && p->M<=12 ); - if( p->validHMS && p->h==24 ){ - p->h = 0; - p->D++; - } - if( p->D<=28 ){ - p->nFloor = 0; - }else if( (1<M) & 0x15aa ){ - p->nFloor = 0; - }else if( p->M!=2 ){ - p->nFloor = (p->D==31); - }else if( p->Y%4!=0 || (p->Y%100==0 && p->Y%400!=0) ){ - p->nFloor = p->D - 28; - }else{ - p->nFloor = p->D - 29; - } + mxD = daysOfMonth(p->Y, p->M); + p->nFloor = p->D>mxD ? p->D - mxD : 0; } /* @@ -26112,7 +26116,19 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){ zDate += 10; while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; } if( parseHhMmSs(zDate, p)==0 ){ - /* We got the time */ + if( p->h==24 ){ + int mxD = daysOfMonth(Y,M); + p->h = 0; + D++; + if( D>mxD ){ + D -= mxD; + M++; + if( M>12 ){ + M = 1; + Y++; + } + } + } }else if( *zDate==0 ){ p->validHMS = 0; }else{ @@ -46242,28 +46258,35 @@ static void unixRemapfile( #endif if( pOrig ){ + i64 nReuse = pFd->mmapSize & ~((int)osGetpagesize()-1); + + /* Unmap any part of the current mapping that will not be reused */ + if( nReusemmapSizeActual ){ + osMunmap(&pOrig[nReuse], pFd->mmapSizeActual - nReuse); + } + + /* If nReuse is now zero, then the entire mapping was unmapped by the + ** call above. In this case do not attempt to extend pOrig. */ + if( nReuse>0 ){ #if HAVE_MREMAP - i64 nReuse = pFd->mmapSize; - pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE); - zErr = "mremap"; + pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE); + zErr = "mremap"; #else - const int szSyspage = osGetpagesize(); - i64 nReuse = (pFd->mmapSize & ~(szSyspage-1)); - u8 *pReq = &pOrig[nReuse]; - pNew = osMmap(pReq, nNew-nReuse, flags, MAP_SHARED, h, nReuse); - if( pNew!=MAP_FAILED ){ - if( pNew!=pReq ){ - osMunmap(pNew, nNew - nReuse); - pNew = 0; - }else{ - pNew = pOrig; + pNew = osMmap(&pOrig[nReuse], nNew-nReuse, flags, MAP_SHARED, h, nReuse); + if( pNew!=MAP_FAILED ){ + if( pNew!=&pOrig[nReuse] ){ + osMunmap(pNew, nNew - nReuse); + pNew = 0; + }else{ + pNew = pOrig; + } } - } #endif - /* The attempt to extend the existing mapping failed. Free it. */ - if( pNew==MAP_FAILED || pNew==0 ){ - osMunmap(pOrig, nReuse); + /* The attempt to extend the existing mapping failed. Free it. */ + if( pNew==MAP_FAILED || pNew==0 ){ + osMunmap(pOrig, nReuse); + } } } @@ -87488,6 +87511,7 @@ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ assert( pParse->aLabel==0 ); assert( pParse->nLabel==0 ); assert( p->nOpAlloc==0 ); + assert( pParse->szOpAlloc==0 ); sqlite3VdbeAddOp2(p, OP_Init, 0, 1); return p; } @@ -87518,6 +87542,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlag p->prepFlags = prepFlags; if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){ p->expmask = 0; + p->smimask = 0; } assert( p->zSql==0 ); p->zSql = sqlite3DbStrNDup(p->db, z, n); @@ -87638,7 +87663,8 @@ static int growOpArray(Vdbe *v, int nOp){ assert( nNew>=(v->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); if( pNew ){ - v->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op); + p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew); + v->nOpAlloc = p->szOpAlloc/sizeof(Op); v->aOp = pNew; } return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT); @@ -90145,7 +90171,7 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady( n = ROUND8P(sizeof(Op)*p->nOp); /* Bytes of opcode memory used */ x.pSpace = &((u8*)p->aOp)[n]; /* Unused opcode memory */ assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) ); - x.nFree = ROUNDDOWN8((p->nOpAlloc-p->nOp)*sizeof(Op)); /* Bytes unused mem */ + x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes unused memory */ assert( x.nFree>=0 ); assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) ); @@ -92796,10 +92822,12 @@ SQLITE_PRIVATE void sqlite3VdbeReprepareOnBind(Vdbe *v, int iVar, int bSmallint) || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 ); m = (iVar>=32) ? 0x80000000 : ((u32)1 << (iVar-1)); - v->expmask |= m; if( bSmallint ){ - v->smimask |= m; + if( (v->expmask & m)==0 ) v->smimask |= m; + }else{ + v->smimask &= ~m; } + v->expmask |= m; /* smimask is always a subset of expmask */ assert( (v->smimask & v->expmask) == v->smimask ); @@ -94952,10 +94980,8 @@ static int vdbeUnbind(Vdbe *p, unsigned int i){ sqlite3_mutex_leave(p->db->mutex); return SQLITE_RANGE; } + pVar = &p->aVar[i]; - sqlite3VdbeMemRelease(pVar); - pVar->flags = MEM_Null; - p->db->errCode = SQLITE_OK; /* If the bit corresponding to this variable in Vdbe.expmask is set, then ** binding a new value to this variable invalidates the current query plan. @@ -94969,11 +94995,20 @@ static int vdbeUnbind(Vdbe *p, unsigned int i){ assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 ); assert( (p->expmask & p->smimask)==p->smimask ); if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<smimask is set and the old - ** value is an integer other than (0,1). But that is such a corner - ** case that it does not seem worth the extra code to implement. */ - p->expired = 1; + /* If the p->smimask bit is also set, then only expire the statement if + ** the value being clobbered was integer value 0 or 1. */ + if( (p->smimask==0) + || (p->smimask & (i>=31 ? 0x80000000 : (u32)1<flags & MEM_Int)!=0 && pVar->u.i>=0 && pVar->u.i<=1) + ){ + p->expired = 1; + } } + + sqlite3VdbeMemRelease(pVar); + pVar->flags = MEM_Null; + p->db->errCode = SQLITE_OK; + return SQLITE_OK; } @@ -95101,8 +95136,8 @@ SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValu if( sm1!=sm2 ){ p->expired = 1; } - }else if( (pVar->flags & MEM_Int)==0 || pVar->u.i!=iValue ){ - /* Always expire if the value really is changing */ + }else if( (pVar->flags & MEM_Int)==0 || iValue!=pVar->u.i ){ + /* Always expire if the smimask bit is clear */ p->expired = 1; } } @@ -98407,7 +98442,18 @@ case OP_AddImm: { /* in1 */ case OP_MustBeInt: { /* jump0, in1 */ pIn1 = &aMem[pOp->p1]; if( (pIn1->flags & MEM_Int)==0 ){ - applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); + if( (pIn1->flags & MEM_Real)!=0 ){ + sqlite3_int64 ix; + if( pIn1->u.r>=-9223372036854775808.0 + && pIn1->u.r<+9223372036854775808.0 + && (double)(ix = sqlite3RealToI64(pIn1->u.r))==pIn1->u.r + ){ + pIn1->u.i = ix; + MemSetTypeFlag(pIn1, MEM_Int); + } + }else{ + applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); + } if( (pIn1->flags & MEM_Int)==0 ){ VdbeBranchTaken(1, 2); if( pOp->p2==0 ){ @@ -115777,10 +115823,7 @@ SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){ ** is marked so as to cause the statement to be reprepared each time a new ** value is bound to it. Except, if parameter bRSI is true, then the statement ** will only be reprepared if the rebind changes the value to or from a -** "small integer" (either 0 or 1). Note that if p is a variable then -** reprepare is always enabled for that variable, regardless of its current -** binding. The RSI is only enabled if the current binding is a small -** integer. "RSI" stands for "Reprepare Small Integers". +** "small integer" (either 0 or 1). */ SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr *p, int *pValue, Parse *pParse, int bRSI){ int iSign = 1; /* Either +1 or -1. */ @@ -115803,7 +115846,6 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr *p, int *pValue, Parse *pPars } if( p->op==TK_VARIABLE && pParse!=0 ){ sqlite3_value *pVal; /* The variable */ - int isSmall = 0; /* Only reprepare if change to/from small integer */ int rc = 0; /* 1 if successful, 0 if failed */ assert( iSign==1 ); if( NEVER(pParse->pVdbe==0) ) break; @@ -115817,14 +115859,11 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr *p, int *pValue, Parse *pPars && vv<=0x7fffffff ){ *pValue = (int)vv; - if( bRSI ){ - isSmall = vv<=1; - } rc = 1; } sqlite3ValueFree(pVal); } - sqlite3VdbeReprepareOnBind(pParse->pVdbe, p->iColumn, isSmall); + sqlite3VdbeReprepareOnBind(pParse->pVdbe, p->iColumn, bRSI); return rc; } break; @@ -116865,6 +116904,12 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ } sqlite3VdbeScanStatusRange(v, addrExplain, addrExplain, -1); + if( dest.eDest==SRT_Mem + && sqlite3ExprCanReturnSubtype(pParse, pSel->pEList->a[0].pExpr) + ){ + sqlite3VdbeAddOp1(v, OP_ClrSubtype, rReg); + } + /* Subroutine return */ assert( ExprUseYSub(pExpr) ); assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn @@ -117084,7 +117129,6 @@ static void sqlite3ExprCodeIN( testcase( aiMap[i]!=i ); sqlite3VdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0); } - sqlite3ReleaseTempReg(pParse, rLhsOrig); } } @@ -117620,7 +117664,7 @@ static int exprCodeInlineFunction( ** ** The only expressions that can return a subtype are: ** -** 1. A function +** 1. A function, including an aggregate function ** 2. The no-op "+" operator ** 3. A CASE...END expression ** 4. A CAST() expression @@ -117645,14 +117689,19 @@ static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ ){ return WRC_Continue; } - if( pExpr->op!=TK_FUNCTION ){ + if( pExpr->op!=TK_FUNCTION && pExpr->op!=TK_AGG_FUNCTION ){ return WRC_Prune; } assert( ExprUseXList(pExpr) ); db = pWalker->pParse->db; n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); - if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION + if( pDef==0 ) return WRC_Continue; +#else + assert( pDef!=0 ); +#endif + if( (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ pWalker->eCode = 1; return WRC_Abort; } @@ -117722,10 +117771,16 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup( v = pParse->pVdbe; assert( v!=0 ); - if( p->bMaybeNullRow ){ - /* If the index is on a NULL row due to an outer join, then we - ** cannot extract the value from the index. The value must be - ** computed using the original expression. */ + if( p->bMaybeNullRow || sqlite3ExprIsConstant(pParse, pExpr) ){ + /* The value of pExpr should be computed from the original expression, + ** not from the index, if either: + ** + ** 1. The index might be on a NULL row due to an outer join. + ** + ** 2. The expression is a constant. This prevents an attempt to + ** use an index value outside of the loop that positions the + ** index. (Bug 2026-10-11T19:26:40Z). + */ int addr = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp3(v, OP_IfNullRow, p->iIdxCur, addr+3, target); VdbeCoverage(v); @@ -120452,7 +120507,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ if( pOBList->nExpr==1 && nArg==1 && sqlite3ExprCompare(0,pOBList->a[0].pExpr, - pExpr->x.pList->a[0].pExpr,0)==0 + pExpr->x.pList->a[0].pExpr,-1)==0 ){ pItem->bOBPayload = 0; pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); @@ -120540,6 +120595,13 @@ SQLITE_PRIVATE int sqlite3GetTempReg(Parse *pParse){ */ SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){ if( iReg ){ +#ifdef SQLITE_DEBUG + /* Verify that iReg is not already on the unused register list */ + int kk; + for(kk=0; kknTempReg; kk++){ + assert( pParse->aTempReg[kk]!=iReg ); + } +#endif sqlite3VdbeReleaseRegisters(pParse, iReg, 1, 0, 0); if( pParse->nTempRegaTempReg) ){ pParse->aTempReg[pParse->nTempReg++] = iReg; @@ -127358,6 +127420,7 @@ SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){ for(i=0; inDb; i++){ if( DbHasProperty(db, i, DB_ResetWanted) ){ sqlite3SchemaClear(db->aDb[i].pSchema); + db->mDbFlags &= ~DBFLAG_SchemaKnownOk; } } } @@ -153608,7 +153671,9 @@ static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){ if( op==TK_COLUMN || op==TK_IF_NULL_ROW ){ renumberCursorDoMapping(pWalker, &pExpr->iTable); } - if( ExprHasProperty(pExpr, EP_OuterON) ){ + if( ExprHasProperty(pExpr, (EP_OuterON|EP_InnerON)) ){ + testcase( ExprHasProperty(pExpr, EP_OuterON) ); + testcase( ExprHasProperty(pExpr, EP_InnerON) ); renumberCursorDoMapping(pWalker, &pExpr->w.iJoin); } return WRC_Continue; @@ -154488,7 +154553,7 @@ static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ ** ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or ** CONSTANT=COLUMN that are top-level AND-connected terms that are not -** part of a ON clause from a LEFT JOIN, then throughout the query +** part of a ON clause from an OUTER JOIN, then throughout the query ** replace all other occurrences of COLUMN with CONSTANT. ** ** For example, the query: @@ -174720,13 +174785,13 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ ** direction because there is no way to run a co-routine backwards. */ static SQLITE_NOINLINE int wherePathMatchSubqueryOB( - WhereInfo *pWInfo, /* The WHERE clause */ WhereLoop *pLoop, /* The nested loop term that is a subquery */ int iLoop, /* Which level of the nested loop. 0==outermost */ int iCur, /* Cursor used by the this loop */ ExprList *pOrderBy, /* The ORDER BY clause on the whole query */ Bitmask *pRevMask, /* When loops need to go in reverse order */ - Bitmask *pOBSat /* Which terms of pOrderBy are satisfied so far */ + Bitmask *pOBSat, /* Which terms of pOrderBy are satisfied so far */ + u16 wctrlFlags /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */ ){ int iOB; /* Index into pOrderBy->a[] */ int jSub; /* Index into pSubOB->a[] */ @@ -174744,7 +174809,7 @@ static SQLITE_NOINLINE int wherePathMatchSubqueryOB( if( pOBExpr->op!=TK_COLUMN && pOBExpr->op!=TK_AGG_COLUMN ) break; if( pOBExpr->iTable!=iCur ) break; if( pOBExpr->iColumn!=pSubOB->a[jSub].u.x.iOrderByCol-1 ) break; - if( (pWInfo->wctrlFlags & WHERE_GROUPBY)==0 ){ + if( (wctrlFlags & WHERE_GROUPBY)==0 ){ u8 sfOB = pOrderBy->a[iOB].fg.sortFlags; /* sortFlags for iOB */ u8 sfSub = pSubOB->a[jSub].fg.sortFlags; /* sortFlags for jSub */ if( (sfSub & KEYINFO_ORDER_BIGNULL) != (sfOB & KEYINFO_ORDER_BIGNULL) ){ @@ -174926,8 +174991,8 @@ static i8 wherePathSatisfiesOrderBy( if( pLoop->wsFlags & WHERE_IPK ){ if( pLoop->u.btree.pOrderBy && OptimizationEnabled(db, SQLITE_OrderBySubq) - && wherePathMatchSubqueryOB(pWInfo,pLoop,iLoop,iCur, - pOrderBy,pRevMask, &obSat) + && wherePathMatchSubqueryOB(pLoop,iLoop,iCur, + pOrderBy,pRevMask, &obSat, wctrlFlags) ){ nColumn = 0; isOrderDistinct = 0; @@ -212951,13 +213016,11 @@ SQLITE_PRIVATE void sqlite3Fts3Matchinfo( /* #include "fts3_tokenizer.h" */ /* -** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied -** from the sqlite3 source file utf.c. If this file is compiled as part -** of the amalgamation, they are not required. +** The following two macros - FTS3_READ_UTF8 and FTS3_WRITE_UTF8 - have +** been copied from the sqlite3 source file utf.c. */ -#ifndef SQLITE_AMALGAMATION -static const unsigned char sqlite3Utf8Trans1[] = { +static const unsigned char fts3Utf8Trans1[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -212968,10 +213031,10 @@ static const unsigned char sqlite3Utf8Trans1[] = { 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, }; -#define READ_UTF8(zIn, zTerm, c) \ +#define FTS3_READ_UTF8(zIn, zTerm, c) \ c = *(zIn++); \ if( c>=0xc0 ){ \ - c = sqlite3Utf8Trans1[c-0xc0]; \ + c = fts3Utf8Trans1[c-0xc0]; \ while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ c = (c<<6) + (0x3f & *(zIn++)); \ } \ @@ -212980,28 +213043,26 @@ static const unsigned char sqlite3Utf8Trans1[] = { || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ } -#define WRITE_UTF8(zOut, c) { \ - if( c<0x00080 ){ \ - *zOut++ = (u8)(c&0xFF); \ - } \ - else if( c<0x00800 ){ \ - *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); \ - *zOut++ = 0x80 + (u8)(c & 0x3F); \ - } \ - else if( c<0x10000 ){ \ - *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); \ - *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ - *zOut++ = 0x80 + (u8)(c & 0x3F); \ - }else{ \ - *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); \ - *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); \ - *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ - *zOut++ = 0x80 + (u8)(c & 0x3F); \ - } \ +#define FTS3_WRITE_UTF8(zOut, c) { \ + if( c<0x00080 ){ \ + *zOut++ = (u8)(c&0xFF); \ + } \ + else if( c<0x00800 ){ \ + *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); \ + *zOut++ = 0x80 + (u8)(c & 0x3F); \ + } \ + else if( c<0x10000 ){ \ + *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); \ + *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ + *zOut++ = 0x80 + (u8)(c & 0x3F); \ + }else{ \ + *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); \ + *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); \ + *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); \ + *zOut++ = 0x80 + (u8)(c & 0x3F); \ + } \ } -#endif /* ifndef SQLITE_AMALGAMATION */ - typedef struct unicode_tokenizer unicode_tokenizer; typedef struct unicode_cursor unicode_cursor; @@ -213067,7 +213128,7 @@ static int unicodeAddExceptions( assert( bAlnum==0 || bAlnum==1 ); while( zeRemoveDiacritic); if( iOut ){ - WRITE_UTF8(zOut, iOut); + FTS3_WRITE_UTF8(zOut, iOut); } /* If the cursor is not at EOF, read the next character */ if( z>=zTerm ) break; - READ_UTF8(z, zTerm, iCode); + FTS3_READ_UTF8(z, zTerm, iCode); }while( unicodeIsAlnum(p, (int)iCode) || sqlite3FtsUnicodeIsdiacritic((int)iCode) ); @@ -214109,6 +214170,7 @@ struct JsonParse { */ #define JSON_EDITABLE 0x01 /* Generate a writable JsonParse object */ #define JSON_KEEPERROR 0x02 /* Return non-NULL even if there is an error */ +#define JSON_NOCACHE 0x04 /* Do not use the JSON cache */ /************************************************************************** ** Forward references @@ -217552,7 +217614,9 @@ static JsonParse *jsonParseFuncArg( if( eType==SQLITE_NULL ){ return 0; } - pFromCache = jsonCacheSearch(ctx, pArg); + if( (flgs & JSON_NOCACHE)==0 ){ + pFromCache = jsonCacheSearch(ctx, pArg); + } if( pFromCache ){ pFromCache->nJPRef++; if( (flgs & JSON_EDITABLE)==0 ){ @@ -218627,7 +218691,7 @@ static void jsonValidFunc( if( (flags & 0x3)==0 ) break; memset(&px, 0, sizeof(px)); - p = jsonParseFuncArg(ctx, argv[0], JSON_KEEPERROR); + p = jsonParseFuncArg(ctx, argv[0], JSON_KEEPERROR|JSON_NOCACHE); if( p ){ if( p->oom ){ sqlite3_result_error_nomem(ctx); @@ -265409,7 +265473,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2026-10-16 14:45:20 555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76", -1, SQLITE_TRANSIENT); } /* @@ -267413,13 +267477,10 @@ static int fts5AsciiTokenize( /* -** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied -** from the sqlite3 source file utf.c. If this file is compiled as part -** of the amalgamation, they are not required. +** The following two macros - FTS5_READ_UTF8 and FTS5_WRITE_UTF8 - have +** been copied from the sqlite3 source file utf.c. */ -#ifndef SQLITE_AMALGAMATION - -static const unsigned char sqlite3Utf8Trans1[] = { +static const unsigned char fts5Utf8Trans1[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -267430,45 +267491,43 @@ static const unsigned char sqlite3Utf8Trans1[] = { 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, }; -#define READ_UTF8(zIn, zTerm, c) \ +#define FTS5_READ_UTF8(zIn, zTerm, c) \ c = *(zIn++); \ if( c>=0xc0 ){ \ - c = sqlite3Utf8Trans1[c-0xc0]; \ + c = fts5Utf8Trans1[c-0xc0]; \ while( zIn>6)&0x1F); \ - *zOut++ = 0x80 + (unsigned char)(c & 0x3F); \ - } \ - else if( c<0x10000 ){ \ - *zOut++ = 0xE0 + (unsigned char)((c>>12)&0x0F); \ - *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F); \ - *zOut++ = 0x80 + (unsigned char)(c & 0x3F); \ - }else{ \ - *zOut++ = 0xF0 + (unsigned char)((c>>18) & 0x07); \ - *zOut++ = 0x80 + (unsigned char)((c>>12) & 0x3F); \ - *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F); \ - *zOut++ = 0x80 + (unsigned char)(c & 0x3F); \ - } \ +#define FTS5_WRITE_UTF8(zOut, c) { \ + if( c<0x00080 ){ \ + *zOut++ = (unsigned char)(c&0xFF); \ + } \ + else if( c<0x00800 ){ \ + *zOut++ = 0xC0 + (unsigned char)((c>>6)&0x1F); \ + *zOut++ = 0x80 + (unsigned char)(c & 0x3F); \ + } \ + else if( c<0x10000 ){ \ + *zOut++ = 0xE0 + (unsigned char)((c>>12)&0x0F); \ + *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F); \ + *zOut++ = 0x80 + (unsigned char)(c & 0x3F); \ + }else{ \ + *zOut++ = 0xF0 + (unsigned char)((c>>18) & 0x07); \ + *zOut++ = 0x80 + (unsigned char)((c>>12) & 0x3F); \ + *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F); \ + *zOut++ = 0x80 + (unsigned char)(c & 0x3F); \ + } \ } -#endif /* ifndef SQLITE_AMALGAMATION */ - -#define FTS5_SKIP_UTF8(zIn) { \ - if( ((unsigned char)(*(zIn++)))>=0xc0 ){ \ - while( (((unsigned char)*zIn) & 0xc0)==0x80 ){ zIn++; } \ - } \ +#define FTS5_SKIP_UTF8(zIn) { \ + if( ((unsigned char)(*(zIn++)))>=0xc0 ){ \ + while( (((unsigned char)*zIn) & 0xc0)==0x80 ){zIn++;} \ + } \ } typedef struct Unicode61Tokenizer Unicode61Tokenizer; @@ -267507,7 +267566,7 @@ static int fts5UnicodeAddExceptions( while( zCsraTokenChar[iCode] = (unsigned char)bTokenChars; }else{ @@ -267711,7 +267770,7 @@ static int fts5UnicodeTokenize( /* A character outside of the ascii range. Skip past it if it is ** a separator character. Or break out of the loop if it is not. */ is = zCsr - (unsigned char*)pText; - READ_UTF8(zCsr, zTerm, iCode); + FTS5_READ_UTF8(zCsr, zTerm, iCode); if( fts5UnicodeIsAlnum(p, iCode) ){ goto non_ascii_tokenchar; } @@ -267747,11 +267806,11 @@ static int fts5UnicodeTokenize( if( *zCsr & 0x80 ){ /* An non-ascii-range character. Fold it into the output buffer if ** it is a token character, or break out of the loop if it is not. */ - READ_UTF8(zCsr, zTerm, iCode); + FTS5_READ_UTF8(zCsr, zTerm, iCode); if( fts5UnicodeIsAlnum(p,iCode)||sqlite3Fts5UnicodeIsdiacritic(iCode) ){ non_ascii_tokenchar: iCode = sqlite3Fts5UnicodeFold(iCode, p->eRemoveDiacritic); - if( iCode ) WRITE_UTF8(zOut, iCode); + if( iCode ) FTS5_WRITE_UTF8(zOut, iCode); }else{ break; } @@ -268606,10 +268665,10 @@ static int fts5TriTokenize( do { aStart[ii] = zIn - (const unsigned char*)pText; if( zIn>=zEof ) return SQLITE_OK; - READ_UTF8(zIn, zEof, iCode); + FTS5_READ_UTF8(zIn, zEof, iCode); if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam); }while( iCode==0 ); - WRITE_UTF8(zOut, iCode); + FTS5_WRITE_UTF8(zOut, iCode); } /* At the start of each iteration of this loop: @@ -268631,7 +268690,7 @@ static int fts5TriTokenize( iCode = 0; break; } - READ_UTF8(zIn, zEof, iCode); + FTS5_READ_UTF8(zIn, zEof, iCode); if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam); }while( iCode==0 ); @@ -268645,7 +268704,7 @@ static int fts5TriTokenize( FTS5_SKIP_UTF8(z1); memmove(aBuf, z1, zOut - z1); zOut -= (z1 - aBuf); - WRITE_UTF8(zOut, iCode); + FTS5_WRITE_UTF8(zOut, iCode); /* Update the aStart[] array */ aStart[0] = aStart[1]; diff --git a/deps/sqlite/sqlite3.h b/deps/sqlite/sqlite3.h index 9a4ffb13d467..30d431bc34ae 100644 --- a/deps/sqlite/sqlite3.h +++ b/deps/sqlite/sqlite3.h @@ -146,12 +146,12 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.54.0" -#define SQLITE_VERSION_NUMBER 3054000 -#define SQLITE_SOURCE_ID "2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3" -#define SQLITE_SCM_BRANCH "trunk" -#define SQLITE_SCM_TAGS "release major-release version-3.54.0" -#define SQLITE_SCM_DATETIME "2026-10-09T15:46:58.543Z" +#define SQLITE_VERSION "3.54.1" +#define SQLITE_VERSION_NUMBER 3054001 +#define SQLITE_SOURCE_ID "2026-10-16 14:45:20 555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76" +#define SQLITE_SCM_BRANCH "branch-3.54" +#define SQLITE_SCM_TAGS "release version-3.54.1" +#define SQLITE_SCM_DATETIME "2026-10-16T14:45:20.546Z" /* ** CAPI3REF: Run-Time Library Version Numbers