Skip to content

Commit 79e509f

Browse files
caifengyingit-hulk
authored andcommitted
feat: support database comment
1 parent b3f8c47 commit 79e509f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

parser/ast.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,7 @@ type CreateDatabase struct {
15021502
IfNotExists bool // true if 'IF NOT EXISTS' is specified
15031503
OnCluster *ClusterClause
15041504
Engine *EngineExpr
1505+
Comment *StringLiteral
15051506
}
15061507

15071508
func (c *CreateDatabase) Pos() Pos {
@@ -1531,6 +1532,10 @@ func (c *CreateDatabase) String() string {
15311532
builder.WriteString(" ")
15321533
builder.WriteString(c.Engine.String())
15331534
}
1535+
if c.Comment != nil {
1536+
builder.WriteString(" COMMENT ")
1537+
builder.WriteString(c.Comment.String())
1538+
}
15341539
return builder.String()
15351540
}
15361541

parser/parser_table.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,18 @@ func (p *Parser) parseCreateDatabase(pos Pos) (*CreateDatabase, error) {
9898
if engineExpr != nil {
9999
StatementEnd = onCluster.End()
100100
}
101+
commentExpr, err := p.tryParseComment()
102+
if err != nil {
103+
return nil, err
104+
}
101105
return &CreateDatabase{
102106
CreatePos: pos,
103107
StatementEnd: StatementEnd,
104108
Name: name,
105109
IfNotExists: ifNotExists,
106110
OnCluster: onCluster,
107111
Engine: engineExpr,
112+
Comment: commentExpr,
108113
}, nil
109114
}
110115

0 commit comments

Comments
 (0)