Commit f20cad78 authored by Tom Lane's avatar Tom Lane

Preserve tuple OIDs during ATRewriteTable. Per gripe from Duncan Crombie.

parent 4361e0d2
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.172 2005/10/02 23:50:08 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.173 2005/10/03 02:45:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2509,8 +2509,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) ...@@ -2509,8 +2509,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
{ {
if (newrel) if (newrel)
{ {
Oid tupOid = InvalidOid;
/* Extract data from old tuple */ /* Extract data from old tuple */
heap_deform_tuple(tuple, oldTupDesc, values, isnull); heap_deform_tuple(tuple, oldTupDesc, values, isnull);
if (oldTupDesc->tdhasoid)
tupOid = HeapTupleGetOid(tuple);
/* Set dropped attributes to null in new tuple */ /* Set dropped attributes to null in new tuple */
foreach (lc, dropped_attrs) foreach (lc, dropped_attrs)
...@@ -2539,6 +2543,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) ...@@ -2539,6 +2543,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
* be reset shortly. * be reset shortly.
*/ */
tuple = heap_form_tuple(newTupDesc, values, isnull); tuple = heap_form_tuple(newTupDesc, values, isnull);
/* Preserve OID, if any */
if (newTupDesc->tdhasoid)
HeapTupleSetOid(tuple, tupOid);
} }
/* Now check any constraints on the possibly-changed tuple */ /* Now check any constraints on the possibly-changed tuple */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment