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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Devrim GUNDUZ
Gesendet: Montag, 13. Juni 2005 13:31
An: pgsql-hackers@postgresql.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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to