diff options
author | drh <> | 2021-02-21 23:44:14 +0000 |
---|---|---|
committer | drh <> | 2021-02-21 23:44:14 +0000 |
commit | a79e2a2d28eab71b7434a77ada3af5c2855d9bef (patch) | |
tree | 47b464c9d63c9a1a665779ba0022dacdbf503ce9 /src/expr.c | |
parent | 7601294ad3fe9f7e0db8eb2478dec0de293b8bb6 (diff) | |
download | sqlite-a79e2a2d28eab71b7434a77ada3af5c2855d9bef.tar.gz sqlite-a79e2a2d28eab71b7434a77ada3af5c2855d9bef.zip |
Materialize any CTE that is used more than once.
FossilOrigin-Name: ba59159fbe6b83fb6d79fbfee22d983768b0ebbaac7e99d2ac66c810e5e04100
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c index cf9a213f4..b66556b03 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1544,7 +1544,10 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ if( pNewItem->fg.isIndexedBy ){ pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); } - pNewItem->pIBIndex = pOldItem->pIBIndex; + pNewItem->u2 = pOldItem->u2; + if( pNewItem->fg.isCte ){ + pNewItem->u2.pCteUse->nUse++; + } if( pNewItem->fg.isTabFunc ){ pNewItem->u1.pFuncArg = sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags); |