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

Fix 1.5.1 regression in date conversion to/from java.sql.Date #201

Merged
merged 2 commits into from
Nov 5, 2018

Conversation

jcflack
Copy link
Contributor

@jcflack jcflack commented 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).

1.5.1 added support for the newer java.time classes from JSR 310 / JDBC 4.2, which are recommended as superior alternatives to the older conversions involving java.sql.Date and related classes. The new versions are superior in part because they do not have hidden timezone dependencies.

However, the change to the historical java.sql.Date conversion behavior was inadvertent and needs to be fixed.

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.

That commit was part of the work of adding the java.time types for 1.5.1
(issue #137). A potential for overflow in timezone handling for timestamps
was corrected by changing the API of Timestamp_getTimeZone_id(). There
was known to be one other use of that function, in Date.c. A comment was
even added in Timestamp.h advising that there was a known use in Date.c.
But somehow updating that known use in Date.c slipped through the cracks.

The end result was that the new, preferable java.time API got added
(preferable in part because it eliminates the unexpected timezone
dependencies when manipulating local dates and times), but in the process
a spooky timezone-dependent off-by-a-day error got introduced to the
old date <-> java.sql.Date conversions.
@jcflack jcflack merged commit 64e62ef into REL1_5_STABLE Nov 5, 2018
jcflack added a commit that referenced this pull request 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.
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

Successfully merging this pull request may close these issues.

1 participant