Skip to content

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

3 participants