]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Preserve tuple OIDs during ATRewriteTable. Per gripe from Duncan Crombie.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 3 Oct 2005 02:45:25 +0000 (02:45 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 3 Oct 2005 02:45:25 +0000 (02:45 +0000)
src/backend/commands/tablecmds.c

index 2ab6a114c2a89a475a00d5606b9fe28697f31073..20c6437897aa40868319d18814a6999fdfa62196 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.142.4.3 2005/03/25 18:04:47 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.142.4.4 2005/10/03 02:45:25 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2486,8 +2486,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
                {
                        if (newrel)
                        {
+                               Oid             tupOid = InvalidOid;
+
                                /* Extract data from old tuple */
                                heap_deformtuple(tuple, oldTupDesc, values, nulls);
+                               if (oldTupDesc->tdhasoid)
+                                       tupOid = HeapTupleGetOid(tuple);
 
                                /* Set dropped attributes to null in new tuple */
                                foreach (lc, dropped_attrs)
@@ -2521,6 +2525,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
                                 * be reset shortly.
                                 */
                                tuple = heap_formtuple(newTupDesc, values, nulls);
+
+                               /* Preserve OID, if any */
+                               if (newTupDesc->tdhasoid)
+                                       HeapTupleSetOid(tuple, tupOid);
                        }
 
                        /* Now check any constraints on the possibly-changed tuple */