Обсуждение: pgsql: Disallow changing NO INHERIT status of a not-null constraint

Поиск
Список
Период
Сортировка

pgsql: Disallow changing NO INHERIT status of a not-null constraint

От
Alvaro Herrera
Дата:
Disallow changing NO INHERIT status of a not-null constraint

It makes no sense to add a NO INHERIT not-null constraint to a child
table that already has one in that column inherited from its parent.
Disallow that, and add tests for the relevant cases.

Per complaint from Kyotaro Horiguchi.  I also used part of his proposed
patch.

Co-authored-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Co-authored-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/20230828.161658.1184657435220765047.horikyota.ntt@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9b581c53418666205938311ef86047aa3c6b741f

Modified Files
--------------
src/backend/catalog/heap.c            | 13 ++++++++++++-
src/backend/catalog/pg_constraint.c   | 22 ++++++++++++++++++----
src/include/catalog/pg_constraint.h   |  3 ++-
src/test/regress/expected/inherit.out |  9 +++++++++
src/test/regress/sql/inherit.sql      |  6 ++++++
5 files changed, 47 insertions(+), 6 deletions(-)