RE: [HACKERS] Numeric with '-'

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: RE: [HACKERS] Numeric with '-'
Date: 2000-02-26 23:09:00
Message-ID: NDBBIJLOILGIKBGDINDFAEADCDAA.Inoue@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> -----Original Message-----
> From: owner-pgsql-hackers(at)postgreSQL(dot)org
> [mailto:owner-pgsql-hackers(at)postgreSQL(dot)org]On Behalf Of Tom Lane
>
> "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> writes:
> >> They didn't give any such warning before, either. I doubt I've
> >> made anything worse.
>
> > Before your change
> > INSERT into t (numdata) values (-1234567890.1234567);
> > caused an error
> > ERROR: Unable to convert left operator '-' from type 'unknown'.
> > but currently inserts a constant -1234567890.12346.
>
> Yipes, you are right. I think that that sort of construct should
> result in the value not getting converted at all until the parser
> knows that it must be converted to the destination column's type.
> Let me see if I can find out what's going wrong. If this doesn't
> seem to be fixable, I may have to back off the patch...
>

This seems to be fixed.
Thanks a lot.

However there still remains the following case.
select * from num_data where val = 1.1;
ERROR: Unable to identify an operator '=' for types 'numeric' and 'float8'
You will have to retype this query using an explicit cast

SQL standard seems to say 1.1 is a numeric constant and
it's not good to treat a numeric value as an aproximate value.
For example,what do you think about the following.

select 11111111111111 * 1.1;
?column?
------------------
12222222222222.1
(1 row)

select 111111111111111 * 1.1;
?column?
-----------------
122222222222222
(1 row)

select 100000000 + .000001;
?column?
------------------
100000000.000001
(1 row)

select 100000000 + .0000001;
?column?
-----------
100000000
(1 row)

select 100000000.0000001;
?column?
-------------------
100000000.0000001
(1 row)

Regards.

Hiroshi Inoue
Inoue(at)tpf(dot)co(dot)jp

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-02-26 23:46:32 Re: [HACKERS] Numeric with '-'
Previous Message Don Baccus 2000-02-26 21:57:00 Re: [HACKERS] LZTEXT for rule plan stings