5
5
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
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 $
9
9
*
10
10
*-------------------------------------------------------------------------
11
11
*/
@@ -34,6 +34,7 @@ main(int argc, char *argv[])
34
34
{"encoding" , required_argument , NULL , 'E' },
35
35
{"lc-collate" , required_argument , NULL , 1 },
36
36
{"lc-ctype" , required_argument , NULL , 2 },
37
+ {"locale" , required_argument , NULL , 'l' },
37
38
{NULL , 0 , NULL , 0 }
38
39
};
39
40
@@ -54,6 +55,7 @@ main(int argc, char *argv[])
54
55
char * encoding = NULL ;
55
56
char * lc_collate = NULL ;
56
57
char * lc_ctype = NULL ;
58
+ char * locale = NULL ;
57
59
58
60
PQExpBufferData sql ;
59
61
@@ -65,7 +67,7 @@ main(int argc, char *argv[])
65
67
66
68
handle_help_version_opts (argc , argv , "createdb" , help );
67
69
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 )
69
71
{
70
72
switch (c )
71
73
{
@@ -105,6 +107,9 @@ main(int argc, char *argv[])
105
107
case 2 :
106
108
lc_ctype = optarg ;
107
109
break ;
110
+ case 'l' :
111
+ locale = optarg ;
112
+ break ;
108
113
default :
109
114
fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
110
115
exit (1 );
@@ -129,6 +134,24 @@ main(int argc, char *argv[])
129
134
exit (1 );
130
135
}
131
136
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
+
132
155
if (encoding )
133
156
{
134
157
if (pg_char_to_encoding (encoding ) < 0 )
@@ -224,6 +247,7 @@ help(const char *progname)
224
247
printf (_ ("\nOptions:\n" ));
225
248
printf (_ (" -D, --tablespace=TABLESPACE default tablespace for the database\n" ));
226
249
printf (_ (" -E, --encoding=ENCODING encoding for the database\n" ));
250
+ printf (_ (" -l, --locale=LOCALE locale settings for the database\n" ));
227
251
printf (_ (" --lc-collate=LOCALE LC_COLLATE setting for the database\n" ));
228
252
printf (_ (" --lc-ctype=LOCALE LC_CTYPE setting for the database\n" ));
229
253
printf (_ (" -O, --owner=OWNER database user to own the new database\n" ));
0 commit comments