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

Function ResolveBlankPaddedChar

pkg/sql/sem/tree/pgwire_encode.go:30–45  ·  view source on GitHub ↗

ResolveBlankPaddedChar pads the given string with spaces if blank padding is required or returns the string unmodified otherwise.

(s string, t *types.T)

Source from the content-addressed store, hash-verified

28// ResolveBlankPaddedChar pads the given string with spaces if blank padding is
29// required or returns the string unmodified otherwise.
30func ResolveBlankPaddedChar(s string, t *types.T) string {
31 if t.Oid() == oid.T_bpchar && len(s) < int(t.Width()) {
32 // Pad spaces on the right of the string to make it of length specified
33 // in the type t.
34 res := make([]byte, t.Width())
35 copy(res, s)
36 pad := res[len(s):]
37 for len(pad) > len(spaces) {
38 copy(pad, spaces)
39 pad = pad[len(spaces):]
40 }
41 copy(pad, spaces)
42 return encoding.UnsafeConvertBytesToString(res)
43 }
44 return s
45}
46
47func (d *DTuple) pgwireFormat(ctx *FmtCtx) {
48 // When converting a tuple to text in "postgres mode" there is

Callers 1

pgwireFormatMethod · 0.85

Calls 3

OidMethod · 0.80
WidthMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…