Skip to content

Commit 60dd40b

Browse files
committed
Under wal_level=logical, when saving old tuples, always save OID.
There's no real point in not doing this. It doesn't cost anything in performance or space. So let's go wild. Andres Freund, with substantial editing as to style by me.
1 parent 09df854 commit 60dd40b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/backend/access/heap/heapam.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6638,7 +6638,6 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
66386638
TupleDesc idx_desc;
66396639
char replident = relation->rd_rel->relreplident;
66406640
HeapTuple key_tuple = NULL;
6641-
bool copy_oid = false;
66426641
bool nulls[MaxHeapAttributeNumber];
66436642
Datum values[MaxHeapAttributeNumber];
66446643
int natt;
@@ -6697,20 +6696,30 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
66976696
{
66986697
int attno = idx_rel->rd_index->indkey.values[natt];
66996698

6700-
if (attno == ObjectIdAttributeNumber)
6701-
copy_oid = true;
6702-
else if (attno < 0)
6699+
if (attno < 0)
6700+
{
6701+
/*
6702+
* The OID column can appear in an index definition, but that's
6703+
* OK, becuse we always copy the OID if present (see below).
6704+
* Other system columns may not.
6705+
*/
6706+
if (attno == ObjectIdAttributeNumber)
6707+
continue;
67036708
elog(ERROR, "system column in index");
6704-
else
6705-
nulls[attno - 1] = false;
6709+
}
6710+
nulls[attno - 1] = false;
67066711
}
67076712

67086713
key_tuple = heap_form_tuple(desc, values, nulls);
67096714
*copy = true;
67106715
RelationClose(idx_rel);
67116716

6712-
/* XXX: we could also do this unconditionally, the space is used anyway */
6713-
if (copy_oid)
6717+
/*
6718+
* Always copy oids if the table has them, even if not included in the
6719+
* index. The space in the logged tuple is used anyway, so there's little
6720+
* point in not including the information.
6721+
*/
6722+
if (relation->rd_rel->relhasoids)
67146723
HeapTupleSetOid(key_tuple, HeapTupleGetOid(tp));
67156724

67166725
/*

0 commit comments

Comments
 (0)