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

From: James Robinson <jlrobins(at)socialserve(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Way to get at parsed trigger 'WHEN' clause expression?
Date: 2016-03-24 20:05:16
Message-ID: 2B58A7BD-8740-4222-BC79-A82E3DCD62E0@socialserve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Folks,

I see that psql's \d displays trigger information of a table by making a call to pg_catalog.pg_get_triggerdef(), which abstracts away most all need to parse the contents of system catalog pg_trigger. However, we'd like to be able to get at a human readable representation of just the WHEN clause of the trigger expression. Function pg_get_expr() looked likely, but fails when fed a pgqual value from pg_trigger ala:

ERROR: bogus varno: 2

I suspect that it is falling over dead trying to parse the representation of NEW and / or OLD. Anything built in, or should we just make call to pg_catalog.pg_get_triggerdef() and parse out the WHEN clause text?

Thanks!
------
James Robinson
Socialserve.com by Emphasys Software

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavin Flower 2016-03-24 20:40:04 Re: Uninstalled working db by mistake
Previous Message Howard News 2016-03-24 18:03:32 Re: Uninstalled working db by mistake