*** pgsql/src/backend/utils/adt/trigfuncs.c 2008/11/05 19:15:15 1.4 --- pgsql/src/backend/utils/adt/trigfuncs.c 2008/11/05 20:17:18 1.5 *************** *** 7,13 **** * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * ! * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.3 2008/11/05 18:49:27 adunstan Exp $ * *------------------------------------------------------------------------- */ --- 7,13 ---- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * ! * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.4 2008/11/05 19:15:15 adunstan Exp $ * *------------------------------------------------------------------------- */ *************** suppress_redundant_updates_trigger(PG_FU *** 62,72 **** newheader = newtuple->t_data; oldheader = oldtuple->t_data; if (trigdata->tg_relation->rd_rel->relhasoids && !OidIsValid(HeapTupleHeaderGetOid(newheader))) HeapTupleHeaderSetOid(newheader, HeapTupleHeaderGetOid(oldheader)); - /* if the tuple payload is the same ... */ if (newtuple->t_len == oldtuple->t_len && newheader->t_hoff == oldheader->t_hoff && --- 62,78 ---- newheader = newtuple->t_data; oldheader = oldtuple->t_data; + /* + * We are called before the OID, if any, has been transcribed from the + * old tuple to the new (in heap_update). To avoid a bogus compare + * failure, copy the OID now. But check that someone didn't already put + * another OID value into newtuple. (That's not actually possible at + * present, but maybe someday.) + */ if (trigdata->tg_relation->rd_rel->relhasoids && !OidIsValid(HeapTupleHeaderGetOid(newheader))) HeapTupleHeaderSetOid(newheader, HeapTupleHeaderGetOid(oldheader)); /* if the tuple payload is the same ... */ if (newtuple->t_len == oldtuple->t_len && newheader->t_hoff == oldheader->t_hoff && *************** suppress_redundant_updates_trigger(PG_FU *** 81,87 **** /* ... then suppress the update */ rettuple = NULL; } ! ! ! return PointerGetDatum(rettuple); } --- 87,92 ---- /* ... then suppress the update */ rettuple = NULL; } ! ! return PointerGetDatum(rettuple); }