Re: Allow ON CONFLICT DO UPDATE to return EXCLUDED values

From: Viktor Holmberg <v(at)viktorh(dot)net>
To: Vik Fearing <vik(at)postgresfriends(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Allow ON CONFLICT DO UPDATE to return EXCLUDED values
Date: 2026-02-13 14:16:06
Message-ID: ec099f14-221d-41a0-9a83-f8adc95c85f5@Spark
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12 Feb 2026 at 13:23 +0100, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, wrote:
> On Thu, 12 Feb 2026 at 11:11, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> >
> > Rebased version attached (now also works with ON CONFLICT DO SELECT).
> >
>
> Something else to consider is the fact that this patch allows both
> colname and EXCLUDED.colname to appear in the RETURNING list, where
> the former refers to the target relation as it always has done. We're
> pretty-much forced into that position, in order that people don't have
> to rewrite all their existing queries (the same was true when support
> for OLD/NEW was added to RETURNING).
>
> But that then leads to the odd situation where colname has to be
> qualified when it appears on the RHS of a SET clause, or in the WHERE
> clause of INSERT ON CONFLICT, but not when it appears in the RETURNING
> list.
>
> There was a separate discussion [1] about whether we should remove
> this requirement for colname to be qualified elsewhere in INSERT ON
> CONFLICT, and I think this patch adds more weight to that argument.
>
> [1] https://www.postgresql.org/message-id/flat/a31a76b6-b176-47fe-8778-9dfece231341(at)wikimedia(dot)org
>
> So should we do that, and allow unqualified column names in ON
> CONFLICT SET and WHERE?
In my opinion, yes. Qualifying with the table name doesn’t really make it much clearer which version of the table you’re referring to than having it unqualified.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2026-02-13 14:23:14 Re: pgsql: Add file_extend_method=posix_fallocate,write_zeros.
Previous Message Fujii Masao 2026-02-13 13:27:34 Re: recovery.signal not cleaned up when both signal files are present