Re: [HACKERS] cast from integer to money

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

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Joseph Adams
On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas robertmh...@gmail.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

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Robert Haas
On Apr 4, 2011, at 1:46 AM, Joseph Adams joeyadams3.14...@gmail.com wrote: On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas robertmh...@gmail.com wrote: Thanks for the patch, but I think you forgot to worry about overflow: rhaas=# select 9223372036854775807::money; money -$1.00 (1

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.org)

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Apr 4, 2011, at 1:46 AM, Joseph Adams joeyadams3.14...@gmail.com wrote: On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas robertmh...@gmail.com wrote: Thanks for the patch, but I think you forgot to worry about overflow: cash_in doesn't test for

Re: [HACKERS] cast from integer to money

2011-04-04 Thread Robert Haas
On Mon, Apr 4, 2011 at 10:58 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Apr 4, 2011, at 1:46 AM, Joseph Adams joeyadams3.14...@gmail.com wrote: On Sun, Apr 3, 2011 at 11:23 PM, Robert Haas robertmh...@gmail.com wrote: Thanks for the patch, but I think

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 ---

Re: [HACKERS] cast from integer to money

2011-04-03 Thread Robert Haas
On Fri, Apr 1, 2011 at 10:33 PM, Joseph Adams joeyadams3.14...@gmail.com wrote: On Thu, Mar 31, 2011 at 6:39 PM, Stephen Frost sfr...@snowman.net 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

Re: [HACKERS] cast from integer to money

2011-04-03 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Fri, Apr 1, 2011 at 10:33 PM, Joseph Adams joeyadams3.14...@gmail.com 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.

Re: [HACKERS] cast from integer to money

2011-04-01 Thread Joseph Adams
On Thu, Mar 31, 2011 at 6:39 PM, Stephen Frost sfr...@snowman.net 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

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Kevin Grittner
Robert Haas robertmh...@gmail.com 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

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Robert Haas
On Thu, Mar 31, 2011 at 4:58 PM, Kevin Grittner kevin.gritt...@wicourts.gov wrote: Robert Haas robertmh...@gmail.com 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

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Kevin Grittner
Robert Haas robertmh...@gmail.com 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

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

Re: [HACKERS] cast from integer to money

2011-03-31 Thread Robert Haas
On Mar 31, 2011, at 6:39 PM, Stephen Frost sfr...@snowman.net 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