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/