Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: rwestlun(at)gmail(dot)com
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE
Date: 2016-01-25 19:22:49
Message-ID: CAM3SWZT3X4zsKQwoAfe59afay+MWLLpQXtMDOVchBJfv+iqrNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, Jan 24, 2016 at 11:48 PM, <rwestlun(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2016-01-25 19:35:17 Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE
Previous Message Gavin Flower 2016-01-25 19:00:46 Re: BUG #13883: Very Important Facility