pgsql: Fix improper matching of resjunk column names for FOR UPDATE in

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix improper matching of resjunk column names for FOR UPDATE in
Date: 2011-02-10 04:30:06
Message-ID: E1PnOAQ-0000UI-FM@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix improper matching of resjunk column names for FOR UPDATE in subselect.

Flattening of subquery range tables during setrefs.c could lead to the
rangetable indexes in PlanRowMark nodes not matching up with the column
names previously assigned to the corresponding resjunk ctid (resp. tableoid
or wholerow) columns. Typical symptom would be either a "cannot extract
system attribute from virtual tuple" error or an Assert failure. This
wasn't a problem before 9.0 because we didn't support FOR UPDATE below the
top query level, and so the final flattening could never renumber an RTE
that was relevant to FOR UPDATE. Fix by using a plan-tree-wide unique
number for each PlanRowMark to label the associated resjunk columns, so
that the number need not change during flattening.

Per report from David Johnston (though I'm darned if I can see how this got
past initial testing of the relevant code). Back-patch to 9.0.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/d5478c3391f8f1a243abbc3d9253aac3d6d3538e

Modified Files
--------------
src/backend/executor/execMain.c | 13 ++++++++++---
src/backend/nodes/copyfuncs.c | 1 +
src/backend/nodes/outfuncs.c | 2 ++
src/backend/optimizer/plan/planner.c | 3 +++
src/backend/optimizer/plan/setrefs.c | 2 +-
src/backend/optimizer/prep/preptlist.c | 6 +++---
src/backend/optimizer/prep/prepunion.c | 1 +
src/include/nodes/execnodes.h | 1 +
src/include/nodes/plannodes.h | 7 ++++++-
src/include/nodes/relation.h | 2 ++
10 files changed, 30 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Gurjeet Singh 2011-02-10 06:04:54 Re: [COMMITTERS] pgsql: Update docs on building for Windows to accomodate current realit
Previous Message Itagaki Takahiro 2011-02-10 01:59:44 pgsql: Fix typo in the documentation.