summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtsuro Fujita2025-07-06 08:15:00 +0000
committerEtsuro Fujita2025-07-06 08:15:00 +0000
commit21c9756db6458f859e6579a6754c78154321cb39 (patch)
tree7557ae8a1658067b292d20f68dd1837593d2d693
parent144ad723a4484927266a316d1c9550d56745ff67 (diff)
postgres_fdw: Add Assert to estimate_path_cost_size().HEADmaster
When estimating the cost/size of a pre-sorted path for a given upper relation using local stats, this function dereferences the passed-in PgFdwPathExtraData pointer without checking that it is not NULL. But that is not a bug as the pointer is guaranteed to be non-NULL in that case; to avoid confusion, add an Assert to ensure that it is not NULL before dereferencing it. Reported-by: Ranier Vilela <[email protected]> Author: Etsuro Fujita <[email protected]> Reviewed-by: Ranier Vilela <[email protected]> Discussion: https://postgr.es/m/CAEudQArgiALbV1akQpeZOgim7XP05n%3DbDP1%3DTcOYLA43nRX_vA%40mail.gmail.com
-rw-r--r--contrib/postgres_fdw/postgres_fdw.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 4283ce9f962..e0a34b27c7c 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -3507,6 +3507,13 @@ estimate_path_cost_size(PlannerInfo *root,
{
Assert(foreignrel->reloptkind == RELOPT_UPPER_REL &&
fpinfo->stage == UPPERREL_GROUP_AGG);
+
+ /*
+ * We can only get here when this function is called from
+ * add_foreign_ordered_paths() or add_foreign_final_paths();
+ * in which cases, the passed-in fpextra should not be NULL.
+ */
+ Assert(fpextra);
adjust_foreign_grouping_path_cost(root, pathkeys,
retrieved_rows, width,
fpextra->limit_tuples,