From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 2/2] services: postgresql: Add locale to configuration Date: Wed, 14 Dec 2016 00:09:18 +0100 Message-ID: <871sxbl941.fsf@gnu.org> References: <20161211211301.28403-1-mail@cbaines.net> <20161211211301.28403-2-mail@cbaines.net> <87shpuxdls.fsf@gnu.org> <8e95bcb3-15de-1176-5164-1bdbfae4698a@cbaines.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGwCL-00088S-4m for guix-devel@gnu.org; Tue, 13 Dec 2016 18:09:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGwCH-0003FW-Un for guix-devel@gnu.org; Tue, 13 Dec 2016 18:09:25 -0500 In-Reply-To: <8e95bcb3-15de-1176-5164-1bdbfae4698a@cbaines.net> (Christopher Baines's message of "Mon, 12 Dec 2016 06:53:20 +0000") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Christopher Baines Cc: guix-devel@gnu.org Christopher Baines skribis: > On 11/12/16 23:14, Ludovic Court=C3=A8s wrote: >> Hi! >> >> Christopher Baines skribis: >> >>> * gnu/services/postgresql.scm (): 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 =E2=80=9Cnormalized codeset=E2=80=9D, so =E2= =80=9Cen_US.utf8=E2=80=9D. >> >>> (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=3D" #$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-director= y))) >>> + (primitive-exit >>> + (apply system* >>> + initdb >>> + "-D" >>> + #$data-directory >>> + initdb-args))) >>> (lambda () >>> (primitive-exit 1)))) >>> (pid (waitpid pid)))))))) >> >> The effect of that is that =E2=80=98initdb=E2=80=99, but not =E2=80=98po= stgresql=E2=80=99 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=E2=80=99re right of course. > I thought about trying to get the LANG from /etc/environment, or the > , 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=E2=80=99s no easy way to retrieve the currently-configured = system locale, so let=E2=80=99s forget about it (maybe add an =E2=80=9CXXX=E2=80= =9D comment next to it.) Could you send an updated patch with (1) the normalized codeset by default (=E2=80=9Cen_US.utf8=E2=80=9D), and (2) a guix.texi update mentioni= ng the new option? Thanks in advance! Ludo=E2=80=99.