Thread: "-t template0" in createdb
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? Thanks, Mike
Mike Thomsen <mikerthomsen@gmail.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
Interesting. Your docs say to use "-T template0" I have a feeling that our instructions had a typo which caused the grief^H^Hfun I was having. At any rate, if all I need is a bit bucket, is there a practical difference between leaving it on versus off when running createdb? On Thu, Feb 3, 2011 at 1:27 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Mike Thomsen <mikerthomsen@gmail.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 >
Mike Thomsen <mikerthomsen@gmail.com> writes: > Interesting. Your docs say to use "-T template0" I have a feeling that > our instructions had a typo which caused the grief^H^Hfun I was > having. Oh ... I had assumed that was just a typo in your mail, because createdb doesn't actually *have* a -t switch, only a -T switch. On reasonable platforms you will get a failure message if you try to use -t. But I suppose you might have a broken version of getopt_long that doesn't report an error, in which case it's anybody's guess exactly how createdb is interpreting that command. regards, tom lane