Re: ON CONFLICT DO SELECT (take 3)

From: Viktor Holmberg <v(at)viktorh(dot)net>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(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-02-11 14:54:55
Message-ID: badc3b4c-da73-4000-b8d3-638a6f53a769@Spark
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11 Feb 2026 at 12:34 +0100, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, wrote:
> > Thanks for sorting all these changes Dean, all look good to me. The only
> > thing that gave me pause is this change in analyse.c lines 1238-1247:
> >
> > So in v.24 we set p_is_insert = false for DO SELECT as well.
> > If I’m understanding the code correctly, this is only used when using indirection
> > on target columns for updates, like setting a value inside an array, like for example:
> > update example set arr[2] = 10;
> > So changing this should have any effect, as the DO SELECT doesn’t have any SET clause.
> > Logically it makes sense that DO SELECT is p_is_insert = false.
> > But maybe the comment should be updated to explain this?
>
> Yes, that's right. I was just trying to reduce code churn. However, if
> we need to change the comment to explain why it's OK for DO SELECT,
> the code churn argument doesn't work, and it's probably better to only
> set it for DO UPDATE. So I've reverted it back to how it was in v23,
> with slightly updated comments.
Looking more at this, I’m quite sure that the p_is_insert field can just be removed?
See 0002. If you’d rather focus on reducing code churn, or you believe this is risky,
I’m also happy for you to just commit 0001.
> Re-reading the INSERT docs, I still wasn't entirely happy with the
> description of the conflict_action parameter, so I had a go at
> rewriting it. I also pulled out the description of the locking
> options, describing them separately and linking to the description of
> the locking clause on the SELECT page.
Had a look through it and yes, the docs are better with your changes.

Attachment Content-Type Size
v26-0001-Add-support-for-INSERT-.-ON-CONFLICT-DO-SELECT.patch application/octet-stream 145.7 KB
v26-0002-Refactor-remove-redundant-p_is_insert-field-from.patch application/octet-stream 4.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-02-11 15:02:47 Re: Little cleanup: Move ProcStructLock to the ProcGlobal struct
Previous Message Tom Lane 2026-02-11 14:52:56 Re: Little cleanup: Move ProcStructLock to the ProcGlobal struct