-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff/push: fix MySQL 8 collation edge case verify failure
MySQL 8 exhibits some unusual behavior in SHOW CREATE TABLE regarding superfluous column-level CHARACTER SET and COLLATE clauses (where "superfluous" means "equal to the table-level defaults"). This logic was consistent in MySQL 5.7 and older, and in all versions of MariaDB; however, MySQL 8 seems to use different and sometimes-inconsistent logic. This caused false-positives for diff/push --verify failures beginning with Skeema v1.7.1 since it refactored some related logic in a03718c. Essentially, the --verify option assumed the output of SHOW CREATE TABLE is a stable "canonical" representation of the table: if you take the output and execute it as a CREATE TABLE, and then run SHOW CREATE TABLE on it, you should get back the same output. Unfortunately this is not always the case in MySQL 8 for tables that use a default collation which differs from the default for the table's chosen default charset. To fix --verify, this commit changes the logic away from being solely based on SHOW CREATE TABLE comparisons, and instead it now does a full table diff (which inherently first compares SHOW CREATE TABLE, and then compares all table metadata if those do not match). This comparison is able to detect, but intentionally ignore, differences in superfluous CHARACTER SET and COLLATE clauses in MySQL 8. This commit also adds a new integration test method, which failed on the old --verify logic in MySQL 8 but now passes. Fixes #184. Thank you to Etsy's database team for the report!
- Loading branch information
Showing
3 changed files
with
139 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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,41 @@ | ||
USE product; | ||
|
||
CREATE TABLE many_permutations1 ( | ||
a char(10), | ||
b char(10) CHARACTER SET latin1, | ||
c char(10) COLLATE latin1_swedish_ci, | ||
d char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci, | ||
e char(10) COLLATE latin1_general_ci, | ||
f char(10) CHARACTER SET utf8mb4, | ||
g char(10) COLLATE utf8mb4_general_ci | ||
) DEFAULT CHARSET=latin1; | ||
|
||
CREATE TABLE many_permutations2 ( | ||
a char(10), | ||
b char(10) CHARACTER SET latin1, | ||
c char(10) COLLATE latin1_swedish_ci, | ||
d char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci, | ||
e char(10) COLLATE latin1_general_ci, | ||
f char(10) CHARACTER SET utf8mb4, | ||
g char(10) COLLATE utf8mb4_general_ci | ||
) DEFAULT CHARSET=latin1 COLLATE latin1_general_ci; | ||
|
||
CREATE TABLE many_permutations3 ( | ||
a char(10), | ||
b char(10) CHARACTER SET latin1, | ||
c char(10) COLLATE latin1_swedish_ci, | ||
d char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci, | ||
e char(10) COLLATE utf8_general_ci, | ||
f char(10) CHARACTER SET utf8mb3, | ||
g char(10) COLLATE utf8_unicode_ci | ||
) DEFAULT CHARSET=utf8; | ||
|
||
CREATE TABLE many_permutations4 ( | ||
a char(10), | ||
b char(10) CHARACTER SET latin1, | ||
c char(10) COLLATE latin1_swedish_ci, | ||
d char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci, | ||
e char(10) COLLATE utf8_general_ci, | ||
f char(10) CHARACTER SET utf8mb3, | ||
g char(10) COLLATE utf8_unicode_ci | ||
) DEFAULT CHARSET=utf8mb3 COLLATE utf8_unicode_ci; |