From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-hackers list <pgsql-hackers@lists.postgresql.org>
Subject: Re: Have I found an interval arithmetic bug?
Date: Wed, 28 Jul 2021 11:52:34 -0400
Message-ID: <588727.1627487554@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+Tgmob-eV1wUY5zVpzPVFo1-jtuTsn1BJ5OMKQp4bc1a7=Ohw@mail.gmail.com>
References: <BDAE4B56-3337-45A2-AC8A-30593849D6C0@yugabyte.com>
<20210402180549.GF9270@momjian.us>
<CALNJ-vRJUo62KNrQsiSsNAuPSBYpOXk8SPLh6r5jwHVzYai=HA@mail.gmail.com>
<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>
<CA+Tgmob-eV1wUY5zVpzPVFo1-jtuTsn1BJ5OMKQp4bc1a7=Ohw@mail.gmail.com>
Robert Haas <robertmhaas@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, bruce@momjian.us, bryn@yugabyte.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Have I found an interval arithmetic bug?
In-Reply-To: <588727.1627487554@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox