Skip to content

feat(parser)!: MySQL accepts non-CSV table options. - #8503

Open
burnison wants to merge 2 commits into
tobymao:mainfrom
burnison:mysql_alter_table_properties
Open

burnison wants to merge 2 commits into
tobymao:mainfrom
burnison:mysql_alter_table_properties

Conversation

@burnison

@burnison burnison commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

An ALTER TABLE in MySQL allows table options to be passed without commas,

ALTER TABLE tbl_name
    [alter_option [, alter_option] ...]
    [partition_options]

alter_option: {
    table_options
    ...

table_options:
    table_option [[,] table_option] ...

This commit adds OPTIONAL_COMMA_BETWEEN_ALTER_TABLE_OPTIONS, which, when True, correctly parses a query like

ALTER TABLE t ADD i int, ENGINE=INNODB COMMENT='hi' AUTO_INCREMENT=5

Adding this support in MySQL raised a small issue, where CHARSET is a valid alias of CHARACTER SET, but was otherwise parsed as a table option.

An `ALTER TABLE` in MySQL allows table options to be passed without
commas,

```
ALTER TABLE tbl_name
    [alter_option [, alter_option] ...]
    [partition_options]

alter_option: {
    table_options
    ...

table_options:
    table_option [[,] table_option] ...
```

This commit adds `OPTIONAL_COMMA_BETWEEN_ALTER_TABLE_OPTIONS`, which,
when `True`, correctly parses a query like

```sql
ALTER TABLE t ADD i int, ENGINE=INNODB COMMENT='hi' AUTO_INCREMENT=5
```

Adding this support in MySQL raised a small issue, where `CHARSET` is a
valid alias of `CHARACTER SET`, but was otherwise parsed as a table
option.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The changes align with existing parser behavior and include focused regression coverage, with no confirmed blocking issues.

Review effort: Balanced
Findings: None

What changed in this PR

Extends SQLGlot’s MySQL DDL parser to accept table options without commas and recognize column-level CHARSET aliases.

Changes:

  • Enables optional commas between MySQL ALTER TABLE options.
  • Adds CHARSET column-constraint parsing.
  • Adds regression coverage for mixed options, charset handling, and comments.
File Description
tests/​dialects/​test_mysql.py Adds DDL parsing and expression assertions.
sqlglot/​parsers/​mysql.py Enables optional commas and column CHARSET support.
sqlglot/​parser.py Adds configurable ALTER option parsing and property separator handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The `CHAR SET` syntax is a synonym for `CHARACTER SET` and `CHARSET`,
which the MySQL parser fails to parse.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants