Re: Valid role name (PostgreSQL 9.0.4)

From: Grzegorz Szpetkowski <gszpetkowski(at)gmail(dot)com>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Valid role name (PostgreSQL 9.0.4)
Date: 2011-04-08 14:11:01
Message-ID: BANLkTi=jQ739XzuAQ_yMWpm4Kq4z7dMLvA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)com>:
> On Thu, Apr 7, 2011 at 11:21 PM, Grzegorz Szpetkowski
> <gszpetkowski(at)gmail(dot)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
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Kupershmidt 2011-04-08 21:39:17 Re: Valid role name (PostgreSQL 9.0.4)
Previous Message Grzegorz Szpetkowski 2011-04-08 13:38:07 Re: Superuser accout (PostgreSQL 9.0.4)