Re: Dump only functions

From: Vasilis Ventirozos <v(dot)ventirozos(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Dump only functions
Date: 2013-03-28 15:57:54
Message-ID: CAF8jcqr1fuB3MUbpePmGQaJs9NakHpaKEVtnBtb6LCmwSbaUzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

something like this would probably work too

for a in `echo "SELECT p.proname
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE pg_catalog.pg_function_is_visible(p.oid)
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'"|psql -A -t test`;
do echo "SELECT pg_get_functiondef('$a'::regproc);"|psql -A -t test
>$a.function.sql ;done

On Thu, Mar 28, 2013 at 5:29 PM, Keith Ouellette <Keith(dot)Ouellette(at)airgas(dot)com
> wrote:

> Thank you. I tried pg_extractor and it work almost perfect. I have just
> one question. We do overloading of a function name (using different
> parameters) and I think it puts all overlaoded functions in the same file
> (those with the same file name that is). Is there a way to separate them?
>
>
>
> Thanks again for everyones help.
>
>
>
>
> ------------------------------
> *From:* Scott Mead [scottm(at)openscg(dot)com]
> *Sent:* Wednesday, March 27, 2013 1:49 PM
> *To:* Raghavendra
> *Cc:* Keith Ouellette; pgsql-admin(at)postgresql(dot)org
> *Subject:* Re: [ADMIN] Dump only functions
>
> On Wed, Mar 27, 2013 at 1:43 PM, Raghavendra <
> raghavendra(dot)rao(at)enterprisedb(dot)com> wrote:
>
>> On Wed, Mar 27, 2013 at 10:53 PM, Keith Ouellette <
>> Keith(dot)Ouellette(at)airgas(dot)com> wrote:
>>
>>> Is there a way to dump only functions to a directory with each
>>> function as its own file in SQL format?
>>>
>> AFAIK, there's no direct way to dump each function to a separate file.
>> However, you can use system-defined function or system table to retrieve
>> function structure and then write them to separate file each by using bash
>> or perl scripting.
>>
>> select prosrc from pg_proc where proname='foo';
>> or
>> select pg_get_functiondef('foo(integer)'::regprocedure::oid);
>> or
>> Use other sources like pg_extractor tools.
>> http://www.keithf4.com/pg_extractor/
>>
>
> +1 here. pg_extractor is my personal favorite for this type of thing.
> It can give you all of your objects as separate files if you'd like.
>
> --Scott
>
>
>>
>> ---
>> Regards,
>> Raghavendra
>> EnterpriseDB Corporation
>> Blog: http://raghavt.blogspot.com/
>>
>>
>>
>>>
>>>
>>> Thanks,
>>>
>>> Keith
>>>
>>>
>>>
>>
>>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Grittner 2013-03-28 16:32:09 Re: VACUUM ANALYZE AND ANALYZE ISSUE
Previous Message Keith Ouellette 2013-03-28 15:29:53 Re: Dump only functions