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 1rX0LD-008GaP-DB for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Feb 2024 14:52:59 +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 1rX0LC-00Ducq-Gl for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Feb 2024 14:52:58 +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 1rX0LC-00DuaX-4g for pgsql-hackers@lists.postgresql.org; Mon, 05 Feb 2024 14:52:58 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rX0L9-005Cmq-Bd for pgsql-hackers@lists.postgresql.org; Mon, 05 Feb 2024 14:52:56 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id A58F33200A47; Mon, 5 Feb 2024 09:52:53 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 05 Feb 2024 09:52:54 -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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707144773; x= 1707231173; bh=RC6vuID0nLQfcUeMRxlySKpTq600KPgFAOTbj9a5CD8=; b=i G6Bx+oWFcDnlv7r7gmZ2rdc5VUrUWau+RZ+SZpWKC2RIpHbAFiEzX9X4KLbEFQqz WyfnqZatCWFQqjchDSa2XMDGYPzQOi5B2oSRHPtLTtlqrWgHAR123W3iY/dqq36l kDHRc7cyLHx6hzVoCswIvdNuqOdmHiIrkS18kr+cyrDI/gcPpUyIvstFK9D426Mz BMH8jsWIJk3fw8kDYiuHkGwOR3Ni3bCqPnIu0QtHOCNDuWNeAar5TQfO6mWgCKA2 oKw0ages2ps/aJAgb4BC4QLSbTvIQPrr75LDHRnv7AQdkXxF0aaO9r0oT8INOpxM GgR/49/ILD4xPGcsopwOw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedvtddgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Feb 2024 09:52:52 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1707144439; bh=6dJQGOgZ1sCOEVrMRxlYNti2mJLnFVZducTWeYMOzl4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=hoN5wRxIocgPdcioh0FZ4jT5p0BEhqOpv5bYnffq194CjSzYH3WqR5IBS8d31Lh2W d6D6unczUcHJT0VkdIZwteVqZtsOGCFP79hTcqoYBDpSUsWVFZoWelQ4pZLWXhnLa1 nWYtCozNoRlvn7SP4XxVcgVdoXZCOwK6SMCt5Gvx5cCd2mysPLR2dk6ftct4UPoKqV WW78TzTvlNKW/zn7Y5EUmwpT7LmXQZtHtTKzpIgqeW1NUsf8+QYng8erG8z8u+kTT2 n/zQ4r5jmSE+3vqzo8ZREoNPF6Ihz/NkyS8blOiZ9sxuXEH4w/bP4/1RiK8MU0MHzm 07j3Ou5jvON4w== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 5BF0BBA3; Mon, 5 Feb 2024 15:47:19 +0100 (CET) Date: Mon, 5 Feb 2024 15:47:19 +0100 From: Alvaro Herrera To: Michael Paquier Cc: Alexander Lakhin , Dean Rasheed , Peter Eisentraut , Robert Haas , pgsql-hackers@lists.postgresql.org Subject: Re: cataloguing NOT NULL constraints Message-ID: <202402051447.wimb4xmtiiyb@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202402050950.q367e2d6rtjs@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Feb-05, Alvaro Herrera wrote: > So this regression test no longer fails: > > create table cnn2_parted(a int primary key) partition by list (a); > create table cnn2_part1(a int); > alter table cnn2_parted attach partition cnn2_part1 for values in (1); > Here, in the existing code the ALTER TABLE ATTACH fails with the error > message that > ERROR: primary key column "a" is not marked NOT NULL > but with the patch, this no longer occurs. I think this change is OK. In the partition, the primary key is created in the partition anyway (as expected) which marks the column as attnotnull[*], and the table is scanned for presence of NULLs if there's no not-null constraint, and not scanned if there's one. (The actual scan is inevitable anyway because we must check the partition constraint). This seems the behavior we want. [*] This attnotnull constraint is lost if you DETACH the partition and drop the primary key, which is also the behavior we want. While playing with it I noticed this other behavior change from 16, create table pa (a int primary key) partition by list (a); create table pe (a int unique); alter table pa attach partition pe for values in (1, null); In 16, we get the error: ERROR: column "a" in child table must be marked NOT NULL which is correct (because the PK requires not-null). In master we just let that through, but that seems to be a separate bug. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Saca el libro que tu religión considere como el indicado para encontrar la oración que traiga paz a tu alma. Luego rebootea el computador y ve si funciona" (Carlos Duclós)