From ab067bdeb6de84db80504d2fb05da4385fa02ebc Mon Sep 17 00:00:00 2001 From: "Andrey V. Lepikhov" Date: Fri, 6 Aug 2021 10:11:52 +0500 Subject: [PATCH] Share es_result_relations of parent EState in EPQState because FDW direct-modify nodes expect it available. --- src/backend/executor/execMain.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index b3ce4bae53..a030fec86a 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -2714,10 +2714,12 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree) rcestate->es_output_cid = parentestate->es_output_cid; /* - * ResultRelInfos needed by subplans are initialized from scratch when the - * subplans themselves are initialized. + * Share the parent's copy of ResultRelInfos needed by subplans. + * We must do this before initializing the subplan, because direct-modify + * FDWs expect their ResultRelInfos to be available. */ - rcestate->es_result_relations = NULL; + rcestate->es_result_relations = parentestate->es_result_relations; + /* es_trig_target_relations must NOT be copied */ rcestate->es_top_eflags = parentestate->es_top_eflags; rcestate->es_instrument = parentestate->es_instrument; -- 2.31.1