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 1m9Yam-0000Gr-Tl for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Jul 2021 19:54:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m9Yal-0001eL-SE for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Jul 2021 19:54:47 +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 1m9Yal-0001eD-KD for pgsql-hackers@lists.postgresql.org; Fri, 30 Jul 2021 19:54:47 +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 1m9Yaj-0002Gt-GR for pgsql-hackers@lists.postgresql.org; Fri, 30 Jul 2021 19:54:47 +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 16UJsgeU1119161; Fri, 30 Jul 2021 15:54:42 -0400 From: Tom Lane To: Bruce Momjian cc: Robert Haas , Dean Rasheed , John W Higgins , pgsql-hackers list Subject: Re: Have I found an interval arithmetic bug? In-reply-to: <20210730192010.GD9600@momjian.us> References: <20210727211314.GA23040@momjian.us> <901454CE-2C0D-4C49-ADAB-A094C03B7CB1@yugabyte.com> <20210728151916.GA15440@momjian.us> <20210730160439.GZ9600@momjian.us> <20210730160854.GA9600@momjian.us> <1008623.1627663774@sss.pgh.pa.us> <20210730190313.GC9600@momjian.us> <20210730192010.GD9600@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Fri, 30 Jul 2021 15:20:10 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1119159.1627674882.1@sss.pgh.pa.us> Date: Fri, 30 Jul 2021 15:54:42 -0400 Message-ID: <1119160.1627674882@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bruce Momjian writes: > On Fri, Jul 30, 2021 at 03:08:56PM -0400, Robert Haas wrote: >> Just to be clear, I am against this patch. I don't think it's a >> minimal change for the reported problem, and I think some people will >> be unhappy about the behavior changes. > Uh, what do you suggest then? You wanted the years/months fixed, and > rounding at spill stop time makes sense, and fixes the problem. The complained-of bug is that 'X years Y months' isn't always identical to 'Y months X years'. I do not believe that this patch fixes that, though it may obscure the problem for some values of X and Y. After a quick look at the code, I am suspicious that the actual problem is that AdjustFractDays is applied at the wrong time, before we've collected all the input. We probably need to collect up all of the contributing input as floats and then do the fractional spilling once at the end. Having said that, I also agree that it's not great that '1.4 years' is converted to '1 year 4 mons' (1.33333... years) rather than '1 year 5 mons' (1.41666... years). The latter seems like a clearly saner translation. I would really rather that we reject such input altogether, but if we're going to accept it, we should round not truncate. regards, tom lane