From: | Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com> |
Subject: | Re: FOR EACH ROW triggers on partitioned tables |
Date: | 2018-01-30 09:49:49 |
Message-ID: | bd2763a7-b845-8595-1cc1-a0244f692801@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2018/01/30 5:30, Peter Eisentraut wrote:
> On 1/23/18 17:10, Alvaro Herrera wrote:
>> The main question is this: when running the trigger function, it is
>> going to look as it is running in the context of the partition, not in
>> the context of the parent partitioned table (TG_RELNAME etc). That
>> seems mildly ugly: some users may be expecting that the partitioning
>> stuff is invisible to the rest of the system, so if you have triggers on
>> a regular table and later on decide to partition that table, the
>> behavior of triggers will change, which is maybe unexpected. Maybe this
>> is not really a problem, but I'm not sure and would like further
>> opinions.
>
> One could go either way on this, but I think reporting the actual table
> partition is acceptable and preferable.
+1
> If you are writing a generic
> trigger function, maybe to dump out all columns, you want to know the
> physical table and its actual columns. It's easy[citation needed] to
> get the partition root for a given table, if the trigger code needs
> that. The other way around is not possible.
I guess you mean the root where a trigger originated, that is, ancestor
table on which an inherited trigger was originally defined. It is
possible for a trigger to be defined on an intermediate parent and not the
topmost root in a partition tree.
I see that the only parent-child relationship for triggers created
recursively is recorded in the form of a dependency. I wonder why not a
flag in, say, pg_trigger to indicate that a trigger may have been created
recursively. With the committed for inherited indexes, I can see that
inheritance is explicitly recorded in pg_inherits because indexes are
relations, so it's possible in the indexes' case to get the parent in
which a given inherited index originated.
> Similarly, transition tables should be OK. You only get the current
> partition to look at, of course.
+1
> The function name CloneRowTriggersOnPartition() confused me. A more
> accurate phrasing might be CloneRowTriggersToPartition(), or maybe
> reword altogether.
CloneRowTriggers*For*Partition()?
Thanks,
Amit
From | Date | Subject | |
---|---|---|---|
Next Message | Etsuro Fujita | 2018-01-30 09:52:21 | Re: non-bulk inserts and tuple routing |
Previous Message | Simon Riggs | 2018-01-30 09:45:49 | Re: [HACKERS] MERGE SQL Statement for PG11 |