Re: BUG #18999: Equivalent queries processing WHERE IS NULL & WHERE IS NOT NULL produce mutually exclusive results

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: BUG #18999: Equivalent queries processing WHERE IS NULL & WHERE IS NOT NULL produce mutually exclusive results
Дата
Msg-id
1856868.1753450099@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
BUG #18999: Equivalent queries processing WHERE IS NULL & WHERE IS NOT NULL produce mutually exclusive results PG Bug reporting form <noreply@postgresql.org>
Re: BUG #18999: Equivalent queries processing WHERE IS NULL & WHERE IS NOT NULL produce mutually exclusive results Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #18999: Equivalent queries processing WHERE IS NULL & WHERE IS NOT NULL produce mutually exclusive results "David G. Johnston" <david.g.johnston@gmail.com>
PG Bug reporting form  writes:
> I think "SELECT COUNT(c0) FROM t0" = "SELECT COUNT(c0) FROM t0 WHERE c0 IS
> NOT NULL" + "SELECT COUNT(c0) FROM t0 WHERE c0 IS NULL".

This is not so when c0 is composite.  Per [1]:

    If the expression is row-valued, then IS NULL is true when the row
    expression itself is null or when all the row's fields are null,
    while IS NOT NULL is true when the row expression itself is
    non-null and all the row's fields are non-null. Because of this
    behavior, IS NULL and IS NOT NULL do not always return inverse
    results for row-valued expressions; in particular, a row-valued
    expression that contains both null and non-null fields will return
    false for both tests.

Pretty weird, I agree, but that's what the SQL standard
says to do.

			regards, tom lane

[1] https://www.postgresql.org/docs/current/functions-comparison.html


В списке pgsql-bugs по дате отправления
От: Hugo DUBOIS
Дата:
От: Nathan Bossart
Дата:
FAQ