[CONJ-349] Connector disregards calendar argument for DATETIME parameters. Created: 2016-09-14  Updated: 2016-09-14

Status: Open
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 1.3.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Vitali Haravy Assignee: Diego Dupin
Resolution: Unresolved Votes: 0
Labels: datetime
Environment:

Windows, MariaDB 10.1



 Description   

MariaDB Connector/J introduced new DATETIME implementation in version 1.3.0 which breaks legacy code even though useLegacyDatetimeCode is set to true. Before, we have used version 1.1.8 in the following manner (simplified):

Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
statement.setTimestamp(index, timestamp, calendar);

Thus, we instructed to always use UTC regardless of the server/client TimeZone. After upgrading to the version 1.4.2 the above-mentioned code stopped working even with useLegacyDatetimeCode set to true. This is rather obvious if we take a look at TimestampParameter source code:

public void writeBinary(PacketOutputStream writeBuffer) {
    if (options.useLegacyDatetimeCode) {
        calendar = Calendar.getInstance();
    }
    calendar.setTimeInMillis(ts.getTime());
    writeBuffer.writeTimestampLength(calendar, ts);
}

As you can see, this code completely disregards calendar passed to it as a parameter (it saved in the constructor). As I see it, it is a breaking change.

If I set useLegacyDatetimeCode to false it will use server's time zone, which also is not a behavior we are trying to achieve.


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