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-20 21:33:07
Message-ID: CALNJ-vSc22BFW__bUqJk0USvn8_w+fWLWJjNqH=6WSa1-OJRTQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Mon, Jul 19, 2021 at 9:14 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Wed, Jul 14, 2021 at 09:03:21AM -0700, Zhihong Yu wrote:
> > On Thu, Jul 8, 2021 at 10:22 AM Zhihong Yu <zyu(at)yugabyte(dot)com> wrote:
> > On Wed, Jun 30, 2021 at 9:35 AM Bruce Momjian <bruce(at)momjian(dot)us>
> wrote:
> >
> > On Tue, Jun 29, 2021 at 06:49:45PM +0200, Daniel Gustafsson
> wrote:
> > > > On 29 Jun 2021, at 18:50, Zhihong Yu <zyu(at)yugabyte(dot)com>
> wrote:
> > >
> > > > Now that PG 15 is open for commit, do you think the patch
> can land
> > ?
> > >
> > > Adding it to the commitfest patch tracker is a good way to
> ensure
> > it's not
> > > forgotten about:
> > >
> > > https://commitfest.postgresql.org/33/
> >
> > OK, I have been keeping it in my git tree since I wrote it and
> will
> > apply it in the next few days.
> > Thanks, Bruce.
> >
> > Hopefully you can get to this soon.
> >
> > Bruce:
> > Please see if the patch can be integrated now.
>
> I found a mistake in my most recent patch. For example, in master we
> see this output:
>
> SELECT INTERVAL '1.8594 months';
> interval
> --------------------------
> 1 mon 25 days 18:46:04.8
>
> 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().
>
> 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,
Patch looks good.
Maybe add the statement above as a test case :

SELECT INTERVAL '1.8594 months'

Cheers

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2021-07-20 22:53:50 Re: Have I found an interval arithmetic bug?
Previous Message Tom Lane 2021-07-20 17:07:43 Re: More records after sort

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-07-20 21:41:20 Re: logical decoding and replication of sequences
Previous Message John Naylor 2021-07-20 21:24:33 Re: speed up verifying UTF-8