Re: cast from integer to money - Mailing list pgsql-hackers

From Robert Haas
Subject Re: cast from integer to money
Date
Msg-id BANLkTinUxdO94FxO46+fVDgV=Z_AWNCf3g@mail.gmail.com
Whole thread Raw
In response to Re: cast from integer to money  (Joseph Adams <joeyadams3.14159@gmail.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Dimitri Fontaine
Date:
Subject: Re: Extensions Dependency Checking
Next
From: Alexander Korotkov
Date:
Subject: Re: Proposal: q-gram GIN and GiST indexes