question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[PostgreSQL] Display privileges and default privileges in schema DDL

See original GitHub issue

Hello,

Working on PostgreSQL schemas with DBeaver 6.1.4, I noticed that in the generated DDL for schemas the privileges and default privileges are not displayed.

pgAdmin

CREATE SCHEMA <schema> AUTHORIZATION <admin>;

GRANT ALL ON SCHEMA <schema> TO <admin>;
GRANT ALL ON SCHEMA <schema> TO <role_1>;
GRANT USAGE ON SCHEMA <schema> TO <role_2>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT INSERT, SELECT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON TABLES
    TO <role_1>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT SELECT ON TABLES
    TO <role_2>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT SELECT, UPDATE, USAGE ON SEQUENCES
    TO <role_1>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT SELECT, UPDATE, USAGE ON SEQUENCES
    TO <role_2>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT EXECUTE ON FUNCTIONS
    TO <role_1>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT EXECUTE ON FUNCTIONS
    TO <role_2>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT USAGE ON TYPES
    TO <role_1>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema>
    GRANT USAGE ON TYPES
    TO <role_2>;

DBeaver 6.1.4

CREATE SCHEMA <schema> AUTHORIZATION <admin>;

As I can see, the missing statements are:

  • GRANT <what> ON SCHEMA <schema> TO <who>;
  • ALTER DEFAULT PRIVILEGES IN SCHEMA <schema> GRANT <what-s> ON TABLES TO <who>;

Is it possible to add these informations?

Thanks for your great work.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
grassucommented, Jul 30, 2020

Hello @usless,

thanks for your reply. Unfortunately not. There are only visible the “GRANT …” entries:

GRANT ALL ON SCHEMA test TO test_admin;
GRANT USAGE ON SCHEMA test TO test_writegroup;
GRANT USAGE ON SCHEMA test TO test_readgroup;

Entries starting with “ALTER DEFAULT PRIVILEGES …” are missing completely:

ALTER DEFAULT PRIVILEGES IN SCHEMA test
GRANT ALL ON TABLES TO test_admin;
ALTER DEFAULT PRIVILEGES IN SCHEMA test
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLES TO test_writegroup;
ALTER DEFAULT PRIVILEGES IN SCHEMA test
GRANT SELECT ON TABLES TO test_readgroup;

Same for functions, sequences, etc.

1reaction
rbovardcommented, Jun 11, 2020

Hello @uslss @serge-rider

I’ve downloaded v7.1.0 and I still cannot see what I’m looking for…

Maybe something is not clear between us, I’m trying to see rights and default priviliges on schema in the source tab, like in PgAdmin (see my initial post). Or maybe it is avalaible somewhere else?

Thanks for your feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

15: ALTER DEFAULT PRIVILEGES - PostgreSQL
The privileges can be set globally (i.e., for all objects created in the current database), or just for objects created in specified schemas....
Read more >
How to manage DEFAULT PRIVILEGES for USERs on a ...
PostgreSQL grants default privileges on some types of objects to PUBLIC . No privileges are granted to PUBLIC by default on tables, columns, ......
Read more >
sql - postgresql - view schema privileges - Stack Overflow
in console util psql: \dn+. will show you. Name | Owner | Access privileges | Description.
Read more >
How to Handle Privileges in PostgreSQL | by Shengyu Huang
Yes, when we do not specify any particular schema in ALTER DEFAULT PRIVILEGES , the changes apply to the whole database. So one...
Read more >
Postgres: Display granted permissions on objects : DBE-2629
We currently default for the most part to Navicat, which has been very problematic in a number of ways, but in order to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found