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

Commit6462e7b

Browse files
committed
Add a --locale switch to createdb, to ease the creation of databases with
different locales. This is just syntactical sweetener over --lc-collate and--lc-ctype. Per discussion.While at it, properly document --lc-ctype and --lc-collate in SGML docs,which apparently were forgotten (or purposefully ommited?) when they werecreated.
1 parent2b74d45 commit6462e7b

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/createdb.sgml,v 1.47 2007/12/11 19:57:32 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/createdb.sgml,v 1.48 2008/11/10 16:25:41 alvherre Exp $
33
PostgreSQL documentation
44
-->
55

@@ -106,6 +106,35 @@ PostgreSQL documentation
106106
</listitem>
107107
</varlistentry>
108108

109+
<varlistentry>
110+
<term><option>-l <replaceable class="parameter">locale</replaceable></></term>
111+
<term><option>--locale <replaceable class="parameter">locale</replaceable></></term>
112+
<listitem>
113+
<para>
114+
Specifies the locale to be used in this database. This is equivalent
115+
to specifying both <option>--lc-collate</option> and <option>--lc-ctype</option>.
116+
</para>
117+
</listitem>
118+
</varlistentry>
119+
120+
<varlistentry>
121+
<term><option>--lc-collate <replaceable class="parameter">locale</replaceable></></term>
122+
<listitem>
123+
<para>
124+
Specifies the LC_COLLATE setting to be used in this database.
125+
</para>
126+
</listitem>
127+
</varlistentry>
128+
129+
<varlistentry>
130+
<term><option>--lc-ctype <replaceable class="parameter">locale</replaceable></></term>
131+
<listitem>
132+
<para>
133+
Specifies the LC_CTYPE setting to be used in this database.
134+
</para>
135+
</listitem>
136+
</varlistentry>
137+
109138
<varlistentry>
110139
<term><option>-E <replaceable class="parameter">encoding</replaceable></></term>
111140
<term><option>--encoding <replaceable class="parameter">encoding</replaceable></></term>
@@ -142,7 +171,7 @@ PostgreSQL documentation
142171
</para>
143172

144173
<para>
145-
The options <option>-D</option>, <option>-E</option>,
174+
The options <option>-D</option>, <option>-E</option>, <option>-l</option>,
146175
<option>-O</option>, and
147176
<option>-T</option> correspond to options of the underlying
148177
SQL command <xref linkend="SQL-CREATEDATABASE"

‎src/bin/scripts/createdb.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.27 2008/09/23 09:20:38 heikki Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.28 2008/11/10 16:25:41 alvherre Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -34,6 +34,7 @@ main(int argc, char *argv[])
3434
{"encoding",required_argument,NULL,'E'},
3535
{"lc-collate",required_argument,NULL,1},
3636
{"lc-ctype",required_argument,NULL,2},
37+
{"locale",required_argument,NULL,'l'},
3738
{NULL,0,NULL,0}
3839
};
3940

@@ -54,6 +55,7 @@ main(int argc, char *argv[])
5455
char*encoding=NULL;
5556
char*lc_collate=NULL;
5657
char*lc_ctype=NULL;
58+
char*locale=NULL;
5759

5860
PQExpBufferDatasql;
5961

@@ -65,7 +67,7 @@ main(int argc, char *argv[])
6567

6668
handle_help_version_opts(argc,argv,"createdb",help);
6769

68-
while ((c=getopt_long(argc,argv,"h:p:U:WeqO:D:T:E:",long_options,&optindex))!=-1)
70+
while ((c=getopt_long(argc,argv,"h:p:U:WeqO:D:T:E:l:",long_options,&optindex))!=-1)
6971
{
7072
switch (c)
7173
{
@@ -105,6 +107,9 @@ main(int argc, char *argv[])
105107
case2:
106108
lc_ctype=optarg;
107109
break;
110+
case'l':
111+
locale=optarg;
112+
break;
108113
default:
109114
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
110115
exit(1);
@@ -129,6 +134,24 @@ main(int argc, char *argv[])
129134
exit(1);
130135
}
131136

137+
if (locale)
138+
{
139+
if (lc_ctype)
140+
{
141+
fprintf(stderr,_("%s: only one of --locale and --lc-ctype can be specified\n"),
142+
progname);
143+
exit(1);
144+
}
145+
if (lc_collate)
146+
{
147+
fprintf(stderr,_("%s: only one of --locale and --lc-collate can be specified\n"),
148+
progname);
149+
exit(1);
150+
}
151+
lc_ctype=locale;
152+
lc_collate=locale;
153+
}
154+
132155
if (encoding)
133156
{
134157
if (pg_char_to_encoding(encoding)<0)
@@ -224,6 +247,7 @@ help(const char *progname)
224247
printf(_("\nOptions:\n"));
225248
printf(_(" -D, --tablespace=TABLESPACE default tablespace for the database\n"));
226249
printf(_(" -E, --encoding=ENCODING encoding for the database\n"));
250+
printf(_(" -l, --locale=LOCALE locale settings for the database\n"));
227251
printf(_(" --lc-collate=LOCALE LC_COLLATE setting for the database\n"));
228252
printf(_(" --lc-ctype=LOCALE LC_CTYPE setting for the database\n"));
229253
printf(_(" -O, --owner=OWNER database user to own the new database\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp