]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Block ALTER TABLE .. DROP NOT NULL on columns in replica identity index
authorMichael Paquier <michael@paquier.xyz>
Thu, 25 Nov 2021 06:05:28 +0000 (15:05 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 25 Nov 2021 06:05:28 +0000 (15:05 +0900)
commit37827de430deba44f373db1e4efae0c9e320ef2d
treeb81edd6e643505f3e58e5d6a1131717e42ff9815
parent499552273d47645c759d58c5916b3bc8ecc7f13d
Block ALTER TABLE .. DROP NOT NULL on columns in replica identity index

Replica identities that depend directly on an index rely on a set of
properties, one of them being that all the columns defined in this index
have to be marked as NOT NULL.  There was a hole in the logic with ALTER
TABLE DROP NOT NULL, where it was possible to remove the NOT NULL
property of a column part of an index used as replica identity, so block
it to avoid problems with logical decoding down the road.

The same check was already done columns part of a primary key, so the
fix is straight-forward.

Author: Haiying Tang, Hou Zhijie
Reviewed-by: Dilip Kumar, Michael Paquier
Discussion: https://postgr.es/m/OS0PR01MB6113338C102BEE8B2FFC5BD9FB619@OS0PR01MB6113.jpnprd01.prod.outlook.com
Backpatch-through: 10
src/backend/commands/tablecmds.c
src/test/regress/expected/replica_identity.out
src/test/regress/sql/replica_identity.sql