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 1qaaXY-009oI5-Ck for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Aug 2023 11:36:16 +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 1qaaXW-00BFJG-GH for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Aug 2023 11:36:14 +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 1qaaXV-00BFJ5-Cg for pgsql-hackers@lists.postgresql.org; Mon, 28 Aug 2023 11:36:13 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qaaXQ-001WFE-8R for pgsql-hackers@lists.postgresql.org; Mon, 28 Aug 2023 11:36:12 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 885613200921; Mon, 28 Aug 2023 07:36:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 28 Aug 2023 07:36:04 -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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1693222564; x= 1693308964; bh=w8r3OMnJ71JXbZFiuFkW07ZSm0VZYZKDGOBtQ/viZ88=; b=u wH+a7eesy4b9vxAHwJ3JzVUbfebyiM9QcDGa1lwLgG2u8QI2979ZJ3vLXoIqz6BG Fba/ZNMtP4brAizzQ04hOACNeX83j4TRM6e8zZHoX++o5RF/7diVpm38mt+7VT11 lnJmapiSKLT8+6ETrUxQcImvpgbwXZaqYrEOY4D8+EbOmUmr4D7udHcu3cYq1CYk Qv8Ntiu9iMjJiX1IManFvPTLFXX+yTOqyWMq+1nOSwkurBove4r/fdMwEI5I/gs2 HY3NUT7kAgwqRptIkchOGcjOUuGR190xI0lLFje944Mk67ZEpbiBOdKREivAVHKt CG4jhT8tOEA6/6uG7IQuw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefgedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehtke ertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedvkedtffduff dtffffheffhfejjefhgfeiueeukeejkeffgfdufffhudffffeuveenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhr gh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 28 Aug 2023 07:36:02 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 76F77A9; Mon, 28 Aug 2023 13:36:00 +0200 (CEST) Date: Mon, 28 Aug 2023 13:36:00 +0200 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Strange presentaion related to inheritance in \d+ Message-ID: <20230828113600.kdzqev7e4gcdkdig@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230828.161658.1184657435220765047.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Aug-28, Kyotaro Horiguchi wrote: > But with these tables: > > create table p (a int, b int not null default 0); > create table c1 (a int, b int not null NO INHERIT default 1) inherits (p); > > I get: > > > Not-null constraints: > > "c1_b_not_null" NOT NULL "b" *NO INHERIT* > > Here, "NO INHERIT" is mapped from connoinherit, and conislocal and > "coninhcount <> 0" align with "local" and "inherited". For a clearer > picuture, those values for c1 are as follows. Hmm, I think the bug here is that we let you create a constraint in c1 that is NOINHERIT. If the parent already has one INHERIT constraint in that column, then the child must have that one also; it's not possible to have both a constraint that inherits and one that doesn't. I understand that there are only three possibilities for a NOT NULL constraint in a column: - There's a NO INHERIT constraint. A NO INHERIT constraint is always defined locally in that table. In this case, if there is a parent relation, then it must either not have a NOT NULL constraint in that column, or it may also have a NO INHERIT one. Therefore, it's correct to print NO INHERIT and nothing else. We could also print "(local)" but I see no point in doing that. - A constraint comes inherited from one or more parent tables and has no local definition. In this case, the constraint always inherits (otherwise, the parent wouldn't have given it to this table). So printing "(inherited)" and nothing else is correct. - A constraint can have a local definition and also be inherited. In this case, printing "(local, inherited)" is correct. Have I missed other cases? The NO INHERIT bit is part of the syntax, which is why I put it in uppercase and not marked it for translation. The other two are informational, so they are translatable. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "The important things in the world are problems with society that we don't understand at all. The machines will become more complicated but they won't be more complicated than the societies that run them." (Freeman Dyson)