Commit 60dd40bb authored by Robert Haas's avatar Robert Haas

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.
parent 09df854b
...@@ -6638,7 +6638,6 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool * ...@@ -6638,7 +6638,6 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
TupleDesc idx_desc; TupleDesc idx_desc;
char replident = relation->rd_rel->relreplident; char replident = relation->rd_rel->relreplident;
HeapTuple key_tuple = NULL; HeapTuple key_tuple = NULL;
bool copy_oid = false;
bool nulls[MaxHeapAttributeNumber]; bool nulls[MaxHeapAttributeNumber];
Datum values[MaxHeapAttributeNumber]; Datum values[MaxHeapAttributeNumber];
int natt; int natt;
...@@ -6697,20 +6696,30 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool * ...@@ -6697,20 +6696,30 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
{ {
int attno = idx_rel->rd_index->indkey.values[natt]; int attno = idx_rel->rd_index->indkey.values[natt];
if (attno == ObjectIdAttributeNumber) if (attno < 0)
copy_oid = true; {
else if (attno < 0) /*
* The OID column can appear in an index definition, but that's
* OK, becuse we always copy the OID if present (see below).
* Other system columns may not.
*/
if (attno == ObjectIdAttributeNumber)
continue;
elog(ERROR, "system column in index"); elog(ERROR, "system column in index");
else }
nulls[attno - 1] = false; nulls[attno - 1] = false;
} }
key_tuple = heap_form_tuple(desc, values, nulls); key_tuple = heap_form_tuple(desc, values, nulls);
*copy = true; *copy = true;
RelationClose(idx_rel); RelationClose(idx_rel);
/* XXX: we could also do this unconditionally, the space is used anyway */ /*
if (copy_oid) * Always copy oids if the table has them, even if not included in the
* index. The space in the logged tuple is used anyway, so there's little
* point in not including the information.
*/
if (relation->rd_rel->relhasoids)
HeapTupleSetOid(key_tuple, HeapTupleGetOid(tp)); HeapTupleSetOid(key_tuple, HeapTupleGetOid(tp));
/* /*
......
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