Re: INSERT ... ON CONFLICT syntax issues

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: hlinnaka <hlinnaka(at)iki(dot)fi>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Subject: Re: INSERT ... ON CONFLICT syntax issues
Date: 2015-05-06 20:56:47
Message-ID: CAM3SWZSDSJNQL9rtGy0FF7WrF_M=81sK18-QxShXwBxDeOeQ+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 6, 2015 at 1:48 PM, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>> TARGET is also very descriptive, because it situationally describes
>> either the existing tuple actually present in the table, or (from a
>> RETURNING clause) the final tuple present in the table post-UPDATE.
>> We use the term "target" for that pervasively (in the docs and in the
>> code).
>
>
> but I find that totally unconvincing. It's clear that TARGET refers to the
> table being upserted, but it's totally unclear on *which* version of the
> tuple it refers to.

Then we're simply talking about 2 different things. My understanding
is that it *is* the relation. And like UPDATE's RETURNING, it will be
the same relation/alias but a different tuple here. Andres said this
was a mutating tuple or something like that, and I suppose it is. But
Vars are variables.

Now, Andres (and now you) want to change it so that the TARGET alias
becomes magical and expression-like, so that it really does refer to a
tuple and not a relation (and so is closer to EXCLUDED.*). And you
seem pretty set on that. That being the case, clearly TARGET is
unsuitable for the reasons you state.

I suppose that it doesn't much matter, but that's how I understood the
situation all along. So I can see why you don't like "TARGET" in light
of that. I would vote for EXISTING as an alternative, given that it's
pretty clear that what is now TARGET.* will become a magic
alias/expression thing. EXISTING is the EXISTING tuple, which goes
well with EXCLUDED.
--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-05-06 21:01:42 Re: INSERT ... ON CONFLICT syntax issues
Previous Message Andres Freund 2015-05-06 20:48:43 Re: INSERT ... ON CONFLICT syntax issues