Skip to content

Commit a69f03c

Browse files
JoshuaWisem4heshd
andauthored
Update SQLite to version 3.53.1 (#1467)
Co-authored-by: m4heshd <6711514+m4heshd@users.noreply.github.com>
1 parent d116f32 commit a69f03c

4 files changed

Lines changed: 113 additions & 79 deletions

File tree

deps/download.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# ===
2020

2121
YEAR="2026"
22-
VERSION="3530000"
22+
VERSION="3530100"
2323

2424
# Defines below are sorted alphabetically
2525
DEFINES="

deps/sqlite3/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
*/
@@ -468,12 +468,12 @@ extern "C" {
468468
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
469469
** [sqlite_version()] and [sqlite_source_id()].
470470
*/
471-
#define SQLITE_VERSION "3.53.0"
472-
#define SQLITE_VERSION_NUMBER 3053000
473-
#define SQLITE_SOURCE_ID "2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b"
474-
#define SQLITE_SCM_BRANCH "trunk"
475-
#define SQLITE_SCM_TAGS "release major-release version-3.53.0"
476-
#define SQLITE_SCM_DATETIME "2026-04-09T11:41:38.498Z"
471+
#define SQLITE_VERSION "3.53.1"
472+
#define SQLITE_VERSION_NUMBER 3053001
473+
#define SQLITE_SOURCE_ID "2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9"
474+
#define SQLITE_SCM_BRANCH "branch-3.53"
475+
#define SQLITE_SCM_TAGS "release version-3.53.1"
476+
#define SQLITE_SCM_DATETIME "2026-05-05T10:34:17.344Z"
477477

478478
/*
479479
** CAPI3REF: Run-Time Library Version Numbers
@@ -32514,7 +32514,7 @@ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
3251432514
sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG);
3251532515
return 0;
3251632516
}
32517-
z = sqlite3DbMallocRaw(pAccum->db, n);
32517+
z = sqlite3_malloc(n);
3251832518
if( z==0 ){
3251932519
sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
3252032520
}
@@ -32972,11 +32972,27 @@ SQLITE_API void sqlite3_str_vappendf(
3297232972

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

3298132997
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
3298232998
/* The sign in front of the number */
@@ -33077,14 +33093,22 @@ SQLITE_API void sqlite3_str_vappendf(
3307733093
}
3307833094
length = width;
3307933095
}
33080-
pAccum->nChar += length;
33081-
zOut[length] = 0;
3308233096

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

36820+
#if !defined(SQLITE_DISABLE_INTRINSIC) \
36821+
&& (defined(__GNUC__) || defined(__clang__)) \
36822+
&& (defined(__x86_64__) || defined(__aarch64__) || \
36823+
(defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen>32)))
36824+
#define SQLITE_USE_UINT128
36825+
#endif
36826+
3679636827
/*
3679736828
** Two inputs are multiplied to get a 128-bit result. Write the
3679836829
** lower 64-bits of the result into *pLo, and return the high-order
3679936830
** 64 bits.
3680036831
*/
3680136832
static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36802-
#if (defined(__GNUC__) || defined(__clang__)) \
36803-
&& (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36804-
&& !defined(SQLITE_DISABLE_INTRINSIC)
36833+
#if defined(SQLITE_USE_UINT128)
3680536834
__uint128_t r = (__uint128_t)a * b;
3680636835
*pLo = (u64)r;
3680736836
return (u64)(r>>64);
@@ -36835,9 +36864,7 @@ static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
3683536864
** The lower 64 bits of A*B are discarded.
3683636865
*/
3683736866
static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36838-
#if (defined(__GNUC__) || defined(__clang__)) \
36839-
&& (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36840-
&& !defined(SQLITE_DISABLE_INTRINSIC)
36867+
#if defined(SQLITE_USE_UINT128)
3684136868
__uint128_t r = (__uint128_t)a * b;
3684236869
r += ((__uint128_t)aLo * b) >> 32;
3684336870
*pLo = (r>>32)&0xffffffff;
@@ -36875,6 +36902,8 @@ static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
3687536902
#endif
3687636903
}
3687736904

36905+
#undef SQLITE_USE_UINT128
36906+
3687836907
/*
3687936908
** Return a u64 with the N-th bit set.
3688036909
*/
@@ -56109,10 +56138,10 @@ SQLITE_API int sqlite3_deserialize(
5610956138
if( rc ) goto end_deserialize;
5611056139
db->init.iDb = (u8)iDb;
5611156140
db->init.reopenMemdb = 1;
56112-
rc = sqlite3_step(pStmt);
56141+
sqlite3_step(pStmt);
5611356142
db->init.reopenMemdb = 0;
56114-
if( rc!=SQLITE_DONE ){
56115-
rc = SQLITE_ERROR;
56143+
rc = sqlite3_finalize(pStmt);
56144+
if( rc!=SQLITE_OK ){
5611656145
goto end_deserialize;
5611756146
}
5611856147
p = memdbFromDbSchema(db, zSchema);
@@ -56133,7 +56162,6 @@ SQLITE_API int sqlite3_deserialize(
5613356162
}
5613456163

5613556164
end_deserialize:
56136-
sqlite3_finalize(pStmt);
5613756165
if( pData && (mFlags & SQLITE_DESERIALIZE_FREEONCLOSE)!=0 ){
5613856166
sqlite3_free(pData);
5613956167
}
@@ -123123,7 +123151,9 @@ SQLITE_PRIVATE void sqlite3AlterDropConstraint(
123123123151
if( !pTab ) return;
123124123152

123125123153
if( pCons ){
123126-
zArg = sqlite3MPrintf(db, "%.*Q", pCons->n, pCons->z);
123154+
char *z = sqlite3NameFromToken(db, pCons);
123155+
zArg = sqlite3MPrintf(db, "%Q", z);
123156+
sqlite3DbFree(db, z);
123127123157
}else{
123128123158
int iCol;
123129123159
if( alterFindCol(pParse, pTab, pCol, &iCol) ) return;
@@ -125505,6 +125535,16 @@ static void attachFunc(
125505125535
** from sqlite3_deserialize() to close database db->init.iDb and
125506125536
** reopen it as a MemDB */
125507125537
Btree *pNewBt = 0;
125538+
125539+
pNew = &db->aDb[db->init.iDb];
125540+
assert( pNew->pBt!=0 );
125541+
if( sqlite3BtreeTxnState(pNew->pBt)!=SQLITE_TXN_NONE
125542+
|| sqlite3BtreeIsInBackup(pNew->pBt)
125543+
){
125544+
rc = SQLITE_BUSY;
125545+
goto attach_error;
125546+
}
125547+
125508125548
pVfs = sqlite3_vfs_find("memdb");
125509125549
if( pVfs==0 ) return;
125510125550
rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNewBt, 0, SQLITE_OPEN_MAIN_DB);
@@ -125514,8 +125554,7 @@ static void attachFunc(
125514125554
/* Both the Btree and the new Schema were allocated successfully.
125515125555
** Close the old db and update the aDb[] slot with the new memdb
125516125556
** values. */
125517-
pNew = &db->aDb[db->init.iDb];
125518-
if( ALWAYS(pNew->pBt) ) sqlite3BtreeClose(pNew->pBt);
125557+
sqlite3BtreeClose(pNew->pBt);
125519125558
pNew->pBt = pNewBt;
125520125559
pNew->pSchema = pNewSchema;
125521125560
}else{
@@ -156058,6 +156097,7 @@ static SQLITE_NOINLINE void existsToJoin(
156058156097
&& !ExprHasProperty(pWhere, EP_OuterON|EP_InnerON)
156059156098
&& ALWAYS(p->pSrc!=0)
156060156099
&& p->pSrc->nSrc<BMS
156100+
&& (p->pLimit==0 || p->pLimit->pRight==0)
156061156101
){
156062156102
if( pWhere->op==TK_AND ){
156063156103
Expr *pRight = pWhere->pRight;
@@ -156105,7 +156145,6 @@ static SQLITE_NOINLINE void existsToJoin(
156105156145
sqlite3TreeViewSelect(0, p, 0);
156106156146
}
156107156147
#endif
156108-
existsToJoin(pParse, p, pSubWhere);
156109156148
}
156110156149
}
156111156150
}
@@ -165947,7 +165986,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
165947165986
** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
165948165987
** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
165949165988
*/
165950-
if( pWInfo->nLevel>1 ){
165989+
if( pWInfo->nLevel>1 || pTabItem->fg.fromExists ){
165951165990
int nNotReady; /* The number of notReady tables */
165952165991
SrcItem *origSrc; /* Original list of tables */
165953165992
nNotReady = pWInfo->nLevel - iLevel - 1;
@@ -165960,6 +165999,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
165960165999
for(k=1; k<=nNotReady; k++){
165961166000
memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
165962166001
}
166002+
166003+
/* Clear the fromExists flag on the OR-optimized table entry so that
166004+
** the calls to sqlite3WhereEnd() do not code early-exits after the
166005+
** first row is visited. The early exit applies to this table's
166006+
** overall loop - including the multiple OR branches and any WHERE
166007+
** conditions not passed to the sub-loops - not to the sub-loops. */
166008+
pOrTab->a[0].fg.fromExists = 0;
165963166009
}else{
165964166010
pOrTab = pWInfo->pTabList;
165965166011
}
@@ -166203,7 +166249,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
166203166249
assert( pLevel->op==OP_Return );
166204166250
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
166205166251

166206-
if( pWInfo->nLevel>1 ){ sqlite3DbFreeNN(db, pOrTab); }
166252+
if( pWInfo->pTabList!=pOrTab ){ sqlite3DbFreeNN(db, pOrTab); }
166207166253
if( !untestedTerms ) disableTerm(pLevel, pTerm);
166208166254
}else
166209166255
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
@@ -176128,27 +176174,11 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
176128176174
}
176129176175
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
176130176176
}
176131-
if( pTabList->a[pLevel->iFrom].fg.fromExists
176132-
&& (i==pWInfo->nLevel-1
176133-
|| pTabList->a[pWInfo->a[i+1].iFrom].fg.fromExists==0)
176134-
){
176135-
/* This is an EXISTS-to-JOIN optimization which is either the
176136-
** inner-most loop, or the inner-most of a group of nested
176137-
** EXISTS-to-JOIN optimization loops. If this loop sees a successful
176138-
** row, it should break out of itself as well as other EXISTS-to-JOIN
176139-
** loops in which is is directly nested. */
176140-
int nOuter = 0; /* Nr of outer EXISTS that this one is nested within */
176141-
while( nOuter<i ){
176142-
if( !pTabList->a[pLevel[-nOuter-1].iFrom].fg.fromExists ) break;
176143-
nOuter++;
176144-
}
176145-
testcase( nOuter>0 );
176146-
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel[-nOuter].addrBrk);
176147-
if( nOuter ){
176148-
VdbeComment((v, "EXISTS break %d..%d", i-nOuter, i));
176149-
}else{
176150-
VdbeComment((v, "EXISTS break %d", i));
176151-
}
176177+
if( pTabList->a[pLevel->iFrom].fg.fromExists ){
176178+
/* This is an EXISTS-to-JOIN optimization loop. If this loop sees a
176179+
** successful row, it should break out of itself. */
176180+
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
176181+
VdbeComment((v, "EXISTS break %d", i));
176152176182
}
176153176183
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
176154176184
if( pLevel->op!=OP_Noop ){
@@ -184353,6 +184383,7 @@ static YYACTIONTYPE yy_reduce(
184353184383
yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
184354184384
if( yymsp[-4].minor.yy454 ){
184355184385
yymsp[-4].minor.yy454->x.pList = pList;
184386+
sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
184356184387
}else{
184357184388
sqlite3ExprListDelete(pParse->db, pList);
184358184389
}
@@ -233970,10 +234001,11 @@ static int sessionSerialLen(const u8 *a){
233970234001
int n;
233971234002
assert( a!=0 );
233972234003
e = *a;
233973-
if( e==0 || e==0xFF ) return 1;
233974-
if( e==SQLITE_NULL ) return 1;
233975234004
if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;
233976-
return sessionVarintGet(&a[1], &n) + 1 + n;
234005+
if( e==SQLITE_TEXT || e==SQLITE_BLOB ){
234006+
return sessionVarintGet(&a[1], &n) + 1 + n;
234007+
}
234008+
return 1;
233977234009
}
233978234010

233979234011
/*
@@ -233996,17 +234028,17 @@ static unsigned int sessionChangeHash(
233996234028
u8 *a = aRecord; /* Used to iterate through change record */
233997234029

233998234030
for(i=0; i<pTab->nCol; i++){
233999-
int eType = *a;
234000234031
int isPK = pTab->abPK[i];
234001234032
if( bPkOnly && isPK==0 ) continue;
234002234033

234003-
assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT
234004-
|| eType==SQLITE_TEXT || eType==SQLITE_BLOB
234005-
|| eType==SQLITE_NULL || eType==0
234006-
);
234007-
234008234034
if( isPK ){
234009-
a++;
234035+
int eType = *a++;
234036+
234037+
assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT
234038+
|| eType==SQLITE_TEXT || eType==SQLITE_BLOB
234039+
|| eType==SQLITE_NULL || eType==0
234040+
);
234041+
234010234042
h = sessionHashAppendType(h, eType);
234011234043
if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
234012234044
h = sessionHashAppendI64(h, sessionGetI64(a));
@@ -237034,9 +237066,11 @@ static int sessionChangesetBufferRecord(
237034237066
rc = sessionInputBuffer(pIn, nByte);
237035237067
}else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
237036237068
nByte += 8;
237069+
}else if( eType!=0 && eType!=SQLITE_NULL ){
237070+
rc = SQLITE_CORRUPT_BKPT;
237037237071
}
237038237072
}
237039-
if( (pIn->iNext+nByte)>pIn->nData ){
237073+
if( rc==SQLITE_OK && (pIn->iNext+nByte)>pIn->nData ){
237040237074
rc = SQLITE_CORRUPT_BKPT;
237041237075
}
237042237076
}
@@ -263241,7 +263275,7 @@ static void fts5SourceIdFunc(
263241263275
){
263242263276
assert( nArg==0 );
263243263277
UNUSED_PARAM2(nArg, apUnused);
263244-
sqlite3_result_text(pCtx, "fts5: 2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b", -1, SQLITE_TRANSIENT);
263278+
sqlite3_result_text(pCtx, "fts5: 2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9", -1, SQLITE_TRANSIENT);
263245263279
}
263246263280

263247263281
/*

0 commit comments

Comments
 (0)