Skip to content

Commit 4a4fd2b

Browse files
committed
Ensure tableoid reads correctly in EvalPlanQual-manufactured tuples.
The ROW_MARK_COPY path in EvalPlanQualFetchRowMarks() was just setting tableoid to InvalidOid, I think on the assumption that the referenced RTE must be a subquery or other case without a meaningful OID. However, foreign tables also use this code path, and they do have meaningful table OIDs; so failure to set the tuple field can lead to user-visible misbehavior. Fix that by fetching the appropriate OID from the range table. There's still an issue about whether CTID can ever have a meaningful value in this case; at least with postgres_fdw foreign tables, it does. But that is a different problem that seems to require a significantly different patch --- it's debatable whether postgres_fdw really wants to use this code path at all. Simplified version of a patch by Etsuro Fujita, who also noted the problem to begin with. The issue can be demonstrated in all versions having FDWs, so back-patch to 9.1.
1 parent 92bb008 commit 4a4fd2b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/executor/execMain.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,9 @@ EvalPlanQualFetchRowMarks(EPQState *epqstate)
21052105
/* build a temporary HeapTuple control structure */
21062106
tuple.t_len = HeapTupleHeaderGetDatumLength(td);
21072107
ItemPointerSetInvalid(&(tuple.t_self));
2108-
tuple.t_tableOid = InvalidOid;
2108+
/* relation might be a foreign table, if so provide tableoid */
2109+
tuple.t_tableOid = getrelid(erm->rti,
2110+
epqstate->estate->es_range_table);
21092111
tuple.t_data = td;
21102112

21112113
/* copy and store tuple */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy