-C Do\snot\sdo\san\searly\sabort\sif\sa\slateral\ssubquery\sis\san\sempty\sset.
-D 2024-07-20T03:57:10.925
+C Optimizations\sand\simproved\scomments.
+D 2024-07-20T08:31:52.630
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/btree.c 8b42fc7d9efdb2df05c30e8f91ff6cfbd979724ae24bf90269028468b7a13333
F src/btree.h 55066f513eb095db935169dab1dc2f7c7a747ef223c533f5d4ad4dfed346cbd0
F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b6
-F src/build.c 237ccc0290d131d646be722f418e92ee0a38043aee25e7dfdc75f8ce5b3abe4e
+F src/build.c 7db395d00bc3a188266400d6d0bf65183a92add62adac24f32822df660fd3f2b
F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3
F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce
F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9
F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
-F src/resolve.c 8a82616721e6009aad4502d8c20ac003a08c5b83fb141784ccca75ce6467ec98
+F src/resolve.c 85b299024d32eb6fb4490490a82514627cfff3ff18ee426899ff34aa5a039ce5
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
-F src/select.c da8c817bc099e9e6d4169b03d1935bf8d17c062f7635cc90abfe29a764c873ae
+F src/select.c 89eee19cf4bcf1ef55eb3db33a9ffd3300dbbb7f9333e93cb28cf0b5300f2a2b
F src/shell.c.in b7d435c137eb323981adff814f172dbaabb9ba504fef17cb11d4681c1633ee13
F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
-F src/sqliteInt.h c5f0c47ecbd9ea1c3809f2f8f5c1082d4f4d590211a53e51761b21fd7522d129
+F src/sqliteInt.h bb005bc625db3f95aea4679d53cf2924351cfbd1438c9caa75cc3590c832e27e
F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728
F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2
F src/where.c e411ef973e520428a3cbbf8a348c7b37bc8f7f639ebdabd64f835861364be3ee
F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65
-F src/wherecode.c e6518bac30e75554996c50ffd4d6d01522de0beb54020446fd498dfc2111a193
+F src/wherecode.c 84f3b1d4c97d8b0c2e30d5b0f6d6a9dfd391fac79ff05df0e0d8cfc1d3728827
F src/whereexpr.c 7d0d34b42b9edfd8e8ca66beb3a6ef63fe211c001af54caf2ccbcd989b783290
F src/window.c 1e40ffc509bae21e466f6106382d238e91eb73edd4ba10e66ca4fd7af2b96896
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 8217bddaf8c0697799c7518746996665bbd1f5a327315d18091a6ab3250f1112
-R 5c22f2a95f0481fb172addeee95820dd
+P 9e50d338ebd974b5d1b8baf4c7a400abded28ee997414e896c2e8b9d61d39a94
+R f7bd63c57c273b4368bcf35dafa83b42
U drh
-Z 86dc0c94580a9c5283fa406f79f2dc76
+Z f4cfc48df533373bac4bfb5d658558a1
# Remove this line to create a well-formed Fossil manifest.
-9e50d338ebd974b5d1b8baf4c7a400abded28ee997414e896c2e8b9d61d39a94
+84b80233e7f1afd9ed2c0c63f2d641891d9ed06cc160fee55c75a6fd77af6144
**
** The operator is "natural cross join". The A and B operands are stored
** in p->a[0] and p->a[1], respectively. The parser initially stores the
-** operator with A. This routine shifts that operator over to B.
+** operator with A in p->a[0]. This routine shifts that operator over to
+** B in p->a[1]. After this shift, the left-most term (p->a[0].fg.jointype)
+** is not used except as a placeholder for JT_LTORJ and/or JT_LATERAL to
+** indicate that at least one RIGHT JOIN or LATERAL JOIN (respectively)
+** occurs somewhere in the FROM.
**
** Additional changes:
**
assert( pItem->zName!=0 || pItem->pSelect!=0 );/* Test of tag-20240424-1*/
if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
int nRef = pOuterNC ? pOuterNC->nRef : 0;
+ int nRef2 = sNC.nRef;
+ NameContext *pSubNC;
const char *zSavedContext = pParse->zAuthContext;
if( pItem->zName ) pParse->zAuthContext = pItem->zName;
- if( pItem->fg.isLateral && i>0 ){
- int nRef2 = sNC.nRef;
+ if( pItem->fg.isLateral ){
+ assert( i>0 ); /* Because p->pSub->a[0] is never marked LATERAL */
p->pSrc->nSrc = i;
sNC.pSrcList = p->pSrc;
sNC.pNext = pOuterNC;
- sqlite3ResolveSelectNames(pParse, pItem->pSelect, &sNC);
- p->pSrc->nSrc = nSrc;
- if( sNC.nRef>nRef2 ){
- int kk;
- pItem->fg.isCorrelated = 1;
- for(kk=0; kk<i; kk++) p->pSrc->a[kk].fg.jointype |= JT_LATERAL;
- }
+ pSubNC = &sNC;
+ }else{
sNC.pSrcList = 0;
sNC.pNext = 0;
- }else{
- sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);
+ pSubNC = pOuterNC;
+ }
+ sqlite3ResolveSelectNames(pParse, pItem->pSelect, pSubNC);
+ p->pSrc->nSrc = nSrc;
+ if( sNC.nRef>nRef2 ){
+ pItem->fg.isCorrelated = 1;
+ /* Add JT_LATERAL to the left-most term of the FROM clause as a
+ ** marker that this FROM clause contains one or more LATERALs. */
+ p->pSrc->a[0].fg.jointype |= JT_LATERAL;
}
-
pParse->zAuthContext = zSavedContext;
if( pParse->nErr ) return WRC_Abort;
assert( db->mallocFailed==0 );
*/
int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
int jointype = 0;
- int bErr = 0;
Token *apAll[3];
Token *p;
/* 0123456789 123456789 123456789 123 */
}
testcase( j==0 || j==1 || j==2 || j==3 || j==4 || j==5 || j==6 );
if( j>=ArraySize(aKeyword) ){
- bErr = 1;
+ jointype = JT_OUTER; /* Triggers error report below */
break;
}
}
if(
(jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
- bErr>0 ||
(jointype & (JT_OUTER|JT_LEFT|JT_RIGHT))==JT_OUTER
){
const char *zSp1 = " ";
** (a) the AS MATERIALIZED keyword is used, or
** (b) the CTE is used multiple times and does not have the
** NOT MATERIALIZED keyword
-** (3) The subquery is not part of a left operand for a RIGHT JOIN
+** (3) The FROM clause does not contain a RIGHT JOIN nor a LATERAL JOIN.
** (4) The SQLITE_Coroutine optimization disable flag is not set
** (5) The subquery is not self-joined
*/
** The SrcItem object represents a single term in the FROM clause of a query.
** The SrcList object is mostly an array of SrcItems.
**
-** The jointype starts out showing the join type between the current table
-** and the next table on the list. The parser builds the list this way.
+** The jointype starts out showing the join type between the current term
+** and the next term on the list. The parser builds the list this way.
** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each
-** jointype expresses the join between the table and the previous table.
+** jointype expresses the join between the current term and the previous.
**
** In the colUsed field, the high-order bit (bit 63) is set if the table
** contains more than 63 columns and the 64-th or later column is used.
int regReturn; /* Register holding return address of addrFillSub */
int regResult; /* Registers holding results of a co-routine */
struct {
- u8 jointype; /* Type of join between this table and the previous */
+ u8 jointype; /* Type of join. See above for more detail. */
unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
unsigned isTabFunc :1; /* True if table-valued-function syntax */
#define JT_OUTER 0x20 /* The "OUTER" keyword is present */
#define JT_LTORJ 0x40 /* One of the LEFT operands of a RIGHT JOIN
** Mnemonic: Left Table Of Right Join */
-#define JT_LATERAL 0x80 /* A LATERAL join */
+#define JT_LATERAL 0x80 /* A LATERAL join. Or, if on the left-most
+ ** SrcItem, an indication that at least one
+ ** correlated LATERAL join exists in the FROM */
/*
** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()
int iLevel,
SrcItem *pTabItem
){
- if( pTabItem->fg.isLateral==0 ){
+ if( pTabItem->fg.isLateral==0 || pTabItem->fg.isCorrelated==0 ){
while( 1 /*exit-by-break*/ ){
if( pWInfo->a[iLevel].iLeftJoin ) break;
if( pWInfo->a[iLevel].pRJ ) break;