Thread: Inconsistencies with create role

Inconsistencies with create role

From
"Joshua D. Drake"
Date:
Hello,

When doing:

SELECT * FROM pg_user;

foo=# select * from pg_user; usename | usesysid | usecreatedb | usesuper | usecatupd |  passwd  | 
valuntil | useconfig
---------+----------+-------------+----------+-----------+----------+----------+----------- jd      |       10 | t
    | t        | t         | ******** |         |
 
(1 row)

Then:

foo=# create role foo with createdb;
CREATE ROLE
foo=# create user foo;
ERROR:  role "foo" already exists
ERROR:  role "foo" already exists
foo=# select * from pg_user; usename | usesysid | usecreatedb | usesuper | usecatupd |  passwd  | 
valuntil | useconfig
---------+----------+-------------+----------+-----------+----------+----------+----------- jd      |       10 | t
    | t        | t         | ******** |         |
 
(1 row)

I understand what is happening, but perhaps the error should be:

A role "foo" already exists which can not be the same as a username?

Or something like that...

Sincerely,

Joshua D. Drake


-- 
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/


Re: Inconsistencies with create role

From
Tom Lane
Date:
"Joshua D. Drake" <jd@commandprompt.com> writes:
> foo=# create role foo with createdb;
> CREATE ROLE
> foo=# create user foo;
> ERROR:  role "foo" already exists

> I understand what is happening, but perhaps the error should be:
> A role "foo" already exists which can not be the same as a username?

The documentation already says prominently that roles and users are
the same thing.  If you're fooling with CREATE ROLE without having
read any of that, I'm not sure that an error message will help.

Also, although the SQL standard thinks that roles and users are
distinct, it requires them to have distinct names; this is necessary
because <authorization identifier> doesn't syntactically distinguish
between the two cases.  So there's no support in the spec either for
supposing that you can create both user foo and role foo.
        regards, tom lane


Re: Inconsistencies with create role

From
"Joshua D. Drake"
Date:
>The documentation already says prominently that roles and users are
>the same thing.  If you're fooling with CREATE ROLE without having
>read any of that, I'm not sure that an error message will help.
>  
>
I am talking about consistency here. Most people are not
going to think a role is a user, at least not initially since it
is a new feature. All I was saying was that the error message
was a little confusing.

Sincerely,

Joshua D. Drake