pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Herouth Maoz <herouth@oumail.openu.ac.il>
Cc: pgsql-sql@postgreSQL.org
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] Re: [SQL] Oddities with NULL and GROUP BY
Date: Wed, 19 May 1999 10:44:16 -0400
Message-ID: <29820.927125056@sss.pgh.pa.us> (raw)
In-Reply-To: <l03130303b3686def8239@[147.233.159.109]>

Herouth Maoz <herouth@oumail.openu.ac.il> 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, "<comparison predicate>".

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



view thread (15+ messages)  latest in thread

Message-ID: <29820.927125056@sss.pgh.pa.us>
Permalink:  ../29820.927125056@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29820.927125056@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, herouth@oumail.openu.ac.il, pgsql-hackers@postgreSQL.org
  Subject: Re: [HACKERS] Re: [SQL] Oddities with NULL and GROUP BY
  In-Reply-To: <29820.927125056@sss.pgh.pa.us>
  References: <l03130303b3686def8239@[147.233.159.109]> <29820.927125056@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox