Re: [HACKERS] numeric data type on 6.5

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jan Wieck <jwieck(at)debis(dot)com>, hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] numeric data type on 6.5
Date: 1999-05-04 17:23:09
Message-ID: 199905041723.NAA00660@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > > I'm looking at this right now. I had coded in a fallback to FLOAT8 for
> > > the integer types because at the time that was the only other useful
> > > numeric type. However, I'm going to try changing the code to leave a
> > > failed INTx token as a string of unspecified type, which would be
> > > typed and converted later using the automatic coersion mechanism.
> > That would be good as far as it goes, but what about cases with a
> > decimal point in 'em? Converting to float and then to numeric will
> > lose precision.
> > I'm inclined to think you should prevent the parser from converting
> > *any* numeric constant out of string form until it knows the target data
> > type.
> > (IIRC, INT8 has problems similar to NUMERIC's...)
>
> Right. Here is a patch which tries to do something right for most
> cases. For the "integer" token (numbers w/o a decimal point) it keeps
> the token as a string if the conversion to int4 fails. I split the
> "real" token into "decimal" (w/o exponent) and "real"; at the moment
> "decimal" is forced to become a float8 if there are fewer than 18
> characters in the string, but there may be a more robust strategy to
> be had.

This seems like a perfect approach.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 1999-05-04 18:01:25 Re: [HACKERS] posmaster failed under high load
Previous Message Bruce Momjian 1999-05-04 17:21:52 Re: [HACKERS] an older problem? hash table out of memory