Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6G2h-0007N3-9Z for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Jul 2021 17:29:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6G2g-000313-8b for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Jul 2021 17:29:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6G2g-00030n-0b for pgsql-hackers@lists.postgresql.org; Wed, 21 Jul 2021 17:29:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6G2d-00037E-Hd for pgsql-hackers@postgresql.org; Wed, 21 Jul 2021 17:29:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 16LHTn6f711399; Wed, 21 Jul 2021 13:29:50 -0400 From: Tom Lane To: Bryn Llewellyn cc: Dean Rasheed , Bruce Momjian , Zhihong Yu , Daniel Gustafsson , Justin Pryzby , Isaac Morland , John W Higgins , PostgreSQL-development Subject: Re: Have I found an interval arithmetic bug? In-reply-to: References: <20210508024204.GB27048@momjian.us> <076E1871-8446-405C-9561-29FA03F46A4A@yesql.se> <20210630163516.GA3304@momjian.us> <20210720041419.GA5882@momjian.us> <20210720225350.GB27025@momjian.us> <20210721024834.GA8395@momjian.us> <677937.1626861539@sss.pgh.pa.us> Comments: In-reply-to Bryn Llewellyn message dated "Wed, 21 Jul 2021 10:18:34 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <711397.1626888589.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 21 Jul 2021 13:29:49 -0400 Message-ID: <711398.1626888589@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn writes: > On 21-Jul-2021, at 02:58, Tom Lane 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 indisputab= ly >> broken. > It was me that started the enormous thread with the title =E2=80=9CHave = I found an interval arithmetic bug?=E2=80=9D on 01-Apr-2021. I presented t= his testcase: >> select interval '-1.7 years'; -- -1 years -8 m= ons >> = >> select interval '29.4 months'; -- 2 years 5 m= ons 12 days >> = >> select interval '-1.7 years 29.4 months'; -- 8 m= ons 12 days << wrong >> select interval '29.4 months -1.7 years'; -- 9 m= ons 12 days >> = >> select interval '-1.7 years' + interval '29.4 months'; -- 9 m= ons 12 days >> select interval '29.4 months' + interval '-1.7 years'; -- 9 m= ons 12 days > The consensus was that the outcome that I flagged with =E2=80=9Cwrong=E2= =80=9D 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