Re: granting right to create and delete just one database

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Chris Withers <chris(at)withers(dot)org>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: granting right to create and delete just one database
Date: 2019-06-05 08:52:17
Message-ID: 91b121d8f4f2e4a7b85e46f87cf91f634598c88d.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Withers wrote:
> Is there any way to grant rights to a user such that they can drop and
> re-create only a single database?

No; what I'd do if I needed that is to create a SECURITY DEFINER function
that is owned by a user with the CREATEDB privilege.
This function can be called by a normal user that has the EXECUTE privilege
on the function.

Don't forget to "SET search_path" on such a function (as mentioned in the
documentation). It might also be a good idea to REVOKE EXECUTE on the
function from PUBLIC.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Withers 2019-06-05 08:56:10 Re: granting right to create and delete just one database
Previous Message Rob Northcott 2019-06-05 08:05:16 RE: Query very different speeds on seemingly similar data