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

Re: [HACKERS] Interval aggregate regression failure

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paesold <mpaesold(at)gmx(dot)at>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Interval aggregate regression failure
Date: 2006-08-30 17:08:45
Message-ID: 200608301708.k7UH8jL01607@momjian.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Michael Glaesemann wrote:
> > Yea, just an optimization, but I was worried that the computations  
> > might
> > throw problems for certain numbers, so I figured I would only  
> > trigger it
> > when necessary.
> 
> Thanks for the explanation. Helps me know I might actually be  
> learning this.
> 
> > Patch attached.  It also fixes a regression test output too.
> 
> Thanks for the patch. I'll look at it more closely tonight.

OK, here is a much nicer patch.  The fix is to do no rounding, but to
find the number of days before applying the factor adjustment.  It
passes all your tests here:

	test=> select '41 mon 10:00:00'::interval / 10 as "pos";
	          pos
	------------------------
	 4 mons 3 days 01:00:00
	(1 row)
	
	test=> select interval '41 mon 12 days 360:00' * 0.3 as product_a
	     , interval '41 mon -12 days -360:00' * 0.3 as product_b
	     , interval '-41 mon 12 days 360:00' * 0.3 as product_c
	     , interval '-41 mon -12 days -360:00' * 0.3 as product_d;
	        product_a         |        product_b         |         
	product_c          |          product_d
	--------------------------+--------------------------+-----------------------------+------------------------------
	
	 1 year 12 days 122:24:00 | 1 year 6 days -122:24:00 | -1 years -6 days
	+122:24:00 | -1 years -12 days -122:24:00
	(1 row)
	
	test=> select interval '41 mon 12 days 360:00' / 10 as quotient_a
	     , interval '41 mon -12 days -360:00' / 10 as quotient_b
	     , interval '-41 mon 12 days 360:00' / 10 as quotient_c
	     , interval '-41 mon -12 days -360:00' / 10 as quotient_d;
	       quotient_a       |       quotient_b        |        quotient_c   
	     |        quotient_d
	------------------------+-------------------------+---------------------------+---------------------------
	
	 4 mons 4 days 40:48:00 | 4 mons 2 days -40:48:00 | -4 mons -2 days
	+40:48:00 | -4 mons -4 days -40:48:00
	(1 row)

What do you see on your platform?

-- 
  Bruce Momjian   bruce(at)momjian(dot)us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Attachment: /pgpatches/interval
Description: text/x-diff (3.7 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2006-08-30 17:09:04
Subject: Re: [HACKERS] Interval aggregate regression failure
Previous:From: Jaime CasanovaDate: 2006-08-30 17:04:01
Subject: Re: [COMMITTERS] pgsql: Second try committing the path changes.

pgsql-patches by date

Next:From: Bruce MomjianDate: 2006-08-30 17:09:04
Subject: Re: [HACKERS] Interval aggregate regression failure
Previous:From: Jim C. NasbyDate: 2006-08-30 16:50:37
Subject: Re: [HACKERS] Updatable views

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