pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: John W Higgins <wishdev@gmail.com>
Cc: pgsql-hackers list <pgsql-hackers@lists.postgresql.org>
Subject: Re: Have I found an interval arithmetic bug?
Date: Fri, 30 Jul 2021 15:54:42 -0400
Message-ID: <1119160.1627674882@sss.pgh.pa.us> (raw)
In-Reply-To: <20210730192010.GD9600@momjian.us>
References: <20210727211314.GA23040@momjian.us>
	<901454CE-2C0D-4C49-ADAB-A094C03B7CB1@yugabyte.com>
	<CAPhAwGyccJZT-mXzHU1216Q-Z_xY3q+4TixzZ2sZf3hiPFe5tg@mail.gmail.com>
	<CAEZATCWaK0qdTiqxS=fM03VaKcfbYmSOV_JzqYDrVn2nSaMnFQ@mail.gmail.com>
	<20210728151916.GA15440@momjian.us>
	<20210730160439.GZ9600@momjian.us>
	<20210730160854.GA9600@momjian.us>
	<1008623.1627663774@sss.pgh.pa.us>
	<20210730190313.GC9600@momjian.us>
	<CA+TgmobqWU=eS1DGs-MomKJTwY9agfMF5NBN20tHBsyMWKuAmA@mail.gmail.com>
	<20210730192010.GD9600@momjian.us>

Bruce Momjian <bruce@momjian.us> writes:
> On Fri, Jul 30, 2021 at 03:08:56PM -0400, Robert Haas wrote:
>> Just to be clear, I am against this patch. I don't think it's a
>> minimal change for the reported problem, and I think some people will
>> be unhappy about the behavior changes.

> Uh, what do you suggest then?  You wanted the years/months fixed, and
> rounding at spill stop time makes sense, and fixes the problem.

The complained-of bug is that 'X years Y months' isn't always
identical to 'Y months X years'.  I do not believe that this patch
fixes that, though it may obscure the problem for some values of
X and Y.  After a quick look at the code, I am suspicious that
the actual problem is that AdjustFractDays is applied at the wrong
time, before we've collected all the input.  We probably need to
collect up all of the contributing input as floats and then do the
fractional spilling once at the end.

Having said that, I also agree that it's not great that '1.4 years'
is converted to '1 year 4 mons' (1.33333... years) rather than
'1 year 5 mons' (1.41666... years).  The latter seems like a clearly
saner translation.  I would really rather that we reject such input
altogether, but if we're going to accept it, we should round not
truncate.

			regards, tom lane





view thread (99+ messages)  latest in thread

Message-ID: <1119160.1627674882@sss.pgh.pa.us>
Permalink:  ../1119160.1627674882@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1119160.1627674882@sss.pgh.pa.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: tgl@sss.pgh.pa.us, bruce@momjian.us, robertmhaas@gmail.com, dean.a.rasheed@gmail.com, wishdev@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Have I found an interval arithmetic bug?
  In-Reply-To: <1119160.1627674882@sss.pgh.pa.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