diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-01-12 20:47:09 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-01-12 20:47:09 -0500 |
commit | fed8dcdb84d255088d22efa3156a193f3399e792 (patch) | |
tree | 8262474db57695b73d2fcdb0975a5f89f5573307 /src/include/nodes/plannodes.h | |
parent | a1ed4cf6ca6ee2115d9f618ed7930a97842042a8 (diff) | |
download | postgresql-fed8dcdb84d255088d22efa3156a193f3399e792.tar.gz postgresql-fed8dcdb84d255088d22efa3156a193f3399e792.zip |
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/include/nodes/plannodes.h')
-rw-r--r-- | src/include/nodes/plannodes.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 79876100d5a..e14257932e6 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -158,6 +158,9 @@ typedef struct Result * ModifyTable node - * Apply rows produced by subplan(s) to result table(s), * by inserting, updating, or deleting. + * + * Note that rowMarks and epqParam are presumed to be valid for all the + * subplan(s); they can't contain any info that varies across subplans. * ---------------- */ typedef struct ModifyTable @@ -690,9 +693,18 @@ typedef enum RowMarkType * prti == parent's RT index, and can therefore be recognized as children by * the fact that prti != rti. * - * The AttrNumbers are filled in during preprocess_targetlist. We use - * different subsets of them for plain relations, inheritance children, - * and non-table relations. + * The planner also adds resjunk output columns to the plan that carry + * information sufficient to identify the locked or fetched rows. For + * tables (markType != ROW_MARK_COPY), these columns are named + * tableoid%u OID of table + * ctid%u TID of row + * The tableoid column is only present for an inheritance hierarchy. + * When markType == ROW_MARK_COPY, there is instead a single column named + * wholerow%u whole-row value of relation + * In all three cases, %u represents the parent rangetable index (prti). + * Note this means that all tables in an inheritance hierarchy share the + * same resjunk column names. However, in an inherited UPDATE/DELETE the + * columns could have different physical column numbers in each subplan. */ typedef struct PlanRowMark { @@ -702,9 +714,6 @@ typedef struct PlanRowMark RowMarkType markType; /* see enum above */ bool noWait; /* NOWAIT option */ bool isParent; /* true if this is a "dummy" parent entry */ - AttrNumber ctidAttNo; /* resno of ctid junk attribute, if any */ - AttrNumber toidAttNo; /* resno of tableoid junk attribute, if any */ - AttrNumber wholeAttNo; /* resno of whole-row junk attribute, if any */ } PlanRowMark; |