Re: Interval aggregate regression failure (expected seems

From: Michael Paesold <mpaesold(at)gmx(dot)at>
To: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Interval aggregate regression failure (expected seems
Date: 2005-11-07 10:21:50
Message-ID: 436F2ABE.5070409@gmx.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2005-11-07 12:19:40 Another pgindent gripe
Previous Message Michael Glaesemann 2005-11-07 09:59:28 Re: Interval aggregate regression failure (expected seems wrong)

Browse pgsql-patches by date

  From Date Subject
Next Message Pavel Stehule 2005-11-07 13:58:16 return can contains any row or record functions
Previous Message Michael Glaesemann 2005-11-07 09:59:28 Re: Interval aggregate regression failure (expected seems wrong)