[ [ WITH ] [ OWNER [=] <replaceable class="parameter">user_name</replaceable> ]
[ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ]
[ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ]
+ [ LOCALE [=] <replaceable class="parameter">locale</replaceable> ]
[ LC_COLLATE [=] <replaceable class="parameter">lc_collate</replaceable> ]
[ LC_CTYPE [=] <replaceable class="parameter">lc_ctype</replaceable> ]
[ TABLESPACE [=] <replaceable class="parameter">tablespace_name</replaceable> ]
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><replaceable class="parameter">locale</replaceable></term>
+ <listitem>
+ <para>
+ This is a shortcut for setting <symbol>LC_COLLATE</symbol>
+ and <symbol>LC_CTYPE</symbol> at once. If you specify this,
+ you cannot specify either of those parameters.
+ </para>
+ <tip>
+ <para>
+ The other locale settings <xref linkend="guc-lc-messages"/>, <xref
+ linkend="guc-lc-monetary"/>, <xref linkend="guc-lc-numeric"/>, and
+ <xref linkend="guc-lc-time"/> are not fixed per database and are not
+ set by this command. If you want to make them the default for a
+ specific database, you can use <literal>ALTER DATABASE
+ ... SET</literal>.
+ </para>
+ </tip>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><replaceable class="parameter">lc_collate</replaceable></term>
<listitem>
To create a database <literal>music</literal> with a different locale:
<programlisting>
CREATE DATABASE music
- LC_COLLATE 'sv_SE.utf8' LC_CTYPE 'sv_SE.utf8'
+ LOCALE 'sv_SE.utf8'
TEMPLATE template0;
</programlisting>
In this example, the <literal>TEMPLATE template0</literal> clause is required if
different character set encoding:
<programlisting>
CREATE DATABASE music2
- LC_COLLATE 'sv_SE.iso885915' LC_CTYPE 'sv_SE.iso885915'
+ LOCALE 'sv_SE.iso885915'
ENCODING LATIN9
TEMPLATE template0;
</programlisting>
DefElem *downer = NULL;
DefElem *dtemplate = NULL;
DefElem *dencoding = NULL;
+ DefElem *dlocale = NULL;
DefElem *dcollate = NULL;
DefElem *dctype = NULL;
DefElem *distemplate = NULL;
parser_errposition(pstate, defel->location)));
dencoding = defel;
}
+ else if (strcmp(defel->defname, "locale") == 0)
+ {
+ if (dlocale)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("conflicting or redundant options"),
+ parser_errposition(pstate, defel->location)));
+ dlocale = defel;
+ }
else if (strcmp(defel->defname, "lc_collate") == 0)
{
if (dcollate)
parser_errposition(pstate, defel->location)));
}
+ if (dlocale && (dcollate || dctype))
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("conflicting or redundant options"),
+ errdetail("LOCALE cannot be specified together with LC_COLLATE or LC_CTYPE.")));
+
if (downer && downer->arg)
dbowner = defGetString(downer);
if (dtemplate && dtemplate->arg)
parser_errposition(pstate, dencoding->location)));
}
}
+ if (dlocale && dlocale->arg)
+ {
+ dbcollate = defGetString(dlocale);
+ dbctype = defGetString(dlocale);
+ }
if (dcollate && dcollate->arg)
dbcollate = defGetString(dcollate);
if (dctype && dctype->arg)
appendPQExpBufferStr(creaQry, " ENCODING = ");
appendStringLiteralAH(creaQry, encoding, fout);
}
- if (strlen(collate) > 0)
+ if (strlen(collate) > 0 && strcmp(collate, ctype) == 0)
{
- appendPQExpBufferStr(creaQry, " LC_COLLATE = ");
+ appendPQExpBufferStr(creaQry, " LOCALE = ");
appendStringLiteralAH(creaQry, collate, fout);
}
- if (strlen(ctype) > 0)
+ else
{
- appendPQExpBufferStr(creaQry, " LC_CTYPE = ");
- appendStringLiteralAH(creaQry, ctype, fout);
+ if (strlen(collate) > 0)
+ {
+ appendPQExpBufferStr(creaQry, " LC_COLLATE = ");
+ appendStringLiteralAH(creaQry, collate, fout);
+ }
+ if (strlen(ctype) > 0)
+ {
+ appendPQExpBufferStr(creaQry, " LC_CTYPE = ");
+ appendStringLiteralAH(creaQry, ctype, fout);
+ }
}
/*
like => { pg_dumpall_dbprivs => 1, },
},
+ "CREATE DATABASE dump_test2 LOCALE = 'C'" => {
+ create_order => 47,
+ create_sql => "CREATE DATABASE dump_test2 LOCALE = 'C' TEMPLATE = template0;",
+ regexp => qr/^
+ \QCREATE DATABASE dump_test2 \E.*\QLOCALE = 'C';\E
+ /xm,
+ like => { pg_dumpall_dbprivs => 1, },
+ },
+
'CREATE EXTENSION ... plpgsql' => {
regexp => qr/^
\QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E