diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-01-12 20:47:02 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-01-12 20:47:02 -0500 |
commit | d487afbb813b7ca8803e20974b9e45530a1f4ef1 (patch) | |
tree | 81c79a1546e772ad11114d705fcc3cbc3b05822a /src/backend/executor/execJunk.c | |
parent | 7a32ff97321408afa0ddfcae1a4a060062956d24 (diff) |
Fix PlanRowMark/ExecRowMark structures to handle inheritance correctly.
In an inherited UPDATE/DELETE, each target table has its own subplan,
because it might have a column set different from other targets. This
means that the resjunk columns we add to support EvalPlanQual might be
at different physical column numbers in each subplan. The EvalPlanQual
rewrite I did for 9.0 failed to account for this, resulting in possible
misbehavior or even crashes during concurrent updates to the same row,
as seen in a recent report from Gordon Shannon. Revise the data structure
so that we track resjunk column numbers separately for each subplan.
I also chose to move responsibility for identifying the physical column
numbers back to executor startup, instead of assuming that numbers derived
during preprocess_targetlist would stay valid throughout subsequent
massaging of the plan. That's a bit slower, so we might want to consider
undoing it someday; but it would complicate the patch considerably and
didn't seem justifiable in a bug fix that has to be back-patched to 9.0.
Diffstat (limited to 'src/backend/executor/execJunk.c')
-rw-r--r-- | src/backend/executor/execJunk.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index c4987789e7d..5d0174c5afe 100644 --- a/src/backend/executor/execJunk.c +++ b/src/backend/executor/execJunk.c @@ -208,9 +208,21 @@ ExecInitJunkFilterConversion(List *targetList, AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter, const char *attrName) { + return ExecFindJunkAttributeInTlist(junkfilter->jf_targetList, attrName); +} + +/* + * ExecFindJunkAttributeInTlist + * + * Find a junk attribute given a subplan's targetlist (not necessarily + * part of a JunkFilter). + */ +AttrNumber +ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName) +{ ListCell *t; - foreach(t, junkfilter->jf_targetList) + foreach(t, targetlist) { TargetEntry *tle = lfirst(t); |