Re: alter user/role CURRENT_USER

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: adam(dot)brightwell(at)crunchydatasolutions(dot)com, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alter user/role CURRENT_USER
Date: 2014-10-28 00:22:33
Message-ID: CABRT9RABDq915iMROxxa7VgQ60Pg7t3D+fGz8pyGC6gBFKraBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 24, 2014 at 11:29 AM, Kyotaro HORIGUCHI
<horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> - 0001-ALTER-ROLE-CURRENT_USER_v2.patch - the patch.

+RoleId: CURRENT_USER { $$ = "current_user";}
+ | USER { $$ = "current_user";}
+ | CURRENT_ROLE { $$ = "current_user";}
+ | SESSION_USER { $$ = "session_user";}

This is kind of ugly, and it means you can't distinguish between a
CURRENT_USER keyword and a quoted user name "current_user". It's a
legitimate user name, so the behavior of the following now changes:

CREATE ROLE "current_user";
ALTER ROLE "current_user" SET work_mem='10MB';

There ought to be a better way to represent this than using magic string values.

----
> It accepts CURRENT_USER/USER/CURRENT_ROLE/SESSION_USER.

On a stylistic note, do we really want to support the alternative
spellings of CURRENT_USER, like CURRENT_ROLE and USER? The SQL
standard is well-hated for inventing more keywords than necessary.
There is no precedent for using/allowing these aliases in PostgreSQL
DDL commands, and ALTER USER & ROLE aren't SQL standard anyway. So
maybe we should stick with just accepting one canonical syntax
instead.

I think the word USER may reasonably arise from an editing mistake,
ALTER USER USER does not seem like sane syntax that should be
accepted.

----
From your original email:

> - Modify syntax of ALTER USER so as to be an alias of ALTER ROLE.
> - Added ALL syntax as user name to ALTER USER.

But should ALTER USER ALL and ALTER ROLE ALL really do the same thing?
A user is a role with the LOGIN option. Every user is a role, but not
every role is a user. I suspect that ambiguity was why ALTER USER ALL
wasn't originally implemented.

Regards,
Marti

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G Johnston 2014-10-28 00:33:41 Re: proposal: CREATE DATABASE vs. (partial) CHECKPOINT
Previous Message Ali Akbar 2014-10-28 00:22:24 Re: Function array_agg(array)