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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ y.go
.idea/
.vscode/
coverage.txt
parser/genkeyword
20 changes: 20 additions & 0 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,12 @@ type InsertStmt struct {
Priority mysql.PriorityEnum
OnDuplicate []*Assignment
Select ResultSetNode
// RowAlias is the alias for the inserted row, set by `INSERT ... AS row_alias`.
// MySQL 8.0.19+ syntax for use inside ON DUPLICATE KEY UPDATE.
RowAlias *CIStr
// ColumnAliases are the optional column aliases that follow RowAlias,
// set by `INSERT ... AS row_alias (col_alias_list)`.
ColumnAliases []*CIStr
// TableHints represents the table level Optimizer Hint for join type.
TableHints []*TableOptimizerHint
PartitionNames []CIStr
Expand Down Expand Up @@ -2516,6 +2522,20 @@ func (n *InsertStmt) Restore(ctx *format.RestoreCtx) error {
return fmt.Errorf("Incorrect type for InsertStmt.Select: %T", v)
}
}
if n.RowAlias != nil {
ctx.WriteKeyWord(" AS ")
ctx.WriteName(n.RowAlias.O)
if len(n.ColumnAliases) != 0 {
ctx.WritePlain("(")
for i, c := range n.ColumnAliases {
if i != 0 {
ctx.WritePlain(",")
}
ctx.WriteName(c.O)
}
ctx.WritePlain(")")
}
}
if n.OnDuplicate != nil {
ctx.WriteKeyWord(" ON DUPLICATE KEY UPDATE ")
for i, v := range n.OnDuplicate {
Expand Down
Loading
Loading