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

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: rwestlun(at)gmail(dot)com, 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:46:47
Message-ID: 56A67BA7.7020201@joh.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2016-01-25 8:35 PM, Peter Geoghegan wrote:
> On Mon, Jan 25, 2016 at 2:00 AM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:
>> FWIW, I would've expected to be able to do RETURNING excluded.foo which
>> would have been NULL in case of INSERT, and the value from the updated tuple
>> otherwise. But that doesn't seem to work.
>
> The problem with that approach is that it makes both the target table
> and the excluded pseudo table visible from within RETURNING. If we
> were to do that, virtually every use of INSERT with both an ON
> CONFLICT DO UPDATE clause and a RETURNING clause breaks. That's
> because any unqualified column reference becomes ambiguous ("Did you
> mean target.foo or excluded.foo?").

Surely there's a way to make this work so that EXCLUDED is a special
tuple whose fields are normally not in scope, but can be accessed
explicitly.

But this discussion belongs to -HACKERS, as you said upthread.

.m

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Vitaly Burovoy 2016-01-25 19:55:52 Re: BUG #13883: Very Important Facility
Previous 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