From: | "Itagaki Takahiro" <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #4845: cash_in is broken for lc_monetary = 'ja' |
Date: | 2009-06-10 07:13:08 |
Message-ID: | 200906100713.n5A7D8m3072505@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 4845
Logged by: Itagaki Takahiro
Email address: itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp
PostgreSQL version: 8.4dev, 8.3.7
Operating system: Windows XP
Description: cash_in is broken for lc_monetary = 'ja'
Details:
The type input function for money is broken
if lc_monetary is set to zero-precision locale.
Since Japanese "yen" has no decimal fractions,
lconv.frac_digits is 0 when lc_monetary = 'ja'.
I tested the bug in 8.3.7 and 8.4dev, but probably
we need to port it to older versions.
=# SET lc_monetary = 'en';
=# SELECT '$123'::money;
money
---------
$123.00
(1 row)
=# SET lc_monetary = 'ja';
=# SELECT E'\\123'::money;
money
-------
\0 <== should be \123.
(1 row)
[Patch attached]
Index: src/backend/utils/adt/cash.c
===================================================================
--- src/backend/utils/adt/cash.c (HEAD)
+++ src/backend/utils/adt/cash.c (fixed)
@@ -193,7 +193,7 @@
{
/* we look for digits as int8 as we have less */
/* than the required number of decimal places */
- if (isdigit((unsigned char) *s) && dec < fpoint)
+ if (isdigit((unsigned char) *s) && (!seen_dot || dec < fpoint))
{
value = (value * 10) + *s - '0';
@@ -236,7 +236,7 @@
result = value * sgn;
#ifdef CASHDEBUG
- printf("cashin- result is %d\n", result);
+ printf("cashin- result is " INT64_FORMAT "\n", result);
#endif
PG_RETURN_CASH(result);
From | Date | Subject | |
---|---|---|---|
Next Message | Anders Gunnarsson | 2009-06-10 08:40:59 | BUG #4846: Error reading file: config |
Previous Message | Daniele Bortoluzzi | 2009-06-10 06:38:49 | Re: BUG #4838: Database corruption after btree_gin index creation |