From: Fabio Ugo Venchiarutti <f.venchiarutti@ocado.com>
To: Justin Pryzby <pryzby@telsasoft.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@postgresql.org
Subject: Re: distinguish update from insert (on conflict)
Date: Wed, 22 May 2019 10:36:10 +0100
Message-ID: <e56b433e-5781-65f5-228d-54681967ed88@ocado.com> (raw)
In-Reply-To: <20190522023748.GH4426@telsasoft.com>
References: <20190522013428.GG4426@telsasoft.com>
<106c0789-7a13-7f9c-8d49-3562556bcdd8@aklaver.com>
<20190522023748.GH4426@telsasoft.com>
On 22/05/2019 03:37, Justin Pryzby wrote:
> On Tue, May 21, 2019 at 06:57:36PM -0700, Adrian Klaver wrote:
>> On 5/21/19 6:34 PM, Justin Pryzby wrote:
>>> Is it still impossible to distinguish whether a row was inserted vs updated ?
>>
>> You will need to be more specific.
>
> Sorry, I mean with UPSERT / "INSERT .. ON CONFLICT DO UPDATE", is it possible
> to tell whether a row was inserted vs. updated ?
>
> Thanks,
> Justin
>
>
Here's my recipe for that:
RETURNING
/* whatever, */
(xmax = 0) AS is_new_record
;
I don't know if any of the hackers thought of a sleeker technique
--
Regards
Fabio Ugo Venchiarutti
OSPCFC Network Engineering Dpt.
Ocado Technology
--
Notice: This email is confidential and may contain copyright material of
members of the Ocado Group. Opinions and views expressed in this message
may not necessarily reflect the opinions and views of the members of the
Ocado Group.
If you are not the intended recipient, please notify us
immediately and delete all copies of this message. Please note that it is
your responsibility to scan this message for viruses.
Fetch and Sizzle
are trading names of Speciality Stores Limited and Fabled is a trading name
of Marie Claire Beauty Limited, both members of the Ocado Group.
References to the “Ocado Group” are to Ocado Group plc (registered in
England and Wales with number 7098618) and its subsidiary undertakings (as
that expression is defined in the Companies Act 2006) from time to time.
The registered office of Ocado Group plc is Buildings One & Two, Trident
Place, Mosquito Way, Hatfield, Hertfordshire, AL10 9UL.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: f.venchiarutti@ocado.com, pryzby@telsasoft.com, adrian.klaver@aklaver.com
Subject: Re: distinguish update from insert (on conflict)
In-Reply-To: <e56b433e-5781-65f5-228d-54681967ed88@ocado.com>
References: <20190522013428.GG4426@telsasoft.com> <106c0789-7a13-7f9c-8d49-3562556bcdd8@aklaver.com> <20190522023748.GH4426@telsasoft.com> <e56b433e-5781-65f5-228d-54681967ed88@ocado.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox