diff options
author | drh <> | 2024-06-27 14:54:15 +0000 |
---|---|---|
committer | drh <> | 2024-06-27 14:54:15 +0000 |
commit | c96e47c80e67d3a21c591ccb3432f3c18153f8aa (patch) | |
tree | 2b1d1087e7a55cb08e9fe8dfe4d5aad3d674dc31 /src/select.c | |
parent | 620a00ee32c64944289bc8ff8c37b23bb4e220a1 (diff) | |
parent | 105c20648e1b05839fd0638686b95f2e3998abcb (diff) | |
download | sqlite-c96e47c80e67d3a21c591ccb3432f3c18153f8aa.tar.gz sqlite-c96e47c80e67d3a21c591ccb3432f3c18153f8aa.zip |
Merge the latest trunk enhancements into the exists-to-join branch.
FossilOrigin-Name: fc643f8a12e9b7448136b281f798e18dfebe0a3df5115d930b965c8a33933e2d
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/select.c b/src/select.c index 832b711b8..f2d44bf36 100644 --- a/src/select.c +++ b/src/select.c @@ -7692,13 +7692,16 @@ 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 not a recursive CTE. ORDER BY has a different + ** meaning for recursive CTEs and this optimization does not + ** apply. ** ** Also retain the ORDER BY if the OmitOrderBy optimization is disabled. */ if( pSub->pOrderBy!=0 && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */ && pSub->pLimit==0 /* Condition (1) */ - && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */ + && (pSub->selFlags & (SF_OrderByReqd|SF_Recursive))==0 /* (2) and (6) */ && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */ && OptimizationEnabled(db, SQLITE_OmitOrderBy) ){ |