Oid tableOid = RelationGetRelid(OldHeap);
Oid tableSpace = OldHeap->rd_rel->reltablespace;
Oid OIDNewHeap;
+ char relpersistence;
bool is_system_catalog;
bool swap_toast_by_content;
TransactionId frozenXid;
if (OidIsValid(indexOid))
mark_index_clustered(OldHeap, indexOid, true);
- /* Remember if it's a system catalog */
+ /* Remember info about rel before closing OldHeap */
+ relpersistence = OldHeap->rd_rel->relpersistence;
is_system_catalog = IsSystemRelation(OldHeap);
/* Close relcache entry, but keep lock until transaction commit */
/* Create the transient table that will receive the re-ordered data */
OIDNewHeap = make_new_heap(tableOid, tableSpace,
- OldHeap->rd_rel->relpersistence,
+ relpersistence,
AccessExclusiveLock);
/* Copy the heap data into the new table in the desired order */
finish_heap_swap(tableOid, OIDNewHeap, is_system_catalog,
swap_toast_by_content, false, true,
frozenXid, cutoffMulti,
- OldHeap->rd_rel->relpersistence);
+ relpersistence);
}