aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c1
-rw-r--r--src/select.c5
-rw-r--r--src/treeview.c4
3 files changed, 10 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c
index a30097134..170987621 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1527,6 +1527,7 @@ With *sqlite3WithDup(sqlite3 *db, With *p){
pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0);
pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0);
pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName);
+ pRet->a[i].eM10d = p->a[i].eM10d;
}
}
}
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
diff --git a/src/treeview.c b/src/treeview.c
index 3ba8a63cd..db73943f0 100644
--- a/src/treeview.c
+++ b/src/treeview.c
@@ -115,6 +115,10 @@ void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 moreToFollow){
}
sqlite3_str_appendf(&x, ")");
}
+ if( pCte->eM10d!=M10d_Any ){
+ sqlite3_str_appendf(&x, " %sMATERIALIZED",
+ pCte->eM10d==M10d_No ? "NOT " : "");
+ }
if( pCte->pUse ){
sqlite3_str_appendf(&x, " (pUse=0x%p, nUse=%d)", pCte->pUse,
pCte->pUse->nUse);