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 1tg4kG-007Wio-EP for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Feb 2025 16:28:52 +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 1tg4kF-009CKk-Hi for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Feb 2025 16:28:51 +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 1tg4kF-009CJ6-5y for pgsql-hackers@lists.postgresql.org; Thu, 06 Feb 2025 16:28:51 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tg4kC-003zxe-0C for pgsql-hackers@postgresql.org; Thu, 06 Feb 2025 16:28:50 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 328FF2540181; Thu, 6 Feb 2025 11:28:46 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Thu, 06 Feb 2025 11:28:46 -0500 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=fm3; t=1738859326; x=1738945726; bh=T 9JG25FpGLr3urkxUjIzNTS/8xpk3WFu2g1m5LT8Qjg=; b=UpI32LjIbWVRn7Y8t RRYEQ0A9Scg8PlHnIR88/y2BtJLimULBRveLibSqE5E4AJv5o96bKWgEhlzVwZPp vxDVTu1wn63ijK4SLrHXKAPV48svKRfu1H0YoIStNC5DegNN7KScjLpqje/b03Vz 0MBp2Nja8mkaQ3DOeelFA0wNrEwHsEHrAjioU6In5WUcZb4kJOjEbDUZaDl0efs3 G9HEbtpBL+Y0UutWM8ugrDt+Wiu4WhMaM9KK19IVccXgNXCA0u70d5JJTyvgQkrb HPKg8QcHGDUV7fM4Ss6pOTQjOOuFIbhowYV1MQWd9KgG6+p9AYDPs480Q5jr38eQ aHShQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieekjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdej necuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvh hhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeekfeeiheekkefftdffgeeg tdffleekiefguddvkefgudfgleeutdeihfektedugfenucffohhmrghinhepghhithhhuh gsrdgtohhmpdgvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnoh dqihhprdhorhhgpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehruhhshhgrsghhrdhlrghthhhirgesghhmrghilhdrtghomhdprhgtphhtth hopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Feb 2025 11:28:45 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1738859323; bh=0/b56xp9mKLiFBi0+gPbjK/P4+BeymG57w2UR00BWqY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=MSrt5OwlT13lgENqj8ECHZPXtVkUuD4TYuSNgPuSbI+YlAJv3glAJvzdZBewnJjoc lSC1EoFx/pt/oUEGmsjRzsA8S9shkNUVh5jJzgwZ6MLR+ZulyiI53GxwUyGXLL0PA1 TnwqIN7ZLkmPYNtTy3kYsVOAwHu/4N7nqHNkW1Wf5t9gTZoYUNndG7ew6miS3SrPj/ Hm1TssPeHsrPp8josD8KUVcOpKdT6ZvUpvR+6K8/DNmURPxUjL0hnhWDsMgU3AWaiw yrq8aOM7oU3rvDYSaD5a2ruLd/hktlIJoVYd9DBIkDkbkijMmxs6ubPdSaNYnDPQYm Ula3GqMwoE56Q== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id ADC8294; Thu, 6 Feb 2025 17:28:43 +0100 (CET) Date: Thu, 6 Feb 2025 17:28:43 +0100 From: Alvaro Herrera To: Rushabh Lathia Cc: PostgreSQL Hackers Subject: Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints Message-ID: <202502061628.duexh6aq7a6p@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 Hello Rushabh, On 2025-Feb-06, Rushabh Lathia wrote: > Commit 14e87ffa5c543b5f30ead7413084c25f7735039f > > added the support for named NOT NULL constraints. We can now support > the NOT VALID/VALID named NOT NULL constraints. > > This patch supports the NOT VALID and VALIDATE CONSTRAINT for name NOT > NULL constraints. In order to achieve this patch, Thank you very much for working on this. > 1) Converted the pg_attribute.attnotnull to CHAR type, so that it can > hold the INVALID flag for the constraint. This looks good to me. It'll have implications for client-side queries, but I think they will need to adapt. One school of thought says we should rename the column, so that every tool is forced to think about the issue and adapt accordingly, instead of only realizing the problem the first time they break. > 4) Added related testcases. Please remember to add test cases for tables with not-valid constraint that are not dropped at the end. That way, the pg_upgrade test will try to process that table and we'll know if the roundtrip via pg_dump works correctly. I haven't looked at 0002 too closely, but I think it has the right shape. > 3) Support for pg_dump, where we now dumping the INVALID NOT NULL as > separate from table schemes, just like CHECK Constraints. I think you copied a little bit too much of the code for check constraints. If a constraint is accumulated in invalidnotnulloids, you already know that it's not validated and needs to be dumped separately. So your new query doesn't need to bring convalidated (we know it's false). This would simplify a few lines in this new code. Also, the pg_log_info() line is mistaken about what this block is doing. I think it'd be good to have NOT VALID NO INHERIT constraints in the tests as well. Also consider the case where the child table is created first with a valid constraint, then the parent table is created later with a not valid constraint -- if the pg_dump table scans find the child first, does pg_dump do the right thing or does it try to create the parent constraint first? Also, what if the constraint in the child has a different name from the constraint in the parent? This should be pg_dump round-tripped as well. (I bet there are tons of other corner cases here that should be verified.) Please add something to pg_dump/t/002_pg_dump.pl. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/