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

Method Format

postgres/parser/sem/tree/alter_database.go:63–89  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

61
62// Format implements the NodeFormatter interface.
63func (node *AlterDatabase) Format(ctx *FmtCtx) {
64 ctx.WriteString("ALTER DATABASE ")
65 ctx.FormatNode(&node.Name)
66 if len(node.Options) > 0 {
67 opts := make([]string, len(node.Options))
68 for i, opt := range node.Options {
69 opts[i] = fmt.Sprintf("%s %s", opt.Opt, AsString(opt.Val))
70 }
71 ctx.WriteString(fmt.Sprintf(" WITH %s", strings.Join(opts, " ")))
72 } else if node.Owner != "" {
73 ctx.WriteString(" OWNER TO ")
74 ctx.FormatNameP(&node.Owner)
75 } else if node.Tablespace != "" {
76 ctx.WriteString(" SET TABLESPACE ")
77 ctx.FormatNameP(&node.Tablespace)
78 } else if node.RefreshCollationVersion {
79 ctx.WriteString(" REFRESH COLLATION VERSION")
80 } else if node.SetVar != nil {
81 ctx.WriteByte(' ')
82 node.SetVar.Format(ctx)
83 } else if node.ResetVar != "" {
84 ctx.WriteString(" RESET ")
85 ctx.FormatNameP(&node.ResetVar)
86 } else if node.ResetAll {
87 ctx.WriteString(" RESET ALL")
88 }
89}

Callers

nothing calls this directly

Calls 5

AsStringFunction · 0.85
WriteStringMethod · 0.80
FormatNodeMethod · 0.80
FormatNamePMethod · 0.80
FormatMethod · 0.65

Tested by

no test coverage detected