Fossil SCM
Update the built-in SQLite to the latest trunk version which includes all of the fixes that went into version 3.38.3.
Commit
f905bd0d8d5b70fe0670733d948e20261a7aa7db50bd6332a9cc8e30a6a4bb3d
Parent
74250821b1f4b08…
2 files changed
+187
-43
+1
-1
+187
-43
| --- 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-04-21 19:38:17 f766dff012af0ea3c28a8ce4db850cd0205729a8283bce1e442992aded7c734b" | |
| 457 | +#define SQLITE_SOURCE_ID "2022-04-26 19:16:11 b1bec72043f798f4d4d30e6b60a45ed4dc521115c8a9f97bb8228e3f089deefb" | |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| @@ -15790,12 +15790,14 @@ | ||
| 15790 | 15790 | # define sqlite3VdbeVerifyNoMallocRequired(A,B) |
| 15791 | 15791 | # define sqlite3VdbeVerifyNoResultRow(A) |
| 15792 | 15792 | #endif |
| 15793 | 15793 | #if defined(SQLITE_DEBUG) |
| 15794 | 15794 | SQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int); |
| 15795 | +SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn(Vdbe*,int,int,int); | |
| 15795 | 15796 | #else |
| 15796 | 15797 | # define sqlite3VdbeVerifyAbortable(A,B) |
| 15798 | +# define sqlite3VdbeNoJumpsOutsideSubrtn(A,B,C,D) | |
| 15797 | 15799 | #endif |
| 15798 | 15800 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno); |
| 15799 | 15801 | #ifndef SQLITE_OMIT_EXPLAIN |
| 15800 | 15802 | SQLITE_PRIVATE void sqlite3VdbeExplain(Parse*,u8,const char*,...); |
| 15801 | 15803 | SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse*); |
| @@ -17051,10 +17053,11 @@ | ||
| 17051 | 17053 | /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ |
| 17052 | 17054 | #define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */ |
| 17053 | 17055 | #define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */ |
| 17054 | 17056 | #define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */ |
| 17055 | 17057 | #define SQLITE_ReleaseReg 0x00400000 /* Use OP_ReleaseReg for testing */ |
| 17058 | +#define SQLITE_FlttnUnionAll 0x00800000 /* Disable the UNION ALL flattener */ | |
| 17056 | 17059 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17057 | 17060 | |
| 17058 | 17061 | /* |
| 17059 | 17062 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| 17060 | 17063 | */ |
| @@ -20022,10 +20025,11 @@ | ||
| 20022 | 20025 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); |
| 20023 | 20026 | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*); |
| 20024 | 20027 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 20025 | 20028 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); |
| 20026 | 20029 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); |
| 20030 | +SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr*,const SrcItem*); | |
| 20027 | 20031 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 20028 | 20032 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 20029 | 20033 | #endif |
| 20030 | 20034 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20031 | 20035 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| @@ -30462,12 +30466,18 @@ | ||
| 30462 | 30466 | sqlite3_str_append(pAccum, ".", 1); |
| 30463 | 30467 | } |
| 30464 | 30468 | sqlite3_str_appendall(pAccum, pItem->zName); |
| 30465 | 30469 | }else if( pItem->zAlias ){ |
| 30466 | 30470 | sqlite3_str_appendall(pAccum, pItem->zAlias); |
| 30467 | - }else if( ALWAYS(pItem->pSelect) ){ | |
| 30468 | - sqlite3_str_appendf(pAccum, "SUBQUERY %u", pItem->pSelect->selId); | |
| 30471 | + }else{ | |
| 30472 | + Select *pSel = pItem->pSelect; | |
| 30473 | + assert( pSel!=0 ); | |
| 30474 | + if( pSel->selFlags & SF_NestedFrom ){ | |
| 30475 | + sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); | |
| 30476 | + }else{ | |
| 30477 | + sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId); | |
| 30478 | + } | |
| 30469 | 30479 | } |
| 30470 | 30480 | length = width = 0; |
| 30471 | 30481 | break; |
| 30472 | 30482 | } |
| 30473 | 30483 | default: { |
| @@ -31077,10 +31087,14 @@ | ||
| 31077 | 31087 | sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zEName); |
| 31078 | 31088 | cSep = ','; |
| 31079 | 31089 | } |
| 31080 | 31090 | sqlite3_str_appendf(&x, ")"); |
| 31081 | 31091 | } |
| 31092 | + if( pCte->eM10d!=M10d_Any ){ | |
| 31093 | + sqlite3_str_appendf(&x, " %sMATERIALIZED", | |
| 31094 | + pCte->eM10d==M10d_No ? "NOT " : ""); | |
| 31095 | + } | |
| 31082 | 31096 | if( pCte->pUse ){ |
| 31083 | 31097 | sqlite3_str_appendf(&x, " (pUse=0x%p, nUse=%d)", pCte->pUse, |
| 31084 | 31098 | pCte->pUse->nUse); |
| 31085 | 31099 | } |
| 31086 | 31100 | sqlite3StrAccumFinish(&x); |
| @@ -81423,10 +81437,94 @@ | ||
| 81423 | 81437 | pParse->nLabel = 0; |
| 81424 | 81438 | *pMaxFuncArgs = nMaxArgs; |
| 81425 | 81439 | assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) ); |
| 81426 | 81440 | } |
| 81427 | 81441 | |
| 81442 | +#ifdef SQLITE_DEBUG | |
| 81443 | +/* | |
| 81444 | +** Check to see if a subroutine contains a jump to a location outside of | |
| 81445 | +** the subroutine. If a jump outside the subroutine is detected, add code | |
| 81446 | +** that will cause the program to halt with an error message. | |
| 81447 | +** | |
| 81448 | +** The subroutine consists of opcodes between iFirst and iLast. Jumps to | |
| 81449 | +** locations within the subroutine are acceptable. iRetReg is a register | |
| 81450 | +** that contains the return address. Jumps to outside the range of iFirst | |
| 81451 | +** through iLast are also acceptable as long as the jump destination is | |
| 81452 | +** an OP_Return to iReturnAddr. | |
| 81453 | +** | |
| 81454 | +** A jump to an unresolved label means that the jump destination will be | |
| 81455 | +** beyond the current address. That is normally a jump to an early | |
| 81456 | +** termination and is consider acceptable. | |
| 81457 | +** | |
| 81458 | +** This routine only runs during debug builds. The purpose is (of course) | |
| 81459 | +** to detect invalid escapes out of a subroutine. The OP_Halt opcode | |
| 81460 | +** is generated rather than an assert() or other error, so that ".eqp full" | |
| 81461 | +** will still work to show the original bytecode, to aid in debugging. | |
| 81462 | +*/ | |
| 81463 | +SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn( | |
| 81464 | + Vdbe *v, /* The byte-code program under construction */ | |
| 81465 | + int iFirst, /* First opcode of the subroutine */ | |
| 81466 | + int iLast, /* Last opcode of the subroutine */ | |
| 81467 | + int iRetReg /* Subroutine return address register */ | |
| 81468 | +){ | |
| 81469 | + VdbeOp *pOp; | |
| 81470 | + Parse *pParse; | |
| 81471 | + int i; | |
| 81472 | + sqlite3_str *pErr = 0; | |
| 81473 | + assert( v!=0 ); | |
| 81474 | + pParse = v->pParse; | |
| 81475 | + assert( pParse!=0 ); | |
| 81476 | + if( pParse->nErr ) return; | |
| 81477 | + assert( iLast>=iFirst ); | |
| 81478 | + assert( iLast<v->nOp ); | |
| 81479 | + pOp = &v->aOp[iFirst]; | |
| 81480 | + for(i=iFirst; i<=iLast; i++, pOp++){ | |
| 81481 | + if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ){ | |
| 81482 | + int iDest = pOp->p2; /* Jump destination */ | |
| 81483 | + if( iDest==0 ) continue; | |
| 81484 | + if( pOp->opcode==OP_Gosub ) continue; | |
| 81485 | + if( iDest<0 ){ | |
| 81486 | + int j = ADDR(iDest); | |
| 81487 | + assert( j>=0 ); | |
| 81488 | + if( j>=-pParse->nLabel || pParse->aLabel[j]<0 ){ | |
| 81489 | + continue; | |
| 81490 | + } | |
| 81491 | + iDest = pParse->aLabel[j]; | |
| 81492 | + } | |
| 81493 | + if( iDest<iFirst || iDest>iLast ){ | |
| 81494 | + int j = iDest; | |
| 81495 | + for(; j<v->nOp; j++){ | |
| 81496 | + VdbeOp *pX = &v->aOp[j]; | |
| 81497 | + if( pX->opcode==OP_Return ){ | |
| 81498 | + if( pX->p1==iRetReg ) break; | |
| 81499 | + continue; | |
| 81500 | + } | |
| 81501 | + if( pX->opcode==OP_Noop ) continue; | |
| 81502 | + if( pX->opcode==OP_Explain ) continue; | |
| 81503 | + if( pErr==0 ){ | |
| 81504 | + pErr = sqlite3_str_new(0); | |
| 81505 | + }else{ | |
| 81506 | + sqlite3_str_appendchar(pErr, 1, '\n'); | |
| 81507 | + } | |
| 81508 | + sqlite3_str_appendf(pErr, | |
| 81509 | + "Opcode at %d jumps to %d which is outside the " | |
| 81510 | + "subroutine at %d..%d", | |
| 81511 | + i, iDest, iFirst, iLast); | |
| 81512 | + break; | |
| 81513 | + } | |
| 81514 | + } | |
| 81515 | + } | |
| 81516 | + } | |
| 81517 | + if( pErr ){ | |
| 81518 | + char *zErr = sqlite3_str_finish(pErr); | |
| 81519 | + sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_INTERNAL, OE_Abort, 0, zErr, 0); | |
| 81520 | + sqlite3_free(zErr); | |
| 81521 | + sqlite3MayAbort(pParse); | |
| 81522 | + } | |
| 81523 | +} | |
| 81524 | +#endif /* SQLITE_DEBUG */ | |
| 81525 | + | |
| 81428 | 81526 | /* |
| 81429 | 81527 | ** Return the address of the next instruction to be inserted. |
| 81430 | 81528 | */ |
| 81431 | 81529 | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){ |
| 81432 | 81530 | assert( p->eVdbeState==VDBE_INIT_STATE ); |
| @@ -104911,10 +105009,11 @@ | ||
| 104911 | 105009 | pRet->nCte = p->nCte; |
| 104912 | 105010 | for(i=0; i<p->nCte; i++){ |
| 104913 | 105011 | pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0); |
| 104914 | 105012 | pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0); |
| 104915 | 105013 | pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName); |
| 105014 | + pRet->a[i].eM10d = p->a[i].eM10d; | |
| 104916 | 105015 | } |
| 104917 | 105016 | } |
| 104918 | 105017 | } |
| 104919 | 105018 | return pRet; |
| 104920 | 105019 | } |
| @@ -105678,10 +105777,46 @@ | ||
| 105678 | 105777 | ** table other than iCur. |
| 105679 | 105778 | */ |
| 105680 | 105779 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){ |
| 105681 | 105780 | return exprIsConst(p, 3, iCur); |
| 105682 | 105781 | } |
| 105782 | + | |
| 105783 | +/* | |
| 105784 | +** Check pExpr to see if it is an invariant constraint on data source pSrc. | |
| 105785 | +** This is an optimization. False negatives will perhaps cause slower | |
| 105786 | +** queries, but false positives will yield incorrect answers. So when in | |
| 105787 | +** double, return 0. | |
| 105788 | +** | |
| 105789 | +** To be an invariant constraint, the following must be true: | |
| 105790 | +** | |
| 105791 | +** (1) pExpr cannot refer to any table other than pSrc->iCursor. | |
| 105792 | +** | |
| 105793 | +** (2) pExpr cannot use subqueries or non-deterministic functions. | |
| 105794 | +** | |
| 105795 | +** (3) pSrc cannot be part of the left operand for a RIGHT JOIN. | |
| 105796 | +** (Is there some way to relax this constraint?) | |
| 105797 | +** | |
| 105798 | +** (4) If pSrc is the right operand of a LEFT JOIN, then... | |
| 105799 | +** (4a) pExpr must come from an ON clause.. | |
| 105800 | + (4b) and specifically the ON clause associated with the LEFT JOIN. | |
| 105801 | +** | |
| 105802 | +** (5) If pSrc is not the right operand of a LEFT JOIN or the left | |
| 105803 | +** operand of a RIGHT JOIN, then pExpr must be from the WHERE | |
| 105804 | +** clause, not an ON clause. | |
| 105805 | +*/ | |
| 105806 | +SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr *pExpr, const SrcItem *pSrc){ | |
| 105807 | + if( pSrc->fg.jointype & JT_LTORJ ){ | |
| 105808 | + return 0; /* rule (3) */ | |
| 105809 | + } | |
| 105810 | + if( pSrc->fg.jointype & JT_LEFT ){ | |
| 105811 | + if( !ExprHasProperty(pExpr, EP_FromJoin) ) return 0; /* rule (4a) */ | |
| 105812 | + if( pExpr->w.iJoin!=pSrc->iCursor ) return 0; /* rule (4b) */ | |
| 105813 | + }else{ | |
| 105814 | + if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0; /* rule (5) */ | |
| 105815 | + } | |
| 105816 | + return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor); /* rules (1), (2) */ | |
| 105817 | +} | |
| 105683 | 105818 | |
| 105684 | 105819 | |
| 105685 | 105820 | /* |
| 105686 | 105821 | ** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). |
| 105687 | 105822 | */ |
| @@ -115001,13 +115136,11 @@ | ||
| 115001 | 115136 | Returning *pReturning = pParse->u1.pReturning; |
| 115002 | 115137 | int addrRewind; |
| 115003 | 115138 | int i; |
| 115004 | 115139 | int reg; |
| 115005 | 115140 | |
| 115006 | - if( NEVER(pReturning->nRetCol==0) ){ | |
| 115007 | - assert( CORRUPT_DB ); | |
| 115008 | - }else{ | |
| 115141 | + if( pReturning->nRetCol ){ | |
| 115009 | 115142 | sqlite3VdbeAddOp0(v, OP_FkCheck); |
| 115010 | 115143 | addrRewind = |
| 115011 | 115144 | sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur); |
| 115012 | 115145 | VdbeCoverage(v); |
| 115013 | 115146 | reg = pReturning->iRetReg; |
| @@ -115099,13 +115232,11 @@ | ||
| 115099 | 115232 | } |
| 115100 | 115233 | } |
| 115101 | 115234 | |
| 115102 | 115235 | if( pParse->bReturning ){ |
| 115103 | 115236 | Returning *pRet = pParse->u1.pReturning; |
| 115104 | - if( NEVER(pRet->nRetCol==0) ){ | |
| 115105 | - assert( CORRUPT_DB ); | |
| 115106 | - }else{ | |
| 115237 | + if( pRet->nRetCol ){ | |
| 115107 | 115238 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol); |
| 115108 | 115239 | } |
| 115109 | 115240 | } |
| 115110 | 115241 | |
| 115111 | 115242 | /* Finally, jump back to the beginning of the executable code. */ |
| @@ -117888,11 +118019,10 @@ | ||
| 117888 | 118019 | */ |
| 117889 | 118020 | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ |
| 117890 | 118021 | Table *pSelTab; /* A fake table from which we get the result set */ |
| 117891 | 118022 | Select *pSel; /* Copy of the SELECT that implements the view */ |
| 117892 | 118023 | int nErr = 0; /* Number of errors encountered */ |
| 117893 | - int n; /* Temporarily holds the number of cursors assigned */ | |
| 117894 | 118024 | sqlite3 *db = pParse->db; /* Database connection for malloc errors */ |
| 117895 | 118025 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 117896 | 118026 | int rc; |
| 117897 | 118027 | #endif |
| 117898 | 118028 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| @@ -117946,12 +118076,13 @@ | ||
| 117946 | 118076 | */ |
| 117947 | 118077 | assert( IsView(pTable) ); |
| 117948 | 118078 | pSel = sqlite3SelectDup(db, pTable->u.view.pSelect, 0); |
| 117949 | 118079 | if( pSel ){ |
| 117950 | 118080 | u8 eParseMode = pParse->eParseMode; |
| 118081 | + int nTab = pParse->nTab; | |
| 118082 | + int nSelect = pParse->nSelect; | |
| 117951 | 118083 | pParse->eParseMode = PARSE_MODE_NORMAL; |
| 117952 | - n = pParse->nTab; | |
| 117953 | 118084 | sqlite3SrcListAssignCursors(pParse, pSel->pSrc); |
| 117954 | 118085 | pTable->nCol = -1; |
| 117955 | 118086 | DisableLookaside; |
| 117956 | 118087 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 117957 | 118088 | xAuth = db->xAuth; |
| @@ -117959,11 +118090,12 @@ | ||
| 117959 | 118090 | pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); |
| 117960 | 118091 | db->xAuth = xAuth; |
| 117961 | 118092 | #else |
| 117962 | 118093 | pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); |
| 117963 | 118094 | #endif |
| 117964 | - pParse->nTab = n; | |
| 118095 | + pParse->nTab = nTab; | |
| 118096 | + pParse->nSelect = nSelect; | |
| 117965 | 118097 | if( pSelTab==0 ){ |
| 117966 | 118098 | pTable->nCol = 0; |
| 117967 | 118099 | nErr++; |
| 117968 | 118100 | }else if( pTable->pCheck ){ |
| 117969 | 118101 | /* CREATE VIEW name(arglist) AS ... |
| @@ -139375,10 +139507,12 @@ | ||
| 139375 | 139507 | ** See also (3) for restrictions on LEFT JOIN. |
| 139376 | 139508 | ** |
| 139377 | 139509 | ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 139378 | 139510 | ** is the first element of the parent query. |
| 139379 | 139511 | ** |
| 139512 | +** (28) The subquery is not a MATERIALIZED CTE. | |
| 139513 | +** | |
| 139380 | 139514 | ** |
| 139381 | 139515 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 139382 | 139516 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 139383 | 139517 | ** uses aggregates. |
| 139384 | 139518 | ** |
| @@ -139498,10 +139632,13 @@ | ||
| 139498 | 139632 | |
| 139499 | 139633 | assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 139500 | 139634 | if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 139501 | 139635 | return 0; /* Restriction (27) */ |
| 139502 | 139636 | } |
| 139637 | + if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ | |
| 139638 | + return 0; /* (28) */ | |
| 139639 | + } | |
| 139503 | 139640 | |
| 139504 | 139641 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 139505 | 139642 | ** use only the UNION ALL operator. And none of the simple select queries |
| 139506 | 139643 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 139507 | 139644 | ** queries. |
| @@ -139542,10 +139679,11 @@ | ||
| 139542 | 139679 | /* Restriction (23) */ |
| 139543 | 139680 | if( (p->selFlags & SF_Recursive) ) return 0; |
| 139544 | 139681 | |
| 139545 | 139682 | if( pSrc->nSrc>1 ){ |
| 139546 | 139683 | if( pParse->nSelect>500 ) return 0; |
| 139684 | + if( OptimizationDisabled(db, SQLITE_FlttnUnionAll) ) return 0; | |
| 139547 | 139685 | aCsrMap = sqlite3DbMallocZero(db, ((i64)pParse->nTab+1)*sizeof(int)); |
| 139548 | 139686 | if( aCsrMap ) aCsrMap[0] = pParse->nTab; |
| 139549 | 139687 | } |
| 139550 | 139688 | } |
| 139551 | 139689 | |
| @@ -140170,17 +140308,17 @@ | ||
| 140170 | 140308 | */ |
| 140171 | 140309 | static int pushDownWhereTerms( |
| 140172 | 140310 | Parse *pParse, /* Parse context (for malloc() and error reporting) */ |
| 140173 | 140311 | Select *pSubq, /* The subquery whose WHERE clause is to be augmented */ |
| 140174 | 140312 | Expr *pWhere, /* The WHERE clause of the outer query */ |
| 140175 | - int iCursor, /* Cursor number of the subquery */ | |
| 140176 | - int isLeftJoin /* True if pSubq is the right term of a LEFT JOIN */ | |
| 140313 | + SrcItem *pSrc /* The subquery term of the outer FROM clause */ | |
| 140177 | 140314 | ){ |
| 140178 | 140315 | Expr *pNew; |
| 140179 | 140316 | int nChng = 0; |
| 140180 | 140317 | if( pWhere==0 ) return 0; |
| 140181 | 140318 | if( pSubq->selFlags & (SF_Recursive|SF_MultiPart) ) return 0; |
| 140319 | + if( pSrc->fg.jointype & (JT_LTORJ|JT_RIGHT) ) return 0; | |
| 140182 | 140320 | |
| 140183 | 140321 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140184 | 140322 | if( pSubq->pPrior ){ |
| 140185 | 140323 | Select *pSel; |
| 140186 | 140324 | for(pSel=pSubq; pSel; pSel=pSel->pPrior){ |
| @@ -140206,14 +140344,15 @@ | ||
| 140206 | 140344 | |
| 140207 | 140345 | if( pSubq->pLimit!=0 ){ |
| 140208 | 140346 | return 0; /* restriction (3) */ |
| 140209 | 140347 | } |
| 140210 | 140348 | while( pWhere->op==TK_AND ){ |
| 140211 | - nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, | |
| 140212 | - iCursor, isLeftJoin); | |
| 140349 | + nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, pSrc); | |
| 140213 | 140350 | pWhere = pWhere->pLeft; |
| 140214 | 140351 | } |
| 140352 | + | |
| 140353 | +#if 0 /* Legacy code. Checks now done by sqlite3ExprIsTableConstraint() */ | |
| 140215 | 140354 | if( isLeftJoin |
| 140216 | 140355 | && (ExprHasProperty(pWhere,EP_FromJoin)==0 |
| 140217 | 140356 | || pWhere->w.iJoin!=iCursor) |
| 140218 | 140357 | ){ |
| 140219 | 140358 | return 0; /* restriction (4) */ |
| @@ -140221,20 +140360,22 @@ | ||
| 140221 | 140360 | if( ExprHasProperty(pWhere,EP_FromJoin) |
| 140222 | 140361 | && pWhere->w.iJoin!=iCursor |
| 140223 | 140362 | ){ |
| 140224 | 140363 | return 0; /* restriction (5) */ |
| 140225 | 140364 | } |
| 140226 | - if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ | |
| 140365 | +#endif | |
| 140366 | + | |
| 140367 | + if( sqlite3ExprIsTableConstraint(pWhere, pSrc) ){ | |
| 140227 | 140368 | nChng++; |
| 140228 | 140369 | pSubq->selFlags |= SF_PushDown; |
| 140229 | 140370 | while( pSubq ){ |
| 140230 | 140371 | SubstContext x; |
| 140231 | 140372 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| 140232 | 140373 | unsetJoinExpr(pNew, -1); |
| 140233 | 140374 | x.pParse = pParse; |
| 140234 | - x.iTable = iCursor; | |
| 140235 | - x.iNewTable = iCursor; | |
| 140375 | + x.iTable = pSrc->iCursor; | |
| 140376 | + x.iNewTable = pSrc->iCursor; | |
| 140236 | 140377 | x.isOuterJoin = 0; |
| 140237 | 140378 | x.pEList = pSubq->pEList; |
| 140238 | 140379 | pNew = substExpr(&x, pNew); |
| 140239 | 140380 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140240 | 140381 | if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){ |
| @@ -140773,11 +140914,11 @@ | ||
| 140773 | 140914 | if( pTab==0 ) return SQLITE_NOMEM; |
| 140774 | 140915 | pTab->nTabRef = 1; |
| 140775 | 140916 | if( pFrom->zAlias ){ |
| 140776 | 140917 | pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias); |
| 140777 | 140918 | }else{ |
| 140778 | - pTab->zName = sqlite3MPrintf(pParse->db, "subquery_%u", pSel->selId); | |
| 140919 | + pTab->zName = sqlite3MPrintf(pParse->db, "%!S", pFrom); | |
| 140779 | 140920 | } |
| 140780 | 140921 | while( pSel->pPrior ){ pSel = pSel->pPrior; } |
| 140781 | 140922 | sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); |
| 140782 | 140923 | pTab->iPKey = -1; |
| 140783 | 140924 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| @@ -141026,39 +141167,42 @@ | ||
| 141026 | 141167 | assert( pE->pLeft!=0 ); |
| 141027 | 141168 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 141028 | 141169 | zTName = pE->pLeft->u.zToken; |
| 141029 | 141170 | } |
| 141030 | 141171 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 141031 | - Table *pTab = pFrom->pTab; | |
| 141032 | - Select *pSub; | |
| 141033 | - char *zTabName = pFrom->zAlias; | |
| 141034 | - const char *zSchemaName = 0; | |
| 141035 | - int iDb; | |
| 141036 | - if( zTabName==0 ){ | |
| 141172 | + Table *pTab = pFrom->pTab; /* Table for this data source */ | |
| 141173 | + ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ | |
| 141174 | + char *zTabName; /* AS name for this data source */ | |
| 141175 | + const char *zSchemaName = 0; /* Schema name for this data source */ | |
| 141176 | + int iDb; /* Schema index for this data src */ | |
| 141177 | + | |
| 141178 | + if( (zTabName = pFrom->zAlias)==0 ){ | |
| 141037 | 141179 | zTabName = pTab->zName; |
| 141038 | 141180 | } |
| 141039 | 141181 | if( db->mallocFailed ) break; |
| 141040 | 141182 | assert( pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) ); |
| 141041 | 141183 | if( pFrom->fg.isNestedFrom ){ |
| 141042 | - pSub = pFrom->pSelect; | |
| 141043 | - assert( pSub->pEList!=0 ); | |
| 141044 | - assert( pSub->pEList->nExpr==pTab->nCol ); | |
| 141184 | + assert( pFrom->pSelect!=0 ); | |
| 141185 | + pNestedFrom = pFrom->pSelect->pEList; | |
| 141186 | + assert( pNestedFrom!=0 ); | |
| 141187 | + assert( pNestedFrom->nExpr==pTab->nCol ); | |
| 141045 | 141188 | }else{ |
| 141046 | - pSub = 0; | |
| 141047 | 141189 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 141048 | 141190 | continue; |
| 141049 | 141191 | } |
| 141192 | + pNestedFrom = 0; | |
| 141050 | 141193 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 141051 | 141194 | zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*"; |
| 141052 | 141195 | } |
| 141053 | 141196 | for(j=0; j<pTab->nCol; j++){ |
| 141054 | 141197 | char *zName = pTab->aCol[j].zCnName; |
| 141055 | 141198 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 141056 | 141199 | |
| 141057 | 141200 | assert( zName ); |
| 141058 | - if( zTName && pSub | |
| 141059 | - && sqlite3MatchEName(&pSub->pEList->a[j], 0, zTName, 0)==0 | |
| 141201 | + if( zTName | |
| 141202 | + && pNestedFrom | |
| 141203 | + && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0)==0 | |
| 141060 | 141204 | ){ |
| 141061 | 141205 | continue; |
| 141062 | 141206 | } |
| 141063 | 141207 | |
| 141064 | 141208 | /* If a column is marked as 'hidden', omit it from the expanded |
| @@ -141107,12 +141251,12 @@ | ||
| 141107 | 141251 | break; /* OOM */ |
| 141108 | 141252 | } |
| 141109 | 141253 | pX = &pNew->a[pNew->nExpr-1]; |
| 141110 | 141254 | assert( pX->zEName==0 ); |
| 141111 | 141255 | if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ |
| 141112 | - if( pSub ){ | |
| 141113 | - pX->zEName = sqlite3DbStrDup(db, pSub->pEList->a[j].zEName); | |
| 141256 | + if( pNestedFrom ){ | |
| 141257 | + pX->zEName = sqlite3DbStrDup(db, pNestedFrom->a[j].zEName); | |
| 141114 | 141258 | testcase( pX->zEName==0 ); |
| 141115 | 141259 | }else{ |
| 141116 | 141260 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 141117 | 141261 | zSchemaName, zTabName, zName); |
| 141118 | 141262 | testcase( pX->zEName==0 ); |
| @@ -142053,13 +142197,11 @@ | ||
| 142053 | 142197 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 142054 | 142198 | */ |
| 142055 | 142199 | if( OptimizationEnabled(db, SQLITE_PushDown) |
| 142056 | 142200 | && (pItem->fg.isCte==0 |
| 142057 | 142201 | || (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2)) |
| 142058 | - && (pItem->fg.jointype & JT_RIGHT)==0 | |
| 142059 | - && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, | |
| 142060 | - (pItem->fg.jointype & JT_OUTER)!=0) | |
| 142202 | + && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem) | |
| 142061 | 142203 | ){ |
| 142062 | 142204 | #if TREETRACE_ENABLED |
| 142063 | 142205 | if( sqlite3TreeTrace & 0x100 ){ |
| 142064 | 142206 | SELECTTRACE(0x100,pParse,p, |
| 142065 | 142207 | ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); |
| @@ -148109,10 +148251,11 @@ | ||
| 148109 | 148251 | struct WhereRightJoin { |
| 148110 | 148252 | int iMatch; /* Cursor used to determine prior matched rows */ |
| 148111 | 148253 | int regBloom; /* Bloom filter for iRJMatch */ |
| 148112 | 148254 | int regReturn; /* Return register for the interior subroutine */ |
| 148113 | 148255 | int addrSubrtn; /* Starting address for the interior subroutine */ |
| 148256 | + int endSubrtn; /* The last opcode in the interior subroutine */ | |
| 148114 | 148257 | }; |
| 148115 | 148258 | |
| 148116 | 148259 | /* |
| 148117 | 148260 | ** This object contains information needed to implement a single nested |
| 148118 | 148261 | ** loop in WHERE clause. |
| @@ -151508,10 +151651,12 @@ | ||
| 151508 | 151651 | SrcList sFrom; |
| 151509 | 151652 | Bitmask mAll = 0; |
| 151510 | 151653 | int k; |
| 151511 | 151654 | |
| 151512 | 151655 | ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pTab->zName)); |
| 151656 | + sqlite3VdbeNoJumpsOutsideSubrtn(v, pRJ->addrSubrtn, pRJ->endSubrtn, | |
| 151657 | + pRJ->regReturn); | |
| 151513 | 151658 | for(k=0; k<iLevel; k++){ |
| 151514 | 151659 | int iIdxCur; |
| 151515 | 151660 | mAll |= pWInfo->a[k].pWLoop->maskSelf; |
| 151516 | 151661 | sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); |
| 151517 | 151662 | iIdxCur = pWInfo->a[k].iIdxCur; |
| @@ -153516,11 +153661,11 @@ | ||
| 153516 | 153661 | ** continuation of the inner-most loop. */ |
| 153517 | 153662 | return pWInfo->iContinue; |
| 153518 | 153663 | } |
| 153519 | 153664 | pInner = &pWInfo->a[pWInfo->nLevel-1]; |
| 153520 | 153665 | assert( pInner->addrNxt!=0 ); |
| 153521 | - return pInner->addrNxt; | |
| 153666 | + return pInner->pRJ ? pWInfo->iContinue : pInner->addrNxt; | |
| 153522 | 153667 | } |
| 153523 | 153668 | |
| 153524 | 153669 | /* |
| 153525 | 153670 | ** While generating code for the min/max optimization, after handling |
| 153526 | 153671 | ** the aggregate-step call to min() or max(), check to see if any |
| @@ -154246,13 +154391,11 @@ | ||
| 154246 | 154391 | Expr *pExpr = pTerm->pExpr; |
| 154247 | 154392 | /* Make the automatic index a partial index if there are terms in the |
| 154248 | 154393 | ** WHERE clause (or the ON clause of a LEFT join) that constrain which |
| 154249 | 154394 | ** rows of the target table (pSrc) that can be used. */ |
| 154250 | 154395 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 154251 | - && ((pSrc->fg.jointype&(JT_LEFT|JT_LTORJ))==0 | |
| 154252 | - || ExprHasProperty(pExpr,EP_FromJoin)) | |
| 154253 | - && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) | |
| 154396 | + && sqlite3ExprIsTableConstraint(pExpr, pSrc) | |
| 154254 | 154397 | ){ |
| 154255 | 154398 | pPartial = sqlite3ExprAnd(pParse, pPartial, |
| 154256 | 154399 | sqlite3ExprDup(pParse->db, pExpr, 0)); |
| 154257 | 154400 | } |
| 154258 | 154401 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| @@ -154487,11 +154630,11 @@ | ||
| 154487 | 154630 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); |
| 154488 | 154631 | pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm]; |
| 154489 | 154632 | for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){ |
| 154490 | 154633 | Expr *pExpr = pTerm->pExpr; |
| 154491 | 154634 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 154492 | - && sqlite3ExprIsTableConstant(pExpr, iCur) | |
| 154635 | + && sqlite3ExprIsTableConstraint(pExpr, pItem) | |
| 154493 | 154636 | ){ |
| 154494 | 154637 | sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); |
| 154495 | 154638 | } |
| 154496 | 154639 | } |
| 154497 | 154640 | if( pLoop->wsFlags & WHERE_IPK ){ |
| @@ -159438,10 +159581,11 @@ | ||
| 159438 | 159581 | /* Terminate the subroutine that forms the interior of the loop of |
| 159439 | 159582 | ** the RIGHT JOIN table */ |
| 159440 | 159583 | WhereRightJoin *pRJ = pLevel->pRJ; |
| 159441 | 159584 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 159442 | 159585 | pLevel->addrCont = 0; |
| 159586 | + pRJ->endSubrtn = sqlite3VdbeCurrentAddr(v); | |
| 159443 | 159587 | sqlite3VdbeAddOp3(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn, 1); |
| 159444 | 159588 | VdbeCoverage(v); |
| 159445 | 159589 | assert( pParse->withinRJSubrtn>0 ); |
| 159446 | 159590 | pParse->withinRJSubrtn--; |
| 159447 | 159591 | } |
| @@ -235980,11 +236124,11 @@ | ||
| 235980 | 236124 | int nArg, /* Number of args */ |
| 235981 | 236125 | sqlite3_value **apUnused /* Function arguments */ |
| 235982 | 236126 | ){ |
| 235983 | 236127 | assert( nArg==0 ); |
| 235984 | 236128 | UNUSED_PARAM2(nArg, apUnused); |
| 235985 | - sqlite3_result_text(pCtx, "fts5: 2022-04-19 15:56:03 b966d52437f08a6759a83a45cafb0d706a8933a8e55dee38ae78166d1a5b3ba4", -1, SQLITE_TRANSIENT); | |
| 236129 | + sqlite3_result_text(pCtx, "fts5: 2022-04-26 19:16:11 b1bec72043f798f4d4d30e6b60a45ed4dc521115c8a9f97bb8228e3f089deefb", -1, SQLITE_TRANSIENT); | |
| 235986 | 236130 | } |
| 235987 | 236131 | |
| 235988 | 236132 | /* |
| 235989 | 236133 | ** Return true if zName is the extension on one of the shadow tables used |
| 235990 | 236134 | ** by this module. |
| 235991 | 236135 |
| --- 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-04-21 19:38:17 f766dff012af0ea3c28a8ce4db850cd0205729a8283bce1e442992aded7c734b" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -15790,12 +15790,14 @@ | |
| 15790 | # define sqlite3VdbeVerifyNoMallocRequired(A,B) |
| 15791 | # define sqlite3VdbeVerifyNoResultRow(A) |
| 15792 | #endif |
| 15793 | #if defined(SQLITE_DEBUG) |
| 15794 | SQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int); |
| 15795 | #else |
| 15796 | # define sqlite3VdbeVerifyAbortable(A,B) |
| 15797 | #endif |
| 15798 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno); |
| 15799 | #ifndef SQLITE_OMIT_EXPLAIN |
| 15800 | SQLITE_PRIVATE void sqlite3VdbeExplain(Parse*,u8,const char*,...); |
| 15801 | SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse*); |
| @@ -17051,10 +17053,11 @@ | |
| 17051 | /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ |
| 17052 | #define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */ |
| 17053 | #define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */ |
| 17054 | #define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */ |
| 17055 | #define SQLITE_ReleaseReg 0x00400000 /* Use OP_ReleaseReg for testing */ |
| 17056 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17057 | |
| 17058 | /* |
| 17059 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| 17060 | */ |
| @@ -20022,10 +20025,11 @@ | |
| 20022 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); |
| 20023 | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*); |
| 20024 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 20025 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); |
| 20026 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); |
| 20027 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 20028 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 20029 | #endif |
| 20030 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20031 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| @@ -30462,12 +30466,18 @@ | |
| 30462 | sqlite3_str_append(pAccum, ".", 1); |
| 30463 | } |
| 30464 | sqlite3_str_appendall(pAccum, pItem->zName); |
| 30465 | }else if( pItem->zAlias ){ |
| 30466 | sqlite3_str_appendall(pAccum, pItem->zAlias); |
| 30467 | }else if( ALWAYS(pItem->pSelect) ){ |
| 30468 | sqlite3_str_appendf(pAccum, "SUBQUERY %u", pItem->pSelect->selId); |
| 30469 | } |
| 30470 | length = width = 0; |
| 30471 | break; |
| 30472 | } |
| 30473 | default: { |
| @@ -31077,10 +31087,14 @@ | |
| 31077 | sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zEName); |
| 31078 | cSep = ','; |
| 31079 | } |
| 31080 | sqlite3_str_appendf(&x, ")"); |
| 31081 | } |
| 31082 | if( pCte->pUse ){ |
| 31083 | sqlite3_str_appendf(&x, " (pUse=0x%p, nUse=%d)", pCte->pUse, |
| 31084 | pCte->pUse->nUse); |
| 31085 | } |
| 31086 | sqlite3StrAccumFinish(&x); |
| @@ -81423,10 +81437,94 @@ | |
| 81423 | pParse->nLabel = 0; |
| 81424 | *pMaxFuncArgs = nMaxArgs; |
| 81425 | assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) ); |
| 81426 | } |
| 81427 | |
| 81428 | /* |
| 81429 | ** Return the address of the next instruction to be inserted. |
| 81430 | */ |
| 81431 | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){ |
| 81432 | assert( p->eVdbeState==VDBE_INIT_STATE ); |
| @@ -104911,10 +105009,11 @@ | |
| 104911 | pRet->nCte = p->nCte; |
| 104912 | for(i=0; i<p->nCte; i++){ |
| 104913 | pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0); |
| 104914 | pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0); |
| 104915 | pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName); |
| 104916 | } |
| 104917 | } |
| 104918 | } |
| 104919 | return pRet; |
| 104920 | } |
| @@ -105678,10 +105777,46 @@ | |
| 105678 | ** table other than iCur. |
| 105679 | */ |
| 105680 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){ |
| 105681 | return exprIsConst(p, 3, iCur); |
| 105682 | } |
| 105683 | |
| 105684 | |
| 105685 | /* |
| 105686 | ** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). |
| 105687 | */ |
| @@ -115001,13 +115136,11 @@ | |
| 115001 | Returning *pReturning = pParse->u1.pReturning; |
| 115002 | int addrRewind; |
| 115003 | int i; |
| 115004 | int reg; |
| 115005 | |
| 115006 | if( NEVER(pReturning->nRetCol==0) ){ |
| 115007 | assert( CORRUPT_DB ); |
| 115008 | }else{ |
| 115009 | sqlite3VdbeAddOp0(v, OP_FkCheck); |
| 115010 | addrRewind = |
| 115011 | sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur); |
| 115012 | VdbeCoverage(v); |
| 115013 | reg = pReturning->iRetReg; |
| @@ -115099,13 +115232,11 @@ | |
| 115099 | } |
| 115100 | } |
| 115101 | |
| 115102 | if( pParse->bReturning ){ |
| 115103 | Returning *pRet = pParse->u1.pReturning; |
| 115104 | if( NEVER(pRet->nRetCol==0) ){ |
| 115105 | assert( CORRUPT_DB ); |
| 115106 | }else{ |
| 115107 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol); |
| 115108 | } |
| 115109 | } |
| 115110 | |
| 115111 | /* Finally, jump back to the beginning of the executable code. */ |
| @@ -117888,11 +118019,10 @@ | |
| 117888 | */ |
| 117889 | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ |
| 117890 | Table *pSelTab; /* A fake table from which we get the result set */ |
| 117891 | Select *pSel; /* Copy of the SELECT that implements the view */ |
| 117892 | int nErr = 0; /* Number of errors encountered */ |
| 117893 | int n; /* Temporarily holds the number of cursors assigned */ |
| 117894 | sqlite3 *db = pParse->db; /* Database connection for malloc errors */ |
| 117895 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 117896 | int rc; |
| 117897 | #endif |
| 117898 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| @@ -117946,12 +118076,13 @@ | |
| 117946 | */ |
| 117947 | assert( IsView(pTable) ); |
| 117948 | pSel = sqlite3SelectDup(db, pTable->u.view.pSelect, 0); |
| 117949 | if( pSel ){ |
| 117950 | u8 eParseMode = pParse->eParseMode; |
| 117951 | pParse->eParseMode = PARSE_MODE_NORMAL; |
| 117952 | n = pParse->nTab; |
| 117953 | sqlite3SrcListAssignCursors(pParse, pSel->pSrc); |
| 117954 | pTable->nCol = -1; |
| 117955 | DisableLookaside; |
| 117956 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 117957 | xAuth = db->xAuth; |
| @@ -117959,11 +118090,12 @@ | |
| 117959 | pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); |
| 117960 | db->xAuth = xAuth; |
| 117961 | #else |
| 117962 | pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); |
| 117963 | #endif |
| 117964 | pParse->nTab = n; |
| 117965 | if( pSelTab==0 ){ |
| 117966 | pTable->nCol = 0; |
| 117967 | nErr++; |
| 117968 | }else if( pTable->pCheck ){ |
| 117969 | /* CREATE VIEW name(arglist) AS ... |
| @@ -139375,10 +139507,12 @@ | |
| 139375 | ** See also (3) for restrictions on LEFT JOIN. |
| 139376 | ** |
| 139377 | ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 139378 | ** is the first element of the parent query. |
| 139379 | ** |
| 139380 | ** |
| 139381 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 139382 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 139383 | ** uses aggregates. |
| 139384 | ** |
| @@ -139498,10 +139632,13 @@ | |
| 139498 | |
| 139499 | assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 139500 | if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 139501 | return 0; /* Restriction (27) */ |
| 139502 | } |
| 139503 | |
| 139504 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 139505 | ** use only the UNION ALL operator. And none of the simple select queries |
| 139506 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 139507 | ** queries. |
| @@ -139542,10 +139679,11 @@ | |
| 139542 | /* Restriction (23) */ |
| 139543 | if( (p->selFlags & SF_Recursive) ) return 0; |
| 139544 | |
| 139545 | if( pSrc->nSrc>1 ){ |
| 139546 | if( pParse->nSelect>500 ) return 0; |
| 139547 | aCsrMap = sqlite3DbMallocZero(db, ((i64)pParse->nTab+1)*sizeof(int)); |
| 139548 | if( aCsrMap ) aCsrMap[0] = pParse->nTab; |
| 139549 | } |
| 139550 | } |
| 139551 | |
| @@ -140170,17 +140308,17 @@ | |
| 140170 | */ |
| 140171 | static int pushDownWhereTerms( |
| 140172 | Parse *pParse, /* Parse context (for malloc() and error reporting) */ |
| 140173 | Select *pSubq, /* The subquery whose WHERE clause is to be augmented */ |
| 140174 | Expr *pWhere, /* The WHERE clause of the outer query */ |
| 140175 | int iCursor, /* Cursor number of the subquery */ |
| 140176 | int isLeftJoin /* True if pSubq is the right term of a LEFT JOIN */ |
| 140177 | ){ |
| 140178 | Expr *pNew; |
| 140179 | int nChng = 0; |
| 140180 | if( pWhere==0 ) return 0; |
| 140181 | if( pSubq->selFlags & (SF_Recursive|SF_MultiPart) ) return 0; |
| 140182 | |
| 140183 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140184 | if( pSubq->pPrior ){ |
| 140185 | Select *pSel; |
| 140186 | for(pSel=pSubq; pSel; pSel=pSel->pPrior){ |
| @@ -140206,14 +140344,15 @@ | |
| 140206 | |
| 140207 | if( pSubq->pLimit!=0 ){ |
| 140208 | return 0; /* restriction (3) */ |
| 140209 | } |
| 140210 | while( pWhere->op==TK_AND ){ |
| 140211 | nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, |
| 140212 | iCursor, isLeftJoin); |
| 140213 | pWhere = pWhere->pLeft; |
| 140214 | } |
| 140215 | if( isLeftJoin |
| 140216 | && (ExprHasProperty(pWhere,EP_FromJoin)==0 |
| 140217 | || pWhere->w.iJoin!=iCursor) |
| 140218 | ){ |
| 140219 | return 0; /* restriction (4) */ |
| @@ -140221,20 +140360,22 @@ | |
| 140221 | if( ExprHasProperty(pWhere,EP_FromJoin) |
| 140222 | && pWhere->w.iJoin!=iCursor |
| 140223 | ){ |
| 140224 | return 0; /* restriction (5) */ |
| 140225 | } |
| 140226 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ |
| 140227 | nChng++; |
| 140228 | pSubq->selFlags |= SF_PushDown; |
| 140229 | while( pSubq ){ |
| 140230 | SubstContext x; |
| 140231 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| 140232 | unsetJoinExpr(pNew, -1); |
| 140233 | x.pParse = pParse; |
| 140234 | x.iTable = iCursor; |
| 140235 | x.iNewTable = iCursor; |
| 140236 | x.isOuterJoin = 0; |
| 140237 | x.pEList = pSubq->pEList; |
| 140238 | pNew = substExpr(&x, pNew); |
| 140239 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140240 | if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){ |
| @@ -140773,11 +140914,11 @@ | |
| 140773 | if( pTab==0 ) return SQLITE_NOMEM; |
| 140774 | pTab->nTabRef = 1; |
| 140775 | if( pFrom->zAlias ){ |
| 140776 | pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias); |
| 140777 | }else{ |
| 140778 | pTab->zName = sqlite3MPrintf(pParse->db, "subquery_%u", pSel->selId); |
| 140779 | } |
| 140780 | while( pSel->pPrior ){ pSel = pSel->pPrior; } |
| 140781 | sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); |
| 140782 | pTab->iPKey = -1; |
| 140783 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| @@ -141026,39 +141167,42 @@ | |
| 141026 | assert( pE->pLeft!=0 ); |
| 141027 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 141028 | zTName = pE->pLeft->u.zToken; |
| 141029 | } |
| 141030 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 141031 | Table *pTab = pFrom->pTab; |
| 141032 | Select *pSub; |
| 141033 | char *zTabName = pFrom->zAlias; |
| 141034 | const char *zSchemaName = 0; |
| 141035 | int iDb; |
| 141036 | if( zTabName==0 ){ |
| 141037 | zTabName = pTab->zName; |
| 141038 | } |
| 141039 | if( db->mallocFailed ) break; |
| 141040 | assert( pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) ); |
| 141041 | if( pFrom->fg.isNestedFrom ){ |
| 141042 | pSub = pFrom->pSelect; |
| 141043 | assert( pSub->pEList!=0 ); |
| 141044 | assert( pSub->pEList->nExpr==pTab->nCol ); |
| 141045 | }else{ |
| 141046 | pSub = 0; |
| 141047 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 141048 | continue; |
| 141049 | } |
| 141050 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 141051 | zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*"; |
| 141052 | } |
| 141053 | for(j=0; j<pTab->nCol; j++){ |
| 141054 | char *zName = pTab->aCol[j].zCnName; |
| 141055 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 141056 | |
| 141057 | assert( zName ); |
| 141058 | if( zTName && pSub |
| 141059 | && sqlite3MatchEName(&pSub->pEList->a[j], 0, zTName, 0)==0 |
| 141060 | ){ |
| 141061 | continue; |
| 141062 | } |
| 141063 | |
| 141064 | /* If a column is marked as 'hidden', omit it from the expanded |
| @@ -141107,12 +141251,12 @@ | |
| 141107 | break; /* OOM */ |
| 141108 | } |
| 141109 | pX = &pNew->a[pNew->nExpr-1]; |
| 141110 | assert( pX->zEName==0 ); |
| 141111 | if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ |
| 141112 | if( pSub ){ |
| 141113 | pX->zEName = sqlite3DbStrDup(db, pSub->pEList->a[j].zEName); |
| 141114 | testcase( pX->zEName==0 ); |
| 141115 | }else{ |
| 141116 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 141117 | zSchemaName, zTabName, zName); |
| 141118 | testcase( pX->zEName==0 ); |
| @@ -142053,13 +142197,11 @@ | |
| 142053 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 142054 | */ |
| 142055 | if( OptimizationEnabled(db, SQLITE_PushDown) |
| 142056 | && (pItem->fg.isCte==0 |
| 142057 | || (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2)) |
| 142058 | && (pItem->fg.jointype & JT_RIGHT)==0 |
| 142059 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, |
| 142060 | (pItem->fg.jointype & JT_OUTER)!=0) |
| 142061 | ){ |
| 142062 | #if TREETRACE_ENABLED |
| 142063 | if( sqlite3TreeTrace & 0x100 ){ |
| 142064 | SELECTTRACE(0x100,pParse,p, |
| 142065 | ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); |
| @@ -148109,10 +148251,11 @@ | |
| 148109 | struct WhereRightJoin { |
| 148110 | int iMatch; /* Cursor used to determine prior matched rows */ |
| 148111 | int regBloom; /* Bloom filter for iRJMatch */ |
| 148112 | int regReturn; /* Return register for the interior subroutine */ |
| 148113 | int addrSubrtn; /* Starting address for the interior subroutine */ |
| 148114 | }; |
| 148115 | |
| 148116 | /* |
| 148117 | ** This object contains information needed to implement a single nested |
| 148118 | ** loop in WHERE clause. |
| @@ -151508,10 +151651,12 @@ | |
| 151508 | SrcList sFrom; |
| 151509 | Bitmask mAll = 0; |
| 151510 | int k; |
| 151511 | |
| 151512 | ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pTab->zName)); |
| 151513 | for(k=0; k<iLevel; k++){ |
| 151514 | int iIdxCur; |
| 151515 | mAll |= pWInfo->a[k].pWLoop->maskSelf; |
| 151516 | sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); |
| 151517 | iIdxCur = pWInfo->a[k].iIdxCur; |
| @@ -153516,11 +153661,11 @@ | |
| 153516 | ** continuation of the inner-most loop. */ |
| 153517 | return pWInfo->iContinue; |
| 153518 | } |
| 153519 | pInner = &pWInfo->a[pWInfo->nLevel-1]; |
| 153520 | assert( pInner->addrNxt!=0 ); |
| 153521 | return pInner->addrNxt; |
| 153522 | } |
| 153523 | |
| 153524 | /* |
| 153525 | ** While generating code for the min/max optimization, after handling |
| 153526 | ** the aggregate-step call to min() or max(), check to see if any |
| @@ -154246,13 +154391,11 @@ | |
| 154246 | Expr *pExpr = pTerm->pExpr; |
| 154247 | /* Make the automatic index a partial index if there are terms in the |
| 154248 | ** WHERE clause (or the ON clause of a LEFT join) that constrain which |
| 154249 | ** rows of the target table (pSrc) that can be used. */ |
| 154250 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 154251 | && ((pSrc->fg.jointype&(JT_LEFT|JT_LTORJ))==0 |
| 154252 | || ExprHasProperty(pExpr,EP_FromJoin)) |
| 154253 | && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) |
| 154254 | ){ |
| 154255 | pPartial = sqlite3ExprAnd(pParse, pPartial, |
| 154256 | sqlite3ExprDup(pParse->db, pExpr, 0)); |
| 154257 | } |
| 154258 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| @@ -154487,11 +154630,11 @@ | |
| 154487 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); |
| 154488 | pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm]; |
| 154489 | for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){ |
| 154490 | Expr *pExpr = pTerm->pExpr; |
| 154491 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 154492 | && sqlite3ExprIsTableConstant(pExpr, iCur) |
| 154493 | ){ |
| 154494 | sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); |
| 154495 | } |
| 154496 | } |
| 154497 | if( pLoop->wsFlags & WHERE_IPK ){ |
| @@ -159438,10 +159581,11 @@ | |
| 159438 | /* Terminate the subroutine that forms the interior of the loop of |
| 159439 | ** the RIGHT JOIN table */ |
| 159440 | WhereRightJoin *pRJ = pLevel->pRJ; |
| 159441 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 159442 | pLevel->addrCont = 0; |
| 159443 | sqlite3VdbeAddOp3(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn, 1); |
| 159444 | VdbeCoverage(v); |
| 159445 | assert( pParse->withinRJSubrtn>0 ); |
| 159446 | pParse->withinRJSubrtn--; |
| 159447 | } |
| @@ -235980,11 +236124,11 @@ | |
| 235980 | int nArg, /* Number of args */ |
| 235981 | sqlite3_value **apUnused /* Function arguments */ |
| 235982 | ){ |
| 235983 | assert( nArg==0 ); |
| 235984 | UNUSED_PARAM2(nArg, apUnused); |
| 235985 | sqlite3_result_text(pCtx, "fts5: 2022-04-19 15:56:03 b966d52437f08a6759a83a45cafb0d706a8933a8e55dee38ae78166d1a5b3ba4", -1, SQLITE_TRANSIENT); |
| 235986 | } |
| 235987 | |
| 235988 | /* |
| 235989 | ** Return true if zName is the extension on one of the shadow tables used |
| 235990 | ** by this module. |
| 235991 |
| --- 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-04-26 19:16:11 b1bec72043f798f4d4d30e6b60a45ed4dc521115c8a9f97bb8228e3f089deefb" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -15790,12 +15790,14 @@ | |
| 15790 | # define sqlite3VdbeVerifyNoMallocRequired(A,B) |
| 15791 | # define sqlite3VdbeVerifyNoResultRow(A) |
| 15792 | #endif |
| 15793 | #if defined(SQLITE_DEBUG) |
| 15794 | SQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int); |
| 15795 | SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn(Vdbe*,int,int,int); |
| 15796 | #else |
| 15797 | # define sqlite3VdbeVerifyAbortable(A,B) |
| 15798 | # define sqlite3VdbeNoJumpsOutsideSubrtn(A,B,C,D) |
| 15799 | #endif |
| 15800 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno); |
| 15801 | #ifndef SQLITE_OMIT_EXPLAIN |
| 15802 | SQLITE_PRIVATE void sqlite3VdbeExplain(Parse*,u8,const char*,...); |
| 15803 | SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse*); |
| @@ -17051,10 +17053,11 @@ | |
| 17053 | /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ |
| 17054 | #define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */ |
| 17055 | #define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */ |
| 17056 | #define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */ |
| 17057 | #define SQLITE_ReleaseReg 0x00400000 /* Use OP_ReleaseReg for testing */ |
| 17058 | #define SQLITE_FlttnUnionAll 0x00800000 /* Disable the UNION ALL flattener */ |
| 17059 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17060 | |
| 17061 | /* |
| 17062 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| 17063 | */ |
| @@ -20022,10 +20025,11 @@ | |
| 20025 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); |
| 20026 | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*); |
| 20027 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 20028 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); |
| 20029 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); |
| 20030 | SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr*,const SrcItem*); |
| 20031 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 20032 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 20033 | #endif |
| 20034 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20035 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| @@ -30462,12 +30466,18 @@ | |
| 30466 | sqlite3_str_append(pAccum, ".", 1); |
| 30467 | } |
| 30468 | sqlite3_str_appendall(pAccum, pItem->zName); |
| 30469 | }else if( pItem->zAlias ){ |
| 30470 | sqlite3_str_appendall(pAccum, pItem->zAlias); |
| 30471 | }else{ |
| 30472 | Select *pSel = pItem->pSelect; |
| 30473 | assert( pSel!=0 ); |
| 30474 | if( pSel->selFlags & SF_NestedFrom ){ |
| 30475 | sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId); |
| 30476 | }else{ |
| 30477 | sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId); |
| 30478 | } |
| 30479 | } |
| 30480 | length = width = 0; |
| 30481 | break; |
| 30482 | } |
| 30483 | default: { |
| @@ -31077,10 +31087,14 @@ | |
| 31087 | sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zEName); |
| 31088 | cSep = ','; |
| 31089 | } |
| 31090 | sqlite3_str_appendf(&x, ")"); |
| 31091 | } |
| 31092 | if( pCte->eM10d!=M10d_Any ){ |
| 31093 | sqlite3_str_appendf(&x, " %sMATERIALIZED", |
| 31094 | pCte->eM10d==M10d_No ? "NOT " : ""); |
| 31095 | } |
| 31096 | if( pCte->pUse ){ |
| 31097 | sqlite3_str_appendf(&x, " (pUse=0x%p, nUse=%d)", pCte->pUse, |
| 31098 | pCte->pUse->nUse); |
| 31099 | } |
| 31100 | sqlite3StrAccumFinish(&x); |
| @@ -81423,10 +81437,94 @@ | |
| 81437 | pParse->nLabel = 0; |
| 81438 | *pMaxFuncArgs = nMaxArgs; |
| 81439 | assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) ); |
| 81440 | } |
| 81441 | |
| 81442 | #ifdef SQLITE_DEBUG |
| 81443 | /* |
| 81444 | ** Check to see if a subroutine contains a jump to a location outside of |
| 81445 | ** the subroutine. If a jump outside the subroutine is detected, add code |
| 81446 | ** that will cause the program to halt with an error message. |
| 81447 | ** |
| 81448 | ** The subroutine consists of opcodes between iFirst and iLast. Jumps to |
| 81449 | ** locations within the subroutine are acceptable. iRetReg is a register |
| 81450 | ** that contains the return address. Jumps to outside the range of iFirst |
| 81451 | ** through iLast are also acceptable as long as the jump destination is |
| 81452 | ** an OP_Return to iReturnAddr. |
| 81453 | ** |
| 81454 | ** A jump to an unresolved label means that the jump destination will be |
| 81455 | ** beyond the current address. That is normally a jump to an early |
| 81456 | ** termination and is consider acceptable. |
| 81457 | ** |
| 81458 | ** This routine only runs during debug builds. The purpose is (of course) |
| 81459 | ** to detect invalid escapes out of a subroutine. The OP_Halt opcode |
| 81460 | ** is generated rather than an assert() or other error, so that ".eqp full" |
| 81461 | ** will still work to show the original bytecode, to aid in debugging. |
| 81462 | */ |
| 81463 | SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn( |
| 81464 | Vdbe *v, /* The byte-code program under construction */ |
| 81465 | int iFirst, /* First opcode of the subroutine */ |
| 81466 | int iLast, /* Last opcode of the subroutine */ |
| 81467 | int iRetReg /* Subroutine return address register */ |
| 81468 | ){ |
| 81469 | VdbeOp *pOp; |
| 81470 | Parse *pParse; |
| 81471 | int i; |
| 81472 | sqlite3_str *pErr = 0; |
| 81473 | assert( v!=0 ); |
| 81474 | pParse = v->pParse; |
| 81475 | assert( pParse!=0 ); |
| 81476 | if( pParse->nErr ) return; |
| 81477 | assert( iLast>=iFirst ); |
| 81478 | assert( iLast<v->nOp ); |
| 81479 | pOp = &v->aOp[iFirst]; |
| 81480 | for(i=iFirst; i<=iLast; i++, pOp++){ |
| 81481 | if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ){ |
| 81482 | int iDest = pOp->p2; /* Jump destination */ |
| 81483 | if( iDest==0 ) continue; |
| 81484 | if( pOp->opcode==OP_Gosub ) continue; |
| 81485 | if( iDest<0 ){ |
| 81486 | int j = ADDR(iDest); |
| 81487 | assert( j>=0 ); |
| 81488 | if( j>=-pParse->nLabel || pParse->aLabel[j]<0 ){ |
| 81489 | continue; |
| 81490 | } |
| 81491 | iDest = pParse->aLabel[j]; |
| 81492 | } |
| 81493 | if( iDest<iFirst || iDest>iLast ){ |
| 81494 | int j = iDest; |
| 81495 | for(; j<v->nOp; j++){ |
| 81496 | VdbeOp *pX = &v->aOp[j]; |
| 81497 | if( pX->opcode==OP_Return ){ |
| 81498 | if( pX->p1==iRetReg ) break; |
| 81499 | continue; |
| 81500 | } |
| 81501 | if( pX->opcode==OP_Noop ) continue; |
| 81502 | if( pX->opcode==OP_Explain ) continue; |
| 81503 | if( pErr==0 ){ |
| 81504 | pErr = sqlite3_str_new(0); |
| 81505 | }else{ |
| 81506 | sqlite3_str_appendchar(pErr, 1, '\n'); |
| 81507 | } |
| 81508 | sqlite3_str_appendf(pErr, |
| 81509 | "Opcode at %d jumps to %d which is outside the " |
| 81510 | "subroutine at %d..%d", |
| 81511 | i, iDest, iFirst, iLast); |
| 81512 | break; |
| 81513 | } |
| 81514 | } |
| 81515 | } |
| 81516 | } |
| 81517 | if( pErr ){ |
| 81518 | char *zErr = sqlite3_str_finish(pErr); |
| 81519 | sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_INTERNAL, OE_Abort, 0, zErr, 0); |
| 81520 | sqlite3_free(zErr); |
| 81521 | sqlite3MayAbort(pParse); |
| 81522 | } |
| 81523 | } |
| 81524 | #endif /* SQLITE_DEBUG */ |
| 81525 | |
| 81526 | /* |
| 81527 | ** Return the address of the next instruction to be inserted. |
| 81528 | */ |
| 81529 | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){ |
| 81530 | assert( p->eVdbeState==VDBE_INIT_STATE ); |
| @@ -104911,10 +105009,11 @@ | |
| 105009 | pRet->nCte = p->nCte; |
| 105010 | for(i=0; i<p->nCte; i++){ |
| 105011 | pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0); |
| 105012 | pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0); |
| 105013 | pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName); |
| 105014 | pRet->a[i].eM10d = p->a[i].eM10d; |
| 105015 | } |
| 105016 | } |
| 105017 | } |
| 105018 | return pRet; |
| 105019 | } |
| @@ -105678,10 +105777,46 @@ | |
| 105777 | ** table other than iCur. |
| 105778 | */ |
| 105779 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){ |
| 105780 | return exprIsConst(p, 3, iCur); |
| 105781 | } |
| 105782 | |
| 105783 | /* |
| 105784 | ** Check pExpr to see if it is an invariant constraint on data source pSrc. |
| 105785 | ** This is an optimization. False negatives will perhaps cause slower |
| 105786 | ** queries, but false positives will yield incorrect answers. So when in |
| 105787 | ** double, return 0. |
| 105788 | ** |
| 105789 | ** To be an invariant constraint, the following must be true: |
| 105790 | ** |
| 105791 | ** (1) pExpr cannot refer to any table other than pSrc->iCursor. |
| 105792 | ** |
| 105793 | ** (2) pExpr cannot use subqueries or non-deterministic functions. |
| 105794 | ** |
| 105795 | ** (3) pSrc cannot be part of the left operand for a RIGHT JOIN. |
| 105796 | ** (Is there some way to relax this constraint?) |
| 105797 | ** |
| 105798 | ** (4) If pSrc is the right operand of a LEFT JOIN, then... |
| 105799 | ** (4a) pExpr must come from an ON clause.. |
| 105800 | (4b) and specifically the ON clause associated with the LEFT JOIN. |
| 105801 | ** |
| 105802 | ** (5) If pSrc is not the right operand of a LEFT JOIN or the left |
| 105803 | ** operand of a RIGHT JOIN, then pExpr must be from the WHERE |
| 105804 | ** clause, not an ON clause. |
| 105805 | */ |
| 105806 | SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr *pExpr, const SrcItem *pSrc){ |
| 105807 | if( pSrc->fg.jointype & JT_LTORJ ){ |
| 105808 | return 0; /* rule (3) */ |
| 105809 | } |
| 105810 | if( pSrc->fg.jointype & JT_LEFT ){ |
| 105811 | if( !ExprHasProperty(pExpr, EP_FromJoin) ) return 0; /* rule (4a) */ |
| 105812 | if( pExpr->w.iJoin!=pSrc->iCursor ) return 0; /* rule (4b) */ |
| 105813 | }else{ |
| 105814 | if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0; /* rule (5) */ |
| 105815 | } |
| 105816 | return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor); /* rules (1), (2) */ |
| 105817 | } |
| 105818 | |
| 105819 | |
| 105820 | /* |
| 105821 | ** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). |
| 105822 | */ |
| @@ -115001,13 +115136,11 @@ | |
| 115136 | Returning *pReturning = pParse->u1.pReturning; |
| 115137 | int addrRewind; |
| 115138 | int i; |
| 115139 | int reg; |
| 115140 | |
| 115141 | if( pReturning->nRetCol ){ |
| 115142 | sqlite3VdbeAddOp0(v, OP_FkCheck); |
| 115143 | addrRewind = |
| 115144 | sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur); |
| 115145 | VdbeCoverage(v); |
| 115146 | reg = pReturning->iRetReg; |
| @@ -115099,13 +115232,11 @@ | |
| 115232 | } |
| 115233 | } |
| 115234 | |
| 115235 | if( pParse->bReturning ){ |
| 115236 | Returning *pRet = pParse->u1.pReturning; |
| 115237 | if( pRet->nRetCol ){ |
| 115238 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol); |
| 115239 | } |
| 115240 | } |
| 115241 | |
| 115242 | /* Finally, jump back to the beginning of the executable code. */ |
| @@ -117888,11 +118019,10 @@ | |
| 118019 | */ |
| 118020 | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ |
| 118021 | Table *pSelTab; /* A fake table from which we get the result set */ |
| 118022 | Select *pSel; /* Copy of the SELECT that implements the view */ |
| 118023 | int nErr = 0; /* Number of errors encountered */ |
| 118024 | sqlite3 *db = pParse->db; /* Database connection for malloc errors */ |
| 118025 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 118026 | int rc; |
| 118027 | #endif |
| 118028 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| @@ -117946,12 +118076,13 @@ | |
| 118076 | */ |
| 118077 | assert( IsView(pTable) ); |
| 118078 | pSel = sqlite3SelectDup(db, pTable->u.view.pSelect, 0); |
| 118079 | if( pSel ){ |
| 118080 | u8 eParseMode = pParse->eParseMode; |
| 118081 | int nTab = pParse->nTab; |
| 118082 | int nSelect = pParse->nSelect; |
| 118083 | pParse->eParseMode = PARSE_MODE_NORMAL; |
| 118084 | sqlite3SrcListAssignCursors(pParse, pSel->pSrc); |
| 118085 | pTable->nCol = -1; |
| 118086 | DisableLookaside; |
| 118087 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 118088 | xAuth = db->xAuth; |
| @@ -117959,11 +118090,12 @@ | |
| 118090 | pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); |
| 118091 | db->xAuth = xAuth; |
| 118092 | #else |
| 118093 | pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); |
| 118094 | #endif |
| 118095 | pParse->nTab = nTab; |
| 118096 | pParse->nSelect = nSelect; |
| 118097 | if( pSelTab==0 ){ |
| 118098 | pTable->nCol = 0; |
| 118099 | nErr++; |
| 118100 | }else if( pTable->pCheck ){ |
| 118101 | /* CREATE VIEW name(arglist) AS ... |
| @@ -139375,10 +139507,12 @@ | |
| 139507 | ** See also (3) for restrictions on LEFT JOIN. |
| 139508 | ** |
| 139509 | ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 139510 | ** is the first element of the parent query. |
| 139511 | ** |
| 139512 | ** (28) The subquery is not a MATERIALIZED CTE. |
| 139513 | ** |
| 139514 | ** |
| 139515 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 139516 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 139517 | ** uses aggregates. |
| 139518 | ** |
| @@ -139498,10 +139632,13 @@ | |
| 139632 | |
| 139633 | assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 139634 | if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 139635 | return 0; /* Restriction (27) */ |
| 139636 | } |
| 139637 | if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ |
| 139638 | return 0; /* (28) */ |
| 139639 | } |
| 139640 | |
| 139641 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 139642 | ** use only the UNION ALL operator. And none of the simple select queries |
| 139643 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 139644 | ** queries. |
| @@ -139542,10 +139679,11 @@ | |
| 139679 | /* Restriction (23) */ |
| 139680 | if( (p->selFlags & SF_Recursive) ) return 0; |
| 139681 | |
| 139682 | if( pSrc->nSrc>1 ){ |
| 139683 | if( pParse->nSelect>500 ) return 0; |
| 139684 | if( OptimizationDisabled(db, SQLITE_FlttnUnionAll) ) return 0; |
| 139685 | aCsrMap = sqlite3DbMallocZero(db, ((i64)pParse->nTab+1)*sizeof(int)); |
| 139686 | if( aCsrMap ) aCsrMap[0] = pParse->nTab; |
| 139687 | } |
| 139688 | } |
| 139689 | |
| @@ -140170,17 +140308,17 @@ | |
| 140308 | */ |
| 140309 | static int pushDownWhereTerms( |
| 140310 | Parse *pParse, /* Parse context (for malloc() and error reporting) */ |
| 140311 | Select *pSubq, /* The subquery whose WHERE clause is to be augmented */ |
| 140312 | Expr *pWhere, /* The WHERE clause of the outer query */ |
| 140313 | SrcItem *pSrc /* The subquery term of the outer FROM clause */ |
| 140314 | ){ |
| 140315 | Expr *pNew; |
| 140316 | int nChng = 0; |
| 140317 | if( pWhere==0 ) return 0; |
| 140318 | if( pSubq->selFlags & (SF_Recursive|SF_MultiPart) ) return 0; |
| 140319 | if( pSrc->fg.jointype & (JT_LTORJ|JT_RIGHT) ) return 0; |
| 140320 | |
| 140321 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140322 | if( pSubq->pPrior ){ |
| 140323 | Select *pSel; |
| 140324 | for(pSel=pSubq; pSel; pSel=pSel->pPrior){ |
| @@ -140206,14 +140344,15 @@ | |
| 140344 | |
| 140345 | if( pSubq->pLimit!=0 ){ |
| 140346 | return 0; /* restriction (3) */ |
| 140347 | } |
| 140348 | while( pWhere->op==TK_AND ){ |
| 140349 | nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, pSrc); |
| 140350 | pWhere = pWhere->pLeft; |
| 140351 | } |
| 140352 | |
| 140353 | #if 0 /* Legacy code. Checks now done by sqlite3ExprIsTableConstraint() */ |
| 140354 | if( isLeftJoin |
| 140355 | && (ExprHasProperty(pWhere,EP_FromJoin)==0 |
| 140356 | || pWhere->w.iJoin!=iCursor) |
| 140357 | ){ |
| 140358 | return 0; /* restriction (4) */ |
| @@ -140221,20 +140360,22 @@ | |
| 140360 | if( ExprHasProperty(pWhere,EP_FromJoin) |
| 140361 | && pWhere->w.iJoin!=iCursor |
| 140362 | ){ |
| 140363 | return 0; /* restriction (5) */ |
| 140364 | } |
| 140365 | #endif |
| 140366 | |
| 140367 | if( sqlite3ExprIsTableConstraint(pWhere, pSrc) ){ |
| 140368 | nChng++; |
| 140369 | pSubq->selFlags |= SF_PushDown; |
| 140370 | while( pSubq ){ |
| 140371 | SubstContext x; |
| 140372 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| 140373 | unsetJoinExpr(pNew, -1); |
| 140374 | x.pParse = pParse; |
| 140375 | x.iTable = pSrc->iCursor; |
| 140376 | x.iNewTable = pSrc->iCursor; |
| 140377 | x.isOuterJoin = 0; |
| 140378 | x.pEList = pSubq->pEList; |
| 140379 | pNew = substExpr(&x, pNew); |
| 140380 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140381 | if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){ |
| @@ -140773,11 +140914,11 @@ | |
| 140914 | if( pTab==0 ) return SQLITE_NOMEM; |
| 140915 | pTab->nTabRef = 1; |
| 140916 | if( pFrom->zAlias ){ |
| 140917 | pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias); |
| 140918 | }else{ |
| 140919 | pTab->zName = sqlite3MPrintf(pParse->db, "%!S", pFrom); |
| 140920 | } |
| 140921 | while( pSel->pPrior ){ pSel = pSel->pPrior; } |
| 140922 | sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); |
| 140923 | pTab->iPKey = -1; |
| 140924 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| @@ -141026,39 +141167,42 @@ | |
| 141167 | assert( pE->pLeft!=0 ); |
| 141168 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 141169 | zTName = pE->pLeft->u.zToken; |
| 141170 | } |
| 141171 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 141172 | Table *pTab = pFrom->pTab; /* Table for this data source */ |
| 141173 | ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ |
| 141174 | char *zTabName; /* AS name for this data source */ |
| 141175 | const char *zSchemaName = 0; /* Schema name for this data source */ |
| 141176 | int iDb; /* Schema index for this data src */ |
| 141177 | |
| 141178 | if( (zTabName = pFrom->zAlias)==0 ){ |
| 141179 | zTabName = pTab->zName; |
| 141180 | } |
| 141181 | if( db->mallocFailed ) break; |
| 141182 | assert( pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) ); |
| 141183 | if( pFrom->fg.isNestedFrom ){ |
| 141184 | assert( pFrom->pSelect!=0 ); |
| 141185 | pNestedFrom = pFrom->pSelect->pEList; |
| 141186 | assert( pNestedFrom!=0 ); |
| 141187 | assert( pNestedFrom->nExpr==pTab->nCol ); |
| 141188 | }else{ |
| 141189 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 141190 | continue; |
| 141191 | } |
| 141192 | pNestedFrom = 0; |
| 141193 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 141194 | zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*"; |
| 141195 | } |
| 141196 | for(j=0; j<pTab->nCol; j++){ |
| 141197 | char *zName = pTab->aCol[j].zCnName; |
| 141198 | struct ExprList_item *pX; /* Newly added ExprList term */ |
| 141199 | |
| 141200 | assert( zName ); |
| 141201 | if( zTName |
| 141202 | && pNestedFrom |
| 141203 | && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0)==0 |
| 141204 | ){ |
| 141205 | continue; |
| 141206 | } |
| 141207 | |
| 141208 | /* If a column is marked as 'hidden', omit it from the expanded |
| @@ -141107,12 +141251,12 @@ | |
| 141251 | break; /* OOM */ |
| 141252 | } |
| 141253 | pX = &pNew->a[pNew->nExpr-1]; |
| 141254 | assert( pX->zEName==0 ); |
| 141255 | if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ |
| 141256 | if( pNestedFrom ){ |
| 141257 | pX->zEName = sqlite3DbStrDup(db, pNestedFrom->a[j].zEName); |
| 141258 | testcase( pX->zEName==0 ); |
| 141259 | }else{ |
| 141260 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 141261 | zSchemaName, zTabName, zName); |
| 141262 | testcase( pX->zEName==0 ); |
| @@ -142053,13 +142197,11 @@ | |
| 142197 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 142198 | */ |
| 142199 | if( OptimizationEnabled(db, SQLITE_PushDown) |
| 142200 | && (pItem->fg.isCte==0 |
| 142201 | || (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2)) |
| 142202 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem) |
| 142203 | ){ |
| 142204 | #if TREETRACE_ENABLED |
| 142205 | if( sqlite3TreeTrace & 0x100 ){ |
| 142206 | SELECTTRACE(0x100,pParse,p, |
| 142207 | ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); |
| @@ -148109,10 +148251,11 @@ | |
| 148251 | struct WhereRightJoin { |
| 148252 | int iMatch; /* Cursor used to determine prior matched rows */ |
| 148253 | int regBloom; /* Bloom filter for iRJMatch */ |
| 148254 | int regReturn; /* Return register for the interior subroutine */ |
| 148255 | int addrSubrtn; /* Starting address for the interior subroutine */ |
| 148256 | int endSubrtn; /* The last opcode in the interior subroutine */ |
| 148257 | }; |
| 148258 | |
| 148259 | /* |
| 148260 | ** This object contains information needed to implement a single nested |
| 148261 | ** loop in WHERE clause. |
| @@ -151508,10 +151651,12 @@ | |
| 151651 | SrcList sFrom; |
| 151652 | Bitmask mAll = 0; |
| 151653 | int k; |
| 151654 | |
| 151655 | ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pTab->zName)); |
| 151656 | sqlite3VdbeNoJumpsOutsideSubrtn(v, pRJ->addrSubrtn, pRJ->endSubrtn, |
| 151657 | pRJ->regReturn); |
| 151658 | for(k=0; k<iLevel; k++){ |
| 151659 | int iIdxCur; |
| 151660 | mAll |= pWInfo->a[k].pWLoop->maskSelf; |
| 151661 | sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); |
| 151662 | iIdxCur = pWInfo->a[k].iIdxCur; |
| @@ -153516,11 +153661,11 @@ | |
| 153661 | ** continuation of the inner-most loop. */ |
| 153662 | return pWInfo->iContinue; |
| 153663 | } |
| 153664 | pInner = &pWInfo->a[pWInfo->nLevel-1]; |
| 153665 | assert( pInner->addrNxt!=0 ); |
| 153666 | return pInner->pRJ ? pWInfo->iContinue : pInner->addrNxt; |
| 153667 | } |
| 153668 | |
| 153669 | /* |
| 153670 | ** While generating code for the min/max optimization, after handling |
| 153671 | ** the aggregate-step call to min() or max(), check to see if any |
| @@ -154246,13 +154391,11 @@ | |
| 154391 | Expr *pExpr = pTerm->pExpr; |
| 154392 | /* Make the automatic index a partial index if there are terms in the |
| 154393 | ** WHERE clause (or the ON clause of a LEFT join) that constrain which |
| 154394 | ** rows of the target table (pSrc) that can be used. */ |
| 154395 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 154396 | && sqlite3ExprIsTableConstraint(pExpr, pSrc) |
| 154397 | ){ |
| 154398 | pPartial = sqlite3ExprAnd(pParse, pPartial, |
| 154399 | sqlite3ExprDup(pParse->db, pExpr, 0)); |
| 154400 | } |
| 154401 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| @@ -154487,11 +154630,11 @@ | |
| 154630 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); |
| 154631 | pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm]; |
| 154632 | for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){ |
| 154633 | Expr *pExpr = pTerm->pExpr; |
| 154634 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 154635 | && sqlite3ExprIsTableConstraint(pExpr, pItem) |
| 154636 | ){ |
| 154637 | sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); |
| 154638 | } |
| 154639 | } |
| 154640 | if( pLoop->wsFlags & WHERE_IPK ){ |
| @@ -159438,10 +159581,11 @@ | |
| 159581 | /* Terminate the subroutine that forms the interior of the loop of |
| 159582 | ** the RIGHT JOIN table */ |
| 159583 | WhereRightJoin *pRJ = pLevel->pRJ; |
| 159584 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 159585 | pLevel->addrCont = 0; |
| 159586 | pRJ->endSubrtn = sqlite3VdbeCurrentAddr(v); |
| 159587 | sqlite3VdbeAddOp3(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn, 1); |
| 159588 | VdbeCoverage(v); |
| 159589 | assert( pParse->withinRJSubrtn>0 ); |
| 159590 | pParse->withinRJSubrtn--; |
| 159591 | } |
| @@ -235980,11 +236124,11 @@ | |
| 236124 | int nArg, /* Number of args */ |
| 236125 | sqlite3_value **apUnused /* Function arguments */ |
| 236126 | ){ |
| 236127 | assert( nArg==0 ); |
| 236128 | UNUSED_PARAM2(nArg, apUnused); |
| 236129 | sqlite3_result_text(pCtx, "fts5: 2022-04-26 19:16:11 b1bec72043f798f4d4d30e6b60a45ed4dc521115c8a9f97bb8228e3f089deefb", -1, SQLITE_TRANSIENT); |
| 236130 | } |
| 236131 | |
| 236132 | /* |
| 236133 | ** Return true if zName is the extension on one of the shadow tables used |
| 236134 | ** by this module. |
| 236135 |
+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-04-21 19:38:17 f766dff012af0ea3c28a8ce4db850cd0205729a8283bce1e442992aded7c734b" | |
| 151 | +#define SQLITE_SOURCE_ID "2022-04-26 19:16:11 b1bec72043f798f4d4d30e6b60a45ed4dc521115c8a9f97bb8228e3f089deefb" | |
| 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-04-21 19:38:17 f766dff012af0ea3c28a8ce4db850cd0205729a8283bce1e442992aded7c734b" |
| 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-04-26 19:16:11 b1bec72043f798f4d4d30e6b60a45ed4dc521115c8a9f97bb8228e3f089deefb" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| 157 |