Fix for interval division/multiplication

Started by Bruce Momjianabout 21 years ago1 messagespatches
Jump to latest
#1Bruce Momjian
bruce@momjian.us

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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/bjm/difftext/plainDownload+4-4