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 1roQOj-001OL9-LF for pgsql-general@arkaria.postgresql.org; Sun, 24 Mar 2024 16:08:38 +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 1roQOh-00Dq4d-Kn for pgsql-general@arkaria.postgresql.org; Sun, 24 Mar 2024 16:08:36 +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 1roQOf-00Dq4R-Uf for pgsql-general@lists.postgresql.org; Sun, 24 Mar 2024 16:08:35 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1roQOW-006FiK-GY for pgsql-general@lists.postgresql.org; Sun, 24 Mar 2024 16:08:33 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 7AE2C320030E; Sun, 24 Mar 2024 12:08:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 24 Mar 2024 12:08:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1711296499; x=1711382899; bh=eAJpNCSx29aEAbIMpsYn1WB/mP4Qzo7FAISVPeBE6yU=; b= oO7Dk5dvcyiXwjF11fPhGlaYDjEZrrb7qEAUjU0vPG9wJ8bPC91kUg3kszgWllUo /S6xdRhwCBlTRBxQUMwMabH1wRMExGs0JnHdd6C1dQyvFvthk2LP4RHGUt2j/4Ee WCEP5qWMRBHD7TrZyqz0bQpqPoRNo1D9ssW7cB/0ZQC/b9UIHaWJwo1znTNIhfXY VdbxJmW5Z3fW/2ACblUjJ2+pZ3+Zgz2y1DT1qLkf8FtYCqXyB3CZV/rDv79HmGSq LflRsf6lNANyjvwxgWN8pXtlvQ3L8JH6Z7s4dlJZZNkiy8BmN5cO0J8iZN4Op3cX LjPinS+zmYFdW9surHmhCg== 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 :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1711296499; x= 1711382899; bh=eAJpNCSx29aEAbIMpsYn1WB/mP4Qzo7FAISVPeBE6yU=; b=a ALJFA4SnoJQsdVBEcJv+DWU8iACO14Nn0STuOoM4ln5VEBgv0+8TO0ORZIrsh5aB ejoUEmLubBu+DoWt1+ceGR7FctHR02Hczmsgzg9nyAT0kn/V6xUEgeg4trSHWF+G 6wubBRrz8kK43/hLaOfqxCOOppyXUuw/uoRi+Xxvx27ylNixettdP18L2PHshHDn /OrHxFUEefyfPCfXiUZgeY+wMja08EzSd/+javt2PQVuxqQs2ZxZzJRXgTwH208V Fb2Ll3Euth0XzSH+JKDzJrkG1T/mq1cVUJwgzql/Fxgw7hugSdWL9Sf8a7Jb10VA Cloo/fMCADL6kOkR3uAzw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtjedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepgfdufeekhfevfeelveeiueevhedvuddukeduvddv lefhueeuieejtdeuvdevvdeunecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 24 Mar 2024 12:08:19 -0400 (EDT) Message-ID: <582a40a4-ac92-4247-8cea-bae9f2da5c73@aklaver.com> Date: Sun, 24 Mar 2024 09:08:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Is this a buggy behavior? Content-Language: en-US To: Thiemo Kellner , Tom Lane Cc: pgsql-general@lists.postgresql.org References: <51eb3063-1d90-40c6-a8c6-9a77fe105a61@gelassene-pferde.biz> <2005111.1711293431@sss.pgh.pa.us> From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/24/24 08:28, Thiemo Kellner wrote: > > Am 24.03.2024 um 16:17 schrieb Tom Lane: > >> 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. > > If I understood correctly, only the NOT NULL expression gets remembered, > but the NULL gets discarded. No, I do not quite get it. Somehow, it has > to be decided whether to create a "check constraint" or not, but this > information is not available any more when creating the primary key? Not > even in some kind of intermediary catalogue? > > "Considering that this usage of NULL isn't even permitted by the SQL > standard" is in my opinion a strange argument. To me, it is similar as > to say, well a column has a not null constraint and that must be enough, > we do not check whether the data complies when inserting or updating. > Sure, my example has lots more side effect than silently do the right > thing. That is sort of the point the OPs example was for a CREATE TABLE and hence had no data. The OP also wanted a PK and per: https://www.postgresql.org/docs/current/sql-createtable.html "PRIMARY KEY enforces the same data constraints as a combination of UNIQUE and NOT NULL. " they got a compound PK with the specified constraints. If they had being doing a ALTER TABLE to add a PK over the columns after null values where added they result would be different: CREATE TABLE test1 ( c1 varchar(36) NULL , c2 varchar(36) NOT NULL ) ; insert into test1 values (null, 'test'); alter table test1 add constraint test_pk PRIMARY KEY(c1,c2); ERROR: column "c1" of relation "test1" contains null values > > Please do not get me wrong. I can totally understand that something > needs to much work to implement. I am just puzzled. > > -- Adrian Klaver adrian.klaver@aklaver.com