Fossil SCM

Update the built-in SQLite to the latest trunk version that attempts to fix various harmless compiler warnings reported by the new Clang-15.

drh 2023-02-03 14:59 trunk
Commit ea57625d3137f512ff125b389fd68da0c5dbaa83284a794c51fe9798192b53cd
+7 -3
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3549,11 +3549,12 @@
35493549
*/
35503550
static char* toBase85( u8 *pIn, int nbIn, char *pOut, char *pSep ){
35513551
int nCol = 0;
35523552
while( nbIn >= 4 ){
35533553
int nco = 5;
3554
- unsigned long qbv = (pIn[0]<<24)|(pIn[1]<<16)|(pIn[2]<<8)|pIn[3];
3554
+ unsigned long qbv = (((unsigned long)pIn[0])<<24) |
3555
+ (pIn[1]<<16) | (pIn[2]<<8) | pIn[3];
35553556
while( nco > 0 ){
35563557
unsigned nqv = (unsigned)(qbv/85UL);
35573558
unsigned char dv = qbv - 85UL*nqv;
35583559
qbv = nqv;
35593560
pOut[--nco] = base85Numeral(dv);
@@ -20829,14 +20830,17 @@
2082920830
#endif
2083020831
2083120832
/*
2083220833
** A no-op routine that runs with the ".breakpoint" doc-command. This is
2083320834
** a useful spot to set a debugger breakpoint.
20835
+**
20836
+** This routine does not do anything practical. The code are there simply
20837
+** to prevent the compiler from optimizing this routine out.
2083420838
*/
2083520839
static void test_breakpoint(void){
20836
- static int nCall = 0;
20837
- nCall++;
20840
+ static unsigned int nCall = 0;
20841
+ if( (nCall++)==0xffffffff ) printf("Many .breakpoints have run\n");
2083820842
}
2083920843
2084020844
/*
2084120845
** An object used to read a CSV and other files for import.
2084220846
*/
2084320847
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3549,11 +3549,12 @@
3549 */
3550 static char* toBase85( u8 *pIn, int nbIn, char *pOut, char *pSep ){
3551 int nCol = 0;
3552 while( nbIn >= 4 ){
3553 int nco = 5;
3554 unsigned long qbv = (pIn[0]<<24)|(pIn[1]<<16)|(pIn[2]<<8)|pIn[3];
 
3555 while( nco > 0 ){
3556 unsigned nqv = (unsigned)(qbv/85UL);
3557 unsigned char dv = qbv - 85UL*nqv;
3558 qbv = nqv;
3559 pOut[--nco] = base85Numeral(dv);
@@ -20829,14 +20830,17 @@
20829 #endif
20830
20831 /*
20832 ** A no-op routine that runs with the ".breakpoint" doc-command. This is
20833 ** a useful spot to set a debugger breakpoint.
 
 
 
20834 */
20835 static void test_breakpoint(void){
20836 static int nCall = 0;
20837 nCall++;
20838 }
20839
20840 /*
20841 ** An object used to read a CSV and other files for import.
20842 */
20843
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3549,11 +3549,12 @@
3549 */
3550 static char* toBase85( u8 *pIn, int nbIn, char *pOut, char *pSep ){
3551 int nCol = 0;
3552 while( nbIn >= 4 ){
3553 int nco = 5;
3554 unsigned long qbv = (((unsigned long)pIn[0])<<24) |
3555 (pIn[1]<<16) | (pIn[2]<<8) | pIn[3];
3556 while( nco > 0 ){
3557 unsigned nqv = (unsigned)(qbv/85UL);
3558 unsigned char dv = qbv - 85UL*nqv;
3559 qbv = nqv;
3560 pOut[--nco] = base85Numeral(dv);
@@ -20829,14 +20830,17 @@
20830 #endif
20831
20832 /*
20833 ** A no-op routine that runs with the ".breakpoint" doc-command. This is
20834 ** a useful spot to set a debugger breakpoint.
20835 **
20836 ** This routine does not do anything practical. The code are there simply
20837 ** to prevent the compiler from optimizing this routine out.
20838 */
20839 static void test_breakpoint(void){
20840 static unsigned int nCall = 0;
20841 if( (nCall++)==0xffffffff ) printf("Many .breakpoints have run\n");
20842 }
20843
20844 /*
20845 ** An object used to read a CSV and other files for import.
20846 */
20847
+97 -45
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455455
#define SQLITE_VERSION "3.41.0"
456456
#define SQLITE_VERSION_NUMBER 3041000
457
-#define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
457
+#define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -31543,10 +31543,17 @@
3154331543
sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse);
3154431544
}
3154531545
if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
3154631546
sqlite3_str_appendf(&x, " ON");
3154731547
}
31548
+ if( pItem->fg.isTabFunc ) sqlite3_str_appendf(&x, " isTabFunc");
31549
+ if( pItem->fg.isCorrelated ) sqlite3_str_appendf(&x, " isCorrelated");
31550
+ if( pItem->fg.isMaterialized ) sqlite3_str_appendf(&x, " isMaterialized");
31551
+ if( pItem->fg.viaCoroutine ) sqlite3_str_appendf(&x, " viaCoroutine");
31552
+ if( pItem->fg.notCte ) sqlite3_str_appendf(&x, " notCte");
31553
+ if( pItem->fg.isNestedFrom ) sqlite3_str_appendf(&x, " isNestedFrom");
31554
+
3154831555
sqlite3StrAccumFinish(&x);
3154931556
sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1);
3155031557
n = 0;
3155131558
if( pItem->pSelect ) n++;
3155231559
if( pItem->fg.isTabFunc ) n++;
@@ -38548,11 +38555,11 @@
3854838555
** still short of its goal. The following chart shows the allowed
3854938556
** transitions and the inserted intermediate states:
3855038557
**
3855138558
** UNLOCKED -> SHARED
3855238559
** SHARED -> RESERVED
38553
-** SHARED -> (PENDING) -> EXCLUSIVE
38560
+** SHARED -> EXCLUSIVE
3855438561
** RESERVED -> (PENDING) -> EXCLUSIVE
3855538562
** PENDING -> EXCLUSIVE
3855638563
**
3855738564
** This routine will only increase a lock. Use the sqlite3OsUnlock()
3855838565
** routine to lower a locking level.
@@ -38581,23 +38588,24 @@
3858138588
**
3858238589
** A process may only obtain a RESERVED lock after it has a SHARED lock.
3858338590
** A RESERVED lock is implemented by grabbing a write-lock on the
3858438591
** 'reserved byte'.
3858538592
**
38586
- ** A process may only obtain a PENDING lock after it has obtained a
38587
- ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock
38588
- ** on the 'pending byte'. This ensures that no new SHARED locks can be
38589
- ** obtained, but existing SHARED locks are allowed to persist. A process
38590
- ** does not have to obtain a RESERVED lock on the way to a PENDING lock.
38591
- ** This property is used by the algorithm for rolling back a journal file
38592
- ** after a crash.
38593
+ ** An EXCLUSIVE lock may only be requested after either a SHARED or
38594
+ ** RESERVED lock is held. An EXCLUSIVE lock is implemented by obtaining
38595
+ ** a write-lock on the entire 'shared byte range'. Since all other locks
38596
+ ** require a read-lock on one of the bytes within this range, this ensures
38597
+ ** that no other locks are held on the database.
3859338598
**
38594
- ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is
38595
- ** implemented by obtaining a write-lock on the entire 'shared byte
38596
- ** range'. Since all other locks require a read-lock on one of the bytes
38597
- ** within this range, this ensures that no other locks are held on the
38598
- ** database.
38599
+ ** If a process that holds a RESERVED lock requests an EXCLUSIVE, then
38600
+ ** a PENDING lock is obtained first. A PENDING lock is implemented by
38601
+ ** obtaining a write-lock on the 'pending byte'. This ensures that no new
38602
+ ** SHARED locks can be obtained, but existing SHARED locks are allowed to
38603
+ ** persist. If the call to this function fails to obtain the EXCLUSIVE
38604
+ ** lock in this case, it holds the PENDING lock intead. The client may
38605
+ ** then re-attempt the EXCLUSIVE lock later on, after existing SHARED
38606
+ ** locks have cleared.
3859938607
*/
3860038608
int rc = SQLITE_OK;
3860138609
unixFile *pFile = (unixFile*)id;
3860238610
unixInodeInfo *pInode;
3860338611
struct flock lock;
@@ -38664,11 +38672,11 @@
3866438672
** be released.
3866538673
*/
3866638674
lock.l_len = 1L;
3866738675
lock.l_whence = SEEK_SET;
3866838676
if( eFileLock==SHARED_LOCK
38669
- || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)
38677
+ || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock==RESERVED_LOCK)
3867038678
){
3867138679
lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);
3867238680
lock.l_start = PENDING_BYTE;
3867338681
if( unixFileLock(pFile, &lock) ){
3867438682
tErrno = errno;
@@ -38675,10 +38683,13 @@
3867538683
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
3867638684
if( rc!=SQLITE_BUSY ){
3867738685
storeLastErrno(pFile, tErrno);
3867838686
}
3867938687
goto end_lock;
38688
+ }else if( eFileLock==EXCLUSIVE_LOCK ){
38689
+ pFile->eFileLock = PENDING_LOCK;
38690
+ pInode->eFileLock = PENDING_LOCK;
3868038691
}
3868138692
}
3868238693
3868338694
3868438695
/* If control gets to this point, then actually go ahead and make
@@ -38762,17 +38773,13 @@
3876238773
pFile->dbUpdate = 0;
3876338774
pFile->inNormalWrite = 1;
3876438775
}
3876538776
#endif
3876638777
38767
-
3876838778
if( rc==SQLITE_OK ){
3876938779
pFile->eFileLock = eFileLock;
3877038780
pInode->eFileLock = eFileLock;
38771
- }else if( eFileLock==EXCLUSIVE_LOCK ){
38772
- pFile->eFileLock = PENDING_LOCK;
38773
- pInode->eFileLock = PENDING_LOCK;
3877438781
}
3877538782
3877638783
end_lock:
3877738784
sqlite3_mutex_leave(pInode->pLockMutex);
3877838785
OSTRACE(("LOCK %d %s %s (unix)\n", pFile->h, azFileLock(eFileLock),
@@ -60118,11 +60125,10 @@
6011860125
int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
6011960126
int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
6012060127
u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
6012160128
const char *zUri = 0; /* URI args to copy */
6012260129
int nUriByte = 1; /* Number of bytes of URI args at *zUri */
60123
- int nUri = 0; /* Number of URI parameters */
6012460130
6012560131
/* Figure out how much space is required for each journal file-handle
6012660132
** (there are two of them, the main journal and the sub-journal). */
6012760133
journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
6012860134
@@ -60166,11 +60172,10 @@
6016660172
nPathname = sqlite3Strlen30(zPathname);
6016760173
z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
6016860174
while( *z ){
6016960175
z += strlen(z)+1;
6017060176
z += strlen(z)+1;
60171
- nUri++;
6017260177
}
6017360178
nUriByte = (int)(&z[1] - zUri);
6017460179
assert( nUriByte>=1 );
6017560180
if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
6017660181
/* This branch is taken when the journal path required by
@@ -78786,11 +78791,13 @@
7878678791
** entry represents the span of a cell or freeblock on a btree page.
7878778792
** The upper 16 bits are the index of the first byte of a range and the
7878878793
** lower 16 bits are the index of the last byte of that range.
7878978794
*/
7879078795
static void btreeHeapInsert(u32 *aHeap, u32 x){
78791
- u32 j, i = ++aHeap[0];
78796
+ u32 j, i;
78797
+ assert( aHeap!=0 );
78798
+ i = ++aHeap[0];
7879278799
aHeap[i] = x;
7879378800
while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){
7879478801
x = aHeap[j];
7879578802
aHeap[j] = aHeap[i];
7879678803
aHeap[i] = x;
@@ -81830,12 +81837,10 @@
8183081837
if( pVal==0 ){
8183181838
rc = SQLITE_NOMEM_BKPT;
8183281839
goto value_from_function_out;
8183381840
}
8183481841
81835
- testcase( pCtx->pParse->rc==SQLITE_ERROR );
81836
- testcase( pCtx->pParse->rc==SQLITE_OK );
8183781842
memset(&ctx, 0, sizeof(ctx));
8183881843
ctx.pOut = pVal;
8183981844
ctx.pFunc = pFunc;
8184081845
ctx.enc = ENC(db);
8184181846
pFunc->xSFunc(&ctx, nVal, apVal);
@@ -81843,15 +81848,18 @@
8184381848
rc = ctx.isError;
8184481849
sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
8184581850
}else{
8184681851
sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
8184781852
assert( rc==SQLITE_OK );
81853
+ assert( enc==pVal->enc || db->mallocFailed );
81854
+#if 0 /* Not reachable except after a prior failure */
8184881855
rc = sqlite3VdbeChangeEncoding(pVal, enc);
8184981856
if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
8185081857
rc = SQLITE_TOOBIG;
8185181858
pCtx->pParse->nErr++;
8185281859
}
81860
+#endif
8185381861
}
8185481862
pCtx->pParse->rc = rc;
8185581863
8185681864
value_from_function_out:
8185781865
if( rc!=SQLITE_OK ){
@@ -103700,10 +103708,36 @@
103700103708
assert( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 );
103701103709
ExprSetProperty(pNew, EP_CanBeNull);
103702103710
*ppList = sqlite3ExprListAppend(pParse, *ppList, pNew);
103703103711
}
103704103712
}
103713
+
103714
+/*
103715
+** Return TRUE (non-zero) if zTab is a valid name for the schema table pTab.
103716
+*/
103717
+static SQLITE_NOINLINE int isValidSchemaTableName(
103718
+ const char *zTab, /* Name as it appears in the SQL */
103719
+ Table *pTab, /* The schema table we are trying to match */
103720
+ Schema *pSchema /* non-NULL if a database qualifier is present */
103721
+){
103722
+ const char *zLegacy;
103723
+ assert( pTab!=0 );
103724
+ assert( pTab->tnum==1 );
103725
+ if( sqlite3StrNICmp(zTab, "sqlite_", 7)!=0 ) return 0;
103726
+ zLegacy = pTab->zName;
103727
+ if( strcmp(zLegacy+7, &LEGACY_TEMP_SCHEMA_TABLE[7])==0 ){
103728
+ if( sqlite3StrICmp(zTab+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 ){
103729
+ return 1;
103730
+ }
103731
+ if( pSchema==0 ) return 0;
103732
+ if( sqlite3StrICmp(zTab+7, &LEGACY_SCHEMA_TABLE[7])==0 ) return 1;
103733
+ if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1;
103734
+ }else{
103735
+ if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1;
103736
+ }
103737
+ return 0;
103738
+}
103705103739
103706103740
/*
103707103741
** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
103708103742
** that name in the set of source tables in pSrcList and make the pExpr
103709103743
** expression node refer back to that source column. The following changes
@@ -103854,19 +103888,21 @@
103854103888
}
103855103889
if( hit || zTab==0 ) continue;
103856103890
}
103857103891
assert( zDb==0 || zTab!=0 );
103858103892
if( zTab ){
103859
- const char *zTabName;
103860103893
if( zDb ){
103861103894
if( pTab->pSchema!=pSchema ) continue;
103862103895
if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue;
103863103896
}
103864
- zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
103865
- assert( zTabName!=0 );
103866
- if( sqlite3StrICmp(zTabName, zTab)!=0 ){
103867
- continue;
103897
+ if( pItem->zAlias!=0 ){
103898
+ if( sqlite3StrICmp(zTab, pItem->zAlias)!=0 ){
103899
+ continue;
103900
+ }
103901
+ }else if( sqlite3StrICmp(zTab, pTab->zName)!=0 ){
103902
+ if( pTab->tnum!=1 ) continue;
103903
+ if( !isValidSchemaTableName(zTab, pTab, pSchema) ) continue;
103868103904
}
103869103905
assert( ExprUseYTab(pExpr) );
103870103906
if( IN_RENAME_OBJECT && pItem->zAlias ){
103871103907
sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
103872103908
}
@@ -116150,20 +116186,22 @@
116150116186
/*
116151116187
** If the Index.aSample variable is not NULL, delete the aSample[] array
116152116188
** and its contents.
116153116189
*/
116154116190
SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
116191
+ assert( db!=0 );
116192
+ assert( pIdx!=0 );
116155116193
#ifdef SQLITE_ENABLE_STAT4
116156116194
if( pIdx->aSample ){
116157116195
int j;
116158116196
for(j=0; j<pIdx->nSample; j++){
116159116197
IndexSample *p = &pIdx->aSample[j];
116160116198
sqlite3DbFree(db, p->p);
116161116199
}
116162116200
sqlite3DbFree(db, pIdx->aSample);
116163116201
}
116164
- if( db && db->pnBytesFreed==0 ){
116202
+ if( db->pnBytesFreed==0 ){
116165116203
pIdx->nSample = 0;
116166116204
pIdx->aSample = 0;
116167116205
}
116168116206
#else
116169116207
UNUSED_PARAMETER(db);
@@ -135976,16 +136014,25 @@
135976136014
/* Fetch the right-most column from the table. This will cause
135977136015
** the entire record header to be parsed and sanity checked. It
135978136016
** will also prepopulate the cursor column cache that is used
135979136017
** by the OP_IsType code, so it is a required step.
135980136018
*/
135981
- mxCol = pTab->nCol-1;
135982
- while( mxCol>=0
135983
- && ((pTab->aCol[mxCol].colFlags & COLFLAG_VIRTUAL)!=0
135984
- || pTab->iPKey==mxCol) ) mxCol--;
136019
+ assert( !IsVirtual(pTab) );
136020
+ if( HasRowid(pTab) ){
136021
+ mxCol = -1;
136022
+ for(j=0; j<pTab->nCol; j++){
136023
+ if( (pTab->aCol[j].colFlags & COLFLAG_VIRTUAL)==0 ) mxCol++;
136024
+ }
136025
+ if( mxCol==pTab->iPKey ) mxCol--;
136026
+ }else{
136027
+ /* COLFLAG_VIRTUAL columns are not included in the WITHOUT ROWID
136028
+ ** PK index column-count, so there is no need to account for them
136029
+ ** in this case. */
136030
+ mxCol = sqlite3PrimaryKeyIndex(pTab)->nColumn-1;
136031
+ }
135985136032
if( mxCol>=0 ){
135986
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, mxCol, 3);
136033
+ sqlite3VdbeAddOp3(v, OP_Column, iDataCur, mxCol, 3);
135987136034
sqlite3VdbeTypeofColumn(v, 3);
135988136035
}
135989136036
135990136037
if( !isQuick ){
135991136038
if( pPk ){
@@ -143758,13 +143805,10 @@
143758143805
return 2;
143759143806
}
143760143807
pFrom->fg.isCte = 1;
143761143808
pFrom->u2.pCteUse = pCteUse;
143762143809
pCteUse->nUse++;
143763
- if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){
143764
- pCteUse->eM10d = M10d_Yes;
143765
- }
143766143810
143767143811
/* Check if this is a recursive CTE. */
143768143812
pRecTerm = pSel = pFrom->pSelect;
143769143813
bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
143770143814
while( bMayRecursive && pRecTerm->op==pSel->op ){
@@ -145043,12 +145087,14 @@
145043145087
** (i) The subquery is the left-most subquery in the FROM clause
145044145088
** (ii) There is nothing that would prevent the subquery from
145045145089
** being used as the outer loop if the sqlite3WhereBegin()
145046145090
** routine nominates it to that position.
145047145091
** (iii) The query is not a UPDATE ... FROM
145048
-** (2) The subquery is not a CTE that should be materialized because of
145049
-** the AS MATERIALIZED keywords
145092
+** (2) The subquery is not a CTE that should be materialized because
145093
+** (a) the AS MATERIALIZED keyword is used, or
145094
+** (b) the CTE is used multiple times and does not have the
145095
+** NOT MATERIALIZED keyword
145050145096
** (3) The subquery is not part of a left operand for a RIGHT JOIN
145051145097
** (4) The SQLITE_Coroutine optimization disable flag is not set
145052145098
** (5) The subquery is not self-joined
145053145099
*/
145054145100
static int fromClauseTermCanBeCoroutine(
@@ -145056,13 +145102,17 @@
145056145102
SrcList *pTabList, /* FROM clause */
145057145103
int i, /* Which term of the FROM clause holds the subquery */
145058145104
int selFlags /* Flags on the SELECT statement */
145059145105
){
145060145106
SrcItem *pItem = &pTabList->a[i];
145061
- if( pItem->fg.isCte && pItem->u2.pCteUse->eM10d==M10d_Yes ) return 0;/* (2) */
145062
- if( pTabList->a[0].fg.jointype & JT_LTORJ ) return 0; /* (3) */
145063
- if( OptimizationDisabled(pParse->db, SQLITE_Coroutines) ) return 0; /* (4) */
145107
+ if( pItem->fg.isCte ){
145108
+ const CteUse *pCteUse = pItem->u2.pCteUse;
145109
+ if( pCteUse->eM10d==M10d_Yes ) return 0; /* (2a) */
145110
+ if( pCteUse->nUse>=2 && pCteUse->eM10d!=M10d_No ) return 0; /* (2b) */
145111
+ }
145112
+ if( pTabList->a[0].fg.jointype & JT_LTORJ ) return 0; /* (3) */
145113
+ if( OptimizationDisabled(pParse->db, SQLITE_Coroutines) ) return 0; /* (4) */
145064145114
if( isSelfJoinView(pTabList, pItem, i+1, pTabList->nSrc)!=0 ){
145065145115
return 0; /* (5) */
145066145116
}
145067145117
if( i==0 ){
145068145118
if( pTabList->nSrc==1 ) return 1; /* (1a) */
@@ -160345,11 +160395,12 @@
160345160395
** indexes on subqueries and views. */
160346160396
pNew->rSetup = rLogSize + rSize;
160347160397
if( !IsView(pTab) && (pTab->tabFlags & TF_Ephemeral)==0 ){
160348160398
pNew->rSetup += 28;
160349160399
}else{
160350
- pNew->rSetup -= 10;
160400
+ pNew->rSetup -= 25; /* Greatly reduced setup cost for auto indexes
160401
+ ** on ephemeral materializations of views */
160351160402
}
160352160403
ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
160353160404
if( pNew->rSetup<0 ) pNew->rSetup = 0;
160354160405
/* TUNING: Each index lookup yields 20 rows in the table. This
160355160406
** is more than the usual guess of 10 rows, since we have no way
@@ -164586,10 +164637,11 @@
164586164637
** of sqlite3DbMallocRawNN() called from
164587164638
** sqlite3SrcListAppend() */
164588164639
if( p->pSrc ){
164589164640
Table *pTab2;
164590164641
p->pSrc->a[0].pSelect = pSub;
164642
+ p->pSrc->a[0].fg.isCorrelated = 1;
164591164643
sqlite3SrcListAssignCursors(pParse, p->pSrc);
164592164644
pSub->selFlags |= SF_Expanded|SF_OrderByReqd;
164593164645
pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
164594164646
pSub->selFlags |= (selFlags & SF_Aggregate);
164595164647
if( pTab2==0 ){
@@ -240036,11 +240088,11 @@
240036240088
int nArg, /* Number of args */
240037240089
sqlite3_value **apUnused /* Function arguments */
240038240090
){
240039240091
assert( nArg==0 );
240040240092
UNUSED_PARAM2(nArg, apUnused);
240041
- sqlite3_result_text(pCtx, "fts5: 2023-01-19 18:16:09 fa10e561f5dcdb23af862c2e486e877d379f12eae077ae5fd3da6028f1c20b49", -1, SQLITE_TRANSIENT);
240093
+ sqlite3_result_text(pCtx, "fts5: 2023-02-03 12:03:56 75cdaafc77b8a1efc84e71e90470994227f376e7d7de34c813e75dcadbb9f268", -1, SQLITE_TRANSIENT);
240042240094
}
240043240095
240044240096
/*
240045240097
** Return true if zName is the extension on one of the shadow tables used
240046240098
** by this module.
240047240099
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.41.0"
456 #define SQLITE_VERSION_NUMBER 3041000
457 #define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -31543,10 +31543,17 @@
31543 sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse);
31544 }
31545 if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
31546 sqlite3_str_appendf(&x, " ON");
31547 }
 
 
 
 
 
 
 
31548 sqlite3StrAccumFinish(&x);
31549 sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1);
31550 n = 0;
31551 if( pItem->pSelect ) n++;
31552 if( pItem->fg.isTabFunc ) n++;
@@ -38548,11 +38555,11 @@
38548 ** still short of its goal. The following chart shows the allowed
38549 ** transitions and the inserted intermediate states:
38550 **
38551 ** UNLOCKED -> SHARED
38552 ** SHARED -> RESERVED
38553 ** SHARED -> (PENDING) -> EXCLUSIVE
38554 ** RESERVED -> (PENDING) -> EXCLUSIVE
38555 ** PENDING -> EXCLUSIVE
38556 **
38557 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
38558 ** routine to lower a locking level.
@@ -38581,23 +38588,24 @@
38581 **
38582 ** A process may only obtain a RESERVED lock after it has a SHARED lock.
38583 ** A RESERVED lock is implemented by grabbing a write-lock on the
38584 ** 'reserved byte'.
38585 **
38586 ** A process may only obtain a PENDING lock after it has obtained a
38587 ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock
38588 ** on the 'pending byte'. This ensures that no new SHARED locks can be
38589 ** obtained, but existing SHARED locks are allowed to persist. A process
38590 ** does not have to obtain a RESERVED lock on the way to a PENDING lock.
38591 ** This property is used by the algorithm for rolling back a journal file
38592 ** after a crash.
38593 **
38594 ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is
38595 ** implemented by obtaining a write-lock on the entire 'shared byte
38596 ** range'. Since all other locks require a read-lock on one of the bytes
38597 ** within this range, this ensures that no other locks are held on the
38598 ** database.
 
 
 
38599 */
38600 int rc = SQLITE_OK;
38601 unixFile *pFile = (unixFile*)id;
38602 unixInodeInfo *pInode;
38603 struct flock lock;
@@ -38664,11 +38672,11 @@
38664 ** be released.
38665 */
38666 lock.l_len = 1L;
38667 lock.l_whence = SEEK_SET;
38668 if( eFileLock==SHARED_LOCK
38669 || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)
38670 ){
38671 lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);
38672 lock.l_start = PENDING_BYTE;
38673 if( unixFileLock(pFile, &lock) ){
38674 tErrno = errno;
@@ -38675,10 +38683,13 @@
38675 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
38676 if( rc!=SQLITE_BUSY ){
38677 storeLastErrno(pFile, tErrno);
38678 }
38679 goto end_lock;
 
 
 
38680 }
38681 }
38682
38683
38684 /* If control gets to this point, then actually go ahead and make
@@ -38762,17 +38773,13 @@
38762 pFile->dbUpdate = 0;
38763 pFile->inNormalWrite = 1;
38764 }
38765 #endif
38766
38767
38768 if( rc==SQLITE_OK ){
38769 pFile->eFileLock = eFileLock;
38770 pInode->eFileLock = eFileLock;
38771 }else if( eFileLock==EXCLUSIVE_LOCK ){
38772 pFile->eFileLock = PENDING_LOCK;
38773 pInode->eFileLock = PENDING_LOCK;
38774 }
38775
38776 end_lock:
38777 sqlite3_mutex_leave(pInode->pLockMutex);
38778 OSTRACE(("LOCK %d %s %s (unix)\n", pFile->h, azFileLock(eFileLock),
@@ -60118,11 +60125,10 @@
60118 int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
60119 int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
60120 u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
60121 const char *zUri = 0; /* URI args to copy */
60122 int nUriByte = 1; /* Number of bytes of URI args at *zUri */
60123 int nUri = 0; /* Number of URI parameters */
60124
60125 /* Figure out how much space is required for each journal file-handle
60126 ** (there are two of them, the main journal and the sub-journal). */
60127 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
60128
@@ -60166,11 +60172,10 @@
60166 nPathname = sqlite3Strlen30(zPathname);
60167 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
60168 while( *z ){
60169 z += strlen(z)+1;
60170 z += strlen(z)+1;
60171 nUri++;
60172 }
60173 nUriByte = (int)(&z[1] - zUri);
60174 assert( nUriByte>=1 );
60175 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
60176 /* This branch is taken when the journal path required by
@@ -78786,11 +78791,13 @@
78786 ** entry represents the span of a cell or freeblock on a btree page.
78787 ** The upper 16 bits are the index of the first byte of a range and the
78788 ** lower 16 bits are the index of the last byte of that range.
78789 */
78790 static void btreeHeapInsert(u32 *aHeap, u32 x){
78791 u32 j, i = ++aHeap[0];
 
 
78792 aHeap[i] = x;
78793 while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){
78794 x = aHeap[j];
78795 aHeap[j] = aHeap[i];
78796 aHeap[i] = x;
@@ -81830,12 +81837,10 @@
81830 if( pVal==0 ){
81831 rc = SQLITE_NOMEM_BKPT;
81832 goto value_from_function_out;
81833 }
81834
81835 testcase( pCtx->pParse->rc==SQLITE_ERROR );
81836 testcase( pCtx->pParse->rc==SQLITE_OK );
81837 memset(&ctx, 0, sizeof(ctx));
81838 ctx.pOut = pVal;
81839 ctx.pFunc = pFunc;
81840 ctx.enc = ENC(db);
81841 pFunc->xSFunc(&ctx, nVal, apVal);
@@ -81843,15 +81848,18 @@
81843 rc = ctx.isError;
81844 sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
81845 }else{
81846 sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
81847 assert( rc==SQLITE_OK );
 
 
81848 rc = sqlite3VdbeChangeEncoding(pVal, enc);
81849 if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
81850 rc = SQLITE_TOOBIG;
81851 pCtx->pParse->nErr++;
81852 }
 
81853 }
81854 pCtx->pParse->rc = rc;
81855
81856 value_from_function_out:
81857 if( rc!=SQLITE_OK ){
@@ -103700,10 +103708,36 @@
103700 assert( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 );
103701 ExprSetProperty(pNew, EP_CanBeNull);
103702 *ppList = sqlite3ExprListAppend(pParse, *ppList, pNew);
103703 }
103704 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103705
103706 /*
103707 ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
103708 ** that name in the set of source tables in pSrcList and make the pExpr
103709 ** expression node refer back to that source column. The following changes
@@ -103854,19 +103888,21 @@
103854 }
103855 if( hit || zTab==0 ) continue;
103856 }
103857 assert( zDb==0 || zTab!=0 );
103858 if( zTab ){
103859 const char *zTabName;
103860 if( zDb ){
103861 if( pTab->pSchema!=pSchema ) continue;
103862 if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue;
103863 }
103864 zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
103865 assert( zTabName!=0 );
103866 if( sqlite3StrICmp(zTabName, zTab)!=0 ){
103867 continue;
 
 
 
103868 }
103869 assert( ExprUseYTab(pExpr) );
103870 if( IN_RENAME_OBJECT && pItem->zAlias ){
103871 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
103872 }
@@ -116150,20 +116186,22 @@
116150 /*
116151 ** If the Index.aSample variable is not NULL, delete the aSample[] array
116152 ** and its contents.
116153 */
116154 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
 
 
116155 #ifdef SQLITE_ENABLE_STAT4
116156 if( pIdx->aSample ){
116157 int j;
116158 for(j=0; j<pIdx->nSample; j++){
116159 IndexSample *p = &pIdx->aSample[j];
116160 sqlite3DbFree(db, p->p);
116161 }
116162 sqlite3DbFree(db, pIdx->aSample);
116163 }
116164 if( db && db->pnBytesFreed==0 ){
116165 pIdx->nSample = 0;
116166 pIdx->aSample = 0;
116167 }
116168 #else
116169 UNUSED_PARAMETER(db);
@@ -135976,16 +136014,25 @@
135976 /* Fetch the right-most column from the table. This will cause
135977 ** the entire record header to be parsed and sanity checked. It
135978 ** will also prepopulate the cursor column cache that is used
135979 ** by the OP_IsType code, so it is a required step.
135980 */
135981 mxCol = pTab->nCol-1;
135982 while( mxCol>=0
135983 && ((pTab->aCol[mxCol].colFlags & COLFLAG_VIRTUAL)!=0
135984 || pTab->iPKey==mxCol) ) mxCol--;
 
 
 
 
 
 
 
 
 
135985 if( mxCol>=0 ){
135986 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, mxCol, 3);
135987 sqlite3VdbeTypeofColumn(v, 3);
135988 }
135989
135990 if( !isQuick ){
135991 if( pPk ){
@@ -143758,13 +143805,10 @@
143758 return 2;
143759 }
143760 pFrom->fg.isCte = 1;
143761 pFrom->u2.pCteUse = pCteUse;
143762 pCteUse->nUse++;
143763 if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){
143764 pCteUse->eM10d = M10d_Yes;
143765 }
143766
143767 /* Check if this is a recursive CTE. */
143768 pRecTerm = pSel = pFrom->pSelect;
143769 bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
143770 while( bMayRecursive && pRecTerm->op==pSel->op ){
@@ -145043,12 +145087,14 @@
145043 ** (i) The subquery is the left-most subquery in the FROM clause
145044 ** (ii) There is nothing that would prevent the subquery from
145045 ** being used as the outer loop if the sqlite3WhereBegin()
145046 ** routine nominates it to that position.
145047 ** (iii) The query is not a UPDATE ... FROM
145048 ** (2) The subquery is not a CTE that should be materialized because of
145049 ** the AS MATERIALIZED keywords
 
 
145050 ** (3) The subquery is not part of a left operand for a RIGHT JOIN
145051 ** (4) The SQLITE_Coroutine optimization disable flag is not set
145052 ** (5) The subquery is not self-joined
145053 */
145054 static int fromClauseTermCanBeCoroutine(
@@ -145056,13 +145102,17 @@
145056 SrcList *pTabList, /* FROM clause */
145057 int i, /* Which term of the FROM clause holds the subquery */
145058 int selFlags /* Flags on the SELECT statement */
145059 ){
145060 SrcItem *pItem = &pTabList->a[i];
145061 if( pItem->fg.isCte && pItem->u2.pCteUse->eM10d==M10d_Yes ) return 0;/* (2) */
145062 if( pTabList->a[0].fg.jointype & JT_LTORJ ) return 0; /* (3) */
145063 if( OptimizationDisabled(pParse->db, SQLITE_Coroutines) ) return 0; /* (4) */
 
 
 
 
145064 if( isSelfJoinView(pTabList, pItem, i+1, pTabList->nSrc)!=0 ){
145065 return 0; /* (5) */
145066 }
145067 if( i==0 ){
145068 if( pTabList->nSrc==1 ) return 1; /* (1a) */
@@ -160345,11 +160395,12 @@
160345 ** indexes on subqueries and views. */
160346 pNew->rSetup = rLogSize + rSize;
160347 if( !IsView(pTab) && (pTab->tabFlags & TF_Ephemeral)==0 ){
160348 pNew->rSetup += 28;
160349 }else{
160350 pNew->rSetup -= 10;
 
160351 }
160352 ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
160353 if( pNew->rSetup<0 ) pNew->rSetup = 0;
160354 /* TUNING: Each index lookup yields 20 rows in the table. This
160355 ** is more than the usual guess of 10 rows, since we have no way
@@ -164586,10 +164637,11 @@
164586 ** of sqlite3DbMallocRawNN() called from
164587 ** sqlite3SrcListAppend() */
164588 if( p->pSrc ){
164589 Table *pTab2;
164590 p->pSrc->a[0].pSelect = pSub;
 
164591 sqlite3SrcListAssignCursors(pParse, p->pSrc);
164592 pSub->selFlags |= SF_Expanded|SF_OrderByReqd;
164593 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
164594 pSub->selFlags |= (selFlags & SF_Aggregate);
164595 if( pTab2==0 ){
@@ -240036,11 +240088,11 @@
240036 int nArg, /* Number of args */
240037 sqlite3_value **apUnused /* Function arguments */
240038 ){
240039 assert( nArg==0 );
240040 UNUSED_PARAM2(nArg, apUnused);
240041 sqlite3_result_text(pCtx, "fts5: 2023-01-19 18:16:09 fa10e561f5dcdb23af862c2e486e877d379f12eae077ae5fd3da6028f1c20b49", -1, SQLITE_TRANSIENT);
240042 }
240043
240044 /*
240045 ** Return true if zName is the extension on one of the shadow tables used
240046 ** by this module.
240047
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.41.0"
456 #define SQLITE_VERSION_NUMBER 3041000
457 #define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -31543,10 +31543,17 @@
31543 sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse);
31544 }
31545 if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
31546 sqlite3_str_appendf(&x, " ON");
31547 }
31548 if( pItem->fg.isTabFunc ) sqlite3_str_appendf(&x, " isTabFunc");
31549 if( pItem->fg.isCorrelated ) sqlite3_str_appendf(&x, " isCorrelated");
31550 if( pItem->fg.isMaterialized ) sqlite3_str_appendf(&x, " isMaterialized");
31551 if( pItem->fg.viaCoroutine ) sqlite3_str_appendf(&x, " viaCoroutine");
31552 if( pItem->fg.notCte ) sqlite3_str_appendf(&x, " notCte");
31553 if( pItem->fg.isNestedFrom ) sqlite3_str_appendf(&x, " isNestedFrom");
31554
31555 sqlite3StrAccumFinish(&x);
31556 sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1);
31557 n = 0;
31558 if( pItem->pSelect ) n++;
31559 if( pItem->fg.isTabFunc ) n++;
@@ -38548,11 +38555,11 @@
38555 ** still short of its goal. The following chart shows the allowed
38556 ** transitions and the inserted intermediate states:
38557 **
38558 ** UNLOCKED -> SHARED
38559 ** SHARED -> RESERVED
38560 ** SHARED -> EXCLUSIVE
38561 ** RESERVED -> (PENDING) -> EXCLUSIVE
38562 ** PENDING -> EXCLUSIVE
38563 **
38564 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
38565 ** routine to lower a locking level.
@@ -38581,23 +38588,24 @@
38588 **
38589 ** A process may only obtain a RESERVED lock after it has a SHARED lock.
38590 ** A RESERVED lock is implemented by grabbing a write-lock on the
38591 ** 'reserved byte'.
38592 **
38593 ** An EXCLUSIVE lock may only be requested after either a SHARED or
38594 ** RESERVED lock is held. An EXCLUSIVE lock is implemented by obtaining
38595 ** a write-lock on the entire 'shared byte range'. Since all other locks
38596 ** require a read-lock on one of the bytes within this range, this ensures
38597 ** that no other locks are held on the database.
 
 
38598 **
38599 ** If a process that holds a RESERVED lock requests an EXCLUSIVE, then
38600 ** a PENDING lock is obtained first. A PENDING lock is implemented by
38601 ** obtaining a write-lock on the 'pending byte'. This ensures that no new
38602 ** SHARED locks can be obtained, but existing SHARED locks are allowed to
38603 ** persist. If the call to this function fails to obtain the EXCLUSIVE
38604 ** lock in this case, it holds the PENDING lock intead. The client may
38605 ** then re-attempt the EXCLUSIVE lock later on, after existing SHARED
38606 ** locks have cleared.
38607 */
38608 int rc = SQLITE_OK;
38609 unixFile *pFile = (unixFile*)id;
38610 unixInodeInfo *pInode;
38611 struct flock lock;
@@ -38664,11 +38672,11 @@
38672 ** be released.
38673 */
38674 lock.l_len = 1L;
38675 lock.l_whence = SEEK_SET;
38676 if( eFileLock==SHARED_LOCK
38677 || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock==RESERVED_LOCK)
38678 ){
38679 lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);
38680 lock.l_start = PENDING_BYTE;
38681 if( unixFileLock(pFile, &lock) ){
38682 tErrno = errno;
@@ -38675,10 +38683,13 @@
38683 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
38684 if( rc!=SQLITE_BUSY ){
38685 storeLastErrno(pFile, tErrno);
38686 }
38687 goto end_lock;
38688 }else if( eFileLock==EXCLUSIVE_LOCK ){
38689 pFile->eFileLock = PENDING_LOCK;
38690 pInode->eFileLock = PENDING_LOCK;
38691 }
38692 }
38693
38694
38695 /* If control gets to this point, then actually go ahead and make
@@ -38762,17 +38773,13 @@
38773 pFile->dbUpdate = 0;
38774 pFile->inNormalWrite = 1;
38775 }
38776 #endif
38777
 
38778 if( rc==SQLITE_OK ){
38779 pFile->eFileLock = eFileLock;
38780 pInode->eFileLock = eFileLock;
 
 
 
38781 }
38782
38783 end_lock:
38784 sqlite3_mutex_leave(pInode->pLockMutex);
38785 OSTRACE(("LOCK %d %s %s (unix)\n", pFile->h, azFileLock(eFileLock),
@@ -60118,11 +60125,10 @@
60125 int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
60126 int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
60127 u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
60128 const char *zUri = 0; /* URI args to copy */
60129 int nUriByte = 1; /* Number of bytes of URI args at *zUri */
 
60130
60131 /* Figure out how much space is required for each journal file-handle
60132 ** (there are two of them, the main journal and the sub-journal). */
60133 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
60134
@@ -60166,11 +60172,10 @@
60172 nPathname = sqlite3Strlen30(zPathname);
60173 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
60174 while( *z ){
60175 z += strlen(z)+1;
60176 z += strlen(z)+1;
 
60177 }
60178 nUriByte = (int)(&z[1] - zUri);
60179 assert( nUriByte>=1 );
60180 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
60181 /* This branch is taken when the journal path required by
@@ -78786,11 +78791,13 @@
78791 ** entry represents the span of a cell or freeblock on a btree page.
78792 ** The upper 16 bits are the index of the first byte of a range and the
78793 ** lower 16 bits are the index of the last byte of that range.
78794 */
78795 static void btreeHeapInsert(u32 *aHeap, u32 x){
78796 u32 j, i;
78797 assert( aHeap!=0 );
78798 i = ++aHeap[0];
78799 aHeap[i] = x;
78800 while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){
78801 x = aHeap[j];
78802 aHeap[j] = aHeap[i];
78803 aHeap[i] = x;
@@ -81830,12 +81837,10 @@
81837 if( pVal==0 ){
81838 rc = SQLITE_NOMEM_BKPT;
81839 goto value_from_function_out;
81840 }
81841
 
 
81842 memset(&ctx, 0, sizeof(ctx));
81843 ctx.pOut = pVal;
81844 ctx.pFunc = pFunc;
81845 ctx.enc = ENC(db);
81846 pFunc->xSFunc(&ctx, nVal, apVal);
@@ -81843,15 +81848,18 @@
81848 rc = ctx.isError;
81849 sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
81850 }else{
81851 sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
81852 assert( rc==SQLITE_OK );
81853 assert( enc==pVal->enc || db->mallocFailed );
81854 #if 0 /* Not reachable except after a prior failure */
81855 rc = sqlite3VdbeChangeEncoding(pVal, enc);
81856 if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
81857 rc = SQLITE_TOOBIG;
81858 pCtx->pParse->nErr++;
81859 }
81860 #endif
81861 }
81862 pCtx->pParse->rc = rc;
81863
81864 value_from_function_out:
81865 if( rc!=SQLITE_OK ){
@@ -103700,10 +103708,36 @@
103708 assert( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 );
103709 ExprSetProperty(pNew, EP_CanBeNull);
103710 *ppList = sqlite3ExprListAppend(pParse, *ppList, pNew);
103711 }
103712 }
103713
103714 /*
103715 ** Return TRUE (non-zero) if zTab is a valid name for the schema table pTab.
103716 */
103717 static SQLITE_NOINLINE int isValidSchemaTableName(
103718 const char *zTab, /* Name as it appears in the SQL */
103719 Table *pTab, /* The schema table we are trying to match */
103720 Schema *pSchema /* non-NULL if a database qualifier is present */
103721 ){
103722 const char *zLegacy;
103723 assert( pTab!=0 );
103724 assert( pTab->tnum==1 );
103725 if( sqlite3StrNICmp(zTab, "sqlite_", 7)!=0 ) return 0;
103726 zLegacy = pTab->zName;
103727 if( strcmp(zLegacy+7, &LEGACY_TEMP_SCHEMA_TABLE[7])==0 ){
103728 if( sqlite3StrICmp(zTab+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 ){
103729 return 1;
103730 }
103731 if( pSchema==0 ) return 0;
103732 if( sqlite3StrICmp(zTab+7, &LEGACY_SCHEMA_TABLE[7])==0 ) return 1;
103733 if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1;
103734 }else{
103735 if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1;
103736 }
103737 return 0;
103738 }
103739
103740 /*
103741 ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
103742 ** that name in the set of source tables in pSrcList and make the pExpr
103743 ** expression node refer back to that source column. The following changes
@@ -103854,19 +103888,21 @@
103888 }
103889 if( hit || zTab==0 ) continue;
103890 }
103891 assert( zDb==0 || zTab!=0 );
103892 if( zTab ){
 
103893 if( zDb ){
103894 if( pTab->pSchema!=pSchema ) continue;
103895 if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue;
103896 }
103897 if( pItem->zAlias!=0 ){
103898 if( sqlite3StrICmp(zTab, pItem->zAlias)!=0 ){
103899 continue;
103900 }
103901 }else if( sqlite3StrICmp(zTab, pTab->zName)!=0 ){
103902 if( pTab->tnum!=1 ) continue;
103903 if( !isValidSchemaTableName(zTab, pTab, pSchema) ) continue;
103904 }
103905 assert( ExprUseYTab(pExpr) );
103906 if( IN_RENAME_OBJECT && pItem->zAlias ){
103907 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
103908 }
@@ -116150,20 +116186,22 @@
116186 /*
116187 ** If the Index.aSample variable is not NULL, delete the aSample[] array
116188 ** and its contents.
116189 */
116190 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
116191 assert( db!=0 );
116192 assert( pIdx!=0 );
116193 #ifdef SQLITE_ENABLE_STAT4
116194 if( pIdx->aSample ){
116195 int j;
116196 for(j=0; j<pIdx->nSample; j++){
116197 IndexSample *p = &pIdx->aSample[j];
116198 sqlite3DbFree(db, p->p);
116199 }
116200 sqlite3DbFree(db, pIdx->aSample);
116201 }
116202 if( db->pnBytesFreed==0 ){
116203 pIdx->nSample = 0;
116204 pIdx->aSample = 0;
116205 }
116206 #else
116207 UNUSED_PARAMETER(db);
@@ -135976,16 +136014,25 @@
136014 /* Fetch the right-most column from the table. This will cause
136015 ** the entire record header to be parsed and sanity checked. It
136016 ** will also prepopulate the cursor column cache that is used
136017 ** by the OP_IsType code, so it is a required step.
136018 */
136019 assert( !IsVirtual(pTab) );
136020 if( HasRowid(pTab) ){
136021 mxCol = -1;
136022 for(j=0; j<pTab->nCol; j++){
136023 if( (pTab->aCol[j].colFlags & COLFLAG_VIRTUAL)==0 ) mxCol++;
136024 }
136025 if( mxCol==pTab->iPKey ) mxCol--;
136026 }else{
136027 /* COLFLAG_VIRTUAL columns are not included in the WITHOUT ROWID
136028 ** PK index column-count, so there is no need to account for them
136029 ** in this case. */
136030 mxCol = sqlite3PrimaryKeyIndex(pTab)->nColumn-1;
136031 }
136032 if( mxCol>=0 ){
136033 sqlite3VdbeAddOp3(v, OP_Column, iDataCur, mxCol, 3);
136034 sqlite3VdbeTypeofColumn(v, 3);
136035 }
136036
136037 if( !isQuick ){
136038 if( pPk ){
@@ -143758,13 +143805,10 @@
143805 return 2;
143806 }
143807 pFrom->fg.isCte = 1;
143808 pFrom->u2.pCteUse = pCteUse;
143809 pCteUse->nUse++;
 
 
 
143810
143811 /* Check if this is a recursive CTE. */
143812 pRecTerm = pSel = pFrom->pSelect;
143813 bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
143814 while( bMayRecursive && pRecTerm->op==pSel->op ){
@@ -145043,12 +145087,14 @@
145087 ** (i) The subquery is the left-most subquery in the FROM clause
145088 ** (ii) There is nothing that would prevent the subquery from
145089 ** being used as the outer loop if the sqlite3WhereBegin()
145090 ** routine nominates it to that position.
145091 ** (iii) The query is not a UPDATE ... FROM
145092 ** (2) The subquery is not a CTE that should be materialized because
145093 ** (a) the AS MATERIALIZED keyword is used, or
145094 ** (b) the CTE is used multiple times and does not have the
145095 ** NOT MATERIALIZED keyword
145096 ** (3) The subquery is not part of a left operand for a RIGHT JOIN
145097 ** (4) The SQLITE_Coroutine optimization disable flag is not set
145098 ** (5) The subquery is not self-joined
145099 */
145100 static int fromClauseTermCanBeCoroutine(
@@ -145056,13 +145102,17 @@
145102 SrcList *pTabList, /* FROM clause */
145103 int i, /* Which term of the FROM clause holds the subquery */
145104 int selFlags /* Flags on the SELECT statement */
145105 ){
145106 SrcItem *pItem = &pTabList->a[i];
145107 if( pItem->fg.isCte ){
145108 const CteUse *pCteUse = pItem->u2.pCteUse;
145109 if( pCteUse->eM10d==M10d_Yes ) return 0; /* (2a) */
145110 if( pCteUse->nUse>=2 && pCteUse->eM10d!=M10d_No ) return 0; /* (2b) */
145111 }
145112 if( pTabList->a[0].fg.jointype & JT_LTORJ ) return 0; /* (3) */
145113 if( OptimizationDisabled(pParse->db, SQLITE_Coroutines) ) return 0; /* (4) */
145114 if( isSelfJoinView(pTabList, pItem, i+1, pTabList->nSrc)!=0 ){
145115 return 0; /* (5) */
145116 }
145117 if( i==0 ){
145118 if( pTabList->nSrc==1 ) return 1; /* (1a) */
@@ -160345,11 +160395,12 @@
160395 ** indexes on subqueries and views. */
160396 pNew->rSetup = rLogSize + rSize;
160397 if( !IsView(pTab) && (pTab->tabFlags & TF_Ephemeral)==0 ){
160398 pNew->rSetup += 28;
160399 }else{
160400 pNew->rSetup -= 25; /* Greatly reduced setup cost for auto indexes
160401 ** on ephemeral materializations of views */
160402 }
160403 ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
160404 if( pNew->rSetup<0 ) pNew->rSetup = 0;
160405 /* TUNING: Each index lookup yields 20 rows in the table. This
160406 ** is more than the usual guess of 10 rows, since we have no way
@@ -164586,10 +164637,11 @@
164637 ** of sqlite3DbMallocRawNN() called from
164638 ** sqlite3SrcListAppend() */
164639 if( p->pSrc ){
164640 Table *pTab2;
164641 p->pSrc->a[0].pSelect = pSub;
164642 p->pSrc->a[0].fg.isCorrelated = 1;
164643 sqlite3SrcListAssignCursors(pParse, p->pSrc);
164644 pSub->selFlags |= SF_Expanded|SF_OrderByReqd;
164645 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
164646 pSub->selFlags |= (selFlags & SF_Aggregate);
164647 if( pTab2==0 ){
@@ -240036,11 +240088,11 @@
240088 int nArg, /* Number of args */
240089 sqlite3_value **apUnused /* Function arguments */
240090 ){
240091 assert( nArg==0 );
240092 UNUSED_PARAM2(nArg, apUnused);
240093 sqlite3_result_text(pCtx, "fts5: 2023-02-03 12:03:56 75cdaafc77b8a1efc84e71e90470994227f376e7d7de34c813e75dcadbb9f268", -1, SQLITE_TRANSIENT);
240094 }
240095
240096 /*
240097 ** Return true if zName is the extension on one of the shadow tables used
240098 ** by this module.
240099
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.41.0"
150150
#define SQLITE_VERSION_NUMBER 3041000
151
-#define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
151
+#define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.41.0"
150 #define SQLITE_VERSION_NUMBER 3041000
151 #define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.41.0"
150 #define SQLITE_VERSION_NUMBER 3041000
151 #define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button