On Tue, Apr 5, 2011 at 1:10 AM, Joseph Adams <joeyadams3.14159@gmail.com> wrote:
> Attached is an updated version of the patch to allow conversion of
> int4/int8 directly to money. I added overflow checks, dropped
> int2->cash, and updated the documentation.
Excellent, thanks.
My only gripe is that I don't think we should duplicate int8mul, so
I've changed your patch to use this incantation:
+ result = DatumGetInt64(DirectFunctionCall2(int8mul, Int64GetDatum(amount
+ Int64GetDatum(scale)));
...which is parallel to what the existing numeric -> money cast
already does. That results in a slightly different error message, but
I think that's OK: no one has complained about the numeric -> cash
error message, or the fact that the remaining functions in this module
do no overflow checking at all.
With that change, committed. Thanks for picking this one up.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company