aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2024-08-20 22:44:40 +0000
committerdrh <>2024-08-20 22:44:40 +0000
commita0651b370706e58f9014453c5f36124ca8a738c9 (patch)
treef2dd4e4723349b740b28d209f378f39203c55156 /src
parentbb36d55e638fb7f8ba1c1ce787b835f398fc98d3 (diff)
downloadsqlite-a0651b370706e58f9014453c5f36124ca8a738c9.tar.gz
sqlite-a0651b370706e58f9014453c5f36124ca8a738c9.zip
Fix a name resolution issue with CTEs.
FossilOrigin-Name: 4fa8235dd59cd683d6c6c97bfe181a9637be7c054d435323c903b9dbd74aff02
Diffstat (limited to 'src')
-rw-r--r--src/select.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/select.c b/src/select.c
index 655221b06..b76e42b74 100644
--- a/src/select.c
+++ b/src/select.c
@@ -5823,9 +5823,10 @@ static int resolveFromTermToCte(
assert( pRecTerm->pPrior!=0 );
for(i=0; i<pSrc->nSrc; i++){
SrcItem *pItem = &pSrc->a[i];
- if( ((pItem->fg.fixedSchema==0 && pItem->u4.zDatabase==0)
- || pItem->fg.hadSchema==0)
- && pItem->zName!=0
+ if( pItem->zName!=0
+ && !pItem->fg.hadSchema
+ && ALWAYS( !pItem->fg.isSubquery )
+ && (pItem->fg.fixedSchema || pItem->u4.zDatabase==0)
&& 0==sqlite3StrICmp(pItem->zName, pCte->zName)
){
pItem->pSTab = pTab;