Skip site navigation (1) Skip section navigation (2)

WIP: push AFTER-trigger execution into ModifyTable node

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: WIP: push AFTER-trigger execution into ModifyTable node
Date: 2009-10-28 22:45:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
I suggested that we should push the actual execution (not just queuing)
of non-deferred AFTER triggers into the new ModifyTable plan node.
The attached patch does that, and seems like a nice improvement since it
removes knowledge of trigger handling from a number of other places.
However the original objective was to allow EXPLAIN to associate trigger
runtimes with ModifyTable nodes, and I realized that this patch doesn't
accomplish that --- the trigger stats are still accumulated in the
executor-wide EState, not in the ModifyTable node.  Right at the moment
we could cheat and have EXPLAIN print the trigger stats under
ModifyTable anyway, because there can be only one ModifyTable in any
plan tree.  But that will fall down as soon as we try to let INSERT
RETURNING and friends execute within WITH clauses.

After poking around a bit I think it should be possible to keep the
trigger instrumentation data in the ModifyTable node instead of in
EState, and thereby allow EXPLAIN to know which node to blame the
trigger time on.  This will require passing an extra parameter down
from nodeModifyTable into the trigger code, but none of those call paths
are very long.  Still, it'll be a significantly more invasive patch by
the time it's done than what you see here.

So, before I go off and do that work: anybody have an objection to this
line of development?  The main implication of changing to this approach
is that we'll be nailing down the assumption that each WITH (command
RETURNING) clause acts very much like a separate statement for
trigger purposes: it will fire BEFORE STATEMENT triggers at start,
and AFTER STATEMENT triggers at end, and actually execute all
non-deferred AFTER triggers, before we move on to executing the next
WITH clause or the main query.

			regards, tom lane

Attachment: triggers-in-modify-table-1.patch
Description: text/x-patch (16.1 KB)


pgsql-hackers by date

Next:From: Marko TiikkajaDate: 2009-10-29 00:21:09
Subject: Re: WIP: push AFTER-trigger execution into ModifyTable node
Previous:From: Guillaume LelargeDate: 2009-10-28 22:35:45
Subject: Re: Show schema size with \dn+

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group