Prevent setting NO INHERIT on partitioned not-null constraints

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Prevent setting NO INHERIT on partitioned not-null constraints
Date: 2026-05-20 19:25:31
Message-ID: ecc985ad-6ec1-4094-a315-317943ca5f3f@proxel.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Me and Joel found a bug when working on another patch. We noticed that
you cannot create not-null constraints with NO INHEIRT set on
partitioned tables, but you can actually set it later by using ALTER
CONSTRAINT. This must be an oversight so I have attached a patch which
adds a check to prevent this.

The SQL below should give an error but does not:

CREATE TABLE t (
a int,
CONSTRAINT a_is_not_null NOT NULL a
) PARTITION BY LIST (a);

ALTER TABLE t ALTER CONSTRAINT a_is_not_null NO INHERIT;

--
Andreas Karlsson
Percona

Attachment Content-Type Size
v1-0001-Prevent-setting-NO-INHERIT-on-paritioned-not-null.patch text/x-patch 3.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2026-05-20 20:13:43 Re: [PATCH] Fix REPACK decoding worker not cleaned up on FATAL exit
Previous Message Arseniy Mukhin 2026-05-20 17:55:53 Re: amcheck support for BRIN indexes