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 1qTh5Q-00ANBF-JB for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Aug 2023 11:10:45 +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 1qTh5O-004aKO-Kr for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Aug 2023 11:10:43 +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 1qTh5N-004aJs-H2 for pgsql-hackers@lists.postgresql.org; Wed, 09 Aug 2023 11:10:42 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qTh5G-001Srj-84 for pgsql-hackers@lists.postgresql.org; Wed, 09 Aug 2023 11:10:41 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1F87D5C014E; Wed, 9 Aug 2023 07:10:32 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 09 Aug 2023 07:10:32 -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=fm3; t=1691579432; x= 1691665832; bh=GtizUH9q/onNYGeE+fbrSpeLsVo4VbS7TT1GFJL4mBE=; b=U XfoVHpVwgMUf5SKI4c7AWasv7rJoE0nJ/9DDHeb1ATWfePn1Ury8Rk+mrL1zdr95 kEeYufTuVsKMAkB4GVtOWjyIwD7/NrFJZbzvxx2HfX3tuy9dkVy13id6G0LCoDvH YX11ptBIp7QPRL5qllffZ2Vqdg8vgLGcHeZi0VZ/MfodpmXKs07G9auqyKlZE+FG WfTPGTKtJwh/3L+Etn8IMMRvhAI85Crcdu3eVFpiX7acrwy5NKvSMEluBTRie1Sc LLzIfTqD8UXtISIuGs22k+V6qe8DRmIaOx15vsbqrZ6fleij6hgKR7jedt1xKOUQ 3ohKYzEfNdI5aMBekZEhg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrleeggdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Aug 2023 07:10:31 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 77C98DF; Wed, 9 Aug 2023 13:10:29 +0200 (CEST) Date: Wed, 9 Aug 2023 13:10:29 +0200 From: Alvaro Herrera To: Peter Eisentraut Cc: Dean Rasheed , pgsql-hackers@lists.postgresql.org Subject: Re: cataloguing NOT NULL constraints Message-ID: <20230809111029.dlztbsuu5yyapi7x@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5a281a92-eb80-2346-3e23-e23044122408@eisentraut.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Aug-09, Peter Eisentraut wrote: > I wonder whether the root of these problems is that we mix together primary > key constraints and not-null constraints. I understand that right now, with > the proposed patch, when a table inherits from a parent table with a primary > key constraint, we generate not-null constraints on the child, in order to > enforce the not-nullness. What if we did something like this instead: In > the child table, we don't generate a not-null constraint, but instead a > primary key constraint entry. But we mark the primary key constraint > somehow to say, this is just for the purpose of inheritance, don't enforce > uniqueness, but enforce not-nullness. Would that work? Hmm. One table can have many parents, and many of them can have primary keys. If we tried to model it the way you suggest, the child table would need to have several primary keys. I don't think this would work. But I think I just need to stare at the dependency graph a little while longer. Maybe I just need to add some extra edges to make it work correctly. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/