Can pg_restore produce create or replace commands

From: Berend Tober <btober(at)broadstripe(dot)net>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Can pg_restore produce create or replace commands
Date: 2015-01-17 18:05:37
Message-ID: 54BAA471.1020409@computer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I often work with the output of pg_restore from a custom format dump
file. For example a file produced by running

pg_restore -s -1 -L listfile dumpfile

where listfile has been edited to comment out most of the rows to leave
only the data base objects I'm currently interested in.

Most often, I'm refactoring functions and so don't really want to drop
the function but rather want to do a "create or replace function"
operation to implement the changes. Consequently I have to frequently do
a global search and replace along the lines of

sed -ie 's/CREATE FUNCTION/CREATE OR REPLACE FUNCTION/'

I am not seeing in the documentation an option to generate the script
with anything but straight "create function" commands.

Is there a way for me to access this functionality (i.e., to generate
"create or replace function" scripts) from the command line?

I suppose I could pipe the pg_restore output through the sed command
just as a matter of standard operating procedure, but the capability
must exist because that is the way the scripts appear in pgadmin. I
generally do not use the GUI tool and so would like it to happen
automatically when using the command line tools.

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-01-17 18:55:16 Re: Can pg_restore produce create or replace commands
Previous Message Kouhei Sutou 2015-01-17 14:18:38 WAL supported extension