diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index cd0def4aab9..d46cdf8c349 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -2105,7 +2105,9 @@ EvalPlanQualFetchRowMarks(EPQState *epqstate) /* build a temporary HeapTuple control structure */ tuple.t_len = HeapTupleHeaderGetDatumLength(td); ItemPointerSetInvalid(&(tuple.t_self)); - tuple.t_tableOid = InvalidOid; + /* relation might be a foreign table, if so provide tableoid */ + tuple.t_tableOid = getrelid(erm->rti, + epqstate->estate->es_range_table); tuple.t_data = td; /* copy and store tuple */