Обсуждение: retrieving a function?

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

retrieving a function?

От
Cindy
Дата:
Hi, all.  I'm trying to recreate a function in one database to put
into another.

Text=# select * from pg_proc where proname = 'get_citation';

   proname    | proowner | prolang | proisinh | proistrusted |   proiscachable | pronargs | proretset | prorettype |
proargtypes| probyte_pct | properbyte_cpu | propercall_cpu |   prooutin_ratio |           prosrc
         | probin 
--------------+----------+---------+----------+--------------+---------------+-

---------+-----------+------------+-------------+-------------+----------------+----------------+----------------+--------------------------------------------------------------------------+--------
 get_citation |     3899 |      14 | f        | t            | f   |        3 | t         |1043 |    21 21 23 |
100|              0 |              0 |   100 | select citation from citations where aid= $1 and wid= $2 and byteloc=$3
|- 


But I'm not quite sure how to make use of this info.  It looks like
there are three arguments, but I don't know what their names or types
are.  When I look up the create function in the online reference
manual, there's no examples showing the use of the $1 and $2.  I'm not
even entirely certain of what this function returns.

I thought of trying to dump the function so as to have it from that,
but there doesn't seem to be a utility to just dump functions.  It
sounded from the documentation on dump_pg that if one dumped a table,
all the related functions would be dumped too, so I dumped citations
but did not get the functions.  I'm reluctant to dump the entire db
Text because it's way too big (citations.dump alone is 300M).

Surely there's an easier way to reconstruct this function?

Thanks,
--Cindy
--
ctmoore@uci.edu

Re: retrieving a function?

От
Tom Lane
Дата:
Cindy <ctmoore@uci.edu> writes:
> I'm reluctant to dump the entire db
> Text because it's way too big (citations.dump alone is 300M).

> Surely there's an easier way to reconstruct this function?

pg_dump -s (schema only) will get you the function definitions with
only a reasonable amount of other stuff.

            regards, tom lane

Re: retrieving a function?

От
Cindy
Дата:
Tom Lane writes:
 >Cindy <ctmoore@uci.edu> writes:
 >> I'm reluctant to dump the entire db
 >> Text because it's way too big (citations.dump alone is 300M).
 >
 >> Surely there's an easier way to reconstruct this function?
 >
 >pg_dump -s (schema only) will get you the function definitions with
 >only a reasonable amount of other stuff.

This worked beautifully.  Thanks!

--Cindy, who is almost there with the su -c on autostarting postmaster