mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
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.
This commit is contained in:
@ -28,13 +28,13 @@ Outputs
|
||||
|
||||
Example usage
|
||||
|
||||
select dblink_connect('dbname=template1');
|
||||
select dblink_connect('dbname=postgres');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
(1 row)
|
||||
|
||||
select dblink_connect('myconn','dbname=template1');
|
||||
select dblink_connect('myconn','dbname=postgres');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
|
@ -44,7 +44,7 @@ Note
|
||||
|
||||
Example usage
|
||||
|
||||
test=# select dblink_connect('dbname=template1');
|
||||
test=# select dblink_connect('dbname=postgres');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
@ -94,7 +94,7 @@ Outputs
|
||||
|
||||
Example usage
|
||||
|
||||
test=# select dblink_connect('dbname=template1');
|
||||
test=# select dblink_connect('dbname=postgres');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
@ -175,7 +175,7 @@ Note
|
||||
|
||||
Example usage
|
||||
|
||||
test=# select dblink_connect('dbname=template1');
|
||||
test=# select dblink_connect('dbname=postgres');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
|
@ -17,10 +17,10 @@ Outputs
|
||||
|
||||
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
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
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)
|
||||
|
||||
==================================================================
|
||||
|
@ -37,7 +37,7 @@ Outputs
|
||||
|
||||
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%';
|
||||
proname | prosrc
|
||||
------------+------------
|
||||
@ -55,7 +55,7 @@ select * from dblink('dbname=template1','select proname, prosrc from pg_proc')
|
||||
byteaout | byteaout
|
||||
(12 rows)
|
||||
|
||||
select dblink_connect('dbname=template1');
|
||||
select dblink_connect('dbname=postgres');
|
||||
dblink_connect
|
||||
----------------
|
||||
OK
|
||||
@ -111,7 +111,7 @@ A more convenient way to use dblink may be to create a view:
|
||||
|
||||
create view myremote_pg_proc as
|
||||
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);
|
||||
|
||||
Then you can simply write:
|
||||
|
@ -518,7 +518,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (my_opts->dbname == NULL)
|
||||
{
|
||||
my_opts->dbname = "template1";
|
||||
my_opts->dbname = "postgres";
|
||||
my_opts->nodb = true;
|
||||
}
|
||||
pgconn = sql_conn(my_opts);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
|
||||
# Package : reindexdb Version : $Revision: 1.5 $
|
||||
# Package : reindexdb Version : $Revision: 1.6 $
|
||||
# Date : 05/08/2002 Author : Shaun Thomas
|
||||
# Req : psql, sh, perl, sed Type : Utility
|
||||
#
|
||||
@ -174,7 +174,7 @@ if [ "$alldb" ]; then
|
||||
# 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.
|
||||
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
|
||||
# specified before continuing.
|
||||
|
@ -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
|
||||
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
|
||||
---------
|
||||
9.0 .. 11 -- should be: 9 .. 11
|
||||
|
Reference in New Issue
Block a user