diff options
author | drh <> | 2022-04-22 16:15:48 +0000 |
---|---|---|
committer | drh <> | 2022-04-22 16:15:48 +0000 |
commit | 67f70bea06eea1e20124c4e97d2f545b3f10b473 (patch) | |
tree | 6244e193f3ff28fe9e7732438f332294f91855ec /src/select.c | |
parent | 9b843f0ce0bae9a6a62edd0a006bcec436622cdf (diff) | |
download | sqlite-67f70bea06eea1e20124c4e97d2f545b3f10b473.tar.gz sqlite-67f70bea06eea1e20124c4e97d2f545b3f10b473.zip |
Honor the MATERIALIZED keyword on a common table expression by not flattening
the CTE into an outer query.
FossilOrigin-Name: 8d631a6b9eb06b54b10eda595a4c588ca38f909b4afa653b24d1f720b55d72f7
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c index 2b27eea63..26a3172ae 100644 --- a/src/select.c +++ b/src/select.c @@ -4153,6 +4153,8 @@ static void renumberCursors( ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it ** is the first element of the parent query. ** +** (28) The subquery is not a MATERIALIZED CTE. +** ** ** In this routine, the "p" parameter is a pointer to the outer query. ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query @@ -4276,6 +4278,9 @@ static int flattenSubquery( if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ return 0; /* Restriction (27) */ } + if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ + return 0; /* (28) */ + } /* Restriction (17): If the sub-query is a compound SELECT, then it must ** use only the UNION ALL operator. And none of the simple select queries |