aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c10
-rw-r--r--src/parse.y3
-rw-r--r--src/select.c3
3 files changed, 13 insertions, 3 deletions
diff --git a/src/expr.c b/src/expr.c
index e271e4679..4da9d6263 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -895,7 +895,12 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
return pNew;
}
-With *withDup(sqlite3 *db, With *p){
+/*
+** Create and return a deep copy of the object passed as the second
+** argument. If an OOM condition is encountered, NULL is returned
+** and the db->mallocFailed flag set.
+*/
+static With *withDup(sqlite3 *db, With *p){
With *pRet = 0;
if( p ){
int nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
@@ -1055,7 +1060,8 @@ Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
pNew->addrOpenEphm[1] = -1;
pNew->addrOpenEphm[2] = -1;
pNew->pWith = withDup(db, p->pWith);
- pNew->pRecurse = p->pRecurse;
+ assert( p->pRecurse==0 );
+ pNew->pRecurse = 0;
return pNew;
}
#else
diff --git a/src/parse.y b/src/parse.y
index b1992f241..937669eb5 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -684,8 +684,9 @@ where_opt(A) ::= WHERE expr(X). {A = X.pExpr;}
////////////////////////// The UPDATE command ////////////////////////////////
//
%ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
-cmd ::= with UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)
+cmd ::= with(C) UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)
where_opt(W) orderby_opt(O) limit_opt(L). {
+ sqlite3WithPush(pParse, C);
sqlite3SrcListIndexedBy(pParse, X, &I);
sqlite3ExprListCheckLength(pParse,Y,"set list");
W = sqlite3LimitWhere(pParse, X, W, O, L.pLimit, L.pOffset, "UPDATE");
diff --git a/src/select.c b/src/select.c
index 22eaf1b1c..35edcbb03 100644
--- a/src/select.c
+++ b/src/select.c
@@ -2844,6 +2844,8 @@ static void substSelect(
**
** Flattening is only attempted if all of the following are true:
**
+** (0) The subquery is not a recursive CTE.
+**
** (1) The subquery and the outer query do not both use aggregates.
**
** (2) The subquery is not an aggregate or the outer query is not a join.
@@ -2968,6 +2970,7 @@ static int flattenSubquery(
iParent = pSubitem->iCursor;
pSub = pSubitem->pSelect;
assert( pSub!=0 );
+ if( pSub->pRecurse ) return 0; /* Restriction (0) */
if( isAgg && subqueryIsAgg ) return 0; /* Restriction (1) */
if( subqueryIsAgg && pSrc->nSrc>1 ) return 0; /* Restriction (2) */
pSubSrc = pSub->pSrc;