Re: alter user/role CURRENT_USER

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
Cc: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, "Marti R(dot)" <marti(at)juffo(dot)org>, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alter user/role CURRENT_USER
Date: 2014-10-30 19:06:46
Message-ID: 20141030190645.GF28859@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

* Adam Brightwell (adam(dot)brightwell(at)crunchydatasolutions(dot)com) wrote:
> > | RoleId_or_curruser: RoleId { $$ = $1; }
> > | | CURRENT_USER { $$ = "\x00\x01";};
[...]
> > This is ugly but needs no additional struct member or special
> > logics. (Macros could make them look better.)
>
> Yeah, that's pretty ugly. I think Alvaro's recommendation of having the
> production return a node with a name or flag is the better approach.

That's more than just 'ugly', in my view. I don't think there's any
reason to avoid making this into a node with a field that can be set to
indicate it's something special if we're going to support this.

The other idea which comes to mind is- could we try to actually resolve
what the 'right' answer is here, instead of setting a special value and
then having to detect and fix it later? Perhaps have a Oid+Rolename
structure and then fill in the Oid w/ GetUserId(), if we're called with
CURRENT_USER, and otherwise just populate the Rolename field and have
code later which fills in the Oid if it's InvalidOid.

> > Please let me know the reason to avoid registering new keyword
> > making the word unusable as an literal identifier, if any?

We really don't want to introduce new keywords without very good reason,
and adding to the list of "can't be used even if quoted" is all but
completely forbidden.

Thanks,

Stephen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-10-30 19:10:43 Re: proposal: CREATE DATABASE vs. (partial) CHECKPOINT
Previous Message Alvaro Herrera 2014-10-30 19:02:56 Re: Faster relevance ranking didn't make it into PostgreSQL 9.4