weird ON CONFLICT clauses

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: weird ON CONFLICT clauses
Date: 2025-11-27 16:00:24
Message-ID: 202511271516.oiefpvn3z27m@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While reviewing a patch I noticed that we allow some extraneous items in
ON CONFLICT clauses -- for instance,

create table tab (a int unique, b int);
insert into tab values (1, 1) on conflict (a int4_ops (fillfactor=10)) do nothing;

Why do we accept reloptions there without complaint? Should we tighten
this up a little bit, or maybe it makes sense to accept this for some
reason? I suspect the reloptions were added to index_elems after the ON
CONFLICT clause was made to use that production, but I didn't check the
git history.

So what about the attached patch? I ran all tests and everything seems
to work correctly. (Maybe I'd add some tests to verify that this
new error is covered, as the ones just above.) It would complain to the
above:

ERROR: operator class options are not allowed in ON CONFLICT clause
LÍNEA 1: insert into tab values (1, 1) on conflict (a int4_ops (fillf...
^

This is certainly not very critical.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"El Maquinismo fue proscrito so pena de cosquilleo hasta la muerte"
(Ijon Tichy en Viajes, Stanislaw Lem)

Attachment Content-Type Size
0001-Reject-opclass-options-in-ON-CONFLICT-clause.patch text/x-diff 2.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Maxim Orlov 2025-11-27 16:00:30 Using MyDatabaseId in SET_LOCKTAG_APPLY_TRANSACTION
Previous Message Peter Eisentraut 2025-11-27 15:44:26 Re: SQL:2011 Application Time Update & Delete