Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a1em0-0001k2-A9 for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Nov 2015 18:26:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a1elz-00022F-TE for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Nov 2015 18:26:31 +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.84) (envelope-from ) id 1a1drl-0007hY-9E for pgsql-bugs@postgresql.org; Wed, 25 Nov 2015 17:28:25 +0000 Received: from formauri.es ([78.47.205.180]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1a1drg-0005Vt-Q0 for pgsql-bugs@postgresql.org; Wed, 25 Nov 2015 17:28:23 +0000 Received: from [0.0.0.0] (formauri.es [78.47.205.180]) by formauri.es (Postfix) with ESMTPS id 0E2B583718; Wed, 25 Nov 2015 18:28:18 +0100 (CET) Message-ID: <5655EFB2.2@personal.formauri.es> Date: Wed, 25 Nov 2015 18:28:18 +0100 From: Pedro Gimeno User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.7.0 MIME-Version: 1.0 To: "David G. Johnston" , xelah-postgresql@xelah.com CC: "pgsql-bugs@postgresql.org" Subject: Re: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres References: <20151124121258.435.64678@wrigleys.postgresql.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org David G. Johnston wrote, On 2015-11-24 22:56: > On Tue, Nov 24, 2015 at 5:12 AM, wrote: >> 'CREATE DATABASE .. OWNER ..' creates a database owned by the correct user, >> but containing a schema apparently owned by the user running 'CREATE >> DATABASE'. This causes us a problem when our test code tries to 'DROP >> SCHEMA >> public CASCADE' (as a way of clearing the database) as the database owner. > > This is not a bug and > ​is ​ > not going to be changed. > > You need to choose one of the many other ways to accomplish your goal. > > The specific behavior is that the template1 database which is being used as > a template (by default) has a public schema owned by the bootstrap > (postgres typically) user. The create database commands clones the > template database exactly as it is defined. The documentation covers this > dynamic in considerable detail. We were bitten by a similar problem, where restoring a database dump re-created the public schema that we dropped, which was a security concern for us (BUG #3684). We solved it by dropping it from template1. It wasn't that evident from reading the documentation. I think that doing so would solve the OP's problem. I think that a palliative measure would be to change the documentation as follows: At the end of the first paragraph, after: "If you add objects to template1, these objects will be copied into subsequently created user databases. This behavior allows site-local modifications to the standard set of objects in databases. For example, if you install the procedural language PL/Perl in template1, it will automatically be available in user databases without any extra action being taken when those databases are created." add the following: "Similarly, dropping objects from template1 will cause subsequently created databases to not have these objects. For example, dropping the public schema from template1 will cause it to not exist in user databases created after that." I know the wording may not be ideal. The whole idea is to suggest that objects can also be dropped from it, AND mention 'public' as a specific example, which is the most likely target of wanting to drop objects. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs