Re: ON CONFLICT DO SELECT (take 3)

From: Viktor Holmberg <v(at)viktorh(dot)net>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Marko Tiikkaja <marko(at)joh(dot)to>, Andreas Karlsson <andreas(at)proxel(dot)se>
Subject: Re: ON CONFLICT DO SELECT (take 3)
Date: 2026-01-28 20:33:21
Message-ID: af711978-dac1-4c79-a7cd-83cdf89c0af6@Spark
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28 Jan 2026 at 09:53 +0100, jian he <jian(dot)universality(at)gmail(dot)com>, wrote:
>
> doc/src/sgml/ref/create_policy.sgml
> <para>
> When an <literal>INSERT</literal> command has an auxiliary
> <literal>ON CONFLICT DO UPDATE</literal> clause, if the
> <literal>UPDATE</literal> path is taken, the row to be updated is
> first checked against the <literal>USING</literal> expressions of
> For ON CONFLICT DO SELECT, perhaps we should add some explanatory text
> to the preceding paragraph?
I think this is overkill. The previous paragraph talks about the returning clause, and in general I think the behaviour is obvious? Or did you have anything specific in mind?
> typedef struct RTEPermissionInfo
> comment:
> * For SELECT/INSERT/UPDATE permissions, if the user doesn't have table-wide
> * permissions then it is sufficient to have the permissions on all columns
> * identified in selectedCols (for SELECT) and/or insertedCols and/or
> * updatedCols (INSERT with ON CONFLICT DO UPDATE may have all 3).
>
> This applies to ON CONFLICT DO SELECT FOR UPDATE, i think.
> Maybe we can update this too.
I think the comment is clear enough as is - the example about ON CONFLCIT DO UPDATE is just to illustrate how it works. Adding details about DO SELECT seems out of place here? No a hill I'm willing to die on but maybe you can suggest something if you disagree Jian?
> Overall, these are all the issues I’ve identified. Aside from those
> issues, the patch looks very good.
>
> --
> jian
Here comes v.22 with all your comments except those 2 mentioned above updated in line with your comments Jian.
I squashed everything together - if you’d rather have the fixes as a separate commit for review let me know.
Thanks again for your detailed feedback & fixes. I’m sorry you’ve had to go though so many iterations of review on this one, but hopefully it’s starting to look ok now.

/Viktor

Attachment Content-Type Size
v22-0001-Add-ON-CONFLICT-DO-SELECT-FOR-SHARE-UPDATE.patch application/octet-stream 153.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Chavez 2026-01-28 20:43:54 Re: Add SECURITY_INVOKER_VIEWS option to CREATE DATABASE
Previous Message Laurenz Albe 2026-01-28 20:28:43 Re: Add SECURITY_INVOKER_VIEWS option to CREATE DATABASE