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 1m9Yco-0000Kj-JR for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Jul 2021 19:56:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m9Ycn-0006sM-Ho for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Jul 2021 19:56:53 +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 1m9Ycn-0006sB-9y for pgsql-hackers@lists.postgresql.org; Fri, 30 Jul 2021 19:56:53 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9Yck-0002OA-QW for pgsql-hackers@lists.postgresql.org; Fri, 30 Jul 2021 19:56:52 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1m9Ycj-0006B3-8y; Fri, 30 Jul 2021 15:56:49 -0400 Date: Fri, 30 Jul 2021 15:56:49 -0400 From: Bruce Momjian To: Tom Lane Cc: Robert Haas , Dean Rasheed , John W Higgins , pgsql-hackers list Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210730195649.GF9600@momjian.us> References: <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> <1119160.1627674882@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1119160.1627674882@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jul 30, 2021 at 03:54:42PM -0400, Tom Lane wrote: > 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. My patch returns what you want: SELECT interval '1.4 years'; interval --------------- 1 year 5 mons -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.