Re: How to get triggeroid by triggername in postgres 8.0

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rafaqat Ali <smoken0(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to get triggeroid by triggername in postgres 8.0
Date: 2005-04-18 15:18:10
Message-ID: 21979.1113837490@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rafaqat Ali <smoken0(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Fuhr 2005-04-18 15:19:19 Re: Call to build-in operator from new operator
Previous Message Bruce Momjian 2005-04-18 15:13:15 Win32 presentation