Commit 6f7fc0ba authored by Tom Lane's avatar Tom Lane

Cause initdb to create a third standard database "postgres", which

unlike template0 and template1 does not have any special status in
terms of backend functionality.  However, all external utilities such
as createuser and createdb now connect to "postgres" instead of
template1, and the documentation is changed to encourage people to use
"postgres" instead of template1 as a play area.  This should fix some
longstanding gotchas involving unexpected propagation of database
objects by createdb (when you used template1 without understanding
the implications), as well as ameliorating the problem that CREATE
DATABASE is unhappy if anyone else is connected to template1.
Patch by Dave Page, minor editing by Tom Lane.  All per recent
pghackers discussions.
parent ec3a1af0
...@@ -28,13 +28,13 @@ Outputs ...@@ -28,13 +28,13 @@ Outputs
Example usage Example usage
select dblink_connect('dbname=template1'); select dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
select dblink_connect('myconn','dbname=template1'); select dblink_connect('myconn','dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
......
...@@ -44,7 +44,7 @@ Note ...@@ -44,7 +44,7 @@ Note
Example usage Example usage
test=# select dblink_connect('dbname=template1'); test=# select dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
...@@ -94,7 +94,7 @@ Outputs ...@@ -94,7 +94,7 @@ Outputs
Example usage Example usage
test=# select dblink_connect('dbname=template1'); test=# select dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
...@@ -175,7 +175,7 @@ Note ...@@ -175,7 +175,7 @@ Note
Example usage Example usage
test=# select dblink_connect('dbname=template1'); test=# select dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
......
...@@ -17,10 +17,10 @@ Outputs ...@@ -17,10 +17,10 @@ Outputs
Example usage Example usage
test=# select dblink_current_query() from (select dblink('dbname=template1','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1; test=# select dblink_current_query() from (select dblink('dbname=postgres','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1;
dblink_current_query dblink_current_query
----------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------
select dblink_current_query() from (select dblink('dbname=template1','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1; select dblink_current_query() from (select dblink('dbname=postgres','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1;
(1 row) (1 row)
================================================================== ==================================================================
......
...@@ -37,7 +37,7 @@ Outputs ...@@ -37,7 +37,7 @@ Outputs
Example usage Example usage
select * from dblink('dbname=template1','select proname, prosrc from pg_proc') select * from dblink('dbname=postgres','select proname, prosrc from pg_proc')
as t1(proname name, prosrc text) where proname like 'bytea%'; as t1(proname name, prosrc text) where proname like 'bytea%';
proname | prosrc proname | prosrc
------------+------------ ------------+------------
...@@ -55,7 +55,7 @@ select * from dblink('dbname=template1','select proname, prosrc from pg_proc') ...@@ -55,7 +55,7 @@ select * from dblink('dbname=template1','select proname, prosrc from pg_proc')
byteaout | byteaout byteaout | byteaout
(12 rows) (12 rows)
select dblink_connect('dbname=template1'); select dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
...@@ -111,7 +111,7 @@ A more convenient way to use dblink may be to create a view: ...@@ -111,7 +111,7 @@ A more convenient way to use dblink may be to create a view:
create view myremote_pg_proc as create view myremote_pg_proc as
select * select *
from dblink('dbname=template1','select proname, prosrc from pg_proc') from dblink('dbname=postgres','select proname, prosrc from pg_proc')
as t1(proname name, prosrc text); as t1(proname name, prosrc text);
Then you can simply write: Then you can simply write:
......
...@@ -518,7 +518,7 @@ main(int argc, char **argv) ...@@ -518,7 +518,7 @@ main(int argc, char **argv)
if (my_opts->dbname == NULL) if (my_opts->dbname == NULL)
{ {
my_opts->dbname = "template1"; my_opts->dbname = "postgres";
my_opts->nodb = true; my_opts->nodb = true;
} }
pgconn = sql_conn(my_opts); pgconn = sql_conn(my_opts);
......
#!/bin/sh #!/bin/sh
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# Package : reindexdb Version : $Revision: 1.5 $ # Package : reindexdb Version : $Revision: 1.6 $
# Date : 05/08/2002 Author : Shaun Thomas # Date : 05/08/2002 Author : Shaun Thomas
# Req : psql, sh, perl, sed Type : Utility # Req : psql, sh, perl, sed Type : Utility
# #
...@@ -174,7 +174,7 @@ if [ "$alldb" ]; then ...@@ -174,7 +174,7 @@ if [ "$alldb" ]; then
# connect to. That's the list we'll be using. It's also why it's # connect to. That's the list we'll be using. It's also why it's
# a good idea for this to be run as a super-user. # a good idea for this to be run as a super-user.
sql='SELECT datname FROM pg_database WHERE datallowconn' sql='SELECT datname FROM pg_database WHERE datallowconn'
dbname=`$PSQL $PSQLOPT -q -t -A -d template1 -c "$sql"` dbname=`$PSQL $PSQLOPT -q -t -A -d postgres -c "$sql"`
# Ok, if it's not all databases, make sure at least one database is # Ok, if it's not all databases, make sure at least one database is
# specified before continuing. # specified before continuing.
......
...@@ -159,7 +159,7 @@ Any number (rules 5,6) -- creates a zero-length segment (a point, ...@@ -159,7 +159,7 @@ Any number (rules 5,6) -- creates a zero-length segment (a point,
boundaries. For example, it adds an extra digit to the lower boundaries. For example, it adds an extra digit to the lower
boundary if the resulting interval includes a power of ten: boundary if the resulting interval includes a power of ten:
template1=> select '10(+-)1'::seg as seg; postgres=> select '10(+-)1'::seg as seg;
seg seg
--------- ---------
9.0 .. 11 -- should be: 9 .. 11 9.0 .. 11 -- should be: 9 .. 11
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.66 2005/06/20 13:52:17 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.67 2005/06/21 04:02:29 tgl Exp $
--> -->
<chapter id="backup"> <chapter id="backup">
<title>Backup and Restore</title> <title>Backup and Restore</title>
...@@ -177,11 +177,11 @@ pg_dumpall &gt; <replaceable>outfile</> ...@@ -177,11 +177,11 @@ pg_dumpall &gt; <replaceable>outfile</>
</synopsis> </synopsis>
The resulting dump can be restored with <application>psql</>: The resulting dump can be restored with <application>psql</>:
<synopsis> <synopsis>
psql -f <replaceable class="parameter">infile</replaceable> template1 psql -f <replaceable class="parameter">infile</replaceable> postgres
</synopsis> </synopsis>
(Actually, you can specify any existing database name to start from, (Actually, you can specify any existing database name to start from,
but if you are reloading in an empty cluster then <literal>template1</> but if you are reloading in an empty cluster then <literal>postgres</>
is the only available choice.) It is always necessary to have should generally be used.) It is always necessary to have
database superuser access when restoring a <application>pg_dumpall</> database superuser access when restoring a <application>pg_dumpall</>
dump, as that is required to restore the user and group information. dump, as that is required to restore the user and group information.
</para> </para>
...@@ -1223,7 +1223,7 @@ restore_command = 'copy /mnt/server/archivedir/%f "%p"' # Windows ...@@ -1223,7 +1223,7 @@ restore_command = 'copy /mnt/server/archivedir/%f "%p"' # Windows
in parallel, on different ports. Then you can use something like in parallel, on different ports. Then you can use something like
<programlisting> <programlisting>
pg_dumpall -p 5432 | psql -d template1 -p 6543 pg_dumpall -p 5432 | psql -d postgres -p 6543
</programlisting> </programlisting>
to transfer your data. Or use an intermediate file if you want. to transfer your data. Or use an intermediate file if you want.
...@@ -1256,7 +1256,7 @@ cd ~/postgresql-&version; ...@@ -1256,7 +1256,7 @@ cd ~/postgresql-&version;
gmake install gmake install
initdb -D /usr/local/pgsql/data initdb -D /usr/local/pgsql/data
postmaster -D /usr/local/pgsql/data postmaster -D /usr/local/pgsql/data
psql -f backup template1 psql -f backup postgres
</programlisting> </programlisting>
See <xref linkend="runtime"> about ways to start and stop the See <xref linkend="runtime"> about ways to start and stop the
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/charset.sgml,v 2.72 2005/04/16 16:50:01 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/charset.sgml,v 2.73 2005/06/21 04:02:29 tgl Exp $ -->
<chapter id="charset"> <chapter id="charset">
<title>Localization</> <title>Localization</>
...@@ -647,6 +647,7 @@ $ <userinput>psql -l</userinput> ...@@ -647,6 +647,7 @@ $ <userinput>psql -l</userinput>
euc_kr | t-ishii | EUC_KR euc_kr | t-ishii | EUC_KR
euc_tw | t-ishii | EUC_TW euc_tw | t-ishii | EUC_TW
mule_internal | t-ishii | MULE_INTERNAL mule_internal | t-ishii | MULE_INTERNAL
postgres | t-ishii | EUC_JP
regression | t-ishii | SQL_ASCII regression | t-ishii | SQL_ASCII
template1 | t-ishii | EUC_JP template1 | t-ishii | EUC_JP
test | t-ishii | EUC_JP test | t-ishii | EUC_JP
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.80 2005/06/04 20:42:41 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.81 2005/06/21 04:02:29 tgl Exp $
--> -->
<chapter id="client-authentication"> <chapter id="client-authentication">
...@@ -452,17 +452,17 @@ host all all 127.0.0.1/32 trust ...@@ -452,17 +452,17 @@ host all all 127.0.0.1/32 trust
host all all 127.0.0.1 255.255.255.255 trust host all all 127.0.0.1 255.255.255.255 trust
# Allow any user from any host with IP address 192.168.93.x to connect # Allow any user from any host with IP address 192.168.93.x to connect
# to database "template1" as the same user name that ident reports for # to database "postgres" as the same user name that ident reports for
# the connection (typically the Unix user name). # the connection (typically the Unix user name).
# #
# TYPE DATABASE USER CIDR-ADDRESS METHOD # TYPE DATABASE USER CIDR-ADDRESS METHOD
host template1 all 192.168.93.0/24 ident sameuser host postgres all 192.168.93.0/24 ident sameuser
# Allow a user from host 192.168.12.10 to connect to database # Allow a user from host 192.168.12.10 to connect to database
# "template1" if the user's password is correctly supplied. # "postgres" if the user's password is correctly supplied.
# #
# TYPE DATABASE USER CIDR-ADDRESS METHOD # TYPE DATABASE USER CIDR-ADDRESS METHOD
host template1 all 192.168.12.10/32 md5 host postgres all 192.168.12.10/32 md5
# In the absence of preceding "host" lines, these two lines will # In the absence of preceding "host" lines, these two lines will
# reject all connection from 192.168.54.1 (since that entry will be # reject all connection from 192.168.54.1 (since that entry will be
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.235 2005/06/12 15:51:50 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.236 2005/06/21 04:02:29 tgl Exp $ -->
<chapter id="installation"> <chapter id="installation">
<title><![%standalone-include[<productname>PostgreSQL</>]]> <title><![%standalone-include[<productname>PostgreSQL</>]]>
...@@ -468,7 +468,7 @@ su - postgres ...@@ -468,7 +468,7 @@ su - postgres
</programlisting> </programlisting>
Finally, restore your data with Finally, restore your data with
<screen> <screen>
<userinput>/usr/local/pgsql/bin/psql -d template1 -f <replaceable>outputfile</></userinput> <userinput>/usr/local/pgsql/bin/psql -d postgres -f <replaceable>outputfile</></userinput>
</screen> </screen>
using the <emphasis>new</> <application>psql</>. using the <emphasis>new</> <application>psql</>.
</para> </para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.185 2005/06/12 00:00:20 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.186 2005/06/21 04:02:29 tgl Exp $
--> -->
<chapter id="libpq"> <chapter id="libpq">
...@@ -4230,14 +4230,14 @@ main(int argc, char **argv) ...@@ -4230,14 +4230,14 @@ main(int argc, char **argv)
/* /*
* If the user supplies a parameter on the command line, use it as * If the user supplies a parameter on the command line, use it as
* the conninfo string; otherwise default to setting dbname=template1 * the conninfo string; otherwise default to setting dbname=postgres
* and using environment variables or defaults for all other connection * and using environment variables or defaults for all other connection
* parameters. * parameters.
*/ */
if (argc &gt; 1) if (argc &gt; 1)
conninfo = argv[1]; conninfo = argv[1];
else else
conninfo = "dbname = template1"; conninfo = "dbname = postgres";
/* Make a connection to the database */ /* Make a connection to the database */
conn = PQconnectdb(conninfo); conn = PQconnectdb(conninfo);
...@@ -4376,14 +4376,14 @@ main(int argc, char **argv) ...@@ -4376,14 +4376,14 @@ main(int argc, char **argv)
/* /*
* If the user supplies a parameter on the command line, use it as * If the user supplies a parameter on the command line, use it as
* the conninfo string; otherwise default to setting dbname=template1 * the conninfo string; otherwise default to setting dbname=postgres
* and using environment variables or defaults for all other connection * and using environment variables or defaults for all other connection
* parameters. * parameters.
*/ */
if (argc &gt; 1) if (argc &gt; 1)
conninfo = argv[1]; conninfo = argv[1];
else else
conninfo = "dbname = template1"; conninfo = "dbname = postgres";
/* Make a connection to the database */ /* Make a connection to the database */
conn = PQconnectdb(conninfo); conn = PQconnectdb(conninfo);
...@@ -4518,14 +4518,14 @@ main(int argc, char **argv) ...@@ -4518,14 +4518,14 @@ main(int argc, char **argv)
/* /*
* If the user supplies a parameter on the command line, use it as * If the user supplies a parameter on the command line, use it as
* the conninfo string; otherwise default to setting dbname=template1 * the conninfo string; otherwise default to setting dbname=postgres
* and using environment variables or defaults for all other connection * and using environment variables or defaults for all other connection
* parameters. * parameters.
*/ */
if (argc &gt; 1) if (argc &gt; 1)
conninfo = argv[1]; conninfo = argv[1];
else else
conninfo = "dbname = template1"; conninfo = "dbname = postgres";
/* Make a connection to the database */ /* Make a connection to the database */
conn = PQconnectdb(conninfo); conn = PQconnectdb(conninfo);
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.41 2005/06/13 02:40:04 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.42 2005/06/21 04:02:30 tgl Exp $
--> -->
<chapter id="managing-databases"> <chapter id="managing-databases">
...@@ -113,17 +113,20 @@ CREATE DATABASE <replaceable>name</>; ...@@ -113,17 +113,20 @@ CREATE DATABASE <replaceable>name</>;
<command>initdb</> command when the data storage area is <command>initdb</> command when the data storage area is
initialized. (See <xref linkend="creating-cluster">.) This initialized. (See <xref linkend="creating-cluster">.) This
database is called database is called
<literal>template1</>.<indexterm><primary>template1</></> So to <literal>postgres</>.<indexterm><primary>postgres</></> So to
create the first <quote>real</> database you can connect to create the first <quote>ordinary</> database you can connect to
<literal>template1</>. <literal>postgres</>.
</para> </para>
<para> <para>
The name <literal>template1</literal> is no accident: when a new A second database,
database is created, the template database is essentially cloned. <literal>template1</literal>,<indexterm><primary>template1</></>
is also created by
<command>initdb</>. Whenever a new database is created within the
cluster, <literal>template1</literal> is essentially cloned.
This means that any changes you make in <literal>template1</> are This means that any changes you make in <literal>template1</> are
propagated to all subsequently created databases. This implies that propagated to all subsequently created databases. Therefore it is
you should not use the template database for real work, but when unwise to use <literal>template1</> for real work, but when
used judiciously this feature can be convenient. More details used judiciously this feature can be convenient. More details
appear in <xref linkend="manage-ag-templatedbs">. appear in <xref linkend="manage-ag-templatedbs">.
</para> </para>
...@@ -137,7 +140,7 @@ CREATE DATABASE <replaceable>name</>; ...@@ -137,7 +140,7 @@ CREATE DATABASE <replaceable>name</>;
createdb <replaceable class="parameter">dbname</replaceable> createdb <replaceable class="parameter">dbname</replaceable>
</synopsis> </synopsis>
<command>createdb</> does no magic. It connects to the <literal>template1</> <command>createdb</> does no magic. It connects to the <literal>postgres</>
database and issues the <command>CREATE DATABASE</> command, database and issues the <command>CREATE DATABASE</> command,
exactly as described above. exactly as described above.
The <xref linkend="app-createdb"> reference page contains the invocation The <xref linkend="app-createdb"> reference page contains the invocation
...@@ -268,13 +271,19 @@ createdb -T template0 <replaceable>dbname</> ...@@ -268,13 +271,19 @@ createdb -T template0 <replaceable>dbname</>
<para> <para>
<literal>template1</> and <literal>template0</> do not have any special <literal>template1</> and <literal>template0</> do not have any special
status beyond the fact that the name <literal>template1</> is the default status beyond the fact that the name <literal>template1</> is the default
source database name for <command>CREATE DATABASE</> and the default source database name for <command>CREATE DATABASE</>.
database-to-connect-to for various programs such as <command>createdb</>.
For example, one could drop <literal>template1</> and recreate it from For example, one could drop <literal>template1</> and recreate it from
<literal>template0</> without any ill effects. This course of action <literal>template0</> without any ill effects. This course of action
might be advisable if one has carelessly added a bunch of junk in might be advisable if one has carelessly added a bunch of junk in
<literal>template1</>. <literal>template1</>.
</para> </para>
<para>
The <literal>postgres</> database is also created when a database
cluster is initialized. This database is meant as a default database for
users and applications to connect to. It is simply a copy of
<literal>template1</> and may be dropped and recreated if required.
</para>
</note> </note>
</sect1> </sect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/createlang.sgml,v 1.34 2005/05/29 03:32:18 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/createlang.sgml,v 1.35 2005/06/21 04:02:31 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -223,6 +223,9 @@ PostgreSQL documentation ...@@ -223,6 +223,9 @@ PostgreSQL documentation
<screen> <screen>
<prompt>$ </prompt><userinput>createlang pltcl template1</userinput> <prompt>$ </prompt><userinput>createlang pltcl template1</userinput>
</screen> </screen>
Note that installing the language into <literal>template1</literal>
will cause it to be automatically installed into subsequently-created
databases as well.
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_database.sgml,v 1.19 2003/11/29 19:51:38 pgsql Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/drop_database.sgml,v 1.20 2005/06/21 04:02:31 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -32,7 +32,7 @@ DROP DATABASE <replaceable class="PARAMETER">name</replaceable> ...@@ -32,7 +32,7 @@ DROP DATABASE <replaceable class="PARAMETER">name</replaceable>
catalog entries for the database and deletes the directory catalog entries for the database and deletes the directory
containing the data. It can only be executed by the database owner. containing the data. It can only be executed by the database owner.
Also, it cannot be executed while you or anyone else are connected Also, it cannot be executed while you or anyone else are connected
to the target database. (Connect to <literal>template1</literal> or any to the target database. (Connect to <literal>postgres</literal> or any
other database to issue this command.) other database to issue this command.)
</para> </para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/initdb.sgml,v 1.34 2005/02/22 02:54:19 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/initdb.sgml,v 1.35 2005/06/21 04:02:31 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -47,9 +47,12 @@ PostgreSQL documentation ...@@ -47,9 +47,12 @@ PostgreSQL documentation
which the database data will live, generating the shared catalog which the database data will live, generating the shared catalog
tables (tables that belong to the whole cluster rather than to any tables (tables that belong to the whole cluster rather than to any
particular database), and creating the <literal>template1</literal> particular database), and creating the <literal>template1</literal>
database. When you later create a new database, everything in the and <literal>postgres</literal> databases. When you later create a
<literal>template1</literal> database is copied. It contains catalog new database, everything in the <literal>template1</literal> database is
tables containing things like built-in data types. copied. (Therefore, anything installed in <literal>template1</literal>
is automatically copied into each database created later.)
The <literal>postgres</literal> database is a default database meant
for use by users, utilities and third party applications.
</para> </para>
<para> <para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.49 2005/05/29 03:32:18 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.50 2005/06/21 04:02:31 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -401,7 +401,7 @@ PostgreSQL documentation ...@@ -401,7 +401,7 @@ PostgreSQL documentation
<para> <para>
To reload this database use, for example: To reload this database use, for example:
<screen> <screen>
<prompt>$</prompt> <userinput>psql -f db.out template1</userinput> <prompt>$</prompt> <userinput>psql -f db.out postgres</userinput>
</screen> </screen>
(It is not important to which database you connect here since the (It is not important to which database you connect here since the
script file created by <application>pg_dumpall</application> will script file created by <application>pg_dumpall</application> will
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.329 2005/06/17 22:32:42 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.330 2005/06/21 04:02:30 tgl Exp $
--> -->
<chapter Id="runtime"> <chapter Id="runtime">
...@@ -54,8 +54,13 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.329 2005/06/17 22:32:42 tgl Exp ...@@ -54,8 +54,13 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.329 2005/06/17 22:32:42 tgl Exp
(<acronym>SQL</acronym> uses the term catalog cluster.) A (<acronym>SQL</acronym> uses the term catalog cluster.) A
database cluster is a collection of databases that is managed by a database cluster is a collection of databases that is managed by a
single instance of a running database server. After initialization, a single instance of a running database server. After initialization, a
database cluster will contain a database named database cluster will contain a database named <literal>postgres</literal>,
<literal>template1</literal>. As the name suggests, this will be used which is meant as a default database for use by utilities, users and third
party applications. The database server itself does not require the
<literal>postgres</literal> database to exist, but many external utility
programs assume it exists. Another database created within each cluster
during initialization is called
<literal>template1</literal>. As the name suggests, this will be used
as a template for subsequently created databases; it should not be as a template for subsequently created databases; it should not be
used for actual work. (See <xref linkend="managing-databases"> for used for actual work. (See <xref linkend="managing-databases"> for
information about creating new databases within a cluster.) information about creating new databases within a cluster.)
...@@ -5319,7 +5324,7 @@ ssh -L 3333:foo.com:5432 joe@foo.com ...@@ -5319,7 +5324,7 @@ ssh -L 3333:foo.com:5432 joe@foo.com
to connect to. In order to connect to the database server using to connect to. In order to connect to the database server using
this tunnel, you connect to port 3333 on the local machine: this tunnel, you connect to port 3333 on the local machine:
<programlisting> <programlisting>
psql -h localhost -p 3333 template1 psql -h localhost -p 3333 postgres
</programlisting> </programlisting>
To the database server it will then look as though you are really To the database server it will then look as though you are really
user <literal>joe@foo.com</literal> and it will use whatever user <literal>joe@foo.com</literal> and it will use whatever
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/start.sgml,v 1.38 2005/01/08 01:44:08 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/start.sgml,v 1.39 2005/06/21 04:02:30 tgl Exp $
--> -->
<chapter id="tutorial-start"> <chapter id="tutorial-start">
...@@ -183,7 +183,7 @@ createdb: command not found ...@@ -183,7 +183,7 @@ createdb: command not found
<para> <para>
Another response could be this: Another response could be this:
<screen> <screen>
createdb: could not connect to database template1: could not connect to server: createdb: could not connect to database postgres: could not connect to server:
No such file or directory No such file or directory
Is the server running locally and accepting Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"? connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
...@@ -196,7 +196,7 @@ No such file or directory ...@@ -196,7 +196,7 @@ No such file or directory
<para> <para>
Another response could be this: Another response could be this:
<screen> <screen>
createdb: could not connect to database template1: FATAL: user "joe" does not createdb: could not connect to database postgres: FATAL: user "joe" does not
exist exist
</screen> </screen>
where your own login name is mentioned. This will happen if the where your own login name is mentioned. This will happen if the
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.159 2005/06/06 20:22:57 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.160 2005/06/21 04:02:31 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -93,7 +93,7 @@ createdb(const CreatedbStmt *stmt) ...@@ -93,7 +93,7 @@ createdb(const CreatedbStmt *stmt)
DefElem *dencoding = NULL; DefElem *dencoding = NULL;
char *dbname = stmt->dbname; char *dbname = stmt->dbname;
char *dbowner = NULL; char *dbowner = NULL;
char *dbtemplate = NULL; const char *dbtemplate = NULL;
int encoding = -1; int encoding = -1;
#ifndef WIN32 #ifndef WIN32
......
...@@ -8,14 +8,19 @@ ...@@ -8,14 +8,19 @@
* *
* To create the database cluster, we create the directory that contains * To create the database cluster, we create the directory that contains
* all its data, create the files that hold the global tables, create * all its data, create the files that hold the global tables, create
* a few other control files for it, and create two databases: the * a few other control files for it, and create three databases: the
* template0 and template1 databases. * template databases "template0" and "template1", and a default user
* database "postgres".
* *
* The template databases are ordinary PostgreSQL databases. template0 * The template databases are ordinary PostgreSQL databases. template0
* is never supposed to change after initdb, whereas template1 can be * is never supposed to change after initdb, whereas template1 can be
* changed to add site-local standard data. Either one can be copied * changed to add site-local standard data. Either one can be copied
* to produce a new database. * to produce a new database.
* *
* For largely-historical reasons, the template1 database is the one built
* by the basic bootstrap process. After it is complete, template0 and
* the default database, postgres, are made just by copying template1.
*
* To create template1, we run the postgres (backend) program in bootstrap * To create template1, we run the postgres (backend) program in bootstrap
* mode and feed it data from the postgres.bki library file. After this * mode and feed it data from the postgres.bki library file. After this
* initial bootstrap phase, some additional stuff is created by normal * initial bootstrap phase, some additional stuff is created by normal
...@@ -23,12 +28,10 @@ ...@@ -23,12 +28,10 @@
* just embedded into this program (yeah, it's ugly), but larger chunks * just embedded into this program (yeah, it's ugly), but larger chunks
* are taken from script files. * are taken from script files.
* *
* template0 is made just by copying the completed template1.
* *
* Note: * Note:
* The program has some memory leakage - it isn't worth cleaning it up. * The program has some memory leakage - it isn't worth cleaning it up.
* *
*
* This is a C implementation of the previous shell script for setting up a * This is a C implementation of the previous shell script for setting up a
* PostgreSQL cluster location, and should be highly compatible with it. * PostgreSQL cluster location, and should be highly compatible with it.
* author of C translation: Andrew Dunstan mailto:andrew@dunslane.net * author of C translation: Andrew Dunstan mailto:andrew@dunslane.net
...@@ -39,7 +42,7 @@ ...@@ -39,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * Portions taken from FreeBSD.
* *
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.84 2005/06/17 22:32:47 tgl Exp $ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.85 2005/06/21 04:02:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -178,6 +181,7 @@ static void set_info_version(void); ...@@ -178,6 +181,7 @@ static void set_info_version(void);
static void setup_schema(void); static void setup_schema(void);
static void vacuum_db(void); static void vacuum_db(void);
static void make_template0(void); static void make_template0(void);
static void make_postgres(void);
static void trapsig(int signum); static void trapsig(int signum);
static void check_ok(void); static void check_ok(void);
static char *escape_quotes(const char *src); static char *escape_quotes(const char *src);
...@@ -1846,7 +1850,7 @@ make_template0(void) ...@@ -1846,7 +1850,7 @@ make_template0(void)
* We use the OID of template0 to determine lastsysoid * We use the OID of template0 to determine lastsysoid
*/ */
"UPDATE pg_database SET datlastsysoid = " "UPDATE pg_database SET datlastsysoid = "
" (SELECT oid::int4 - 1 FROM pg_database " " (SELECT oid FROM pg_database "
" WHERE datname = 'template0');\n", " WHERE datname = 'template0');\n",
/* /*
...@@ -1882,6 +1886,37 @@ make_template0(void) ...@@ -1882,6 +1886,37 @@ make_template0(void)
check_ok(); check_ok();
} }
/*
* copy template1 to postgres
*/
static void
make_postgres(void)
{
PG_CMD_DECL;
char **line;
static char *postgres_setup[] = {
"CREATE DATABASE postgres;\n",
NULL
};
fputs(_("copying template1 to postgres ... "), stdout);
fflush(stdout);
snprintf(cmd, sizeof(cmd),
"\"%s\" %s template1 >%s",
backend_exec, backend_options,
DEVNULL);
PG_CMD_OPEN;
for (line = postgres_setup; *line; line++)
PG_CMD_PUTS(*line);
PG_CMD_CLOSE;
check_ok();
}
/* /*
* signal handler in case we are interrupted. * signal handler in case we are interrupted.
...@@ -2609,6 +2644,8 @@ main(int argc, char *argv[]) ...@@ -2609,6 +2644,8 @@ main(int argc, char *argv[])
make_template0(); make_template0();
make_postgres();
if (authwarning != NULL) if (authwarning != NULL)
fprintf(stderr, "%s", authwarning); fprintf(stderr, "%s", authwarning);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.57 2005/05/04 22:35:15 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.58 2005/06/21 04:02:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -442,7 +442,7 @@ test_postmaster_connection(void) ...@@ -442,7 +442,7 @@ test_postmaster_connection(void)
for (i = 0; i < wait_seconds; i++) for (i = 0; i < wait_seconds; i++)
{ {
if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL, if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
"template1", NULL, NULL)) != NULL && "postgres", NULL, NULL)) != NULL &&
(PQstatus(conn) == CONNECTION_OK || (PQstatus(conn) == CONNECTION_OK ||
(strcmp(PQerrorMessage(conn), (strcmp(PQerrorMessage(conn),
PQnoPasswordSupplied) == 0))) PQnoPasswordSupplied) == 0)))
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* *
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.59 2005/04/18 23:47:52 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.60 2005/06/21 04:02:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -297,13 +297,13 @@ main(int argc, char *argv[]) ...@@ -297,13 +297,13 @@ main(int argc, char *argv[])
} }
conn = connectDatabase("template1", pghost, pgport, pguser, force_password); conn = connectDatabase("postgres", pghost, pgport, pguser, force_password);
printf("--\n-- PostgreSQL database cluster dump\n--\n\n"); printf("--\n-- PostgreSQL database cluster dump\n--\n\n");
if (verbose) if (verbose)
dumpTimestamp("Started on"); dumpTimestamp("Started on");
printf("\\connect \"template1\"\n\n"); printf("\\connect \"postgres\"\n\n");
if (!data_only) if (!data_only)
{ {
...@@ -880,7 +880,7 @@ runPgDump(const char *dbname) ...@@ -880,7 +880,7 @@ runPgDump(const char *dbname)
/* /*
* Win32 has to use double-quotes for args, rather than single quotes. * Win32 has to use double-quotes for args, rather than single quotes.
* Strangely enough, this is the only place we pass a database name on * Strangely enough, this is the only place we pass a database name on
* the command line, except template1 that doesn't need quoting. * the command line, except "postgres" which doesn't need quoting.
*/ */
#ifndef WIN32 #ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin, appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.117 2005/06/14 02:57:41 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.118 2005/06/21 04:02:33 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -195,7 +195,7 @@ main(int argc, char *argv[]) ...@@ -195,7 +195,7 @@ main(int argc, char *argv[])
{ {
need_pass = false; need_pass = false;
pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL, pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
options.action == ACT_LIST_DB ? "template1" : options.dbname, options.action == ACT_LIST_DB ? "postgres" : options.dbname,
username, password); username, password);
if (PQstatus(pset.db) == CONNECTION_BAD && if (PQstatus(pset.db) == CONNECTION_BAD &&
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 2002-2005, PostgreSQL Global Development Group * Portions Copyright (c) 2002-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.12 2005/01/01 05:43:08 momjian Exp $ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.13 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -207,7 +207,7 @@ cluster_all_databases(const char *host, const char *port, ...@@ -207,7 +207,7 @@ cluster_all_databases(const char *host, const char *port,
PGresult *result; PGresult *result;
int i; int i;
conn = connectDatabase("template1", host, port, username, password, progname); conn = connectDatabase("postgres", host, port, username, password, progname);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo);
PQfinish(conn); PQfinish(conn);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.14 2004/12/31 22:03:17 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.15 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -157,7 +157,8 @@ main(int argc, char *argv[]) ...@@ -157,7 +157,8 @@ main(int argc, char *argv[])
appendPQExpBuffer(&sql, " TEMPLATE %s", fmtId(template)); appendPQExpBuffer(&sql, " TEMPLATE %s", fmtId(template));
appendPQExpBuffer(&sql, ";\n"); appendPQExpBuffer(&sql, ";\n");
conn = connectDatabase("template1", host, port, username, password, progname); conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres",
host, port, username, password, progname);
if (echo) if (echo)
printf("%s", sql.data); printf("%s", sql.data);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.16 2004/12/31 22:03:17 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.17 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -209,7 +209,7 @@ main(int argc, char *argv[]) ...@@ -209,7 +209,7 @@ main(int argc, char *argv[])
appendPQExpBuffer(&sql, " NOCREATEUSER"); appendPQExpBuffer(&sql, " NOCREATEUSER");
appendPQExpBuffer(&sql, ";\n"); appendPQExpBuffer(&sql, ";\n");
conn = connectDatabase("template1", host, port, username, password, progname); conn = connectDatabase("postgres", host, port, username, password, progname);
if (echo) if (echo)
printf("%s", sql.data); printf("%s", sql.data);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.14 2004/12/31 22:03:17 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.15 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -117,7 +117,8 @@ main(int argc, char *argv[]) ...@@ -117,7 +117,8 @@ main(int argc, char *argv[])
appendPQExpBuffer(&sql, "DROP DATABASE %s;\n", appendPQExpBuffer(&sql, "DROP DATABASE %s;\n",
fmtId(dbname)); fmtId(dbname));
conn = connectDatabase("template1", host, port, username, password, progname); conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres",
host, port, username, password, progname);
if (echo) if (echo)
printf("%s", sql.data); printf("%s", sql.data);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.13 2004/12/31 22:03:17 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.14 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -116,7 +116,7 @@ main(int argc, char *argv[]) ...@@ -116,7 +116,7 @@ main(int argc, char *argv[])
initPQExpBuffer(&sql); initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "DROP USER %s;\n", fmtId(dropuser)); appendPQExpBuffer(&sql, "DROP USER %s;\n", fmtId(dropuser));
conn = connectDatabase("template1", host, port, username, password, progname); conn = connectDatabase("postgres", host, port, username, password, progname);
if (echo) if (echo)
printf("%s", sql.data); printf("%s", sql.data);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.12 2004/12/31 22:03:17 pgsql Exp $ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.13 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -233,7 +233,7 @@ vacuum_all_databases(bool full, bool verbose, bool analyze, ...@@ -233,7 +233,7 @@ vacuum_all_databases(bool full, bool verbose, bool analyze,
PGresult *result; PGresult *result;
int i; int i;
conn = connectDatabase("template1", host, port, username, password, progname); conn = connectDatabase("postgres", host, port, username, password, progname);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo);
PQfinish(conn); PQfinish(conn);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.279 2005/06/20 10:29:37 teodor Exp $ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.280 2005/06/21 04:02:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200506201 #define CATALOG_VERSION_NO 200506202
#endif #endif
...@@ -13,7 +13,7 @@ int main() ...@@ -13,7 +13,7 @@ int main()
if (getenv("SQLOPT")) ECPGdebug(1,stderr); if (getenv("SQLOPT")) ECPGdebug(1,stderr);
exec sql whenever sqlerror do sqlprint(); exec sql whenever sqlerror do sqlprint();
exec sql connect to template1; exec sql connect to postgres;
exec sql allocate descriptor mydesc; exec sql allocate descriptor mydesc;
exec sql select tablename into descriptor mydesc from pg_tables; exec sql select tablename into descriptor mydesc from pg_tables;
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
# A service is a set of named connection parameters. You may specify # A service is a set of named connection parameters. You may specify
# multiple services in this file. Each starts with a service name in # multiple services in this file. Each starts with a service name in
# brackets. Subsequent lines have connection configuration parameters of # brackets. Subsequent lines have connection configuration parameters of
# the pattern "param=value". A sample configuration for template1 is # the pattern "param=value". A sample configuration for postgres is
# included in this file. Lines beginning with '#' are comments. # included in this file. Lines beginning with '#' are comments.
# #
# Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and # Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
# rename it pg_service.conf. # rename it pg_service.conf.
# #
# #
#[template1] #[postgres]
#dbname=template1 #dbname=postgres
#user=postgres #user=postgres
#!/bin/sh #!/bin/sh
# $PostgreSQL: pgsql/src/test/bench/create.sh,v 1.4 2004/09/01 17:25:40 tgl Exp $ # $PostgreSQL: pgsql/src/test/bench/create.sh,v 1.5 2005/06/21 04:02:34 tgl Exp $
# #
if [ ! -d $1 ]; then if [ ! -d $1 ]; then
echo " you must specify a valid data directory " >&2 echo " you must specify a valid data directory " >&2
...@@ -10,10 +10,10 @@ if [ -d ./obj ]; then ...@@ -10,10 +10,10 @@ if [ -d ./obj ]; then
fi fi
echo =============== destroying old bench database... ================= echo =============== destroying old bench database... =================
echo "drop database bench" | postgres -D${1} template1 > /dev/null echo "drop database bench" | postgres -D${1} postgres > /dev/null
echo =============== creating new bench database... ================= echo =============== creating new bench database... =================
echo "create database bench" | postgres -D${1} template1 > /dev/null echo "create database bench" | postgres -D${1} postgres > /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo createdb failed echo createdb failed
exit 1 exit 1
......
...@@ -26,14 +26,14 @@ main(int argc, char **argv) ...@@ -26,14 +26,14 @@ main(int argc, char **argv)
/* /*
* If the user supplies a parameter on the command line, use it as the * If the user supplies a parameter on the command line, use it as the
* conninfo string; otherwise default to setting dbname=template1 and * conninfo string; otherwise default to setting dbname=postgres and
* using environment variables or defaults for all other connection * using environment variables or defaults for all other connection
* parameters. * parameters.
*/ */
if (argc > 1) if (argc > 1)
conninfo = argv[1]; conninfo = argv[1];
else else
conninfo = "dbname = template1"; conninfo = "dbname = postgres";
/* Make a connection to the database */ /* Make a connection to the database */
conn = PQconnectdb(conninfo); conn = PQconnectdb(conninfo);
......
...@@ -46,14 +46,14 @@ main(int argc, char **argv) ...@@ -46,14 +46,14 @@ main(int argc, char **argv)
/* /*
* If the user supplies a parameter on the command line, use it as the * If the user supplies a parameter on the command line, use it as the
* conninfo string; otherwise default to setting dbname=template1 and * conninfo string; otherwise default to setting dbname=postgres and
* using environment variables or defaults for all other connection * using environment variables or defaults for all other connection
* parameters. * parameters.
*/ */
if (argc > 1) if (argc > 1)
conninfo = argv[1]; conninfo = argv[1];
else else
conninfo = "dbname = template1"; conninfo = "dbname = postgres";
/* Make a connection to the database */ /* Make a connection to the database */
conn = PQconnectdb(conninfo); conn = PQconnectdb(conninfo);
......
...@@ -51,14 +51,14 @@ main(int argc, char **argv) ...@@ -51,14 +51,14 @@ main(int argc, char **argv)
/* /*
* If the user supplies a parameter on the command line, use it as the * If the user supplies a parameter on the command line, use it as the
* conninfo string; otherwise default to setting dbname=template1 and * conninfo string; otherwise default to setting dbname=postgres and
* using environment variables or defaults for all other connection * using environment variables or defaults for all other connection
* parameters. * parameters.
*/ */
if (argc > 1) if (argc > 1)
conninfo = argv[1]; conninfo = argv[1];
else else
conninfo = "dbname = template1"; conninfo = "dbname = postgres";
/* Make a connection to the database */ /* Make a connection to the database */
conn = PQconnectdb(conninfo); conn = PQconnectdb(conninfo);
......
#! /bin/sh #! /bin/sh
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.56 2005/06/20 02:26:50 tgl Exp $ # $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.57 2005/06/21 04:02:34 tgl Exp $
me=`basename $0` me=`basename $0`
: ${TMPDIR=/tmp} : ${TMPDIR=/tmp}
...@@ -441,7 +441,7 @@ then ...@@ -441,7 +441,7 @@ then
# wait forever, however. # wait forever, however.
i=0 i=0
max=60 max=60
until "$bindir/psql" -X $psql_options template1 </dev/null 2>/dev/null until "$bindir/psql" -X $psql_options postgres </dev/null 2>/dev/null
do do
i=`expr $i + 1` i=`expr $i + 1`
if [ $i -ge $max ] if [ $i -ge $max ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment