[CONJ-1065] wrong Resultset.wasNull() for zero-date timestamps Created: 2023-03-20  Updated: 2023-04-26  Resolved: 2023-04-25

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC compatibility
Affects Version/s: 3.1.2
Fix Version/s: 3.1.4

Type: Bug Priority: Major
Reporter: Thorsten Goetzke Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

We updated mariadb-java client from version 2.72 to 3.1.2
This seems to cause an jdbc compatibility problem as follows.

There is a Timestamp 0,0,0 0,0,0:000 in the database. mariadb-java reads this value and converts this to null.
See https://github.com/mariadb-corporation/mariadb-connector-j/blame/master/src/main/java/org/mariadb/jdbc/client/column/TimestampColumn.java

    // xpand workaround https://jira.mariadb.org/browse/XPT-274
    if (year == 0
        && month == 0
        && dayOfMonth == 0
        && hour == 0
        && minutes == 0
        && seconds == 0
        && microseconds == 0) return null;

I dont know what the comment means, and the link doesnt work for me. However this behavior means that ResultSet#getTimestamp will return null, if the databse value is not NULL but 0,0,0 0,0,0:000.
our codebase asumes that ResultSet#getTimespamp can only return null, if the Coloumn Value is SQL NULL (as checked with #wasNull). However in this case #wasNull will return false, yet the value will be null, causing a Nullpointer Exception in the process.
I guess thats a jdbc compatibility violation?



 Comments   
Comment by Diego Dupin [ 2023-03-20 ]

Timestamp "0000-00-00 00:00:00.000" cannot be returned, and connector returns null. That is the expected behavior.
problem is indeed that Resultset.wasNull must return true in this specific case, and that's not the case.

This will be in 3.1.4 (3.1.3 is in the process of being released).

Comment by Thorsten Goetzke [ 2023-03-21 ]

Many thanks. is there an estimate for the release date of 3.1.4?

Comment by Diego Dupin [ 2023-04-25 ]

corrected with https://github.com/mariadb-corporation/mariadb-connector-j/commit/7d24adec2bfd1ee23804bad33d14e5460cf64bc3
3.1.4 will be release this week.

Generated at Thu Feb 08 03:20:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.