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 1m84WB-0002gD-MS for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Jul 2021 17:35:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m84WA-0004w3-Kj for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Jul 2021 17:35:54 +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 1m84WA-0004vv-Cw for pgsql-hackers@lists.postgresql.org; Mon, 26 Jul 2021 17:35:54 +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 1m84W3-0004Dt-J6 for pgsql-hackers@postgresql.org; Mon, 26 Jul 2021 17:35:54 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1m84Vx-00040z-Jc; Mon, 26 Jul 2021 13:35:41 -0400 Date: Mon, 26 Jul 2021 13:35:41 -0400 From: Bruce Momjian To: Bryn Llewellyn Cc: Zhihong Yu , Tom Lane PostgreSQL , Dean Rasheed , Daniel Gustafsson , Justin Pryzby , Isaac Morland , John W Higgins , PostgreSQL-development Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210726173541.GA13525@momjian.us> References: <711398.1626888589@sss.pgh.pa.us> <20210722000713.GA19630@momjian.us> <654FEA5F-79CF-414A-9801-F1482EEBCD88@yugabyte.com> <20210722014331.GB19630@momjian.us> <20210723150551.GA8025@momjian.us> <20210723202738.GC8025@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 Sun, Jul 25, 2021 at 11:56:54AM -0700, Bryn Llewellyn wrote: > As far as I’ve been able, the PG documentation doesn’t do a good job of > defining the semantics of any of these operations. Some (like the “justify” This is because fractional interval values are not used or asked about often. > functions” are sketched reasonably well. Others, like interval multiplication, > are entirely undefined. Yes, the “justify” functions were requested and implemented because they met a frequently-requested need unrelated to fractional values, though they do have spill-up uses. > This makes discussion of simple test like the two I showed immediately above > hard. It also makes any discussion of correctness, possible bugs, and proposed > implementation changes very difficult. Agreed. With fractional values an edge use-case, we are trying to find the most useful implementation. > As I’ve said, my conclusion is that the only safe approach is to create and use > only “pure” interval values (where just one of the internal fields is > non-zero). For this reason (and having seen what I decided was the impossibly > unmemorable rules that my modeled implementation uses) I didn’t look at the > rules for the other fields that the interval literal allows (weeks, centuries, > millennia, and so on). I think the current page is clear about _specifying_ fractional units, but you are right that multiplication/division of fractional values is not covered. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.