Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,10 @@ type AlterCollationSpec struct {
Collation string
}

type AlterCommentSpec struct {
Comment string
}

type ProcedureSpec struct {
ProcName ProcedureName
Definer string
Expand Down Expand Up @@ -2272,6 +2276,9 @@ type DDL struct {
// AlterCollationSpec is set for CHARACTER SET / COLLATE operations on ALTER statements
AlterCollationSpec *AlterCollationSpec

// AlterCommentSpec is set for COMMENT operations on ALTER statements
AlterCommentSpec *AlterCommentSpec

// EventSpec is set for CREATE EVENT operations
EventSpec *EventSpec

Expand Down Expand Up @@ -2676,6 +2683,8 @@ func (node *DDL) alterFormat(buf *TrackedBuffer) {
if len(node.AlterCollationSpec.Collation) > 0 {
buf.Myprintf(" collate %s", node.AlterCollationSpec.Collation)
}
} else if node.AlterCommentSpec != nil {
buf.Myprintf(" comment '%s'", node.AlterCommentSpec.Comment)
}
}

Expand Down
14 changes: 13 additions & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4245,7 +4245,19 @@ var (
},
{
input: "alter table t comment='asdf'",
output: "alter table t",
output: "alter table t comment 'asdf'",
},
{
input: `alter table t comment="asdf"`,
output: "alter table t comment 'asdf'",
},
{
input: "alter table t comment 'asdf'",
output: "alter table t comment 'asdf'",
},
{
input: `alter table t comment "asdf"`,
output: "alter table t comment 'asdf'",
},
{
input: "alter table t compression='asdf'",
Expand Down
2 changes: 1 addition & 1 deletion go/vt/sqlparser/sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/sqlparser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -6073,7 +6073,7 @@ alter_table_options:
}
| COMMENT_KEYWORD equal_opt STRING
{
$$ = &DDL{Action: AlterStr}
$$ = &DDL{Action: AlterStr, AlterCommentSpec: &AlterCommentSpec{Comment: string($3)}}
}
| COMPRESSION equal_opt STRING
{
Expand Down