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 1t8IFS-003Efa-Bm for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Nov 2024 12:01:25 +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 1t8IFP-00CbZs-2t for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Nov 2024 12:01:23 +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 1t8IFN-00CbZj-On for pgsql-hackers@lists.postgresql.org; Tue, 05 Nov 2024 12:01:23 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8IFJ-000JLu-FL for pgsql-hackers@lists.postgresql.org; Tue, 05 Nov 2024 12:01:21 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5B4AE1140200; Tue, 5 Nov 2024 07:01:16 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Tue, 05 Nov 2024 07:01:16 -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: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=1730808076; x=1730894476; bh=M/jy8hsFJ7j/had1vPtGcOFH9wf7 h3oFSLKIq2kQ4uw=; b=b4GbGvdm6ckb6JnURWFKJ9NR+FtsYW8UUNhnbD/tFLOM jb3O9cwyPMxjfDMMpKHYdL7KHqtfpZPgmc/hAFrAHGAbHHNrCigvJkSlg15nqXrH jP4VvDJijpNb66rAvvTaClUXhSAATbA3WjqPMu84n68edg5XFYKrd45ggx+mQaDw M/k2S/OLRGZS2rNPuWP6tphw6BpIfHaR9GQowl6LKOnoWVABOGsXpjCjPs1jF7Tx yMgFVjmTgGn/T2QeIxV54ejOcHdNwFdirdgshNEc6K3hQ4s6iTtv8iYgRJjMg4Vi N967fCJ3rNIo8O/b8ZSa/N7bWP8ZtELxfKAUrSZ3uw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrtddtgddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfesthekredttddtjeenucfh rhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnh hoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepleejlefggfejvdekheeludeggfdv jeelgeehfeekvdduieduiefhvdekkeekjefhnecuffhomhgrihhnpegvnhhtvghrphhrih hsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprhgtph htthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrmhhithhlrghnghho thgvtdelsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhhosggvrhhtmhhhrggrshesgh hmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhs rdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Nov 2024 07:01:15 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1730808072; bh=g7D6G38V9fyYFoo9HJabaFi560beVIy+yHpTwGikqPY=; h=Date:From:To:Cc:Subject:From; b=AIwElzjiEPdlk2DiFkarlBN1T682q10peNr1+QumpMpYSIZm6wwFUbPM0PE7Y2T8l 8xwPsUnQ/3fdaf/hO4N2FEkZ3Ntixbt/hE6YzFAwHr4EuCHGSsaj83oE6Ch1LFHqU6 P43X7pAGFgtn5FNWHx7gnq82sZ6RjMyeMnasWlVO9/7+OrAPE/VYtokJ678PXh3mHl rY5Zl6huI3uzv7E647PuNGUD3eepSGFWxUaXVkvT6dvxE4cOctmhpu+mPpN3XVAtXM WhTi0CjfpiWKS7+Ehl/Ragvu8YBeTIVuMIeLt8MEB4y4IFQ8TmoueSwE8rdNUgzoDO Qv7E2aL4pjK0g== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 2A28B9B; Tue, 5 Nov 2024 13:01:12 +0100 (CET) Date: Tue, 5 Nov 2024 13:01:12 +0100 From: Alvaro Herrera To: Pg Hackers Cc: Robert Haas , Amit Langote Subject: doc fail about ALTER TABLE ATTACH re. NO INHERIT Message-ID: <202411051201.zody6mld7vkw@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, While doing final review for not-null constraints, I noticed that the ALTER TABLE ATTACH PARTITION have this phrase: If any of the CHECK constraints of the table being attached are marked NO INHERIT, the command will fail; such constraints must be recreated without the NO INHERIT clause. However, this is not true and apparently has never been true. I tried this in both master and pg10: create table parted (a int) partition by list (a); create table part1 (a int , check (a > 0) no inherit); alter table parted attach partition part1 for values in (1); In both versions (and I imagine all intermediate ones) that sequence works fine and results in this table: Table "public.part1" Column │ Type │ Collation │ Nullable │ Default │ Storage │ Stats target │ Description ────────┼─────────┼───────────┼──────────┼─────────┼─────────┼──────────────┼───────────── a │ integer │ │ │ │ plain │ │ Partition of: parted FOR VALUES IN (1) Partition constraint: ((a IS NOT NULL) AND (a = 1)) Check constraints: "part1_a_check" CHECK (a > 0) NO INHERIT On the other hand, if we were to throw an error in the ALTER TABLE as the docs say, it would serve no purpose: the partition cannot have any more descendants, so the fact that the CHECK constraint is NO INHERIT makes no difference. So I think the code is fine and we should just fix the docs. Note that if you interpret it the other way around, i.e., that the "table being attached" is the parent table, then the first CREATE already fails: create table parted2 (a int check (a > 0) no inherit) partition by list (a); ERROR: cannot add NO INHERIT constraint to partitioned table "parted2" This says that we don't need to worry about this condition in the parent table either. All in all, I think this text serves no purpose and should be removed (from all live branches), as in the attached patch. This text came in with the original partitioning commit f0e44751d717. CCing Robert and Amit. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "No renuncies a nada. No te aferres a nada."