From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Brendan Jurd <direvus(at)gmail(dot)com>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: When is a record NULL? |
Date: | 2009-07-24 16:40:22 |
Message-ID: | 1248453622.5201.88.camel@jdavis |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 2009-07-24 at 09:31 -0400, Tom Lane wrote:
> Brendan Jurd <direvus(at)gmail(dot)com> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Emanuel Calvo Franco | 2009-07-24 16:47:01 | uuid contrib don't compile in OpenSolaris |
Previous Message | Tom Lane | 2009-07-24 15:38:06 | Re: bytea vs. pg_dump |