+ /*
+ * If the result relation has OIDs, force the tuple's OID to zero so that
+ * heap_insert will assign a fresh OID. Usually the OID already will be
+ * zero at this point, but there are corner cases where the plan tree can
+ * return a tuple extracted literally from some table with the same
+ * rowtype.
+ *
+ * XXX if we ever wanted to allow users to assign their own OIDs to new
+ * rows, this'd be the place to do it. For the moment, we make a point
+ * of doing this before calling triggers, so that a user-supplied trigger
+ * could hack the OID if desired.
+ */
+ if (resultRelationDesc->rd_rel->relhasoids)
+ HeapTupleSetOid(tuple, InvalidOid);
+