Re: has_column_privilege behavior (was Re: Assert failed in snprintf.c)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephen Frost <sfrost@snowman.net>
Cc: Jaime Casanova <jaime.casanova@2ndquadrant.com>,
Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-10-01T20:27:19Z
Lists: pgsql-hackers
Stephen Frost <sfrost@snowman.net> writes:
> My complaint is specifically trying to do something like:
> =*# select *
> from
> pg_class
> join pg_attribute on (pg_class.oid = pg_attribute.attrelid)
> join pg_namespace on (pg_class.relnamespace = pg_namespace.oid)
> where
> has_column_privilege(quote_ident(nspname) || '.' || quote_ident(relname),attname,'SELECT');
> and getting this:
> ERROR: column "........pg.dropped.2........" of relation "t1" does not exist
That code is kinda broken anyway, because it won't survive relation drops
either. What you *should* be writing is
has_column_privilege(pg_class.oid, attnum, 'SELECT');
which is not only not sensitive to these problems but significantly more
efficient.
Having said that, I'm fine with having it return NULL if the given
attname matches an attisdropped column. What I was on about is what
happens when you write
has_column_privilege('sometab'::regclass, 'somecol', 'SELECT');
and sometab exists but somecol doesn't.
regards, tom lane
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