From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> |
Cc: | Stephen Frost <sfrost(at)snowman(dot)net>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: cast from integer to money |
Date: | 2011-04-04 03:23:48 |
Message-ID: | BANLkTi=qzAhufDZ-oQfH-mt13i1FZw5giQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Apr 1, 2011 at 10:33 PM, Joseph Adams
<joeyadams3(dot)14159(at)gmail(dot)com> wrote:
> On Thu, Mar 31, 2011 at 6:39 PM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>> Going just integer->money, with the "1" -> "$1.00", seems completely
>> reasonable to me. As for being too late in the cycle.. if someone's
>> willing to do the work, I can't imagine it breaking anything, so I
>> wouldn't be against putting it in. It really should be before the
>> first beta tho.
>
> Attached is a patch which enables casting int2/int4/int8 to money,
> with the same scaling as numeric uses. Hence, 1::money yields '$1.00'
Thanks for the patch, but I think you forgot to worry about overflow:
rhaas=# select 9223372036854775807::money;
money
--------
-$1.00
(1 row)
> . The only other numeric types (other than oid, cardinal_number,
> etc.) that can't be casted directly to money are float4 and float8,
> and I suspect this is intentional.
Agreed.
> The patch includes tests, but does not update the documentation.
> Should the docs be updated where it reads "Values of the numeric data
> type can be cast to money. Other numeric types can be converted to
> money by casting to numeric first" ?
Yes.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2011-04-04 03:26:22 | Re: Finding a flow when query is fired in postgresql |
Previous Message | Robert Haas | 2011-04-04 01:53:57 | Re: BUG #5856: pg_attribute.attinhcount is not correct. |