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 1qGlFQ-0008QX-Pq for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Jul 2023 18:59:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qGlFP-0005vk-Et for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Jul 2023 18:59:35 +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 1qGlFP-0005vb-2u for pgsql-bugs@lists.postgresql.org; Tue, 04 Jul 2023 18:59:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qGlFH-0022Iv-Vp for pgsql-bugs@lists.postgresql.org; Tue, 04 Jul 2023 18:59:33 +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 364IxOoW881846; Tue, 4 Jul 2023 14:59:24 -0400 From: Tom Lane To: Wilm Hoyer cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: XML column causes record to be both NULL and NOT NULL In-reply-to: <3a116b87d6eb4a6a8040749c991fe961@dental-vision.de> References: <3a116b87d6eb4a6a8040749c991fe961@dental-vision.de> Comments: In-reply-to Wilm Hoyer message dated "Tue, 04 Jul 2023 18:46:23 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <881844.1688497164.1@sss.pgh.pa.us> Date: Tue, 04 Jul 2023 14:59:24 -0400 Message-ID: <881845.1688497164@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Wilm Hoyer writes: > i found a strange behavior and hope it's not a pilot error. Well, it is strange, but it's acting per SQL spec. As stated at [1]: If the expression is row-valued, then IS NULL is true when the row expression itself is null or when all the row's fields are null, while IS NOT NULL is true when the row expression itself is non-null and all the row's fields are non-null. Because of this behavior, IS NULL and IS NOT NULL do not always return inverse results for row-valued expressions; in particular, a row-valued expression that contains both null and non-null fields will return false for both tests. The fact that the added column is of XML type isn't relevant here; what's relevant is that it has a null value. regards, tom lane [1] https://www.postgresql.org/docs/current/functions-comparison.html