Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYReo-00062S-Do for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2019 08:52:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hYRem-0002IN-Ov for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2019 08:52:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYRem-0002Dn-Aa for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2019 08:52:28 +0000 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYRej-0000R6-Ew for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2019 08:52:27 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id A99794F228; Wed, 5 Jun 2019 10:52:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id hElf2wPBVSfd; Wed, 5 Jun 2019 10:52:18 +0200 (CEST) Message-ID: <91b121d8f4f2e4a7b85e46f87cf91f634598c88d.camel@cybertec.at> Subject: Re: granting right to create and delete just one database From: Laurenz Albe To: Chris Withers , pgsql-general@lists.postgresql.org Date: Wed, 05 Jun 2019 10:52:17 +0200 In-Reply-To: <32b82200-576e-d51a-f16c-541068896762@withers.org> References: <32b82200-576e-d51a-f16c-541068896762@withers.org> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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