Re: [HACKERS] cast from integer to money

2011-04-05 Thread Robert Haas
On Tue, Apr 5, 2011 at 1:10 AM, Joseph Adams 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

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Joseph Adams
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. - Joey diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index ecc79e2..13b888d 100644 --- a/doc/src/sgml

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Robert Haas
On Mon, Apr 4, 2011 at 10:58 AM, Tom Lane wrote: > Robert Haas writes: >> On Apr 4, 2011, at 1:46 AM, Joseph Adams wrote: >>> On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas wrote: Thanks for the patch, but I think you forgot to worry about overflow: > >>> cash_in doesn't test for overflow, e

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Tom Lane
Robert Haas writes: > On Apr 4, 2011, at 1:46 AM, Joseph Adams wrote: >> On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas 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 bu

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Andrew Dunstan
On Mon, April 4, 2011 7:02 am, Robert Haas wrote: > 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... > Not really ... cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.o

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Robert Haas
On Apr 4, 2011, at 1:46 AM, Joseph Adams wrote: > On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas 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 fo

Re: [HACKERS] cast from integer to money

2011-04-03 Thread Joseph Adams
On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas 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=#

Re: [HACKERS] cast from integer to money

2011-04-03 Thread Tom Lane
Robert Haas writes: > On Fri, Apr 1, 2011 at 10:33 PM, Joseph Adams > wrote: >> The only other numeric types (other than oid, cardinal_number, >> etc.) that can't be casted directly to money are float4 and float8, >> and I suspect this is intentional. > Agreed. BTW, I think inclusion of int2 in

Re: [HACKERS] cast from integer to money

2011-04-03 Thread Robert Haas
On Fri, Apr 1, 2011 at 10:33 PM, Joseph Adams wrote: > On Thu, Mar 31, 2011 at 6:39 PM, Stephen Frost wrote: >> Going just integer->money, with the "1" -> "$1.00", seems completely >> reasonable to me.  As for being too late in the cycle..  if someone's >> willing to do the work, I can't imagine

Re: [HACKERS] cast from integer to money

2011-04-01 Thread Joseph Adams
On Thu, Mar 31, 2011 at 6:39 PM, Stephen Frost wrote: > Going just integer->money, with the "1" -> "$1.00", seems completely > reasonable to me.  As for being too late in the cycle..  if someone's > willing to do the work, I can't imagine it breaking anything, so I > wouldn't be against putting it

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Robert Haas
On Mar 31, 2011, at 6:39 PM, Stephen Frost wrote: > * Kevin Grittner (kevin.gritt...@wicourts.gov) wrote: >> If you're just talking about going in the one direction, I might be >> persuaded that's sane, especially because of the case of literals, >> and especially since there are currencies where

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Stephen Frost
* Kevin Grittner (kevin.gritt...@wicourts.gov) wrote: > If you're just talking about going in the one direction, I might be > persuaded that's sane, especially because of the case of literals, > and especially since there are currencies where fractional amounts > aren't used in the conventional rep

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Kevin Grittner
Robert Haas wrote: >> There were reasonable arguments made why this could be a bad idea >> -- primarily around the question of whether '395' represented >> $3.95 or $395.00. > > That's not too hard to figure out, right? If 1.00 means $1.00, 1 > had better not mean $0.01, or there will be riots

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Robert Haas
On Thu, Mar 31, 2011 at 4:58 PM, Kevin Grittner wrote: > Robert Haas wrote: >> On the open items list, we have: >> >> conversion from integer literals to money type >> http://archives.postgresql.org/pgsql-testers/2011-01/msg0.php >> >> What this is really complaining about is that we added a

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Kevin Grittner
Robert Haas wrote: > On the open items list, we have: > > conversion from integer literals to money type > http://archives.postgresql.org/pgsql-testers/2011-01/msg0.php > > What this is really complaining about is that we added a cast from > numeric to money, but not from integer to money.

[HACKERS] cast from integer to money

2011-03-31 Thread Robert Haas
On the open items list, we have: conversion from integer literals to money type http://archives.postgresql.org/pgsql-testers/2011-01/msg0.php What this is really complaining about is that we added a cast from numeric to money, but not from integer to money. This isn't really a bug: the fact