Re: Mysterious empty database name? - Mailing list pgsql-general

From Tom Lane
Subject Re: Mysterious empty database name?
Date
Msg-id 674.1274827200@sss.pgh.pa.us
Whole thread Raw
In response to Mysterious empty database name?  (Azlin Rahim <azlin.rahim@gmail.com>)
Responses Re: Mysterious empty database name?  (Azlin Rahim <azlin.rahim@gmail.com>)
List pgsql-general
Azlin Rahim <azlin.rahim@gmail.com> writes:
> In our database list, there is one 'mysterious' database with a blank name.
> We don't know how it got there.

Your mail client has done you no favors as far as preserving the
formatting of the SELECT output, but it looks to me like the name of the
weird database is probably not blank but rather contains some control
characters (perhaps a carriage return?).  Depending on how old your psql
is, that could result in wacky formatting, which is what it looks like
you've got here.  Another theory is that it's an encoding problem:
non-ASCII database names are troublesome if you don't use the same
encoding in each database.

I'd suggest trying the SELECT under some other output format, perhaps
\pset format unaligned, to see if it gets any more readable.

Depending on what the name really is, you might be able to type it as a
double-quoted identifier, in which case ALTER DATABASE RENAME would
work to fix it.  If all else fails, you could try getting the OID
of the database and then
    UPDATE pg_database SET datname = 'something_sane' WHERE oid = nnn;
as superuser should fix it.  (If it's pre-8.1 PG, you might need another
ALTER DATABASE RENAME to be sure subsidiary files are updated.)

            regards, tom lane

pgsql-general by date:

Previous
From: Azlin Rahim
Date:
Subject: Mysterious empty database name?
Next
From: alvherre
Date:
Subject: Re: Mysterious empty database name?