On Fri, 2009-07-24 at 09:31 -0400, Tom Lane wrote:
> Brendan Jurd <[email protected]> writes:
> It's worse than that, because there actually is also such a thing as
> the row value being NULL --- ie, there's no row structure at all.
> At least internally, that's a completely different thing from having
> a row all of whose fields are null.
Here is an example:
select * from (values (row(NULL)), (null)) v;
But it's hard to do much useful with row values once you have them. You
can't even count them:
select count(column1) from (values (row(NULL)), (null)) v;
ERROR: record type has not been registered
> SQL doesn't provide a test for this case that's separate from the test
> involving null-ness of individual fields. Not much we can do about
> it though. I'm not entirely sure that exposing the distinction would
> be helpful anyway ...
There's no single test, but you can see if it's an empty row with:
x IS NULL AND x IS DISTINCT FROM NULL
And you can see if it's a "real" NULL by:
x IS NULL AND x IS NOT DISTINCT FROM NULL
It's funny until you try it -- then it's just scary.
Regards,
Jeff Davis
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers