Re: "Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? ) - Mailing list pgsql-general

From Milen Kulev
Subject Re: "Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? )
Date
Msg-id 000c01c65c01$9d5fecf0$0a00a8c0@trivadis.com
Whole thread Raw
In response to Re: "Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? )  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: "Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? )
List pgsql-general
Hello Tom,
I am  getting the commands you mention:
 pg_restore  -C -Fc tdb1b.bak  1> OUT
 Less OUT:

CREATE DATABASE testdb1 WITH TEMPLATE = template0 ENCODING = 'UTF8' TABLESPACE = tbs1;
ALTER DATABASE testdb1 OWNER TO pg;
\connect testdb1
...

, but testdb1  is NOT created ! That is actually my problem.
According to the documentation, the DB should be created (-C  option).
If I pre-create the database and then issue "pg_restore  -C -Fc tdb1b.bak" all objects
get created as expected.

I am seeing some "DROP DATABASE" commend in the tdb1b.bak file (binary format)

pg@node5#[server1] /tmp]$ strings  tdb1b.bak | less
PGDMP
testdb1
8.1.3
8.1.3
ENCODING
ENCODING
SET client_encoding = 'UTF8';
false
1262
41411
testdb1
DATABASE
CREATE DATABASE testdb1 WITH TEMPLATE = template0 ENCODING = 'UTF8' TABLESPACE = tbs1;
DROP DATABASE testdb1;  <--!!!!!!!
false
2615
2200
public
SCHEMA
CREATE SCHEMA public;
DROP SCHEMA public;



Regards. Milen


-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Tom Lane
Sent: Sunday, April 09, 2006 6:01 PM
To: Milen Kulev
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] "Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? )


"Milen Kulev" <makulev@gmx.net> writes:
> My case : I have a DB, that I  have archived with
> pg_dump -C -Fc  -d   testdb1 > tdb1b.bak
> Then I am dropping the database testdb1 ( with DROP DATABASE testdb1;
> ) I want to recover it. When I issue the following
> command:
> pg_restore  -C -Fc tdb1b.bak
> I am getting all the SQL statements executed, but the DB testdb1 is NOT created, although
> I have explicitely specified it (-C option).

Works AFAICS --- I see this in pg_restore's output:

    CREATE DATABASE testdb1 WITH TEMPLATE = template0 ENCODING = 'UTF8';

    ALTER DATABASE testdb1 OWNER TO postgres;

    \connect testdb1

Are you not getting those commands?  Maybe they are failing for some reason?

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster


pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Is difference between PostgreSQL and mySQL licences for client application minor only
Next
From: Tom Lane
Date:
Subject: Re: "Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? )