Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group