Re: [PATCHES] Fixes for MONEY type using locale - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCHES] Fixes for MONEY type using locale
Date
Msg-id 200711270532.lAR5W9O17619@momjian.us
Whole thread Raw
In response to Re: [PATCHES] Fixes for MONEY type using locale  ("Joshua D. Drake" <jd@commandprompt.com>)
List pgsql-hackers
Joshua D. Drake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Mon, 26 Nov 2007 23:47:04 -0500 (EST)
> Bruce Momjian <bruce@momjian.us> wrote:
> 
> > Perhaps all we need is a way to accomplish the casting so it isn't
> > automatic.  This works:
> > 
> >     test=> SELECT regexp_replace('2343'::money::text, '[^$,]*',
> > '', 'g')::numeric; regexp_replace
> >     ----------------
> >             2343.00
> >     (1 row)
> > 
> > but the '$' and ',' are locale-specific and I can't think of a way to
> > do this generically.
> 
> With a regex?

The problem is there is no locale-independent way to determine if
'123.456' is ~123k or ~123.  I think we are going to need a way to
output the MONEY value without a currency and thousands symbols.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://postgres.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: [PATCHES] Fixes for MONEY type using locale
Next
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] Proposed patch for operator lookup caching