mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Admit deferrable PKs into rd_pkindex, but flag them as such
... and in particular don't return them as replica identity. The motivation for this change is letting the primary keys be seen by code that derives NOT NULL constraints from them, when creating inheritance children; before this change, if you had a deferrable PK, pg_dump would not recreate the attnotnull marking properly, because the column would not be considered as having anything to back said marking after dropping the throwaway NOT NULL constraint. The reason we don't want these PKs as replica identities is that replication can corrupt data, if the uniqueness constraint is transiently broken. Reported-by: Amul Sul <sulamul@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/CAAJ_b94QonkgsbDXofakHDnORQNgafd1y3Oa5QXfpQNJyXyQ7A@mail.gmail.com
This commit is contained in:
@ -843,9 +843,9 @@ IsIndexUsableForReplicaIdentityFull(IndexInfo *indexInfo, AttrMap *attrmap)
|
||||
}
|
||||
|
||||
/*
|
||||
* Get replica identity index or if it is not defined a primary key.
|
||||
*
|
||||
* If neither is defined, returns InvalidOid
|
||||
* Return the OID of the replica identity index if one is defined;
|
||||
* the OID of the PK if one exists and is not deferrable;
|
||||
* otherwise, InvalidOid.
|
||||
*/
|
||||
Oid
|
||||
GetRelationIdentityOrPK(Relation rel)
|
||||
|
Reference in New Issue
Block a user