Skip to content

Commit

Permalink
Update SQLite to version 3.43.1 (WiseLibs#1077)
Browse files Browse the repository at this point in the history
Co-authored-by: mceachen <mceachen@users.noreply.github.com>
  • Loading branch information
JoshuaWise and mceachen authored Sep 30, 2023
1 parent ae23e69 commit b7eb1ff
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 92 deletions.
2 changes: 1 addition & 1 deletion deps/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# ===

YEAR="2023"
VERSION="3430000"
VERSION="3430100"

# Defines below are sorted alphabetically
DEFINES="
Expand Down
183 changes: 96 additions & 87 deletions deps/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.43.0. By combining all the individual C code files into this
** version 3.43.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
Expand All @@ -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
** f80b798b3f4b81a7bb4233c58294edd0f11.
** d3a40c05c49e1a49264912b1a05bc2143ac.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
Expand Down Expand Up @@ -460,9 +460,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.43.0"
#define SQLITE_VERSION_NUMBER 3043000
#define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c"
#define SQLITE_VERSION "3.43.1"
#define SQLITE_VERSION_NUMBER 3043001
#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down Expand Up @@ -128462,8 +128462,10 @@ static void sumFinalize(sqlite3_context *context){
if( p->approx ){
if( p->ovrfl ){
sqlite3_result_error(context,"integer overflow",-1);
}else{
}else if( !sqlite3IsNaN(p->rErr) ){
sqlite3_result_double(context, p->rSum+p->rErr);
}else{
sqlite3_result_double(context, p->rSum);
}
}else{
sqlite3_result_int64(context, p->iSum);
Expand All @@ -128476,7 +128478,8 @@ static void avgFinalize(sqlite3_context *context){
if( p && p->cnt>0 ){
double r;
if( p->approx ){
r = p->rSum+p->rErr;
r = p->rSum;
if( !sqlite3IsNaN(p->rErr) ) r += p->rErr;
}else{
r = (double)(p->iSum);
}
Expand All @@ -128489,7 +128492,8 @@ static void totalFinalize(sqlite3_context *context){
p = sqlite3_aggregate_context(context, 0);
if( p ){
if( p->approx ){
r = p->rSum+p->rErr;
r = p->rSum;
if( !sqlite3IsNaN(p->rErr) ) r += p->rErr;
}else{
r = (double)(p->iSum);
}
Expand Down Expand Up @@ -145692,12 +145696,12 @@ static int disableUnusedSubqueryResultColumns(SrcItem *pItem){
assert( pItem->pSelect!=0 );
pSub = pItem->pSelect;
assert( pSub->pEList->nExpr==pTab->nCol );
if( (pSub->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){
testcase( pSub->selFlags & SF_Distinct );
testcase( pSub->selFlags & SF_Aggregate );
return 0;
}
for(pX=pSub; pX; pX=pX->pPrior){
if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){
testcase( pX->selFlags & SF_Distinct );
testcase( pX->selFlags & SF_Aggregate );
return 0;
}
if( pX->pPrior && pX->op!=TK_ALL ){
/* This optimization does not work for compound subqueries that
** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */
Expand Down Expand Up @@ -198102,7 +198106,7 @@ static u64 fts3ChecksumIndex(
int rc;
u64 cksum = 0;

assert( *pRc==SQLITE_OK );
if( *pRc ) return 0;

memset(&filter, 0, sizeof(filter));
memset(&csr, 0, sizeof(csr));
Expand Down Expand Up @@ -203732,7 +203736,9 @@ static void jsonArrayLengthFunc(
}
if( pNode->eType==JSON_ARRAY ){
while( 1 /*exit-by-break*/ ){
for(i=1; i<=pNode->n; n++){
i = 1;
while( i<=pNode->n ){
if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++;
i += jsonNodeSize(&pNode[i]);
}
if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;
Expand Down Expand Up @@ -223004,15 +223010,19 @@ static int sessionReadRecord(
}
}
if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
sqlite3_int64 v = sessionGetI64(aVal);
if( eType==SQLITE_INTEGER ){
sqlite3VdbeMemSetInt64(apOut[i], v);
if( (pIn->nData-pIn->iNext)<8 ){
rc = SQLITE_CORRUPT_BKPT;
}else{
double d;
memcpy(&d, &v, 8);
sqlite3VdbeMemSetDouble(apOut[i], d);
sqlite3_int64 v = sessionGetI64(aVal);
if( eType==SQLITE_INTEGER ){
sqlite3VdbeMemSetInt64(apOut[i], v);
}else{
double d;
memcpy(&d, &v, 8);
sqlite3VdbeMemSetDouble(apOut[i], d);
}
pIn->iNext += 8;
}
pIn->iNext += 8;
}
}
}
Expand Down Expand Up @@ -239838,80 +239848,79 @@ static void fts5DoSecureDelete(
}
}
}else if( iStart==4 ){
int iPgno;

assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno );
/* The entry being removed may be the only position list in
** its doclist. */
for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){
Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno));
int bEmpty = (pPg && pPg->nn==4);
fts5DataRelease(pPg);
if( bEmpty==0 ) break;
}

if( iPgno==pSeg->iTermLeafPgno ){
i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno);
Fts5Data *pTerm = fts5DataRead(p, iId);
if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){
u8 *aTermIdx = &pTerm->p[pTerm->szLeaf];
int nTermIdx = pTerm->nn - pTerm->szLeaf;
int iTermIdx = 0;
int iTermOff = 0;

while( 1 ){
u32 iVal = 0;
int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal);
iTermOff += iVal;
if( (iTermIdx+nByte)>=nTermIdx ) break;
iTermIdx += nByte;
}
nTermIdx = iTermIdx;
int iPgno;

assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno );
/* The entry being removed may be the only position list in
** its doclist. */
for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){
Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno));
int bEmpty = (pPg && pPg->nn==4);
fts5DataRelease(pPg);
if( bEmpty==0 ) break;
}

memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx);
fts5PutU16(&pTerm->p[2], iTermOff);
if( iPgno==pSeg->iTermLeafPgno ){
i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno);
Fts5Data *pTerm = fts5DataRead(p, iId);
if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){
u8 *aTermIdx = &pTerm->p[pTerm->szLeaf];
int nTermIdx = pTerm->nn - pTerm->szLeaf;
int iTermIdx = 0;
int iTermOff = 0;

fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx);
if( nTermIdx==0 ){
fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno);
}
while( 1 ){
u32 iVal = 0;
int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal);
iTermOff += iVal;
if( (iTermIdx+nByte)>=nTermIdx ) break;
iTermIdx += nByte;
}
fts5DataRelease(pTerm);
}
}
nTermIdx = iTermIdx;

if( p->rc==SQLITE_OK ){
const int nMove = nPg - iNextOff;
int nShift = 0;

memmove(&aPg[iOff], &aPg[iNextOff], nMove);
iPgIdx -= (iNextOff - iOff);
nPg = iPgIdx;
fts5PutU16(&aPg[2], iPgIdx);

nShift = iNextOff - iOff;
for(iIdx=0, iKeyOff=0, iPrevKeyOff=0; iIdx<nIdx; /* no-op */){
u32 iVal = 0;
iIdx += fts5GetVarint32(&aIdx[iIdx], iVal);
iKeyOff += iVal;
if( iKeyOff!=iDelKeyOff ){
if( iKeyOff>iOff ){
iKeyOff -= nShift;
nShift = 0;
}
nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOff - iPrevKeyOff);
iPrevKeyOff = iKeyOff;
memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx);
fts5PutU16(&pTerm->p[2], iTermOff);

fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx);
if( nTermIdx==0 ){
fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno);
}
}
fts5DataRelease(pTerm);
}
}

if( p->rc==SQLITE_OK ){
const int nMove = nPg - iNextOff; /* Number of bytes to move */
int nShift = iNextOff - iOff; /* Distance to move them */

if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){
fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno);
int iPrevKeyOut = 0;
int iKeyIn = 0;

memmove(&aPg[iOff], &aPg[iNextOff], nMove);
iPgIdx -= nShift;
nPg = iPgIdx;
fts5PutU16(&aPg[2], iPgIdx);

for(iIdx=0; iIdx<nIdx; /* no-op */){
u32 iVal = 0;
iIdx += fts5GetVarint32(&aIdx[iIdx], iVal);
iKeyIn += iVal;
if( iKeyIn!=iDelKeyOff ){
int iKeyOut = (iKeyIn - (iKeyIn>iOff ? nShift : 0));
nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOut - iPrevKeyOut);
iPrevKeyOut = iKeyOut;
}
}

assert_nc( nPg>4 || fts5GetU16(aPg)==0 );
fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg,nPg);
if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){
fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno);
}
sqlite3_free(aIdx);

assert_nc( nPg>4 || fts5GetU16(aPg)==0 );
fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg, nPg);
}
sqlite3_free(aIdx);
}

/*
Expand Down Expand Up @@ -245763,7 +245772,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c", -1, SQLITE_TRANSIENT);
sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions deps/sqlite3/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.43.0"
#define SQLITE_VERSION_NUMBER 3043000
#define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c"
#define SQLITE_VERSION "3.43.1"
#define SQLITE_VERSION_NUMBER 3043001
#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down
2 changes: 1 addition & 1 deletion docs/compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you're using a SQLite3 encryption extension that is a drop-in replacement for

# Bundled configuration

By default, this distribution currently uses SQLite3 **version 3.43.0** with the following [compilation options](https://www.sqlite.org/compile.html):
By default, this distribution currently uses SQLite3 **version 3.43.1** with the following [compilation options](https://www.sqlite.org/compile.html):

```
HAVE_INT16_T=1
Expand Down

0 comments on commit b7eb1ff

Please sign in to comment.