Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quicksetup: creating database with owner fails #5827

Closed
ltalirz opened this issue Dec 8, 2022 · 0 comments · Fixed by #5828
Closed

quicksetup: creating database with owner fails #5827

ltalirz opened this issue Dec 8, 2022 · 0 comments · Fixed by #5828
Labels

Comments

@ltalirz
Copy link
Member

ltalirz commented Dec 8, 2022

Connecting to a postgresql cluster as the superuser azureuser on an Azure postgresql database.

Granting all privileges works:

template1=> create database test;
CREATE DATABASE
template1=> create user test;
CREATE ROLE
template1=> grant all privileges on database test to test;
GRANT
template1=> drop database test;
DROP DATABASE

but creating the database with owner test fails:

template1=> create database test owner test;
ERROR:  must be member of role "test"
template1=> grant test to azureuser;
GRANT ROLE
template1=> create database test owner test;
CREATE DATABASE

verdi quicksetup currently creates the database with owner and grants all privileges

self.execute(_CREATE_DB_COMMAND.format(dbname, dbuser))
self.execute(_GRANT_PRIV_COMMAND.format(dbname, dbuser))

This is actually overkill: according to the postgres documentation

There is no need to grant privileges to the owner of an object (usually the user that created it), as the owner has all privileges by default. (The owner could, however, choose to revoke some of their own privileges for safety.)

I.e. I propose that we go the

template1=> create user test;
CREATE ROLE
template1=> grant test to azureuser;
GRANT ROLE
template1=> create database test owner test;
CREATE DATABASE

route.

Will open a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant