Re: cataloguing NOT NULL constraints - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: cataloguing NOT NULL constraints
Date
Msg-id 202404251016.m2jyipj2zaav@alvherre.pgsql
Whole thread Raw
In response to Re: cataloguing NOT NULL constraints  (Alexander Lakhin <exclusion@gmail.com>)
Responses Re: cataloguing NOT NULL constraints
List pgsql-hackers
On 2024-Apr-25, Alexander Lakhin wrote:

> While studying the NO INHERIT option, I've noticed that the documentation
> probably misses it's specification for NOT NULL:
> https://www.postgresql.org/docs/devel/sql-createtable.html
> 
> where column_constraint is:
> ...
> [ CONSTRAINT constraint_name ]
> { NOT NULL |
>   NULL |
>   CHECK ( expression ) [ NO INHERIT ] |

Hmm, okay, will fix.

> Also, I've found a weird behaviour with a non-inherited NOT NULL
> constraint for a partitioned table:
> CREATE TABLE pt(a int NOT NULL NO INHERIT) PARTITION BY LIST (a);
> CREATE TABLE dp(a int NOT NULL);
> ALTER TABLE pt ATTACH PARTITION dp DEFAULT;
> ALTER TABLE pt DETACH PARTITION dp;
> fails with:
> ERROR:  relation 16389 has non-inherited constraint "dp_a_not_null"

Ugh.  Maybe a way to handle this is to disallow NO INHERIT in
constraints on partitioned tables altogether.  I mean, they are a
completely useless gimmick, aren't they?

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: broken reading on standby (PostgreSQL 16.2)
Next
From: Amit Kapila
Date:
Subject: Re: Race condition in FetchTableStates() breaks synchronization of subscription tables