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 1tyEf1-0045TJ-1q for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Mar 2025 18:42:31 +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 1tyEez-00EbLK-HG for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Mar 2025 18:42:29 +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 1tyEez-00EbLC-55 for pgsql-hackers@lists.postgresql.org; Fri, 28 Mar 2025 18:42:29 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tyEew-001ktA-1o for pgsql-hackers@postgresql.org; Fri, 28 Mar 2025 18:42:28 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id C5B3C11400E9; Fri, 28 Mar 2025 14:42:24 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 28 Mar 2025 14:42:24 -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=fm2; t=1743187344; x=1743273744; bh=U dCUetVfPJcCYIm/tc8wblLTYp8pvHPsu/MwOkxX6mk=; b=tH9Ahq4/atQ9Z4L7w o6wyKnimS87MSImcYWLScfvDADx0oeSqOncKXcPwWkYf3TQD1raBcyOXwxvSxoJe ptX/ml+471yKCaV+55E2mvxkruluWUuodoAUNrsEJKV65kKq3GvhL6vjqX/ImRsM SuFrdjw+rXYYk/o+2UvZXjA+UzSGnQKKS7ZAm0NJDf39dUCMJfZEaz9iw2u8Bg+X kyBvgBDFVUa/Uv2fV+Nk7iHU0YU2mg8LEq0pmGKY+g0nJyy+VSybESYULhiIsTQx 1zOcvn1T6UInapV4bqluI48J1Icx8YktcX6iBzl91v9q5FLKuLobj16UeS7kAVnR kL4lg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddujedvtdegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddt jeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepgfdtgeelgefgffdtiedu udffhfevkefgudefteehgfethfekvdegjeelhfethedvnecuffhomhgrihhnpegvnhhtvg hrphhrihhsvggusgdrtghomhdpphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrghdpnhgspghrtghpthhtohephedpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtoheprghshhhuthhoshhhrdgsrghprghtrdhoshhssehgmhgrihhlrd gtohhmpdhrtghpthhtohepjhhirghnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdr tghomhdprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtg hpthhtoheprhhushhhrggshhdrlhgrthhhihgrsehgmhgrihhlrdgtohhmpdhrtghpthht ohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Mar 2025 14:42:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1743187342; bh=S78b6eq+fLNzu9rcTRA+Bek7MFsDmVlVvN+GHd9IQTQ=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=IByIwpk/aG3DS8SyHaPcUFjT71NQs2zTDs222YSlUYUr9zcanZNOkiCAmyynfKGwT Lm4v6s0up9GAOyf8bk/gOWKaVQpnsICpLkp+a7ZLaghZh1g5JkCH51/VnfiHyFio7g 10CQkgQ08FaFt9MUwSAWysIZYHrZ/zD91fJmd6KEf5JUiWcB2PSLCECktpfmxEPVJZ mBfjU3Ps9qnD9B0QDfKkFwDZkScY2p9ywUi7DSnwp9B1iWM4Za16WpsBcF9JL2IfLk /POI/rldje1CMA8GuWAwA3E8MnpR5N6/tcWqeTpefC/cnTBs46r0GvY3IlwaQaw9Jb XvhzFQljyMVZQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 093F585; Fri, 28 Mar 2025 19:42:22 +0100 (CET) Date: Fri, 28 Mar 2025 19:42:22 +0100 From: Alvaro Herrera To: jian he Cc: Robert Haas , Rushabh Lathia , Ashutosh Bapat , PostgreSQL Hackers Subject: Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints Message-ID: <202503281842.iiuztzg6ksxi@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-28, jian he wrote: > i think your patch messed up with pg_constraint.conislocal. > for example: > > CREATE TABLE parted (id bigint default 1,id_abc bigint) PARTITION BY LIST (id); > alter TABLE parted add CONSTRAINT dummy_constr not null id not valid; > CREATE TABLE parted_1 (id bigint default 1,id_abc bigint); > alter TABLE parted_1 add CONSTRAINT dummy_constr not null id; > ALTER TABLE parted ATTACH PARTITION parted_1 FOR VALUES IN ('1'); > > select conrelid::regclass, conname, conislocal > from pg_constraint where conname = 'dummy_constr'; > > conrelid | conname | conislocal > ----------+--------------+------------ > parted | dummy_constr | t > parted_1 | dummy_constr | f > (2 rows) > > > if you do pg_dump, and execute the pg_dump output > pg_dump --no-statistics --clean --table-and-children=*parted* > --no-owner --verbose --column-inserts --file=dump.sql --no-acl > > select conrelid::regclass, conname, conislocal > from pg_constraint where conname = 'dummy_constr'; > output is > > conrelid | conname | conislocal > ----------+--------------+------------ > parted | dummy_constr | t > parted_1 | dummy_constr | t > (2 rows) Interesting. Yeah, I removed the code you had there because it was super weird, had no comments, and removing it had zero effect (no tests failed), so I thought it was useless. But apparently something is going on here that's not what we want. To fix this, we could say that pg_dump should realize the difference and dump in a different way ... however I think that'd require looking at conislocal differently, which I definitely don't want to mess with. Maybe the real problem here is that making the (valid) child constraint no longer local when the parent constraint is not valid is not sensible, precisely because pg_dump won't be able to produce good output. That sounds more workable to me ... except that we'd have to ensure that validating the parent constraint would turn the child constraints as not local anymore, which might be a bit weird. But maybe not weirder than the other approach. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "I must say, I am absolutely impressed with what pgsql's implementation of VALUES allows me to do. It's kind of ridiculous how much "work" goes away in my code. Too bad I can't do this at work (Oracle 8/9)." (Tom Allison) http://archives.postgresql.org/pgsql-general/2007-06/msg00016.php