Re: When is a record NULL? - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: When is a record NULL?
Date
Msg-id 69692EBE-15BE-405C-9E0C-C5D69380E4D2@kineticode.com
Whole thread Raw
In response to Re: When is a record NULL?  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: When is a record NULL?
List pgsql-hackers
On Jul 24, 2009, at 9:40 AM, Jeff Davis wrote:

> 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.

Amen to that.

So here's what I'm doing, essentially (some error handling removed for  
clarity):
    FETCH have INTO rec_have;    FETCH want INTO rec_want;    WHILE NOT rec_have IS NULL OR NOT rec_want IS NULL LOOP
    IF rec_have IS DISTINCT FROM rec_want THEN            RETURN false;        END IF;        rownum = rownum + 1;
 FETCH have INTO rec_have;        FETCH want INTO rec_want;    END LOOP;    RETURN true;
 

So far this seems to work for the tests I've thrown at it, telling me  
when two cursors return results that are row-by-row equivalent,  
including when columns have the NULLs, though I've not yet tried rows  
that are nothing but nulls. That's probably not very useful, but it is  
possible.

Does this look like it's a reasonable implementation for what I'm  
testing? Have I missed anything in the swirl of the bizarre that this  
thread has triggered?

Thanks,

David





pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Enable SSPI on cygwin
Next
From: Andrew Dunstan
Date:
Subject: Re: Enable SSPI on cygwin