v6-0001-mark_async_capable-subpath-should-match-subplan.patch
text/x-diff
Filename: v6-0001-mark_async_capable-subpath-should-match-subplan.patch
Type: text/x-diff
Part: 0
Message:
Re: Asynchronous MergeAppend
From 044ff10f402c0cbc4f815a34fc266e4e581274c0 Mon Sep 17 00:00:00 2001 From: Alexander Pyhalov <a.pyhalov@postgrespro.ru> Date: Sat, 15 Nov 2025 10:16:25 +0300 Subject: [PATCH 1/2] mark_async_capable(): subpath should match subplan create_append_plan() calls mark_async_capable() on subplan of Append and corresponding subpath. Later mark_async_capable() looks at path type and decides that subplan has type, corresponding to the path type. However, this is not true if create_append_plan() inserts Sort node above Append subplan. So we should handle such case separately. --- src/backend/optimizer/plan/createplan.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 8af091ba647..004bbc6d1d6 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -1139,10 +1139,10 @@ mark_async_capable_plan(Plan *plan, Path *path) SubqueryScan *scan_plan = (SubqueryScan *) plan; /* - * If the generated plan node includes a gating Result node, - * we can't execute it asynchronously. + * If the generated plan node includes a gating Result node or + * a Sort node, we can't execute it asynchronously. */ - if (IsA(plan, Result)) + if (IsA(plan, Result) || IsA(plan, Sort)) return false; /* @@ -1160,10 +1160,10 @@ mark_async_capable_plan(Plan *plan, Path *path) FdwRoutine *fdwroutine = path->parent->fdwroutine; /* - * If the generated plan node includes a gating Result node, - * we can't execute it asynchronously. + * If the generated plan node includes a gating Result node or + * a Sort node, we can't execute it asynchronously. */ - if (IsA(plan, Result)) + if (IsA(plan, Result) || IsA(plan, Sort)) return false; Assert(fdwroutine != NULL); @@ -1176,9 +1176,9 @@ mark_async_capable_plan(Plan *plan, Path *path) /* * If the generated plan node includes a Result node for the - * projection, we can't execute it asynchronously. + * projection or a Sort node, we can't execute it asynchronously. */ - if (IsA(plan, Result)) + if (IsA(plan, Result) || IsA(plan, Sort)) return false; /* -- 2.43.0