diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-25 22:07:21 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-25 22:07:21 +0000 |
commit | 2ba05400242c31604c14a1d0276abeabc7d7ed77 (patch) | |
tree | 05477f5f8d56e3f28da62e254349d486ab035dc3 /src/backend/commands/trigger.c | |
parent | c9e69d71bda9a4e1b41bd2c08a2a57b70b97b334 (diff) | |
download | postgresql-2ba05400242c31604c14a1d0276abeabc7d7ed77.tar.gz postgresql-2ba05400242c31604c14a1d0276abeabc7d7ed77.zip |
Back-patch fixes for problems with VACUUM destroying t_ctid chains too soon,
and with insufficient paranoia in code that follows t_ctid links.
This patch covers the 7.4 branch.
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r-- | src/backend/commands/trigger.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index d2cc87e43d5..f49fa1a02fd 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.159 2003/10/02 06:34:03 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.159.2.1 2005/08/25 22:07:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1556,14 +1556,18 @@ GetTupleForTrigger(EState *estate, ResultRelInfo *relinfo, if (newSlot != NULL) { int test; + ItemPointerData update_ctid; + TransactionId update_xmax; + + *newSlot = NULL; /* * mark tuple for update */ - *newSlot = NULL; - tuple.t_self = *tid; ltrmark:; - test = heap_mark4update(relation, &tuple, &buffer, cid); + tuple.t_self = *tid; + test = heap_mark4update(relation, &tuple, &buffer, + &update_ctid, &update_xmax, cid); switch (test) { case HeapTupleSelfUpdated: @@ -1580,15 +1584,18 @@ ltrmark:; ereport(ERROR, (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), errmsg("could not serialize access due to concurrent update"))); - else if (!(ItemPointerEquals(&(tuple.t_self), tid))) + else if (!ItemPointerEquals(&update_ctid, &tuple.t_self)) { - TupleTableSlot *epqslot = EvalPlanQual(estate, - relinfo->ri_RangeTableIndex, - &(tuple.t_self)); - - if (!(TupIsNull(epqslot))) + /* it was updated, so look at the updated version */ + TupleTableSlot *epqslot; + + epqslot = EvalPlanQual(estate, + relinfo->ri_RangeTableIndex, + &update_ctid, + update_xmax); + if (!TupIsNull(epqslot)) { - *tid = tuple.t_self; + *tid = update_ctid; *newSlot = epqslot; goto ltrmark; } @@ -1626,6 +1633,7 @@ ltrmark:; tuple.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tuple.t_len = ItemIdGetLength(lp); tuple.t_self = *tid; + tuple.t_tableOid = RelationGetRelid(relation); } result = heap_copytuple(&tuple); |