Andrew McMillan <andrew@catalyst.net.nz> writes:
> On Thu, 2004-01-08 at 14:05, Cath Lawrence wrote:
>> me,and yet this does seem to be relevant, because if I try it as
>> userpostgres, I get a different error:
>> pg_restore -O -d cbisdb SampleTableChange.tar
>> pg_restore: [archiver (db)] could not execute query: ERROR:
>> function"plpgsql_call_handler" already exists with same argument types
> Hi Cath,
> I see this all the time doing restores.
> I think there are some situations (on Debian, at least) where pl/pgsql
> gets added to the template1 database. Once that happens you will always
> have to do a "DROP LANGUAGE plpgsql CASCADE" after creating the database
> and before restoring your dump.
The correct way to avoid this issue is to create the database you are
about to restore into as a clone of template0, not template1.
$ createdb -T template0 cbisdb
$ pg_restore -O -d cbisdb SampleTableChange.tar
You can get away without this fine point only so long as you don't add
any site-local objects to template1. plpgsql is just the most common
example of a site-local object you might want to add there ...
regards, tom lane