Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in 1.5.1, PG date to/from java.sql.Date conversions #199

Closed
pmichalek opened this issue Oct 30, 2018 · 9 comments
Closed

Regression in 1.5.1, PG date to/from java.sql.Date conversions #199

pmichalek opened this issue Oct 30, 2018 · 9 comments

Comments

@pmichalek
Copy link

After transition to winter time on night to 28th October 2018 calling TriggerResultSet.getDate(...) returns one day before.
DB: 28-10-2018 -> getDate(...) -> Java: 28-10-2018 (night was one hour longer)
DB: 29-10-2018 -> getDate(...) -> Java: 28-10-2018
DB: 30-10-2018 -> getDate(...) -> Java: 29-10-2018

Fedora 27 (time zone CET)
Java version 1.8.0.192 and 1.8.0.162
Postgresql 11.0 and 10.4 (timezone='Europe/Prague')

@jcflack
Copy link
Contributor

jcflack commented Oct 30, 2018 via email

@pmichalek
Copy link
Author

Is the same problem seen with getObject(..., java.time.LocalDate.class)?

getObject(..., java.time.LocalDate.class) seems to be OK!

Do you have an easy way to see if PL/Java 1.5.0 behaved differently (i.e., is this a behavior change)?

Unfortunately not.

@jcflack
Copy link
Contributor

jcflack commented Oct 30, 2018 via email

@jcflack
Copy link
Contributor

jcflack commented Oct 30, 2018

I can reproduce in PG 11 / PL/Java 1.5.1 by setting TimeZone to Europe/Prague (changing no other settings):

set TimeZone to 'Europe/Prague';
select *
  from
    (select date '2018-10-29') as p,
    roundtrip(p) as (tostring text, class text);
    date    |  tostring  |     class     
------------+------------+---------------
 2018-10-29 | 2018-10-28 | java.sql.Date

select *
  from
    (select date '2018-10-29') as p,
    roundtrip(p, 'java.time.LocalDate') as (tostring text, class text);
    date    |  tostring  |        class        
------------+------------+---------------------
 2018-10-29 | 2018-10-29 | java.time.LocalDate

Now to see if 1.5.0 did the same thing....

@pmichalek
Copy link
Author

Postgresql 9.6.2 with branch trackpg/REL1_5_STABLE/pg96 seems to be OK!

@jcflack
Copy link
Contributor

jcflack commented Oct 31, 2018

Rats. That would suggest 1.5.1 broke it then.

Could you try the bug/REL1_5_STABLE/issue199 branch?

@pmichalek
Copy link
Author

pmichalek commented Oct 31, 2018

Branch bug/REL1_5_STABLE/issue199 is OK

@jcflack jcflack changed the title Wrong result of getDate after transition to winter time Regression in 1.5.1, PG date to/from java.sql.Date conversions Nov 5, 2018
@jcflack
Copy link
Contributor

jcflack commented Nov 5, 2018

There will be a 1.5.2 to fix this 1.5.1 regression.

However, analysis for this issue uncovered several other, longstanding issues in the legacy date, time, and timestamp conversions to and from the java.sql types, now detailed in #200. Because those are not regressions, they will be left alone in 1.5.2 and fixed in a later release.

Meanwhile, all of these issues underscore the advantages of migrating code to Java 8 or later and the java.time types wherever practical.

jcflack added a commit that referenced this issue Nov 5, 2018
Fix a regression in 1.5.1 that was not caught in pre-release testing,
and could leave conversions between PostgreSQL date and java.sql.Date
off by one day in certain timezones and times of the year (#199).

Other issues in date/time conversion have also been uncovered that are
of longer standing, not recent regressions. They are detailed in #200
and are not fixed in this PR, but can be addressed in another, later
release.
@jcflack
Copy link
Contributor

jcflack commented Nov 5, 2018

Resolved with release of 1.5.2.

@jcflack jcflack closed this as completed Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants