doc: Clarify ALTER CONSTRAINT enforceability wording
doc: Clarify ALTER CONSTRAINT enforceability wording
Hi,
I just started to test “Add support for altering CHECK constraint enforceability”. I read the related ALTER TABLE doc first, and found it a bit confusing:
```
ALTER CONSTRAINT
This form alters the attributes of a constraint that was previously created. Currently FOREIGN KEY and CHECK constraints may be altered in this fashion, but see below.
```
In the feature commit 342051d73, only “CHECK" was added:
```
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -578,8 +578,8 @@ WITH ( MODULUS numeric_literal, REM
This form alters the attributes of a constraint that was previously
- created. Currently only foreign key constraints may be altered in
- this fashion, but see below.
+ created. Currently FOREIGN KEY and CHECK
+ constraints may be altered in this fashion, but see below.
```
However, the last phrase “but see below” is quite confusing. I read the doc several times up and down, and finally my best guess is that “see below” refers to the immediately following paragraph’s sentence “Only not-null constraints may be altered in this fashion at present”, but the sentence does not say anything about enforceability.
```
ALTER CONSTRAINT ... INHERIT
ALTER CONSTRAINT ... NO INHERIT
These forms modify an inheritable constraint so that it becomes not inheritable, or vice-versa. **Only not-null constraints may be altered in this fashion at present.** In addition to changing the inheritability status of the constraint, in the case where a non-inheritable constraint is being marked inheritable, if the table has children, an equivalent constraint will be added to them. If marking an inheritable constraint as non-inheritable on a table with children, then the corresponding constraint on children will be marked as no longer inherited, but not removed.
```
As I understand it, the current behavior is:
* Deferrability attributes can only be altered for FOREIGN KEY constraints
* Enforceability attributes can be altered for both FOREIGN KEY and CHECK constraints, and CHECK support was newly added by 342051d73 for v19
To remove the confusion, I updated the documentation. See the attached patch for details.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Re: doc: Clarify ALTER CONSTRAINT enforceability wording
От:
Chao Li <li.evan.chao@gmail.com>
Дата:
> On May 25, 2026, at 17:31, Chao Li wrote: > > Hi, > > I just started to test “Add support for altering CHECK constraint enforceability”. I read the related ALTER TABLE doc first, and found it a bit confusing: > ``` > ALTER CONSTRAINT > This form alters the attributes of a constraint that was previously created. Currently FOREIGN KEY and CHECK constraints may be altered in this fashion, but see below. > ``` > > In the feature commit 342051d73, only “CHECK" was added: > ``` > --- a/doc/src/sgml/ref/alter_table.sgml > +++ b/doc/src/sgml/ref/alter_table.sgml > @@ -578,8 +578,8 @@ WITH ( MODULUS numeric_literal, REM > > > This form alters the attributes of a constraint that was previously > - created. Currently only foreign key constraints may be altered in > - this fashion, but see below. > + created. Currently FOREIGN KEY and CHECK > + constraints may be altered in this fashion, but see below. > > ``` > > However, the last phrase “but see below” is quite confusing. I read the doc several times up and down, and finally my best guess is that “see below” refers to the immediately following paragraph’s sentence “Only not-null constraints may be altered in this fashion at present”, but the sentence does not say anything about enforceability. > ``` > ALTER CONSTRAINT ... INHERIT > ALTER CONSTRAINT ... NO INHERIT > These forms modify an inheritable constraint so that it becomes not inheritable, or vice-versa. **Only not-null constraints may be altered in this fashion at present.** In addition to changing the inheritability status of the constraint, in the case where a non-inheritable constraint is being marked inheritable, if the table has children, an equivalent constraint will be added to them. If marking an inheritable constraint as non-inheritable on a table with children, then the corresponding constraint on children will be marked as no longer inherited, but not removed. > ``` > > As I understand it, the current behavior is: > * Deferrability attributes can only be altered for FOREIGN KEY constraints > * Enforceability attributes can be altered for both FOREIGN KEY and CHECK constraints, and CHECK support was newly added by 342051d73 for v19 > > To remove the confusion, I updated the documentation. See the attached patch for details. > > Best regards, > -- > Chao Li (Evan) > HighGo Software Co., Ltd. > https://www.highgo.com/ > > > > > As I found a bug of the feature and proposed a fix in [1], let's merge this thread into that one, as they are for the same feature. [1] https://postgr.es/m/E74C57FA-1DD0-4C8E-8FB1-538034752592@gmail.com Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/