Thread: 7.2 Upgrade problems: Cannot restore from pg_dumpall

7.2 Upgrade problems: Cannot restore from pg_dumpall

From
Chris Lee
Date:
Hi,

I following INSTALL instruction, however I got error on Step 4.
I issue the follow command:
$ su - postgres
$ /usr/local/pgsql/bin/psql -d template1 -f /tmp/pg_dump.bak

Error message:

CREATE DATABASE
psql:/tmp/pg_dump.bak:473: \connect: FATAL 1:  Database "chinese" does not
exist in the system catalog.
copying template1 to template0... ok

Here is the content of pg_dump.bak

471 \connect template1 postgres
472 CREATE DATABASE "Chinese" WITH TEMPLATE = template0 ENCODING = 'EUC_TW';
473 \connect Chinese postgres

Any Hints?

Regards,
Chris Lee

Re: 7.2 Upgrade problems: Cannot restore from pg_dumpall

From
Jeff Davis
Date:
> CREATE DATABASE
> psql:/tmp/pg_dump.bak:473: \connect: FATAL 1:  Database "chinese" does not
> exist in the system catalog.
> copying template1 to template0... ok
>
> Here is the content of pg_dump.bak
>
> 471 \connect template1 postgres
> 472 CREATE DATABASE "Chinese" WITH TEMPLATE = template0 ENCODING =
> 'EUC_TW'; 473 \connect Chinese postgres

It looks like you're running into a problem with case sensitivity. I guess it
might also be a problem with pg_dump, since you used it directly. I think the
solution is to use quotation marks around the word "Chinese" in the connect
statement.
\connect Chinese postgres => \connect "Chinese" postgres

Hope it helps. I wonder what's up with pg_dump though... It seems like a bad
idea to use any capital letters for any identifiers in postgresql because
postgresql handles them so awkwardly.

Regards,
    Jeff

Re: 7.2 Upgrade problems: Cannot restore from pg_dumpall

From
Tom Lane
Date:
Chris Lee <Chrislee@centurycity.com.hk> writes:
> Here is the content of pg_dump.bak

> 471 \connect template1 postgres
> 472 CREATE DATABASE "Chinese" WITH TEMPLATE = template0 ENCODING = 'EUC_TW';
> 473 \connect Chinese postgres

> Any Hints?

That last line needs to be

\connect "Chinese" postgres

This appears to be a bug in pg_dumpall --- it should quote the database
name to avoid case-folding.  If you can hand-edit the dump script to
fix it, you should be okay.

            regards, tom lane