pingcap / pingcap/tidb

the behavior of inserting time/duration to `varchar` through binary protocol is inconsistent with MySQL

Open
#48,566 0 comments 0 reactions 0 assignees View on GitHub
compatibility-mysql80
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

Run the test `testUtilDateSetters` in `mysql-connector-j` on TiDB. The following line will fail:

```java
/* Into VARCHAR field */

String expDatetime2 = useSSPS
? zdt_20200101_120000_123456_on_wire.format(TimeUtil.DATETIME_FORMATTER_NO_FRACT_NO_OFFSET)
: expDatetime; // TODO milliseconds are ignored by server. Bug ?
String expDatetimeTS2 = useSSPS ? zdt_TS_on_wire.format(TimeUtil.DATETIME_FORMATTER_NO_FRACT_NO_OFFSET) : expDatetimeTS; // TODO milliseconds are ignored by server. Bug ?
String expTime2 = useSSPS ? expTimeNoMs : expTime; // TODO milliseconds are ignored by server. Bug ?

setObjectFromTz(props, tVarchar, utilDate, null, senderTz, expDatetimeTS2);
```

The TiDB's behavior is that the milliseconds are not ignored, but the behavior of MySQL is to ignore them. As shown in the comment, both I and the coders of `mysql-connector-j` are not sure whether it's a bug or not, so I just add this issue to record this difference and track the process of verifying it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.