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 1uk6gb-00FnjX-9K for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Aug 2025 19:54:01 +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 1uk6gZ-00AIe5-TJ for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Aug 2025 19:53:59 +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 1uk6gZ-00AIdd-GY for pgsql-bugs@lists.postgresql.org; Thu, 07 Aug 2025 19:53:59 +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.96) (envelope-from ) id 1uk6gW-001Gyc-23 for pgsql-bugs@lists.postgresql.org; Thu, 07 Aug 2025 19:53: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 577JrtlT1603235; Thu, 7 Aug 2025 15:53:55 -0400 From: Tom Lane To: Peter Praxmarer cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG: IS NOT NULL on RECORD variable fails in 17.5-dev In-reply-to: References: Comments: In-reply-to Peter Praxmarer message dated "Thu, 07 Aug 2025 12:43:54 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1603233.1754596435.1@sss.pgh.pa.us> Date: Thu, 07 Aug 2025 15:53:55 -0400 Message-ID: <1603234.1754596435@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Praxmarer writes: > I have discovered what appears to be a severe bug in a development version > of PostgreSQL 17 where a populated RECORD variable incorrectly fails an IS > NOT NULL check. No, that's behaving per SQL standard, and the same as many PG versions before it. Per [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. IMHO this wasn't one of the SQL committee's better ideas, but we're stuck with it. regards, tom lane [1] https://www.postgresql.org/docs/current/functions-comparison.html