public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Tablespace ACLs
2+ messages / 2 participants
[nested] [flat]

* Re: Tablespace ACLs
@ 2024-10-10 14:19 Erik Wienhold <[email protected]>
  2024-10-10 14:46 ` Re: Tablespace ACLs Dominique Devienne <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Erik Wienhold @ 2024-10-10 14:19 UTC (permalink / raw)
  To: Dominique Devienne <[email protected]>; +Cc: [email protected]

I wrote:
> > On 2024-10-10 14:35 +0200, Dominique Devienne wrote:
> > > On a related but different matter, is it normal not having access to a
> > > single tablespace makes the whole output disappear?
> > >
> > > ddevienne=> \db+
> > > ERROR:  permission denied for tablespace hdd_data
> > 
> > This lacks permission for executing pg_tablespace_size().  Granting
> > pg_read_all_stats should be sufficient.  But I agree, omitting the
> > non-accessible tablespaces would be better IMO.

On second thought, just guarding the pg_tablespace_size() call and
reporting an unknown size when permissions are insufficient is better,
so that \db+ still lists all tablespaces like \db does.

    SELECT spcname AS "Name",
      pg_catalog.pg_get_userbyid(spcowner) AS "Owner",
      pg_catalog.pg_tablespace_location(t.oid) AS "Location",
      pg_catalog.array_to_string(spcacl, E'\n') AS "Access privileges",
      spcoptions AS "Options",
      CASE WHEN pg_catalog.has_tablespace_privilege(t.oid, 'CREATE')
             OR pg_catalog.pg_has_role('pg_read_all_stats', 'USAGE')
             OR dattablespace IS NOT NULL -- is default tablespace
        THEN pg_catalog.pg_size_pretty(pg_catalog.pg_tablespace_size(t.oid))
        ELSE null -- unknown size
      END AS "Size",
      pg_catalog.shobj_description(t.oid, 'pg_tablespace') AS "Description"
    FROM pg_catalog.pg_tablespace t
      LEFT JOIN pg_catalog.pg_database
        ON datname = pg_catalog.current_database()
        AND dattablespace = t.oid
    ORDER BY 1;

-- 
Erik






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Tablespace ACLs
  2024-10-10 14:19 Re: Tablespace ACLs Erik Wienhold <[email protected]>
@ 2024-10-10 14:46 ` Dominique Devienne <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dominique Devienne @ 2024-10-10 14:46 UTC (permalink / raw)
  To: Erik Wienhold <[email protected]>; +Cc: [email protected]

On Thu, Oct 10, 2024 at 4:19 PM Erik Wienhold <[email protected]> wrote:
> > > On 2024-10-10 14:35 +0200, Dominique Devienne wrote:
> > > > On a related but different matter, is it normal not having access to a
> > > > single tablespace makes the whole output disappear?
> On second thought, just guarding the pg_tablespace_size() call and
> reporting an unknown size when permissions are insufficient is better,
> so that \db+ still lists all tablespaces like \db does.

FWIW, I agree. --DD






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-10-10 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 14:19 Re: Tablespace ACLs Erik Wienhold <[email protected]>
2024-10-10 14:46 ` Dominique Devienne <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox