| 17 | } |
| 18 | |
| 19 | func (n *CreateFunctionStmt) Format(buf *TrackedBuffer, d format.Dialect) { |
| 20 | if n == nil { |
| 21 | return |
| 22 | } |
| 23 | buf.WriteString("CREATE ") |
| 24 | if n.Replace { |
| 25 | buf.WriteString("OR REPLACE ") |
| 26 | } |
| 27 | buf.WriteString("FUNCTION ") |
| 28 | buf.astFormat(n.Func, d) |
| 29 | buf.WriteString("(") |
| 30 | if items(n.Params) { |
| 31 | buf.join(n.Params, d, ", ") |
| 32 | } |
| 33 | buf.WriteString(")") |
| 34 | if n.ReturnType != nil { |
| 35 | buf.WriteString(" RETURNS ") |
| 36 | buf.astFormat(n.ReturnType, d) |
| 37 | } |
| 38 | // Format options (AS, LANGUAGE, etc.) |
| 39 | if items(n.Options) { |
| 40 | for _, opt := range n.Options.Items { |
| 41 | buf.WriteString(" ") |
| 42 | buf.astFormat(opt, d) |
| 43 | } |
| 44 | } |
| 45 | } |