-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
schemadiff
: fix diffing of textual columns with implicit charsets
#14930
schemadiff
: fix diffing of textual columns with implicit charsets
#14930
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…eIgnoreAlways behavior Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #14930 +/- ##
==========================================
+ Coverage 47.26% 47.31% +0.04%
==========================================
Files 1136 1137 +1
Lines 238484 238684 +200
==========================================
+ Hits 112721 112923 +202
+ Misses 117158 117152 -6
- Partials 8605 8609 +4 ☔ View full report in Codecov by Sentry. |
go/vt/schemadiff/column.go
Outdated
if c.IsTextual() || other.IsTextual() { | ||
switch hints.TableCharsetCollateStrategy { | ||
case TableCharsetCollateStrict: | ||
// No need to do anything |
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 don't think this is correct. Also in this case we can get an empty / column charset due to normalization if you change the table level charset and we shouldn't then generate a diff.
This is actually visible in a broken test that was added.
go/vt/schemadiff/diff_test.go
Outdated
from: "create table t (a varchar(64) CHARACTER SET latin1 COLLATE latin1_bin) default charset=latin1", | ||
to: "create table t (a varchar(64) CHARACTER SET latin1 COLLATE latin1_bin)", | ||
diff: "alter table t modify column a varchar(64) character set latin1 collate latin1_bin, charset utf8mb4, algorithm = COPY", | ||
cdiff: "ALTER TABLE `t` MODIFY COLUMN `a` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin, CHARSET utf8mb4, ALGORITHM = COPY", |
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.
This test expectation is wrong. In this case there should not be a MODIFY COLUMN
, since the charset / collation of the column doesn't actually change. This should only be alter table t charset utf8mb4
instead.
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.
Agreed. Looking into it.
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've fixed the expected output, so that now the PR should be failing until the logic is adapted.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
scheadiff
: handle TableCharsetCollateIgnoreAlways
and TableCharsetCollateIgnoreEmpty
correctlyscheadiff
: fix diffing of textual columns with implicit charsets
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
We already had the parser that needed to be injected, but in order to properly handle MySQL 5.7 we also need to inject collations configuration. Instead of adding more arguments, we introduce the schemadiff environment struct and use that to inject the things like the current parser and current collation environment and default collation. Also need to refactor the rest that ends up using schemadiff to inject it similarly. The core goal here is that the sidecar can properly inject the right collation as well so we can unblock fixing the case sensitivity there. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
…hout a charset, we use Envronment to autopopulate the charset, or return an error what that is not possible Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…hout a charset, we use Envronment to autopopulate the charset, or return an error what that is not possible Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
ad0fe03
to
26acffc
Compare
scheadiff
: fix diffing of textual columns with implicit charsetsschemadiff
: fix diffing of textual columns with implicit charsets
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.
LGTM! Thankyou for fixing this!
…olumns with implicit charsets Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Description
See story in #14929. Also, see test cases added in
diff_test.go
to understand the nuances ofTableCharsetCollateStrategy
.In this PR:
column.go
,ColumnDefinitionEntity.ColumnDiff()
investigates not only the from/to columns, but also the from/to tables' charset/collation, and temporarily populates column with any missing data so as to have a true comparison.charsetCollate
struct was introduced, and used throughouttable.go
as the diff result of two tables' charset/collations.Update: merged another PR
In a game of pass-the-ball, this PR now includes #14934 (which originally started off this PR). Please see description on #14934
Related Issue(s)
Fixes #14929
Checklist
Deployment Notes