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
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
@@ -462,9 +462,9 @@ extern "C" {
462462** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463463** [sqlite_version()] and [sqlite_source_id()].
464464*/
465- #define SQLITE_VERSION "3.47.0 "
466- #define SQLITE_VERSION_NUMBER 3047000
467- #define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e "
465+ #define SQLITE_VERSION "3.47.1 "
466+ #define SQLITE_VERSION_NUMBER 3047001
467+ #define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e "
468468
469469/*
470470** CAPI3REF: Run-Time Library Version Numbers
@@ -968,6 +968,13 @@ SQLITE_API int sqlite3_exec(
968968** filesystem supports doing multiple write operations atomically when those
969969** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
970970** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
971+ **
972+ ** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
973+ ** from the database file in amounts that are not a multiple of the
974+ ** page size and that do not begin at a page boundary. Without this
975+ ** property, SQLite is careful to only do full-page reads and write
976+ ** on aligned pages, with the one exception that it will do a sub-page
977+ ** read of the first page to access the database header.
971978*/
972979#define SQLITE_IOCAP_ATOMIC 0x00000001
973980#define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -984,6 +991,7 @@ SQLITE_API int sqlite3_exec(
984991#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
985992#define SQLITE_IOCAP_IMMUTABLE 0x00002000
986993#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
994+ #define SQLITE_IOCAP_SUBPAGE_READ 0x00008000
987995
988996/*
989997** CAPI3REF: File Locking Levels
@@ -1130,6 +1138,7 @@ struct sqlite3_file {
11301138** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
11311139** <li> [SQLITE_IOCAP_IMMUTABLE]
11321140** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
1141+ ** <li> [SQLITE_IOCAP_SUBPAGE_READ]
11331142** </ul>
11341143**
11351144** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -32298,6 +32307,7 @@ SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExp
3229832307 pExpr = pExpr->pLeft;
3229932308 }
3230032309 if( pExpr==0 ) return;
32310+ if( ExprHasProperty(pExpr, EP_FromDDL) ) return;
3230132311 db->errByteOffset = pExpr->w.iOfst;
3230232312}
3230332313
@@ -42591,6 +42601,7 @@ static void setDeviceCharacteristics(unixFile *pFd){
4259142601 if( pFd->ctrlFlags & UNIXFILE_PSOW ){
4259242602 pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
4259342603 }
42604+ pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ;
4259442605
4259542606 pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
4259642607 }
@@ -50391,7 +50402,7 @@ static int winSectorSize(sqlite3_file *id){
5039150402*/
5039250403static int winDeviceCharacteristics(sqlite3_file *id){
5039350404 winFile *p = (winFile*)id;
50394- return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
50405+ return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_SUBPAGE_READ |
5039550406 ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
5039650407}
5039750408
@@ -51779,7 +51790,7 @@ static int winOpen(
5177951790
5178051791 int rc = SQLITE_OK; /* Function Return Code */
5178151792#if !defined(NDEBUG) || SQLITE_OS_WINCE
51782- int eType = flags&0xFFFFFF00 ; /* Type of file to open */
51793+ int eType = flags&0x0FFF00 ; /* Type of file to open */
5178351794#endif
5178451795
5178551796 int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -57999,18 +58010,26 @@ static const unsigned char aJournalMagic[] = {
5799958010** Return true if page pgno can be read directly from the database file
5800058011** by the b-tree layer. This is the case if:
5800158012**
58002- ** * the database file is open,
58003- ** * there are no dirty pages in the cache, and
58004- ** * the desired page is not currently in the wal file.
58013+ ** (1) the database file is open
58014+ ** (2) the VFS for the database is able to do unaligned sub-page reads
58015+ ** (3) there are no dirty pages in the cache, and
58016+ ** (4) the desired page is not currently in the wal file.
5800558017*/
5800658018SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){
58007- if( pPager->fd->pMethods==0 ) return 0;
58008- if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
58019+ assert( pPager!=0 );
58020+ assert( pPager->fd!=0 );
58021+ if( pPager->fd->pMethods==0 ) return 0; /* Case (1) */
58022+ assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
58023+ if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
58024+ & SQLITE_IOCAP_SUBPAGE_READ)==0 ){
58025+ return 0; /* Case (2) */
58026+ }
58027+ if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
5800958028#ifndef SQLITE_OMIT_WAL
5801058029 if( pPager->pWal ){
5801158030 u32 iRead = 0;
5801258031 (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
58013- return iRead==0;
58032+ return iRead==0; /* Condition (4) */
5801458033 }
5801558034#endif
5801658035 return 1;
@@ -158939,6 +158958,7 @@ static Expr *removeUnindexableInClauseTerms(
158939158958 pNew->pLeft->x.pList = pLhs;
158940158959 }
158941158960 pSelect->pEList = pRhs;
158961+ pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */
158942158962 if( pLhs && pLhs->nExpr==1 ){
158943158963 /* Take care here not to generate a TK_VECTOR containing only a
158944158964 ** single value. Since the parser never creates such a vector, some
@@ -189798,10 +189818,15 @@ static int fts3PoslistPhraseMerge(
189798189818 if( *p1==POS_COLUMN ){
189799189819 p1++;
189800189820 p1 += fts3GetVarint32(p1, &iCol1);
189821+ /* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN
189822+ ** entry, so this is actually end-of-doclist. */
189823+ if( iCol1==0 ) return 0;
189801189824 }
189802189825 if( *p2==POS_COLUMN ){
189803189826 p2++;
189804189827 p2 += fts3GetVarint32(p2, &iCol2);
189828+ /* As above, iCol2==0 indicates corruption. */
189829+ if( iCol2==0 ) return 0;
189805189830 }
189806189831
189807189832 while( 1 ){
@@ -192972,7 +192997,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
192972192997 nTmp += p->pRight->pPhrase->doclist.nList;
192973192998 }
192974192999 nTmp += p->pPhrase->doclist.nList;
192975- aTmp = sqlite3_malloc64(nTmp*2);
193000+ aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX );
192976193001 if( !aTmp ){
192977193002 *pRc = SQLITE_NOMEM;
192978193003 res = 0;
@@ -194525,10 +194550,11 @@ static int getNextString(
194525194550 Fts3PhraseToken *pToken;
194526194551
194527194552 p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
194528- if( !p ) goto no_mem;
194529-
194530194553 zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);
194531- if( !zTemp ) goto no_mem;
194554+ if( !zTemp || !p ){
194555+ rc = SQLITE_NOMEM;
194556+ goto getnextstring_out;
194557+ }
194532194558
194533194559 assert( nToken==ii );
194534194560 pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];
@@ -194543,29 +194569,27 @@ static int getNextString(
194543194569 nToken = ii+1;
194544194570 }
194545194571 }
194546-
194547- pModule->xClose(pCursor);
194548- pCursor = 0;
194549194572 }
194550194573
194551194574 if( rc==SQLITE_DONE ){
194552194575 int jj;
194553194576 char *zBuf = 0;
194554194577
194555194578 p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);
194556- if( !p ) goto no_mem;
194579+ if( !p ){
194580+ rc = SQLITE_NOMEM;
194581+ goto getnextstring_out;
194582+ }
194557194583 memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);
194558194584 p->eType = FTSQUERY_PHRASE;
194559194585 p->pPhrase = (Fts3Phrase *)&p[1];
194560194586 p->pPhrase->iColumn = pParse->iDefaultCol;
194561194587 p->pPhrase->nToken = nToken;
194562194588
194563194589 zBuf = (char *)&p->pPhrase->aToken[nToken];
194590+ assert( nTemp==0 || zTemp );
194564194591 if( zTemp ){
194565194592 memcpy(zBuf, zTemp, nTemp);
194566- sqlite3_free(zTemp);
194567- }else{
194568- assert( nTemp==0 );
194569194593 }
194570194594
194571194595 for(jj=0; jj<p->pPhrase->nToken; jj++){
@@ -194575,17 +194599,17 @@ static int getNextString(
194575194599 rc = SQLITE_OK;
194576194600 }
194577194601
194578- *ppExpr = p;
194579- return rc;
194580- no_mem:
194581-
194602+ getnextstring_out:
194582194603 if( pCursor ){
194583194604 pModule->xClose(pCursor);
194584194605 }
194585194606 sqlite3_free(zTemp);
194586- sqlite3_free(p);
194587- *ppExpr = 0;
194588- return SQLITE_NOMEM;
194607+ if( rc!=SQLITE_OK ){
194608+ sqlite3_free(p);
194609+ p = 0;
194610+ }
194611+ *ppExpr = p;
194612+ return rc;
194589194613}
194590194614
194591194615/*
@@ -232806,7 +232830,27 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
232806232830/************** End of sqlite3session.c **************************************/
232807232831/************** Begin file fts5.c ********************************************/
232808232832
232809-
232833+ /*
232834+ ** This, the "fts5.c" source file, is a composite file that is itself
232835+ ** assembled from the following files:
232836+ **
232837+ ** fts5.h
232838+ ** fts5Int.h
232839+ ** fts5parse.h <--- Generated from fts5parse.y by Lemon
232840+ ** fts5parse.c <--- Generated from fts5parse.y by Lemon
232841+ ** fts5_aux.c
232842+ ** fts5_buffer.c
232843+ ** fts5_config.c
232844+ ** fts5_expr.c
232845+ ** fts5_hash.c
232846+ ** fts5_index.c
232847+ ** fts5_main.c
232848+ ** fts5_storage.c
232849+ ** fts5_tokenize.c
232850+ ** fts5_unicode2.c
232851+ ** fts5_varint.c
232852+ ** fts5_vocab.c
232853+ */
232810232854#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5)
232811232855
232812232856#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -232816,6 +232860,12 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
232816232860# undef NDEBUG
232817232861#endif
232818232862
232863+ #ifdef HAVE_STDINT_H
232864+ /* #include <stdint.h> */
232865+ #endif
232866+ #ifdef HAVE_INTTYPES_H
232867+ /* #include <inttypes.h> */
232868+ #endif
232819232869/*
232820232870** 2014 May 31
232821232871**
@@ -254888,7 +254938,7 @@ static void fts5SourceIdFunc(
254888254938){
254889254939 assert( nArg==0 );
254890254940 UNUSED_PARAM2(nArg, apUnused);
254891- sqlite3_result_text(pCtx, "fts5: 2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e ", -1, SQLITE_TRANSIENT);
254941+ sqlite3_result_text(pCtx, "fts5: 2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e ", -1, SQLITE_TRANSIENT);
254892254942}
254893254943
254894254944/*
@@ -260079,7 +260129,7 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
260079260129}
260080260130
260081260131
260082-
260132+ /* Here ends the fts5.c composite file. */
260083260133#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
260084260134
260085260135/************** End of fts5.c ************************************************/
0 commit comments