Skip to content

Commit f20cad7

Browse files
committed
Preserve tuple OIDs during ATRewriteTable. Per gripe from Duncan Crombie.
1 parent 4361e0d commit f20cad7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/commands/tablecmds.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.172 2005/10/02 23:50:08 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.173 2005/10/03 02:45:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2509,8 +2509,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
25092509
{
25102510
if (newrel)
25112511
{
2512+
Oid tupOid = InvalidOid;
2513+
25122514
/* Extract data from old tuple */
25132515
heap_deform_tuple(tuple, oldTupDesc, values, isnull);
2516+
if (oldTupDesc->tdhasoid)
2517+
tupOid = HeapTupleGetOid(tuple);
25142518

25152519
/* Set dropped attributes to null in new tuple */
25162520
foreach (lc, dropped_attrs)
@@ -2539,6 +2543,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
25392543
* be reset shortly.
25402544
*/
25412545
tuple = heap_form_tuple(newTupDesc, values, isnull);
2546+
2547+
/* Preserve OID, if any */
2548+
if (newTupDesc->tdhasoid)
2549+
HeapTupleSetOid(tuple, tupOid);
25422550
}
25432551

25442552
/* Now check any constraints on the possibly-changed tuple */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy