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

Commit75e5e20

Browse files
committed
Add -O/--owner switch to createdb script, in support of new OWNER option
for CREATE DATABASE.
1 parent36d2cc1 commit75e5e20

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

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

Lines changed: 23 additions & 6 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.24 2002/01/20 22:19:56 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.25 2002/02/24 23:27:57 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -92,6 +92,15 @@ PostgreSQL documentation
9292
</listitem>
9393
</varlistentry>
9494

95+
<varlistentry>
96+
<term>-O, --owner <replaceable class="parameter">owner</replaceable></term>
97+
<listitem>
98+
<para>
99+
Specifies the database user who will own the new database.
100+
</para>
101+
</listitem>
102+
</varlistentry>
103+
95104
<varlistentry>
96105
<term>-D, --location <replaceable class="parameter">datadir</replaceable></term>
97106
<listitem>
@@ -144,12 +153,13 @@ PostgreSQL documentation
144153

145154
</variablelist>
146155

147-
The options <literal>-h</literal>, <literal>-p</literal>, <literal>-U</literal>,
148-
<literal>-W</literal>, and <literal>-e</literal> are passed on literally to
156+
The options <option>-h</option>, <option>-p</option>, <option>-U</option>,
157+
<option>-W</option>, and <option>-e</option> are passed on literally to
149158
<xref linkend="app-psql">.
150159

151-
The options <literal>-D</literal>, <literal>-T</literal>, and
152-
<literal>-E</literal> are converted into options for the underlying
160+
The options <option>-O</option>, <option>-D</option>,
161+
<option>-T</option>, and
162+
<option>-E</option> are converted into options for the underlying
153163
SQL command <xref linkend="SQL-CREATEDATABASE"
154164
endterm="SQL-CREATEDATABASE-title">; see there for more information
155165
about them.
@@ -202,7 +212,14 @@ PostgreSQL documentation
202212
</title>
203213
<para>
204214
<application>createdb</application> creates a new <productname>PostgreSQL</productname>
205-
database. The user who executes this command becomes the database owner.
215+
database.
216+
</para>
217+
218+
<para>
219+
Normally, the database user who executes this command becomes the owner of
220+
the new database.
221+
However a different owner can be specified via the <option>-O</option>
222+
option, if the executing user has appropriate privileges.
206223
</para>
207224

208225
<para>

‎src/bin/scripts/createdb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414
# IDENTIFICATION
15-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.19 2002/02/18 05:48:44 momjian Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.20 2002/02/24 23:27:58 tgl Exp $
1616
#
1717
#-------------------------------------------------------------------------
1818

@@ -23,6 +23,7 @@ MB=
2323
TEMPLATE=
2424
PSQLOPT=
2525
dbname=
26+
dbowner=
2627
dbcomment=
2728
dbpath=
2829

@@ -71,6 +72,15 @@ do
7172
PSQLOPT="$PSQLOPT -o /dev/null"
7273
;;
7374
# options converted into SQL command
75+
--owner|-O)
76+
dbowner="$2"
77+
shift;;
78+
-O*)
79+
dbowner=`echo"$1"| sed's/^-O//'`
80+
;;
81+
--owner=*)
82+
dbowner=`echo"$1"| sed's/^--owner=//'`
83+
;;
7484
--location|-D)
7585
dbpath="$2"
7686
shift;;
@@ -127,6 +137,7 @@ if [ "$usage" ]; then
127137
echo"$CMDNAME [options] [dbname] [description]"
128138
echo
129139
echo"Options:"
140+
echo" -O, --owner=OWNER Database user to own the new database"
130141
echo" -D, --location=PATH Alternative place to store the database"
131142
echo" -T, --template=TEMPLATE Template database to copy"
132143
echo" -E, --encoding=ENCODING Multibyte encoding for the database"
@@ -170,6 +181,7 @@ dbname=`echo "$dbname" | sed 's/\"/\\\"/g'`
170181
TEMPLATE=`echo"$TEMPLATE"| sed's/\"/\"\"/g'`
171182

172183
withstring=
184+
["$dbowner" ]&& withstring="$withstring OWNER =\"$dbowner\""
173185
["$dbpath" ]&& withstring="$withstring LOCATION = '$dbpath'"
174186
["$MB" ]&& withstring="$withstring ENCODING = '$MB'"
175187
["$TEMPLATE" ]&& withstring="$withstring TEMPLATE =\"$TEMPLATE\""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp