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 1qGwFB-0000x5-AJ for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Jul 2023 06:44:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qGwFA-00051L-6J for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Jul 2023 06:44:04 +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 1qGwF9-00051C-Us for pgsql-bugs@lists.postgresql.org; Wed, 05 Jul 2023 06:44:03 +0000 Received: from mail.dental-vision.de ([82.144.34.210]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qGwF7-0027cz-1p for pgsql-bugs@lists.postgresql.org; Wed, 05 Jul 2023 06:44:02 +0000 Received: from MAIL.cf.local (2001:9e8:e914:7200:58c6:ffce:82d9:8a35) by Mail.cf.local (2001:9e8:e914:7200:58c6:ffce:82d9:8a35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 5 Jul 2023 08:43:57 +0200 Received: from MAIL.cf.local ([192.168.169.216]) by Mail.cf.local ([192.168.169.216]) with mapi id 15.01.2507.027; Wed, 5 Jul 2023 08:43:57 +0200 From: Wilm Hoyer To: Tom Lane CC: "pgsql-bugs@lists.postgresql.org" Subject: AW: XML column causes record to be both NULL and NOT NULL Thread-Topic: XML column causes record to be both NULL and NOT NULL Thread-Index: AdmupmGG9bPATTQrRrucOONNxDPu4///5QEA//8dQgA= Date: Wed, 5 Jul 2023 06:43:57 +0000 Message-ID: <462567f501af4621964bccacaf824590@dental-vision.de> References: <3a116b87d6eb4a6a8040749c991fe961@dental-vision.de> <881845.1688497164@sss.pgh.pa.us> In-Reply-To: <881845.1688497164@sss.pgh.pa.us> Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.169.196] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > 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, whil= e >> IS NOT NULL is true when the row expression itself is non-null and al= l >> 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 bot= h >> 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 Thanks for the Explanation. The solution is clear then - just test part of = the record or "flatten" the record with a cast to text. Best regards, Wilm.