Skip to content

Commit bf6b496

Browse files
deps: update sqlite to 3.53.1
1 parent facd71e commit bf6b496

2 files changed

Lines changed: 111 additions & 77 deletions

File tree

deps/sqlite/sqlite3.c

Lines changed: 105 additions & 71 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.53.0. By combining all the individual C code files into this
3+
** version 3.53.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-
** 4525003a53a7fc63ca75c59b22c79608659c with changes in files:
21+
** c88b22011a54b4f6fbd149e9f8e4de77658c with changes in files:
2222
**
2323
**
2424
*/
@@ -467,12 +467,12 @@ extern "C" {
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470-
#define SQLITE_VERSION "3.53.0"
471-
#define SQLITE_VERSION_NUMBER 3053000
472-
#define SQLITE_SOURCE_ID "2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b"
473-
#define SQLITE_SCM_BRANCH "trunk"
474-
#define SQLITE_SCM_TAGS "release major-release version-3.53.0"
475-
#define SQLITE_SCM_DATETIME "2026-04-09T11:41:38.498Z"
470+
#define SQLITE_VERSION "3.53.1"
471+
#define SQLITE_VERSION_NUMBER 3053001
472+
#define SQLITE_SOURCE_ID "2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9"
473+
#define SQLITE_SCM_BRANCH "branch-3.53"
474+
#define SQLITE_SCM_TAGS "release version-3.53.1"
475+
#define SQLITE_SCM_DATETIME "2026-05-05T10:34:17.344Z"
476476

477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
@@ -32513,7 +32513,7 @@ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
3251332513
sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG);
3251432514
return 0;
3251532515
}
32516-
z = sqlite3DbMallocRaw(pAccum->db, n);
32516+
z = sqlite3_malloc(n);
3251732517
if( z==0 ){
3251832518
sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
3251932519
}
@@ -32971,11 +32971,27 @@ SQLITE_API void sqlite3_str_vappendf(
3297132971

3297232972
szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+10;
3297332973
if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32974-
if( sqlite3StrAccumEnlargeIfNeeded(pAccum, szBufNeeded) ){
32975-
width = length = 0;
32976-
break;
32974+
if( szBufNeeded + pAccum->nChar >= pAccum->nAlloc ){
32975+
if( pAccum->mxAlloc==0 && pAccum->accError==0 ){
32976+
/* Unable to allocate space in pAccum, perhaps because it
32977+
** is coming from sqlite3_snprintf() or similar. We'll have
32978+
** to render into temporary space and the memcpy() it over. */
32979+
bufpt = sqlite3_malloc(szBufNeeded);
32980+
if( bufpt==0 ){
32981+
sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32982+
return;
32983+
}
32984+
zExtra = bufpt;
32985+
}else if( sqlite3StrAccumEnlarge(pAccum, szBufNeeded)<szBufNeeded ){
32986+
width = length = 0;
32987+
break;
32988+
}else{
32989+
bufpt = pAccum->zText + pAccum->nChar;
32990+
}
32991+
}else{
32992+
bufpt = pAccum->zText + pAccum->nChar;
3297732993
}
32978-
bufpt = zOut = pAccum->zText + pAccum->nChar;
32994+
zOut = bufpt;
3297932995

3298032996
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
3298132997
/* The sign in front of the number */
@@ -33076,14 +33092,22 @@ SQLITE_API void sqlite3_str_vappendf(
3307633092
}
3307733093
length = width;
3307833094
}
33079-
pAccum->nChar += length;
33080-
zOut[length] = 0;
3308133095

33082-
/* Floating point conversions render directly into the output
33083-
** buffer. Hence, don't just break out of the switch(). Bypass the
33084-
** output buffer writing that occurs after the switch() by continuing
33085-
** to the next character in the format string. */
33086-
continue;
33096+
if( zExtra==0 ){
33097+
/* The result is being rendered directory into pAccum. This
33098+
** is the command and fast case */
33099+
pAccum->nChar += length;
33100+
zOut[length] = 0;
33101+
continue;
33102+
}else{
33103+
/* We were unable to render directly into pAccum because we
33104+
** couldn't allocate sufficient memory. We need to memcpy()
33105+
** the rendering (or some prefix thereof) into the output
33106+
** buffer. */
33107+
bufpt[0] = 0;
33108+
bufpt = zExtra;
33109+
break;
33110+
}
3308733111
}
3308833112
case etSIZE:
3308933113
if( !bArgList ){
@@ -33130,7 +33154,7 @@ SQLITE_API void sqlite3_str_vappendf(
3313033154
if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
3313133155
break;
3313233156
}
33133-
sqlite3_str_append(pAccum,
33157+
sqlite3_str_append(pAccum,
3313433158
&pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
3313533159
precision -= nPrior;
3313633160
nPrior *= 2;
@@ -33646,7 +33670,7 @@ SQLITE_API void sqlite3_str_reset(StrAccum *p){
3364633670
** of its content, all in one call.
3364733671
*/
3364833672
SQLITE_API void sqlite3_str_free(sqlite3_str *p){
33649-
if( p ){
33673+
if( p!=0 && p!=&sqlite3OomStr ){
3365033674
sqlite3_str_reset(p);
3365133675
sqlite3_free(p);
3365233676
}
@@ -36792,15 +36816,20 @@ SQLITE_PRIVATE u8 sqlite3StrIHash(const char *z){
3679236816
return h;
3679336817
}
3679436818

36819+
#if !defined(SQLITE_DISABLE_INTRINSIC) \
36820+
&& (defined(__GNUC__) || defined(__clang__)) \
36821+
&& (defined(__x86_64__) || defined(__aarch64__) || \
36822+
(defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen>32)))
36823+
#define SQLITE_USE_UINT128
36824+
#endif
36825+
3679536826
/*
3679636827
** Two inputs are multiplied to get a 128-bit result. Write the
3679736828
** lower 64-bits of the result into *pLo, and return the high-order
3679836829
** 64 bits.
3679936830
*/
3680036831
static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36801-
#if (defined(__GNUC__) || defined(__clang__)) \
36802-
&& (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36803-
&& !defined(SQLITE_DISABLE_INTRINSIC)
36832+
#if defined(SQLITE_USE_UINT128)
3680436833
__uint128_t r = (__uint128_t)a * b;
3680536834
*pLo = (u64)r;
3680636835
return (u64)(r>>64);
@@ -36834,9 +36863,7 @@ static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
3683436863
** The lower 64 bits of A*B are discarded.
3683536864
*/
3683636865
static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36837-
#if (defined(__GNUC__) || defined(__clang__)) \
36838-
&& (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36839-
&& !defined(SQLITE_DISABLE_INTRINSIC)
36866+
#if defined(SQLITE_USE_UINT128)
3684036867
__uint128_t r = (__uint128_t)a * b;
3684136868
r += ((__uint128_t)aLo * b) >> 32;
3684236869
*pLo = (r>>32)&0xffffffff;
@@ -36874,6 +36901,8 @@ static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
3687436901
#endif
3687536902
}
3687636903

36904+
#undef SQLITE_USE_UINT128
36905+
3687736906
/*
3687836907
** Return a u64 with the N-th bit set.
3687936908
*/
@@ -56108,10 +56137,10 @@ SQLITE_API int sqlite3_deserialize(
5610856137
if( rc ) goto end_deserialize;
5610956138
db->init.iDb = (u8)iDb;
5611056139
db->init.reopenMemdb = 1;
56111-
rc = sqlite3_step(pStmt);
56140+
sqlite3_step(pStmt);
5611256141
db->init.reopenMemdb = 0;
56113-
if( rc!=SQLITE_DONE ){
56114-
rc = SQLITE_ERROR;
56142+
rc = sqlite3_finalize(pStmt);
56143+
if( rc!=SQLITE_OK ){
5611556144
goto end_deserialize;
5611656145
}
5611756146
p = memdbFromDbSchema(db, zSchema);
@@ -56132,7 +56161,6 @@ SQLITE_API int sqlite3_deserialize(
5613256161
}
5613356162

5613456163
end_deserialize:
56135-
sqlite3_finalize(pStmt);
5613656164
if( pData && (mFlags & SQLITE_DESERIALIZE_FREEONCLOSE)!=0 ){
5613756165
sqlite3_free(pData);
5613856166
}
@@ -123122,7 +123150,9 @@ SQLITE_PRIVATE void sqlite3AlterDropConstraint(
123122123150
if( !pTab ) return;
123123123151

123124123152
if( pCons ){
123125-
zArg = sqlite3MPrintf(db, "%.*Q", pCons->n, pCons->z);
123153+
char *z = sqlite3NameFromToken(db, pCons);
123154+
zArg = sqlite3MPrintf(db, "%Q", z);
123155+
sqlite3DbFree(db, z);
123126123156
}else{
123127123157
int iCol;
123128123158
if( alterFindCol(pParse, pTab, pCol, &iCol) ) return;
@@ -125504,6 +125534,16 @@ static void attachFunc(
125504125534
** from sqlite3_deserialize() to close database db->init.iDb and
125505125535
** reopen it as a MemDB */
125506125536
Btree *pNewBt = 0;
125537+
125538+
pNew = &db->aDb[db->init.iDb];
125539+
assert( pNew->pBt!=0 );
125540+
if( sqlite3BtreeTxnState(pNew->pBt)!=SQLITE_TXN_NONE
125541+
|| sqlite3BtreeIsInBackup(pNew->pBt)
125542+
){
125543+
rc = SQLITE_BUSY;
125544+
goto attach_error;
125545+
}
125546+
125507125547
pVfs = sqlite3_vfs_find("memdb");
125508125548
if( pVfs==0 ) return;
125509125549
rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNewBt, 0, SQLITE_OPEN_MAIN_DB);
@@ -125513,8 +125553,7 @@ static void attachFunc(
125513125553
/* Both the Btree and the new Schema were allocated successfully.
125514125554
** Close the old db and update the aDb[] slot with the new memdb
125515125555
** values. */
125516-
pNew = &db->aDb[db->init.iDb];
125517-
if( ALWAYS(pNew->pBt) ) sqlite3BtreeClose(pNew->pBt);
125556+
sqlite3BtreeClose(pNew->pBt);
125518125557
pNew->pBt = pNewBt;
125519125558
pNew->pSchema = pNewSchema;
125520125559
}else{
@@ -156057,6 +156096,7 @@ static SQLITE_NOINLINE void existsToJoin(
156057156096
&& !ExprHasProperty(pWhere, EP_OuterON|EP_InnerON)
156058156097
&& ALWAYS(p->pSrc!=0)
156059156098
&& p->pSrc->nSrc<BMS
156099+
&& (p->pLimit==0 || p->pLimit->pRight==0)
156060156100
){
156061156101
if( pWhere->op==TK_AND ){
156062156102
Expr *pRight = pWhere->pRight;
@@ -156104,7 +156144,6 @@ static SQLITE_NOINLINE void existsToJoin(
156104156144
sqlite3TreeViewSelect(0, p, 0);
156105156145
}
156106156146
#endif
156107-
existsToJoin(pParse, p, pSubWhere);
156108156147
}
156109156148
}
156110156149
}
@@ -165946,7 +165985,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
165946165985
** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
165947165986
** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
165948165987
*/
165949-
if( pWInfo->nLevel>1 ){
165988+
if( pWInfo->nLevel>1 || pTabItem->fg.fromExists ){
165950165989
int nNotReady; /* The number of notReady tables */
165951165990
SrcItem *origSrc; /* Original list of tables */
165952165991
nNotReady = pWInfo->nLevel - iLevel - 1;
@@ -165959,6 +165998,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
165959165998
for(k=1; k<=nNotReady; k++){
165960165999
memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
165961166000
}
166001+
166002+
/* Clear the fromExists flag on the OR-optimized table entry so that
166003+
** the calls to sqlite3WhereEnd() do not code early-exits after the
166004+
** first row is visited. The early exit applies to this table's
166005+
** overall loop - including the multiple OR branches and any WHERE
166006+
** conditions not passed to the sub-loops - not to the sub-loops. */
166007+
pOrTab->a[0].fg.fromExists = 0;
165962166008
}else{
165963166009
pOrTab = pWInfo->pTabList;
165964166010
}
@@ -166202,7 +166248,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
166202166248
assert( pLevel->op==OP_Return );
166203166249
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
166204166250

166205-
if( pWInfo->nLevel>1 ){ sqlite3DbFreeNN(db, pOrTab); }
166251+
if( pWInfo->pTabList!=pOrTab ){ sqlite3DbFreeNN(db, pOrTab); }
166206166252
if( !untestedTerms ) disableTerm(pLevel, pTerm);
166207166253
}else
166208166254
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
@@ -176127,27 +176173,11 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
176127176173
}
176128176174
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
176129176175
}
176130-
if( pTabList->a[pLevel->iFrom].fg.fromExists
176131-
&& (i==pWInfo->nLevel-1
176132-
|| pTabList->a[pWInfo->a[i+1].iFrom].fg.fromExists==0)
176133-
){
176134-
/* This is an EXISTS-to-JOIN optimization which is either the
176135-
** inner-most loop, or the inner-most of a group of nested
176136-
** EXISTS-to-JOIN optimization loops. If this loop sees a successful
176137-
** row, it should break out of itself as well as other EXISTS-to-JOIN
176138-
** loops in which is is directly nested. */
176139-
int nOuter = 0; /* Nr of outer EXISTS that this one is nested within */
176140-
while( nOuter<i ){
176141-
if( !pTabList->a[pLevel[-nOuter-1].iFrom].fg.fromExists ) break;
176142-
nOuter++;
176143-
}
176144-
testcase( nOuter>0 );
176145-
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel[-nOuter].addrBrk);
176146-
if( nOuter ){
176147-
VdbeComment((v, "EXISTS break %d..%d", i-nOuter, i));
176148-
}else{
176149-
VdbeComment((v, "EXISTS break %d", i));
176150-
}
176176+
if( pTabList->a[pLevel->iFrom].fg.fromExists ){
176177+
/* This is an EXISTS-to-JOIN optimization loop. If this loop sees a
176178+
** successful row, it should break out of itself. */
176179+
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
176180+
VdbeComment((v, "EXISTS break %d", i));
176151176181
}
176152176182
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
176153176183
if( pLevel->op!=OP_Noop ){
@@ -184334,6 +184364,7 @@ static YYACTIONTYPE yy_reduce(
184334184364
yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
184335184365
if( yymsp[-4].minor.yy454 ){
184336184366
yymsp[-4].minor.yy454->x.pList = pList;
184367+
sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
184337184368
}else{
184338184369
sqlite3ExprListDelete(pParse->db, pList);
184339184370
}
@@ -233951,10 +233982,11 @@ static int sessionSerialLen(const u8 *a){
233951233982
int n;
233952233983
assert( a!=0 );
233953233984
e = *a;
233954-
if( e==0 || e==0xFF ) return 1;
233955-
if( e==SQLITE_NULL ) return 1;
233956233985
if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;
233957-
return sessionVarintGet(&a[1], &n) + 1 + n;
233986+
if( e==SQLITE_TEXT || e==SQLITE_BLOB ){
233987+
return sessionVarintGet(&a[1], &n) + 1 + n;
233988+
}
233989+
return 1;
233958233990
}
233959233991

233960233992
/*
@@ -233977,17 +234009,17 @@ static unsigned int sessionChangeHash(
233977234009
u8 *a = aRecord; /* Used to iterate through change record */
233978234010

233979234011
for(i=0; i<pTab->nCol; i++){
233980-
int eType = *a;
233981234012
int isPK = pTab->abPK[i];
233982234013
if( bPkOnly && isPK==0 ) continue;
233983234014

233984-
assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT
233985-
|| eType==SQLITE_TEXT || eType==SQLITE_BLOB
233986-
|| eType==SQLITE_NULL || eType==0
233987-
);
233988-
233989234015
if( isPK ){
233990-
a++;
234016+
int eType = *a++;
234017+
234018+
assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT
234019+
|| eType==SQLITE_TEXT || eType==SQLITE_BLOB
234020+
|| eType==SQLITE_NULL || eType==0
234021+
);
234022+
233991234023
h = sessionHashAppendType(h, eType);
233992234024
if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
233993234025
h = sessionHashAppendI64(h, sessionGetI64(a));
@@ -237015,9 +237047,11 @@ static int sessionChangesetBufferRecord(
237015237047
rc = sessionInputBuffer(pIn, nByte);
237016237048
}else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
237017237049
nByte += 8;
237050+
}else if( eType!=0 && eType!=SQLITE_NULL ){
237051+
rc = SQLITE_CORRUPT_BKPT;
237018237052
}
237019237053
}
237020-
if( (pIn->iNext+nByte)>pIn->nData ){
237054+
if( rc==SQLITE_OK && (pIn->iNext+nByte)>pIn->nData ){
237021237055
rc = SQLITE_CORRUPT_BKPT;
237022237056
}
237023237057
}
@@ -263222,7 +263256,7 @@ static void fts5SourceIdFunc(
263222263256
){
263223263257
assert( nArg==0 );
263224263258
UNUSED_PARAM2(nArg, apUnused);
263225-
sqlite3_result_text(pCtx, "fts5: 2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b", -1, SQLITE_TRANSIENT);
263259+
sqlite3_result_text(pCtx, "fts5: 2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9", -1, SQLITE_TRANSIENT);
263226263260
}
263227263261

263228263262
/*

deps/sqlite/sqlite3.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ extern "C" {
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149-
#define SQLITE_VERSION "3.53.0"
150-
#define SQLITE_VERSION_NUMBER 3053000
151-
#define SQLITE_SOURCE_ID "2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b"
152-
#define SQLITE_SCM_BRANCH "trunk"
153-
#define SQLITE_SCM_TAGS "release major-release version-3.53.0"
154-
#define SQLITE_SCM_DATETIME "2026-04-09T11:41:38.498Z"
149+
#define SQLITE_VERSION "3.53.1"
150+
#define SQLITE_VERSION_NUMBER 3053001
151+
#define SQLITE_SOURCE_ID "2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9"
152+
#define SQLITE_SCM_BRANCH "branch-3.53"
153+
#define SQLITE_SCM_TAGS "release version-3.53.1"
154+
#define SQLITE_SCM_DATETIME "2026-05-05T10:34:17.344Z"
155155

156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers

0 commit comments

Comments
 (0)