1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Materialize any CTE that is used more than once.

FossilOrigin-Name: ba59159fbe6b83fb6d79fbfee22d983768b0ebbaac7e99d2ac66c810e5e04100
This commit is contained in:
drh
2021-02-21 23:44:14 +00:00
parent 7601294ad3
commit a79e2a2d28
9 changed files with 117 additions and 42 deletions

View File

@@ -209,7 +209,11 @@ Expr *sqlite3LimitWhere(
pSrc->a[0].pTab = 0;
pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0);
pSrc->a[0].pTab = pTab;
pSrc->a[0].pIBIndex = 0;
if( pSrc->a[0].fg.isIndexedBy ){
pSrc->a[0].u2.pIBIndex = 0;
}else if( pSrc->a[0].fg.isCte ){
pSrc->a[0].u2.pCteUse->nUse++;
}
/* generate the SELECT expression tree. */
pSelect = sqlite3SelectNew(pParse, pEList, pSelectSrc, pWhere, 0 ,0,