Re: Can pg_restore produce create or replace commands - Mailing list pgsql-general

From Berend Tober
Subject Re: Can pg_restore produce create or replace commands
Date
Msg-id 54BAB36A.30108@computer.org
Whole thread Raw
In response to Re: Can pg_restore produce create or replace commands  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
Adrian Klaver wrote:
> On 01/17/2015 10:05 AM, Berend Tober wrote:
>> I often work with the output of pg_restore from a custom format dump
>> file...
>>
>> 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"...
>>
>> 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?
>
> Not that I know of. Though it should be noted that what you can do with
> CREATE OR REPLACE depends a good deal on what constitutes refactoring.
> ...
> "To replace the current definition of an existing function, use CREATE
> OR REPLACE FUNCTION. It is not possible to change the name or argument
> types...


Indeed. I have run into that occasionally. But currently and most often
it has not been much problem as the refactoring is generally internal to
the function behavior ... in fact most of them are trigger functions,
and since I have adopted a consistent naming convention there are
practically never function interface changes.

>
> My solution to this is using scripts for objects and keeping them under
> version control. Lately I have been using Sqitch(sqitch.org/). There is
> a learning curve, but I am finding it useful.

Oh sqitch is (looks to be) awesome and I wish so much to employ it, but
I have not had success it getting it installed. I do use Wheeler's
companion tool pgtap, and THAT is totally awesome as well and is making
life SO much better. I cannot envision ever again doing data base
development without it!

I just wonder how PgAdmin creates the scripts, then. Is that a feature
specific to the PgAdmin application then rather than the underlying
system and tools?



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Can pg_restore produce create or replace commands
Next
From: Adrian Klaver
Date:
Subject: Re: Can pg_restore produce create or replace commands