Thread: pg_get_procdef ?

pg_get_procdef ?

From
"Marc Mamin"
Date:
Hello,

I want to export a list of procedure definitions, which seems to be a
hard nut to crack :-(
A solution could be to use a combination of pg_dump and pg_restore, but
this also  requires some time investment.
It would be fine, if pg_dump could be more selective about the object to
select...

Does anyone have a handmade solution for a pg_get_procdef function.

I'm still on Postgres 8.3 ...

Thanks for any help,

Marc Mamin

Re: pg_get_procdef ?

From
hubert depesz lubaczewski
Date:
On Wed, Oct 27, 2010 at 11:21:43AM +0200, Marc Mamin wrote:
> Hello,
>
> I want to export a list of procedure definitions, which seems to be a
> hard nut to crack :-(
> A solution could be to use a combination of pg_dump and pg_restore, but
> this also  requires some time investment.
> It would be fine, if pg_dump could be more selective about the object to
> select...
>
> Does anyone have a handmade solution for a pg_get_procdef function.
>
> I'm still on Postgres 8.3 ...

pg_dump -Fc -s + pg_restore -l | grep + pg_restore -L will be fast.

if that's not good enough for you, do:
psql -E
\df+ function

and check the queries. getting function definition from there should be
simple.

Best regards,

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

Re: pg_get_procdef ?

From
Dimitri Fontaine
Date:
hubert depesz lubaczewski <depesz@depesz.com> writes:
> and check the queries. getting function definition from there should be
> simple.

Check getddl to see how much simple it is:

  https://labs.omniti.com/labs/pgtreats/wiki/getddl
  http://pgsql.tapoueh.org/getddl/
  http://pgsql.tapoueh.org/getddl/sql/function.body.sql

The Omiti version will output a single file with the objects in there,
the other version will split the objects each in its own file in
directories, to be svn / git friendly.

With the python version:
  ./getddl.py -f -F fun_dir -d db -h host -p port -U user

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support