Re: [PG19] Wrong results from NOT NULL-based expression simplification

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: [PG19] Wrong results from NOT NULL-based expression simplification
Date: 2026-10-11 02:54:31
Message-ID: CAGRkXqTo=2P2k8qDYmS8xpw83-No=C38RBzbP+J6EpT6hneCWA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Richard, thanks for committing my fix and drafting the quick fix
for the first case.

> Regarding #2, this is a bug in v17 and later, not a v19 regression, so
> I don't think it should be a v19 open item. And it's in the MERGE
> code, so I think Dean is the right person to look at it, not me.

On #2, I agree the root cause is in 17. But the wrong result is new
in 19. The MERGE in my first mail returns t on 17 and 18, and f on
19. So I would like to keep it on the list.

Fujii, thanks for reviewing the fix.
> Codex reported that the following INSERT, which previously succeeded,
still
> fails with this patch. I confirmed the issue. Should we fix this as well?

I see this too. It works on 18 and on 62e46c00c65, and fails from
d8ce0050a on, with or without Richard's v1.

The NULLIF branch labels its result with the typmod the NULLIF had
before f(a) was inlined. The index expression was already inlined in
the relcache, so its NULLIF gets no label.

The attached patch goes on top of Richard's v1. It uses the typmod of
the simplified first argument.

Haibo, thanks for reviewing the 005.
> Without 0005, this returned 12 rows, as expected.
> With 0005, it returned 9.

I reproed that result too. But I agree with Richard
#5 is not a v19 item, I withdraw 0005 for now.

Let's finish the v19 open items first and have new thread to discuss that.

Thanks,
Shihao

Attachment Content-Type Size
nocfbot-0001-Use-the-simplified-argument-s-typmod-when-reducing-NULLIF.patch application/octet-stream 4.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message kedar anavardekar 2026-10-11 04:31:06 Re: Fix WITHOUT OVERLAPS multirange with location replication
Previous Message shihao zhong 2026-10-11 02:38:56 Re: examine_variable ignored CollateExpr