Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZzPp-0003ZN-0b for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Dec 2018 14:35:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gZzPm-0003q2-Qw for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Dec 2018 14:35:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZzPm-0003m9-G1 for pgsql-bugs@lists.postgresql.org; Thu, 20 Dec 2018 14:35:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZzPk-0004Sg-2z for pgsql-bugs@postgresql.org; Thu, 20 Dec 2018 14:35:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBKEZ0v1011492; Thu, 20 Dec 2018 09:35:00 -0500 From: Tom Lane To: =?UTF-8?B?5a2Z5Yaw?= cc: pgsql-bugs@postgresql.org Subject: Re: Test of value equivalency of row type, feature or bug? In-reply-to: References: Comments: In-reply-to =?UTF-8?B?5a2Z5Yaw?= message dated "Thu, 20 Dec 2018 20:31:49 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11490.1545316500.1@sss.pgh.pa.us> Date: Thu, 20 Dec 2018 09:35:00 -0500 Message-ID: <11491.1545316500@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?B?5a2Z5Yaw?= writes: > select t=t from (select 1, null) t; > If I manage to catch the documents, the result of the query should be null, > as an equivalency comparison of null-contained row-typed values is null. > Surprisingly, the query result turns out to be true. > Is this behavior a feature or a bug? It's a feature. The btree comparison functions (<, =, >, etc) for composite types have to provide a total order for their datatypes, and treating an individual null field as a reason to return null would break that. The whole question of when a composite value "is null" is messy. It ought not be --- IMO, either you have a tuple or you don't --- but the SQL committee did nobody any favors with their creative specification for what "x IS [NOT] NULL" means for composite x. Having said that, though, perhaps "t IS NOT NULL" would do what you want here, since it's defined to be true only when each of t's fields is not null. regards, tom lane