| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | "Kumar" <sgnerd(at)yahoo(dot)com(dot)sg>, "psql" <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: Scripting only the functions |
| Date: | 2003-10-20 17:23:14 |
| Message-ID: | 200310201823.14910.dev@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Monday 20 October 2003 14:04, Kumar wrote:
> Dear Friends,
>
> I am working with Postgres 7.3.4 on RH Linux server 7.2.
>
> Using pg_dump I could manage to take a script for all the DB objects. But
> wanted to take the script (DDL) for all the scripts in my database. While I
> searched I dont find any options in the pg_dump except for script tables
> only.
That'll be because there isn't one (as far as I know).
You could pipe the output of your pg_dump schema through a small perl script
something like:
#!/usr/bin/perl -w
use strict;
my ($line, $in_func);
while ($line = <>) {
if ($line =~ /^CREATE.+FUNCTION/) { $in_func = 1; }
if ($in_func) { print $line; }
if ($line =~ /^\s+LANGUAGE\s+\w+;$/) {
$in_func = 0;
print "\n";
}
}
That should do it, although it will fail if you have a line in your function
starting with "LANGUAGE" (doesn't seem likely to me).
The other options you could use are:
1. To write your own function-dumping script (use psql -E then \df+ to see how
to get the function source).
2. Use pgadmin if there aren't too many functions to process, and do it by
hand.
--
Richard Huxton
Archonet Ltd
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joe Conway | 2003-10-20 17:24:19 | Re: Which is faster SQL or PL/PGSQL |
| Previous Message | Josh Berkus | 2003-10-20 17:21:41 | Re: Scripting only the functions |