Re: Usernames with hyphens

From: "Weilguni Mario" <mario(dot)weilguni(at)icomedias(dot)com>
To: "Devrim GUNDUZ" <devrim(at)gunduz(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Usernames with hyphens
Date: 2005-06-13 11:34:03
Message-ID: FA095C015271B64E99B197937712FD020E4B003B@freedom.grz.icomedias.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In fakt, it allows users with hyphens, but you have to use quotes:
CREATE USER "foo-bar";
DROP USER "foo-bar";

Regards,
Mario Weilguni

-----Ursprüngliche Nachricht-----
Von: pgsql-hackers-owner(at)postgresql(dot)org [mailto:pgsql-hackers-owner(at)postgresql(dot)org] Im Auftrag von Devrim GUNDUZ
Gesendet: Montag, 13. Juni 2005 13:31
An: pgsql-hackers(at)postgresql(dot)org
Betreff: [HACKERS] Usernames with hyphens

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

AFAIK, PostgreSQL does not allow hyphens in usernames and databases, right?

template1=# SELECT version();
version
- --------------------------------------------------------------------------------------------------------------
PostgreSQL 8.0.3 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC)
3.2.3 20030502 (Red Hat Linux 3.2.3-42)
(1 row)

template1=# CREATE DATABASE hyphen-test;
ERROR: syntax error at or near "-" at character 22 LINE 1: CREATE DATABASE hyphen-test;
^
This is the same for users;

template1=# CREATE USER hyphen-test;
ERROR: syntax error at or near "-" at character 18 LINE 1: CREATE USER hyphen-test;
^
However, createuser allows us to create users that include a hyphen:

# createuser hyphen-test -U postgres
Shall the new user be allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n
Password:
CREATE USER

but it is not allowed in CREATE DATABASE syntax:

template1=# CREATE DATABASE hyphen_test with owner hyphen-test;
ERROR: syntax error at or near "-" at character 46 LINE 1: CREATE DATABASE hyphen_test with owner hyphen-test;

template1=# SELECT * from pg_shadow WHERE usename='hyphen-test';
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd |
valuntil | useconfig
- -------------+----------+-------------+----------+-----------+--------+----------+-----------
hyphen-test | 103 | f | f | f | |
|
(1 row)

Is it a bug in createuser or am I missing a point? Same applies to
createdb:

# createdb hyphen-test -U postgres
Password:
CREATE DATABASE

Regards,

- --
Devrim GUNDUZ
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.tdmsoft.com.tr http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCrW5dtl86P3SPfQ4RAuF5AJ4xGGqswtNdzcLGi/lNCo8hD5PsYgCggllm
u5GYDj/JODlZ5HA+XYD79DM=
=pFsg
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2005-06-13 11:40:46 Re: Usernames with hyphens
Previous Message Devrim GUNDUZ 2005-06-13 11:30:36 Usernames with hyphens