Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3b00e7

Browse files
committed
Add --template option to createdb script to allow access to WITH TEMPLATE
option of CREATE DATABASE. In pg_regress, create regression databasefrom template0 to ensure that any installation-local cruft in template1will not mess up the tests.
1 parent48d0327 commitc3b00e7

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

‎doc/src/sgml/ref/createdb.sgml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.16 2000/12/25 23:15:26 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.17 2001/02/18 17:53:54 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -41,7 +41,7 @@ Postgres documentation
4141
Specifies the hostname of the machine on which the
4242
<application>postmaster</application>
4343
is running. If host begins with a slash, it is used
44-
as the directory for theunixdomain socket.
44+
as the directory for theUnix-domain socket.
4545
</para>
4646
</listitem>
4747
</varlistentry>
@@ -98,17 +98,26 @@ Postgres documentation
9898
<term>-D, --location <replaceable class="parameter">datadir</replaceable></term>
9999
<listitem>
100100
<para>
101-
Specifies the alternativedatabaselocation. See also <xref
101+
Specifies the alternative location for the database. See also <xref
102102
linkend="app-initlocation">.
103103
</para>
104104
</listitem>
105105
</varlistentry>
106106

107+
<varlistentry>
108+
<term>-T, --template <replaceable class="parameter">template</replaceable></term>
109+
<listitem>
110+
<para>
111+
Specifies the template database from which to build this database.
112+
</para>
113+
</listitem>
114+
</varlistentry>
115+
107116
<varlistentry>
108117
<term>-E, --encoding <replaceable class="parameter">encoding</replaceable></term>
109118
<listitem>
110119
<para>
111-
Specifies the character encoding scheme to be usedwith this database.
120+
Specifies the character encoding scheme to be usedin this database.
112121
</para>
113122
</listitem>
114123
</varlistentry>
@@ -140,6 +149,12 @@ Postgres documentation
140149
The options <literal>-h</literal>, <literal>-p</literal>, <literal>-U</literal>,
141150
<literal>-W</literal>, and <literal>-e</literal> are passed on literally to
142151
<xref linkend="app-psql">.
152+
153+
The options <literal>-D</literal>, <literal>-T</literal>, and
154+
<literal>-E</literal> are converted into options for the underlying
155+
SQL command <xref linkend="SQL-CREATEDATABASE"
156+
endterm="SQL-CREATEDATABASE-title">, which see for more information
157+
about them.
143158
</para>
144159
</refsect2>
145160

@@ -168,7 +183,7 @@ Postgres documentation
168183
<listitem>
169184
<para>
170185
The comment/description for the database could not be created.
171-
the database itself will have been created already. You can use the
186+
The database itself will have been created already. You can use the
172187
<acronym>SQL</acronym> command <command>COMMENT ON DATABASE</command> to
173188
create the comment later on.
174189
</para>
@@ -199,10 +214,10 @@ Postgres documentation
199214
the <productname>Postgres</productname> interactive terminal
200215
<xref linkend="APP-PSQL">. Thus, there is nothing
201216
special about creating databases via this or other methods. This means
202-
that the <application>psql</application> must be found by the script and that
203-
a database serverisrunning at the targetedhost. Also, any default
217+
that the <application>psql</application>programmust be found by the script and that
218+
a database servermust berunning at the targetedport. Also, any default
204219
settings and environment variables available to <application>psql</application>
205-
and the <application>libpq</application> front-end librarydo apply.
220+
and the <application>libpq</application> front-end librarywill apply.
206221
</para>
207222
</refsect1>
208223

‎src/bin/scripts/createdb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
# This program runs psql with the "-c" option to create
88
# the requested database.
99
#
10-
# Copyright (c) 1994, Regents of the University of California
10+
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
11+
# Portions Copyright (c) 1994, Regents of the University of California
1112
#
1213
#
1314
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.13 2001/01/21 05:16:45 momjian Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.14 2001/02/18 17:53:54 tgl Exp $
1516
#
1617
#-------------------------------------------------------------------------
1718

1819
CMDNAME=`basename$0`
1920
PATHNAME=`echo$0| sed"s,$CMDNAME\$,,"`
2021

2122
MB=
23+
TEMPLATE=
2224
PSQLOPT=
2325
dbname=
2426
dbcomment=
@@ -78,6 +80,15 @@ do
7880
--location=*)
7981
dbpath=`echo"$1"| sed's/^--location=//'`
8082
;;
83+
--template|-T)
84+
TEMPLATE="$2"
85+
shift;;
86+
-T*)
87+
TEMPLATE=`echo"$1"| sed's/^-T//'`
88+
;;
89+
--template=*)
90+
TEMPLATE=`echo"$1"| sed's/^--template=//'`
91+
;;
8192
--encoding|-E)
8293
MB="$2"
8394
shift;;
@@ -111,6 +122,7 @@ if [ "$usage" ]; then
111122
echo
112123
echo"Options:"
113124
echo" -D, --location=PATH Alternative place to store the database"
125+
echo" -T, --template=TEMPLATE Template database to copy"
114126
echo" -E, --encoding=ENCODING Multibyte encoding for the database"
115127
echo" -h, --host=HOSTNAME Database server host"
116128
echo" -p, --port=PORT Database server port"
@@ -149,10 +161,12 @@ fi
149161
# escape the quotes
150162
dbpath=`echo"$dbpath"| sed"s/'/\\\\\'/g"`
151163
dbname=`echo"$dbname"| sed's/\"/\\\"/g'`
164+
TEMPLATE=`echo"$TEMPLATE"| sed's/\"/\"\"/g'`
152165

153166
withstring=
154167
["$dbpath" ]&& withstring="$withstring LOCATION = '$dbpath'"
155168
["$MB" ]&& withstring="$withstring ENCODING = '$MB'"
169+
["$TEMPLATE" ]&& withstring="$withstring TEMPLATE =\"$TEMPLATE\""
156170
["$withstring" ]&& withstring=" WITH$withstring"
157171

158172
${PATHNAME}psql$PSQLOPT -d template1 -c"CREATE DATABASE\"$dbname\"$withstring"

‎src/test/regress/pg_regress.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.18 2001/01/19 23:43:36 petere Exp $
2+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.19 2001/02/18 17:53:55 tgl Exp $
33

44
me=`basename$0`
55
:${TMPDIR=/tmp}
@@ -420,10 +420,12 @@ fi
420420

421421
# ----------
422422
# Create the regression database
423+
# We use template0 so that any installation-local cruft in template1
424+
# will not mess up the tests.
423425
# ----------
424426

425427
message"creating database\"$dbname\""
426-
"$bindir/createdb"$encoding_opt$psql_options"$dbname"
428+
"$bindir/createdb"$encoding_opt$psql_options--template template0"$dbname"
427429
if [$?-ne 0 ];then
428430
echo"$me: createdb failed"
429431
(exit 2);exit

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp