pgsql: Ensure tableoid reads correctly in EvalPlanQual-manufactured tup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Ensure tableoid reads correctly in EvalPlanQual-manufactured tup
Date: 2015-03-12 17:39:24
Message-ID: E1YW74u-0003v6-SI@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/443fd0540e298b621be6748dead1fb444556e0d0

Modified Files
--------------
src/backend/executor/execMain.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-03-12 18:18:31 pgsql: Improve documentation of bt_page_items().
Previous Message Heikki Linnakangas 2015-03-12 15:29:40 pgsql: Fix memory leaks in GIN index vacuum.