Re: [HACKERS] numeric data type on 6.5 - Mailing list pgsql-hackers

From Thomas Lockhart
Subject Re: [HACKERS] numeric data type on 6.5
Date
Msg-id 37267F9B.FC9DE090@alumni.caltech.edu
Whole thread Raw
In response to Re: [HACKERS] numeric data type on 6.5  (jwieck@debis.com (Jan Wieck))
List pgsql-hackers
> >     The  problem is that the yacc parser already tries to convert
> >     it into an integer or float if you omit the quotes.
> ... 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.

OK, this seems to work:

postgres=> create table t1 (n numeric(20,0));
CREATE
postgres=> insert into t1 values ('10000000000000000000');
INSERT 18552 1
postgres=> insert into t1 values (20000000000000000000);
INSERT 18553 1
postgres=> select * from t1;                  n
--------------------
10000000000000000000
20000000000000000000

postgres=> select n * 5000000000000000000000000000000 from t1;
---------------------------------------------------50000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000

But, there are some cases which aren't transparent:

postgres=> select 10000000000000000000000000*2;
ERROR:  pg_atoi: error reading "10000000000000000000000000": Numerical
result out of range
postgres=> select 10000000000000000000000000*2::numeric;
--------------------------
20000000000000000000000000

And, if a long numeric string is entered, it actually stays a string
all the way through (never being converted to anything internal):

postgres=> select 400000000000000000000000000000000000000000000000000;
---------------------------------------------------
400000000000000000000000000000000000000000000000000

Comments?

btw, I've got some float8->numeric conversion troubles on my
i686/Linux box:

postgres=> insert into t1 values ('30000000000000000000'::float8);
INSERT 18541 1
postgres=> select * from t1;                n
------------------                3

Any ideas on this last one?

I'm running from this morning's development tree...
                           - Tom

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


pgsql-hackers by date:

Previous
From: Michael J Davis
Date:
Subject: RE: [HACKERS] Issues with the latest 6.5 source
Next
From: "Hiroshi Inoue"
Date:
Subject: RE: [HACKERS] Lock freeze ? in MVCC