Bug #952: real type in WHERE

Started by PostgreSQL Bugs Listalmost 23 years ago3 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Victor (hvicha@mail.ru) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
real type in WHERE

Long Description
Strange result for real type in WHERE, see example.

Sample Code
victest=# CREATE TABLE t (r real);
CREATE
victest=# INSERT INTO t (r) VALUES (1.0);
INSERT 1309087 1
victest=# INSERT INTO t (r) VALUES (1.1);
INSERT 1309145 1
victest=# INSERT INTO t (r) VALUES (1.2);
INSERT 1309146 1
victest=# SELECT * FROM t WHERE r=1.1;
r
---
(0 rows)
victest=# SELECT * FROM t WHERE r='1.1';
r
-----
1.1
(1 row)

No file was uploaded with this report

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #952: real type in WHERE

pgsql-bugs@postgresql.org writes:

victest=# SELECT * FROM t WHERE r=1.1;

The 1.1 is taken as a float8 constant. There is no float4 value that is
exactly equal to 1.1::float8.

regards, tom lane

#3hvicha
hvicha@mail.ru
In reply to: Tom Lane (#2)
Re: Bug #952: real type in WHERE

On Tue, 22 Apr 2003 11:25:34 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

pgsql-bugs@postgresql.org writes:

victest=# SELECT * FROM t WHERE r=1.1;

The 1.1 is taken as a float8 constant. There is no float4 value that is
exactly equal to 1.1::float8.

Yes, I see:
victest=# select 1.1::float4 = 1.1::float8;
?column?
----------
f
(1 row)

;-/

Regards, Vic