Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE - Mailing list pgsql-bugs

From Peter Geoghegan
Subject Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE
Date
Msg-id CAM3SWZT3X4zsKQwoAfe59afay+MWLLpQXtMDOVchBJfv+iqrNg@mail.gmail.com
Whole thread Raw
In response to BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE  (rwestlun@gmail.com)
List pgsql-bugs
On Sun, Jan 24, 2016 at 11:48 PM,  <rwestlun@gmail.com> wrote:
> I believe postgres should be returning "UPDATE" here instead of "INSERT"
> because I see no way to know which operation took place.  I believe my only
> options at the moment are using a second query or adding a column like
> "just_created BOOLEAN DEFAULT true", setting it to false in the UPDATE
> clause, and returning it.

This is the documented behavior for the command tag. I don't think
that it's workable to expose more information there.

It might be desirable to have a feature that exposed whether an insert
or update occurred in respect of each row projected by RETURNING,
perhaps by using a special expression (you might be able to do
something kludgey with xmax today, but I don't want to recommend that,
even informally).

This is a feature request, not a bug. Please post feature requests to
the -general list.

--
Peter Geoghegan

pgsql-bugs by date:

Previous
From: Gavin Flower
Date:
Subject: Re: BUG #13883: Very Important Facility
Next
From: Peter Geoghegan
Date:
Subject: Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE