From: | Oisin Glynn <me(at)oisinglynn(dot)com> |
---|---|
To: | Oisin Glynn <me(at)oisinglynn(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: pg_proc Question |
Date: | 2006-11-02 15:40:09 |
Message-ID: | 454A1159.6090700@oisinglynn.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Martijn van Oosterhout wrote:
> On Thu, Nov 02, 2006 at 09:57:28AM -0500, Oisin Glynn wrote:
>
>> I have named all my functions in a pretty unique way and would like to
>> export just my functions. Is there any way to move just these functions
>> from one db to another.has anyone got a clever piece of SQL that spits
>> out ddl from a select on pg_proc? Or could I use the copy command on
>> pg_proc to spit my functions to file and then copy them into the new db?
>> My issue is that I have allot of dblink and other things I do not want
>> or need in the db and do not want to propagate this any further.
>>
>
> I would say the easiest is to use pg_dump and then filter the output.
> It's simple enough for sed I think:
>
> pg_dump database | sed -ne '/^CREATE FUNCTION tag/,/^--/p'
>
> works well here... Replace tag with a pattern matching your functions.
> If you're using pl/pgsql you may need to do something more clever with
> the end marker...
>
> Have a nice day,
>
Thanks for the help. After a quick intro to sed (I'm a Windows user) I
have this working a treat for me. I used the following slight mod and
it seems to handle both sql and pl/pgsql on 8.1.4
pg_dump database | sed -ne '/^CREATE FUNCTION tag/,/^-- TOC entry/p'
The "-- TOC entry" seems to act as a perfect end tag. I actually dumped
the db as plain from pgAdmin and used this file as input to sed rather
than piping the pg_dump into sed.
The only difference was that I needed double quotes not single quotes in
my sed command so command ended up like
sed -ne "/^CREATE FUNCTION tag/,/^-- TOC entry/p" mybackupfile.backup
>myfunctions.sql
Thanks,
Oisin
From | Date | Subject | |
---|---|---|---|
Next Message | Sandeep Kumar Jakkaraju | 2006-11-02 15:41:58 | Re: PostGIS |
Previous Message | Markus Schiltknecht | 2006-11-02 15:21:52 | lots of values for IN() clause |