I create comment on trigger:
COMMENT ON TRIGGER my_trigger on my_table IS $$comment on trigger$$;
and then retrieve the comment like this:
select description
from pg_description
join pg_trigger on pg_description.objoid = pg_trigger.tgfoid
where tgname = 'my_trigger';
But the statement returned 0 row.
Here is the table and its trigger:
=# \d ps_dbupdates
Column | Type | Modifiers
--------+---------+-----------------------------------------------------------
id | integer | not null default nextval('ps_dbupdates_id_seq'::regclass)
update | integer | not null
Indexes:
"ps_dbupdates_pkey" PRIMARY KEY, btree (id)
Triggers:
single_dbupdate_trigger BEFORE INSERT ON ps_dbupdates FOR EACH ROW EXECUTE PROCEDURE single_dbupdate()
And my comment on statement:
=# COMMENT ON TRIGGER single_dbupdate_trigger ON ps_dbupdates IS $$ensure there is only one row in table ps_dbupdates$$;
fetch the oid of trigger:
=# select tgrelid, tgname, tgfoid from pg_trigger where tgname='single_dbupdate_trigger';
tgrelid | tgname | tgfoid
---------+-------------------------+--------
16689 | single_dbupdate_trigger | 16590
(1 row)
using obj_description(object_oid, catalog_name) to retrieve the comment:
=# select obj_description(16590,'pg_trigger');
obj_description
-----------------
(1 row)
and last thing, the PostgreSQL version:
$ psql --version
psql (PostgreSQL) 8.4.21