-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Online DDL: avoid SQL's CONVERT(...), convert programmatically if needed
#16597
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
shlomi-noach
merged 9 commits into
vitessio:main
from
planetscale:onlineddl-charset-conversions-programmatic
Aug 15, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
63d4ae3
Online DDL: do not CONVERT column charset when migration does not mod…
shlomi-noach 904df0e
vreplication using utf8mb4, remove convert(), only programmatically c…
shlomi-noach e3b07ba
Online DDL: avoid SQL's CONVERT(...), convert programmatically if needed
shlomi-noach 0d0d56f
decapitalize error messages
shlomi-noach 3d8bc2a
simplify 'json' type checks
shlomi-noach 6e15d3f
using TablePlan field values
shlomi-noach 3693d69
using TablePlan field values
shlomi-noach fe7e73f
consolidate charset conversion codes into 'convertStringCharset()'
shlomi-noach 0548937
skip conversion for empty strings
shlomi-noach 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
Empty file.
1 change: 1 addition & 0 deletions
1
go/test/endtoend/onlineddl/vrepl_suite/testdata/alter-charset-non-utf8-80-vcopier/alter
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 @@ | ||
| MODIFY `t1` varchar(128) CHARACTER SET utf8mb4 NOT NULL, MODIFY `t2` varchar(128) CHARACTER SET latin2 NOT NULL, MODIFY `tutf8` varchar(128) CHARACTER SET latin1 NOT NULL |
19 changes: 19 additions & 0 deletions
19
go/test/endtoend/onlineddl/vrepl_suite/testdata/alter-charset-non-utf8-80-vcopier/create.sql
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,19 @@ | ||
| drop table if exists onlineddl_test; | ||
| create table onlineddl_test ( | ||
| id int auto_increment, | ||
| t1 varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| t2 varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| tutf8 varchar(128) charset utf8, | ||
| tutf8mb4 varchar(128) charset utf8mb4, | ||
| tlatin1 varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| primary key(id) | ||
| ) auto_increment=1; | ||
|
|
||
| insert into onlineddl_test values (null, md5(rand()), md5(rand()), md5(rand()), md5(rand()), md5(rand())); | ||
| insert into onlineddl_test values (null, 'átesting', 'átesting', 'átesting', 'átesting', 'átesting'); | ||
| insert into onlineddl_test values (null, 'testátest', 'testátest', 'testátest', '🍻😀', 'átesting'); | ||
| insert into onlineddl_test values (null, 'átesting-binlog', 'átesting-binlog', 'átesting-binlog', 'átesting-binlog', 'átesting-binlog'); | ||
| insert into onlineddl_test values (null, 'testátest-binlog', 'testátest-binlog', 'testátest-binlog', '🍻😀', 'átesting-binlog'); | ||
| insert into onlineddl_test values (null, 'átesting-bnull', 'átesting-bnull', 'átesting-bnull', null, null); | ||
|
|
||
| drop event if exists onlineddl_test; |
1 change: 1 addition & 0 deletions
1
...endtoend/onlineddl/vrepl_suite/testdata/alter-charset-non-utf8-80-vcopier/ignore_versions
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 @@ | ||
| (5.5|5.6|5.7) |
Empty file.
30 changes: 30 additions & 0 deletions
30
go/test/endtoend/onlineddl/vrepl_suite/testdata/non-utf8-charset-pk/create.sql
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,30 @@ | ||
| drop table if exists onlineddl_test; | ||
| create table onlineddl_test ( | ||
| id varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| t1 varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| t2 varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| tutf8 varchar(128) charset utf8, | ||
| tutf8mb4 varchar(128) charset utf8mb4, | ||
| tlatin1 varchar(128) charset latin1 collate latin1_swedish_ci, | ||
| primary key(id) | ||
| ) auto_increment=1; | ||
|
|
||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), md5(rand()), md5(rand()), md5(rand()), md5(rand()), md5(rand())); | ||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), 'átesting', 'átesting', 'átesting', 'átesting', 'átesting'); | ||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), 'testátest', 'testátest', 'testátest', '🍻😀', 'átesting'); | ||
|
|
||
| drop event if exists onlineddl_test; | ||
| delimiter ;; | ||
| create event onlineddl_test | ||
| on schedule every 1 second | ||
| starts current_timestamp | ||
| ends current_timestamp + interval 60 second | ||
| on completion not preserve | ||
| enable | ||
| do | ||
| begin | ||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), md5(rand()), md5(rand()), md5(rand()), md5(rand()), md5(rand())); | ||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), 'átesting-binlog', 'átesting-binlog', 'átesting-binlog', 'átesting-binlog', 'átesting-binlog'); | ||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), 'testátest-binlog', 'testátest-binlog', 'testátest-binlog', '🍻😀', 'átesting-binlog'); | ||
| insert into onlineddl_test values (concat('átesting-', md5(rand())), 'átesting-bnull', 'átesting-bnull', 'átesting-bnull', null, null); | ||
| end ;; |
1 change: 1 addition & 0 deletions
1
go/test/endtoend/onlineddl/vrepl_suite/testdata/non-utf8-charset-pk/ignore_versions
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 @@ | ||
| (5.5|5.6|5.7) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbussink do you think this is still needed? I don't think so anymore, now that we have native
JSONtype support.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this to be bytes we pass on to MySQL "on the other side" and they are interpreted there as either a
JSONfield or serialized as autf8mb4string if some other type on the target.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, I don't think it's a major deal on the source/
vcopierside as the primary problems we've seen there are when theseCONVERTcalls then preclude us from using the desired index in therowstreamerquery and you can't add indexes directly onJSONcolumns anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it like so for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON is a bit special anyway, since we can't use the direct textual representation, but we turn it into a sql expression using
JSON_OBJECTso we lose as little type information as possible.