On Wed, Mar 19, 2003 at 11:35:53PM -0500, Tom Lane wrote:
> Paul M Foster <paulf@quillandmouse.com> writes:
> >> What is the exact error you're getting in the C program?
>
> > ERROR: CREATE DATABASE: source database "template1" is being accessed by
> > other users
>
> Please note this is CREATE DATABASE complaining, *not* connection
> establishment. You can't create a database by cloning an open database
> (there are not locks that would make this safe). Either don't use
> template1 for normal operations, or use template0 as the template for
> CREATE DATABASE.
Excuse my ignorance here.
I'll summarize, and someone can tell me if I'm wrong.
1. So when you create a database, the system uses the open database
you're connected to as a "template" unless you specify otherwise with a
"WITH TEMPLATE = " clause?
2. Since template0 does not accept connections, can I assume that it
exists for the sole purpose of acting as a template for the creation of
other databases?
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?
Paul