MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / Format

Method Format

pkg/sql/sem/tree/create.go:47–69  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

45
46// Format implements the NodeFormatter interface.
47func (node *CreateDatabase) Format(ctx *FmtCtx) {
48 ctx.WriteString("CREATE DATABASE ")
49 if node.IfNotExists {
50 ctx.WriteString("IF NOT EXISTS ")
51 }
52 ctx.FormatNode(&node.Name)
53 if node.Template != "" {
54 ctx.WriteString(" TEMPLATE = ")
55 lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.Template, ctx.flags.EncodeFlags())
56 }
57 if node.Encoding != "" {
58 ctx.WriteString(" ENCODING = ")
59 lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.Encoding, ctx.flags.EncodeFlags())
60 }
61 if node.Collate != "" {
62 ctx.WriteString(" LC_COLLATE = ")
63 lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.Collate, ctx.flags.EncodeFlags())
64 }
65 if node.CType != "" {
66 ctx.WriteString(" LC_CTYPE = ")
67 lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.CType, ctx.flags.EncodeFlags())
68 }
69}
70
71// IndexElem represents a column with a direction in a CREATE INDEX statement.
72type IndexElem struct {

Callers

nothing calls this directly

Calls 3

EncodeSQLStringWithFlagsFunction · 0.92
FormatNodeMethod · 0.80
EncodeFlagsMethod · 0.80

Tested by

no test coverage detected