Re: Function trunc() behaves in unexpected manner with different data types

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, "Nathan M(dot) Davalos" <n(dot)davalos(at)sharedmarketing(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Function trunc() behaves in unexpected manner with different data types
Date: 2011-02-25 16:30:08
Message-ID: AANLkTinCxQ5EWjVbULSa4L+MH=421Sh6=syEumUhmope@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Feb 25, 2011 at 9:48 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Fri, Feb 25, 2011 at 9:40 AM, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
>> Excerpts from Merlin Moncure's message of vie feb 25 12:28:25 -0300 2011:
>>
>>> no I wouldn't, and the pg_dump extra_float_digits setting addresses my
>>> primary concern.  The client has a similar issue though -- suppose it
>>> fetches a value from the server and updates it back -- which record
>>> gets the update?  You would get different results if the client was
>>> using binary or text features of the protocol.  Not saying this is
>>> wrong or needs to be fixed, just pointing it out :-).
>>>
>>> update foo set val=val + 1 where val = 2183.68;
>>
>> I think the mere idea of using floating point equality on a
>> WHERE clause is bogus, regardless of text or binary format.
>
> That's a bridge to[sic] far -- akin to saying floating point should not
> support equality operator.  select count(*) from foo where val >=
> 2183.68?  you are ok getting different answers depending on method of
> transmission of 2183.68 to the server?

I stand corrected -- I did some digging and Postgres's handling of
this issue is afaict correct: you are supposed to round on
presentation only, and equality matching on floating point in sql
(just like in C) is capricious exercise at best, at least without some
defenses. So, we can definitely file under 'not a bug'.

merlin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jonathan Brinkman 2011-02-25 16:44:34 Re: LOCALTIMESTAMP has wrong time zone
Previous Message Jakub Ouhrabka 2011-02-25 16:21:02 Re: Corrupted index on 9.0.3 streaming hot standby