mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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.
This commit is contained in:
@ -1929,10 +1929,6 @@ preprocess_rowmarks(PlannerInfo *root)
|
||||
newrc->markType = ROW_MARK_SHARE;
|
||||
newrc->noWait = rc->noWait;
|
||||
newrc->isParent = false;
|
||||
/* attnos will be assigned in preprocess_targetlist */
|
||||
newrc->ctidAttNo = InvalidAttrNumber;
|
||||
newrc->toidAttNo = InvalidAttrNumber;
|
||||
newrc->wholeAttNo = InvalidAttrNumber;
|
||||
|
||||
prowmarks = lappend(prowmarks, newrc);
|
||||
}
|
||||
@ -1959,10 +1955,6 @@ preprocess_rowmarks(PlannerInfo *root)
|
||||
newrc->markType = ROW_MARK_COPY;
|
||||
newrc->noWait = false; /* doesn't matter */
|
||||
newrc->isParent = false;
|
||||
/* attnos will be assigned in preprocess_targetlist */
|
||||
newrc->ctidAttNo = InvalidAttrNumber;
|
||||
newrc->toidAttNo = InvalidAttrNumber;
|
||||
newrc->wholeAttNo = InvalidAttrNumber;
|
||||
|
||||
prowmarks = lappend(prowmarks, newrc);
|
||||
}
|
||||
|
Reference in New Issue
Block a user