Re: cast from integer to money

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: cast from integer to money
Дата
Msg-id BANLkTinUxdO94FxO46+fVDgV=Z_AWNCf3g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: cast from integer to money  (Joseph Adams <joeyadams3.14159@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Dimitri Fontaine
Дата:
Сообщение: Re: Extensions Dependency Checking
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: Proposal: q-gram GIN and GiST indexes