From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: jinhui-lai@foxmail.com
Subject: BUG #18997: Two equivalent queries return different results
Date: Thu, 24 Jul 2025 14:45:17 +0000
Message-ID: <18997-5da9d229e6f13364@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18997
Logged by: Jinhui Lai
Email address: jinhui-lai@foxmail.com
PostgreSQL version: 17.5
Operating system: ubuntu 22.04
Description:
Dear PG developers:
Thanks for reading my report.
I think these "SELECT COUNT(c0) FILTER (WHERE c0 IS NOT NULL) FROM t0" and
"SELECT COUNT(c0) FROM t0 WHERE c0 IS NOT NULL;" are equivalent. However,
their results are different.
Please you can reproduce it as follows:
CREATE TYPE composite AS (a float8, b float8);
CREATE TABLE t0 (c0 composite NOT NULL);
INSERT INTO t0 VALUES ('(,)');
test=# SELECT COUNT(c0) FILTER (WHERE c0 IS NOT NULL) FROM t0;
count
-------
0
(1 row)
test=# SELECT COUNT(c0) FROM t0 WHERE c0 IS NOT NULL;
count
-------
1
(1 row)
Moreover, when I execute this case in the former versions, such as pg 16,
15... these two queries return the same result.
Best regard,
Jinhui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, jinhui-lai@foxmail.com
Subject: Re: BUG #18997: Two equivalent queries return different results
In-Reply-To: <18997-5da9d229e6f13364@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox