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

From Bruce Momjian
Subject Re: Have I found an interval arithmetic bug?
Date
Msg-id 20210721024834.GA8395@momjian.us
Whole thread Raw
In response to Re: Have I found an interval arithmetic bug?  (Zhihong Yu <zyu@yugabyte.com>)
Responses Re: Have I found an interval arithmetic bug?
List pgsql-hackers
On Tue, Jul 20, 2021 at 05:13:37PM -0700, Zhihong Yu wrote:
> On Tue, Jul 20, 2021 at 3:53 PM Bruce Momjian <bruce@momjian.us> wrote:
> With your patch, the following example (Coutesy Bryn) still shows fraction:
> 
> # select (interval '1 month')*1.123;
>        ?column?
> -----------------------
>  1 mon 3 days 16:33:36
> (1 row) 
> 
> Do you think the output can be improved (by getting rid of fraction) ?

Well, I focused on how fractional units were processed inside of
interval values.  I never considered how multiplication should be
handled.  I have not really thought about how to handle that, but this
example now gives me concern:

    SELECT INTERVAL '1.06 months 1 hour';
           interval
    -----------------------
     1 mon 2 days 01:00:00

Notice that it rounds the '1.06 months' to '1 mon 2 days', rather than
spilling to hours/minutes/seconds, even though hours is already
specified.  I don't see a better way to handle this than the current
code already does, but it is something odd.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  If only the physical world exists, free will is an illusion.




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: add 'noError' to euc_tw_and_big5.c
Next
From: David Rowley
Date:
Subject: Re: Add proper planner support for ORDER BY / DISTINCT aggregates