Skip site navigation (1) Skip section navigation (2)

Re: cast from integer to money

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" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: cast from integer to money
Date: 2011-04-04 11:02:09
Message-ID: 83C03EB9-7AB0-45F2-9D6C-26963FB6DDC6@gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Apr 4, 2011, at 1:46 AM, Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> wrote:
> On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Thanks for the patch, but I think you forgot to worry about overflow:
>> 
>> rhaas=# select 9223372036854775807::money;
>>  money
>> --------
>>  -$1.00
>> (1 row)
> 
> cash_in doesn't test for overflow, either (tested on 8.4.0, 9.0.3, and HEAD):
> 
> joey=# select '9223372036854775807'::money;
> money
> --------
> -$1.00
> (1 row)
> 
> Is this a bug?

Seems like it. You have to feel sorry for the guy who deposits 9 quintillion dollars and then gets a note from the bank saying his account is overdrawn...

> Detail: unlike cash_in, numeric_cash does check for overflow
> (implicitly, through its use of numeric_int8).

Yeah.

...Robert

In response to

Responses

pgsql-hackers by date

Next:From: Andrew DunstanDate: 2011-04-04 11:09:31
Subject: Re: cast from integer to money
Previous:From: Shigeru HANADADate: 2011-04-04 10:49:09
Subject: Re: Re: [COMMITTERS] pgsql: Support comments on FOREIGN DATA WRAPPER and SERVER objects.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group