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.94.2) (envelope-from ) id 1tpa9q-008Ntq-To for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Mar 2025 21:50:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tpa9p-0095wr-Lq for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Mar 2025 21:50:33 +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.94.2) (envelope-from ) id 1tpa9p-0095vp-C6 for pgsql-hackers@lists.postgresql.org; Tue, 04 Mar 2025 21:50:33 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tpa9n-000z2j-1q for pgsql-hackers@lists.postgresql.org; Tue, 04 Mar 2025 21:50:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 524LoSCi195583; Tue, 4 Mar 2025 16:50:29 -0500 From: Tom Lane To: =?utf-8?Q?=C3=81lvaro?= Herrera cc: Pg Hackers Subject: Re: bogus error message for ALTER TABLE ALTER CONSTRAINT In-reply-to: <202503041822.aobpqke3igvb@alvherre.pgsql> References: <202503041822.aobpqke3igvb@alvherre.pgsql> Comments: In-reply-to =?utf-8?Q?=C3=81lvaro?= Herrera message dated "Tue, 04 Mar 2025 19:22:22 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <195581.1741125028.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 04 Mar 2025 16:50:28 -0500 Message-ID: <195582.1741125028@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?utf-8?Q?=3DC3=3D81lvaro?=3D Herrera writes: > I just discovered that trying to set a foreign key as NO INHERIT in > ALTER TABLE ALTER CONSTRAINT returns an absurd error message: > create table pk (a int primary key); > create table fk (a int references pk); > alter table fk alter constraint fk_a_fkey deferrable, alter constraint f= k_a_fkey no inherit; > ERROR: ALTER CONSTRAINT statement constraints cannot be marked NO INHER= IT > The explanation is that somebody misunderstood what must be given to > processCASbits in 2013. The intended message is: > ERROR: FOREIGN KEY constraints cannot be marked NO INHERIT Hmm. I agree that "ALTER CONSTRAINT statement" is off the mark here, but I'm not convinced that "FOREIGN KEY" is entirely on-point either. The grammar has no way of knowing what kind of constraint is being targeted. I do see that ATExecAlterConstraint currently rejects every other kind of constraint, but do we need to think of a more generic phrase? regards, tom lane