Skip to content

Commit 336879f

Browse files
committed
Improve find_em_expr_usable_for_sorting_rel comment
Clarify the relationship between find_em_expr_usable_for_sorting_rel and prepare_sort_from_pathkeys, i.e. what restrictions need to be shared between those two places. Author: James Coleman Reviewed-by: Tomas Vondra Backpatch-through: 13 Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs%3DhC0mSksZC%3DH5M8LSchj5e5OxpTAg%40mail.gmail.com
1 parent aa97890 commit 336879f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/backend/optimizer/path/equivclass.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,11 @@ find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel)
795795
}
796796

797797
/*
798-
* Find an equivalence class member expression that can be safely used by a
799-
* sort node on top of the provided relation. The rules here must match those
800-
* applied in prepare_sort_from_pathkeys.
798+
* Find an equivalence class member expression that can be safely used to build
799+
* a sort node using the provided relation. The rules are a subset of those
800+
* applied in prepare_sort_from_pathkeys since that function deals with sorts
801+
* that must be delayed until the last stages of query execution, while here
802+
* we only care about proactive sorts.
801803
*/
802804
Expr *
803805
find_em_expr_usable_for_sorting_rel(PlannerInfo *root, EquivalenceClass *ec,

src/backend/optimizer/plan/createplan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5844,6 +5844,9 @@ make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols,
58445844
*
58455845
* Returns the node which is to be the input to the Sort (either lefttree,
58465846
* or a Result stacked atop lefttree).
5847+
*
5848+
* Note: Restrictions on what expressions are safely sortable may also need to
5849+
* be added to find_em_expr_usable_for_sorting_rel.
58475850
*/
58485851
static Plan *
58495852
prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy