Fossil SCM

Update the built-in SQLite to the latest 3.39.0 beta, for SQLite testing.

drh 2022-06-23 12:10 trunk
Commit d7a2bda91238bdcc5f2dcec9dd99e89a505375f4b121fab7374a5dc793d494b5
2 files changed +70 -31 +1 -1
+70 -31
--- 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.39.0"
456456
#define SQLITE_VERSION_NUMBER 3039000
457
-#define SQLITE_SOURCE_ID "2022-06-15 16:26:37 56c60a35ea457f06db58ec3f694a1ae16fd03e6625da1d7879d63d72bbcb1c62"
457
+#define SQLITE_SOURCE_ID "2022-06-22 18:51:47 83ff1a28e3e7a99fa90d5079897d76529c4256eed859bf7cb98b860fbedfalt1"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -31073,11 +31073,11 @@
3107331073
*/
3107431074
SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
3107531075
va_list ap;
3107631076
int i;
3107731077
StrAccum acc;
31078
- char zBuf[500];
31078
+ char zBuf[1000];
3107931079
sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
3108031080
if( p ){
3108131081
for(i=0; i<p->iLevel && i<(int)sizeof(p->bLine)-1; i++){
3108231082
sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
3108331083
}
@@ -31204,11 +31204,11 @@
3120431204
if( pSrc==0 ) return;
3120531205
for(i=0; i<pSrc->nSrc; i++){
3120631206
const SrcItem *pItem = &pSrc->a[i];
3120731207
StrAccum x;
3120831208
int n = 0;
31209
- char zLine[100];
31209
+ char zLine[1000];
3121031210
sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
3121131211
x.printfFlags |= SQLITE_PRINTF_INTERNAL;
3121231212
sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
3121331213
if( pItem->pTab ){
3121431214
sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
@@ -72635,10 +72635,13 @@
7263572635
if( pCur->iPage>0
7263672636
&& indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0
7263772637
&& pIdxKey->errCode==SQLITE_OK
7263872638
){
7263972639
pCur->curFlags &= ~BTCF_ValidOvfl;
72640
+ if( !pCur->pPage->isInit ){
72641
+ return SQLITE_CORRUPT_BKPT;
72642
+ }
7264072643
goto bypass_moveto_root; /* Start search on the current page */
7264172644
}
7264272645
pIdxKey->errCode = SQLITE_OK;
7264372646
}
7264472647
@@ -81232,11 +81235,11 @@
8123281235
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
8123381236
sqlite3VdbeAddOp2(p, OP_Expire, 1, 1);
8123481237
}
8123581238
8123681239
/*
81237
-** Mark the VDBE as one that can only be run multiple times.
81240
+** Mark the VDBE as one that can be run multiple times.
8123881241
*/
8123981242
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
8124081243
int i;
8124181244
for(i=1; ALWAYS(i<p->nOp); i++){
8124281245
if( ALWAYS(p->aOp[i].opcode==OP_Expire) ){
@@ -86746,13 +86749,13 @@
8674686749
break;
8674786750
}
8674886751
sqlite3_reset(pStmt);
8674986752
if( savedPc>=0 ){
8675086753
/* Setting minWriteFileFormat to 254 is a signal to the OP_Init and
86751
- ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because one
86752
- ** should output has already occurred due to SQLITE_SCHEMA.
86753
- ** tag-20220401a */
86754
+ ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because it has
86755
+ ** already been done once on a prior invocation that failed due to
86756
+ ** SQLITE_SCHEMA. tag-20220401a */
8675486757
v->minWriteFileFormat = 254;
8675586758
}
8675686759
assert( v->expired==0 );
8675786760
}
8675886761
sqlite3_mutex_leave(db->mutex);
@@ -89294,11 +89297,11 @@
8929489297
**
8929589298
** P2 is not used by the byte-code engine. However, if P2 is positive
8929689299
** and also less than the current address, then the "EXPLAIN" output
8929789300
** formatter in the CLI will indent all opcodes from the P2 opcode up
8929889301
** to be not including the current Return. P2 should be the first opcode
89299
-** in the subroutine from which this opcode is returnning. Thus the P2
89302
+** in the subroutine from which this opcode is returning. Thus the P2
8930089303
** value is a byte-code indentation hint. See tag-20220407a in
8930189304
** wherecode.c and shell.c.
8930289305
*/
8930389306
case OP_Return: { /* in1 */
8930489307
pIn1 = &aMem[pOp->p1];
@@ -89956,11 +89959,11 @@
8995689959
}
8995789960
nByte = pIn1->n + pIn2->n;
8995889961
if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
8995989962
goto too_big;
8996089963
}
89961
- if( sqlite3VdbeMemGrow(pOut, (int)nByte+3, pOut==pIn2) ){
89964
+ if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
8996289965
goto no_mem;
8996389966
}
8996489967
MemSetTypeFlag(pOut, MEM_Str);
8996589968
if( pOut!=pIn2 ){
8996689969
memcpy(pOut->z, pIn2->z, pIn2->n);
@@ -89968,13 +89971,13 @@
8996889971
pIn2->flags = flags2;
8996989972
}
8997089973
memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);
8997189974
assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
8997289975
pIn1->flags = flags1;
89976
+ if( encoding>SQLITE_UTF8 ) nByte &= ~1;
8997389977
pOut->z[nByte]=0;
8997489978
pOut->z[nByte+1] = 0;
89975
- pOut->z[nByte+2] = 0;
8997689979
pOut->flags |= MEM_Term;
8997789980
pOut->n = (int)nByte;
8997889981
pOut->enc = encoding;
8997989982
UPDATE_MAX_BLOBSIZE(pOut);
8998089983
break;
@@ -103265,12 +103268,12 @@
103265103268
*/
103266103269
assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 );
103267103270
sNC.uNC.pEList = p->pEList;
103268103271
sNC.ncFlags |= NC_UEList;
103269103272
if( p->pHaving ){
103270
- if( !pGroupBy ){
103271
- sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
103273
+ if( (p->selFlags & SF_Aggregate)==0 ){
103274
+ sqlite3ErrorMsg(pParse, "HAVING clause on a non-aggregate query");
103272103275
return WRC_Abort;
103273103276
}
103274103277
if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
103275103278
}
103276103279
if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
@@ -135947,28 +135950,29 @@
135947135950
sqlite3SetJoinExpr(p->pLeft, iTable, joinFlag);
135948135951
p = p->pRight;
135949135952
}
135950135953
}
135951135954
135952
-/* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
135953
-** term that is marked with EP_OuterON and w.iJoin==iTable into
135954
-** an ordinary term that omits the EP_OuterON mark.
135955
+/* Undo the work of sqlite3SetJoinExpr(). This is used when a LEFT JOIN
135956
+** is simplified into an ordinary JOIN, and when an ON expression is
135957
+** "pushed down" into the WHERE clause of a subquery.
135955135958
**
135956
-** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
135959
+** Convert every term that is marked with EP_OuterON and w.iJoin==iTable into
135960
+** an ordinary term that omits the EP_OuterON mark. Or if iTable<0, then
135961
+** just clear every EP_OuterON and EP_InnerON mark from the expression tree.
135957135962
**
135958135963
** If nullable is true, that means that Expr p might evaluate to NULL even
135959135964
** if it is a reference to a NOT NULL column. This can happen, for example,
135960135965
** if the table that p references is on the left side of a RIGHT JOIN.
135961135966
** If nullable is true, then take care to not remove the EP_CanBeNull bit.
135962135967
** See forum thread https://sqlite.org/forum/forumpost/b40696f50145d21c
135963135968
*/
135964135969
static void unsetJoinExpr(Expr *p, int iTable, int nullable){
135965135970
while( p ){
135966
- if( ExprHasProperty(p, EP_OuterON)
135967
- && (iTable<0 || p->w.iJoin==iTable) ){
135968
- ExprClearProperty(p, EP_OuterON);
135969
- ExprSetProperty(p, EP_InnerON);
135971
+ if( iTable<0 || (ExprHasProperty(p, EP_OuterON) && p->w.iJoin==iTable) ){
135972
+ ExprClearProperty(p, EP_OuterON|EP_InnerON);
135973
+ if( iTable>=0 ) ExprSetProperty(p, EP_InnerON);
135970135974
}
135971135975
if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){
135972135976
ExprClearProperty(p, EP_CanBeNull);
135973135977
}
135974135978
if( p->op==TK_FUNCTION ){
@@ -140189,10 +140193,12 @@
140189140193
Parse *pParse; /* Parsing context */
140190140194
u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
140191140195
int nConst; /* Number for COLUMN=CONSTANT terms */
140192140196
int nChng; /* Number of times a constant is propagated */
140193140197
int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
140198
+ u32 mExcludeOn; /* Which ON expressions to exclude from considertion.
140199
+ ** Either EP_OuterON or EP_InnerON|EP_OuterON */
140194140200
Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
140195140201
};
140196140202
140197140203
/*
140198140204
** Add a new entry to the pConst object. Except, do not add duplicate
@@ -140251,11 +140257,11 @@
140251140257
** found, add it to the pConst structure.
140252140258
*/
140253140259
static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
140254140260
Expr *pRight, *pLeft;
140255140261
if( NEVER(pExpr==0) ) return;
140256
- if( ExprHasProperty(pExpr, EP_OuterON|EP_InnerON) ){
140262
+ if( ExprHasProperty(pExpr, pConst->mExcludeOn) ){
140257140263
testcase( ExprHasProperty(pExpr, EP_OuterON) );
140258140264
testcase( ExprHasProperty(pExpr, EP_InnerON) );
140259140265
return;
140260140266
}
140261140267
if( pExpr->op==TK_AND ){
@@ -140291,13 +140297,14 @@
140291140297
int bIgnoreAffBlob
140292140298
){
140293140299
int i;
140294140300
if( pConst->pOomFault[0] ) return WRC_Prune;
140295140301
if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
140296
- if( ExprHasProperty(pExpr, EP_FixedCol|EP_OuterON) ){
140302
+ if( ExprHasProperty(pExpr, EP_FixedCol|pConst->mExcludeOn) ){
140297140303
testcase( ExprHasProperty(pExpr, EP_FixedCol) );
140298140304
testcase( ExprHasProperty(pExpr, EP_OuterON) );
140305
+ testcase( ExprHasProperty(pExpr, EP_InnerON) );
140299140306
return WRC_Continue;
140300140307
}
140301140308
for(i=0; i<pConst->nConst; i++){
140302140309
Expr *pColumn = pConst->apExpr[i*2];
140303140310
if( pColumn==pExpr ) continue;
@@ -140417,10 +140424,21 @@
140417140424
do{
140418140425
x.nConst = 0;
140419140426
x.nChng = 0;
140420140427
x.apExpr = 0;
140421140428
x.bHasAffBlob = 0;
140429
+ if( ALWAYS(p->pSrc!=0)
140430
+ && p->pSrc->nSrc>0
140431
+ && (p->pSrc->a[0].fg.jointype & JT_LTORJ)!=0
140432
+ ){
140433
+ /* Do not propagate constants on any ON clause if there is a
140434
+ ** RIGHT JOIN anywhere in the query */
140435
+ x.mExcludeOn = EP_InnerON | EP_OuterON;
140436
+ }else{
140437
+ /* Do not propagate constants through the ON clause of a LEFT JOIN */
140438
+ x.mExcludeOn = EP_OuterON;
140439
+ }
140422140440
findConstInWhere(&x, p->pWhere);
140423140441
if( x.nConst ){
140424140442
memset(&w, 0, sizeof(w));
140425140443
w.pParse = pParse;
140426140444
w.xExprCallback = propagateConstantExprRewrite;
@@ -142280,10 +142298,11 @@
142280142298
&& OptimizationEnabled(db, SQLITE_SimplifyJoin)
142281142299
){
142282142300
SELECTTRACE(0x100,pParse,p,
142283142301
("LEFT-JOIN simplifies to JOIN on term %d\n",i));
142284142302
pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER);
142303
+ assert( pItem->iCursor>=0 );
142285142304
unsetJoinExpr(p->pWhere, pItem->iCursor,
142286142305
pTabList->a[0].fg.jointype & JT_LTORJ);
142287142306
}
142288142307
142289142308
/* No futher action if this term of the FROM clause is no a subquery */
@@ -142501,11 +142520,11 @@
142501142520
zSavedAuthContext = pParse->zAuthContext;
142502142521
pParse->zAuthContext = pItem->zName;
142503142522
142504142523
/* Generate code to implement the subquery
142505142524
**
142506
- ** The subquery is implemented as a co-routine all if the following are
142525
+ ** The subquery is implemented as a co-routine if all of the following are
142507142526
** true:
142508142527
**
142509142528
** (1) the subquery is guaranteed to be the outer loop (so that
142510142529
** it does not need to be computed more than once), and
142511142530
** (2) the subquery is not a CTE that should be materialized
@@ -153168,13 +153187,19 @@
153168153187
sqlite3ErrorMsg(pParse, "ON clause references tables to its right");
153169153188
return;
153170153189
}
153171153190
}else if( (prereqAll>>1)>=x ){
153172153191
/* The ON clause of an INNER JOIN references a table to its right.
153173
- ** Most other SQL database engines raise an error. But all versions
153174
- ** of SQLite going back to 3.0.0 have just put the ON clause constraint
153175
- ** into the WHERE clause and carried on. */
153192
+ ** Most other SQL database engines raise an error. But SQLite versions
153193
+ ** 3.0 through 3.38 just put the ON clause constraint into the WHERE
153194
+ ** clause and carried on. Beginning with 3.39, raise an error only
153195
+ ** if there is a RIGHT or FULL JOIN in the query. This makes SQLite
153196
+ ** more like other systems, and also preserves legacy. */
153197
+ if( ALWAYS(pSrc->nSrc>0) && (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){
153198
+ sqlite3ErrorMsg(pParse, "ON clause references tables to its right");
153199
+ return;
153200
+ }
153176153201
ExprClearProperty(pExpr, EP_InnerON);
153177153202
}
153178153203
}
153179153204
pTerm->prereqAll = prereqAll;
153180153205
pTerm->leftCursor = -1;
@@ -158075,15 +158100,25 @@
158075158100
for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
158076158101
Bitmask mUnusable = 0;
158077158102
pNew->iTab = iTab;
158078158103
pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;
158079158104
pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
158080
- if( bFirstPastRJ || (pItem->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
158105
+ if( bFirstPastRJ
158106
+ || (pItem->fg.jointype & (JT_OUTER|JT_CROSS|JT_LTORJ))!=0
158107
+ ){
158081158108
/* Add prerequisites to prevent reordering of FROM clause terms
158082158109
** across CROSS joins and outer joins. The bFirstPastRJ boolean
158083158110
** prevents the right operand of a RIGHT JOIN from being swapped with
158084
- ** other elements even further to the right. */
158111
+ ** other elements even further to the right.
158112
+ **
158113
+ ** The JT_LTORJ term prevents any FROM-clause term reordering for terms
158114
+ ** to the left of a RIGHT JOIN. This is conservative. Relaxing this
158115
+ ** constraint somewhat to prevent terms from crossing from the right
158116
+ ** side of a LEFT JOIN over to the left side when they are on the
158117
+ ** left side of a RIGHT JOIN would be sufficient for all known failure
158118
+ ** cases. FIX ME: Implement this optimization.
158119
+ */
158085158120
mPrereq |= mPrior;
158086158121
bFirstPastRJ = (pItem->fg.jointype & JT_RIGHT)!=0;
158087158122
}
158088158123
#ifndef SQLITE_OMIT_VIRTUALTABLE
158089158124
if( IsVirtual(pItem->pTab) ){
@@ -158968,11 +159003,15 @@
158968159003
if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
158969159004
assert( pWInfo->pTabList->nSrc>=1 );
158970159005
pItem = pWInfo->pTabList->a;
158971159006
pTab = pItem->pTab;
158972159007
if( IsVirtual(pTab) ) return 0;
158973
- if( pItem->fg.isIndexedBy ) return 0;
159008
+ if( pItem->fg.isIndexedBy || pItem->fg.notIndexed ){
159009
+ testcase( pItem->fg.isIndexedBy );
159010
+ testcase( pItem->fg.notIndexed );
159011
+ return 0;
159012
+ }
158974159013
iCur = pItem->iCursor;
158975159014
pWC = &pWInfo->sWC;
158976159015
pLoop = pBuilder->pNew;
158977159016
pLoop->wsFlags = 0;
158978159017
pLoop->nSkip = 0;
@@ -159141,11 +159180,11 @@
159141159180
WhereTerm *pTerm, *pEnd;
159142159181
SrcItem *pItem;
159143159182
WhereLoop *pLoop;
159144159183
pLoop = pWInfo->a[i].pWLoop;
159145159184
pItem = &pWInfo->pTabList->a[pLoop->iTab];
159146
- if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
159185
+ if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ) continue;
159147159186
if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
159148159187
&& (pLoop->wsFlags & WHERE_ONEROW)==0
159149159188
){
159150159189
continue;
159151159190
}
@@ -236575,11 +236614,11 @@
236575236614
int nArg, /* Number of args */
236576236615
sqlite3_value **apUnused /* Function arguments */
236577236616
){
236578236617
assert( nArg==0 );
236579236618
UNUSED_PARAM2(nArg, apUnused);
236580
- sqlite3_result_text(pCtx, "fts5: 2022-06-15 16:26:37 56c60a35ea457f06db58ec3f694a1ae16fd03e6625da1d7879d63d72bbcb1c62", -1, SQLITE_TRANSIENT);
236619
+ sqlite3_result_text(pCtx, "fts5: 2022-06-22 18:51:47 83ff1a28e3e7a99fa90d5079897d76529c4256eed859bf7cb98b860fbedfdc5b", -1, SQLITE_TRANSIENT);
236581236620
}
236582236621
236583236622
/*
236584236623
** Return true if zName is the extension on one of the shadow tables used
236585236624
** by this module.
236586236625
--- 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.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-06-15 16:26:37 56c60a35ea457f06db58ec3f694a1ae16fd03e6625da1d7879d63d72bbcb1c62"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -31073,11 +31073,11 @@
31073 */
31074 SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
31075 va_list ap;
31076 int i;
31077 StrAccum acc;
31078 char zBuf[500];
31079 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
31080 if( p ){
31081 for(i=0; i<p->iLevel && i<(int)sizeof(p->bLine)-1; i++){
31082 sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
31083 }
@@ -31204,11 +31204,11 @@
31204 if( pSrc==0 ) return;
31205 for(i=0; i<pSrc->nSrc; i++){
31206 const SrcItem *pItem = &pSrc->a[i];
31207 StrAccum x;
31208 int n = 0;
31209 char zLine[100];
31210 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
31211 x.printfFlags |= SQLITE_PRINTF_INTERNAL;
31212 sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
31213 if( pItem->pTab ){
31214 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
@@ -72635,10 +72635,13 @@
72635 if( pCur->iPage>0
72636 && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0
72637 && pIdxKey->errCode==SQLITE_OK
72638 ){
72639 pCur->curFlags &= ~BTCF_ValidOvfl;
 
 
 
72640 goto bypass_moveto_root; /* Start search on the current page */
72641 }
72642 pIdxKey->errCode = SQLITE_OK;
72643 }
72644
@@ -81232,11 +81235,11 @@
81232 SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
81233 sqlite3VdbeAddOp2(p, OP_Expire, 1, 1);
81234 }
81235
81236 /*
81237 ** Mark the VDBE as one that can only be run multiple times.
81238 */
81239 SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
81240 int i;
81241 for(i=1; ALWAYS(i<p->nOp); i++){
81242 if( ALWAYS(p->aOp[i].opcode==OP_Expire) ){
@@ -86746,13 +86749,13 @@
86746 break;
86747 }
86748 sqlite3_reset(pStmt);
86749 if( savedPc>=0 ){
86750 /* Setting minWriteFileFormat to 254 is a signal to the OP_Init and
86751 ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because one
86752 ** should output has already occurred due to SQLITE_SCHEMA.
86753 ** tag-20220401a */
86754 v->minWriteFileFormat = 254;
86755 }
86756 assert( v->expired==0 );
86757 }
86758 sqlite3_mutex_leave(db->mutex);
@@ -89294,11 +89297,11 @@
89294 **
89295 ** P2 is not used by the byte-code engine. However, if P2 is positive
89296 ** and also less than the current address, then the "EXPLAIN" output
89297 ** formatter in the CLI will indent all opcodes from the P2 opcode up
89298 ** to be not including the current Return. P2 should be the first opcode
89299 ** in the subroutine from which this opcode is returnning. Thus the P2
89300 ** value is a byte-code indentation hint. See tag-20220407a in
89301 ** wherecode.c and shell.c.
89302 */
89303 case OP_Return: { /* in1 */
89304 pIn1 = &aMem[pOp->p1];
@@ -89956,11 +89959,11 @@
89956 }
89957 nByte = pIn1->n + pIn2->n;
89958 if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
89959 goto too_big;
89960 }
89961 if( sqlite3VdbeMemGrow(pOut, (int)nByte+3, pOut==pIn2) ){
89962 goto no_mem;
89963 }
89964 MemSetTypeFlag(pOut, MEM_Str);
89965 if( pOut!=pIn2 ){
89966 memcpy(pOut->z, pIn2->z, pIn2->n);
@@ -89968,13 +89971,13 @@
89968 pIn2->flags = flags2;
89969 }
89970 memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);
89971 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
89972 pIn1->flags = flags1;
 
89973 pOut->z[nByte]=0;
89974 pOut->z[nByte+1] = 0;
89975 pOut->z[nByte+2] = 0;
89976 pOut->flags |= MEM_Term;
89977 pOut->n = (int)nByte;
89978 pOut->enc = encoding;
89979 UPDATE_MAX_BLOBSIZE(pOut);
89980 break;
@@ -103265,12 +103268,12 @@
103265 */
103266 assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 );
103267 sNC.uNC.pEList = p->pEList;
103268 sNC.ncFlags |= NC_UEList;
103269 if( p->pHaving ){
103270 if( !pGroupBy ){
103271 sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
103272 return WRC_Abort;
103273 }
103274 if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
103275 }
103276 if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
@@ -135947,28 +135950,29 @@
135947 sqlite3SetJoinExpr(p->pLeft, iTable, joinFlag);
135948 p = p->pRight;
135949 }
135950 }
135951
135952 /* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
135953 ** term that is marked with EP_OuterON and w.iJoin==iTable into
135954 ** an ordinary term that omits the EP_OuterON mark.
135955 **
135956 ** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
 
 
135957 **
135958 ** If nullable is true, that means that Expr p might evaluate to NULL even
135959 ** if it is a reference to a NOT NULL column. This can happen, for example,
135960 ** if the table that p references is on the left side of a RIGHT JOIN.
135961 ** If nullable is true, then take care to not remove the EP_CanBeNull bit.
135962 ** See forum thread https://sqlite.org/forum/forumpost/b40696f50145d21c
135963 */
135964 static void unsetJoinExpr(Expr *p, int iTable, int nullable){
135965 while( p ){
135966 if( ExprHasProperty(p, EP_OuterON)
135967 && (iTable<0 || p->w.iJoin==iTable) ){
135968 ExprClearProperty(p, EP_OuterON);
135969 ExprSetProperty(p, EP_InnerON);
135970 }
135971 if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){
135972 ExprClearProperty(p, EP_CanBeNull);
135973 }
135974 if( p->op==TK_FUNCTION ){
@@ -140189,10 +140193,12 @@
140189 Parse *pParse; /* Parsing context */
140190 u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
140191 int nConst; /* Number for COLUMN=CONSTANT terms */
140192 int nChng; /* Number of times a constant is propagated */
140193 int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
 
 
140194 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
140195 };
140196
140197 /*
140198 ** Add a new entry to the pConst object. Except, do not add duplicate
@@ -140251,11 +140257,11 @@
140251 ** found, add it to the pConst structure.
140252 */
140253 static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
140254 Expr *pRight, *pLeft;
140255 if( NEVER(pExpr==0) ) return;
140256 if( ExprHasProperty(pExpr, EP_OuterON|EP_InnerON) ){
140257 testcase( ExprHasProperty(pExpr, EP_OuterON) );
140258 testcase( ExprHasProperty(pExpr, EP_InnerON) );
140259 return;
140260 }
140261 if( pExpr->op==TK_AND ){
@@ -140291,13 +140297,14 @@
140291 int bIgnoreAffBlob
140292 ){
140293 int i;
140294 if( pConst->pOomFault[0] ) return WRC_Prune;
140295 if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
140296 if( ExprHasProperty(pExpr, EP_FixedCol|EP_OuterON) ){
140297 testcase( ExprHasProperty(pExpr, EP_FixedCol) );
140298 testcase( ExprHasProperty(pExpr, EP_OuterON) );
 
140299 return WRC_Continue;
140300 }
140301 for(i=0; i<pConst->nConst; i++){
140302 Expr *pColumn = pConst->apExpr[i*2];
140303 if( pColumn==pExpr ) continue;
@@ -140417,10 +140424,21 @@
140417 do{
140418 x.nConst = 0;
140419 x.nChng = 0;
140420 x.apExpr = 0;
140421 x.bHasAffBlob = 0;
 
 
 
 
 
 
 
 
 
 
 
140422 findConstInWhere(&x, p->pWhere);
140423 if( x.nConst ){
140424 memset(&w, 0, sizeof(w));
140425 w.pParse = pParse;
140426 w.xExprCallback = propagateConstantExprRewrite;
@@ -142280,10 +142298,11 @@
142280 && OptimizationEnabled(db, SQLITE_SimplifyJoin)
142281 ){
142282 SELECTTRACE(0x100,pParse,p,
142283 ("LEFT-JOIN simplifies to JOIN on term %d\n",i));
142284 pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER);
 
142285 unsetJoinExpr(p->pWhere, pItem->iCursor,
142286 pTabList->a[0].fg.jointype & JT_LTORJ);
142287 }
142288
142289 /* No futher action if this term of the FROM clause is no a subquery */
@@ -142501,11 +142520,11 @@
142501 zSavedAuthContext = pParse->zAuthContext;
142502 pParse->zAuthContext = pItem->zName;
142503
142504 /* Generate code to implement the subquery
142505 **
142506 ** The subquery is implemented as a co-routine all if the following are
142507 ** true:
142508 **
142509 ** (1) the subquery is guaranteed to be the outer loop (so that
142510 ** it does not need to be computed more than once), and
142511 ** (2) the subquery is not a CTE that should be materialized
@@ -153168,13 +153187,19 @@
153168 sqlite3ErrorMsg(pParse, "ON clause references tables to its right");
153169 return;
153170 }
153171 }else if( (prereqAll>>1)>=x ){
153172 /* The ON clause of an INNER JOIN references a table to its right.
153173 ** Most other SQL database engines raise an error. But all versions
153174 ** of SQLite going back to 3.0.0 have just put the ON clause constraint
153175 ** into the WHERE clause and carried on. */
 
 
 
 
 
 
153176 ExprClearProperty(pExpr, EP_InnerON);
153177 }
153178 }
153179 pTerm->prereqAll = prereqAll;
153180 pTerm->leftCursor = -1;
@@ -158075,15 +158100,25 @@
158075 for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
158076 Bitmask mUnusable = 0;
158077 pNew->iTab = iTab;
158078 pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;
158079 pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
158080 if( bFirstPastRJ || (pItem->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
 
 
158081 /* Add prerequisites to prevent reordering of FROM clause terms
158082 ** across CROSS joins and outer joins. The bFirstPastRJ boolean
158083 ** prevents the right operand of a RIGHT JOIN from being swapped with
158084 ** other elements even further to the right. */
 
 
 
 
 
 
 
 
158085 mPrereq |= mPrior;
158086 bFirstPastRJ = (pItem->fg.jointype & JT_RIGHT)!=0;
158087 }
158088 #ifndef SQLITE_OMIT_VIRTUALTABLE
158089 if( IsVirtual(pItem->pTab) ){
@@ -158968,11 +159003,15 @@
158968 if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
158969 assert( pWInfo->pTabList->nSrc>=1 );
158970 pItem = pWInfo->pTabList->a;
158971 pTab = pItem->pTab;
158972 if( IsVirtual(pTab) ) return 0;
158973 if( pItem->fg.isIndexedBy ) return 0;
 
 
 
 
158974 iCur = pItem->iCursor;
158975 pWC = &pWInfo->sWC;
158976 pLoop = pBuilder->pNew;
158977 pLoop->wsFlags = 0;
158978 pLoop->nSkip = 0;
@@ -159141,11 +159180,11 @@
159141 WhereTerm *pTerm, *pEnd;
159142 SrcItem *pItem;
159143 WhereLoop *pLoop;
159144 pLoop = pWInfo->a[i].pWLoop;
159145 pItem = &pWInfo->pTabList->a[pLoop->iTab];
159146 if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
159147 if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
159148 && (pLoop->wsFlags & WHERE_ONEROW)==0
159149 ){
159150 continue;
159151 }
@@ -236575,11 +236614,11 @@
236575 int nArg, /* Number of args */
236576 sqlite3_value **apUnused /* Function arguments */
236577 ){
236578 assert( nArg==0 );
236579 UNUSED_PARAM2(nArg, apUnused);
236580 sqlite3_result_text(pCtx, "fts5: 2022-06-15 16:26:37 56c60a35ea457f06db58ec3f694a1ae16fd03e6625da1d7879d63d72bbcb1c62", -1, SQLITE_TRANSIENT);
236581 }
236582
236583 /*
236584 ** Return true if zName is the extension on one of the shadow tables used
236585 ** by this module.
236586
--- 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.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-06-22 18:51:47 83ff1a28e3e7a99fa90d5079897d76529c4256eed859bf7cb98b860fbedfalt1"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -31073,11 +31073,11 @@
31073 */
31074 SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
31075 va_list ap;
31076 int i;
31077 StrAccum acc;
31078 char zBuf[1000];
31079 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
31080 if( p ){
31081 for(i=0; i<p->iLevel && i<(int)sizeof(p->bLine)-1; i++){
31082 sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
31083 }
@@ -31204,11 +31204,11 @@
31204 if( pSrc==0 ) return;
31205 for(i=0; i<pSrc->nSrc; i++){
31206 const SrcItem *pItem = &pSrc->a[i];
31207 StrAccum x;
31208 int n = 0;
31209 char zLine[1000];
31210 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
31211 x.printfFlags |= SQLITE_PRINTF_INTERNAL;
31212 sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
31213 if( pItem->pTab ){
31214 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
@@ -72635,10 +72635,13 @@
72635 if( pCur->iPage>0
72636 && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0
72637 && pIdxKey->errCode==SQLITE_OK
72638 ){
72639 pCur->curFlags &= ~BTCF_ValidOvfl;
72640 if( !pCur->pPage->isInit ){
72641 return SQLITE_CORRUPT_BKPT;
72642 }
72643 goto bypass_moveto_root; /* Start search on the current page */
72644 }
72645 pIdxKey->errCode = SQLITE_OK;
72646 }
72647
@@ -81232,11 +81235,11 @@
81235 SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
81236 sqlite3VdbeAddOp2(p, OP_Expire, 1, 1);
81237 }
81238
81239 /*
81240 ** Mark the VDBE as one that can be run multiple times.
81241 */
81242 SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
81243 int i;
81244 for(i=1; ALWAYS(i<p->nOp); i++){
81245 if( ALWAYS(p->aOp[i].opcode==OP_Expire) ){
@@ -86746,13 +86749,13 @@
86749 break;
86750 }
86751 sqlite3_reset(pStmt);
86752 if( savedPc>=0 ){
86753 /* Setting minWriteFileFormat to 254 is a signal to the OP_Init and
86754 ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because it has
86755 ** already been done once on a prior invocation that failed due to
86756 ** SQLITE_SCHEMA. tag-20220401a */
86757 v->minWriteFileFormat = 254;
86758 }
86759 assert( v->expired==0 );
86760 }
86761 sqlite3_mutex_leave(db->mutex);
@@ -89294,11 +89297,11 @@
89297 **
89298 ** P2 is not used by the byte-code engine. However, if P2 is positive
89299 ** and also less than the current address, then the "EXPLAIN" output
89300 ** formatter in the CLI will indent all opcodes from the P2 opcode up
89301 ** to be not including the current Return. P2 should be the first opcode
89302 ** in the subroutine from which this opcode is returning. Thus the P2
89303 ** value is a byte-code indentation hint. See tag-20220407a in
89304 ** wherecode.c and shell.c.
89305 */
89306 case OP_Return: { /* in1 */
89307 pIn1 = &aMem[pOp->p1];
@@ -89956,11 +89959,11 @@
89959 }
89960 nByte = pIn1->n + pIn2->n;
89961 if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
89962 goto too_big;
89963 }
89964 if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
89965 goto no_mem;
89966 }
89967 MemSetTypeFlag(pOut, MEM_Str);
89968 if( pOut!=pIn2 ){
89969 memcpy(pOut->z, pIn2->z, pIn2->n);
@@ -89968,13 +89971,13 @@
89971 pIn2->flags = flags2;
89972 }
89973 memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);
89974 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
89975 pIn1->flags = flags1;
89976 if( encoding>SQLITE_UTF8 ) nByte &= ~1;
89977 pOut->z[nByte]=0;
89978 pOut->z[nByte+1] = 0;
 
89979 pOut->flags |= MEM_Term;
89980 pOut->n = (int)nByte;
89981 pOut->enc = encoding;
89982 UPDATE_MAX_BLOBSIZE(pOut);
89983 break;
@@ -103265,12 +103268,12 @@
103268 */
103269 assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 );
103270 sNC.uNC.pEList = p->pEList;
103271 sNC.ncFlags |= NC_UEList;
103272 if( p->pHaving ){
103273 if( (p->selFlags & SF_Aggregate)==0 ){
103274 sqlite3ErrorMsg(pParse, "HAVING clause on a non-aggregate query");
103275 return WRC_Abort;
103276 }
103277 if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
103278 }
103279 if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
@@ -135947,28 +135950,29 @@
135950 sqlite3SetJoinExpr(p->pLeft, iTable, joinFlag);
135951 p = p->pRight;
135952 }
135953 }
135954
135955 /* Undo the work of sqlite3SetJoinExpr(). This is used when a LEFT JOIN
135956 ** is simplified into an ordinary JOIN, and when an ON expression is
135957 ** "pushed down" into the WHERE clause of a subquery.
135958 **
135959 ** Convert every term that is marked with EP_OuterON and w.iJoin==iTable into
135960 ** an ordinary term that omits the EP_OuterON mark. Or if iTable<0, then
135961 ** just clear every EP_OuterON and EP_InnerON mark from the expression tree.
135962 **
135963 ** If nullable is true, that means that Expr p might evaluate to NULL even
135964 ** if it is a reference to a NOT NULL column. This can happen, for example,
135965 ** if the table that p references is on the left side of a RIGHT JOIN.
135966 ** If nullable is true, then take care to not remove the EP_CanBeNull bit.
135967 ** See forum thread https://sqlite.org/forum/forumpost/b40696f50145d21c
135968 */
135969 static void unsetJoinExpr(Expr *p, int iTable, int nullable){
135970 while( p ){
135971 if( iTable<0 || (ExprHasProperty(p, EP_OuterON) && p->w.iJoin==iTable) ){
135972 ExprClearProperty(p, EP_OuterON|EP_InnerON);
135973 if( iTable>=0 ) ExprSetProperty(p, EP_InnerON);
 
135974 }
135975 if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){
135976 ExprClearProperty(p, EP_CanBeNull);
135977 }
135978 if( p->op==TK_FUNCTION ){
@@ -140189,10 +140193,12 @@
140193 Parse *pParse; /* Parsing context */
140194 u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
140195 int nConst; /* Number for COLUMN=CONSTANT terms */
140196 int nChng; /* Number of times a constant is propagated */
140197 int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
140198 u32 mExcludeOn; /* Which ON expressions to exclude from considertion.
140199 ** Either EP_OuterON or EP_InnerON|EP_OuterON */
140200 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
140201 };
140202
140203 /*
140204 ** Add a new entry to the pConst object. Except, do not add duplicate
@@ -140251,11 +140257,11 @@
140257 ** found, add it to the pConst structure.
140258 */
140259 static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
140260 Expr *pRight, *pLeft;
140261 if( NEVER(pExpr==0) ) return;
140262 if( ExprHasProperty(pExpr, pConst->mExcludeOn) ){
140263 testcase( ExprHasProperty(pExpr, EP_OuterON) );
140264 testcase( ExprHasProperty(pExpr, EP_InnerON) );
140265 return;
140266 }
140267 if( pExpr->op==TK_AND ){
@@ -140291,13 +140297,14 @@
140297 int bIgnoreAffBlob
140298 ){
140299 int i;
140300 if( pConst->pOomFault[0] ) return WRC_Prune;
140301 if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
140302 if( ExprHasProperty(pExpr, EP_FixedCol|pConst->mExcludeOn) ){
140303 testcase( ExprHasProperty(pExpr, EP_FixedCol) );
140304 testcase( ExprHasProperty(pExpr, EP_OuterON) );
140305 testcase( ExprHasProperty(pExpr, EP_InnerON) );
140306 return WRC_Continue;
140307 }
140308 for(i=0; i<pConst->nConst; i++){
140309 Expr *pColumn = pConst->apExpr[i*2];
140310 if( pColumn==pExpr ) continue;
@@ -140417,10 +140424,21 @@
140424 do{
140425 x.nConst = 0;
140426 x.nChng = 0;
140427 x.apExpr = 0;
140428 x.bHasAffBlob = 0;
140429 if( ALWAYS(p->pSrc!=0)
140430 && p->pSrc->nSrc>0
140431 && (p->pSrc->a[0].fg.jointype & JT_LTORJ)!=0
140432 ){
140433 /* Do not propagate constants on any ON clause if there is a
140434 ** RIGHT JOIN anywhere in the query */
140435 x.mExcludeOn = EP_InnerON | EP_OuterON;
140436 }else{
140437 /* Do not propagate constants through the ON clause of a LEFT JOIN */
140438 x.mExcludeOn = EP_OuterON;
140439 }
140440 findConstInWhere(&x, p->pWhere);
140441 if( x.nConst ){
140442 memset(&w, 0, sizeof(w));
140443 w.pParse = pParse;
140444 w.xExprCallback = propagateConstantExprRewrite;
@@ -142280,10 +142298,11 @@
142298 && OptimizationEnabled(db, SQLITE_SimplifyJoin)
142299 ){
142300 SELECTTRACE(0x100,pParse,p,
142301 ("LEFT-JOIN simplifies to JOIN on term %d\n",i));
142302 pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER);
142303 assert( pItem->iCursor>=0 );
142304 unsetJoinExpr(p->pWhere, pItem->iCursor,
142305 pTabList->a[0].fg.jointype & JT_LTORJ);
142306 }
142307
142308 /* No futher action if this term of the FROM clause is no a subquery */
@@ -142501,11 +142520,11 @@
142520 zSavedAuthContext = pParse->zAuthContext;
142521 pParse->zAuthContext = pItem->zName;
142522
142523 /* Generate code to implement the subquery
142524 **
142525 ** The subquery is implemented as a co-routine if all of the following are
142526 ** true:
142527 **
142528 ** (1) the subquery is guaranteed to be the outer loop (so that
142529 ** it does not need to be computed more than once), and
142530 ** (2) the subquery is not a CTE that should be materialized
@@ -153168,13 +153187,19 @@
153187 sqlite3ErrorMsg(pParse, "ON clause references tables to its right");
153188 return;
153189 }
153190 }else if( (prereqAll>>1)>=x ){
153191 /* The ON clause of an INNER JOIN references a table to its right.
153192 ** Most other SQL database engines raise an error. But SQLite versions
153193 ** 3.0 through 3.38 just put the ON clause constraint into the WHERE
153194 ** clause and carried on. Beginning with 3.39, raise an error only
153195 ** if there is a RIGHT or FULL JOIN in the query. This makes SQLite
153196 ** more like other systems, and also preserves legacy. */
153197 if( ALWAYS(pSrc->nSrc>0) && (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){
153198 sqlite3ErrorMsg(pParse, "ON clause references tables to its right");
153199 return;
153200 }
153201 ExprClearProperty(pExpr, EP_InnerON);
153202 }
153203 }
153204 pTerm->prereqAll = prereqAll;
153205 pTerm->leftCursor = -1;
@@ -158075,15 +158100,25 @@
158100 for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
158101 Bitmask mUnusable = 0;
158102 pNew->iTab = iTab;
158103 pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;
158104 pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
158105 if( bFirstPastRJ
158106 || (pItem->fg.jointype & (JT_OUTER|JT_CROSS|JT_LTORJ))!=0
158107 ){
158108 /* Add prerequisites to prevent reordering of FROM clause terms
158109 ** across CROSS joins and outer joins. The bFirstPastRJ boolean
158110 ** prevents the right operand of a RIGHT JOIN from being swapped with
158111 ** other elements even further to the right.
158112 **
158113 ** The JT_LTORJ term prevents any FROM-clause term reordering for terms
158114 ** to the left of a RIGHT JOIN. This is conservative. Relaxing this
158115 ** constraint somewhat to prevent terms from crossing from the right
158116 ** side of a LEFT JOIN over to the left side when they are on the
158117 ** left side of a RIGHT JOIN would be sufficient for all known failure
158118 ** cases. FIX ME: Implement this optimization.
158119 */
158120 mPrereq |= mPrior;
158121 bFirstPastRJ = (pItem->fg.jointype & JT_RIGHT)!=0;
158122 }
158123 #ifndef SQLITE_OMIT_VIRTUALTABLE
158124 if( IsVirtual(pItem->pTab) ){
@@ -158968,11 +159003,15 @@
159003 if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
159004 assert( pWInfo->pTabList->nSrc>=1 );
159005 pItem = pWInfo->pTabList->a;
159006 pTab = pItem->pTab;
159007 if( IsVirtual(pTab) ) return 0;
159008 if( pItem->fg.isIndexedBy || pItem->fg.notIndexed ){
159009 testcase( pItem->fg.isIndexedBy );
159010 testcase( pItem->fg.notIndexed );
159011 return 0;
159012 }
159013 iCur = pItem->iCursor;
159014 pWC = &pWInfo->sWC;
159015 pLoop = pBuilder->pNew;
159016 pLoop->wsFlags = 0;
159017 pLoop->nSkip = 0;
@@ -159141,11 +159180,11 @@
159180 WhereTerm *pTerm, *pEnd;
159181 SrcItem *pItem;
159182 WhereLoop *pLoop;
159183 pLoop = pWInfo->a[i].pWLoop;
159184 pItem = &pWInfo->pTabList->a[pLoop->iTab];
159185 if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ) continue;
159186 if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
159187 && (pLoop->wsFlags & WHERE_ONEROW)==0
159188 ){
159189 continue;
159190 }
@@ -236575,11 +236614,11 @@
236614 int nArg, /* Number of args */
236615 sqlite3_value **apUnused /* Function arguments */
236616 ){
236617 assert( nArg==0 );
236618 UNUSED_PARAM2(nArg, apUnused);
236619 sqlite3_result_text(pCtx, "fts5: 2022-06-22 18:51:47 83ff1a28e3e7a99fa90d5079897d76529c4256eed859bf7cb98b860fbedfdc5b", -1, SQLITE_TRANSIENT);
236620 }
236621
236622 /*
236623 ** Return true if zName is the extension on one of the shadow tables used
236624 ** by this module.
236625
--- 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.39.0"
150150
#define SQLITE_VERSION_NUMBER 3039000
151
-#define SQLITE_SOURCE_ID "2022-06-15 16:26:37 56c60a35ea457f06db58ec3f694a1ae16fd03e6625da1d7879d63d72bbcb1c62"
151
+#define SQLITE_SOURCE_ID "2022-06-22 18:51:47 83ff1a28e3e7a99fa90d5079897d76529c4256eed859bf7cb98b860fbedfalt1"
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.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-06-15 16:26:37 56c60a35ea457f06db58ec3f694a1ae16fd03e6625da1d7879d63d72bbcb1c62"
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.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-06-22 18:51:47 83ff1a28e3e7a99fa90d5079897d76529c4256eed859bf7cb98b860fbedfalt1"
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