v15-0003-Fix-add_partial_path-interaction-with-disabled_n.patch
application/octet-stream
Filename: v15-0003-Fix-add_partial_path-interaction-with-disabled_n.patch
Type: application/octet-stream
Part: 0
Message:
Re: pg_plan_advice
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v15-0003
Subject: Fix add_partial_path interaction with disabled_nodes
| File | + | − |
|---|---|---|
| src/backend/optimizer/util/pathnode.c | 7 | 2 |
From d94c29427e9539b72619e5dc720e4417444cc1ec Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Thu, 5 Feb 2026 15:23:36 -0500
Subject: [PATCH v15 3/5] Fix add_partial_path interaction with disabled_nodes
Commit e22253467942fdb100087787c3e1e3a8620c54b2 adjusted the logic in
add_path() to keep the path list sorted by disabled_nodes and then by
total_cost, but failed to make the corresponding adjustment to
add_partial_path. As a result, add_partial_path might sort the path list
just by total cost, which could lead to later planner misbehavior.
In principle, this should be back-patched to v18, but we are typically
reluctant to back-patch planner fixes for fear of destabilizing working
installations, and it is unclear to me that this has sufficiently
serious consequences to justify an exception, so for now, no back-patch.
---
src/backend/optimizer/util/pathnode.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 829295b3afe..875764abdbe 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -878,8 +878,13 @@ add_partial_path(RelOptInfo *parent_rel, Path *new_path)
}
else
{
- /* new belongs after this old path if it has cost >= old's */
- if (new_path->total_cost >= old_path->total_cost)
+ /*
+ * new belongs after this old path if it has more disabled nodes
+ * or if it has the same number of nodes but a greater total cost
+ */
+ if (new_path->disabled_nodes > old_path->disabled_nodes ||
+ (new_path->disabled_nodes == old_path->disabled_nodes &&
+ new_path->total_cost >= old_path->total_cost))
insert_at = foreach_current_index(p1) + 1;
}
--
2.51.0