pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Zhihong Yu <zyu@yugabyte.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:19:05 -0400
Message-ID: <20210403021905.GF29126@momjian.us> (raw)
In-Reply-To: <CALNJ-vTwCbt+dTeC+5GcrR7CCcBWnz+zSeLGkViEyJSg=UdCXQ@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>

On Fri, Apr  2, 2021 at 06:11:08PM -0700, Zhihong Yu wrote:
> Hi,
> I got a local build with second patch where:
> 
> yugabyte=# SELECT  interval '0.3 years' + interval '0.4 years' -
>                 interval '0.7 years';
>  ?column?
> ----------
>  1 mon
> 
> I think the outcome is a bit unintuitive (I would expect result close to 0).

Uh, the current code returns:

	SELECT  interval '0.3 years' + interval '0.4 years' - interval '0.7 years';
	 ?column?
	----------
	 -1 mon

and with the patch it is:
	
	SELECT  interval '0.3 years' + interval '0.4 years' - interval '0.7 years';
	 ?column?
	----------
	 1 mon

What it isn't, is zero months, which is the obviously ideal answer.


-- 
  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 (99+ messages)  latest in thread

Message-ID: <20210403021905.GF29126@momjian.us>
Permalink:  ../20210403021905.GF29126@momjian.us/
Also on:    postgresql.org/message-id/20210403021905.GF29126@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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: bruce@momjian.us, zyu@yugabyte.com, wishdev@gmail.com
  Subject: Re: Have I found an interval arithmetic bug?
  In-Reply-To: <20210403021905.GF29126@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