Re: Function exists

From: Marko Kreen <marko(at)l-t(dot)ee>
To: Mihai Gheorghiu <tanethq(at)earthlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Function exists
Date: 2001-09-25 18:59:01
Message-ID: 20010925205901.A1406@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 25, 2001 at 02:20:23PM -0400, Mihai Gheorghiu wrote:
> I want to write a function that finds out whether a function already exists.
> Is that possible? How?

select * from pg_proc where proname = ??;

you can run psql with switch -E, then it shows intenal queries
it performs. Eg., for \df - 'show functions' it does:

$ psql -E
marko=# \df
********* QUERY *********
SELECT format_type(p.prorettype, NULL) as "Result", p.proname as
"Function",
oidvectortypes(p.proargtypes) as "Arguments"
FROM pg_proc p
WHERE p.prorettype <> 0 and (pronargs = 0 or
oidvectortypes(p.proargtypes) <> '')
ORDER BY "Function", "Result", "Arguments"
*************************

from there you can hack further.

--
marko

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tony Reina 2001-09-25 18:59:20 Re: [HACKERS] not on .hackers
Previous Message Mihai Gheorghiu 2001-09-25 18:20:23 Function exists