Re: Have I found an interval arithmetic bug?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: Zhihong Yu <zyu(at)yugabyte(dot)com>, Tom Lane PostgreSQL <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, 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-23 20:27:38
Message-ID: 20210723202738.GC8025@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, Jul 23, 2021 at 10:55:11AM -0700, Bryn Llewellyn wrote:
> SELECT
> '1.2345 months 1.2345 days 1.2345 seconds'::interval =
> '1 month 1 day 1 second'::interval*1.2345;
>
> In 13.3, the result is TRUE. (I know that this doesn’t guarantee that the
> internal representations of the two compared interval values are the same. But
> it’s a necessary condition for the outcome that I’m referring to and serves to
> indecate the pont I’m making. A more careful test can be made.

So you are saying fractional unit output should match multiplication
output? It doesn't now for all units:

SELECT interval '1.3443 years';
interval
---------------
1 year 4 mons

SELECT interval '1 years' * 1.3443;
?column?
---------------------------------
1 year 4 mons 3 days 22:45:07.2

It is true this patch is further reducing that matching. Do people
think I should make them match as part of this patch?

--
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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ninad Shah 2021-07-24 03:58:34 Re: pg_restore (fromuser -> touser)
Previous Message Bryn Llewellyn 2021-07-23 17:55:11 Re: Have I found an interval arithmetic bug?

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-07-23 20:49:37 Re: Followup Timestamp to timestamp with TZ conversion
Previous Message Robert Haas 2021-07-23 20:03:25 Re: [Patch] ALTER SYSTEM READ ONLY