agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedBUG #19709: Incorrect result when comparing OLD tuple column to itself in INSERT RETURNING
2+ messages / 2 participants
[nested] [flat]
* BUG #19709: Incorrect result when comparing OLD tuple column to itself in INSERT RETURNING
@ 2026-09-20 12:28 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2026-09-20 12:28 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: 1482694023@qq.com
The following bug has been logged on the website:
Bug reference: 19709
Logged by: N J
Email address: 1482694023@qq.com
PostgreSQL version: 18.4
Operating system: Windows 11 64-bit
Description:
Environment:
PostgreSQL: 18.4
OS: Windows 11 64-bit
Reproduction query:
CREATE TEMP TABLE IF NOT EXISTS a0 (x INTEGER);
TRUNCATE TABLE a0;
INSERT INTO a0 VALUES (42)
RETURNING
CASE
WHEN (old).x IS DISTINCT FROM old.x THEN 1
ELSE 0
END AS bug;
Observed result:
bug
-----
1
Expected result:
bug
-----
0
Explanation:
For INSERT statements, the OLD tuple is all NULL.
The expression old.x IS DISTINCT FROM old.x compares NULL with NULL.
Per SQL standard, NULL IS DISTINCT FROM NULL returns false, so the CASE
expression should return 0.
PostgreSQL incorrectly evaluates this predicate to true and returns 1.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #19709: Incorrect result when comparing OLD tuple column to itself in INSERT RETURNING
@ 2026-09-20 12:58 Ayush Tiwari <ayushtiwari.slg01@gmail.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Ayush Tiwari @ 2026-09-20 12:58 UTC (permalink / raw)
To: 1482694023@qq.com; pgsql-bugs@lists.postgresql.org
Hi,
On Sun, 20 Sept 2026 at 18:13, PG Bug reporting form <noreply@postgresql.org>
wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 19709
> Logged by: N J
> Email address: 1482694023@qq.com
> PostgreSQL version: 18.4
> Operating system: Windows 11 64-bit
> Description:
>
> Environment:
> PostgreSQL: 18.4
> OS: Windows 11 64-bit
>
> Reproduction query:
>
> CREATE TEMP TABLE IF NOT EXISTS a0 (x INTEGER);
> TRUNCATE TABLE a0;
> INSERT INTO a0 VALUES (42)
> RETURNING
> CASE
> WHEN (old).x IS DISTINCT FROM old.x THEN 1
> ELSE 0
> END AS bug;
>
> Observed result:
> bug
> -----
> 1
>
> Expected result:
> bug
> -----
> 0
>
> Explanation:
> For INSERT statements, the OLD tuple is all NULL.
> The expression old.x IS DISTINCT FROM old.x compares NULL with NULL.
> Per SQL standard, NULL IS DISTINCT FROM NULL returns false, so the CASE
> expression should return 0.
> PostgreSQL incorrectly evaluates this predicate to true and returns 1.
IIUC, this has already been fixed [1].
Please try the query on the latest minor versions.
Regards,
Ayush
[1]
https://git.postgresql.org/cgit/postgresql.git/commit/?h=REL_18_STABLE&id=9108fed3eda97475d5ef2f...
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-09-20 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-20 12:28 BUG #19709: Incorrect result when comparing OLD tuple column to itself in INSERT RETURNING PG Bug reporting form <noreply@postgresql.org>
2026-09-20 12:58 ` Ayush Tiwari <ayushtiwari.slg01@gmail.com>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox