Re: import sql dump with psql - language creation throws error - Mailing list pgsql-general

From Adrian Klaver
Subject Re: import sql dump with psql - language creation throws error
Date
Msg-id 200901200718.08898.aklaver@comcast.net
Whole thread Raw
In response to Re: import sql dump with psql - language creation throws error  (Andreas Wenk <a.wenk@netzmeister-st-pauli.de>)
Responses Re: import sql dump with psql - language creation throws error
List pgsql-general
On Tuesday 20 January 2009 7:05:23 am Andreas Wenk wrote:

> Adrian,
>
> no lack of coffee but my fault. You are totally right - that was a copy and
> paste error. For sure the dump is *.sql.
>
> Until now there is no onboard solution for this issue. Means, the import of
> the dump is working correct but a "message" is thrown: FEHLER:  Sprache
> »plpgsql« existiert bereits (means ERROR: Language »plpgsql« allready
> exists). What I do now - and this is not really beautiful - is to erase
> that "message" before oputput is created from the shell script:
>
> psql -o /dev/null $DB < /var/lib/postgresql/scripts/$SQL_DUMP  2>&1 | grep
> -v "FEHLER: Sprache »plpgsql« existiert bereits"
> exit 0
>
> Now, no output from the script is catched by the crondaemon and no email is
> sent. On the other hand, no error from the above line is catched at all ...
> unfortunately ...
>
> By the way - language plpgsql was created with createlang plpgsql
> template1. And because of tsearch2 it's not possible to create the db from
> template0.
>
> Got another idea?
>
> Cheers
>
> Andy


Just to point you to Grzegorz's suggestion of using the  -c switch in the
pg_dump command. To quote the manual:

-c
"Output commands to clean (drop) database objects prior to (the commands for)
creating them.

 This option is only meaningful for the plain-text format. For the archive
formats, you can specify the option when you call pg_restore. "

Also I am not sure cron sending the email is a bad thing. Serves as indicator
that the process ran.

--
Adrian Klaver
aklaver@comcast.net

pgsql-general by date:

Previous
From: Andreas Wenk
Date:
Subject: Re: import sql dump with psql - language creation throws error
Next
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: left join with smaller table or index on (XXX is not null) to avoid upsert