Re: UPSERT on partition - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: UPSERT on partition
Date
Msg-id CAM3SWZRfk_66+7RU6mw_HxRNsrEqk6u2Ber-BfKFprMXuxJQaQ@mail.gmail.com
Whole thread Raw
In response to Re: UPSERT on partition  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: UPSERT on partition  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
List pgsql-hackers
On Wed, Jun 24, 2015 at 7:38 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> Is the root of the problem that the trigger is called for an INSERT ..
> ON CONFLICT statement but it turns that into a plain INSERT?
>
> Is there any way of writing a partitioning trigger that doesn't have
> that defect?

We did discuss whether or not it was important to expose information
to triggers sufficient to route + UPSERT tuples into inheritance
children in an equivalent way (equivalent to an UPSERT into the
inheritance parent). At the time, you seemed to think that it could
wait [1].

Even if we added what was discussed as a minimal and practical way of
exposing this [2], it would still be awkward for an INSERT trigger to
examine the structure of the "UPDATE part" of the UPSERT -- there will
be no *tuple* for that case (yet).

Inheritance with triggers is a leaky abstraction, so this kind of
thing is always awkward. Still, UPSERT has full support for
*inheritance* -- that just doesn't help in this case.

[1] http://www.postgresql.org/message-id/CA+TgmoZAVXMwOeBPK4ASZonuwUr3QPSWWk6XetXMcA+8H7Cd8Q@mail.gmail.com
[2] http://www.postgresql.org/message-id/CAM3SWZRvjyu8nnvw_JHeXx4YMQ9XaA7u0GEtLbCgym0oEAn_7Q@mail.gmail.com
-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Joel Jacobson
Date:
Subject: Trustly PostgreSQL Data Corruption Bug Bounty Program
Next
From: Andres Freund
Date:
Subject: Re: Removing SSL renegotiation (Was: Should we back-patch SSL renegotiation fixes?)