Re: template1, can there be a template2/3/4? - Mailing list pgsql-general

From Jan Wieck
Subject Re: template1, can there be a template2/3/4?
Date
Msg-id 200106041653.f54Grx608590@jupiter.us.greatbridge.com
Whole thread Raw
In response to template1, can there be a template2/3/4?  (Jim Mercer <jim@reptiles.org>)
List pgsql-general
Jim Mercer wrote:
>
> as i understand the usage of template1, it holds the system catalogs,
> users, etc, etc.
>
> it is accessed as a quasi-shadow database supporting the actual production
> data databases.
>
> would it be possible for me to create a template2 and have some arbitrary
> database use it instead of template1?
>
> the reason i ask this is that it would be useful to have something to the
> effect of:
>
> database access startup for "sample" database.
>
> if exists sample_cat database, use it instead of template1
> otherwise use template1
>
> this way "sample" could have its own set of users, permissions, etc, etc.
>
> it would be a method for getting around the fact that a user in template1
> has access to all of the other databases, modulo per-database permissions
> via GRANT/REVOKE
>
> does this make any sense?

    There  is  no  such  concept  like a shadow database. I think
    you've misunderstood something.

    Except  for  a  few  shared  relations,  namely  pg_database,
    pg_shadow,  pg_group  and pg_log, every database has it's own
    copy of the system catalog. The entire content  (catalog  and
    so  far  created  objects)  is *copied* at createdb time from
    whatever you specify as the template database. If you  modify
    the template database after, these changes don't make it into
    the databases derived from it.

    The shared catalogs are shared in the entire instance. So  if
    you  want  different  sets of users, you need to run separate
    postmasters for the different sets of databases.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: template1, can there be a template2/3/4?
Next
From: Martín Marqués
Date:
Subject: Re: datestyle