Re: [GENERAL] date_part bug?

Started by Oleg Broytmannabout 27 years ago3 messages
#1Oleg Broytmann
phd@sun.med.ru

Hello!

On Thu, 17 Dec 1998, Tim Williams wrote:

When I run the following set of statements in postgres v6.4 (built on
Debian Linux):

create table tmp (v1 date, v2 datetime);
insert into tmp values ('06-01-1999', '06-01-1999');
select date_part('month', v1) as m1, date_part('month', v2) as m2 from
tmp;

I see the following results:

m1|m2
--+--
5| 6
(1 row)

Why is date_part giving different results for date and date_time? Why
is it wrong for 'date'? Anybody seen this before?

I tried this and it works pretty good for me on Solaris.
It looks like an error in postgres on glibc2-based linux platform. It is
discussing now on pgsql-hackers list. The solution is not ready yet. I am
working on this with a good deal of help from other people...

Oleg.
----
Oleg Broytmann http://members.tripod.com/~phd2/ phd2@earthling.net
Programmers don't die, they just GOSUB without RETURN.

#2Oliver Elphick
olly@lfix.co.uk
In reply to: Oleg Broytmann (#1)

Oleg Broytmann wrote:

create table tmp (v1 date, v2 datetime);
insert into tmp values ('06-01-1999', '06-01-1999');
select date_part('month', v1) as m1, date_part('month', v2) as m2 from
tmp;

I see the following results:

m1|m2
--+--
5| 6
(1 row)

...

I tried this and it works pretty good for me on Solaris.
It looks like an error in postgres on glibc2-based linux platform. It is
discussing now on pgsql-hackers list. The solution is not ready yet. I am
working on this with a good deal of help from other people...

Not all glibc2: I run glibc2 Debian Linux and do not see this problem.
I was wondering if it was libc5 that was giving trouble...

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"In the beginning was the Word, and the Word was with
God, and the Word was God. The same was in the
beginning with God. All things were made by him; and
without him was not any thing made that was made."
John 1:1-3

#3Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Oliver Elphick (#2)
Re: [HACKERS] Re: [GENERAL] date_part bug?

Not all glibc2: I run glibc2 Debian Linux and do not see this problem.
I was wondering if it was libc5 that was giving trouble...

Not on my libc5-only machine (where I developed the code). We'll need to
get a reproducible case to be able to track it down. I'm guessing that
we are seeing float->int rounding problems, though I don't know why this
test query should show different results for the two columns.

What glibc2, compiler, and optimization level are you using? If you are
using anything above -O2 try backing down to that; if you are already
there then try -O0 and tell us what changes.

- Tom

postgres=> create table tmp (v1 date, v2 datetime);
CREATE
postgres=> insert into tmp values ('06-01-1999', '06-01-1999');
INSERT 901482 1
postgres=> select date_part('month', v1) as m1, date_part('month', v2)
as m2 from tmp;
m1|m2
--+--
6| 6
(1 row)