Re: How to get triggeroid by triggername in postgres 8.0 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: How to get triggeroid by triggername in postgres 8.0
Date
Msg-id 21979.1113837490@sss.pgh.pa.us
Whole thread Raw
In response to How to get triggeroid by triggername in postgres 8.0  (Rafaqat Ali <smoken0@gmail.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Win32 presentation
Next
From: Michael Fuhr
Date:
Subject: Re: Call to build-in operator from new operator