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

Re: [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: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Contrib C source for casting MONEY to INT[248] and FLOAT[48]
Date: 2001-06-19 15:03:55
Message-ID: 20010619100355.A20923@elbonia.lubricants-oil.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackerspgsql-patches
On Tue, Jun 19, 2001 at 10:20:18AM -0400, Tom Lane wrote:

> "David D. Kilzer" <ddkilzer(at)lubricants-oil(dot)com> writes:
> > Attached please find a patch to cast (convert) the MONEY type to any one
> > of the following types:
> >   INT2, INT4, INT8, FLOAT4, FLOAT8
> 
> Hmm.  It strikes me as a rather bad idea to introduce implicit casting
> of MONEY to all these other types --- I suspect that's going to create
> a bunch of parsing ambiguities.

Well, that's why the patch puts the code under contrib/.  I meant this
to be optional code that could be added to PostgreSQL if people needed
the functionality, i.e., for transition work.  I'm sorry if that wasn't
clear in my original post.

Should I have not submitted this code to the pgsql-patches list?

> > 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.
> 
> Seems like a better answer is to use NUMERIC instead of MONEY in the
> first place...

The reason for this (in my case) was covered in the next paragraph:

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

So for those of us who accidentally used the MONEY type (or had legacy
tables that used the MONEY type), these functions (especially the
FLOAT8 type conversion) are extremely useful for transition work.

I don't really care if the code is included with future PostgreSQL
releases or not.  I just wanted to save other people some time if or
when they decide to transition off the MONEY type.

Dave

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-06-19 15:40:57
Subject: Re: AW: Re: [SQL] behavior of ' = NULL' vs. MySQL vs. Stand ards
Previous:From: Alex PilosovDate: 2001-06-19 14:26:19
Subject: Re: PlPerl compile failure

pgsql-patches by date

Next:From: Vivek KheraDate: 2001-06-19 15:53:57
Subject: Re: MySQL Question
Previous:From: Tom LaneDate: 2001-06-19 14:51:41
Subject: Re: possible patch to increase number of hash overflow pages?

pgsql-general by date

Next:From: Tom LaneDate: 2001-06-19 15:48:44
Subject: Re: Re: Still getting problems with -cache lookup for userid 26 failed- (PART 2)
Previous:From: Pete LeonardDate: 2001-06-19 15:02:28
Subject: Re: rule on insert with default values for new instance

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