Skip to content

Commit 3aa2762

Browse files
nodejs-github-bottargos
authored andcommitted
deps: update sqlite to 3.50.1
PR-URL: #58630 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 80eac14 commit 3aa2762

File tree

2 files changed

+73
-35
lines changed

2 files changed

+73
-35
lines changed

deps/sqlite/sqlite3.c

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3-
** version 3.50.0. By combining all the individual C code files into this
3+
** version 3.50.1. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
@@ -18,7 +18,7 @@
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21-
** dfc790f998f450d9c35e3ba1c8c89c17466c with changes in files:
21+
** b77dc5e0f596d2140d9ac682b2893ff65d3a with changes in files:
2222
**
2323
**
2424
*/
@@ -465,9 +465,9 @@ extern "C" {
465465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466
** [sqlite_version()] and [sqlite_source_id()].
467467
*/
468-
#define SQLITE_VERSION "3.50.0"
469-
#define SQLITE_VERSION_NUMBER 3050000
470-
#define SQLITE_SOURCE_ID "2025-05-29 14:26:00 dfc790f998f450d9c35e3ba1c8c89c17466cb559f87b0239e4aab9d34e28f742"
468+
#define SQLITE_VERSION "3.50.1"
469+
#define SQLITE_VERSION_NUMBER 3050001
470+
#define SQLITE_SOURCE_ID "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95"
471471

472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
@@ -18703,6 +18703,7 @@ struct CollSeq {
1870318703
#define SQLITE_AFF_INTEGER 0x44 /* 'D' */
1870418704
#define SQLITE_AFF_REAL 0x45 /* 'E' */
1870518705
#define SQLITE_AFF_FLEXNUM 0x46 /* 'F' */
18706+
#define SQLITE_AFF_DEFER 0x58 /* 'X' - defer computation until later */
1870618707

1870718708
#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
1870818709

@@ -43874,21 +43875,20 @@ static int unixShmLock(
4387443875
/* Check that, if this to be a blocking lock, no locks that occur later
4387543876
** in the following list than the lock being obtained are already held:
4387643877
**
43877-
** 1. Checkpointer lock (ofst==1).
43878-
** 2. Write lock (ofst==0).
43879-
** 3. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
43878+
** 1. Recovery lock (ofst==2).
43879+
** 2. Checkpointer lock (ofst==1).
43880+
** 3. Write lock (ofst==0).
43881+
** 4. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
4388043882
**
4388143883
** In other words, if this is a blocking lock, none of the locks that
4388243884
** occur later in the above list than the lock being obtained may be
4388343885
** held.
43884-
**
43885-
** It is not permitted to block on the RECOVER lock.
4388643886
*/
4388743887
#if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && defined(SQLITE_DEBUG)
4388843888
{
4388943889
u16 lockMask = (p->exclMask|p->sharedMask);
4389043890
assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || (
43891-
(ofst!=2) /* not RECOVER */
43891+
(ofst!=2 || lockMask==0)
4389243892
&& (ofst!=1 || lockMask==0 || lockMask==2)
4389343893
&& (ofst!=0 || lockMask<3)
4389443894
&& (ofst<3 || lockMask<(1<<ofst))
@@ -49849,7 +49849,11 @@ static int winHandleLockTimeout(
4984949849
if( res==WAIT_OBJECT_0 ){
4985049850
ret = TRUE;
4985149851
}else if( res==WAIT_TIMEOUT ){
49852+
#if SQLITE_ENABLE_SETLK_TIMEOUT==1
4985249853
rc = SQLITE_BUSY_TIMEOUT;
49854+
#else
49855+
rc = SQLITE_BUSY;
49856+
#endif
4985349857
}else{
4985449858
/* Some other error has occurred */
4985549859
rc = SQLITE_IOERR_LOCK;
@@ -51660,21 +51664,20 @@ static int winShmLock(
5166051664
/* Check that, if this to be a blocking lock, no locks that occur later
5166151665
** in the following list than the lock being obtained are already held:
5166251666
**
51663-
** 1. Checkpointer lock (ofst==1).
51664-
** 2. Write lock (ofst==0).
51665-
** 3. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
51667+
** 1. Recovery lock (ofst==2).
51668+
** 2. Checkpointer lock (ofst==1).
51669+
** 3. Write lock (ofst==0).
51670+
** 4. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK).
5166651671
**
5166751672
** In other words, if this is a blocking lock, none of the locks that
5166851673
** occur later in the above list than the lock being obtained may be
5166951674
** held.
51670-
**
51671-
** It is not permitted to block on the RECOVER lock.
5167251675
*/
5167351676
#if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && defined(SQLITE_DEBUG)
5167451677
{
5167551678
u16 lockMask = (p->exclMask|p->sharedMask);
5167651679
assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || (
51677-
(ofst!=2) /* not RECOVER */
51680+
(ofst!=2 || lockMask==0)
5167851681
&& (ofst!=1 || lockMask==0 || lockMask==2)
5167951682
&& (ofst!=0 || lockMask<3)
5168051683
&& (ofst<3 || lockMask<(1<<ofst))
@@ -58750,6 +58753,9 @@ struct Pager {
5875058753
Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
5875158754
char *zWal; /* File name for write-ahead log */
5875258755
#endif
58756+
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
58757+
sqlite3 *dbWal;
58758+
#endif
5875358759
};
5875458760

5875558761
/*
@@ -65631,6 +65637,11 @@ static int pagerOpenWal(Pager *pPager){
6563165637
pPager->fd, pPager->zWal, pPager->exclusiveMode,
6563265638
pPager->journalSizeLimit, &pPager->pWal
6563365639
);
65640+
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
65641+
if( rc==SQLITE_OK ){
65642+
sqlite3WalDb(pPager->pWal, pPager->dbWal);
65643+
}
65644+
#endif
6563465645
}
6563565646
pagerFixMaplimit(pPager);
6563665647

@@ -65750,6 +65761,7 @@ SQLITE_PRIVATE int sqlite3PagerWalWriteLock(Pager *pPager, int bLock){
6575065761
** blocking locks are required.
6575165762
*/
6575265763
SQLITE_PRIVATE void sqlite3PagerWalDb(Pager *pPager, sqlite3 *db){
65764+
pPager->dbWal = db;
6575365765
if( pagerUseWal(pPager) ){
6575465766
sqlite3WalDb(pPager->pWal, db);
6575565767
}
@@ -68923,7 +68935,6 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
6892368935
rc = walIndexReadHdr(pWal, pChanged);
6892468936
}
6892568937
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68926-
walDisableBlocking(pWal);
6892768938
if( rc==SQLITE_BUSY_TIMEOUT ){
6892868939
rc = SQLITE_BUSY;
6892968940
*pCnt |= WAL_RETRY_BLOCKED_MASK;
@@ -68938,6 +68949,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
6893868949
** WAL_RETRY this routine will be called again and will probably be
6893968950
** right on the second iteration.
6894068951
*/
68952+
(void)walEnableBlocking(pWal);
6894168953
if( pWal->apWiData[0]==0 ){
6894268954
/* This branch is taken when the xShmMap() method returns SQLITE_BUSY.
6894368955
** We assume this is a transient condition, so return WAL_RETRY. The
@@ -68954,6 +68966,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
6895468966
rc = SQLITE_BUSY_RECOVERY;
6895568967
}
6895668968
}
68969+
walDisableBlocking(pWal);
6895768970
if( rc!=SQLITE_OK ){
6895868971
return rc;
6895968972
}
@@ -75228,6 +75241,13 @@ static SQLITE_NOINLINE int btreeBeginTrans(
7522875241
(void)sqlite3PagerWalWriteLock(pPager, 0);
7522975242
unlockBtreeIfUnused(pBt);
7523075243
}
75244+
#if defined(SQLITE_ENABLE_SETLK_TIMEOUT)
75245+
if( rc==SQLITE_BUSY_TIMEOUT ){
75246+
/* If a blocking lock timed out, break out of the loop here so that
75247+
** the busy-handler is not invoked. */
75248+
break;
75249+
}
75250+
#endif
7523175251
}while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
7523275252
btreeInvokeBusyHandler(pBt) );
7523375253
sqlite3PagerWalDb(pPager, 0);
@@ -105039,7 +105059,7 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
105039105059
assert( pCsr->eCurType==CURTYPE_SORTER );
105040105060
assert( sizeof(KeyInfo) + UMXV(pCsr->pKeyInfo->nKeyField)*sizeof(CollSeq*)
105041105061
< 0x7fffffff );
105042-
szKeyInfo = SZ_KEYINFO(pCsr->pKeyInfo->nKeyField+1);
105062+
szKeyInfo = SZ_KEYINFO(pCsr->pKeyInfo->nKeyField);
105043105063
sz = SZ_VDBESORTER(nWorker+1);
105044105064

105045105065
pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);
@@ -110389,7 +110409,9 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){
110389110409
pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
110390110410
);
110391110411
}
110392-
if( op==TK_VECTOR ){
110412+
if( op==TK_VECTOR
110413+
|| (op==TK_FUNCTION && pExpr->affExpr==SQLITE_AFF_DEFER)
110414+
){
110393110415
assert( ExprUseXList(pExpr) );
110394110416
return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr);
110395110417
}
@@ -110582,7 +110604,9 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){
110582110604
p = p->pLeft;
110583110605
continue;
110584110606
}
110585-
if( op==TK_VECTOR ){
110607+
if( op==TK_VECTOR
110608+
|| (op==TK_FUNCTION && p->affExpr==SQLITE_AFF_DEFER)
110609+
){
110586110610
assert( ExprUseXList(p) );
110587110611
p = p->x.pList->a[0].pExpr;
110588110612
continue;
@@ -145364,7 +145388,7 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){
145364145388
}
145365145389
pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iLeftCol);
145366145390
sqlite3SrcItemColumnUsed(&pSrc->a[iLeft], iLeftCol);
145367-
if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){
145391+
if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 && pParse->nErr==0 ){
145368145392
/* This branch runs if the query contains one or more RIGHT or FULL
145369145393
** JOINs. If only a single table on the left side of this join
145370145394
** contains the zName column, then this branch is a no-op.
@@ -145380,6 +145404,8 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){
145380145404
*/
145381145405
ExprList *pFuncArgs = 0; /* Arguments to the coalesce() */
145382145406
static const Token tkCoalesce = { "coalesce", 8 };
145407+
assert( pE1!=0 );
145408+
ExprSetProperty(pE1, EP_CanBeNull);
145383145409
while( tableAndColumnIndex(pSrc, iLeft+1, i, zName, &iLeft, &iLeftCol,
145384145410
pRight->fg.isSynthUsing)!=0 ){
145385145411
if( pSrc->a[iLeft].fg.isUsing==0
@@ -145396,7 +145422,13 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){
145396145422
if( pFuncArgs ){
145397145423
pFuncArgs = sqlite3ExprListAppend(pParse, pFuncArgs, pE1);
145398145424
pE1 = sqlite3ExprFunction(pParse, pFuncArgs, &tkCoalesce, 0);
145425+
if( pE1 ){
145426+
pE1->affExpr = SQLITE_AFF_DEFER;
145427+
}
145399145428
}
145429+
}else if( (pSrc->a[i+1].fg.jointype & JT_LEFT)!=0 && pParse->nErr==0 ){
145430+
assert( pE1!=0 );
145431+
ExprSetProperty(pE1, EP_CanBeNull);
145400145432
}
145401145433
pE2 = sqlite3CreateColumnExpr(db, pSrc, i+1, iRightCol);
145402145434
sqlite3SrcItemColumnUsed(pRight, iRightCol);
@@ -149004,9 +149036,9 @@ static int compoundHasDifferentAffinities(Select *p){
149004149036
** from 2015-02-09.)
149005149037
**
149006149038
** (3) If the subquery is the right operand of a LEFT JOIN then
149007-
** (3a) the subquery may not be a join and
149008-
** (3b) the FROM clause of the subquery may not contain a virtual
149009-
** table and
149039+
** (3a) the subquery may not be a join
149040+
** (**) Was (3b): "the FROM clause of the subquery may not contain
149041+
** a virtual table"
149010149042
** (**) Was: "The outer query may not have a GROUP BY." This case
149011149043
** is now managed correctly
149012149044
** (3d) the outer query may not be DISTINCT.
@@ -149222,7 +149254,7 @@ static int flattenSubquery(
149222149254
*/
149223149255
if( (pSubitem->fg.jointype & (JT_OUTER|JT_LTORJ))!=0 ){
149224149256
if( pSubSrc->nSrc>1 /* (3a) */
149225-
|| IsVirtual(pSubSrc->a[0].pSTab) /* (3b) */
149257+
/**** || IsVirtual(pSubSrc->a[0].pSTab) (3b)-omitted */
149226149258
|| (p->selFlags & SF_Distinct)!=0 /* (3d) */
149227149259
|| (pSubitem->fg.jointype & JT_RIGHT)!=0 /* (26) */
149228149260
){
@@ -161722,12 +161754,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
161722161754
if( pLevel->iLeftJoin==0 ){
161723161755
/* If a partial index is driving the loop, try to eliminate WHERE clause
161724161756
** terms from the query that must be true due to the WHERE clause of
161725-
** the partial index.
161757+
** the partial index. This optimization does not work on an outer join,
161758+
** as shown by:
161726161759
**
161727-
** 2019-11-02 ticket 623eff57e76d45f6: This optimization does not work
161728-
** for a LEFT JOIN.
161760+
** 2019-11-02 ticket 623eff57e76d45f6 (LEFT JOIN)
161761+
** 2025-05-29 forum post 7dee41d32506c4ae (RIGHT JOIN)
161729161762
*/
161730-
if( pIdx->pPartIdxWhere ){
161763+
if( pIdx->pPartIdxWhere && pLevel->pRJ==0 ){
161731161764
whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
161732161765
}
161733161766
}else{
@@ -209021,8 +209054,10 @@ static int jsonBlobChangePayloadSize(
209021209054
nExtra = 1;
209022209055
}else if( szType==13 ){
209023209056
nExtra = 2;
209024-
}else{
209057+
}else if( szType==14 ){
209025209058
nExtra = 4;
209059+
}else{
209060+
nExtra = 8;
209026209061
}
209027209062
if( szPayload<=11 ){
209028209063
nNeeded = 0;
@@ -213407,6 +213442,8 @@ SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3 *db){
213407213442
#endif
213408213443
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */
213409213444

213445+
/* #include <stddef.h> */
213446+
213410213447
/*
213411213448
** If building separately, we will need some setup that is normally
213412213449
** found in sqliteInt.h
@@ -235449,6 +235486,7 @@ SQLITE_EXTENSION_INIT1
235449235486

235450235487
/* #include <string.h> */
235451235488
/* #include <assert.h> */
235489+
/* #include <stddef.h> */
235452235490

235453235491
#ifndef SQLITE_AMALGAMATION
235454235492

@@ -257192,7 +257230,7 @@ static void fts5SourceIdFunc(
257192257230
){
257193257231
assert( nArg==0 );
257194257232
UNUSED_PARAM2(nArg, apUnused);
257195-
sqlite3_result_text(pCtx, "fts5: 2025-05-29 14:26:00 dfc790f998f450d9c35e3ba1c8c89c17466cb559f87b0239e4aab9d34e28f742", -1, SQLITE_TRANSIENT);
257233+
sqlite3_result_text(pCtx, "fts5: 2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95", -1, SQLITE_TRANSIENT);
257196257234
}
257197257235

257198257236
/*

deps/sqlite/sqlite3.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ extern "C" {
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149-
#define SQLITE_VERSION "3.50.0"
150-
#define SQLITE_VERSION_NUMBER 3050000
151-
#define SQLITE_SOURCE_ID "2025-05-29 14:26:00 dfc790f998f450d9c35e3ba1c8c89c17466cb559f87b0239e4aab9d34e28f742"
149+
#define SQLITE_VERSION "3.50.1"
150+
#define SQLITE_VERSION_NUMBER 3050001
151+
#define SQLITE_SOURCE_ID "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95"
152152

153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers

0 commit comments

Comments
 (0)