Mats Kindahl <mats@timescale.com> writes: > Attached is a proposed fix for the issue.
Hm. Aren't you replacing a risk of overflow with a risk of underflow? I'd be happier about doing this only if isinf(bound2 - bound1), or the reverse for the other path. (Seems like we shouldn't need to check the operand diff separately.)
Yes, I was wondering the same which is why I was adding these tests as a separate file to see if I could force a bad bucket. It seems to be hard to construct a case where the underflow would cause a change in the result.
However, better safe than sorry, so I modified the patch to include the check. And yes, you're right in that there is no need to check for the operand diff since the previous checks guarantee that the operand is between the bounds, and since the diff between the bounds is not infinite, the diff between the operand and any of the bounds cannot be infinite. Added a comment to that effect to the patch as well.