-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix problems when altering a column from binary to varbinary
#1628
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a30693
Fix binary column trailing zero stripping for non-key columns
jorendorff 698ae27
Simplify by removing isUniqueKeyColumn now that it's no longer used.
jorendorff 480d897
In convertArg, don't convert binary data to strings.
jorendorff ca2118a
fix a lint
jorendorff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| -- Test for https://github.com/github/gh-ost/issues/909 variant: | ||
| -- Binary columns with trailing zeros should preserve their values | ||
| -- when migrating from binary(N) to varbinary(M), even for rows | ||
| -- modified during migration via binlog events. | ||
|
|
||
| drop table if exists gh_ost_test; | ||
| create table gh_ost_test ( | ||
| id int NOT NULL AUTO_INCREMENT, | ||
| info varchar(255) NOT NULL, | ||
| data binary(20) NOT NULL, | ||
| PRIMARY KEY (id) | ||
| ) auto_increment=1; | ||
|
|
||
| drop event if exists gh_ost_test; | ||
| delimiter ;; | ||
| create event gh_ost_test | ||
| on schedule every 1 second | ||
| starts current_timestamp | ||
| ends current_timestamp + interval 60 second | ||
| on completion not preserve | ||
| enable | ||
| do | ||
| begin | ||
| -- Insert rows where data has trailing zeros (will be stripped by binlog) | ||
| INSERT INTO gh_ost_test (info, data) VALUES ('insert-during-1', X'aabbccdd00000000000000000000000000000000'); | ||
| INSERT INTO gh_ost_test (info, data) VALUES ('insert-during-2', X'11223344556677889900000000000000000000ee'); | ||
|
|
||
| -- Update existing rows to values with trailing zeros | ||
| UPDATE gh_ost_test SET data = X'ffeeddcc00000000000000000000000000000000' WHERE info = 'update-target-1'; | ||
| UPDATE gh_ost_test SET data = X'aabbccdd11111111111111111100000000000000' WHERE info = 'update-target-2'; | ||
| end ;; | ||
|
|
||
| -- Pre-existing rows (copied via rowcopy, not binlog - these should work fine) | ||
| INSERT INTO gh_ost_test (info, data) VALUES | ||
| ('pre-existing-1', X'01020304050607080910111213141516171819ff'), | ||
| ('pre-existing-2', X'0102030405060708091011121314151617181900'), | ||
| ('update-target-1', X'ffffffffffffffffffffffffffffffffffffffff'), | ||
| ('update-target-2', X'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --alter="MODIFY data varbinary(32)" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.