Search Postgresql Archives

Using pg_trigger.tgqual

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I was interested in reading pg_trigger.tgqual from the system catalogs to
get a trigger WHEN expression. E.g., for

CREATE TRIGGER tr_example
      BEFORE UPDATE
      ON example
      FOR EACH ROW
      WHEN (NEW.num > 5)
      EXECUTE PROCEDURE tr_example_fn();

I would love to receive the "NEW.num > 5" expression in my SELECT FROM
pg_trigger query.

I tried to:
SELECT pg_get_expr(tgqual, tgrelid) FROM pg_trigger
which reports "ERROR: bogus varno: 2", though. I am not aware of anything
better to pass as the second argument to pg_get_expr() - with any other
reasonable column I tried the result is NULL.

I know there is the pg_get_triggerdef(trigger_oid) function, which returns
the whole trigger definition. I am only interested in the WHEN expression,
though. Of course I can parse the WHEN expression from that, but I hoped
the pg_trigger.tgqual field could be usable. It seems to me there is a
problem with respect to the NEW/OLD variables. (When neither NEW nor OLD
is referenced, pg_get_expr() returns the expression alright - which is not
surprising, though...)

information_schema.triggers.action_condition is not an option for me since
it does not contain TRUNCATE triggers.

Could you, please, make any suggestions on what to pass to pg_get_expr()
to return the expression using NEW/OLD references?

Thank you,
Ondřej Bouda


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux