Skip site navigation (1) Skip section navigation (2)

Re: "-t template0" in createdb

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike Thomsen <mikerthomsen(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: "-t template0" in createdb
Date: 2011-02-03 18:27:06
Message-ID: 25991.1296757626@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Mike Thomsen <mikerthomsen(at)gmail(dot)com> writes:
> I while ago, I reported that grant statements were always returning an
> error stating that the database could no be found.

> Today I noticed that it seemed to be caused only when the database was
> created like this:

> createdb newdb -U postgres -t template0

> The installation instructions we got for an inhouse project called for
> the "-t template0" When removed, that consistently caused the
> aforementioned bug to stop.

> What was it about that "-t template0" that was causing it to fail?

If you don't say "-t template0" then what you get is a database cloned
from template1 instead of template0.  It sounds to me like you have
(either intentionally or accidentally) added some objects to template1,
and your code is relying on those objects being there in a newly-created
database.  See

http://www.postgresql.org/docs/9.0/static/manage-ag-templatedbs.html

Whether having extra stuff in template1 is a good thing or not is
something that depends on your individual situation ... but a lot of
people have found it to be a foot-gun.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Mike ThomsenDate: 2011-02-03 19:57:03
Subject: Re: "-t template0" in createdb
Previous:From: Mike ThomsenDate: 2011-02-03 18:04:49
Subject: "-t template0" in createdb

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group