| From: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
|---|---|
| To: | 1482694023(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19709: Incorrect result when comparing OLD tuple column to itself in INSERT RETURNING |
| Date: | 2026-09-20 12:58:02 |
| Message-ID: | CAJTYsWXWJbgWYjmb5gdr6G0yv4SYjC12ck4j3o5B8tfgGDR6HQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi,
On Sun, 20 Sept 2026 at 18:13, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 19709
> Logged by: N J
> Email address: 1482694023(at)qq(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Laurenz Albe | 2026-09-20 13:02:23 | Re: BUG #19706: Documentation: Missing step in the instructions for restoring sample dvdrental DB from dvdrental.zip |
| Previous Message | PG Bug reporting form | 2026-09-20 12:28:14 | BUG #19709: Incorrect result when comparing OLD tuple column to itself in INSERT RETURNING |