Re: Interval aggregate regression failure (expected seems - Mailing list pgsql-hackers

From Michael Paesold
Subject Re: Interval aggregate regression failure (expected seems
Date
Msg-id 436F2ABE.5070409@gmx.at
Whole thread Raw
In response to Re: Interval aggregate regression failure (expected seems wrong)  (Michael Glaesemann <grzm@myrealbox.com>)
Responses Re: Interval aggregate regression failure (expected seems
List pgsql-hackers
Michael Glaesemann wrote:
>> So what do you have in results/interval.out?
>> @ 4 years 1 mon 9 days 28 hours 18 mins 23 secs seems wrong to me, no?
>>
> 
> select avg(f1) from interval_tbl;
>                        avg
> -------------------------------------------------
> @ 4 years 1 mon 9 days 28 hours 18 mins 23 secs
> (1 row)
> 
> The point of the change to the interval datatype in 8.1 is to keep  
> track of months, days, and seconds (which in turn are represented as  
> hours, minutes and seconds). Previous releases tracked only months  and 
> seconds. This has advantages for using intervals with dates and  
> timestamps that involve daylight saving time changes. Admittedly, it  
> looks odd at first, but it falls out of the change in behavior of the  
> interval datatype. There are two new functions, justify_days and  
> justify_hours, that you can use to put intervals into more  traditional 
> forms.
> 
> http://developer.postgresql.org/docs/postgres/functions-datetime.html

Thank you very much for the insight.

> Doesn't explain why you're getting a regression failure though.

Well, I have something now. It seems to be a compiler/optimization issue.

I wrote:> CFLAGS = -O2 -mcpu=pentium4 -march=pentium4 -Wall -Wmissing-prototypes> -Wpointer-arith -Winline
-Wdeclaration-after-statement>-fno-strict-aliasing -g
 

I had set CFLAGS to -O2 -mcpu=pentium4 -march=pentium4. I have been 
using these settings for testing PostgreSQL tip for some time now and 
never had any problems.

Removing the cpu and architecture optimization part changes the behavior 
of the interval aggrate, so the results/interval.out now also looks like 
the expected output.
select avg(f1) from interval_tbl;                       avg
------------------------------------------------- @ 4 years 1 mon 9 days 28 hours 18 mins 23 secs
(1 row)

Switching -mcpu=pentium4 -march=pentium4 back on, results in wrong 
output. This is 100% reproducable. Can somebody with more knowledge 
explain why the compiler should stumble over just this? Pure luck?

I have tested these combination of CFLAGS:
-O2                                 OK
-O2 -mcpu=i686 -march=i686          OK (good, RPMS are built with these)
-O2 -mcpu=pentium4 -march=i686      OK
-O2 -mcpu=pentium4 -march=pentium4  fails

I am definatly not going to use -march=pentium4 in any production 
system. Should I open a bug report with RedHat (gcc vendor)?

Best Regards,
Michael Paesold


pgsql-hackers by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Interval aggregate regression failure (expected seems wrong)
Next
From: Alvaro Herrera
Date:
Subject: Another pgindent gripe