Re: Multiple backend connections - Mailing list pgsql-general

From Tom Lane
Subject Re: Multiple backend connections
Date
Msg-id 9918.1048223340@sss.pgh.pa.us
Whole thread Raw
In response to Re: Multiple backend connections  (Doug McNaught <doug@mcnaught.org>)
List pgsql-general
Doug McNaught <doug@mcnaught.org> writes:
> Paul M Foster <paulf@quillandmouse.com> writes:
>> 3. Am I correct in assuming that you need to specify a database in order
>> to connect to PostgreSQL, and that, on a "virgin" system, template1 is
>> the database provided for that purpose? If it isn't necessary to specify
>> a database in order to connect, how would you otherwise do it?

> You are correct.  The best practice is to stay out of template1 unless
> you are creating a new database or adding stuff to template1.

It's worth noting that there's a conflict between the use of template1
as the default template for CREATE DATABASE, versus its use as the
default database-to-connect-to for scripts like createuser.  You could
get a failure from CREATE DATABASE if someone happens to be transiently
connected to template1 while creating a user or whatever.

This is a historical accident that arises from the fact that template1
is the only certain-to-exist database name (other than template0 which
is a recent innovation).  We're probably going to have to change some
of this stuff eventually...

            regards, tom lane

pgsql-general by date:

Previous
From: "Thomas T. Thai"
Date:
Subject: pg_restore and adding a column
Next
From: Tom Lane
Date:
Subject: Re: fieldwidths