Re: Numeric Datatype

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Terence Ingram" <terence(at)socialchange(dot)net(dot)au>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Numeric Datatype
Date: 2002-05-23 16:21:28
Message-ID: 10145.1022170888@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I said:
> You can work around the issue by explicitly coercing the literal to
> numeric, or by single-quoting it (so that its type is not determined
> until after agency_uid is known to be numeric), or by updating to PG
> 7.2 which uses a slightly different set of type-resolution rules.

Actually, you'll probably still need to do coercion in 7.2. I was
fooled by a poorly chosen test case:

test72=# select * from z where n1 = 12345678901234567890;
n1 | f1
----+----
(0 rows)

But:

test72=# select * from z where n1 = 1234567890123;
ERROR: Unable to identify an operator '=' for types 'numeric' and 'double precision'
You will have to retype this query using an explicit cast

What's happening here is that 7.2 defaults a number literal to be type
numeric if it has too many significant digits to be stored accurately
as a float. But for values in between int and numeric, the default
interpretation is still float, and we still don't make the choice
between exact and inexact comparison for you.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-05-23 16:34:50 Re: in(NULL)
Previous Message pgsql-bugs 2002-05-23 16:10:44 Bug #675: Is there any way to free up some more space?