8000 Cause initdb to create a third standard database "postgres", which · postgrespro/postgres@6f7fc0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f7fc0b

Browse files
committed
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.
1 parent ec3a1af commit 6f7fc0b

38 files changed

+167
-107
lines changed

contrib/dblink/doc/connection

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ Outputs
2828

2929
Example usage
3030

31-
select dblink_connect('dbname=template1');
31+
select dblink_connect('dbname=postgres');
3232
dblink_connect
3333
----------------
3434
OK
3535
(1 row)
3636

37-
select dblink_connect('myconn','dbname=template1');
37+
select dblink_connect('myconn','dbname=postgres');
3838
dblink_connect
3939
----------------
4040
OK

contrib/dblink/doc/cursor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Note
4444

4545
Example usage
4646

47-
test=# select dblink_connect('dbname=template1');
47+
test=# select dblink_connect('dbname=postgres');
4848
dblink_connect
4949
----------------
5050
OK
@@ -94,7 +94,7 @@ Outputs
9494

9595
Example usage
9696

97-
test=# select dblink_connect('dbname=template1');
97+
test=# select dblink_connect('dbname=postgres');
9898
dblink_connect
9999
----------------
100100
OK
@@ -175,7 +175,7 @@ Note
175175

176176
Example usage
177177

178-
test=# select dblink_connect('dbname=template1');
178+
test=# select dblink_connect('dbname=postgres');
179179
dblink_connect
180180
----------------
181181
OK

contrib/dblink/doc/misc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Outputs
1717

1818
Example usage
1919

20-
test=# select dblink_current_query() from (select dblink('dbname=template1','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1;
20+
test=# select dblink_current_query() from (select dblink('dbname=postgres','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1;
2121
dblink_current_query
2222
-----------------------------------------------------------------------------------------------------------------------------------------------------
23-
select dblink_current_query() from (select dblink('dbname=template1','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1;
23+
select dblink_current_query() from (select dblink('dbname=postgres','select oid, proname from pg_proc where proname = ''byteacat''') as f1) as t1;
2424
(1 row)
2525

2626
==================================================================

contrib/dblink/doc/query

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Outputs
3737

3838
Example usage
3939

40-
select * from dblink('dbname=template1','select proname, prosrc from pg_proc')
40+
select * from dblink('dbname=postgres','select proname, prosrc from pg_proc')
4141
as t1(proname name, prosrc text) where proname like 'bytea%';
4242
proname | prosrc
4343
------------+------------
@@ -55,7 +55,7 @@ select * from dblink('dbname=template1','select proname, prosrc from pg_proc')
5555
byteaout | byteaout
5656
(12 rows)
5757

58-
select dblink_connect('dbname=template1');
58+
select dblink_connect('dbname=postgres');
5959
dblink_connect
6060
----------------
6161
OK
@@ -111,7 +111,7 @@ A more convenient way to use dblink may be to create a view:
111111

112112
create view myremote_pg_proc as
113113
select *
114-
from dblink('dbname=template1','select proname, prosrc from pg_proc')
114+
from dblink('dbname=postgres','select proname, prosrc from pg_proc')
115115
as t1(proname name, prosrc text);
116116

117117
Then you can simply write:

contrib/oid2name/oid2name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ main(int argc, char **argv)
518518

519519
if (my_opts->dbname == NULL)
520520
{
521-
my_opts->dbname = "template1";
521+
my_opts->dbname = "postgres";
522522
my_opts->nodb = true;
523523
}
524524
pgconn = sql_conn(my_opts);

contrib/reindexdb/reindexdb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
3-
# Package : reindexdb Version : $Revision: 1.5 $
3+
# Package : reindexdb Version : $Revision: 1.6 $
44
# Date : 05/08/2002 Author : Shaun Thomas
55
# Req : psql, sh, perl, sed Type : Utility
66
#
@@ -174,7 +174,7 @@ if [ "$alldb" ]; then
174174
# connect to. That's the list we'll be using. It's also why it's
175175
# a good idea for this to be run as a super-user.
176176
sql='SELECT datname FROM pg_database WHERE datallowconn'
177-
dbname=`$PSQL $PSQLOPT -q -t -A -d template1 -c "$sql"`
177+
dbname=`$PSQL $PSQLOPT -q -t -A -d postgres -c "$sql"`
178178

179179
# Ok, if it's not all databases, make sure at least one database is
180180
# specified before continuing.

contrib/seg/README.seg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Any number (rules 5,6) -- creates a zero-length segment (a point,
159159
boundaries. For example, it adds an extra digit to the lower
160160
boundary if the resulting interval includes a power of ten:
161161

162-
template1=> select '10(+-)1'::seg as seg;
162+
postgres=> select '10(+-)1'::seg as seg;
163163
seg
164164
---------
165165
9.0 .. 11 -- should be: 9 .. 11

doc/src/sgml/backup.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.66 2005/06/20 13:52:17 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.67 2005/06/21 04:02:29 tgl Exp $
33
-->
44
<chapter id="backup">
55
<title>Backup and Restore</title>
@@ -177,11 +177,11 @@ pg_dumpall &gt; <replaceable>outfile</>
177177
</synopsis>
178178
The resulting dump can be restored with <application>psql</>:
179179
<synopsis>
180-
psql -f <replaceable class="parameter">infile</replaceable> template1
180+
psql -f <replaceable class="parameter">infile</replaceable> postgres
181181
</synopsis>
182182
(Actually, you can specify any existing database name to start from,
183-
but if you are reloading in an empty cluster then <literal>template1</>
184-
is the only available choice.) It is always necessary to have
183+
but if you are reloading in an empty cluster then <literal>postgres</>
184+
should generally be used.) It is always necessary to have
185185
database superuser access when restoring a <application>pg_dumpall</>
186186
dump, as that is required to restore the user and group information.
187187
</para>
@@ -1223,7 +1223,7 @@ restore_command = 'copy /mnt/server/archivedir/%f "%p"' # Windows
12231223
in parallel, on different ports. Then you can use something like
12241224

12251225
<programlisting>
1226-
pg_dumpall -p 5432 | psql -d template1 -p 6543
1226+
pg_dumpall -p 5432 | psql -d postgres -p 6543
12271227
</programlisting>
12281228

12291229
to transfer your data. Or use an intermediate file if you want.
@@ -1256,7 +1256,7 @@ cd ~/postgresql-&version;
12561256
gmake install
12571257
initdb -D /usr/local/pgsql/data
12581258
postmaster -D /usr/local/pgsql/data
1259-
psql -f backup template1
1259+
psql -f backup postgres
12601260
</programlisting>
12611261

12621262
See <xref linkend="runtime"> about ways to start and stop the

doc/src/sgml/charset.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/charset.sgml,v 2.72 2005/04/16 16:50:01 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/charset.sgml,v 2.73 2005/06/21 04:02:29 tgl Exp $ -->
22

33
<chapter id="charset">
44
<title>Localization</>
@@ -647,6 +647,7 @@ $ <userinput>psql -l</userinput>
647647
euc_kr | t-ishii | EUC_KR
648648
euc_tw | t-ishii | EUC_TW
649649
mule_internal | t-ishii | MULE_INTERNAL
650+
postgres | t-ishii | EUC_JP
650651
regression | t-ishii | SQL_ASCII
651652
template1 | t-ishii | EUC_JP
652653
test | t-ishii | EUC_JP

doc/src/sgml/client-auth.sgml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.80 2005/06/04 20:42:41 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.81 2005/06/21 04:02:29 tgl Exp $
33
-->
44

55
<chapter id="client-authentication">
@@ -452,17 +452,17 @@ host all all 127.0.0.1/32 trust
452452
host all all 127.0.0.1 255.255.255.255 trust
453453

454454
# Allow any user from any host with IP address 192.168.93.x to connect
455-
# to database "template1" as the same user name that ident reports for
455+
# to database "postgres" as the same user name that ident reports for
456456
# the connection (typically the Unix user name).
457457
#
458458
# TYPE DATABASE USER CIDR-ADDRESS METHOD
459-
host template1 all 192.168.93.0/24 ident sameuser
459+
host postgres all 192.168.93.0/24 ident sameuser
460460

461461
# Allow a user from host 192.168.12.10 to connect to database
462-
# "template1" if the user's password is correctly supplied.
462+
# "postgres" if the user's password is correctly supplied.
463463
#
464464
# TYPE DATABASE USER CIDR-ADDRESS METHOD
465-
host template1 all 192.168.12.10/32 md5
465+
host postgres all 192.168.12.10/32 md5
466466

467467
# In the absence of preceding "host" lines, these two lines will
468468
# reject all connection from 192.168.54.1 (since that entry will be

0 commit comments

Comments
 (0)
0