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.96) (envelope-from ) id 1wQ4uQ-001GrU-1Y for pgsql-hackers@arkaria.postgresql.org; Thu, 21 May 2026 15:02:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQ4uN-00APG4-0h for pgsql-hackers@arkaria.postgresql.org; Thu, 21 May 2026 15:02:00 +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.96) (envelope-from ) id 1wQ4uM-00APFv-2p for pgsql-hackers@lists.postgresql.org; Thu, 21 May 2026 15:01:59 +0000 Received: from udcm-wwu2.uni-muenster.de ([128.176.118.28]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wQ4uL-000000007BN-084d for pgsql-hackers@lists.postgresql.org; Thu, 21 May 2026 15:01:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-muenster.de; i=@uni-muenster.de; q=dns/txt; s=uniout; t=1779375717; x=1810911717; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=g92OMlgznxv7yNOP5AOVwleCn6nsxR9oQilWH3PF+Ns=; b=jDri4nVYeBLCS5uYg5LFc06aru4qP5Fw6tlu/bRe26b1NfSPmNhiQ7Zw gvpDa4YBIwx9hRge94LdrLoPQ8i3g68iZblkVacztg9CtRUoXwdCOEew6 wP/GeWn3vmeNPpAH8QJNj3LiA7zk5cTcz5oSMmeDXUdjl4icaSgekBvtR feD9HdHVi1b4+F/5JpCc9qHuN56dYEZS+bd3oXh2/mmpK6jiqS1l/t2ws d/uRoPrflJ7b5fmadwgocV/QA69qDZ5H2YN/ZU3IqEeHNUhCTUiFoLMt6 8iEl2UD/BxgDqPt8sBRZbnFcuxPZBxKxp7cLE7kkhaY4+FaTtU8NJHAun g==; X-CSE-ConnectionGUID: rCJtUKEzSf25c1JLSvz6Ng== X-CSE-MsgGUID: tywoKPUcQ9ivpHTpAlqSbw== X-IronPort-AV: E=Sophos;i="6.23,246,1770591600"; d="scan'208";a="394927636" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY2.UNI-MUENSTER.DE with ESMTP; 21 May 2026 17:01:54 +0200 Received: from [192.168.178.49] (dynamic-078-048-205-254.78.48.pool.telefonica.de [78.48.205.254]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id EC0B420ADF02; Thu, 21 May 2026 17:01:52 +0200 (CEST) Message-ID: <24bfd6b7-d566-490c-812f-c61c9eb2ef69@uni-muenster.de> Date: Thu, 21 May 2026 17:01:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Prevent setting NO INHERIT on partitioned not-null constraints To: Andreas Karlsson , PostgreSQL Hackers References: Content-Language: en-US, de-DE From: Jim Jones In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Andreas On 20/05/2026 21:25, Andreas Karlsson wrote: > Me and Joel found a bug when working on another patch. We noticed that > you cannot create not-null constraints with NO INHEIRT set on > partitioned tables, but you can actually set it later by using ALTER > CONSTRAINT. This must be an oversight so I have attached a patch which > adds a check to prevent this. > > The SQL below should give an error but does not: > > CREATE TABLE t ( >   a int, >   CONSTRAINT a_is_not_null NOT NULL a > ) PARTITION BY LIST (a); > > ALTER TABLE t ALTER CONSTRAINT a_is_not_null NO INHERIT; +1 for the fix. postgres=# CREATE TABLE t ( a int, CONSTRAINT a_is_not_null NOT NULL a ) PARTITION BY LIST (a); CREATE TABLE postgres=# ALTER TABLE t ALTER CONSTRAINT a_is_not_null NO INHERIT; ERROR: not-null constraint "a_is_not_null" on partitioned table "t" cannot be NO INHERIT The errcode is most likely wrong: ERRCODE_WRONG_OBJECT_TYPE -> ERRCODE_FEATURE_NOT_SUPPORTED At least it is inconsistent with an equivalent check in parse_utilcmd.c: if (cxt->ispartitioned && constraint->is_no_inherit) ereport(ERROR, errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("not-null constraints on partitioned tables cannot be NO INHERIT")); Thanks! Best, Jim