Fix for interval division/multiplication

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Fix for interval division/multiplication
Date: 2005-07-20 03:49:12
Message-ID: 200507200349.j6K3nCT05147@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

I working on the 'date' interval patch, I found a bug in handling of
interval division and multiplication. Look at this:

test=> select '4 months'::interval / 5;
?column?
---------------
1 mon -6 days
(1 row)

With the attached fix, it returns the right value:

test=> select '4 months'::interval / 5;
?column?
----------
24 days
(1 row)

The bug is the use of rint() to round the division, but then using the
rounded value to find the remainder to pass down to the time field.

The attached patch has been applied to current CVS. Should I backpatch
this fix?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 1.6 KB

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2005-07-20 06:27:43 Re: Writing Commit Status hint bits (was Re: [HACKERS] Constant
Previous Message Tom Lane 2005-07-20 02:24:34 Re: Writing Commit Status hint bits (was Re: [HACKERS] Constant WAL replay)