From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Admit deferrable PKs into rd_pkindex, but flag them as such |
Date: | 2024-03-08 15:33:24 |
Message-ID: | E1ricDs-002jdc-8L@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(at)gmail(dot)com>
Reviewed-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAAJ_b94QonkgsbDXofakHDnORQNgafd1y3Oa5QXfpQNJyXyQ7A@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/270af6f0df764d326e1a7355f4ce10dc73b05dac
Modified Files
--------------
src/backend/replication/logical/relation.c | 6 +-
src/backend/utils/cache/relcache.c | 27 ++++++--
src/include/utils/rel.h | 3 +-
src/test/regress/expected/constraints.out | 92 ++++++++++++++++++++++++++
src/test/regress/expected/publication.out | 10 +++
src/test/regress/expected/replica_identity.out | 5 ++
src/test/regress/sql/constraints.sql | 25 +++++++
src/test/regress/sql/publication.sql | 9 +++
src/test/regress/sql/replica_identity.sql | 4 ++
9 files changed, 170 insertions(+), 11 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-03-08 17:07:44 | pgsql: Improve WIN32 waiting logic in psql's \watch command. |
Previous Message | Alexander Korotkov | 2024-03-08 11:19:14 | pgsql: Turn tail recursion into iteration in CommitTransactionCommand() |