pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Zhihong Yu <zyu@yugabyte.com>
Cc: Isaac Morland <isaac.morland@gmail.com>
Cc: John W Higgins <wishdev@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Have I found an interval arithmetic bug?
Date: Fri, 2 Apr 2021 22:21:26 -0400
Message-ID: <20210403022126.GG29126@momjian.us> (raw)
In-Reply-To: <CALNJ-vRF71-c8oubm96wx4qBz1TQr2Dm5ocQAYbHmtmf_gBTmg@mail.gmail.com>
References: <BDAE4B56-3337-45A2-AC8A-30593849D6C0@yugabyte.com>
	<20210402180549.GF9270@momjian.us>
	<CAPhAwGy9X_fqPz0ekcq0+PwUZZsitcwtuNt-qhajC5pnYtjK+g@mail.gmail.com>
	<20210402235815.GC29126@momjian.us>
	<CALNJ-vRZDWgcevmjoECOPshNbtvMbTPK09NJ7J8FSHJzdySiJA@mail.gmail.com>
	<CALNJ-vTwCbt+dTeC+5GcrR7CCcBWnz+zSeLGkViEyJSg=UdCXQ@mail.gmail.com>
	<CAMsGm5errRXqOOt2r-uSDYqn301s_tQMQdJHLPmTXcc+EOLEfQ@mail.gmail.com>
	<CALNJ-vRF71-c8oubm96wx4qBz1TQr2Dm5ocQAYbHmtmf_gBTmg@mail.gmail.com>

On Fri, Apr  2, 2021 at 07:06:08PM -0700, Zhihong Yu wrote:
> Hi,
> The mix of interval and comparison with float is not easy to interpret. See the
> following (I got 0.0833 since the result for interval '0.3 years' + interval
> '0.4 years' - ... query was 1 month and 1/12 ~= 0.0833).
> 
> yugabyte=# select 0.3 * '1 year'::interval + 0.4 * '1 year'::interval - 0.7 *
> '1 year'::interval = '0.0833 year'::interval;
>  ?column?
> ----------
>  f
> 
> As long as Bruce's patch makes improvements over the current behavior, I think
> that's fine.

I wish I could figure out how to improve it any futher.  What is odd is
that I have never seen this reported as a problem before.  I plan to
apply this early next week for PG 14.

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

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






view thread (95+ messages)  latest in thread

Message-ID: <20210403022126.GG29126@momjian.us>
Permalink:  ../20210403022126.GG29126@momjian.us/
Also on:    postgresql.org/message-id/20210403022126.GG29126@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: bruce@momjian.us, zyu@yugabyte.com, isaac.morland@gmail.com, wishdev@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: Have I found an interval arithmetic bug?
  In-Reply-To: <20210403022126.GG29126@momjian.us>
  References: <BDAE4B56-3337-45A2-AC8A-30593849D6C0@yugabyte.com> <20210402180549.GF9270@momjian.us> <CAPhAwGy9X_fqPz0ekcq0+PwUZZsitcwtuNt-qhajC5pnYtjK+g@mail.gmail.com> <20210402235815.GC29126@momjian.us> <CALNJ-vRZDWgcevmjoECOPshNbtvMbTPK09NJ7J8FSHJzdySiJA@mail.gmail.com> <CALNJ-vTwCbt+dTeC+5GcrR7CCcBWnz+zSeLGkViEyJSg=UdCXQ@mail.gmail.com> <CAMsGm5errRXqOOt2r-uSDYqn301s_tQMQdJHLPmTXcc+EOLEfQ@mail.gmail.com> <CALNJ-vRF71-c8oubm96wx4qBz1TQr2Dm5ocQAYbHmtmf_gBTmg@mail.gmail.com> <20210403022126.GG29126@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox