Re: Evaluate arbitrary expression on tuple inside trigger function?

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Dunstan <pgsql(at)tomd(dot)cc>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Evaluate arbitrary expression on tuple inside trigger function?
Date: 2013-07-30 03:36:39
Message-ID: 20130730033639.GA261727@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 29, 2013 at 12:59:27PM +0930, Tom Dunstan wrote:
> I'm trying to hack a trigger function to evaluate an expression on the
> tuple that the trigger has been fired for, kinda like a check
> constraint. I looked at ExecRelCheck in execMain.c which does
> more-or-less what I want to do, and I have the parsed node tree all
> ready to go. The problem that I'm facing is that ExecRelCheck uses a
> passed in EState to set up the executor in the right mode, and with
> the right memory context, but the EState doesn't get passed in to the
> trigger function, and I can't see anything obvious hanging off the
> TriggerData that does get passed in that would give me access to it.
>
> Can anyone either point me to where I might be able to get a handle on
> the current EState, or otherwise recommend a way forward?

I doubt there's a clean way to grab the parent estate. Creating a local
estate in your trigger function does work. Compare how copy.c creates one for
some relatively-narrow purposes.

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-07-30 04:13:51 Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])
Previous Message Amit Kapila 2013-07-30 03:27:12 Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])