Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT
Дата
Msg-id CAH2-Wzmx5Q-fakiieGOmv=bvOV_KTA1ObA-OZXVN5N6mc3Se3Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT
Список pgsql-hackers
On Thu, Jun 30, 2022 at 2:07 PM David G. Johnston
<david.g.johnston@gmail.com> wrote:
> Current:
> "The SET and WHERE clauses in ON CONFLICT DO UPDATE have access to the
> existing row using the table's name (or an alias), and to [rows] proposed
> for insertion using the special excluded table."
>
> The word table in that sentence is wrong and not a useful way to think of the thing which we've named excluded.  It
isa single value of a composite type having the structure of the named table.
 

I think that your reasoning is correct, but I don't agree with your
conclusion. The term "special excluded table" is a fudge, but that
isn't necessarily a bad thing. Sure, we could add something about the
UPDATE being similar to an UPDATE with a self-join, as I said
upthread. But I think that that would make the concept harder to
grasp.

> I'll agree that most people will mentally paper over the difference and go merrily on their way.  At least one person
recentlydid not do that, which prompted an email to the community
 

Can you provide a reference for this? Didn't see anything like that in
the reference you gave upthread.

I have a hard time imagining a user that reads the INSERT docs and
imagines that "excluded" is a relation that is visible to the query in
ways that are not limited to expression evaluation for the UPDATE's
WHERE/SET. The way that it works (and doesn't work) follows naturally
from what a user would want to do in order to upsert. MySQL's INSERT
... ON DUPLICATE KEY UPDATE feature has a magical UPSERT-only
expression instead of "excluded".

-- 
Peter Geoghegan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT