Skip to content

MySQL time类型字段,值为100:00:01时解析的值错误,解析为00:00:01 #2257

@ysannezzz

Description

@ysannezzz
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

environment

  • canal version
    1.1.3
  • mysql version
    5.7

Issue Description

MySQL字段类型为TIME时,写入值100:00:01,canal解析出来的值为00:00:01。大于100的时间,例如101:00:01,解析正常。

debug研究了下,应该是RowsLogBuffer解析的bug,第759行,个人觉得应该是d >= 100。

           if (d > 100) {
                        builder.append(String.valueOf(d));
                    } else {
                        appendNumber2(builder, d);
                    }
  public static void appendNumber2(StringBuilder builder, int d) {
        if (d >= 10) {
            builder.append(digits[(d / 10) % 10]).append(digits[d % 10]);
        } else {
            builder.append('0').append(digits[d]);
        }
    }

appendNumber2方法里会丢失精度,如果是100,格式化完返回00。

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions