pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Simon Riggs <simon@2ndquadrant.com>
Subject: Re: FOR EACH ROW triggers on partitioned tables
Date: Tue, 30 Jan 2018 19:44:02 -0500
Message-ID: <183aa6b7-468c-cc8d-12b2-aa5577bc807b@2ndquadrant.com> (raw)
In-Reply-To: <bd2763a7-b845-8595-1cc1-a0244f692801@lab.ntt.co.jp>
References: <20180123221027.2qenwwpvgplrrx3d@alvherre.pgsql>
	<171cb95a-35ec-2ace-3add-a8d16279f0bf@2ndquadrant.com>
	<bd2763a7-b845-8595-1cc1-a0244f692801@lab.ntt.co.jp>

On 1/30/18 04:49, Amit Langote wrote:
>> 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.

OK, so maybe not so "easy".

But this muddies the situation even further.  You could be updating
table A, which causes an update in intermediate partition B, which
causes an update in leaf partition C, which fires a trigger that was
logically defined on B and has a local child on C.  Under this proposal,
the trigger will see TG_RELNAME = C.  You could make arguments that the
trigger should also somehow know about B (where the trigger was defined)
and A (what the user actually targeted in their statement).  I'm not
sure how useful these would be.  But if you want to cover everything,
you'll need three values.

I think the patch can go ahead as proposed, and the other things could
be future separate additions.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (39+ messages)  latest in thread

Message-ID: <183aa6b7-468c-cc8d-12b2-aa5577bc807b@2ndquadrant.com>
Permalink:  ../183aa6b7-468c-cc8d-12b2-aa5577bc807b@2ndquadrant.com/
Also on:    postgresql.org/message-id/183aa6b7-468c-cc8d-12b2-aa5577bc807b@2ndquadrant.com

 · 

reply

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, Langote_Amit_f8@lab.ntt.co.jp, alvherre@alvh.no-ip.org, simon@2ndquadrant.com
  Subject: Re: FOR EACH ROW triggers on partitioned tables
  In-Reply-To: <183aa6b7-468c-cc8d-12b2-aa5577bc807b@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