Re: Way to get at parsed trigger 'WHEN' clause expression? - Mailing list pgsql-general

From James Robinson
Subject Re: Way to get at parsed trigger 'WHEN' clause expression?
Date
Msg-id 6818DA0F-65A7-431D-A086-BD0DC6B0CDFB@socialserve.com
Whole thread Raw
In response to Way to get at parsed trigger 'WHEN' clause expression?  (James Robinson <jlrobins@socialserve.com>)
List pgsql-general
> On Mar 25, 2016, at 3:02 PM, Igor Neyman <ineyman@perceptron.com> wrote:
>
> James,
>
> Instead of pg_catalog, you could use INFORMATION_SCHEMA to get "WHEN" clause:
>
> select action_condition from information_schema.triggers where trigger_name = 'your_trigger_name';
>
> Regards,
> Igor

Hah, good suggestion. Looking into how *it* is implemented (on 9.2 at least), brings us back to string manipulation of
theresult of pg_get_triggerdef(): 

\d+ information_schema.triggers
...
"substring"(pg_get_triggerdef(t.oid), "position"("substring"(pg_get_triggerdef(t.oid), 48), 'EXECUTE PROCEDURE'::text)
+47)::information_schema.character_data AS action_statement, 
...

But at least we can turn a blind eye to its internal horror. Thanks!

-------
James Robinson
james@jlr-photo.com





pgsql-general by date:

Previous
From: Moreno Andreo
Date:
Subject: Re: [SPAM] Re: PostgreSQL crash with PANIC message
Next
From: "Jernigan, Kevin"
Date:
Subject: Re: PostgreSQL advocacy