| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Guofenglinux <guofenglinux(at)gmail(dot)com> |
| Subject: | Re: [PG19] Wrong results from NOT NULL-based expression simplification |
| Date: | 2026-10-09 13:56:16 |
| Message-ID: | CACJufxEtrO41q8LndKHLmgYt2pb0gfRjzc98w00gydqGjkybDA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Oct 6, 2026 at 11:28 AM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Hi hackers,
>
> I used Opus to analyze the new features in PG19, and it found five
> queries that work on 18 and break on 19 and master. Each item has a
> script and a patch with its number.
>
> I manually verified these issues and
>
> 1. coalesce(b, '') on a NOT NULL column is simplified to plain b, in
> the index and in ON CONFLICT. Only the ON CONFLICT side counts it as a
> plain column, so they do not match.
> create table oc (b text not null);
> create unique index on oc (coalesce(b, ''));
> insert into oc values ('x') on conflict (coalesce(b, '')) do nothing;
> 18 inserts the row. 19 gives "there is no unique or exclusion
> constraint matching the ON CONFLICT specification". 0001 counts the
> index expression as a plain column too.
>
/*
* Now that all inference elements were matched, ensure that the
* expression elements from inference clause are not missing any
* cataloged expressions. This does the right thing when unique
* indexes redundantly repeat the same attribute, or if attributes
* redundantly appear multiple times within an inference clause.
*/
if (list_difference(idxOtherExprs, inferElems) != NIL)
continue;
The above comments also need to change?
While at it, we can replace 0 with InvalidAttrNumber, as shown in the
attachment.
Other than that, V1 looks good to me.
| Attachment | Content-Type | Size |
|---|---|---|
| minor_change_on_conflict.txt | text/plain | 1018 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hunaid Sohail | 2026-10-09 14:13:03 | Re: Proposal: SELECT * EXCLUDE (...) command |
| Previous Message | Álvaro Herrera | 2026-10-09 13:50:04 | Re: Adding init-po and update-po targets to the meson build system |