Skip to content

Commit

Permalink
Make locale option behavior more consistent
Browse files Browse the repository at this point in the history
Locale options can be specified for initdb, createdb, and CREATE
DATABASE.  In initdb, it has always been possible to specify --locale
and then some --lc-* option to override a category.  CREATE DATABASE
and createdb didn't allow that, requiring either the all-categories
option or only per-category options.  In
f2553d4, this was changed in CREATE
DATABASE (perhaps by accident?) to be more like the initdb behavior,
but createdb still had the old behavior.

Now we change createdb to match the behavior of CREATE DATABASE and
initdb, and also update the documentation of CREATE DATABASE to match
the new behavior, which was not done in the above commit.

Author: Marina Polyakova <m.polyakova@postgrespro.ru>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Discussion: https://www.postgresql.org/message-id/7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru
  • Loading branch information
petere committed Sep 13, 2022
1 parent 8e7a0b4 commit da5d4ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions doc/src/sgml/ref/create_database.sgml
Expand Up @@ -145,8 +145,7 @@ CREATE DATABASE <replaceable class="parameter">name</replaceable>
<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.
and <symbol>LC_CTYPE</symbol> at once.
</para>
<tip>
<para>
Expand Down
10 changes: 4 additions & 6 deletions src/bin/scripts/createdb.c
Expand Up @@ -161,12 +161,10 @@ main(int argc, char *argv[])

if (locale)
{
if (lc_ctype)
pg_fatal("only one of --locale and --lc-ctype can be specified");
if (lc_collate)
pg_fatal("only one of --locale and --lc-collate can be specified");
lc_ctype = locale;
lc_collate = locale;
if (!lc_ctype)
lc_ctype = locale;
if (!lc_collate)
lc_collate = locale;
}

if (encoding)
Expand Down

0 comments on commit da5d4ea

Please sign in to comment.