Fossil SCM
Update the built-in SQLite to the latest 3.39.0 beta, for SQLite testing.
Commit
d7a2bda91238bdcc5f2dcec9dd99e89a505375f4b121fab7374a5dc793d494b5
Parent
ca2248ec2c97e47…
2 files changed
+70
-31
+1
-1
+70
-31
| --- extsrc/sqlite3.c | ||
| +++ extsrc/sqlite3.c | ||
| @@ -452,11 +452,11 @@ | ||
| 452 | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 454 | */ |
| 455 | 455 | #define SQLITE_VERSION "3.39.0" |
| 456 | 456 | #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" | |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| @@ -31073,11 +31073,11 @@ | ||
| 31073 | 31073 | */ |
| 31074 | 31074 | SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){ |
| 31075 | 31075 | va_list ap; |
| 31076 | 31076 | int i; |
| 31077 | 31077 | StrAccum acc; |
| 31078 | - char zBuf[500]; | |
| 31078 | + char zBuf[1000]; | |
| 31079 | 31079 | sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); |
| 31080 | 31080 | if( p ){ |
| 31081 | 31081 | for(i=0; i<p->iLevel && i<(int)sizeof(p->bLine)-1; i++){ |
| 31082 | 31082 | sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4); |
| 31083 | 31083 | } |
| @@ -31204,11 +31204,11 @@ | ||
| 31204 | 31204 | if( pSrc==0 ) return; |
| 31205 | 31205 | for(i=0; i<pSrc->nSrc; i++){ |
| 31206 | 31206 | const SrcItem *pItem = &pSrc->a[i]; |
| 31207 | 31207 | StrAccum x; |
| 31208 | 31208 | int n = 0; |
| 31209 | - char zLine[100]; | |
| 31209 | + char zLine[1000]; | |
| 31210 | 31210 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 31211 | 31211 | x.printfFlags |= SQLITE_PRINTF_INTERNAL; |
| 31212 | 31212 | sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); |
| 31213 | 31213 | if( pItem->pTab ){ |
| 31214 | 31214 | sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", |
| @@ -72635,10 +72635,13 @@ | ||
| 72635 | 72635 | if( pCur->iPage>0 |
| 72636 | 72636 | && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0 |
| 72637 | 72637 | && pIdxKey->errCode==SQLITE_OK |
| 72638 | 72638 | ){ |
| 72639 | 72639 | pCur->curFlags &= ~BTCF_ValidOvfl; |
| 72640 | + if( !pCur->pPage->isInit ){ | |
| 72641 | + return SQLITE_CORRUPT_BKPT; | |
| 72642 | + } | |
| 72640 | 72643 | goto bypass_moveto_root; /* Start search on the current page */ |
| 72641 | 72644 | } |
| 72642 | 72645 | pIdxKey->errCode = SQLITE_OK; |
| 72643 | 72646 | } |
| 72644 | 72647 | |
| @@ -81232,11 +81235,11 @@ | ||
| 81232 | 81235 | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){ |
| 81233 | 81236 | sqlite3VdbeAddOp2(p, OP_Expire, 1, 1); |
| 81234 | 81237 | } |
| 81235 | 81238 | |
| 81236 | 81239 | /* |
| 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. | |
| 81238 | 81241 | */ |
| 81239 | 81242 | SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){ |
| 81240 | 81243 | int i; |
| 81241 | 81244 | for(i=1; ALWAYS(i<p->nOp); i++){ |
| 81242 | 81245 | if( ALWAYS(p->aOp[i].opcode==OP_Expire) ){ |
| @@ -86746,13 +86749,13 @@ | ||
| 86746 | 86749 | break; |
| 86747 | 86750 | } |
| 86748 | 86751 | sqlite3_reset(pStmt); |
| 86749 | 86752 | if( savedPc>=0 ){ |
| 86750 | 86753 | /* 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 */ | |
| 86754 | 86757 | v->minWriteFileFormat = 254; |
| 86755 | 86758 | } |
| 86756 | 86759 | assert( v->expired==0 ); |
| 86757 | 86760 | } |
| 86758 | 86761 | sqlite3_mutex_leave(db->mutex); |
| @@ -89294,11 +89297,11 @@ | ||
| 89294 | 89297 | ** |
| 89295 | 89298 | ** P2 is not used by the byte-code engine. However, if P2 is positive |
| 89296 | 89299 | ** and also less than the current address, then the "EXPLAIN" output |
| 89297 | 89300 | ** formatter in the CLI will indent all opcodes from the P2 opcode up |
| 89298 | 89301 | ** 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 | |
| 89300 | 89303 | ** value is a byte-code indentation hint. See tag-20220407a in |
| 89301 | 89304 | ** wherecode.c and shell.c. |
| 89302 | 89305 | */ |
| 89303 | 89306 | case OP_Return: { /* in1 */ |
| 89304 | 89307 | pIn1 = &aMem[pOp->p1]; |
| @@ -89956,11 +89959,11 @@ | ||
| 89956 | 89959 | } |
| 89957 | 89960 | nByte = pIn1->n + pIn2->n; |
| 89958 | 89961 | if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 89959 | 89962 | goto too_big; |
| 89960 | 89963 | } |
| 89961 | - if( sqlite3VdbeMemGrow(pOut, (int)nByte+3, pOut==pIn2) ){ | |
| 89964 | + if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){ | |
| 89962 | 89965 | goto no_mem; |
| 89963 | 89966 | } |
| 89964 | 89967 | MemSetTypeFlag(pOut, MEM_Str); |
| 89965 | 89968 | if( pOut!=pIn2 ){ |
| 89966 | 89969 | memcpy(pOut->z, pIn2->z, pIn2->n); |
| @@ -89968,13 +89971,13 @@ | ||
| 89968 | 89971 | pIn2->flags = flags2; |
| 89969 | 89972 | } |
| 89970 | 89973 | memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n); |
| 89971 | 89974 | assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); |
| 89972 | 89975 | pIn1->flags = flags1; |
| 89976 | + if( encoding>SQLITE_UTF8 ) nByte &= ~1; | |
| 89973 | 89977 | pOut->z[nByte]=0; |
| 89974 | 89978 | pOut->z[nByte+1] = 0; |
| 89975 | - pOut->z[nByte+2] = 0; | |
| 89976 | 89979 | pOut->flags |= MEM_Term; |
| 89977 | 89980 | pOut->n = (int)nByte; |
| 89978 | 89981 | pOut->enc = encoding; |
| 89979 | 89982 | UPDATE_MAX_BLOBSIZE(pOut); |
| 89980 | 89983 | break; |
| @@ -103265,12 +103268,12 @@ | ||
| 103265 | 103268 | */ |
| 103266 | 103269 | assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 ); |
| 103267 | 103270 | sNC.uNC.pEList = p->pEList; |
| 103268 | 103271 | sNC.ncFlags |= NC_UEList; |
| 103269 | 103272 | 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"); | |
| 103272 | 103275 | return WRC_Abort; |
| 103273 | 103276 | } |
| 103274 | 103277 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 103275 | 103278 | } |
| 103276 | 103279 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| @@ -135947,28 +135950,29 @@ | ||
| 135947 | 135950 | sqlite3SetJoinExpr(p->pLeft, iTable, joinFlag); |
| 135948 | 135951 | p = p->pRight; |
| 135949 | 135952 | } |
| 135950 | 135953 | } |
| 135951 | 135954 | |
| 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. | |
| 135955 | 135958 | ** |
| 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. | |
| 135957 | 135962 | ** |
| 135958 | 135963 | ** If nullable is true, that means that Expr p might evaluate to NULL even |
| 135959 | 135964 | ** if it is a reference to a NOT NULL column. This can happen, for example, |
| 135960 | 135965 | ** if the table that p references is on the left side of a RIGHT JOIN. |
| 135961 | 135966 | ** If nullable is true, then take care to not remove the EP_CanBeNull bit. |
| 135962 | 135967 | ** See forum thread https://sqlite.org/forum/forumpost/b40696f50145d21c |
| 135963 | 135968 | */ |
| 135964 | 135969 | static void unsetJoinExpr(Expr *p, int iTable, int nullable){ |
| 135965 | 135970 | 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); | |
| 135970 | 135974 | } |
| 135971 | 135975 | if( p->op==TK_COLUMN && p->iTable==iTable && !nullable ){ |
| 135972 | 135976 | ExprClearProperty(p, EP_CanBeNull); |
| 135973 | 135977 | } |
| 135974 | 135978 | if( p->op==TK_FUNCTION ){ |
| @@ -140189,10 +140193,12 @@ | ||
| 140189 | 140193 | Parse *pParse; /* Parsing context */ |
| 140190 | 140194 | u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */ |
| 140191 | 140195 | int nConst; /* Number for COLUMN=CONSTANT terms */ |
| 140192 | 140196 | int nChng; /* Number of times a constant is propagated */ |
| 140193 | 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 */ | |
| 140194 | 140200 | Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */ |
| 140195 | 140201 | }; |
| 140196 | 140202 | |
| 140197 | 140203 | /* |
| 140198 | 140204 | ** Add a new entry to the pConst object. Except, do not add duplicate |
| @@ -140251,11 +140257,11 @@ | ||
| 140251 | 140257 | ** found, add it to the pConst structure. |
| 140252 | 140258 | */ |
| 140253 | 140259 | static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ |
| 140254 | 140260 | Expr *pRight, *pLeft; |
| 140255 | 140261 | if( NEVER(pExpr==0) ) return; |
| 140256 | - if( ExprHasProperty(pExpr, EP_OuterON|EP_InnerON) ){ | |
| 140262 | + if( ExprHasProperty(pExpr, pConst->mExcludeOn) ){ | |
| 140257 | 140263 | testcase( ExprHasProperty(pExpr, EP_OuterON) ); |
| 140258 | 140264 | testcase( ExprHasProperty(pExpr, EP_InnerON) ); |
| 140259 | 140265 | return; |
| 140260 | 140266 | } |
| 140261 | 140267 | if( pExpr->op==TK_AND ){ |
| @@ -140291,13 +140297,14 @@ | ||
| 140291 | 140297 | int bIgnoreAffBlob |
| 140292 | 140298 | ){ |
| 140293 | 140299 | int i; |
| 140294 | 140300 | if( pConst->pOomFault[0] ) return WRC_Prune; |
| 140295 | 140301 | if( pExpr->op!=TK_COLUMN ) return WRC_Continue; |
| 140296 | - if( ExprHasProperty(pExpr, EP_FixedCol|EP_OuterON) ){ | |
| 140302 | + if( ExprHasProperty(pExpr, EP_FixedCol|pConst->mExcludeOn) ){ | |
| 140297 | 140303 | testcase( ExprHasProperty(pExpr, EP_FixedCol) ); |
| 140298 | 140304 | testcase( ExprHasProperty(pExpr, EP_OuterON) ); |
| 140305 | + testcase( ExprHasProperty(pExpr, EP_InnerON) ); | |
| 140299 | 140306 | return WRC_Continue; |
| 140300 | 140307 | } |
| 140301 | 140308 | for(i=0; i<pConst->nConst; i++){ |
| 140302 | 140309 | Expr *pColumn = pConst->apExpr[i*2]; |
| 140303 | 140310 | if( pColumn==pExpr ) continue; |
| @@ -140417,10 +140424,21 @@ | ||
| 140417 | 140424 | do{ |
| 140418 | 140425 | x.nConst = 0; |
| 140419 | 140426 | x.nChng = 0; |
| 140420 | 140427 | x.apExpr = 0; |
| 140421 | 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 | + } | |
| 140422 | 140440 | findConstInWhere(&x, p->pWhere); |
| 140423 | 140441 | if( x.nConst ){ |
| 140424 | 140442 | memset(&w, 0, sizeof(w)); |
| 140425 | 140443 | w.pParse = pParse; |
| 140426 | 140444 | w.xExprCallback = propagateConstantExprRewrite; |
| @@ -142280,10 +142298,11 @@ | ||
| 142280 | 142298 | && OptimizationEnabled(db, SQLITE_SimplifyJoin) |
| 142281 | 142299 | ){ |
| 142282 | 142300 | SELECTTRACE(0x100,pParse,p, |
| 142283 | 142301 | ("LEFT-JOIN simplifies to JOIN on term %d\n",i)); |
| 142284 | 142302 | pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER); |
| 142303 | + assert( pItem->iCursor>=0 ); | |
| 142285 | 142304 | unsetJoinExpr(p->pWhere, pItem->iCursor, |
| 142286 | 142305 | pTabList->a[0].fg.jointype & JT_LTORJ); |
| 142287 | 142306 | } |
| 142288 | 142307 | |
| 142289 | 142308 | /* No futher action if this term of the FROM clause is no a subquery */ |
| @@ -142501,11 +142520,11 @@ | ||
| 142501 | 142520 | zSavedAuthContext = pParse->zAuthContext; |
| 142502 | 142521 | pParse->zAuthContext = pItem->zName; |
| 142503 | 142522 | |
| 142504 | 142523 | /* Generate code to implement the subquery |
| 142505 | 142524 | ** |
| 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 | |
| 142507 | 142526 | ** true: |
| 142508 | 142527 | ** |
| 142509 | 142528 | ** (1) the subquery is guaranteed to be the outer loop (so that |
| 142510 | 142529 | ** it does not need to be computed more than once), and |
| 142511 | 142530 | ** (2) the subquery is not a CTE that should be materialized |
| @@ -153168,13 +153187,19 @@ | ||
| 153168 | 153187 | sqlite3ErrorMsg(pParse, "ON clause references tables to its right"); |
| 153169 | 153188 | return; |
| 153170 | 153189 | } |
| 153171 | 153190 | }else if( (prereqAll>>1)>=x ){ |
| 153172 | 153191 | /* 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 | + } | |
| 153176 | 153201 | ExprClearProperty(pExpr, EP_InnerON); |
| 153177 | 153202 | } |
| 153178 | 153203 | } |
| 153179 | 153204 | pTerm->prereqAll = prereqAll; |
| 153180 | 153205 | pTerm->leftCursor = -1; |
| @@ -158075,15 +158100,25 @@ | ||
| 158075 | 158100 | for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){ |
| 158076 | 158101 | Bitmask mUnusable = 0; |
| 158077 | 158102 | pNew->iTab = iTab; |
| 158078 | 158103 | pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR; |
| 158079 | 158104 | 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 | + ){ | |
| 158081 | 158108 | /* Add prerequisites to prevent reordering of FROM clause terms |
| 158082 | 158109 | ** across CROSS joins and outer joins. The bFirstPastRJ boolean |
| 158083 | 158110 | ** 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 | + */ | |
| 158085 | 158120 | mPrereq |= mPrior; |
| 158086 | 158121 | bFirstPastRJ = (pItem->fg.jointype & JT_RIGHT)!=0; |
| 158087 | 158122 | } |
| 158088 | 158123 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 158089 | 158124 | if( IsVirtual(pItem->pTab) ){ |
| @@ -158968,11 +159003,15 @@ | ||
| 158968 | 159003 | if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0; |
| 158969 | 159004 | assert( pWInfo->pTabList->nSrc>=1 ); |
| 158970 | 159005 | pItem = pWInfo->pTabList->a; |
| 158971 | 159006 | pTab = pItem->pTab; |
| 158972 | 159007 | 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 | + } | |
| 158974 | 159013 | iCur = pItem->iCursor; |
| 158975 | 159014 | pWC = &pWInfo->sWC; |
| 158976 | 159015 | pLoop = pBuilder->pNew; |
| 158977 | 159016 | pLoop->wsFlags = 0; |
| 158978 | 159017 | pLoop->nSkip = 0; |
| @@ -159141,11 +159180,11 @@ | ||
| 159141 | 159180 | WhereTerm *pTerm, *pEnd; |
| 159142 | 159181 | SrcItem *pItem; |
| 159143 | 159182 | WhereLoop *pLoop; |
| 159144 | 159183 | pLoop = pWInfo->a[i].pWLoop; |
| 159145 | 159184 | 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; | |
| 159147 | 159186 | if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0 |
| 159148 | 159187 | && (pLoop->wsFlags & WHERE_ONEROW)==0 |
| 159149 | 159188 | ){ |
| 159150 | 159189 | continue; |
| 159151 | 159190 | } |
| @@ -236575,11 +236614,11 @@ | ||
| 236575 | 236614 | int nArg, /* Number of args */ |
| 236576 | 236615 | sqlite3_value **apUnused /* Function arguments */ |
| 236577 | 236616 | ){ |
| 236578 | 236617 | assert( nArg==0 ); |
| 236579 | 236618 | 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); | |
| 236581 | 236620 | } |
| 236582 | 236621 | |
| 236583 | 236622 | /* |
| 236584 | 236623 | ** Return true if zName is the extension on one of the shadow tables used |
| 236585 | 236624 | ** by this module. |
| 236586 | 236625 |
| --- 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 |
+1
-1
| --- extsrc/sqlite3.h | ||
| +++ extsrc/sqlite3.h | ||
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | 148 | */ |
| 149 | 149 | #define SQLITE_VERSION "3.39.0" |
| 150 | 150 | #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" | |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | 156 | ** |
| 157 | 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-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 |