Skip to content

Commit 1fc33f2

Browse files
JoshuaWisemceachen
andauthored
Update SQLite to version 3.47.1 (WiseLibs#1296)
Co-authored-by: mceachen <mceachen@users.noreply.github.com>
1 parent b34c9f5 commit 1fc33f2

File tree

4 files changed

+98
-39
lines changed

4 files changed

+98
-39
lines changed

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="2024"
22-
VERSION="3470000"
22+
VERSION="3470100"
2323

2424
# Defines below are sorted alphabetically
2525
DEFINES="

deps/sqlite3/sqlite3.c

Lines changed: 84 additions & 34 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.47.0. By combining all the individual C code files into this
3+
** version 3.47.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-
** 03a9703e27c44437c39363d0baf82db4ebc9.
21+
** b95d11e958643b969c47a8e5857f3793b9e6.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
@@ -463,9 +463,9 @@ extern "C" {
463463
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
464464
** [sqlite_version()] and [sqlite_source_id()].
465465
*/
466-
#define SQLITE_VERSION "3.47.0"
467-
#define SQLITE_VERSION_NUMBER 3047000
468-
#define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e"
466+
#define SQLITE_VERSION "3.47.1"
467+
#define SQLITE_VERSION_NUMBER 3047001
468+
#define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e"
469469

470470
/*
471471
** CAPI3REF: Run-Time Library Version Numbers
@@ -969,6 +969,13 @@ SQLITE_API int sqlite3_exec(
969969
** filesystem supports doing multiple write operations atomically when those
970970
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
971971
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
972+
**
973+
** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
974+
** from the database file in amounts that are not a multiple of the
975+
** page size and that do not begin at a page boundary. Without this
976+
** property, SQLite is careful to only do full-page reads and write
977+
** on aligned pages, with the one exception that it will do a sub-page
978+
** read of the first page to access the database header.
972979
*/
973980
#define SQLITE_IOCAP_ATOMIC 0x00000001
974981
#define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -985,6 +992,7 @@ SQLITE_API int sqlite3_exec(
985992
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
986993
#define SQLITE_IOCAP_IMMUTABLE 0x00002000
987994
#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
995+
#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000
988996

989997
/*
990998
** CAPI3REF: File Locking Levels
@@ -1131,6 +1139,7 @@ struct sqlite3_file {
11311139
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
11321140
** <li> [SQLITE_IOCAP_IMMUTABLE]
11331141
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
1142+
** <li> [SQLITE_IOCAP_SUBPAGE_READ]
11341143
** </ul>
11351144
**
11361145
** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -32299,6 +32308,7 @@ SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExp
3229932308
pExpr = pExpr->pLeft;
3230032309
}
3230132310
if( pExpr==0 ) return;
32311+
if( ExprHasProperty(pExpr, EP_FromDDL) ) return;
3230232312
db->errByteOffset = pExpr->w.iOfst;
3230332313
}
3230432314

@@ -42592,6 +42602,7 @@ static void setDeviceCharacteristics(unixFile *pFd){
4259242602
if( pFd->ctrlFlags & UNIXFILE_PSOW ){
4259342603
pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
4259442604
}
42605+
pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ;
4259542606

4259642607
pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
4259742608
}
@@ -50392,7 +50403,7 @@ static int winSectorSize(sqlite3_file *id){
5039250403
*/
5039350404
static int winDeviceCharacteristics(sqlite3_file *id){
5039450405
winFile *p = (winFile*)id;
50395-
return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
50406+
return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_SUBPAGE_READ |
5039650407
((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
5039750408
}
5039850409

@@ -51780,7 +51791,7 @@ static int winOpen(
5178051791

5178151792
int rc = SQLITE_OK; /* Function Return Code */
5178251793
#if !defined(NDEBUG) || SQLITE_OS_WINCE
51783-
int eType = flags&0xFFFFFF00; /* Type of file to open */
51794+
int eType = flags&0x0FFF00; /* Type of file to open */
5178451795
#endif
5178551796

5178651797
int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -58000,18 +58011,26 @@ static const unsigned char aJournalMagic[] = {
5800058011
** Return true if page pgno can be read directly from the database file
5800158012
** by the b-tree layer. This is the case if:
5800258013
**
58003-
** * the database file is open,
58004-
** * there are no dirty pages in the cache, and
58005-
** * the desired page is not currently in the wal file.
58014+
** (1) the database file is open
58015+
** (2) the VFS for the database is able to do unaligned sub-page reads
58016+
** (3) there are no dirty pages in the cache, and
58017+
** (4) the desired page is not currently in the wal file.
5800658018
*/
5800758019
SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){
58008-
if( pPager->fd->pMethods==0 ) return 0;
58009-
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
58020+
assert( pPager!=0 );
58021+
assert( pPager->fd!=0 );
58022+
if( pPager->fd->pMethods==0 ) return 0; /* Case (1) */
58023+
assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
58024+
if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
58025+
& SQLITE_IOCAP_SUBPAGE_READ)==0 ){
58026+
return 0; /* Case (2) */
58027+
}
58028+
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
5801058029
#ifndef SQLITE_OMIT_WAL
5801158030
if( pPager->pWal ){
5801258031
u32 iRead = 0;
5801358032
(void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
58014-
return iRead==0;
58033+
return iRead==0; /* Condition (4) */
5801558034
}
5801658035
#endif
5801758036
return 1;
@@ -158940,6 +158959,7 @@ static Expr *removeUnindexableInClauseTerms(
158940158959
pNew->pLeft->x.pList = pLhs;
158941158960
}
158942158961
pSelect->pEList = pRhs;
158962+
pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */
158943158963
if( pLhs && pLhs->nExpr==1 ){
158944158964
/* Take care here not to generate a TK_VECTOR containing only a
158945158965
** single value. Since the parser never creates such a vector, some
@@ -189815,10 +189835,15 @@ static int fts3PoslistPhraseMerge(
189815189835
if( *p1==POS_COLUMN ){
189816189836
p1++;
189817189837
p1 += fts3GetVarint32(p1, &iCol1);
189838+
/* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN
189839+
** entry, so this is actually end-of-doclist. */
189840+
if( iCol1==0 ) return 0;
189818189841
}
189819189842
if( *p2==POS_COLUMN ){
189820189843
p2++;
189821189844
p2 += fts3GetVarint32(p2, &iCol2);
189845+
/* As above, iCol2==0 indicates corruption. */
189846+
if( iCol2==0 ) return 0;
189822189847
}
189823189848

189824189849
while( 1 ){
@@ -192989,7 +193014,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
192989193014
nTmp += p->pRight->pPhrase->doclist.nList;
192990193015
}
192991193016
nTmp += p->pPhrase->doclist.nList;
192992-
aTmp = sqlite3_malloc64(nTmp*2);
193017+
aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX);
192993193018
if( !aTmp ){
192994193019
*pRc = SQLITE_NOMEM;
192995193020
res = 0;
@@ -194542,10 +194567,11 @@ static int getNextString(
194542194567
Fts3PhraseToken *pToken;
194543194568

194544194569
p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
194545-
if( !p ) goto no_mem;
194546-
194547194570
zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);
194548-
if( !zTemp ) goto no_mem;
194571+
if( !zTemp || !p ){
194572+
rc = SQLITE_NOMEM;
194573+
goto getnextstring_out;
194574+
}
194549194575

194550194576
assert( nToken==ii );
194551194577
pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];
@@ -194560,29 +194586,27 @@ static int getNextString(
194560194586
nToken = ii+1;
194561194587
}
194562194588
}
194563-
194564-
pModule->xClose(pCursor);
194565-
pCursor = 0;
194566194589
}
194567194590

194568194591
if( rc==SQLITE_DONE ){
194569194592
int jj;
194570194593
char *zBuf = 0;
194571194594

194572194595
p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);
194573-
if( !p ) goto no_mem;
194596+
if( !p ){
194597+
rc = SQLITE_NOMEM;
194598+
goto getnextstring_out;
194599+
}
194574194600
memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);
194575194601
p->eType = FTSQUERY_PHRASE;
194576194602
p->pPhrase = (Fts3Phrase *)&p[1];
194577194603
p->pPhrase->iColumn = pParse->iDefaultCol;
194578194604
p->pPhrase->nToken = nToken;
194579194605

194580194606
zBuf = (char *)&p->pPhrase->aToken[nToken];
194607+
assert( nTemp==0 || zTemp );
194581194608
if( zTemp ){
194582194609
memcpy(zBuf, zTemp, nTemp);
194583-
sqlite3_free(zTemp);
194584-
}else{
194585-
assert( nTemp==0 );
194586194610
}
194587194611

194588194612
for(jj=0; jj<p->pPhrase->nToken; jj++){
@@ -194592,17 +194616,17 @@ static int getNextString(
194592194616
rc = SQLITE_OK;
194593194617
}
194594194618

194595-
*ppExpr = p;
194596-
return rc;
194597-
no_mem:
194598-
194619+
getnextstring_out:
194599194620
if( pCursor ){
194600194621
pModule->xClose(pCursor);
194601194622
}
194602194623
sqlite3_free(zTemp);
194603-
sqlite3_free(p);
194604-
*ppExpr = 0;
194605-
return SQLITE_NOMEM;
194624+
if( rc!=SQLITE_OK ){
194625+
sqlite3_free(p);
194626+
p = 0;
194627+
}
194628+
*ppExpr = p;
194629+
return rc;
194606194630
}
194607194631

194608194632
/*
@@ -232823,7 +232847,27 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
232823232847
/************** End of sqlite3session.c **************************************/
232824232848
/************** Begin file fts5.c ********************************************/
232825232849

232826-
232850+
/*
232851+
** This, the "fts5.c" source file, is a composite file that is itself
232852+
** assembled from the following files:
232853+
**
232854+
** fts5.h
232855+
** fts5Int.h
232856+
** fts5parse.h <--- Generated from fts5parse.y by Lemon
232857+
** fts5parse.c <--- Generated from fts5parse.y by Lemon
232858+
** fts5_aux.c
232859+
** fts5_buffer.c
232860+
** fts5_config.c
232861+
** fts5_expr.c
232862+
** fts5_hash.c
232863+
** fts5_index.c
232864+
** fts5_main.c
232865+
** fts5_storage.c
232866+
** fts5_tokenize.c
232867+
** fts5_unicode2.c
232868+
** fts5_varint.c
232869+
** fts5_vocab.c
232870+
*/
232827232871
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5)
232828232872

232829232873
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -232833,6 +232877,12 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
232833232877
# undef NDEBUG
232834232878
#endif
232835232879

232880+
#ifdef HAVE_STDINT_H
232881+
/* #include <stdint.h> */
232882+
#endif
232883+
#ifdef HAVE_INTTYPES_H
232884+
/* #include <inttypes.h> */
232885+
#endif
232836232886
/*
232837232887
** 2014 May 31
232838232888
**
@@ -254905,7 +254955,7 @@ static void fts5SourceIdFunc(
254905254955
){
254906254956
assert( nArg==0 );
254907254957
UNUSED_PARAM2(nArg, apUnused);
254908-
sqlite3_result_text(pCtx, "fts5: 2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e", -1, SQLITE_TRANSIENT);
254958+
sqlite3_result_text(pCtx, "fts5: 2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e", -1, SQLITE_TRANSIENT);
254909254959
}
254910254960

254911254961
/*
@@ -260096,7 +260146,7 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
260096260146
}
260097260147

260098260148

260099-
260149+
/* Here ends the fts5.c composite file. */
260100260150
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
260101260151

260102260152
/************** End of fts5.c ************************************************/

deps/sqlite3/sqlite3.h

Lines changed: 12 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.47.0"
150-
#define SQLITE_VERSION_NUMBER 3047000
151-
#define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e"
149+
#define SQLITE_VERSION "3.47.1"
150+
#define SQLITE_VERSION_NUMBER 3047001
151+
#define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e"
152152

153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
@@ -652,6 +652,13 @@ SQLITE_API int sqlite3_exec(
652652
** filesystem supports doing multiple write operations atomically when those
653653
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
654654
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
655+
**
656+
** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
657+
** from the database file in amounts that are not a multiple of the
658+
** page size and that do not begin at a page boundary. Without this
659+
** property, SQLite is careful to only do full-page reads and write
660+
** on aligned pages, with the one exception that it will do a sub-page
661+
** read of the first page to access the database header.
655662
*/
656663
#define SQLITE_IOCAP_ATOMIC 0x00000001
657664
#define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -668,6 +675,7 @@ SQLITE_API int sqlite3_exec(
668675
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
669676
#define SQLITE_IOCAP_IMMUTABLE 0x00002000
670677
#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
678+
#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000
671679

672680
/*
673681
** CAPI3REF: File Locking Levels
@@ -814,6 +822,7 @@ struct sqlite3_file {
814822
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
815823
** <li> [SQLITE_IOCAP_IMMUTABLE]
816824
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
825+
** <li> [SQLITE_IOCAP_SUBPAGE_READ]
817826
** </ul>
818827
**
819828
** The SQLITE_IOCAP_ATOMIC property means that all writes of

docs/compilation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ If you're using a SQLite3 encryption extension that is a drop-in replacement for
4343

4444
# Bundled configuration
4545

46-
By default, this distribution currently uses SQLite3 **version 3.47.0** with the following [compilation options](https://www.sqlite.org/compile.html):
46+
By default, this distribution currently uses SQLite3 **version 3.47.1** with the following [compilation options](https://www.sqlite.org/compile.html):
4747

4848
```
4949
HAVE_INT16_T=1

0 commit comments

Comments
 (0)