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 1lSVum-00041S-6L for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Apr 2021 02:21:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lSVul-0006Of-57 for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Apr 2021 02:21:31 +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 1lSVuk-0006OX-UI for pgsql-hackers@lists.postgresql.org; Sat, 03 Apr 2021 02:21:30 +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 1lSVui-0007hk-Jm for pgsql-hackers@postgresql.org; Sat, 03 Apr 2021 02:21:30 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1lSVug-0003Ml-OM; Fri, 02 Apr 2021 22:21:26 -0400 Date: Fri, 2 Apr 2021 22:21:26 -0400 From: Bruce Momjian To: Zhihong Yu Cc: Isaac Morland , John W Higgins , PostgreSQL-development Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210403022126.GG29126@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 07:06:08PM -0700, Zhihong Yu wrote: > Hi, > The mix of interval and comparison with float is not easy to interpret. See the > following (I got 0.0833 since the result for interval '0.3 years' + interval > '0.4 years' - ... query was 1 month and 1/12 ~= 0.0833). > > yugabyte=# select 0.3 * '1 year'::interval + 0.4 * '1 year'::interval - 0.7 * > '1 year'::interval = '0.0833 year'::interval; >  ?column? > ---------- >  f > > As long as Bruce's patch makes improvements over the current behavior, I think > that's fine. I wish I could figure out how to improve it any futher. What is odd is that I have never seen this reported as a problem before. I plan to apply this early next week for PG 14. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.