diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index eaf76d2b902..45a51446434 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -11052,10 +11052,20 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode int16 attno = indexRel->rd_index->indkey.values[key]; Form_pg_attribute attr; - /* Of the system columns, only oid is indexable. */ - if (attno <= 0 && attno != ObjectIdAttributeNumber) - elog(ERROR, "internal column %u in unique index \"%s\"", - attno, RelationGetRelationName(indexRel)); + /* Allow OID column to be indexed; it's certainly not nullable */ + if (attno == ObjectIdAttributeNumber) + continue; + + /* + * Reject any other system columns. (Going forward, we'll disallow + * indexes containing such columns in the first place, but they might + * exist in older branches.) + */ + if (attno <= 0) + ereport(ERROR, + (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), + errmsg("index \"%s\" cannot be used as replica identity because column %d is a system column", + RelationGetRelationName(indexRel), attno))); attr = rel->rd_att->attrs[attno - 1]; if (!attr->attnotnull) |