Wrong results from in_range() tests with infinite offset

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Subject: Wrong results from in_range() tests with infinite offset
Date: 2020-07-16 18:58:13
Message-ID: 3393130.1594925893@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dean Rasheed pointed out that in_range for float4/float8 seems to be
doing the wrong thing for infinite offsets, and after some testing
I concur that it is. For example, a sort key of '-infinity' should
be considered to be in-range for a range specified as RANGE BETWEEN
'inf' PRECEDING AND 'inf' PRECEDING; but with the code as it stands,
it isn't. I propose the attached patch, which probably should be
back-patched.

When the current row's value is +infinity, actual computation of
base - offset would yield NaN, making it a bit unclear whether
we should consider -infinity to be in-range. It seems to me that
we should, as that gives more natural-looking results in the test
cases, so that's how the patch does it.

regards, tom lane

Attachment Content-Type Size
fix-infinite-in_range-cases.patch text/x-diff 7.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2020-07-16 19:08:09 Re: calling procedures is slow and consumes extra much memory against calling function
Previous Message Anastasia Lubennikova 2020-07-16 17:24:51 Re: Using Valgrind to detect faulty buffer accesses (no pin or buffer content lock held)