We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
MySQL字段类型为TIME时,写入值-00:00:00.12,canal解析出来的值变成了正数00:00:00.12。只有当时分秒都为0,并且毫秒值为负数时才会触发该问题。 看了下代码,应该是RowsLogBuffer解析的bug,第735行,判断正数部分为0后生成时间前缀"00:00:00",感觉应该同时判断下毫秒值,毫秒为负数时前缀需要加上负号:
String second = null; if (intpart == 0) { second = frac < 0 ? "-00:00:00" : "00:00:00"; } else {
原代码如下:
String second = null; if (intpart == 0) { second = "00:00:00"; } else {
建表语句如下:
CREATE DATABASE if not exists canal; CREATE TABLE `canal`.`time2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `start_time` TIME(2) NOT NULL COMMENT '时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='time2测试表';
执行如下SQL写入数据:
insert into canal.time2(start_time) value('-00:00:00.12');
canal可以正确解析出start_time负数字段值-00:00:00.12
实际上canal解析出来的start_time字段值变成了正数00:00:00.12,负号丢掉了
The text was updated successfully, but these errors were encountered:
验证可修复
Sorry, something went wrong.
fixed issue #4178 , support -00:00:00.12
d71a208
No branches or pull requests
environment
Issue Description
MySQL字段类型为TIME时,写入值-00:00:00.12,canal解析出来的值变成了正数00:00:00.12。只有当时分秒都为0,并且毫秒值为负数时才会触发该问题。
看了下代码,应该是RowsLogBuffer解析的bug,第735行,判断正数部分为0后生成时间前缀"00:00:00",感觉应该同时判断下毫秒值,毫秒为负数时前缀需要加上负号:
原代码如下:
Steps to reproduce
建表语句如下:
执行如下SQL写入数据:
Expected behaviour
canal可以正确解析出start_time负数字段值-00:00:00.12
Actual behaviour
实际上canal解析出来的start_time字段值变成了正数00:00:00.12,负号丢掉了
The text was updated successfully, but these errors were encountered: