Re: Scripting function definitions as SQL?

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "Reece Hart" <reece(at)harts(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Scripting function definitions as SQL?
Date: 2008-05-12 07:08:38
Message-ID: 65937bea0805120008y6da21870w7c0e67192c33faf2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 12, 2008 at 10:57 AM, Reece Hart <reece(at)harts(dot)net> wrote:

> On Sun, 2008-05-11 at 06:12 -0700, Postgres User wrote:
> > Has anyone written a function that scripts out all the functions in a
> > database as full SQL statements (Create Function.....)
>
> You could pg_dump the schema in the "custom" format (-Fc), then call
> pg_restore with -l to get the TOC, grep the TOC for functions, and feed
> that back into pg_restore with -L. It sounds like a lot, but it's pretty
> easy in practice, like so:
>
> $ sudo -u postgres pg_dump -Fc -s mydb >mydb.pgdfc
> $ pg_restore -l mydb.pgdfc >mydb.toc
> $ grep -E '^[0-9]+; [0-9]+ [0-9]+ FUNCTION' mydb.toc >mydb-fx.toc
> $ pg_restore -L mydb-fx.toc mydb.pgdfc
>
> The output of pg_restore is sql.
>
> This technique is extremely useful for other kinds of schema elements as
> well.
>
>
It's a bit too much for the task at hand. Recently I was also faced with a
situation where I wanted to dump a few functions (only), but pg_dump does
not have any option to do so!!

Can we have an option to dump function?

Best regards,

--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2008-05-12 09:12:07 Re: Returning RECORD from PGSQL without custom type?
Previous Message Reece Hart 2008-05-12 05:27:51 Re: Scripting function definitions as SQL?