This maneuver really requires a comment ...
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 5 Nov 2008 20:17:18 +0000 (20:17 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 5 Nov 2008 20:17:18 +0000 (20:17 +0000)
src/backend/utils/adt/trigfuncs.c

index a8304f1931ab69f1ce9207a0c66c080a21525ef3..54d49dc4763d165357707045a3276617f8c5c242 100644 (file)
@@ -62,11 +62,17 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
        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 &&
@@ -81,7 +87,6 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
                /* ... then suppress the update */
                rettuple = NULL;
        }
-       
-       
-    return PointerGetDatum(rettuple);
+
+       return PointerGetDatum(rettuple);
 }