Re: REVOKE FROM warning on grantor

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Étienne BERSAC <etienne(dot)bersac(at)dalibo(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: REVOKE FROM warning on grantor
Date: 2024-03-18 21:30:22
Message-ID: 3694568.1710797422@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Sat, Mar 16, 2024 at 8:17 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Even taking the position that this is an unspecified point that we
>> could implement how we like, I don't think there's a sufficient
>> argument for changing behavior that's stood for a couple of decades.

> I got curious about the behavior of other database systems.

Yeah, I was mildly curious about that too; it'd be unlikely to sway
my bottom-line opinion, but it would be interesting to check.

> https://dev.mysql.com/doc/refman/8.0/en/revoke.html documents an "IF
> EXISTS" option whose documentation reads, in relevant part,
> "Otherwise, REVOKE executes normally; if the user does not exist, the
> statement raises an error."

Hmm, I don't think that's quite what's at stake here. We do throw
error if either named role doesn't exist:

regression=# revoke foo from joe;
ERROR: role "joe" does not exist
regression=# create user joe;
CREATE ROLE
regression=# revoke foo from joe;
ERROR: role "foo" does not exist
regression=# create role foo;
CREATE ROLE
regression=# revoke foo from joe;
WARNING: role "joe" has not been granted membership in role "foo" by role "postgres"
REVOKE ROLE

What the OP is on about is that that last case issues WARNING not
ERROR.

Reading further down in the mysql page you cite, it looks like their
IF EXISTS conflates "role doesn't exist" with "role wasn't granted",
and suppresses errors for both those cases. I'm not in favor of
changing things here, but if we did, I sure wouldn't want to adopt
those exact semantics.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2024-03-18 21:40:07 Re: documentation structure
Previous Message Nathan Bossart 2024-03-18 21:29:19 Re: Popcount optimization using AVX512