Обсуждение: How to get triggeroid by triggername in postgres 8.0

Поиск
Список
Период
Сортировка

How to get triggeroid by triggername in postgres 8.0

От
Rafaqat Ali
Дата:
Hello All      Can any one tell me how can I get triggerOid from triggerName
in c code. I first tried to use SearchSysCache Function but it does
not search o the basis of triggername.


Re: How to get triggeroid by triggername in postgres 8.0

От
Tom Lane
Дата:
Rafaqat Ali <smoken0@gmail.com> writes:
>        Can any one tell me how can I get triggerOid from triggerName
> in c code. I first tried to use SearchSysCache Function but it does
> not search o the basis of triggername.

Posting the same question three times on two different lists doesn't
endear you to anyone.

Anyway: you can't get the OID from triggername alone, because that's
not unique.  You need also the OID of the table the trigger is on.
There is not currently a syscache for this, probably because no such
lookup is needed in any heavily used code paths (we tend to rely on
the trigger lists stored in relcache entries, instead).  So there are
two ways to get the info about a particular trigger. One is a search of
the physical pg_trigger table --- see DropTrigger for one example.  The
other way is to open the relation cache entry (eg, with heap_open) and
look through its TriggerDesc array.  In many situations you'll already
have access to the Relation entry and so the second way is clearly a win.
        regards, tom lane