From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: BEFORE ROW triggers for partitioned tables
Date: Tue, 10 Mar 2020 19:44:15 +0100
Message-ID: <2421844e-0798-5c2a-24b8-d061dafe2939@2ndquadrant.com> (raw)
In-Reply-To: <20200227165158.GA2071@alvherre.pgsql>
References: <20200227165158.GA2071@alvherre.pgsql>
On 2020-02-27 17:51, Alvaro Herrera wrote:
> Enabling BEFORE triggers FOR EACH ROW in partitioned tables is very easy
> -- just remove the check against them. With that, they work fine.
This looks good to me in principle. It's a useful thing to support.
> 1. Just let it be. If the user does something silly, it's their problem
> if they get an ugly error message.
>
> 2. If the partition keys are changed, raise an error. The trigger is
> allowed to change everything but those columns. Then there's no
> conflict, and it allows desirable use cases.
>
> 3. Allow the partition keys to change, as long as the tuple ends up in
> the same partition. This is the same as (1) except the error message is
> nicer.
>
> The attached patch implements (2).
That seems alright to me.
> * The new function I added, ReportTriggerPartkeyChange(), contains one
> serious bug (namely: it doesn't map attribute numbers properly if
> partitions are differently defined). Also, it has a performance issue,
> namely that we do heap_getattr() potentially repeatedly -- maybe it'd be
> better to "slotify" the tuple prior to doing the checks.
The attribute ordering issue obviously needs to be addressed, but the
performance issue is probably not so important. How many levels of
partitioning are we expecting?
> Another
> possible controversial point is that its location in commands/trigger.c
> isn't great. (Frankly, I don't understand why the executor trigger
> firing functions are in commands/ at all.)
yeah ...
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, alvherre@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
Subject: Re: BEFORE ROW triggers for partitioned tables
In-Reply-To: <2421844e-0798-5c2a-24b8-d061dafe2939@2ndquadrant.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