Re: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres
Date
Msg-id CAKFQuwbuQnLkA_sQHECg7az5vcvS79L9i_nEG48p5ss6UkHz2Q@mail.gmail.com
Whole thread Raw
In response to BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres  (xelah-postgresql@xelah.com)
Responses Re: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres  (Pedro Gimeno <pgsql-004@personal.formauri.es>)
List pgsql-bugs
On Tue, Nov 24, 2015 at 5:12 AM, <xelah-postgresql@xelah.com> wrote:

>
> 'CREATE DATABASE .. OWNER ..' creates a database owned by the correct use=
r,
> 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=
.
>

=E2=80=8B
This is not a bug and
=E2=80=8Bis =E2=80=8B
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.

You can clone "template0" or add "DROP SCHEMA" or "ALTER SCHEMA" to your
script if you want the final result to not look like template1.

David J.

pgsql-bugs by date:

Previous
From: xelah-postgresql@xelah.com
Date:
Subject: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres
Next
From: Tom Lane
Date:
Subject: Re: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres