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
14 changes: 14 additions & 0 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,9 @@ type InsertStmt struct {
Priority mysql.PriorityEnum
OnDuplicate []*Assignment
Select ResultSetNode
// TableHints represents the table level Optimizer Hint for join type.
TableHints []*TableOptimizerHint
PartitionNames []model.CIStr
}

// Restore implements Node interface.
Expand All @@ -1392,6 +1395,17 @@ func (n *InsertStmt) Restore(ctx *format.RestoreCtx) error {
if err := n.Table.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore InsertStmt.Table")
}
if len(n.PartitionNames) != 0 {
ctx.WriteKeyWord(" PARTITION")
ctx.WritePlain("(")
for i := 0; i < len(n.PartitionNames); i++ {
if i != 0 {
ctx.WritePlain(", ")
}
ctx.WriteName(n.PartitionNames[i].String())
}
ctx.WritePlain(")")
}
if n.Columns != nil {
ctx.WritePlain(" (")
for i, v := range n.Columns {
Expand Down
10 changes: 7 additions & 3 deletions ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,11 @@ func (n *UseStmt) Accept(v Visitor) (Node, bool) {
}

const (
// SetNames is the const for set names/charset stmt.
// If VariableAssignment.Name == Names, it should be set names/charset stmt.
// SetNames is the const for set names stmt.
// If VariableAssignment.Name == Names, it should be set names stmt.
SetNames = "SetNAMES"
// SetCharset is the const for set charset stmt.
SetCharset = "SetCharset"
)

// VariableAssignment is a variable assignment struct.
Expand Down Expand Up @@ -591,11 +593,13 @@ func (n *VariableAssignment) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord("SESSION")
}
ctx.WritePlain(".")
} else if n.Name != SetNames {
} else if n.Name != SetNames && n.Name != SetCharset {
ctx.WriteKeyWord("@")
}
if n.Name == SetNames {
ctx.WriteKeyWord("NAMES ")
} else if n.Name == SetCharset {
ctx.WriteKeyWord("CHARSET ")
} else {
ctx.WriteName(n.Name)
ctx.WritePlain("=")
Expand Down
Loading