Skip site navigation (1) Skip section navigation (2)

Problem with datatype REAL using the = (EQUAL) operator

From: "Javier Carlos" <javier(at)evaloportunidades(dot)insp(dot)mx>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Problem with datatype REAL using the = (EQUAL) operator
Date: 2004-02-12 18:46:27
Message-ID: 1233.192.168.8.34.1076611587.squirrel@evaloportunidades.insp.mx (view raw or flat)
Thread:
Lists: pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name		:	Javier Carlos Rivera
Your email address	:	fjcarlos ( at ) correo ( dot ) insp ( dot ) mx


System Configuration
----------------------
  Architecture (example: Intel Pentium)  	  : Intel Pentium 4

  Operating System (example: Linux 2.0.26 ELF) 	  : Debian GNU/Linux 3.0
2.4.23

  RAM						  : 256 MB

  PostgreSQL version (example: PostgreSQL-6.3.2)  : PostgreSQL-7.4.1

  Compiler used (example:  gcc 2.7.2)		  : 2.95.4



Please enter a FULL description of your problem:
-------------------------------------------------
   When I make a select and in the WHERE section I use the = (EQUAL)
operator whith a column of real datatype the results of the query is 0
rows even if there exist rows that match the condition.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
-----------------------------------------------------------------------
bd_temporal=> CREATE TABLE tbl_temp (var real);
bd_temporal=> \d tbl_temp
  Table "public.tbl_temp"
 Column | Type | Modifiers
--------+------+-----------
 var    | real |

bd_temporal=> INSERT INTO tbl_temp VALUES(0.1);
bd_temporal=> INSERT INTO tbl_temp VALUES(0.11);
bd_temporal=> INSERT INTO tbl_temp VALUES(0.20);
bd_temporal=> INSERT INTO tbl_temp VALUES(0.25);
bd_temporal=> INSERT INTO tbl_temp VALUES(0.26);

bd_temporal=> SELECT * FROM tbl_temp WHERE var < 0.20;
 var
------
  0.1
 0.11
(2 rows)
bd_temporal=> SELECT * FROM tbl_temp WHERE var = 0.11;
 var
-----
(0 rows)
bd_temporal=> SELECT * FROM tbl_temp WHERE var = '0.11';
 var
------
 0.11
(1 row)


If you know how this problem might be fixed, list the solution below:
----------------------------------------------------------------------
For now I have to put between '' the value as I was working whith CHARs
values.
The weird thing is that with all the other comparison operator all works
well, only the = (EQUAL) operator makes things suchs as this:

bd_temporal=> SELECT * FROM tbl_temp WHERE var = 0.25;
 var
------
 0.25
(1 row)

bd_temporal=> SELECT * FROM tbl_temp WHERE var = 0.26;
 var
-----
(0 rows)

bd_temporal=> SELECT * FROM tbl_temp WHERE var = '0.25';
 var
------
 0.25
(1 row)

bd_temporal=> SELECT * FROM tbl_temp WHERE var = '0.26';
 var
------
 0.26
(1 row)

-------------------------------------------------

Responses

pgsql-bugs by date

Next:From: Harry HochheiserDate: 2004-02-12 20:21:34
Subject: Default Timestamp 'Now' bug with 7.4 on Panther.
Previous:From: Tom LaneDate: 2004-02-12 15:58:52
Subject: Re: Integer/BigInt Implicit Typing Bug

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group