unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Christopher Baines <mail@cbaines.net>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 2/2] services: postgresql: Add locale to configuration
Date: Wed, 14 Dec 2016 00:09:18 +0100	[thread overview]
Message-ID: <871sxbl941.fsf@gnu.org> (raw)
In-Reply-To: <8e95bcb3-15de-1176-5164-1bdbfae4698a@cbaines.net> (Christopher Baines's message of "Mon, 12 Dec 2016 06:53:20 +0000")

Christopher Baines <mail@cbaines.net> skribis:

> On 11/12/16 23:14, Ludovic Courtès wrote:
>> Hi!
>>
>> Christopher Baines <mail@cbaines.net> skribis:
>>
>>> * gnu/services/postgresql.scm (<postgresql-configuration>): Add locale
>>>   field.
>>>   (postgresql-shepherd-service): Pass locale to initdb.
>>>   (postgresql-service): Add locale default.
>>
>> [...]
>>
>>> +  (locale         postgresql-configuration-locale
>>> +                  (default "en_US.UTF-8"))
>>
>> Note: this should use the “normalized codeset”, so “en_US.utf8”.
>>
>>>           (let ((user (getpwnam "postgres"))
>>> -               (initdb (string-append #$postgresql "/bin/initdb")))
>>> +               (initdb (string-append #$postgresql "/bin/initdb"))
>>> +               (initdb-args
>>> +                (append
>>> +                 (if #$locale
>>> +                     (list (string-append "--locale=" #$locale))
>>> +                     '()))))
>>>             ;; Create db state directory.
>>>             (mkdir-p #$data-directory)
>>>             (chown #$data-directory (passwd:uid user) (passwd:gid user))
>>> @@ -103,14 +110,19 @@ host	all	all	::1/128 	trust"))
>>>                  (lambda ()
>>>                    (setgid (passwd:gid user))
>>>                    (setuid (passwd:uid user))
>>> -                  (primitive-exit (system* initdb "-D" #$data-directory)))
>>> +                  (primitive-exit
>>> +                   (apply system*
>>> +                          initdb
>>> +                          "-D"
>>> +                          #$data-directory
>>> +                          initdb-args)))
>>>                  (lambda ()
>>>                    (primitive-exit 1))))
>>>               (pid (waitpid pid))))))))
>>
>> The effect of that is that ‘initdb’, but not ‘postgresql’ itself, would
>> run in a locale different from the system locale by default.
>>
>> These two inconsistencies may be quite confusing.  WDYT?
>
> I believe the locale passed to initdb sets "the default locale for the
> database cluster",

Oh, so it affects the initial format of the DB, right?  In that case,
you’re right of course.

> I thought about trying to get the LANG from /etc/environment, or the
> <operating-system>, but I could not see an easy and elegant way to do
> either. By default, initdb will use the environment, its just that the
> environment during service activation contains no locale information.

With 97bb1ab66519736afbdab57c230c3a9deef2fa05 there *is* locale data
available at least, right?

But yeah, there’s no easy way to retrieve the currently-configured system
locale, so let’s forget about it (maybe add an “XXX” comment next to
it.)

Could you send an updated patch with (1) the normalized codeset by
default (“en_US.utf8”), and (2) a guix.texi update mentioning the new
option?

Thanks in advance!

Ludo’.

  reply	other threads:[~2016-12-13 23:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11 21:13 [PATCH 1/2] services: postgresql: Add port to configuration Christopher Baines
2016-12-11 21:13 ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
2016-12-11 23:14   ` Ludovic Courtès
2016-12-12  6:53     ` Christopher Baines
2016-12-13 23:09       ` Ludovic Courtès [this message]
2016-12-14  8:35         ` [PATCH 1/2] services: postgresql: Add port " Christopher Baines
2016-12-14  8:35           ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
2016-12-15 15:55             ` Ludovic Courtès
2016-12-15 15:54           ` [PATCH 1/2] services: postgresql: Add port " Ludovic Courtès
2016-12-11 23:02 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871sxbl941.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=mail@cbaines.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).