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 1roPb7-001Kx8-T2 for pgsql-general@arkaria.postgresql.org; Sun, 24 Mar 2024 15:17:22 +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 1roPb6-00DESV-Cv for pgsql-general@arkaria.postgresql.org; Sun, 24 Mar 2024 15:17:20 +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 1roPb6-00DESM-2m for pgsql-general@lists.postgresql.org; Sun, 24 Mar 2024 15:17:20 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1roPb1-006Bmr-UX for pgsql-general@lists.postgresql.org; Sun, 24 Mar 2024 15:17:19 +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 42OFHB9J2005112; Sun, 24 Mar 2024 11:17:11 -0400 From: Tom Lane To: Thiemo Kellner cc: pgsql-general@lists.postgresql.org Subject: Re: Is this a buggy behavior? In-reply-to: <51eb3063-1d90-40c6-a8c6-9a77fe105a61@gelassene-pferde.biz> References: <51eb3063-1d90-40c6-a8c6-9a77fe105a61@gelassene-pferde.biz> Comments: In-reply-to Thiemo Kellner message dated "Sun, 24 Mar 2024 15:59:46 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2005110.1711293431.1@sss.pgh.pa.us> Date: Sun, 24 Mar 2024 11:17:11 -0400 Message-ID: <2005111.1711293431@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thiemo Kellner writes: > Am 24.03.2024 um 15:54 schrieb Erik Wienhold: >> This is required by the SQL standard: columns of a primary key must be >> NOT NULL. Postgres automatically adds the missing NOT NULL constraints >> when defining a primary key. You can verify that with \d test1 in psql. > To me, this behaviour, while correct, is not too concise. I wished, that > PG issued a warning about a definition conflict. In PostgreSQL, a PK > must always be not nullable, so explicitly defining on of a PK's columns > as nullable is contradictory, one should get notified of. To do that, we'd have to remember that you'd said NULL, which we don't: the word is just discarded as a noise clause. Considering that this usage of NULL isn't even permitted by the SQL standard, that seems like a bit too much work. regards, tom lane