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: numeric binary decode for even 10 thousands #2327

Merged
merged 4 commits into from
Oct 28, 2021

Conversation

bokken
Copy link
Member

@bokken bokken commented Oct 28, 2021

binary numeric values which represented integers multiples of 10,000
from 10,000-9,990,000 were not decoded correctly

fixes #2326

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Does ./gradlew autostyleCheck checkstyleAll pass ?
  3. Have you added your new test classes to an existing test suite in alphabetical order?

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

binary numeric values which represented integers multiples of 10,000
from 10,000-9,990,000 were not decoded correctly

fixes pgjdbc#2326
@davecramer
Copy link
Member

@bokken thanks! Once this passes we can push it and release later today.

@jorsol
Copy link
Member

jorsol commented Oct 28, 2021

Can this be tested with a wide set of different scales (not just 20)?

@bokken
Copy link
Member Author

bokken commented Oct 28, 2021

Glad to figure it out. It is a bit of a strange corner case. This binary format for numeric is... interesting.

I am working on additional tests which go through the database, to catch cases where the database's binary encoding might not match how the driver does the binary encoding.

@bokken
Copy link
Member Author

bokken commented Oct 28, 2021

@jorsol we can test with whatever scale we want. It turns out it just matters that it is not 0.

@bokken
Copy link
Member Author

bokken commented Oct 28, 2021

Any other tests to consider?

@bokken
Copy link
Member Author

bokken commented Oct 28, 2021

FAILURE   0.5sec, org.postgresql.jdbc.ScramTest > testPasswordWithoutSpace(String)[1], [1] My Space
    org.opentest4j.AssertionFailedError: expected: <28P01> but was: <08001>
        at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
        at org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1124)
        at org.postgresql.jdbc.ScramTest.testPasswordWithoutSpace(ScramTest.java:99)
FAILURE   1.2sec,   12 completed,   1 failed,   0 skipped, org.postgresql.jdbc.ScramTest

That does not appear to be related to any of these changes, right?

@jorsol
Copy link
Member

jorsol commented Oct 28, 2021

That does not appear to be related to any of these changes, right?

No, it's not, AppVeyor probably needs an additional configuration for the scram test, probably we could just stick with GH Actions and drop appveyor near in the future.

@davecramer
Copy link
Member

What I would like to see is some documentation on where this algorithm came from. But not before we release.

@davecramer
Copy link
Member

@bokken I'm inclined to merge this and release. Any reason why I shouldn't ?

@bokken
Copy link
Member Author

bokken commented Oct 28, 2021

@davecramer, I say go for it.

@davecramer davecramer merged commit b3050e6 into pgjdbc:master Oct 28, 2021
@bokken
Copy link
Member Author

bokken commented Oct 28, 2021

@davecramer
Copy link
Member

Well this algorithm must have come from somewhere. Perhaps even adding comments in the code as to what some of the parts are doing ?

It's pretty straightforward what scale and precision are. I don't think we need any more language about that.

@davecramer
Copy link
Member

pgjdbc v42.3.1-rc1 is ready for preview.

Git SHA: b3050e6
Staging repository: https://oss.sonatype.org/content/repositories/orgpostgresql-1287

@NikolayMetchev
Copy link

I tested with that version and the bug appears to be fixed.

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.

Upgrading postgres JDBC driver to 42.3.0 breaks big decimal read after 5 reads (only with Hikari)
4 participants