BUG #7587: createdb allows invalid DB names

Started by Nonameover 13 years ago2 messagesbugs
Jump to latest
#1Noname
foss@johnbradshaw.org

The following bug has been logged on the website:

Bug reference: 7587
Logged by: John Bradshaw
Email address: foss@johnbradshaw.org
PostgreSQL version: 9.1.6
Operating system: Ubuntu 12.04 LTS
Description:

createdb allows illegal period/dot (".") in DB names. Can't ALTER DATABASE
name in psql as it doesn't allow periods/dots in database names. Had to
dropdb (which also allows dot in names) and recreate from dump.

Would be nice if createdb checked for illegal characters in DB names.

postgres@dev2:~$ psql -V
psql (PostgreSQL) 9.1.6
contains support for command-line editing

postgres@dev2:~$ sudo dpkg -l postgresql-9.1
Desired=Unknown/Install/Remove/Purge/Hold
|
Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version
Description
+++-===============================================-===============================================-==============================================================================================================
ii postgresql-9.1 9.1.6-0ubuntu12.04
object-relational SQL database, version 9.1 server

postgres@dev2:~$ createdb badname.sql

postgres@dev2:~$ psql badname.sql
psql (9.1.6)
Type "help" for help.

badname.sql=# alter DATABASE badname.sql RENAME TO to goodname;
ERROR: syntax error at or near "."
LINE 1: alter DATABASE badname.sql RENAME TO to goodname;
^
badname.sql=# \q

postgres@dev2:~$ dropdb badname.sql

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: BUG #7587: createdb allows invalid DB names

foss@johnbradshaw.org writes:

createdb allows illegal period/dot (".") in DB names. Can't ALTER DATABASE
name in psql as it doesn't allow periods/dots in database names. Had to
dropdb (which also allows dot in names) and recreate from dump.

This isn't a bug --- those utilities treat whatever's given on the
command line as being double-quoted. Their documentation fails to
say this though :-(

regards, tom lane