Re: Valid role name (PostgreSQL 9.0.4) - Mailing list pgsql-novice

From Grzegorz Szpetkowski
Subject Re: Valid role name (PostgreSQL 9.0.4)
Date
Msg-id BANLkTi=jQ739XzuAQ_yMWpm4Kq4z7dMLvA@mail.gmail.com
Whole thread Raw
In response to Re: Valid role name (PostgreSQL 9.0.4)  (Josh Kupershmidt <schmiddy@gmail.com>)
Responses Re: Valid role name (PostgreSQL 9.0.4)
List pgsql-novice
You are right. I found in documentation:

"As a general rule, if you get spurious parser errors for commands
that contain any of the listed key words as an identifier you should
try to quote the identifier to see if the problem goes away."

psql -c ALTER ROLE "user" CREATEDB'

On the other hand there is also:

"According to the standard, reserved key words are the only real key
words; they are never allowed as identifiers."

Since USER is reserved PostgreSQL keywords should I generally avoid
such names ? I found that I can even create (distinct) "USER" role:

createuser -SdR USER
psql -c "\du"
                       List of roles
 Role name |            Attributes             | Member of
-----------+-----------------------------------+-----------
 USER      | Create DB                         | {}
 postgres  | Superuser, Create role, Create DB | {}
 user      | Create DB                         | {}

Regards,
Grzegorz Sz.

2011/4/8 Josh Kupershmidt <schmiddy@gmail.com>:
> On Thu, Apr 7, 2011 at 11:21 PM, Grzegorz Szpetkowski
> <gszpetkowski@gmail.com> wrote:
>> Then I run:
>>
>> psql -c "ALTER ROLE user CREATEDB"
>> ERROR:  syntax error at or near "user"
>> LINE 1: ALTER ROLE user CREATEDB
>>                  ^
>
> If you quote the "user" username like so:
>
> ALTER ROLE "user" CREATEDB;
>
> the command should work as you expected it to.
>
> Josh
>

pgsql-novice by date:

Previous
From: Grzegorz Szpetkowski
Date:
Subject: Re: Superuser accout (PostgreSQL 9.0.4)
Next
From: Josh Kupershmidt
Date:
Subject: Re: Valid role name (PostgreSQL 9.0.4)