Re: [HACKERS] Re: [SQL] Oddities with NULL and GROUP BY

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
Cc: pgsql-sql(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [SQL] Oddities with NULL and GROUP BY
Date: 1999-05-19 14:44:16
Message-ID: 29820.927125056@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)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

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1999-05-19 14:47:07 Re: [HACKERS] PyGreSQL 2.4
Previous Message The Hermit Hacker 1999-05-19 14:43:37 Re: [HACKERS] PyGreSQL 2.4

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Lockhart 1999-05-19 15:16:52 Re: [HACKERS] Re: [SQL] Oddities with NULL and GROUP BY
Previous Message José Soares 1999-05-19 14:38:09 Re: [SQL] Oddities with NULL and GROUP BY