Marko Mikulicic <marko@seul.org> writes:
> Tom Lane wrote:
>> Note though that most of us think the current money type is a kluge
>> anyway; anything based on int4 storage doesn't have enough significant
>> digits. It would be better rewritten as a thin locale-aware veneer
>> over type "numeric".
> I agree.
> Is there an example of how to inherit from a parametrized type ?
I think you could mostly do this with binary compatibility: if money
were binary-equivalenced to numeric then most of the right things
would happen. (Compare type regproc to type oid --- regproc has
no behavior other than special I/O functions, and still manages to
inherit most of oid's other behaviors.)
One thing you would not get out of that is the ability to say
"money(m,n)" to specify precision --- that would take specialized
hacking in the parser. But I'm not sure you want it. The preferred
number of fractional digits should be determined from the monetary
locale, *not* from any SQL declaration. And there's no good reason to
limit the total number of digits at all.
> Is possible to view the CREATE TYPE command which creates the
> internal type numeric?
There is no such command, because internal types are "created" by
direct insertions of rows into pg_type during initdb. Look at
the contents of src/include/catalog/pg_type.h.
> If you want to use numeric I guess you cannot use strfmon because it uses
> float or double and it's not arbitrary precision.
Ugh. Time to start writing code :-(
regards, tom lane