diff options
author | dan <Dan Kennedy> | 2024-12-09 11:12:12 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2024-12-09 11:12:12 +0000 |
commit | 4f5ae3fc4ec70b440d11154d5072961977264765 (patch) | |
tree | 317eb1bbc4bac50115346808f22b450f33d95526 /src | |
parent | 1a4b2117f11fba43ca892936df22681a7c496d46 (diff) | |
download | sqlite-4f5ae3fc4ec70b440d11154d5072961977264765.tar.gz sqlite-4f5ae3fc4ec70b440d11154d5072961977264765.zip |
Fix an obscure problem with multiple outer joins, ON clauses and query flattening. Forum [forum:5c8a069d23|thread 5c8a069d23].
FossilOrigin-Name: 289daf6cee39625e8f068179cd58efcc1d28242f46064e58ec4175a019cf48ad
Diffstat (limited to 'src')
-rw-r--r-- | src/select.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/select.c b/src/select.c index 285e9133e..9d35e1832 100644 --- a/src/select.c +++ b/src/select.c @@ -4673,6 +4673,7 @@ static int flattenSubquery( /* Transfer the FROM clause terms from the subquery into the ** outer query. */ + iNewParent = pSubSrc->a[0].iCursor; for(i=0; i<nSubSrc; i++){ SrcItem *pItem = &pSrc->a[i+iFrom]; assert( pItem->fg.isTabFunc==0 ); @@ -4682,7 +4683,6 @@ static int flattenSubquery( if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing); *pItem = pSubSrc->a[i]; pItem->fg.jointype |= ltorj; - iNewParent = pSubSrc->a[i].iCursor; memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); } pSrc->a[iFrom].fg.jointype &= JT_LTORJ; @@ -4722,6 +4722,7 @@ static int flattenSubquery( pWhere = pSub->pWhere; pSub->pWhere = 0; if( isOuterJoin>0 ){ + assert( pSubSrc->nSrc==1 ); sqlite3SetJoinExpr(pWhere, iNewParent, EP_OuterON); } if( pWhere ){ |