Re: Timezone error when casting. Maybe daylight saving

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kjetil Nygård <polpot78(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-jdbc(at)postgresql(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Timezone error when casting. Maybe daylight saving
Date: 2014-04-01 22:43:15
Message-ID: 8362.1396392195@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-jdbc

Kjetil =?ISO-8859-1?Q?Nyg=E5rd?= <polpot78(at)gmail(dot)com> writes:
> I try to build with the tests, but when I run the test
> org.postgresql.test.jdbc2.StatementTest.testDateFunctions() i get:
> junit.framework.AssertionFailedError: expected:<-3> but was:<-2>

> When I run the same function directly in PostgreSQL, I also get -2:

> test=> select extract( day from ((CAST(-3 || ' day' as
> interval)+now())-now()));
> date_part
> -----------
> -2

I get -3 ... unless I set my timezone to Europe/Oslo. I'm guessing
that you had a daylight savings transition this past weekend? If so,
the issue is that the query gives a different answer for a couple
of days after a transition, as a consequence of the fact that adding
'1 day' to a timestamp is not the same as adding '24 hours'.

We used to have issues of this sort with the core regression tests;
they'd fail predictably for a couple of days in spring and fall.
Eventually we changed all the test cases to not hit the boundary
condition ... which is arguably a loss of test coverage, but it
wasn't worth the hassle of having unstable regression test results.
It sounds like JDBC's test cases still have the issue.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-04-02 02:05:34 Re: [BUGS] BUG #9518: temporary login failure - "missing pg_hba entry"
Previous Message Richard DeVenezia 2014-04-01 21:51:01 postgresql-9.3.4-1-windows-x64 installer - Problem with strong passwords

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Paquier 2014-04-02 03:54:52 Re: [BUGS] Timezone error when casting. Maybe daylight saving
Previous Message Kjetil Nygård 2014-04-01 20:53:57 Re: Timezone error when casting. Maybe daylight saving