Re: Number format problem

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Number format problem
Date: 2006-02-06 11:15:52
Message-ID: 20060206121927.827211@crocodudule.admin.clubint.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Peter Eisentraut wrote:

> Stéphane SCHILDKNECHT wrote:
> > select to_char(1485.12, '9G999D99');
>
> > But, surprinsingly, I got 1,1485,12.
>
> The fr_FR locale is broken. You should report this to glibc.

On my debian sarge with LC_NUMERIC set to fr_FR(at)euro, a
printf("%'g\n", 1485.12);
produces 1485,12 with which seems to be correct given that the
'thousands_sep' locale entry is set to "" (empty string) and
'decimal_point' to U002C

On the other hand, what postgres produces is:
test=> set lc_numeric='fr_FR(at)euro';
SET
test=> select to_char(1485.12, '9G999D99');
to_char
-----------
1,485,12
(1 row)

which is wrong with regard to thousands_sep="".

In fact, grep'ing the source code reveals that, when 'thousands_sep' is set to
an empty string, it gets ignored and a comma is used instead.
I'm referring to backend/utils/adt/formatting.c, NUM_prepare_locale() in 8.1.2:

/*
* Number thousands separator
*/
if (lconv->thousands_sep && *lconv->thousands_sep)
Np->L_thousands_sep = lconv->thousands_sep;
else
Np->L_thousands_sep = ",";

What's wrong with lconv->thousands_sep being set to an empty string?
Shouldn't it be used nonetheless?

--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Simon Riggs 2006-02-06 11:43:43 Re: Logging statements and parameter values
Previous Message Richard Huxton 2006-02-06 11:10:13 Re: old style outer joins

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2006-02-06 13:49:13 Re: slow information schema with thausand users, seq.scan pg_authid
Previous Message Pavel Stehule 2006-02-06 09:58:43 slow information schema with thausand users, seq.scan pg_authid