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

fix(canal): fix mysql unsigned medium int #399

Merged
merged 6 commits into from
Jul 11, 2019

Conversation

Ryan-Git
Copy link
Contributor

@Ryan-Git Ryan-Git commented Jul 1, 2019

this is port from moiot/gravity#182.

the problem is we use int32 to receive mysql medium int value, which is 3 bytes. When it's unsigned, simply do a type cast is not sufficient.

canal/rows.go Outdated
@@ -57,7 +58,14 @@ func (r *RowsEvent) handleUnsigned() {
case int16:
r.Rows[i][index] = uint16(t)
case int32:
r.Rows[i][index] = uint32(t)
if strings.Contains(strings.ToLower(r.Table.Columns[i].RawType), "mediumint") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, can you add some comments here?

maybe it is better to add a test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the implementation from gh-ost is better and more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siddontang added comments and test.
@NearTan I think so, thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do more, to add a similar MediumIntColumnType.
I worry that comparing string every time can reduce the performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@Ryan-Git Ryan-Git force-pushed the fix-mysql-unsigned-mediumint branch from 591d64f to 7a090e8 Compare July 8, 2019 06:49
@siddontang
Copy link
Collaborator

CI failed

@Ryan-Git
Copy link
Contributor Author

Ryan-Git commented Jul 9, 2019

fixed

@siddontang siddontang merged commit 8b9c05e into go-mysql-org:master Jul 11, 2019
@Ryan-Git Ryan-Git deleted the fix-mysql-unsigned-mediumint branch July 11, 2019 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants