Обсуждение: Schema authorization after create database.

Поиск
Список
Период
Сортировка

Schema authorization after create database.

От
Ian FREISLICH
Дата:
Hi

I ran into this little astonishment yesterday on 7.4.8.  When I
create a database connected as the super user using:

CREATE DATABASE foo OWNER = foo;

The database is indeed owned by user foo, but the automatically
created public schema is is owned by the database super user.  Should
this schema not be created as owned by the database owner specified
in the CREATE DATABASE command?

Our work around is to drop the public schema and recreate it after
reconnecting as the database owner, but that seems like work I
shouldn't have to do.

Is this a problem or am I expecting something that I shouldn't?

Ian

--
Ian Freislich

Re: Schema authorization after create database.

От
Tsirkin Evgeny
Дата:
We have simular behavor:
createdb -U user1 mydb
pg_restore -U user1 -d mydb filename
And the pg_restore complains about the wrong user .I have alwais wolk
around this as supreuser.
Evgeny
Ian FREISLICH wrote:

>Hi
>
>I ran into this little astonishment yesterday on 7.4.8.  When I
>create a database connected as the super user using:
>
>CREATE DATABASE foo OWNER = foo;
>
>The database is indeed owned by user foo, but the automatically
>created public schema is is owned by the database super user.  Should
>this schema not be created as owned by the database owner specified
>in the CREATE DATABASE command?
>
>Our work around is to drop the public schema and recreate it after
>reconnecting as the database owner, but that seems like work I
>shouldn't have to do.
>
>Is this a problem or am I expecting something that I shouldn't?
>
>Ian
>
>--
>Ian Freislich
>
>---------------------------(end of broadcast)---------------------------
>TIP 9: In versions below 8.0, the planner will ignore your desire to
>       choose an index scan if your joining column's datatypes do not
>       match
>
>


Re: Schema authorization after create database.

От
Tom Lane
Дата:
Ian FREISLICH <if@hetzner.co.za> writes:
> I ran into this little astonishment yesterday on 7.4.8.  When I
> create a database connected as the super user using:

> CREATE DATABASE foo OWNER = foo;

> The database is indeed owned by user foo, but the automatically
> created public schema is is owned by the database super user.  Should
> this schema not be created as owned by the database owner specified
> in the CREATE DATABASE command?

That's the way it's supposed to work.  CREATE DATABASE does not change
anything inside the copied database.

            regards, tom lane

Re: Schema authorization after create database.

От
Tsirkin Evgeny
Дата:
Yep.But this is a little strange ,maybe we should ask to change it?
Evgeny.
Tom Lane wrote:
> Ian FREISLICH <if@hetzner.co.za> writes:
>
>>I ran into this little astonishment yesterday on 7.4.8.  When I
>>create a database connected as the super user using:
>
>
>>CREATE DATABASE foo OWNER = foo;
>
>
>>The database is indeed owned by user foo, but the automatically
>>created public schema is is owned by the database super user.  Should
>>this schema not be created as owned by the database owner specified
>>in the CREATE DATABASE command?
>
>
> That's the way it's supposed to work.  CREATE DATABASE does not change
> anything inside the copied database.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster