Re: cast from integer to money

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com>, 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 15:01:15
Message-ID: BANLkTi=Ot7aFzpCvdLuL2rqNYEB5Nh+o0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 4, 2011 at 10:58 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> 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:
>
>>> cash_in doesn't test for overflow, either (tested on 8.4.0, 9.0.3, and HEAD):
>>> 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...
>
> I'm fairly sure that *none* of the money operations bother to check for
> overflow; not only input, but arithmetic.  That falls somewhere between
> bug and missing feature.  It's probably worth fixing but seems outside
> the scope of the current patch.

Oh. Bummer. Yeah, that sounds more like a TODO than an open item.

> In the meantime, I'm not sure whether the newly added functions should
> be held to a higher standard than the existing ones.  It might be better
> to leave it be, and plan to fix them all at once in a consistent style.

Maybe. The numeric->money cast does handle it though, so there's at
least some precedent for checking. If you don't want to worry about
it, I'm OK with just putting it in as-is, but I'd probably be inclined
to look for a way to fix it if we can do that without adding too much
complexity.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kohei Kaigai 2011-04-04 15:01:51 [sepgsql] missing checks of process:transition on trusted procedure invocation
Previous Message Tom Lane 2011-04-04 14:58:16 Re: cast from integer to money