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 1trwjj-00CXF5-W3 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Mar 2025 10:21:24 +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 1trwji-00D3zy-Lk for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Mar 2025 10:21:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1trwji-00D3zq-4q for pgsql-hackers@lists.postgresql.org; Tue, 11 Mar 2025 10:21:22 +0000 Received: from fhigh-b3-smtp.messagingengine.com ([202.12.124.154]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1trwjd-002DM0-39 for pgsql-hackers@lists.postgresql.org; Tue, 11 Mar 2025 10:21:21 +0000 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7E97625401AC; Tue, 11 Mar 2025 06:21:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Tue, 11 Mar 2025 06:21:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1741688476; x=1741774876; bh=t Bp7DyLC5KyALob44D363o/5yyXMbhRDpqBD0oKFd6c=; b=idCwPDKzWUTG6YGx9 HLO6hxE5IjIXZzI6xIckT+otgm2kxTfJc3Ev7wQpX0+JJ+A6yl6OOnCo+bBxLNtj 8DQ6RnWe48dfDagbu5lV0jqeSgjezUdLPmuoZdG+RpEeXJiScFSPYtsQ8BYi5WbJ Wi1d1Q1Cql8goLMwbkyIg+S1ZE8cszc/Ugd14ocpIiuiQyeePpPweQkQ/RdN8suR umdGfMLZtRy4RqU3+DEGbfueqK/VmbHmjKT2Hi8zAvUHFUqdQhWKTn0lGwEWPtld YKS/s60+YYo5BBbKrtS4cH4EF2vmWmOTGrDBi5ufwlURpHmAomic/QgtXSe5Te59 h0awg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduvdduleejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddt jeenucfhrhhomheplmhlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvefhledthffggfevheef gffhuddvgeehhedthedvleelgefhhedvueegjefgueevnecuffhomhgrihhnpegvnhhtvg hrphhrihhsvggusgdrtghomhdpphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrghdpnhgspghrtghpthhtohephedpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhrtghpth htohepjhhirghnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdrtghomhdprhgtphht thhopehnrghthhgrnhgusghoshhsrghrthesghhmrghilhdrtghomhdprhgtphhtthhope hpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdp rhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhs X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Mar 2025 06:21:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1741688473; bh=KmkxNRIuYZ99eh7Vx2LYOZeGnJWilMzqTFklQWxYRi8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=qTwIm8eJIDjOZizPBj2ESV4OmhENgdB2FusnUJHHH5QbeuiD4Aymz82TvX01e9BDO NwshE00bw3fxhAvmOo/gOevg4RP80tf8cbHm0/S9jRA60c4GF/YP+HRQ4ejX50IryR 19R2TYqW3UBarL8Lup1pYZvLFBJYv+9ZWdYllRdDObn0gPq1+dd1rSYWlcYI2/Gjrs amlYJP5A3b6kubZLbFnmg3BBbEFlQIyM8bK7VFar/l5+sH1omkL5sptAeVUjLfb0ZV eh/3OJNjTZHXGC99Qub5sAEbssoGgAZyMQYP26A7iZN7NkaN+OCzO0ocf8BUD8M5wX xJUQiCPE6wvSQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 0366091; Tue, 11 Mar 2025 11:21:13 +0100 (CET) Date: Tue, 11 Mar 2025 11:21:12 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: jian he Cc: Tom Lane , Pg Hackers , Peter Eisentraut , Nathan Bossart Subject: Re: bogus error message for ALTER TABLE ALTER CONSTRAINT Message-ID: <202503111021.xz4itftejc2f@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Mar-11, jian he wrote: > this look a little strange? > if (cas_bits & (CAS_NOT_DEFERRABLE) && seen) > seen->seen_deferrability = true; > > it should be > if ((cas_bits & CAS_NOT_DEFERRABLE) && seen) > seen->seen_deferrability = true; True. And since you mentioned CAS_INITIALLY_IMMEDIATE, it should really be /* These are the default values; just report that we saw them */ if ((cas_bits & (CAS_NOT_DEFERRABLE | CAS_INITIALLY_IMMEDIATE)) && seen) seen->seen_deferrability = true; > typedef struct CAS_flags need add to typedefs.list True. > seems didn't cover "initially immediate" case for domain. > for example: > create domain d_int as int4; > --- the following two cases should fail. > alter domain d_int add constraint nn1 not null initially immediate; > alter domain d_int add constraint cc check(value > 1) initially immediate; Yeah, I thought at first you were right, but on further thought, do we really want to do this? I mean, INITIALLY IMMEDIATE is the default timing for a constraint, so why should we complain if a user wants to get a constraint that's declared that way? I'm not sure that we should do it. Same with NOT DEFERRABLE. [... looks at the standard doc ...] And that's indeed what the SQL standard says: ::= CREATE DOMAIN [ AS ] [ ] [ ... ] [ ] ::= [ ] [ ] 8) For every specified: [...] b) If is not specified, then INITIALLY IMMEDIATE NOT DEFERRABLE is implicit. So I think the fix here needs to distinguish those cases and avoid throwing errors for them. (Note also it does not say that INITIALLY DEFERRED or DEFERRABLE are disallowed, which means that we're failing to fully implement the standard-mandated behavior by prohibiting those.) > create domain d_int as int4; > alter domain d_int add not null no inherit not valid; > ERROR: not-null constraints on domains cannot be marked NOT VALID > LINE 1: alter domain d_int add not null no inherit not valid; > ^ > If we can report an error like > "ERROR: NOT NULL constraints on domains cannot be marked INHERIT / NOT INHERIT" > That would be great. > just report the first constraint property that is not ok, but seems not doable. Yeah, I don't think this can be made to work. Maybe we'd have to change the way ConstraintAttributeSpec is parsed completely. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Once again, thank you and all of the developers for your hard work on PostgreSQL. This is by far the most pleasant management experience of any database I've worked on." (Dan Harris) http://archives.postgresql.org/pgsql-performance/2006-04/msg00247.php