Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA08653; Wed, 19 May 1999 10:46:10 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id KAA29822; Wed, 19 May 1999 10:44:17 -0400 (EDT) To: Herouth Maoz cc: pgsql-sql@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: [HACKERS] Re: [SQL] Oddities with NULL and GROUP BY In-reply-to: Your message of Wed, 19 May 1999 16:52:54 +0300 Date: Wed, 19 May 1999 10:44:16 -0400 Message-ID: <29820.927125056@sss.pgh.pa.us> From: Tom Lane Herouth Maoz writes: > Thus, by rights, NULL=NULL should be true, because there is only one null > value. You are jumping to a conclusion not supported by the text you have quoted. It does appear that GROUP BY and DISTINCT should treat all nulls as falling into the same class, because of > h) distinct: Two values are said to be not distinct if either: > both are the null value, or they compare equal according to > Subclause 8.2, "". Kindly note, however, that the standards authors felt it necessary to describe those two cases as separate cases. If nulls compare as equal, there would be no need to write more than "Two values are not distinct if they compare equal". > One should note, however, that when the actual comparison operator "=" is > used, the standard says that if one of the operands is null, the result of > the comparison is unknown. Precisely. A fortiori, if both operands are null, the result of the comparison is still unknown. We do seem to have a bug in GROUP BY/DISTINCT if nulls are producing more than one output tuple in those operations. But that has nothing to do with what the comparison operator produces. regards, tom lane