Re: Test if a database has any privilege granted to public

2022-12-16 Thread David G. Johnston
On Thu, Dec 15, 2022 at 5:17 PM Bryn Llewellyn wrote: > > There's no mention on the "Privileges" page of the > "has_database_privilege()" function. Nor of "aclexplode()". > Even now, I haven't managed a linear start to finish read of the entire PG > docs. And I found "has_database_privilege()"

Re: Test if a database has any privilege granted to public

2022-12-15 Thread Bryn Llewellyn
> david.g.johns...@gmail.com wrote: > >> b...@yugabyte.com wrote: >> >> select datname::text >> from pg_database >> where 0::oid = any(select (aclexplode(datacl)).grantee) >> or datacl is null; >> >> That's easy if you know that you need to write this. But the need to do so >> seems to depend o

Re: Test if a database has any privilege granted to public

2022-12-15 Thread David G. Johnston
On Thu, Dec 15, 2022 at 12:51 PM Bryn Llewellyn wrote: > > > > > > *select datname::textfrom pg_databasewhere 0::oid = any(select > (aclexplode(datacl)).grantee)or datacl is null;* > That's easy if you know that you need to write this. But the need to do so > seems to depend on pretty arcane know

Re: Test if a database has any privilege granted to public

2022-12-15 Thread Bryn Llewellyn
> t...@sss.pgh.pa.us wrote: > >> ronljohnso...@gmail.com writes: >> >> Off-topic, but you don't need all those text casts. > > Indeed. Something like this ought to do it: > > select datname from pg_database where 0::oid = any(select > (aclexplode(datacl)).grantee); > > datname >

Re: Test if a database has any privilege granted to public

2022-12-14 Thread Tom Lane
Ron writes: > Off-topic, but you don't need all those text casts. Indeed. Something like this ought to do it: =# select datname from pg_database where 0::oid = any(select (aclexplode(datacl)).grantee); datname template1 template0 regression (3 rows)

Re: Test if a database has any privilege granted to public

2022-12-14 Thread Ron
Off-topic, but you don't need all those text casts. On 12/14/22 23:44, Bryn Llewellyn wrote: I want to adopt a rule that no database in my cluster has any privilege granted to public. It suits me best to encapsulate the test as a boolean function thus: *function mgr.db_has_priv_granted_to_pub

Test if a database has any privilege granted to public

2022-12-14 Thread Bryn Llewellyn
I want to adopt a rule that no database in my cluster has any privilege granted to public. It suits me best to encapsulate the test as a boolean function thus: function mgr.db_has_priv_granted_to_public(db in name) where "mgr" is a convenient schema for various admin utilities. I have implement