No migration path for MONEY - Mailing list pgsql-bugs

From Josh Berkus
Subject No migration path for MONEY
Date
Msg-id 200301241112.01170.josh@agliodbs.com
Whole thread Raw
Responses Re: No migration path for MONEY  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-bugs
Folks,

Bug reported off IRC:

MONEY Type cannot be cast to any other type, preventing migration from this=
=20
depreciated data type.

Affects: 7.2.3, 7.3.1
Frequency:  100% Reproducable
Effect When Occurring:   Unable to convert, query data
Difficulty of Fix:  Easy, probably
Certianty of Diagnosis:  100%

On both 7.2.3 and 7.3.1 all of the following statements will fail:

select cast('40.00'::MONEY as NUMERIC);
select cast('40.00'::MONEY as DOUBLE);
select cast('40.00'::MONEY as VARCHAR);
select "numeric"('40.00'::MONEY);
select to_char('40.00'::MONEY, '99999999999.9999');

This means that someone who has inherited or upgarded a 6.5 database with=
=20
MONEY columns has no way to migrate them to NUMERIC columns other than an=
=20
external language script or dump and reload from COPY file.=20=20=20

I propose that we need to restore the CAST(MONEY AS NUMERIC) function so th=
at=20
users can migrate old databases to the new data type.   In later versions o=
f=20
postgres, I suggest that MONEY be abandoned as a true data type and instead=
=20
become a DOMAIN of NUMERIC for those converting.

--=20
-Josh Berkus
 Aglio Database Solutions
 San Francisco

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #885: Trouble with timestamps after vacuuming
Next
From: Tom Lane
Date:
Subject: Re: Bug #885: Trouble with timestamps after vacuuming