pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13636: psql numericlocale adds comma where it ought not
Date: Fri, 25 Sep 2015 11:16:44 -0400
Message-ID: <6391.1443194204@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEepm=2tm4wSgoTj6TBxZqj9f8EaLRmFYTbdey6f2EDy7GLcfA@mail.gmail.com>
References: <20150924202545.26913.85050@wrigleys.postgresql.org>
	<21049.1443137840@sss.pgh.pa.us>
	<CAEepm=1nTC__rwR78OE5NRW_AK4XYU6RsQxwxRv7m16=C5mUsg@mail.gmail.com>
	<27190.1443147551@sss.pgh.pa.us>
	<CAEepm=0x_-CpXc2VctwvKBn2eJ-HK04eZWFG1tAwr7d7kxJAyw@mail.gmail.com>
	<21952.1443153991@sss.pgh.pa.us>
	<CAEepm=2tm4wSgoTj6TBxZqj9f8EaLRmFYTbdey6f2EDy7GLcfA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Thomas Munro <thomas.munro@enterprisedb.com> writes:
> About your follow-up commit 6325527d845b629243fb3f605af6747a7a4ac45f,
> I noticed that glibc localedata has some grouping values of 0 (no
> grouping at all), for example nl_NL, el_GR, hr_HR, it_IT, pl_PL,
> es_CU, pt_PT and we don't honour that, if it's 0 we use 3.  All the
> rest begin with 3, except for unm_US which uses 2;2;2;3 (apparently a
> Delaware language), and I confirmed that now produces strings like "12
> 34 56", so I guess that obscure locale may be the only case that the
> commit actually changes on a glibc system.

Yeah, the locales where grouping isn't just 3 are so obscure that
I don't particularly care.  If someone from one of those areas
wants to submit a feature patch to implement grouping more fully,
more power to 'em ...

However, I checked this morning and found that the MONEY case that
was niggling me yesterday is indeed a problem, for instance in de_DE:

$ LC_NUMERIC=de_DE psql regression
psql (9.6devel)
Type "help" for help.

regression=# set lc_monetary = 'de_DE';
SET
regression=# select '123456.78'::money;
       money       
-------------------
 12.345.678,00 EUR
(1 row)

regression=# \pset numericlocale on
Locale-adjusted numeric output is on.
regression=# select '123456.78'::money;
       money       
-------------------
 12,345.678,00 EUR
(1 row)

So we're gonna have to do something about that.  I considered
a few fixes:

* Remove CASHOID from the set of datatypes that printQuery will choose
to right-justify.  This seems likely to annoy people who are used to
having money amounts right-justified.

* Separate "use locale formatting" from "right justify", and apply only
the latter to CASHOID.  This would be the cleanest fix but by far the
most invasive.  I don't particularly want to do that much work and I
definitely wouldn't want to back-patch it.

* Put a hack into format_numeric_locale() so that it won't mess with
monetary output.  This seems feasible because cash_out() always insists
on using a non-empty currency symbol.  For example, we could check that
the string includes no characters outside "0123456789+-.eE" and feel
pretty safe that no money value would pass the check.

So I'm inclined to do the third one.  Objections, better ideas?

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (8+ messages)

Message-ID: <6391.1443194204@sss.pgh.pa.us>
Permalink:  ../6391.1443194204@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6391.1443194204@sss.pgh.pa.us

 · 

reply

Reply instructions:

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

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, thomas.munro@enterprisedb.com, jeff.janes@gmail.com
  Subject: Re: BUG #13636: psql numericlocale adds comma where it ought not
  In-Reply-To: <6391.1443194204@sss.pgh.pa.us>
  References: <20150924202545.26913.85050@wrigleys.postgresql.org> <21049.1443137840@sss.pgh.pa.us> <CAEepm=1nTC__rwR78OE5NRW_AK4XYU6RsQxwxRv7m16=C5mUsg@mail.gmail.com> <27190.1443147551@sss.pgh.pa.us> <CAEepm=0x_-CpXc2VctwvKBn2eJ-HK04eZWFG1tAwr7d7kxJAyw@mail.gmail.com> <21952.1443153991@sss.pgh.pa.us> <CAEepm=2tm4wSgoTj6TBxZqj9f8EaLRmFYTbdey6f2EDy7GLcfA@mail.gmail.com> <6391.1443194204@sss.pgh.pa.us>

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

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox