Re: When is a record NULL?

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: When is a record NULL?
Дата
Msg-id 69692EBE-15BE-405C-9E0C-C5D69380E4D2@kineticode.com
обсуждение исходный текст
Ответ на Re: When is a record NULL?  (Jeff Davis <pgsql@j-davis.com>)
Ответы Re: When is a record NULL?  ("David E. Wheeler" <david@kineticode.com>)
Список 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 по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: Enable SSPI on cygwin
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Enable SSPI on cygwin