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

Method Format

pkg/sql/sem/tree/datum.go:3432–3454  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

3430
3431// Format implements the NodeFormatter interface.
3432func (d *DArray) Format(ctx *FmtCtx) {
3433 if ctx.HasFlags(fmtPgwireFormat) {
3434 d.pgwireFormat(ctx)
3435 return
3436 }
3437
3438 // If we want to export arrays, we need to ensure that
3439 // the datums within the arrays are formatted with enclosing quotes etc.
3440 if ctx.HasFlags(FmtExport) {
3441 oldFlags := ctx.flags
3442 ctx.flags = oldFlags & ^FmtExport | FmtParsable
3443 defer func() { ctx.flags = oldFlags }()
3444 }
3445
3446 ctx.WriteString("ARRAY[")
3447 comma := ""
3448 for _, v := range d.Array {
3449 ctx.WriteString(comma)
3450 ctx.FormatNode(v)
3451 comma = ","
3452 }
3453 ctx.WriteByte(']')
3454}
3455
3456const maxArrayLength = math.MaxInt32
3457

Callers

nothing calls this directly

Calls 3

pgwireFormatMethod · 0.95
FormatNodeMethod · 0.80
HasFlagsMethod · 0.45

Tested by

no test coverage detected