| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Cc: | Melanie Plageman <melanieplageman(at)gmail(dot)com>, shihao zhong <zhong950419(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-16 06:29:45 |
| Message-ID: | CAMbWs49=JmZmZSWzb1ZwKCZi2aY_zDVC-epw6HPRsoEY7dBYrQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sun, Oct 11, 2026 at 10:50 AM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> Codex reported that the following INSERT, which previously succeeded, still
> fails with this patch. I confirmed the issue. Should we fix this as well?
Thanks for the report. This is the same problem, this time in NULLIF.
A NULLIF's typmod is that of its first argument, and inlining the SQL
function changes it from -1 to that of numeric(10). The index expr is
inlined in the first pass but reduced only in the second, so it gets
the new typmod, while the ON CONFLICT expression is inlined and
reduced in one pass and keeps -1.
v2-0001 extends v1 to relabel a rebuilt NULLIF to its original typmod
as well, and to use that typmod when a NULLIF is folded to a constant.
While testing, I found that relabeling a rebuilt COALESCE defeats
reconsider_full_join_clause(), which expects the merged column of a
FULL JOIN USING to be a bare COALESCE. So when the join inputs are
inlined SQL functions, a qual like "x = 1" on the merged column is no
longer pushed down to them. v2-0002 fixes that by looking through the
RelabelType there.
- Richard
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Preserve-typmod-when-reducing-CASE-COALESCE-and-N.patch | application/octet-stream | 11.7 KB |
| v2-0002-Look-through-RelabelType-when-matching-a-FULL-JOI.patch | application/octet-stream | 4.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nisha Moond | 2026-10-16 06:57:26 | Re: Fix WITHOUT OVERLAPS multirange with location replication |
| Previous Message | Tom Lane | 2026-10-16 05:11:36 | Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding |