Skip to content
New issue

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类型字段,值为100:00:01时解析的值错误,解析为00:00:01 #2257

Closed
2 tasks done
ysannezzz opened this issue Sep 26, 2019 · 1 comment
Closed
2 tasks done
Assignees
Labels
Milestone

Comments

@ysannezzz
Copy link

  • 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。

@agapple
Copy link
Member

agapple commented Sep 29, 2019

可以考虑给我提交一个MR

agapple added a commit that referenced this issue Oct 9, 2019
@agapple agapple closed this as completed Oct 9, 2019
@agapple agapple self-assigned this Oct 9, 2019
@agapple agapple added this to the v1.1.5 milestone Oct 9, 2019
@agapple agapple added the bug label Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants