Support for NO INHERIT to INHERIT state change with named NOT NULL constraints
Suraj Kharage <suraj.kharage@enterprisedb.com>
From: Suraj Kharage <suraj.kharage@enterprisedb.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2024-11-14T05:01:56Z
Lists: pgsql-hackers
Attachments
- v1-alter_not_null_constraint_to_inherit.patch (application/x-patch) patch v1
Hi, Upstream commit 14e87ffa5c543b5f30ead7413084c25f7735039f <https://github.com/postgres/postgres/commit/14e87ffa5c543b5f30ead7413084c25f7735039f> added the support for named NOT NULL constraints which are INHERIT by default. We can declare those as NO INHERIT which means those constraints will not be inherited to child tables and after this state, we don't have the functionality to change the state back to INHERIT. This patch adds this support where named NOT NULL constraint defined as NO INHERIT can be changed to INHERIT. For this, introduced the new syntax something like - ALTER TABLE <tabname> ALTER CONSTRAINT <constrname> INHERIT; Once the not null constraints are altered to INHERIT from NO INHERIT, recurse to all children and propagate the constraint if it doesn't exist. Alvaro stated that allowing a not null constraint state to be modified from INHERIT to NO INHERIT is going to be quite problematic because of the number of weird cases to avoid, so for now that support is not added. Please share your thoughts on the same. -- Thanks & Regards, Suraj kharage, enterprisedb.com <https://www.enterprisedb.com/>
Commits
-
Small fixes for Add ALTER TABLE ... ALTER CONSTRAINT ... SET [NO] INHERIT
- f4b2a62ae314 18.0 landed
-
Add ALTER TABLE ... ALTER CONSTRAINT ... SET [NO] INHERIT
- f4e53e10b6ce 18.0 landed
-
Add pg_constraint rows for not-null constraints
- 14e87ffa5c54 18.0 cited