Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpaus-0005uB-H5 for pgsql-general@arkaria.postgresql.org; Tue, 14 Aug 2018 15:07:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpauq-0002EE-PS for pgsql-general@arkaria.postgresql.org; Tue, 14 Aug 2018 15:07:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpauq-0002E0-HD for pgsql-general@lists.postgresql.org; Tue, 14 Aug 2018 15:07:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpaum-0007f8-GO for pgsql-general@postgresql.org; Tue, 14 Aug 2018 15:07:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7EF7D8j018653; Tue, 14 Aug 2018 11:07:13 -0400 From: Tom Lane To: Alvar Freude cc: Postgres General Subject: Re: Best Practices for Extensions, limitations and recommended use for monitoring In-reply-to: References: Comments: In-reply-to Alvar Freude message dated "Tue, 14 Aug 2018 10:53:19 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18651.1534259233.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Aug 2018 11:07:13 -0400 Message-ID: <18652.1534259233@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvar Freude writes: > I have a question about best practices writing PostgreSQL extensions. Is= it OK to write extensions which create users and grant/revoke rights on t= he created functions to this users? I'd say that's generally deprecated. Per the documentation, you can write CREATE USER commands in an extension script if you like, but the roles won't be considered to "belong" to the extension, and won't be dropped when it is. This is mainly because roles are cluster-wide but extensions are only local to one database. Consider for example what will happen when somebody tries to load your extension into more than one database in the same cluster. > Is it possible to add options to CREATE EXTENSION by the extension itsel= f e.g. to make user names configurable? No. For the particular use-case you're describing here, maybe it'd make sense to grant privileges to the predefined role pg_monitor, which exists in v10 and up. v11 has some additional predefined roles that perhaps would fit in, too. regards, tom lane