77 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88 * Portions Copyright (c) 1994, Regents of the University of California
99 *
10- * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.4 2008/11/0519:15:15 adunstan Exp $
10+ * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.5 2008/11/0520:17:18 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -62,11 +62,17 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
6262newheader = newtuple -> t_data ;
6363oldheader = oldtuple -> t_data ;
6464
65+ /*
66+ * We are called before the OID, if any, has been transcribed from the
67+ * old tuple to the new (in heap_update). To avoid a bogus compare
68+ * failure, copy the OID now. But check that someone didn't already put
69+ * another OID value into newtuple. (That's not actually possible at
70+ * present, but maybe someday.)
71+ */
6572if (trigdata -> tg_relation -> rd_rel -> relhasoids &&
6673!OidIsValid (HeapTupleHeaderGetOid (newheader )))
6774HeapTupleHeaderSetOid (newheader ,HeapTupleHeaderGetOid (oldheader ));
6875
69-
7076/* if the tuple payload is the same ... */
7177if (newtuple -> t_len == oldtuple -> t_len &&
7278newheader -> t_hoff == oldheader -> t_hoff &&
@@ -81,7 +87,6 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
8187/* ... then suppress the update */
8288rettuple = NULL ;
8389}
84-
85-
86- return PointerGetDatum (rettuple );
90+
91+ return PointerGetDatum (rettuple );
8792}