Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wRRf5-002LoD-1g for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2026 09:31:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRRf2-000yGs-1W for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2026 09:31:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wRRf2-000yGk-04 for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2026 09:31:49 +0000 Received: from mail-dy1-x1333.google.com ([2607:f8b0:4864:20::1333]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wRRf0-00000000gFi-2TEE for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2026 09:31:47 +0000 Received: by mail-dy1-x1333.google.com with SMTP id 5a478bee46e88-2f33ae12f97so364450eec.1 for ; Mon, 25 May 2026 02:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779701505; x=1780306305; darn=lists.postgresql.org; h=to:cc:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=fq6byI/Nx/xD5UVw1plBwlRbEK8igDn0u0Aa1qixZpw=; b=itv44WTqIMjaAKOzcxmj4sXwwtHzg+4tQz8cWqmslO7iyx8AH1VIsRaIXGb7ex4gEV OjsJ+oi4d5BTZhe98aKaZJqFmlUgPOz7G6qPE8WPxotV3pCH0e9hXJTM5VUHuZqMTQcZ CSyM2sjOx+ODuD2hWFeoG8SOOhZ574AtlKTgKTMghW8dL0U2mnqHD+F2m9c0xm3MyRb3 KTm+Nbqjsuf64A65mwCWuNwHVg+Fsc15bJMc18CZ20s/GFU/7WFMHafW/1iQZLPrTufH FJiWCRw7hqQQUbHMCJAnmXh5BhpM+Da6elDa4BR0vKuy7RVxBTyWW7kKj8puThzf2uok UwDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779701505; x=1780306305; h=to:cc:date:message-id:subject:mime-version:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fq6byI/Nx/xD5UVw1plBwlRbEK8igDn0u0Aa1qixZpw=; b=WHEikKGSB5kqdH/BTmUtRlae5biVkMVRT42U/gZkt7B6gYUgsNfb2IahMjXajzqqlr 2yabgXwkrX6uQjmlMXkeZ+vrKXymAEFaht+f4ZN6qTysNXMeLkSKAKPWIFXUOLgSRc3f KnDLA7HjycZYdyaAYXzpdeyspdV23p01us30EfM9hn3R31EHP3haEW+byjhQKwsBE6y8 rF1b2oN07XxUfAu17HW6Pvd21EhWbJ/wsiOpPajwAJZRdBCfHgcQwnMBo0UTVE6Otsmq zJWxKMjnJ9EHjZD53A0s1c36+FQfR5ZPJNd8Lt4tuJ8FYBm9P3jbgxtFcHED5mTtvKbC LH/g== X-Gm-Message-State: AOJu0YzbXu1awD1crQji1yPSBdq4w85XvgLA87gmvfiHNFf2ZPRi19H3 FndtefrFkKe+dOo8GYNCq29AwG1ysoFaUU6bNLDOJsFff9cBrVvq8BJpigOu9lZpCHw= X-Gm-Gg: Acq92OE9TgFBvx57c0mhhup2+1vwWJYZo2+VPl8tM+gf7nzuUhixMPexTZ5sDZ8vIS2 XoTS3wLj4bq+ZHLY583erdjqGg/5EAxMY6NbbTTS/twTy+xbjjoDY+1+wnfbgpWODh6MqpeaXqL kIDcX69FN0fSZjytvbEzfzJ0UdrFJg3MJM9fxUw6O7j9qVrkJBQICp7vBRrj9y+fYs8KIla6A6i t7uZC8itRNOLLAlNRtbuAfm67pxkvPD++OTkXlzCliQV7x5htPql/SQzLi0PwuUvY2gjai5ZpWj FM/MbP7GlwzJRGiFcw00kFK4g+hZmBlbCkwFt5yjUOv+no4zzwhSo+Zk29cSj3vMkhl36JyOTFi 6UtL4eA2CG5rUd/5KferedlDa+feTKnkiwE8fvgNAPRG76UUPWhf7isCvnRwqIP5OWYBrk+yl5p hQ8cSbHwRudS5NslzVaFUfzsGoNXAA0w== X-Received: by 2002:a05:693c:2b10:b0:2e7:c701:aa85 with SMTP id 5a478bee46e88-304491415edmr6909873eec.17.1779701505175; Mon, 25 May 2026 02:31:45 -0700 (PDT) Received: from smtpclient.apple ([64.32.14.230]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3045245fbeesm7556069eec.30.2026.05.25.02.31.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 May 2026 02:31:42 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_18EB9990-4BA6-4CE2-93F7-E551CF7B0912" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: doc: Clarify ALTER CONSTRAINT enforceability wording Message-Id: <711B1ED3-1781-4B6C-A573-B58AF20770E5@gmail.com> Date: Mon, 25 May 2026 17:31:07 +0800 Cc: Andrew Dunstan , jian he To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_18EB9990-4BA6-4CE2-93F7-E551CF7B0912 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, I just started to test =E2=80=9CAdd support for altering CHECK = constraint enforceability=E2=80=9D. I read the related ALTER TABLE doc = first, and found it a bit confusing: ``` ALTER CONSTRAINT=20 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 =E2=80=9CCHECK" 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 =E2=80=9Cbut see below=E2=80=9D is quite = confusing. I read the doc several times up and down, and finally my best = guess is that =E2=80=9Csee below=E2=80=9D refers to the immediately = following paragraph=E2=80=99s sentence =E2=80=9COnly not-null = constraints may be altered in this fashion at present=E2=80=9D, but the = sentence does not say anything about enforceability. ``` ALTER CONSTRAINT ... INHERIT ALTER CONSTRAINT ... NO INHERIT=20 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/ --Apple-Mail=_18EB9990-4BA6-4CE2-93F7-E551CF7B0912 Content-Disposition: attachment; filename=v1-0001-doc-Clarify-ALTER-CONSTRAINT-enforceability-behav.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-doc-Clarify-ALTER-CONSTRAINT-enforceability-behav.patch" Content-Transfer-Encoding: quoted-printable =46rom=20321421de15be0a09ae5cd71317d0deeb50173c9b=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Mon,=2025=20May=202026=2016:59:21=20+0800=0ASubject:=20[PATCH=20= v1]=20doc:=20Clarify=20ALTER=20CONSTRAINT=20enforceability=20behavior=0A=0A= The=20ALTER=20TABLE=20documentation=20said=20that=20FOREIGN=20KEY=20and=20= CHECK=0Aconstraints=20may=20be=20altered,=20but=20did=20not=20= distinguish=20between=0Adeferrability=20and=20enforceability=20= attributes.=0A=0AClarify=20that=20deferrability=20attributes=20can=20= currently=20be=20altered=20only=20for=0AFOREIGN=20KEY=20constraints,=20= while=20enforceability=20can=20be=20altered=20for=20both=0AFOREIGN=20KEY=20= and=20CHECK=20constraints.=20=20Also=20document=20that=20setting=20a=0A= constraint=20to=20ENFORCED=20verifies=20existing=20rows=20and=20resumes=20= checking=20new=0Aor=20updated=20rows.=0A=0AAuthor:=20Chao=20Li=20= =0A---=0A=20doc/src/sgml/ref/alter_table.sgml=20|=2014=20= ++++++++++++--=0A=201=20file=20changed,=2012=20insertions(+),=202=20= deletions(-)=0A=0Adiff=20--git=20a/doc/src/sgml/ref/alter_table.sgml=20= b/doc/src/sgml/ref/alter_table.sgml=0Aindex=20dec34337d1a..af247d82902=20= 100644=0A---=20a/doc/src/sgml/ref/alter_table.sgml=0A+++=20= b/doc/src/sgml/ref/alter_table.sgml=0A@@=20-586,8=20+586,18=20@@=20WITH=20= (=20MODULUS=20numeric_literal,=20REM=0A=20=20=20=20=20= =0A=20=20=20=20=20=20=0A=20=20=20=20=20=20=20This=20form=20= alters=20the=20attributes=20of=20a=20constraint=20that=20was=20= previously=0A-=20=20=20=20=20=20created.=20Currently=20FOREIGN=20= KEY=20and=20CHECK=0A-=20=20=20=20=20=20= constraints=20may=20be=20altered=20in=20this=20fashion,=20but=20see=20= below.=0A+=20=20=20=20=20=20created.=20=20Currently,=20the=20= deferrability=20attributes=20can=20be=20altered=20only=0A+=20=20=20=20=20= =20for=20FOREIGN=20KEY=20constraints.=20=20The=20= enforceability=0A+=20=20=20=20=20=20attribute=20can=20be=20altered=20for=20= FOREIGN=20KEY=20and=0A+=20=20=20=20=20=20= CHECK=20constraints.=0A+=20=20=20=20=20=0A+=0A= +=20=20=20=20=20=0A+=20=20=20=20=20=20Setting=20a=20constraint=20= to=20NOT=20ENFORCED=20causes=20the=0A+=20=20=20=20=20=20= database=20system=20to=20stop=20checking=20it=20for=20new=20or=20updated=20= rows.=20=20Setting=0A+=20=20=20=20=20=20a=20constraint=20to=20= ENFORCED=20causes=20the=20database=20system=0A+=20=20=20= =20=20=20to=20verify=20that=20existing=20rows=20satisfy=20the=20= constraint=20and=20to=20check=20it=0A+=20=20=20=20=20=20for=20new=20or=20= updated=20rows.=0A=20=20=20=20=20=20=0A=20=20=20=20=20=0A= =20=20=20=20=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_18EB9990-4BA6-4CE2-93F7-E551CF7B0912--