pg_createcluster prints wrong locale

Bug #1467061 reported by dana
This bug affects 1 person
Affects Status Importance Assigned to Milestone
postgresql-common (Ubuntu)

Bug Description

`pg_createcluster` accepts a `--locale` option that tells it what locale it should create the new cluster with. During the creation process, the script prints information about the settings it's about to use. When it does this, it ignores the user-provided `--locale` value and instead prints the current `LC_CTYPE` environment setting.


% locale | grep -iE '(LANG|LC_ALL|LC_CTYPE)='

% sudo pg_createcluster --locale C 9.4 test1
Creating new cluster 9.4/test1 ...
  config /etc/postgresql/9.4/test1
  data /var/lib/postgresql/9.4/test1
  locale en_GB.utf8
Flags of /var/lib/postgresql/9.4/test1 set as -------------e-C
  port 5434

% export LC_CTYPE='C'
% sudo pg_createcluster --locale C 9.4 test2
Creating new cluster 9.4/test2 ...
  config /etc/postgresql/9.4/test2
  data /var/lib/postgresql/9.4/test2
  locale C
Flags of /var/lib/postgresql/9.4/test2 set as -------------e-C
  port 5435

Note that `pg_createcluster` DOES in fact use the expected locale setting when it creates the cluster — it just prints the wrong one (which is very confusing).

I believe the fix is as simple as this:

*** a/pg_createcluster 2015-06-20 02:38:52.000000000 -0500
--- b/pg_createcluster 2015-06-20 02:39:09.000000000 -0500
*** 363,367 ****
  } else {
! my $loc = setlocale (LC_CTYPE);
      print "Creating new cluster $version/$cluster ...\n";
      print " config $confdir\n data $datadir\n locale $loc\n";
--- 363,367 ----
  } else {
! my $loc = $locale || setlocale (LC_CTYPE);
      print "Creating new cluster $version/$cluster ...\n";
      print " config $confdir\n data $datadir\n locale $loc\n";

Related branches

Revision history for this message
Martin Pitt (pitti) wrote :
Changed in postgresql-common (Ubuntu):
status: New → Fix Committed
importance: Undecided → Low
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package postgresql-common - 170

postgresql-common (170) unstable; urgency=medium

  [ Christoph Berg ]
  * pg_createcluster, pg_dropcluster: When an auto-started cluster is created/
    dropped by root, notify systemd to update the dependencies of
  * pg_dropcluster, pg_renamecluster: Handle stats_temp_directory.
  * testsuite, pg_virtualenv: Remove the unshare hack, too much trouble.
  * pg_buildext, pg_virtualenv: Add PG_VIRTUALENV_NEWPID and
    PG_VIRTUALENV_UNSHARE variables; pg_buildext selects unshare -n by default.
  * t/025_logging.t: Improve syslog detection in the test environment.
  * pg_upgradecluster, t/030_errors.t: Unbreak after we changed the old=new
    error message.
  * make read_cluster_conf_file read as well
    (Closes: #787154)
  * pg_upgradecluster: Support upgrading tablespaces. (Closes: #772202)
  * t/ New function program_ok().
  * t/040_upgrade.t: Skip testing pg_upgrade with datallowconn = f, it does
    not support that anymore as of May 2015.
  * t/170_extensions.t: Catch warning with chkpass >= 9.5.
  * debian/maintscripts-functions: Unset all locale-specific environment
    variables when creating the initial database cluster. (Closes: #791526)
  * Add /var/log/postgresql to /usr/lib/tmpfiles.d/postgresql.conf.
  * Also set OOMScoreAdjust in postgresql@.service.
  * pg_ctlcluster: OOM-protect 9.0 as well.
  * pg_lsclusters: Color online/down clusters green/red.
  * supported-versions: Accept DEB_PG_SUPPORTED_VERSIONS as well.
  * Ship /etc/postgresql/ in postgresql-common. (Closes: #801140)

  [ Martin Pitt ]
  * pg_createcluster: Show the locale selected with --locale instead of the
    current one. (LP: #1467061)

 -- Christoph Berg <email address hidden> Thu, 08 Oct 2015 13:48:26 +0200

Changed in postgresql-common (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers