Re: Have I found an interval arithmetic bug? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Have I found an interval arithmetic bug?
Date
Msg-id 3135041.1618270701@sss.pgh.pa.us
Whole thread Raw
In response to Re: Have I found an interval arithmetic bug?  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Have I found an interval arithmetic bug?  (Bruce Momjian <bruce@momjian.us>)
Re: Have I found an interval arithmetic bug?  (Bryn Llewellyn <bryn@yugabyte.com>)
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
> On Mon, Apr 12, 2021 at 03:09:48PM -0700, Bryn Llewellyn wrote:
>> After all, you've bitten the bullet now and changed the behavior. This means that the semantics of some extant
applicationswill change. So... in for a penny, in for a pound? 

> The docs now say:

>      Field values can have fractional parts;  for example, <literal>'1.5
>      weeks'</literal> or <literal>'01:02:03.45'</literal>.  The fractional
> -->  parts are used to compute appropriate values for the next lower-order
>      internal fields (months, days, seconds).

> meaning fractional years flows to the next lower internal unit, months,
> and no further.  Fractional months would flow to days.  The idea of not
> flowing past the next lower-order internal field is that the
> approximations between units are not precise enough to flow accurately.

Um, what's the argument for down-converting AT ALL?  The problem is
precisely that any such conversion is mostly fictional.

> With my patch, the output is now:

>     SELECT INTERVAL '3 years 10.241604 months';
>             interval
>     ------------------------
>      3 years 10 mons 7 days

> It used to flow to seconds.

Yeah, that's better than before, but I don't see any principled argument
for it not to be "3 years 10 months", full stop.

            regards, tom lane



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays
Next
From: Tom Lane
Date:
Subject: Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays