Skip site navigation (1) Skip section navigation (2)

createuser/dropuser username

From: Grzegorz Szpetkowski <gszpetkowski(at)gmail(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: createuser/dropuser username
Date: 2011-05-04 16:05:39
Message-ID: BANLkTik=8Mi4L9n=8=P0ez4Xen4YuGX8vw@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-docs
Hi,

I think that createuser/drouser reference documentation could be
enhanced for username param. There is:

"createuser is a wrapper around the SQL command CREATE ROLE. There is
no effective difference between creating users via this utility and
via other methods for accessing the server."

http://www.postgresql.org/docs/9.0/static/app-createuser.html
http://www.postgresql.org/docs/9.0/static/app-dropuser.html

But createuser and dropuser wrappers in some cases are doing implicit
quoting (when CREATE ROLE is not), which I think is not fully known
and is undocumented here. For example:

createuser -SDRe user -- reserved in PostgreSQL
CREATE ROLE "user" NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;

createuser -SDRe myuser
CREATE ROLE myuser NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;

createuser -SDRe MYuser
CREATE ROLE "MYuser" NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;

psql postgres
ALTER ROLE MYuser CREATEDB; -- fatal mistake, it works for myuser
delimited identifier
ALTER ROLE

ALTER ROLE "MYuser" CREATEDB; -- ok, quoted identifier
ALTER ROLE

ALTER ROLE user CREATEDB;
ERROR:  syntax error at or near "user"
LINE 1: ALTER ROLE user CREATEDB;
                   ^
postgres=# ALTER ROLE "user" CREATEDB;
ALTER ROLE

Regards,
Grzegorz Szpetkowski

Responses

pgsql-docs by date

Next:From: Grzegorz SzpetkowskiDate: 2011-05-04 18:36:10
Subject: Missing prefix unary '+' operator in Table 4-2 ?
Previous:From: Kevin GrittnerDate: 2011-05-04 12:26:29
Subject: Re: boolean states

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group