Thread: viewing user defined functions

viewing user defined functions

From
dearsoandso@gmail.com
Date:
Hi,

I'm trying to get a look at a user defined function that's being run on a server.  pg_top -E tells me it's encountering a syntax error and I'd like to get a look at the function as it is running on the server.  I have access to the SQL source but there are several version and I don't know which one is running now.

How do I go about viewing a user defined function on postgres 8.3?

Any help is appreciated,

robin


Re: viewing user defined functions

From
Joshua Tolley
Date:
On Sat, Aug 08, 2009 at 12:34:03PM -0400, dearsoandso@gmail.com wrote:
>    Hi,
>
>    I'm trying to get a look at a user defined function that's being run on a
>    server.  pg_top -E tells me it's encountering a syntax error and I'd like
>    to get a look at the function as it is running on the server.  I have
>    access to the SQL source but there are several version and I don't know
>    which one is running now.
>
>    How do I go about viewing a user defined function on postgres 8.3?
>
>    Any help is appreciated,
>
>    robin

Within psql, you can use the \df+ command to get function source.
Alternatively, look in the pg_proc table and the prosrc column.

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

Attachment

Re: viewing user defined functions

From
Andreas Kretschmer
Date:
dearsoandso@gmail.com <dearsoandso@gmail.com> wrote:

> Hi,
>
> I'm trying to get a look at a user defined function that's being run on a
> server.  pg_top -E tells me it's encountering a syntax error and I'd like to
> get a look at the function as it is running on the server.  I have access to
> the SQL source but there are several version and I don't know which one is
> running now.
>
> How do I go about viewing a user defined function on postgres 8.3?

All informations about such functions are stored in the system-table
pg_proc. To view the source, for instance, do a

select prosrc from pg_proc where proname='insert the function-name';

There are more columns contains information, for instance the arguments,
return-type an so on, read more:

http://www.postgresql.org/docs/8.3/interactive/catalog-pg-proc.html


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°