PG Bug reporting form <noreply@postgresql.org> 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