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 1lSVsY-0003wo-Gg for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Apr 2021 02:19:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lSVsX-0004MT-4m for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Apr 2021 02:19:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSVsW-0004MM-UA for pgsql-hackers@lists.postgresql.org; Sat, 03 Apr 2021 02:19:12 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSVsQ-0002ba-Dp for pgsql-hackers@postgresql.org; Sat, 03 Apr 2021 02:19:11 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1lSVsP-0003G4-Ak; Fri, 02 Apr 2021 22:19:05 -0400 Date: Fri, 2 Apr 2021 22:19:05 -0400 From: Bruce Momjian To: Zhihong Yu Cc: John W Higgins , PostgreSQL-development Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210403021905.GF29126@momjian.us> References: <20210402180549.GF9270@momjian.us> <20210402235815.GC29126@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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, Apr 2, 2021 at 06:11:08PM -0700, Zhihong Yu wrote: > Hi, > I got a local build with second patch where: > > yugabyte=# SELECT  interval '0.3 years' + interval '0.4 years' - >                 interval '0.7 years'; >  ?column? > ---------- >  1 mon > > I think the outcome is a bit unintuitive (I would expect result close to 0). Uh, the current code returns: SELECT interval '0.3 years' + interval '0.4 years' - interval '0.7 years'; ?column? ---------- -1 mon and with the patch it is: SELECT interval '0.3 years' + interval '0.4 years' - interval '0.7 years'; ?column? ---------- 1 mon What it isn't, is zero months, which is the obviously ideal answer. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.