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 1lUYOh-0004Pb-LN for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 17:24:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUYOg-0006VV-Jl for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 17:24:50 +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 1lUYOg-0006VI-CK for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 17:24:50 +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 1lUYOd-0007hq-OA for pgsql-hackers@postgresql.org; Thu, 08 Apr 2021 17:24:49 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1lUYOa-0001wF-Py; Thu, 08 Apr 2021 13:24:44 -0400 Date: Thu, 8 Apr 2021 13:24:44 -0400 From: Bruce Momjian To: Justin Pryzby Cc: Bryn Llewellyn , Zhihong Yu , Isaac Morland , John W Higgins , pgsql-hackers@postgresql.org, Tom Lane Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210408172444.GC6909@momjian.us> References: <20210403022126.GG29126@momjian.us> <20210405163310.GP6592@telsasoft.com> <20210405180158.GB12179@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210405180158.GB12179@momjian.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 --17pEHd4RhPHOinZp Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Apr 5, 2021 at 02:01:58PM -0400, Bruce Momjian wrote: > On Mon, Apr 5, 2021 at 11:33:10AM -0500, Justin Pryzby wrote: > Well, bug or not, we are not going to change back branches for this, and > if you want a larger discussion, it will have to wait for PG 15. > > > > https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-INTERVAL-INPUT > > > « …field values can have fractional parts; for example '1.5 week' or '01:02:03.45'. Such input is converted to the appropriate number of months, days, and seconds for storage. When this would result in a fractional number of months or days, the fraction is added to the lower-order fields using the conversion factors 1 month = 30 days and 1 day = 24 hours. For example, '1.5 month' becomes 1 month and 15 days. Only seconds will ever be shown as fractional on output. » > > I see that. What is not clear here is how far we flow down. I was > looking at adding documentation or regression tests for that, but was > unsure. I adjusted the docs slightly in the attached patch. Here is an updated patch, which will be for PG 15. It updates the documentation to state: The fractional parts are used to compute appropriate values for the next lower-order internal fields (months, days, seconds). It removes the flow from fractional months/weeks to hours-minutes-seconds, and adds missing rounding for fractional computations. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion. --17pEHd4RhPHOinZp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="interval.diff"