Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bc2769

Browse files
committed
Error out when Gather Merge input is not sorted
To build Gather Merge path, the input needs to be sufficiently sorted.Ensuring this is the responsibility of the code constructing the paths,but create_gather_merge_plan tried to handle unsorted paths by addingan explicit Sort. In light of the recent issues related to IncrementalSort, this is rather fragile. Some of the expressions may be volatileor parallel unsafe, in which case we can't add the Sort here.We could do more checks and add the Sort in at least some cases, butit seems cleaner to just error out and make it clear this is a bug incode constructing those paths.Author: James ColemanReviewed-by: Tomas VondraDiscussion:https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs%3DhC0mSksZC%3DH5M8LSchj5e5OxpTAg%40mail.gmail.comDiscussion:https://postgr.es/m/CAJGNTeNaxpXgBVcRhJX%2B2vSbq%2BF2kJqGBcvompmpvXb7pq%2BoFA%40mail.gmail.com
1 parentc06d6aa commit6bc2769

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/backend/optimizer/plan/createplan.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,13 +1793,15 @@ create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
17931793
&gm_plan->nullsFirst);
17941794

17951795

1796-
/* Now, insert a Sort node if subplan isn't sufficiently ordered */
1796+
/*
1797+
* All gather merge paths should have already guaranteed the necessary sort
1798+
* order either by adding an explicit sort node or by using presorted input.
1799+
* We can't simply add a sort here on additional pathkeys, because we can't
1800+
* guarantee the sort would be safe. For example, expressions may be
1801+
* volatile or otherwise parallel unsafe.
1802+
*/
17971803
if (!pathkeys_contained_in(pathkeys,best_path->subpath->pathkeys))
1798-
subplan= (Plan*)make_sort(subplan,gm_plan->numCols,
1799-
gm_plan->sortColIdx,
1800-
gm_plan->sortOperators,
1801-
gm_plan->collations,
1802-
gm_plan->nullsFirst);
1804+
elog(ERROR,"gather merge input not sufficiently sorted");
18031805

18041806
/* Now insert the subplan under GatherMerge. */
18051807
gm_plan->plan.lefttree=subplan;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp