pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Granting privileges to a schema to a role
2+ messages / 2 participants
[nested] [flat]

* Granting privileges to a schema to a role
@ 2023-09-11 18:07  Johnson, Bruce E - (bjohnson) <Johnson@pharmacy.arizona.edu>
  0 siblings, 1 reply; 2+ messages in thread

From: Johnson, Bruce E - (bjohnson) @ 2023-09-11 18:07 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

(Background I’m working on migrating an existing set of Oracle schemas with a bunch of inter-schema grants to a Postgres 15 system)

I’ve created the database ‘webdata', successfully used ora2pg to migrate one schema ‘trav’ to Postgres.

The schema on the oracle side is called trav the owner is webdata, and I created the role trav and granted all table rights in the schema to the role

GRANT ALL ON ALL TABLES IN SCHEMA trav TO trav.

When I log into pgsql as trav and run \dp the privileges appear correct but trying a simple select fails with ‘permission denied’ error:


psql webdata -U trav

psql (15.4 (Ubuntu 15.4-1.pgdg22.04+1))

Type "help" for help.


webdata=> \dp trav.sectors

                                 Access privileges

 Schema |  Name   | Type  |    Access privileges    | Column privileges | Policies

--------+---------+-------+-------------------------+-------------------+----------

 trav   | sectors | table | webdata=arwdDxt/webdata+|                   |

        |         |       | trav=arwdDxt/webdata    |                   |

(1 row)


webdata=> select sectorname, count(worldname) from trav.sectors group by sectorname order by sectorname;

ERROR:  permission denied for schema trav

LINE 1: select sectorname, count(worldname) from trav.sectors group ...

What am I missing?


--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs




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

* Re: Granting privileges to a schema to a role
@ 2023-09-11 22:32  Erik Wienhold <ewie@ewie.name>
  parent: Johnson, Bruce E - (bjohnson) <Johnson@pharmacy.arizona.edu>
  0 siblings, 0 replies; 2+ messages in thread

From: Erik Wienhold @ 2023-09-11 22:32 UTC (permalink / raw)
  To: Johnson, Bruce E - (bjohnson) <Johnson@pharmacy.arizona.edu>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 11/09/2023 20:07 CEST Johnson, Bruce E - (bjohnson) <johnson@pharmacy.arizona.edu> wrote:

> I’ve created the database ‘webdata', successfully used ora2pg to migrate one
> schema ‘trav’ to Postgres.
>
> The schema on the oracle side is called trav the owner is webdata, and I
> created the role trav and granted all table rights in the schema to the role
>
> GRANT ALL ON ALL TABLES IN SCHEMA trav TO trav.
>
> When I log into pgsql as trav and run \dp the privileges appear correct but
> trying a simple select fails with ‘permission denied’ error:
>
>
> psql webdata -U trav
>
> psql (15.4 (Ubuntu 15.4-1.pgdg22.04+1))
>
> Type "help" for help.
>
>
> webdata=> \dp trav.sectors
>
>                                  Access privileges
>
>  Schema |  Name   | Type  |    Access privileges    | Column privileges | Policies
>
> --------+---------+-------+-------------------------+-------------------+----------
>
>  trav   | sectors | table | webdata=arwdDxt/webdata+|                   |
>
>         |         |       | trav=arwdDxt/webdata    |                   |
>
> (1 row)
>
>
> webdata=> select sectorname, count(worldname) from trav.sectors group by sectorname order by sectorname;
>
> ERROR:  permission denied for schema trav
>
> LINE 1: select sectorname, count(worldname) from trav.sectors group ...
>
> What am I missing?

You must also grant USAGE on schema trav to role trav to access objects in that
schema.  Use  \dn+ trav  to check the schema privileges.

--
Erik





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


end of thread, other threads:[~2023-09-11 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-09-11 18:07 Granting privileges to a schema to a role Johnson, Bruce E - (bjohnson) <Johnson@pharmacy.arizona.edu>
2023-09-11 22:32 ` Erik Wienhold <ewie@ewie.name>

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