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 1m6NkS-0001FI-G6 for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jul 2021 01:43:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6NkR-0004i0-FP for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jul 2021 01:43:39 +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 1m6NkR-0004hr-7Y for pgsql-hackers@lists.postgresql.org; Thu, 22 Jul 2021 01:43:39 +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 1m6NkO-00076O-7O for pgsql-hackers@postgresql.org; Thu, 22 Jul 2021 01:43:38 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1m6NkJ-0002JD-Rm; Wed, 21 Jul 2021 21:43:31 -0400 Date: Wed, 21 Jul 2021 21:43:31 -0400 From: Bruce Momjian To: Bryn Llewellyn Cc: Tom Lane PostgreSQL , Dean Rasheed , Zhihong Yu , Daniel Gustafsson , Justin Pryzby , Isaac Morland , John W Higgins , PostgreSQL-development Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210722014331.GB19630@momjian.us> References: <20210720225350.GB27025@momjian.us> <20210721024834.GA8395@momjian.us> <677937.1626861539@sss.pgh.pa.us> <711398.1626888589@sss.pgh.pa.us> <20210722000713.GA19630@momjian.us> <654FEA5F-79CF-414A-9801-F1482EEBCD88@yugabyte.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <654FEA5F-79CF-414A-9801-F1482EEBCD88@yugabyte.com> 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 Wed, Jul 21, 2021 at 06:39:26PM -0700, Bryn Llewellyn wrote: > Your statement > > > “months-to-days conversion is almost always an approximation, while the > days to seconds conversion is almost always accurate.” > > > is misleading. Any conversion like these (and also the “spill up” conversions > that the justify_hours(), justify_days(), and justify_interval() built-in > functions bring) are semantically dangerous because of the different rules for > adding a pure months, a pure days, or a pure seconds interval to a timestamptz > value. We are trying to get the most reasonable output for fractional values --- I stand by my statements. > Unless you avoid mixed interval values, then it’s so hard (even though it is > possible) to predict the outcomes of interval arithmetic. Rather, all you get > is emergent behavior that I fail to see can be relied upon in deliberately > designed application code. Here’s a telling example: The point is that we will get unusual values, so we should do the best we can. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.