diff options
author | drh <> | 2023-08-02 00:09:15 +0000 |
---|---|---|
committer | drh <> | 2023-08-02 00:09:15 +0000 |
commit | 4178849736c81ec17bbfb2628ec0ef7bad94962d (patch) | |
tree | f06b8ac7c2a61484442fe203ef57643dacdbb967 /src | |
parent | cbaef88980f48c963da8788faadd429b64d72dca (diff) | |
download | sqlite-4178849736c81ec17bbfb2628ec0ef7bad94962d.tar.gz sqlite-4178849736c81ec17bbfb2628ec0ef7bad94962d.zip |
When a query is inside an AS MATERIALIZED CTE, do not attempt the
omit-ORDER-BY optimization. If the developer specifies MATERIALIZED,
that means he wants the sort to actually happen.
FossilOrigin-Name: aa769ee7477171f26a091cadff98aa4f48da7752ade20b405a95c4525456f62e
Diffstat (limited to 'src')
-rw-r--r-- | src/select.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c index 098b74584..7f73b1928 100644 --- a/src/select.c +++ b/src/select.c @@ -7314,12 +7314,14 @@ int sqlite3Select( ** (a) The outer query has a different ORDER BY clause ** (b) The subquery is part of a join ** See forum post 062d576715d277c8 + ** (6) The subquery is really a MATERIALIZED CTE */ if( pSub->pOrderBy!=0 && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */ && pSub->pLimit==0 /* Condition (1) */ && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */ && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */ + && (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) /* (6) */ && OptimizationEnabled(db, SQLITE_OmitOrderBy) ){ TREETRACE(0x800,pParse,p, |