Skip site navigation (1) Skip section navigation (2)

[PATCH] Contrib C source for casting MONEY to INT[248] and FLOAT[48]

From: "David D(dot) Kilzer" <ddkilzer(at)lubricants-oil(dot)com>
To: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Cc: "David D(dot) Kilzer" <ddkilzer(at)theracingworld(dot)com>, Hitesh Patel <hitesh(at)presys(dot)com>, Jose Soares <jose(at)sferacarta(dot)com>
Subject: [PATCH] Contrib C source for casting MONEY to INT[248] and FLOAT[48]
Date: 2001-06-14 14:31:06
Message-ID: 20010614093105.A14642@elbonia.lubricants-oil.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackerspgsql-patches
Attached please find a patch to cast (convert) the MONEY type to any one
of the following types:

  INT2, INT4, INT8, FLOAT4, FLOAT8

The patch is against PostgreSQL v7.0.3 and creates files in a new
directory named contrib/money/.  I'm pretty sure it won't compile
against v7.1, but it won't be too hard to fix.  (I'll do this when I
upgrade to v7.1 at work, which will hopefully happen sooner rather than
later.)

I wrote this because I needed to convert MONEY to a standard decimal
value and didn't want to do it on the client in Perl, and I didn't want
to use a plpgsql function that used string parsing.  Both solutions were
too inefficient for my needs.

  http://postgresql.bteg.net/mhonarc/pgsql-general/2000-01/msg00446.html

I wouldn't have used the MONEY type in the first place if I had known it
was deprecated, but I didn't see this notice in the v7.0.3 documentation
two to three months ago when designing the database.  Oh well, my loss
is your gain.  :^)

I've attempted to set the Reply-To field to pgsql-hackers, but please
copy me on any posts as well.

Comments welcome!

Dave

Responses

pgsql-hackers by date

Next:From: Hannu KrosingDate: 2001-06-14 14:34:48
Subject: Re: 7.0.3 database corruption
Previous:From: Tom LaneDate: 2001-06-14 14:01:15
Subject: Re: 7.0.3 database corruption

pgsql-patches by date

Next:From: Peter EisentrautDate: 2001-06-14 15:15:07
Subject: Re: [PATCHES] Removal of temp tables
Previous:From: Thomas LockhartDate: 2001-06-14 13:54:59
Subject: Re: Australian timezone configure option

pgsql-general by date

Next:From: Peter EisentrautDate: 2001-06-14 14:47:54
Subject: Re: Log files, how to rotate properly
Previous:From: Lamar OwenDate: 2001-06-14 14:30:33
Subject: Re: Log files, how to rotate properly

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group