Re: Way to get at parsed trigger 'WHEN' clause expression?

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Igor Neyman <ineyman(at)perceptron(dot)com>
Cc: James Robinson <jlrobins(at)socialserve(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Way to get at parsed trigger 'WHEN' clause expression?
Date: 2016-03-25 15:17:05
Message-ID: CANu8FixEa1amXKmFgrsQthrDVGN=Oz7vWh6tMDwpL2DhAZJefQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 25, 2016 at 11:10 AM, Igor Neyman <ineyman(at)perceptron(dot)com>
wrote:

> Did you mean something like
>
>
>
> *SELECT substring(pg_get_triggerdef(tg.oid, TRUE) FROM position('WHEN' in
> pg_get_triggerdef(tg.oid, TRUE))) AS when_cond FROM pg_trigger tg WHERE
> tg.tgname = 'your_trigger_name'; *
>
>
> --
>
> *Melvin Davidson*
>
> *I reserve the right to fantasize. Whether or not you wish to share my
> fantasy is entirely up to you. **[image:
> http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/01.gif]*
>
>
>
>
>
> This doesn’t answer OP question.
>
> Besides this query gets you not only “WHEN” clause but also whatever
> follows it, for instance “EXECUTE PROCEDURE…”
>
>
>
> As for “pg_get_expr(pg_node_tree, relation_oid)” – looks like it doesn’t
> work with pg_trigger, because as a second parameter (Var) it expects
> relation_oid, and relation could have multiple triggers, so pg_get_expr()
> wouldn’t know which trigger’s tgqual you want to decompile.
>
>
>
> Regards,
>
> Igor Neyman
>

Actually, it DOES answer the "OP" question. The "Besides" is irrelevant, as
with additional length() & position() sub functions, just the WHEN clause
can be abstracted. I'm just not going to waste my time doing all the work
when I provided a viable solution that does not error out.
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message James Robinson 2016-03-25 15:29:24 Re: Way to get at parsed trigger 'WHEN' clause expression?
Previous Message Igor Neyman 2016-03-25 15:10:09 Re: Way to get at parsed trigger 'WHEN' clause expression?