Re: [QUESTIONS] money * money? - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [QUESTIONS] money * money?
Date
Msg-id 3527C35E.A1F12A4F@alumni.caltech.edu
Whole thread Raw
List pgsql-hackers
> The following query works:
> brett=> select '1'::money * 2;
> but this one doesn't:
> brett=> select sum('1'::money) * 2
> with the following error:
> ERROR:  There is no operator '*' for types 'money' and 'money'
> bug?

Feature, until we fix it :)
I'm working on automatic type conversion for v6.4, and your specific
example already works in my preliminary code:

tgl=> select sum('$1.00'::money) * 2;
--------
$2.00
(1 row)

And even:

tgl=> select sum('$1.00'::money) * 2.5;
--------
$2.50
(1 row)

> Also, are there any plans to remove the dollar sign from the money
> type?  Or are we just going to use integers with precision.  How do I
> create a table with integers that only output the first two decimal
> places?

We don't yet have exact numerics with a scale other than zero (a
standard integer). We need to get an implementation with either a BCD
package, or 64-bit integers, or the GNU extended-precision math package,
or ?? to enable arbitrary range integers with scale. We also probably
need some work on the backend to pass along extended information for
these kinds of types (e.g. the precision and scale defined for a target
column).

                      - Tom

pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Open 6.3.1 issues
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Open 6.3.1 issues