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

Method Format

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

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

1578
1579// Format implements the NodeFormatter interface.
1580func (d *DBytes) Format(ctx *FmtCtx) {
1581 f := ctx.flags
1582 if f.HasFlags(fmtPgwireFormat) {
1583 ctx.WriteString(`\x`)
1584 writeAsHexString(ctx, string(*d))
1585 } else if f.HasFlags(fmtFormatByteLiterals) {
1586 ctx.WriteByte('x')
1587 ctx.WriteByte('\'')
1588 _, _ = hex.NewEncoder(ctx).Write([]byte(*d))
1589 ctx.WriteByte('\'')
1590 } else {
1591 withQuotes := !f.HasFlags(FmtBareStrings)
1592 if withQuotes {
1593 ctx.WriteByte('\'')
1594 }
1595 ctx.WriteString("\\x")
1596 writeAsHexString(ctx, string(*d))
1597 if withQuotes {
1598 ctx.WriteByte('\'')
1599 }
1600 }
1601}
1602
1603// Size implements the Datum interface.
1604func (d *DBytes) Size() uintptr {

Callers

nothing calls this directly

Calls 4

writeAsHexStringFunction · 0.85
WriteMethod · 0.80
HasFlagsMethod · 0.45
NewEncoderMethod · 0.45

Tested by

no test coverage detected