Re: Mysterious empty database name?

From: alvherre <alvherre(at)commandprompt(dot)com>
To: Azlin Rahim <azlin(dot)rahim(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Mysterious empty database name?
Date: 2010-05-25 22:41:59
Message-ID: 1274826647-sup-4888@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Excerpts from Azlin Rahim's message of mar may 25 18:23:13 -0400 2010:
> In our database list, there is one 'mysterious' database with a blank name.
> We don't know how it got there.

Maybe somebody SQL-injected you and created it.

> Below is the output of pg_database. Does anyone have any idea why this is
> happening? Any way to remove the 'mysterious' database safely.

I'd investigate a bit more what's inside, before deleting it. Maybe the
name has only whitespace or control chars. You can use double quotes to
refer to such names. For example, this is a name a space and a
backspace:

=# create database " ^?";
CREATE DATABASE

You can see the ASCII chars that make up the name with something like this:

=# select datname, ascii(substring(datname, generate_series(1, length(datname)), 1)) from pg_database;

\x7F | 32
\x7F | 127

Now if somebody messed with an Unicode control char, I don't know what
to tell you.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc Munro 2010-05-25 22:49:31 Re: Hiding data in postgresql
Previous Message Tom Lane 2010-05-25 22:40:00 Re: Mysterious empty database name?