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

Method Format

pkg/sql/sem/tree/copy.go:90–157  ·  view source on GitHub ↗

Format implements the NodeFormatter interface

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

88
89// Format implements the NodeFormatter interface
90func (o *CopyOptions) Format(ctx *FmtCtx) {
91 var addSep bool
92 maybeAddSep := func() {
93 if addSep {
94 ctx.WriteString(", ")
95 }
96 addSep = true
97 }
98 ctx.WriteString("(")
99 if o.HasFormat {
100 maybeAddSep()
101 switch o.CopyFormat {
102 case CopyFormatBinary:
103 ctx.WriteString("FORMAT BINARY")
104 case CopyFormatCSV:
105 ctx.WriteString("FORMAT CSV")
106 case CopyFormatText:
107 ctx.WriteString("FORMAT TEXT")
108 }
109 }
110 if o.Delimiter != nil {
111 maybeAddSep()
112 ctx.WriteString("DELIMITER ")
113 ctx.FormatNode(o.Delimiter)
114 addSep = true
115 }
116 if o.Encoding != nil {
117 maybeAddSep()
118 ctx.WriteString("ENCODING ")
119 ctx.FormatNode(o.Encoding)
120 addSep = true
121 }
122 if o.Null != nil {
123 maybeAddSep()
124 ctx.WriteString("NULL ")
125 ctx.FormatNode(o.Null)
126 addSep = true
127 }
128 if o.Destination != nil {
129 maybeAddSep()
130 // Lowercase because that's what has historically been produced
131 // by copy_file_upload.go, so this will provide backward
132 // compatibility with older servers.
133 ctx.WriteString("DESTINATION ")
134 ctx.FormatURI(o.Destination)
135 addSep = true
136 }
137 if o.Escape != nil {
138 maybeAddSep()
139 ctx.WriteString("ESCAPE ")
140 ctx.FormatNode(o.Escape)
141 }
142 if o.HasHeader {
143 maybeAddSep()
144 ctx.WriteString("HEADER ")
145 if o.Header {
146 ctx.WriteString("true")
147 } else {

Callers

nothing calls this directly

Calls 2

FormatNodeMethod · 0.80
FormatURIMethod · 0.80

Tested by

no test coverage detected