Re: inconsistent owners in newly created databases? - Mailing list pgsql-hackers

From Greg Stark
Subject Re: inconsistent owners in newly created databases?
Date
Msg-id 87zn8mvnob.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: inconsistent owners in newly created databases?  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
Fabien COELHO <coelho@cri.ensmp.fr> writes:

> I agree with the advantage.
> 
> But I'm uneasy to know what a special owner would be, pratically speaking.
> If it would mean that everywhere in the source code where an owner is
> manipulated, there must be some kind of special test for that case, I'm
> not sure it would be that great...

Well I can't think of anywhere else in the code that would need this special
case other than creating a database. My thinking is it would otherwise act as
a special user except when you're copying a database it would get mean "set
the owner of this object to the owner of the new database".

> Also any database can be used as a template, not just template1.
> Moreover, template1 is a still usable database, that can be set with
> whatever you want in new created, so it is not "that" special...

Well perhaps it should be an option on create database?
create database foo with template=template1 owner=bar templateowner=baz

Or perhaps it should just default to the name of the template database maybe
the owner of the template database. So these objects would be owned by user
"template1" in the template1 database.

Then If I create a database with 
create database user2 with template=user1 owner=user2

then any objects owned by user1 in the template become owned by user2 in the
new database.

Using the owner of the template database has the advantage that you can copy a
copy of a database and get the same result as if you copied the original. Eg,
this would work:
create database template2 with template=template1 owner=template2create database template3 with template=template2
owner=template3

and the result would be the same as
create database template3 with template=template1 owner=template3

-- 
greg



pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: inconsistent owners in newly created databases?
Next
From: Alvaro Herrera
Date:
Subject: Re: COPY command - CSV files