Thread: Scripting only the functions
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.
Is there a way?
Thanks
Kumar
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
Kumar, > 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. > > Is there a way? Currently, no. -- Josh Berkus Aglio Database Solutions San Francisco