Function already exists with same argument types

Started by gipsy-king1almost 14 years ago2 messagesgeneral
Jump to latest
#1gipsy-king1
stuehle@gis-consult.de

Dear all

I want to import a postGIS-DB backup-file.

When I execute this command:
*pg_restore -i -h localhost -p 5432 -U postgres -d THS -v
"<path>/alkis.backup" > "<path2>\output.txt" 2>&1*

I get an textfile with all outputs. There are lots of ERRORs like this:

*pg_restore: erstelle FUNCTION st_geometry_analyze(internal)
pg_restore: [Archivierer (DB)] Fehler in Inhaltsverzeichniseintrag 33; 1255
121878509 FUNCTION st_geometry_analyze(internal) postgres
pg_restore: [Archivierer (DB)] could not execute query: ERROR: function
"st_geometry_analyze" already exists with same argument types
Command was: CREATE FUNCTION st_geometry_analyze(internal) RETURNS
boolean
AS '$libdir/liblwgeom', 'LWGEOM_analyze'
LANGUAGE c ST...*

/I heard that the restore-command will apply all functions a second time. Is
there a possibility to disable this inside the pg_restore-command?
I don't want to delete all function by hand inside the pdAdmin before I'll
execute the pg_restore-command./

best regards,
Thomas

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Function-already-exists-with-same-argument-types-tp5712191.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#2Craig Ringer
craig@2ndquadrant.com
In reply to: gipsy-king1 (#1)
Re: Function already exists with same argument types

On 06/12/2012 09:01 PM, gipsy-king1 wrote:

Dear all

I want to import a postGIS-DB backup-file.

When I execute this command:
*pg_restore -i -h localhost -p 5432 -U postgres -d THS -v
"<path>/alkis.backup" > "<path2>\output.txt" 2>&1*

I get an textfile with all outputs. There are lots of ERRORs like this:

When you create the database to restore to, create it from template0.

postgres# CREATE DATABASE "THS" WITH TEMPLATE template0;

... adding any LOCALE, ENCODING, OWNER, etc directives you need too.

That'll ensure you're stating with an empty target to restore to.

Alternately, you can use pg_restore with the -C option to tell it to
make a new database to restore to. It'll create a new DB with the same
name as the one you dumped, and restore to it. Strangely, you must tell
pg_restore to connect to a different database in order to create a
database, eg:

pg_restore -C --dbname postgres -U postgres -h localhost -p 5432 -i
-v <path>/alkis.backup

will restore to a NEW database (not to the postgres database) created
with the same name as the db that was dumped had. Note, however, that
this WILL NOT WORK if you're restoring a dump made on Linux to a Windows
box or vice versa due to a limitation/bug in how PostgreSQL and
pg_restore handle locales and encodings. You must use the CREATE
DATABASE followed by separate pg_restore method in that case.

--
Craig Ringer