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

Incorrect handling of negative TIME values #154

Open
fivetran-nghiale opened this issue Sep 10, 2024 · 4 comments
Open

Incorrect handling of negative TIME values #154

fivetran-nghiale opened this issue Sep 10, 2024 · 4 comments

Comments

@fivetran-nghiale
Copy link

Reproduction

Run test in BinaryLogClientIntegrationTest

  @Test
  public void testDeserializationOfTIME() throws Exception {
      assertEquals(writeAndCaptureRow("time", "'-00:00:01'"), new Serializable[]{
          generateTime(1969, 12, 31, 23, 59, 59, 0)});
  }

Test fails with

java.lang.AssertionError: Lists differ at element [0]: -1000 != 3686643000
Expected :-1000
Actual   :3686643000

where 3686643000 is equivalent to Feb 12 1970 16:04:03.000

@fivetran-nghiale
Copy link
Author

Tagging @Naros for awareness here since I know your team at Debezium has forked from the Osheroff client. Are you folks aware of this bug?

@Naros
Copy link
Collaborator

Naros commented Oct 4, 2024

Thanks @fivetran-nghiale, is this specific to a certain version of MySQL or MariaDB?

@Naros
Copy link
Collaborator

Naros commented Oct 4, 2024

I tested with MySQL 8.2 and MariaDB 11.4.3 with Debezium 3, and in both cases, the TIME field was emitted in Debezium as -1000000L, as expected. I haven't looked at the BinlogClient test case, but maybe the issue is just the tests logic?

@fivetran-nghiale
Copy link
Author

fivetran-nghiale commented Oct 8, 2024

Thanks for replying here!

I was running the integration tests from the repository which appears to spin up a MySQL 5.7.17 server according to the output logs but haven't tried other versions.

It is possible that I am missing something but I noticed that the call to asUnixTime for deserializing TIMEV2 is hardcoded to January 1st, 1970 which is the reason why I created this issue in the first place as I didn't think it was possible to generate negative long values from the method return (if dates prior to Unix epoch can be considered negative timestamps).

Something else I noticed is that the sign bit is never used as well from the ByteArrayInputStream inputStream in the deserializeTimeV2 method.

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