Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaHSH-00028a-QS for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 14:09:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaHSF-0004dR-HK for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 14:08:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaHSF-0004dG-8P for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 14:08:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaHSD-0004Sy-0S for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 14:08:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28JE8qcL335176; Mon, 19 Sep 2022 10:08:52 -0400 From: Tom Lane To: Isaac Morland cc: Robert Haas , Alvaro Herrera , Pg Hackers Subject: Re: cataloguing NOT NULL constraints In-reply-to: References: <20220817181249.q7qvj3okywctra3c@alvherre.pgsql> Comments: In-reply-to Isaac Morland message dated "Mon, 19 Sep 2022 09:54:41 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <335174.1663596532.1@sss.pgh.pa.us> Date: Mon, 19 Sep 2022 10:08:52 -0400 Message-ID: <335175.1663596532@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Isaac Morland writes: > I thought I saw some discussion about the SQL standard saying that there is > a difference between putting NOT NULL in a column definition, and CHECK > (column_name NOT NULL). So if we're going to take this seriously, I think > that means there needs to be a field in pg_constraint which identifies > whether a constraint is a "real" one created explicitly as a constraint, or > if it is just one created because a field is marked NOT NULL. If we're going to go that way, I think that we should take the further step of making not-null constraints be their own contype rather than an artificially generated CHECK. The bloat in pg_constraint from CHECK expressions made this way seems like an additional reason not to like doing it like that. regards, tom lane