vacuumdb has a fatal after database rename

Started by huangover 9 years ago3 messagesbugs
Jump to latest
#1huang
foggyglass@163.com

Hi friends,

If I rename the database postgres before vacuumdb , the vacuumdb say
FATAL: database "postgres" does not exist.

[postgres@vdedu1 ~]$ vacuumdb -a
vacuumdb: vacuuming database "mydb"
vacuumdb: vacuuming database "postgres"
vacuumdb: vacuuming database "template1"
[postgres@vdedu1 ~]$ psql -c"alter database postgres rename to postgresql;"
ERROR: current database cannot be renamed
STATEMENT: alter database postgres rename to postgresql;
ERROR: current database cannot be renamed
[postgres@vdedu1 ~]$ psql
psql (9.5.4)
Type "help" for help.

postgres=# alter database postgres rename to postgresql;
ERROR:  current database cannot be renamed
STATEMENT:  alter database postgres rename to postgresql;
ERROR:  current database cannot be renamed
postgres=# \q
[postgres@vdedu1 ~]$ psql -d template1 -c"alter database postgres rename 
to postgresql;"
ALTER DATABASE
[postgres@vdedu1 ~]$ psql -l
FATAL:  database "postgres" does not exist
psql: FATAL:  database "postgres" does not exist
[postgres@vdedu1 ~]$ psql -l -d template1
                                   List of databases
     Name    |  Owner   | Encoding |   Collate   |    Ctype    | Access 
privile
ges
------------+----------+----------+-------------+-------------+-----------------
------
  mydb       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  postgresql | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  template0  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
=c/postgres
      +
             |          |          |             |             | 
postgres=CTc/pos
tgres
  template1  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
=c/postgres
      +
             |          |          |             |             | 
postgres=CTc/pos
tgres
(4 rows)

[postgres@vdedu1 ~]$ vacuumdb -a
FATAL: database "postgres" does not exist
vacuumdb: vacuuming database "mydb"
vacuumdb: vacuuming database "postgresql"
vacuumdb: vacuuming database "template1"
[postgres@vdedu1 ~]$

2016-09-28
TT

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

In reply to: huang (#1)
Re: vacuumdb has a fatal after database rename

On Wed, Sep 28, 2016 at 09:54:41PM +0800, huang wrote:

If I rename the database postgres before vacuumdb , the vacuumdb say
FATAL: database "postgres" does not exist.

So don't rename it. It's being used because you are running vacuumdb
using postgres shell account.

You could try something like:

PGDATABASE=template1 vacuumdb -az

but generally speaking it is not advised to rename postgres db.

Best regards,

depesz

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#3huang
foggyglass@163.com
In reply to: hubert depesz lubaczewski (#2)
Re: vacuumdb has a fatal after database rename

I am sorry .
we want to hide the database postgres for the security concern .
However I found this message in log .
I think there are some problem in vacuumdb .
But now I see this is my mistake .

Best regards,
TT

At 2016-09-29 01:29:37, "hubert depesz lubaczewski" <depesz@depesz.com> wrote:

Show quoted text

On Wed, Sep 28, 2016 at 09:54:41PM +0800, huang wrote:

If I rename the database postgres before vacuumdb , the vacuumdb say
FATAL: database "postgres" does not exist.

So don't rename it. It's being used because you are running vacuumdb
using postgres shell account.

You could try something like:

PGDATABASE=template1 vacuumdb -az

but generally speaking it is not advised to rename postgres db.

Best regards,

depesz