Re: dangers of setlocale() in backend (was: problem with float8 input format)

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: ldm(at)apartia(dot)ch
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: dangers of setlocale() in backend (was: problem with float8 input format)
Date: 2000-08-14 12:06:50
Message-ID: Pine.LNX.3.96.1000814135745.4690B-100000@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


On Sat, 12 Aug 2000, Louis-David Mitterrand wrote:

> On Sat, Aug 12, 2000 at 12:15:26PM -0400, Tom Lane wrote:
> > Louis-David Mitterrand <cunctator(at)apartia(dot)ch> writes:
> > > When "seller_locale" is, for instance, "de_DE", then I get theses
> > > errors:
> > > ERROR: Bad float8 input format '0.05'
> > > Is Postgres expecting the float as 0,05 (notice the comma) because of
> > > the locale?

The postgreSQL allows to work with locale-numbers. See to_char()
and to_number() functions.

test=# select to_char(1234.456, '9G999D999');
to_char
------------
1 234,456
(1 row)

test=# select to_number('1 234,457', '9G999D999');
to_number
-----------
1234.457
(1 row)

And your backend will out of next Tom's note :-)

> > IMPORTANT: changing the backend's locale on-the-fly is an EXTREMELY
> > DANGEROUS thing to do, and I strongly recommend that you find another
> > way to solve your problem.

Karel

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Felipe Zirbes 2000-08-14 12:55:02 PostGres and ERwin
Previous Message Andreas Tille 2000-08-14 07:33:22 Servlet examples

Browse pgsql-hackers by date

  From Date Subject
Next Message Louis-David Mitterrand 2000-08-14 14:47:33 modifying a timestamp in a C trigger
Previous Message Zeugswetter Andreas SB 2000-08-14 08:24:39 AW: Optimizer confusion?