Re: handling of COUNT(record) vs IS NULL - Mailing list pgsql-general

From Tom Lane
Subject Re: handling of COUNT(record) vs IS NULL
Date
Msg-id 7621.1201556281@sss.pgh.pa.us
Whole thread Raw
In response to handling of COUNT(record) vs IS NULL  (Sam Mason <sam@samason.me.uk>)
Responses Re: handling of COUNT(record) vs IS NULL
Re: handling of COUNT(record) vs IS NULL
List pgsql-general
Sam Mason <sam@samason.me.uk> writes:
> I've just noticed that the handling of COUNT(record) and (record IS
> NULL) aren't consistent with my understanding of them.  If I run the
> following query:

>   SELECT
>      NULL       IS NULL, COUNT( NULL      ),
>     (NULL,NULL) IS NULL, COUNT((NULL,NULL));

> The IS NULL checks both return TRUE as I'd expect them to, but the
> second count doesn't return 0.

THe fourth of those isn't really valid SQL.  According to SQL99,
IS NULL takes a <row value expression> as argument, so it's valid
to do (NULL,NULL) IS NULL, but COUNT takes a <value expression>.

I don't see anything in the spec suggesting that we are supposed
to drill down into a rowtype value to see whether all its fields
are null, in any context other than the IS [NOT] NULL predicate.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Surprising (?) Sequence Behavior
Next
From: Vlad
Date:
Subject: 8.3RC2 vs 8.2.6 testing results