diff options
author | Tom Lane | 2005-06-21 04:02:34 +0000 |
---|---|---|
committer | Tom Lane | 2005-06-21 04:02:34 +0000 |
commit | 3294c072f72978e2d729e92ede210122777aaba8 (patch) | |
tree | c6040bb767129b92b132ac691037d5cc35e9186a | |
parent | da001b0c89d702b5376135492ec88fa2c7fc65ce (diff) |
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.
38 files changed, 141 insertions, 81 deletions
diff --git a/contrib/dblink/doc/connection b/contrib/dblink/doc/connection index 251bd93961..c3ce776fbc 100644 --- a/contrib/dblink/doc/connection +++ b/contrib/dblink/doc/connection @@ -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 diff --git a/contrib/dblink/doc/cursor b/contrib/dblink/doc/cursor index 23a3ce89ba..b989fcb69c 100644 --- a/contrib/dblink/doc/cursor +++ b/contrib/dblink/doc/cursor @@ -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 diff --git a/contrib/dblink/doc/misc b/contrib/dblink/doc/misc index 21d241d61b..596c9ecdcf 100644 --- a/contrib/dblink/doc/misc +++ b/contrib/dblink/doc/misc @@ -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) ================================================================== diff --git a/contrib/dblink/doc/query b/contrib/dblink/doc/query index d232f80dbd..cd58a36142 100644 --- a/contrib/dblink/doc/query +++ b/contrib/dblink/doc/query @@ -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: diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 5fd1140f9a..9bea98b507 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -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); diff --git a/contrib/reindexdb/reindexdb b/contrib/reindexdb/reindexdb index 7db6a26622..cfe933126b 100644 --- a/contrib/reindexdb/reindexdb +++ b/contrib/reindexdb/reindexdb @@ -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. diff --git a/contrib/seg/README.seg b/contrib/seg/README.seg index f899b9394d..e738f180e8 100644 --- a/contrib/seg/README.seg +++ b/contrib/seg/README.seg @@ -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 diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml index 247408210c..35e399a618 100644 --- a/doc/src/sgml/backup.sgml +++ b/doc/src/sgml/backup.sgml @@ -177,11 +177,11 @@ pg_dumpall > <replaceable>outfile</> </synopsis> The resulting dump can be restored with <application>psql</>: <synopsis> -psql -f <replaceable class="parameter">infile</replaceable> template1 +psql -f <replaceable class="parameter">infile</replaceable> postgres </synopsis> (Actually, you can specify any existing database name to start from, - but if you are reloading in an empty cluster then <literal>template1</> - is the only available choice.) It is always necessary to have + but if you are reloading in an empty cluster then <literal>postgres</> + should generally be used.) It is always necessary to have database superuser access when restoring a <application>pg_dumpall</> dump, as that is required to restore the user and group information. </para> @@ -1223,7 +1223,7 @@ restore_command = 'copy /mnt/server/archivedir/%f "%p"' # Windows in parallel, on different ports. Then you can use something like <programlisting> -pg_dumpall -p 5432 | psql -d template1 -p 6543 +pg_dumpall -p 5432 | psql -d postgres -p 6543 </programlisting> to transfer your data. Or use an intermediate file if you want. @@ -1256,7 +1256,7 @@ cd ~/postgresql-&version; gmake install initdb -D /usr/local/pgsql/data postmaster -D /usr/local/pgsql/data -psql -f backup template1 +psql -f backup postgres </programlisting> See <xref linkend="runtime"> about ways to start and stop the diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml index ac67a44ee8..5d49898098 100644 --- a/doc/src/sgml/charset.sgml +++ b/doc/src/sgml/charset.sgml @@ -647,6 +647,7 @@ $ <userinput>psql -l</userinput> euc_kr | t-ishii | EUC_KR euc_tw | t-ishii | EUC_TW mule_internal | t-ishii | MULE_INTERNAL + postgres | t-ishii | EUC_JP regression | t-ishii | SQL_ASCII template1 | t-ishii | EUC_JP test | t-ishii | EUC_JP diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml index bd2cd7f7f3..e2faabcc09 100644 --- a/doc/src/sgml/client-auth.sgml +++ b/doc/src/sgml/client-auth.sgml @@ -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 # 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). # # 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 -# "template1" if the user's password is correctly supplied. +# "postgres" if the user's password is correctly supplied. # # 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 # reject all connection from 192.168.54.1 (since that entry will be diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index d646bd0323..0f10d12552 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -468,7 +468,7 @@ su - postgres </programlisting> Finally, restore your data with <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> using the <emphasis>new</> <application>psql</>. </para> diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 2ed98acd1e..33b0254dd7 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -4230,14 +4230,14 @@ main(int argc, char **argv) /* * 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 * parameters. */ if (argc > 1) conninfo = argv[1]; else - conninfo = "dbname = template1"; + conninfo = "dbname = postgres"; /* Make a connection to the database */ conn = PQconnectdb(conninfo); @@ -4376,14 +4376,14 @@ main(int argc, char **argv) /* * 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 * parameters. */ if (argc > 1) conninfo = argv[1]; else - conninfo = "dbname = template1"; + conninfo = "dbname = postgres"; /* Make a connection to the database */ conn = PQconnectdb(conninfo); @@ -4518,14 +4518,14 @@ main(int argc, char **argv) /* * 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 * parameters. */ if (argc > 1) conninfo = argv[1]; else - conninfo = "dbname = template1"; + conninfo = "dbname = postgres"; /* Make a connection to the database */ conn = PQconnectdb(conninfo); diff --git a/doc/src/sgml/manage-ag.sgml b/doc/src/sgml/manage-ag.sgml index 4806a56cb1..e4ce83d08b 100644 --- a/doc/src/sgml/manage-ag.sgml +++ b/doc/src/sgml/manage-ag.sgml @@ -113,17 +113,20 @@ CREATE DATABASE <replaceable>name</>; <command>initdb</> command when the data storage area is initialized. (See <xref linkend="creating-cluster">.) This database is called - <literal>template1</>.<indexterm><primary>template1</></> So to - create the first <quote>real</> database you can connect to - <literal>template1</>. + <literal>postgres</>.<indexterm><primary>postgres</></> So to + create the first <quote>ordinary</> database you can connect to + <literal>postgres</>. </para> <para> - The name <literal>template1</literal> is no accident: when a new - database is created, the template database is essentially cloned. + A second database, + <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 - propagated to all subsequently created databases. This implies that - you should not use the template database for real work, but when + propagated to all subsequently created databases. Therefore it is + unwise to use <literal>template1</> for real work, but when used judiciously this feature can be convenient. More details appear in <xref linkend="manage-ag-templatedbs">. </para> @@ -137,7 +140,7 @@ CREATE DATABASE <replaceable>name</>; createdb <replaceable class="parameter">dbname</replaceable> </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, exactly as described above. The <xref linkend="app-createdb"> reference page contains the invocation @@ -268,13 +271,19 @@ createdb -T template0 <replaceable>dbname</> <para> <literal>template1</> and <literal>template0</> do not have any special status beyond the fact that the name <literal>template1</> is the default - source database name for <command>CREATE DATABASE</> and the default - database-to-connect-to for various programs such as <command>createdb</>. + source database name for <command>CREATE DATABASE</>. For example, one could drop <literal>template1</> and recreate it from <literal>template0</> without any ill effects. This course of action might be advisable if one has carelessly added a bunch of junk in <literal>template1</>. </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> </sect1> diff --git a/doc/src/sgml/ref/createlang.sgml b/doc/src/sgml/ref/createlang.sgml index f75cd2bd95..e1f6abac50 100644 --- a/doc/src/sgml/ref/createlang.sgml +++ b/doc/src/sgml/ref/createlang.sgml @@ -223,6 +223,9 @@ PostgreSQL documentation <screen> <prompt>$ </prompt><userinput>createlang pltcl template1</userinput> </screen> + Note that installing the language into <literal>template1</literal> + will cause it to be automatically installed into subsequently-created + databases as well. </para> </refsect1> diff --git a/doc/src/sgml/ref/drop_database.sgml b/doc/src/sgml/ref/drop_database.sgml index 5ebcf4b923..cd1297c2f4 100644 --- a/doc/src/sgml/ref/drop_database.sgml +++ b/doc/src/sgml/ref/drop_database.sgml @@ -32,7 +32,7 @@ DROP DATABASE <replaceable class="PARAMETER">name</replaceable> catalog entries for the database and deletes the directory containing the data. It can only be executed by the database owner. 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.) </para> diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml index a71d669934..0238850444 100644 --- a/doc/src/sgml/ref/initdb.sgml +++ b/doc/src/sgml/ref/initdb.sgml @@ -47,9 +47,12 @@ PostgreSQL documentation which the database data will live, generating the shared catalog tables (tables that belong to the whole cluster rather than to any particular database), and creating the <literal>template1</literal> - database. When you later create a new database, everything in the - <literal>template1</literal> database is copied. It contains catalog - tables containing things like built-in data types. + and <literal>postgres</literal> databases. When you later create a + new database, everything in the <literal>template1</literal> database is + 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> diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml index cad4d79e48..14696fe71e 100644 --- a/doc/src/sgml/ref/pg_dumpall.sgml +++ b/doc/src/sgml/ref/pg_dumpall.sgml @@ -401,7 +401,7 @@ PostgreSQL documentation <para> To reload this database use, for example: <screen> -<prompt>$</prompt> <userinput>psql -f db.out template1</userinput> +<prompt>$</prompt> <userinput>psql -f db.out postgres</userinput> </screen> (It is not important to which database you connect here since the script file created by <application>pg_dumpall</application> will diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index d9f16faad4..14cc1f034b 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -54,8 +54,13 @@ $PostgreSQL$ (<acronym>SQL</acronym> uses the term catalog cluster.) A database cluster is a collection of databases that is managed by a single instance of a running database server. After initialization, a - database cluster will contain a database named - <literal>template1</literal>. As the name suggests, this will be used + database cluster will contain a database named <literal>postgres</literal>, + 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 used for actual work. (See <xref linkend="managing-databases"> for information about creating new databases within a cluster.) @@ -5319,7 +5324,7 @@ ssh -L 3333:foo.com:5432 [email protected] to connect to. In order to connect to the database server using this tunnel, you connect to port 3333 on the local machine: <programlisting> -psql -h localhost -p 3333 template1 +psql -h localhost -p 3333 postgres </programlisting> To the database server it will then look as though you are really user <literal>[email protected]</literal> and it will use whatever diff --git a/doc/src/sgml/start.sgml b/doc/src/sgml/start.sgml index 3a2c7c7d34..f140167bdf 100644 --- a/doc/src/sgml/start.sgml +++ b/doc/src/sgml/start.sgml @@ -183,7 +183,7 @@ createdb: command not found <para> Another response could be this: <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 Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? @@ -196,7 +196,7 @@ No such file or directory <para> Another response could be this: <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 </screen> where your own login name is mentioned. This will happen if the diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 0b48f93f59..8f17f07440 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -93,7 +93,7 @@ createdb(const CreatedbStmt *stmt) DefElem *dencoding = NULL; char *dbname = stmt->dbname; char *dbowner = NULL; - char *dbtemplate = NULL; + const char *dbtemplate = NULL; int encoding = -1; #ifndef WIN32 diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 27b0525350..7c960e8492 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -8,14 +8,19 @@ * * To create the database cluster, we create the directory that contains * all its data, create the files that hold the global tables, create - * a few other control files for it, and create two databases: the - * template0 and template1 databases. + * a few other control files for it, and create three databases: the + * template databases "template0" and "template1", and a default user + * database "postgres". * * The template databases are ordinary PostgreSQL databases. template0 * is never supposed to change after initdb, whereas template1 can be * changed to add site-local standard data. Either one can be copied * 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 * mode and feed it data from the postgres.bki library file. After this * initial bootstrap phase, some additional stuff is created by normal @@ -23,12 +28,10 @@ * just embedded into this program (yeah, it's ugly), but larger chunks * are taken from script files. * - * template0 is made just by copying the completed template1. * * Note: * 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 * PostgreSQL cluster location, and should be highly compatible with it. * author of C translation: Andrew Dunstan mailto:[email protected] @@ -178,6 +181,7 @@ static void set_info_version(void); static void setup_schema(void); static void vacuum_db(void); static void make_template0(void); +static void make_postgres(void); static void trapsig(int signum); static void check_ok(void); static char *escape_quotes(const char *src); @@ -1846,7 +1850,7 @@ make_template0(void) * We use the OID of template0 to determine lastsysoid */ "UPDATE pg_database SET datlastsysoid = " - " (SELECT oid::int4 - 1 FROM pg_database " + " (SELECT oid FROM pg_database " " WHERE datname = 'template0');\n", /* @@ -1882,6 +1886,37 @@ make_template0(void) 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. @@ -2609,6 +2644,8 @@ main(int argc, char *argv[]) make_template0(); + make_postgres(); + if (authwarning != NULL) fprintf(stderr, "%s", authwarning); diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index a3ed621e1e..7519f728d6 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -442,7 +442,7 @@ test_postmaster_connection(void) for (i = 0; i < wait_seconds; i++) { if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL, - "template1", NULL, NULL)) != NULL && + "postgres", NULL, NULL)) != NULL && (PQstatus(conn) == CONNECTION_OK || (strcmp(PQerrorMessage(conn), PQnoPasswordSupplied) == 0))) diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index d9a28c66f8..0ce1e3c888 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -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"); if (verbose) dumpTimestamp("Started on"); - printf("\\connect \"template1\"\n\n"); + printf("\\connect \"postgres\"\n\n"); if (!data_only) { @@ -880,7 +880,7 @@ runPgDump(const char *dbname) /* * 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 - * the command line, except template1 that doesn't need quoting. + * the command line, except "postgres" which doesn't need quoting. */ #ifndef WIN32 appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin, diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 136a6b00e0..5e7751fe0b 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -195,7 +195,7 @@ main(int argc, char *argv[]) { need_pass = false; 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); if (PQstatus(pset.db) == CONNECTION_BAD && diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c index 9a2ea835e2..c6f700d295 100644 --- a/src/bin/scripts/clusterdb.c +++ b/src/bin/scripts/clusterdb.c @@ -207,7 +207,7 @@ cluster_all_databases(const char *host, const char *port, PGresult *result; 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); PQfinish(conn); diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c index 9faa9aacf8..cd3609e4d3 100644 --- a/src/bin/scripts/createdb.c +++ b/src/bin/scripts/createdb.c @@ -157,7 +157,8 @@ main(int argc, char *argv[]) appendPQExpBuffer(&sql, " TEMPLATE %s", fmtId(template)); 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) printf("%s", sql.data); diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index e9a6885adb..5991132e4f 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -209,7 +209,7 @@ main(int argc, char *argv[]) appendPQExpBuffer(&sql, " NOCREATEUSER"); appendPQExpBuffer(&sql, ";\n"); - conn = connectDatabase("template1", host, port, username, password, progname); + conn = connectDatabase("postgres", host, port, username, password, progname); if (echo) printf("%s", sql.data); diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c index ab23b9cef1..8722b17828 100644 --- a/src/bin/scripts/dropdb.c +++ b/src/bin/scripts/dropdb.c @@ -117,7 +117,8 @@ main(int argc, char *argv[]) appendPQExpBuffer(&sql, "DROP DATABASE %s;\n", 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) printf("%s", sql.data); diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c index 04f902a617..f75b99a7d9 100644 --- a/src/bin/scripts/dropuser.c +++ b/src/bin/scripts/dropuser.c @@ -116,7 +116,7 @@ main(int argc, char *argv[]) initPQExpBuffer(&sql); 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) printf("%s", sql.data); diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c index 31f42ca50b..ea65f0670d 100644 --- a/src/bin/scripts/vacuumdb.c +++ b/src/bin/scripts/vacuumdb.c @@ -233,7 +233,7 @@ vacuum_all_databases(bool full, bool verbose, bool analyze, PGresult *result; 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); PQfinish(conn); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 04a492e340..1c7e1bfd52 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200506201 +#define CATALOG_VERSION_NO 200506202 #endif diff --git a/src/interfaces/ecpg/test/testdynalloc.pgc b/src/interfaces/ecpg/test/testdynalloc.pgc index c0023f8640..a2f67412b7 100644 --- a/src/interfaces/ecpg/test/testdynalloc.pgc +++ b/src/interfaces/ecpg/test/testdynalloc.pgc @@ -13,7 +13,7 @@ int main() if (getenv("SQLOPT")) ECPGdebug(1,stderr); exec sql whenever sqlerror do sqlprint(); - exec sql connect to template1; + exec sql connect to postgres; exec sql allocate descriptor mydesc; exec sql select tablename into descriptor mydesc from pg_tables; diff --git a/src/interfaces/libpq/pg_service.conf.sample b/src/interfaces/libpq/pg_service.conf.sample index e15d79b91e..8a22fda95a 100644 --- a/src/interfaces/libpq/pg_service.conf.sample +++ b/src/interfaces/libpq/pg_service.conf.sample @@ -4,13 +4,13 @@ # A service is a set of named connection parameters. You may specify # multiple services in this file. Each starts with a service name in # 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. # # Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and # rename it pg_service.conf. # # -#[template1] -#dbname=template1 +#[postgres] +#dbname=postgres #user=postgres diff --git a/src/test/bench/create.sh b/src/test/bench/create.sh index 3106bd2593..c374ae1a21 100755 --- a/src/test/bench/create.sh +++ b/src/test/bench/create.sh @@ -10,10 +10,10 @@ if [ -d ./obj ]; then fi 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 "create database bench" | postgres -D${1} template1 > /dev/null +echo "create database bench" | postgres -D${1} postgres > /dev/null if [ $? -ne 0 ]; then echo createdb failed exit 1 diff --git a/src/test/examples/testlibpq.c b/src/test/examples/testlibpq.c index b9d396a2dc..3295076481 100644 --- a/src/test/examples/testlibpq.c +++ b/src/test/examples/testlibpq.c @@ -26,14 +26,14 @@ main(int argc, char **argv) /* * 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 * parameters. */ if (argc > 1) conninfo = argv[1]; else - conninfo = "dbname = template1"; + conninfo = "dbname = postgres"; /* Make a connection to the database */ conn = PQconnectdb(conninfo); diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c index 1cb7616f24..9f1e96d8da 100644 --- a/src/test/examples/testlibpq2.c +++ b/src/test/examples/testlibpq2.c @@ -46,14 +46,14 @@ main(int argc, char **argv) /* * 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 * parameters. */ if (argc > 1) conninfo = argv[1]; else - conninfo = "dbname = template1"; + conninfo = "dbname = postgres"; /* Make a connection to the database */ conn = PQconnectdb(conninfo); diff --git a/src/test/examples/testlibpq3.c b/src/test/examples/testlibpq3.c index 7036d3e81f..49b03066cd 100644 --- a/src/test/examples/testlibpq3.c +++ b/src/test/examples/testlibpq3.c @@ -51,14 +51,14 @@ main(int argc, char **argv) /* * 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 * parameters. */ if (argc > 1) conninfo = argv[1]; else - conninfo = "dbname = template1"; + conninfo = "dbname = postgres"; /* Make a connection to the database */ conn = PQconnectdb(conninfo); diff --git a/src/test/regress/pg_regress.sh b/src/test/regress/pg_regress.sh index b92afbe5e2..fee8ea767d 100644 --- a/src/test/regress/pg_regress.sh +++ b/src/test/regress/pg_regress.sh @@ -441,7 +441,7 @@ then # wait forever, however. i=0 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 i=`expr $i + 1` if [ $i -ge $max ] |