From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | jinhui-lai(at)foxmail(dot)com |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18999: Equivalent queries processing WHERE IS NULL & WHERE IS NOT NULL produce mutually exclusive results |
Date: | 2025-07-25 13:28:19 |
Message-ID: | 1856868.1753450099@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2025-07-25 14:15:17 | Re: BUG #18964: `ALTER DATABASE ... RESET ...` fails to reset extension parameters that no longer exist |
Previous Message | Hugo DUBOIS | 2025-07-25 12:13:22 | Re: Unexpected Standby Shutdown on sync_replication_slots change |