Repository navigation
Conversation
CREATE TABLE ON COMMIT and USING clauses were split into one raw TableOption per word. Parse them as Kind.ON_COMMIT with a typed OnCommitAction and as Kind.ACCESS_METHOD; the legacy token lists and SQL output are unchanged. ALTER TABLE DROP [COLUMN] c RESTRICT was rejected. AlterExpressionDrop now keeps CASCADE/RESTRICT as a CascadeBehavior for column and constraint drops, and getParameters() still lists the keyword. Signed-off-by: minleejae <mmj9808@gmail.com>
Read the table COMMENT of CREATE TABLE, CREATE TABLE ... AS SELECT and ALTER TABLE, and the partition and subpartition COMMENT, with the stringValue() helper so the literal records the dialect's escaping and getNotExcapedValue() returns the stored text. TableOption gains getComment(), setComment(), withComment() and a comment() factory, following the table option state rules: the literal replaces the option's contents, while setValue() and setTokens() store unparsed text. PartitionDefinition gains getCommentValue() and setCommentValue(); getComment() and setComment(String) remain String accessors. getValue(), the token snapshots and the rendered SQL keep the literal as written. Signed-off-by: minleejae <mmj9808@gmail.com>
This was referenced Oct 14, 2026
This branch has not been deployed
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.
Builds on #2814, which adds the ON COMMIT state to
TableOption; this PR adds the COMMENT literal to the same state model, so please review that first.Purpose
Let callers read MySQL table and partition comments as decoded text. Column and event comments are already
StringValueliterals whosegetNotExcapedValue()matches what MySQL stores. Table and partition comments are only raw SQL text, so a caller that convertsCOMMENT='it\'s'to another database has to strip the quotes and undo the MySQL escapes itself.Current design (As-is)
COMMENTof CREATE TABLE, CREATE TABLE … AS SELECT and ALTER TABLE is read byMySqlTableOptionValue()and stored as a String inTableOption.getValue(), for example'it\'s'.COMMENTin CREATE TABLE, ALTER TABLE ADD PARTITION and REORGANIZE PARTITION is the token image inPartitionDefinition.getComment().\','',\\,\nand double-quoted MySQL strings cannot be decoded reliably.Target design (To-be)
stringValue(token)helper, like column comments. TheStringValuerecords the dialect's escaping, sogetNotExcapedValue()returns the stored text:it'sfor'it''s'and, withDialect.MYSQL, for'it\'s';a\bfor'a\\b'; a line break for'line1\nline2';double "quoted" textfor"double \"quoted\" text".TableOption.getComment(),setComment(StringValue),withComment(...)and aTableOption.comment(StringValue)factory. The state rules follow Make table option state transitions explicit #2765:setCommentreplaces the option's contents with the literal and selectsCOMMENT. It keeps the equals spelling, and an existing COMMENT also keeps its name (comment = …). A null literal omits the value.setValuestores a plain value andsetTokensopaque tokens. Neither is parsed, sogetComment()then returns null. Selecting another kind keeps the literal's SQL text as a plain value.COMMENT "x"without the MySQL dialect, where"x"is a quoted identifier.TableDefinitionTraversal, like a column COMMENT literal.PartitionDefinition.getCommentValue()/setCommentValue(StringValue). The existinggetComment()/setComment(String)remain as String accessors: the getter returns the literal's SQL text, and the setter reads SQL text into aStringValuewith standard escaping.TableOption.getValue(),getTokens(),CreateTable.getTableOptionsStrings(),AlterExpressionTableOption.getCommentText()andPartitionDefinition.getComment()still return the literal as written, for example'it\'s'.n'…'is now printed asN'…', as column comments already are.usage.rstdocuments the accessors and state rules.Validation
MySqlCommentLiteralTestadds 27 cases:Dialect.MYSQLand without a dialect;getNotExcapedValue()compared with the values MySQL 8.4 stored:'it''s','it\'s',"dq","double \"quoted\" text",'','line1\nline2','a\\b','tab\there','percent\% underscore\_', Korean text, an emoji and a literal line break;spotlessApply checkon top of Model PostgreSQL ON COMMIT, access method and DROP behavior #2814: 10,420 tests, 10,395 passed, 25 skipped, zero failures/errors. The grammar choice conflict check, Checkstyle, PMD, SpotBugs and coverage checks pass.master(bdf8ac31) on a corpus of 635 MySQL 8.4 and PostgreSQL 18 DDL/DCL statements, each accepted by the server, plus variants, with and without a dialect:toString(), deparser output and reparse are identical, with zero regressions;StringValue.StringValue. Its decoded value matches what MySQL 8.4 stored for the same literal forms.COMMENT 'a' 'b'andCOMMENT = _utf8mb4'x', which MySQL rejects, parse as before.toString()on a second, identical server, in the same order. All 205 MySQL and 328 PostgreSQL statements give the same result (success, or the same error).pg_description) is byte-identical on both servers.Integration validation
Applied this PR together with the other comment PRs (#2820, #2822, #2824, #2823), the DDL/DCL PRs #2806–#2819 and #2778 on
master(bdf8ac31), with the stacked PRs on top of their bases (#2814 → #2821, #2816 → #2822, #2806 → #2824 and #2811 → #2812 → #2823).master. Between the branches, conflicts are limited to adjacent additions (README/index rows, usage sections, imports, test methods, visitor and feature lists, an enum line and an alias guard).spotlessApply check: 11,877 tests, 11,852 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.master: 206) and 363 of 364 PostgreSQL statements (master: 328), the same as Share MySQL account names across CREATE USER and DEFINER #2806–Render single spaces in ALTER visibility, FORCE and row level security actions #2819 together. There are no regressions.master: 67) and for 118 of 119 PostgreSQL statements (master: 76). The exception is aCREATE AGGREGATEsetup statement. Every table, column, index, partition, routine, event, user andCOMMENT ONcomment literal is aStringValue, exceptCOMMENT = _utf8mb4'x', which MySQL rejects.