Re: Have I found an interval arithmetic bug?

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Bryn Llewellyn <bryn(at)yugabyte(dot)com>, Tom Lane PostgreSQL <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, John W Higgins <wishdev(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Have I found an interval arithmetic bug?
Date: 2021-07-21 00:13:37
Message-ID: CALNJ-vQXQGPQiKt1SubT2fd4xGuvoN9UUtJyVr8JRfPxBfQHgg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Jul 20, 2021 at 3:53 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Tue, Jul 20, 2021 at 02:33:07PM -0700, Zhihong Yu wrote:
> > On Mon, Jul 19, 2021 at 9:14 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > > Obviously this should return '1 mon 26 days', but with my most
> recent
> > > patch, it returned '1 mon 25 days'. Turns out I had not properly
> used
> > > rint() in AdjustFractDays, and in fact the function is now longer
> needed
> > > because it is just a multiplication and an rint().
> >
> > Patch looks good.
> > Maybe add the statement above as a test case :
> >
> > SELECT INTERVAL '1.8594 months'
>
> Good idea --- updated patch attached.
>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
> EDB https://enterprisedb.com
>
> If only the physical world exists, free will is an illusion.
>
> Hi,
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) ?

Thanks

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2021-07-21 00:55:27 Re: More records after sort
Previous Message Bruce Momjian 2021-07-20 22:53:50 Re: Have I found an interval arithmetic bug?

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-07-21 00:14:17 Re: Column Filtering in Logical Replication
Previous Message Jacob Champion 2021-07-21 00:08:24 Re: badly calculated width of emoji in psql