8000 postgres_fdw: Add Assert to estimate_path_cost_size(). · sthagen/postgres-postgres@21c9756 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21c9756

Browse files
author
Etsuro Fujita
committed
postgres_fdw: Add Assert to estimate_path_cost_size().
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 <ranier.vf@gmail.com> Author: Etsuro Fujita <etsuro.fujita@gmail.com> Reviewed-by: Ranier Vilela <ranier.vf@gmail.com> Discussion: https://postgr.es/m/CAEudQArgiALbV1akQpeZOgim7XP05n%3DbDP1%3DTcOYLA43nRX_vA%40mail.gmail.com
1 parent 144ad72 commit 21c9756

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,6 +3507,13 @@ estimate_path_cost_size(PlannerInfo *root,
35073507
{
35083508
Assert(foreignrel->reloptkind == RELOPT_UPPER_REL &&
35093509
fpinfo->stage == UPPERREL_GROUP_AGG);
3510+
3511+
/*
3512+
* We can only get here when this function is called from
3513+
* add_foreign_ordered_paths() or add_foreign_final_paths();
3514+
* in which cases, the passed-in fpextra should not be NULL.
3515+
*/
3516+
Assert(fpextra);
35103517
adjust_foreign_grouping_path_cost(root, pathkeys,
35113518
retrieved_rows, width,
35123519
fpextra->limit_tuples,

0 commit comments

Comments
 (0)
0