Repository navigation
fix: parse every MySQL character set form of ALTER TABLE CONVERT TO - #2882
Merged
manticore-projects merged 1 commit intoOct 31, 2026
Conversation
CONVERT TO accepted only CHARACTER SET followed by an unquoted name, and COLLATE only an unquoted name. CONVERT TO CHARSET, CHARACTER SET DEFAULT, the binary character set and quoted names failed, although MySQL accepts them all and column types already took the same names. CONVERT TO now reads its character set and collation with the name rule of column types, which the new CharacterSetName production shares, and also accepts DEFAULT. AlterExpression.isUseCharsetKeyword() keeps the CHARSET spelling, so CONVERT TO CHARSET, DEFAULT CHARSET and CHARSET table options print as written instead of as CHARACTER SET. Signed-off-by: minleejae <[email protected]>
Contributor
|
Thank you! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ALTER TABLE … CONVERT TOaccepted onlyCHARACTER SETfollowed by an unquoted name, andCOLLATEonly an unquoted name. MySQL accepts theCHARSETabbreviation,CHARACTER SET DEFAULT, thebinarycharacter set and quoted names there, and column types already parse the same names, butALTER TABLE t CONVERT TO CHARSET utf8mb4,… CONVERT TO CHARACTER SET DEFAULT,… CONVERT TO CHARACTER SET binaryand… COLLATE 'utf8mb4_bin'failed, with and without the MySQL dialect.CONVERT TOnow reads its character set and collation with the name rule of column types (TypeCharacterSet), which the newCharacterSetNameproduction shares, and also acceptsDEFAULT. The newAlterExpression.isUseCharsetKeyword()keeps theCHARSETspelling, asColDataType.isUseCharsetKeyword()does for columns.CONVERT TO CHARSET, and theDEFAULT CHARSETandCHARSETtable options, which parsed before, now print as written instead of asCHARACTER SET.Public method signatures are retained.
Syntax reference: MySQL 8.4 ALTER TABLE (
CONVERT TO), Specifying Character Sets and Collations.Validation:
MySqlConvertToCharacterSetTestadds 12 statements. Each is parsed with and without the MySQL dialect, checked againsttoString()and the deparser, and parsed inside a script. Further tests check theCHARSETspelling, the character set and collation values, and 4 rejected forms. On masterdd03d6ff1, 10 of the 12 fail, and the other 2 (DEFAULT CHARSET utf8mb4,CHARSET = utf8mb4 COLLATE = utf8mb4_bin) printCHARACTER SET.check: 12,338 tests, 0 failures, 25 skipped. Grammar ambiguity, formatting (Spotless ratchet againstupstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass.AI assistance: prepared with Claude Code.