pgsql: Add missing buffer lock acquisition in GetTupleForTrigger().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add missing buffer lock acquisition in GetTupleForTrigger().
Date: 2012-11-30 18:56:56
Message-ID: E1TeVlg-000336-8j@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1c316e3a02e7eb8aaf8e04a441fc176aef06e317

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

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2012-11-30 19:50:00 pgsql: Move long_options structures to the top of main() functions, for
Previous Message Andrew Dunstan 2012-11-30 15:55:18 pgsql: Clean environment for pg_upgrade test.