pgsql: Add missing buffer lock acquisition in GetTupleForTrigger(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Add missing buffer lock acquisition in GetTupleForTrigger().
Date
Msg-id E1TeVlg-00033G-E3@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add missing buffer lock acquisition in GetTupleForTrigger().

If we had not been holding buffer pin continuously since the tuple was
initially fetched by the UPDATE or DELETE query, it would be possible for
VACUUM or a page-prune operation to move the tuple while we're trying to
copy it.  This would result in a garbage "old" tuple value being passed to
an AFTER ROW UPDATE or AFTER ROW DELETE trigger.  The preconditions for
this are somewhat improbable, and the timing constraints are very tight;
so it's not so surprising that this hasn't been reported from the field,
even though the bug has been there a long time.

Problem found by Andres Freund.  Back-patch to all active branches.

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/244413f0041cf6c55053d83c71ae2ec8fb6224d3

Modified Files
--------------
src/backend/commands/trigger.c |   12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Add missing buffer lock acquisition in GetTupleForTrigger().
Next
From: Tom Lane
Date:
Subject: pgsql: Add missing buffer lock acquisition in GetTupleForTrigger().