Re: Extending grant insert on tables to sequences - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Extending grant insert on tables to sequences
Date
Msg-id 23912.1215893211@sss.pgh.pa.us
Whole thread Raw
In response to Re: Extending grant insert on tables to sequences  ("Jaime Casanova" <jcasanov@systemguards.com.ec>)
List pgsql-hackers
"Jaime Casanova" <jcasanov@systemguards.com.ec> writes:
> +         if (istmt.all_privs)
> +             istmt_seq.all_privs = true;
> +         else
> +         {
> +             if (istmt.privileges & ACL_INSERT) 
> +                 istmt_seq.privileges |= ACL_USAGE;
> +             if (istmt.privileges & ACL_UPDATE) 
> +                 istmt_seq.privileges |= ACL_UPDATE;
> +             if (istmt.privileges & ACL_SELECT) 
> +                 istmt_seq.privileges |= ACL_SELECT;
> +         }

This definition of the derived rights seems pretty arbitrary and
unprincipled.  If you can't explain it precisely in a few words in the
documentation (and I notice you didn't even attempt to explain it at
all), then you probably need to think harder.

In particular, I don't see why having UPDATE on the parent table should
grant the right to use setval() on the sequence.  If you had INSERT and
DELETE as well, implying the right to make arbitrary changes in the
parent table, then maybe setval() would be sensible to allow --- but
this code can't really tell that, since it doesn't have a global view
of the privileges previously granted.

What I think makes sense is just to have parent INSERT privilege lead to
USAGE on the sequence (thus granting nextval/currval rights, which are
what you'd typically need in association with trying to do inserts).
I don't see any need to automatically grant more than that.  Selects and
updates on the parent table don't need to touch the sequence, so why are
those privileges granting anything?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Abhijit Menon-Sen
Date:
Subject: Re: Extending grant insert on tables to sequences
Next
From: Tom Lane
Date:
Subject: Re: Extending grant insert on tables to sequences