Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 36 | |
| 37 | // Format implements the NodeFormatter interface. |
| 38 | func (node *CreateFunction) Format(ctx *FmtCtx) { |
| 39 | ctx.WriteString("CREATE ") |
| 40 | if node.Replace { |
| 41 | ctx.WriteString("OR REPLACE ") |
| 42 | } |
| 43 | ctx.WriteString("FUNCTION ") |
| 44 | ctx.FormatNode(node.Name) |
| 45 | if len(node.Args) != 0 { |
| 46 | ctx.WriteString(" (") |
| 47 | ctx.FormatNode(node.Args) |
| 48 | ctx.WriteString(" )") |
| 49 | } |
| 50 | if node.RetType != nil { |
| 51 | if !node.ReturnsTable { |
| 52 | ctx.WriteString("RETURNS ") |
| 53 | if node.ReturnsSetOf { |
| 54 | ctx.WriteString("SETOF ") |
| 55 | } |
| 56 | ctx.WriteString(node.RetType[0].Type.SQLString()) |
| 57 | } else { |
| 58 | ctx.WriteString("RETURNS TABLE ") |
| 59 | for i, t := range node.RetType { |
| 60 | if i != 0 { |
| 61 | ctx.WriteString(", ") |
| 62 | } |
| 63 | ctx.FormatNode(&t.Name) |
| 64 | ctx.WriteByte(' ') |
| 65 | ctx.WriteString(t.Type.SQLString()) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | for i, option := range node.Options { |
| 70 | if i != 0 { |
| 71 | ctx.WriteByte(' ') |
| 72 | } |
| 73 | ctx.FormatNode(option) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | type SimpleColumnDef struct { |
| 78 | Name Name |
nothing calls this directly
no test coverage detected