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 1m8lrR-0001CO-Qn for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jul 2021 15:52:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8lrQ-0001VM-7c for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jul 2021 15:52:44 +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 1m8lrQ-0001VE-01 for pgsql-hackers@lists.postgresql.org; Wed, 28 Jul 2021 15:52:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8lrI-0001Ey-Nq for pgsql-hackers@lists.postgresql.org; Wed, 28 Jul 2021 15:52:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 16SFqYj5588728; Wed, 28 Jul 2021 11:52:34 -0400 From: Tom Lane To: Robert Haas cc: Bruce Momjian , Bryn Llewellyn , pgsql-hackers list Subject: Re: Have I found an interval arithmetic bug? In-reply-to: References: <20210402180549.GF9270@momjian.us> <20210402234943.GB29126@momjian.us> <95D98B9E-CD54-4FAC-9574-D950E9741CAC@yugabyte.com> <20210403010229.GE29126@momjian.us> <20210727193614.GE19774@momjian.us> <456756.1627416114@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 28 Jul 2021 11:31:08 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <588726.1627487554.1@sss.pgh.pa.us> Date: Wed, 28 Jul 2021 11:52:34 -0400 Message-ID: <588727.1627487554@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > If we were doing this over again, I would argue that, with this > on-disk representation, 0.7 months ought to be rejected as invalid > input, because it's generally not a good idea to have a data type that > silently converts a value into a different value that is not > equivalent for all purposes. It is confusing and causes people to > expect behavior different from what they will actually get. Now, it > seems far too late to consider such a change at this point ... and it > is also no good considering a change to the on-disk representation of > the existing data type at this point ... but it is also no good > pretending like we have a floating-point representation of months and > days when we actually do not. You know, I was thinking exactly that thing earlier. Changing the on-disk representation is certainly a nonstarter, but the problem here stems from expecting interval_in to do something sane with inputs that do not correspond to any representable value. I do not think we have any other datatypes where we expect the input function to make choices like that. Is it really too late to say "that was a damfool idea" and drop fractional years/months/etc from interval_in's lexicon? By definition, this will not create any dump/reload problems, because interval_out will never emit any such thing. It will break applications that are expecting such syntax to do something sane. But that expectation is fundamentally not meetable, so maybe we should just make a clean break. (Without back-patching it, of course.) I'm not entirely sure about whether to reject fractional days, though. Converting those on the assumption of 1 day == 24 hours is not quite theoretically right. But it's unsurprising, which is not something we can say about fractions of the larger units. So maybe it's OK to continue accepting that. regards, tom lane