Skip to content

Yet another PG 11 problem: postgresBeginForeignModify needs PlanState. #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/partition_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,8 @@ prepare_rri_fdw_for_insert(ResultRelInfoHolder *rri_holder,
TupleDesc tupdesc;
int i,
target_attr;
PlanState plan_state;
PlanState *plan_state_ptr;

/* Fetch RangeTblEntry for partition */
rte = rt_fetch(rri->ri_RangeTableIndex, estate->es_range_table);
Expand Down Expand Up @@ -1066,6 +1068,14 @@ prepare_rri_fdw_for_insert(ResultRelInfoHolder *rri_holder,
/* Plan fake query in for FDW access to be planned as well */
elog(DEBUG1, "FDW(%u): plan fake query for fdw_private", partid);
plan = standard_planner(&query, 0, NULL);
/*
* Add fake PlanState to mt_plans. Though no one will ever look at the
* contents, postgresBeginForeignModify segfaults since 11 if it is
* absent.
*/
memset(&plan_state, 0, sizeof(PlanState));
plan_state_ptr = &plan_state;
mtstate.mt_plans = &plan_state_ptr;

/* Extract fdw_private from useless plan */
elog(DEBUG1, "FDW(%u): extract fdw_private", partid);
Expand Down