1
1
/******************************************************************************
2
2
** 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
4
4
** single large file, the entire code can be compiled as a single translation
5
5
** unit. This allows many compilers to do optimizations that would not be
6
6
** possible if the files were compiled separately. Performance improvements
18
18
** separate file. This file contains only code for the core SQLite library.
19
19
**
20
20
** The content in this amalgamation comes from Fossil check-in
21
- ** 03a9703e27c44437c39363d0baf82db4ebc9 .
21
+ ** b95d11e958643b969c47a8e5857f3793b9e6 .
22
22
*/
23
23
#define SQLITE_CORE 1
24
24
#define SQLITE_AMALGAMATION 1
@@ -463,9 +463,9 @@ extern "C" {
463
463
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
464
464
** [sqlite_version()] and [sqlite_source_id()].
465
465
*/
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 "
469
469
470
470
/*
471
471
** CAPI3REF: Run-Time Library Version Numbers
@@ -969,6 +969,13 @@ SQLITE_API int sqlite3_exec(
969
969
** filesystem supports doing multiple write operations atomically when those
970
970
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
971
971
** [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.
972
979
*/
973
980
#define SQLITE_IOCAP_ATOMIC 0x00000001
974
981
#define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -985,6 +992,7 @@ SQLITE_API int sqlite3_exec(
985
992
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
986
993
#define SQLITE_IOCAP_IMMUTABLE 0x00002000
987
994
#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
995
+ #define SQLITE_IOCAP_SUBPAGE_READ 0x00008000
988
996
989
997
/*
990
998
** CAPI3REF: File Locking Levels
@@ -1131,6 +1139,7 @@ struct sqlite3_file {
1131
1139
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
1132
1140
** <li> [SQLITE_IOCAP_IMMUTABLE]
1133
1141
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
1142
+ ** <li> [SQLITE_IOCAP_SUBPAGE_READ]
1134
1143
** </ul>
1135
1144
**
1136
1145
** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -32299,6 +32308,7 @@ SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExp
32299
32308
pExpr = pExpr->pLeft;
32300
32309
}
32301
32310
if( pExpr==0 ) return;
32311
+ if( ExprHasProperty(pExpr, EP_FromDDL) ) return;
32302
32312
db->errByteOffset = pExpr->w.iOfst;
32303
32313
}
32304
32314
@@ -42592,6 +42602,7 @@ static void setDeviceCharacteristics(unixFile *pFd){
42592
42602
if( pFd->ctrlFlags & UNIXFILE_PSOW ){
42593
42603
pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
42594
42604
}
42605
+ pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ;
42595
42606
42596
42607
pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
42597
42608
}
@@ -50392,7 +50403,7 @@ static int winSectorSize(sqlite3_file *id){
50392
50403
*/
50393
50404
static int winDeviceCharacteristics(sqlite3_file *id){
50394
50405
winFile *p = (winFile*)id;
50395
- return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
50406
+ return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_SUBPAGE_READ |
50396
50407
((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
50397
50408
}
50398
50409
@@ -51780,7 +51791,7 @@ static int winOpen(
51780
51791
51781
51792
int rc = SQLITE_OK; /* Function Return Code */
51782
51793
#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 */
51784
51795
#endif
51785
51796
51786
51797
int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -58000,18 +58011,26 @@ static const unsigned char aJournalMagic[] = {
58000
58011
** Return true if page pgno can be read directly from the database file
58001
58012
** by the b-tree layer. This is the case if:
58002
58013
**
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.
58006
58018
*/
58007
58019
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) */
58010
58029
#ifndef SQLITE_OMIT_WAL
58011
58030
if( pPager->pWal ){
58012
58031
u32 iRead = 0;
58013
58032
(void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
58014
- return iRead==0;
58033
+ return iRead==0; /* Condition (4) */
58015
58034
}
58016
58035
#endif
58017
58036
return 1;
@@ -158940,6 +158959,7 @@ static Expr *removeUnindexableInClauseTerms(
158940
158959
pNew->pLeft->x.pList = pLhs;
158941
158960
}
158942
158961
pSelect->pEList = pRhs;
158962
+ pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */
158943
158963
if( pLhs && pLhs->nExpr==1 ){
158944
158964
/* Take care here not to generate a TK_VECTOR containing only a
158945
158965
** single value. Since the parser never creates such a vector, some
@@ -189815,10 +189835,15 @@ static int fts3PoslistPhraseMerge(
189815
189835
if( *p1==POS_COLUMN ){
189816
189836
p1++;
189817
189837
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;
189818
189841
}
189819
189842
if( *p2==POS_COLUMN ){
189820
189843
p2++;
189821
189844
p2 += fts3GetVarint32(p2, &iCol2);
189845
+ /* As above, iCol2==0 indicates corruption. */
189846
+ if( iCol2==0 ) return 0;
189822
189847
}
189823
189848
189824
189849
while( 1 ){
@@ -192989,7 +193014,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
192989
193014
nTmp += p->pRight->pPhrase->doclist.nList;
192990
193015
}
192991
193016
nTmp += p->pPhrase->doclist.nList;
192992
- aTmp = sqlite3_malloc64(nTmp*2);
193017
+ aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX );
192993
193018
if( !aTmp ){
192994
193019
*pRc = SQLITE_NOMEM;
192995
193020
res = 0;
@@ -194542,10 +194567,11 @@ static int getNextString(
194542
194567
Fts3PhraseToken *pToken;
194543
194568
194544
194569
p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
194545
- if( !p ) goto no_mem;
194546
-
194547
194570
zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);
194548
- if( !zTemp ) goto no_mem;
194571
+ if( !zTemp || !p ){
194572
+ rc = SQLITE_NOMEM;
194573
+ goto getnextstring_out;
194574
+ }
194549
194575
194550
194576
assert( nToken==ii );
194551
194577
pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];
@@ -194560,29 +194586,27 @@ static int getNextString(
194560
194586
nToken = ii+1;
194561
194587
}
194562
194588
}
194563
-
194564
- pModule->xClose(pCursor);
194565
- pCursor = 0;
194566
194589
}
194567
194590
194568
194591
if( rc==SQLITE_DONE ){
194569
194592
int jj;
194570
194593
char *zBuf = 0;
194571
194594
194572
194595
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
+ }
194574
194600
memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);
194575
194601
p->eType = FTSQUERY_PHRASE;
194576
194602
p->pPhrase = (Fts3Phrase *)&p[1];
194577
194603
p->pPhrase->iColumn = pParse->iDefaultCol;
194578
194604
p->pPhrase->nToken = nToken;
194579
194605
194580
194606
zBuf = (char *)&p->pPhrase->aToken[nToken];
194607
+ assert( nTemp==0 || zTemp );
194581
194608
if( zTemp ){
194582
194609
memcpy(zBuf, zTemp, nTemp);
194583
- sqlite3_free(zTemp);
194584
- }else{
194585
- assert( nTemp==0 );
194586
194610
}
194587
194611
194588
194612
for(jj=0; jj<p->pPhrase->nToken; jj++){
@@ -194592,17 +194616,17 @@ static int getNextString(
194592
194616
rc = SQLITE_OK;
194593
194617
}
194594
194618
194595
- *ppExpr = p;
194596
- return rc;
194597
- no_mem:
194598
-
194619
+ getnextstring_out:
194599
194620
if( pCursor ){
194600
194621
pModule->xClose(pCursor);
194601
194622
}
194602
194623
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;
194606
194630
}
194607
194631
194608
194632
/*
@@ -232823,7 +232847,27 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
232823
232847
/************** End of sqlite3session.c **************************************/
232824
232848
/************** Begin file fts5.c ********************************************/
232825
232849
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
+ */
232827
232871
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5)
232828
232872
232829
232873
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -232833,6 +232877,12 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
232833
232877
# undef NDEBUG
232834
232878
#endif
232835
232879
232880
+ #ifdef HAVE_STDINT_H
232881
+ /* #include <stdint.h> */
232882
+ #endif
232883
+ #ifdef HAVE_INTTYPES_H
232884
+ /* #include <inttypes.h> */
232885
+ #endif
232836
232886
/*
232837
232887
** 2014 May 31
232838
232888
**
@@ -254905,7 +254955,7 @@ static void fts5SourceIdFunc(
254905
254955
){
254906
254956
assert( nArg==0 );
254907
254957
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);
254909
254959
}
254910
254960
254911
254961
/*
@@ -260096,7 +260146,7 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
260096
260146
}
260097
260147
260098
260148
260099
-
260149
+ /* Here ends the fts5.c composite file. */
260100
260150
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
260101
260151
260102
260152
/************** End of fts5.c ************************************************/
0 commit comments