Search Postgresql Archives

"Pg_restore -C" is not creating a database ( Was Create database bug in 8.1.3 ? )

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Listers, 
My saga contunues ;( 
I can not get pg_restore working as expected (as described in the documentation).

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).

BUT if I create DB testdb1 manually and then issue:
pg_restore  -Fc -d  testdb1 <  tdb1b.bak

I am getting the result what I want/expect.

What I am doinf wrong ?
Any hints, suggestions ? 

Best Regards, Milen 

-----Original Message-----
From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of William ZHANG
Sent: Sunday, April 09, 2006 2:37 PM
To: pgsql-general@xxxxxxxxxxxxxx
Subject: Re: [GENERAL] Create database bug in 8.1.3 ?


The backend doesnot save the name of the template database used by "CREATE DATABASE".

pg_dump, pg_dumpall have hard code like this:
    appendPQExpBuffer(buf, " WITH TEMPLATE = template0"); That's why you found the template database is always
`template0`.

If the backend saves the name of the template database, and dump the database as
    "CREATE DATABASE foo WITH TEMPLATE 'bar';",
dump and restore should be careful to dump/restore 'bar' before 'foo'. If 'bar' is modified after the "CREATE DATABASE"
command, things will be more complicated.

If you have not modified system catalogs in template1, using template0 in dump should cause no problem.

Regrads,
William ZHANG



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux