MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Format

Method Format

postgres/parser/sem/tree/create_function.go:38–75  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

36
37// Format implements the NodeFormatter interface.
38func (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
77type SimpleColumnDef struct {
78 Name Name

Callers

nothing calls this directly

Calls 3

WriteStringMethod · 0.80
FormatNodeMethod · 0.80
SQLStringMethod · 0.65

Tested by

no test coverage detected