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 1wRkZc-002ect-0t for pgsql-hackers@arkaria.postgresql.org; Tue, 26 May 2026 05:43:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRkZa-0034B8-0U for pgsql-hackers@arkaria.postgresql.org; Tue, 26 May 2026 05:43:27 +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 1wRkZZ-0034Az-2o for pgsql-hackers@lists.postgresql.org; Tue, 26 May 2026 05:43:26 +0000 Received: from mail-dy1-x1334.google.com ([2607:f8b0:4864:20::1334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wRkZY-00000000o8N-3ANP for pgsql-hackers@lists.postgresql.org; Tue, 26 May 2026 05:43:25 +0000 Received: by mail-dy1-x1334.google.com with SMTP id 5a478bee46e88-2f0d3e07e30so33818763eec.0 for ; Mon, 25 May 2026 22:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779774204; x=1780379004; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xqzxnxx50wjBfDmtqFqr+uZtstxMYJvY95q0wO/tCWs=; b=eGsOu9yxU4Q3D4aC824apRtogdt0yBZrKNm7mvr1gKGVSjkFpOZZSxiX+mqURbvKAq qzFbV8g73xUUWd4XrnnTZshbtBWHkCv5sQyW9efZnPEvLKOtI+NqUjv4+nN4/efVwfRu oP0usKhvdAv1eW8oU11BMImXdKEoMVmEB63A6WbLnhFShakrBcZ2IqWIB9FQsymOhuP3 EOp/trKH3efPG7c1TtNn4fdKpCWpIwx04zC7ZrWWJxRX5qHKnwQAZLMAe+o5omXX2Dsx QyoSUiJCqP5UKw1K6iqtHoldk8u+uTX3EqNqKgdpVAJjjB1QQ3kItiCT2jZ+1gIqmm6G aieg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779774204; x=1780379004; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xqzxnxx50wjBfDmtqFqr+uZtstxMYJvY95q0wO/tCWs=; b=rQQYl/WyQ5gAmrgJm/mLXM0CTAFYxi/CkQqmlxAqZ0DLqNWjazz26Dz3LG8lAMM9jC TwcBJBqCneehz6QIaHWWH4PTUh0nly+WjddxZ8oUQlU2PhmTN5jjyoTOq2oJC9QuNqWo +CjCaq/Eja/8l4usYjgl/1eYflewpBMaxWATEA2MvR14yucQc16q0gqBsyy/Qb29zqwW 4ltOcvgNLO90gpiWWDjLmD5XksTsI51gVfwVrSOJYV6tCImNw2TevYS0+qIHcVG7gO+u aXt3q9bFFpKx2N3zhDiFkC6NleiXiwoEuwAXTyoqSU7GgRrC/ypRimmN8/EsVyp7fIIo pWTQ== X-Gm-Message-State: AOJu0YySYVfOmBtgCt/dExp+16mJfK7odAAa3mEU59dHzbMTkB3/ydQ0 WWPEUYssWzrLagZRMkwIyIklrfssibVGvd/ePwJvNPX3kW3G20YhhoYg22ooOx1G X-Gm-Gg: Acq92OHFHN4AgBLK/mRjG6kV+tMHC3eIcJGA6SMxYDtUTjJ9Z6MRx/IjD9HrPT7cEOW gM0BTntvpw/AM7H8mnm09Pllz3NCIFZ1sl/lFTvF0WkHCaB3duT/z29nMvuXr971tQcdvJbpqCB 5X9Cv7/OrSmodgy6Vl4xnroMDGahGtPyYejghWsxV5JG73JRaJ4v3zYE/h0Frokzv/6OcnhqHtt +pEGVGedD4h2JizrBmpqInXm7Wvovql9aDRr0XbNXEF/51n/isJmhjvWgIiinA2SaPKMXiMscMz 3XYA+3Wsx3kghCxZreMs7sPg8ORTlgagzWUSLDjOoazcyPsCHTCh6lQJ1wWzeAlxml0Vc/2DLUT LS8xCOg+ALPVNK0anTvoDTfIQAEJAUhgefqQKmlFigE6Xg3iATOPUZJlsAKUp8bfwstbBkpBjbx s7wzqLJbb5t5AfqnlozSHSbMw96prl1C9gnhnG8TCn X-Received: by 2002:a05:7301:9f08:b0:2d3:f43c:d684 with SMTP id 5a478bee46e88-30448fbf1aemr7089934eec.2.1779774203702; Mon, 25 May 2026 22:43:23 -0700 (PDT) Received: from smtpclient.apple ([64.32.14.230]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3045245fbeesm9795119eec.30.2026.05.25.22.43.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 May 2026 22:43:23 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: doc: Clarify ALTER CONSTRAINT enforceability wording From: Chao Li In-Reply-To: <711B1ED3-1781-4B6C-A573-B58AF20770E5@gmail.com> Date: Tue, 26 May 2026 13:42:48 +0800 Cc: Andrew Dunstan , jian he Content-Transfer-Encoding: quoted-printable Message-Id: <72669A61-01A6-4B6C-A9A7-46BDF094B875@gmail.com> References: <711B1ED3-1781-4B6C-A573-B58AF20770E5@gmail.com> 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 > On May 25, 2026, at 17:31, Chao Li wrote: >=20 > Hi, >=20 > 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. > ``` >=20 > 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. > > ``` >=20 > 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. > ``` >=20 > 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 >=20 > To remove the confusion, I updated the documentation. See the attached = patch for details. >=20 > Best regards, > -- > Chao Li (Evan) > HighGo Software Co., Ltd. > https://www.highgo.com/ >=20 >=20 >=20 >=20 > 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/