Re: has_column_privilege behavior (was Re: Assert failed in snprintf.c)
Stephen Frost <sfrost@snowman.net>
From: Stephen Frost <sfrost@snowman.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jaime Casanova <jaime.casanova@2ndquadrant.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-10-02T16:10:49Z
Lists: pgsql-hackers
Greetings,
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> >> OK, so here's a patch that I think does the right things.
> >> I noticed that has_foreign_data_wrapper_privilege() and some other
> >> recently-added members of the has_foo_privilege family had not gotten
> >> the word about not failing on bogus OIDs, so I also fixed those.
>
> > I just glanced through it pretty quickly, but looks good to me.
>
> Pushed with some test cases; thanks for reviewing!
Thanks for hacking on it.
> BTW, I noticed while making the test cases that there are some odd-seeming
> behaviors as a result of early exits from the test functions. For
> instance,
>
> regression=# create table mytab(f1 int, f2 int);
> CREATE TABLE
> regression=# select has_column_privilege('mytab',99::int2,'select');
> has_column_privilege
> ----------------------
> t
> (1 row)
Ah, yeah, that's the whole "you have access to all columns if you have
SELECT rights on the table".
> One might reasonably expect NULL there, but column_privilege_check
> observes that you have table-level select privilege so it doesn't
> bother to look up the column number. Not sure if this is worth
> doing something about.
Yeah, I'm on the fence about if it makes sense to do anything here or
not. Hard to see how getting a NULL back is really more useful in this
case.
Thanks!
Stephen
Commits
-
Fix corner-case failures in has_foo_privilege() family of functions.
- fd81fae67fa0 9.4.20 landed
- dad4df0fc8a1 9.5.15 landed
- 01c7a87df98c 9.3.25 landed
- 7eed72333731 10.6 landed
- 6d73983be61a 9.6.11 landed
- 419cc8add5fb 11.0 landed
- 3d0f68dd3061 12.0 landed