Re: Error with Insert from View with ON Conflict

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
Cc: Alex Magnum <magnum11200(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Error with Insert from View with ON Conflict
Date: 2021-11-04 00:54:40
Message-ID: CAH2-Wzm7=qhf3itAzmCGPyKOqW14aseiHtj7eNue6NXN8HyYnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Nov 3, 2021 at 2:18 PM Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com> wrote:
> I'm pretty sure the 'alias' for the '.. on conflict do update ..' needs to be 'excluded' (i.e. checks = excluded.checks, ...). Check the docs.

That's right . The excluded.* pseudo-table isn't exactly the same
thing as the target table -- it is a tuple that has the same "shape",
that represents what the implementation tried (and failed) to insert
into the table. I have to imagine that Alex wants to reference that,
because that's the standard idiomatic approach with ON CONFLICT. And
because the only alternative interpretation is that Alex intends to
update those columns using their current values (not new values),
which won't really change anything -- that seems unlikely to have been
the intent.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bryn Llewellyn 2021-11-04 02:12:39 Re: to_date() and to_timestamp() with negative years
Previous Message Adrian Klaver 2021-11-04 00:07:36 Re: to_date() and to_timestamp() with negative years