Format formats the node.
(buf *nodeBuffer)
| 603 | |
| 604 | // Format formats the node. |
| 605 | func (node *DDL) Format(buf *nodeBuffer) { |
| 606 | switch node.Action { |
| 607 | case CreateTable: |
| 608 | if node.PartitionOf != nil { |
| 609 | buf.Printf("create table %v partition of %v", node.NewName, node.PartitionOf.ParentTable) |
| 610 | node.PartitionOf.BoundSpec.Format(buf) |
| 611 | } else if node.TableSpec == nil { |
| 612 | buf.Printf("create table %v", node.NewName) |
| 613 | } else { |
| 614 | buf.Printf("create table %v %v", node.NewName, node.TableSpec) |
| 615 | } |
| 616 | case CreateView: |
| 617 | if node.View.SecurityType != "" { |
| 618 | buf.Printf("alter %v view %v as %v", node.View.SecurityType, node.View.Name, node.View.Definition) |
| 619 | } else { |
| 620 | buf.Printf("alter %v as %v", node.View.Name, node.View.Definition) |
| 621 | } |
| 622 | default: |
| 623 | panic(fmt.Sprintf("unexpected action: %v", node.Action)) |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | // Format formats the PartitionBoundSpec node. |
| 628 | func (node *PartitionBoundSpec) Format(buf *nodeBuffer) { |