Bryn Llewellyn <bryn@yugabyte.com> writes:
> On 21-Jul-2021, at 02:58, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> In general, considering that (most of?) the existing behavior has stood
>> for decades, I think we need to tread VERY carefully about changing it.
>> I don't want to see this patch changing any case that is not indisputably
>> broken.
> It was me that started the enormous thread with the title “Have I found an interval arithmetic bug?” on 01-Apr-2021.
Ipresented this testcase:
>> select interval '-1.7 years'; -- -1 years -8 mons
>>
>> select interval '29.4 months'; -- 2 years 5 mons 12 days
>>
>> select interval '-1.7 years 29.4 months'; -- 8 mons 12 days << wrong
>> select interval '29.4 months -1.7 years'; -- 9 mons 12 days
>>
>> select interval '-1.7 years' + interval '29.4 months'; -- 9 mons 12 days
>> select interval '29.4 months' + interval '-1.7 years'; -- 9 mons 12 days
> The consensus was that the outcome that I flagged with “wrong” does indeed have that status.
Yeah, I think it's self-evident that your last four cases should
produce the same results. Whether '9 mons 12 days' is the best
possible result is debatable --- in a perfect world, maybe we'd
produce '9 mons' exactly --- but given that the first two cases
produce what they do, that does seem self-consistent. I think
we should be setting out to fix that outlier without causing
any of the other five results to change.
regards, tom lane