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

Method Format

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

Format implements the Datum interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

5749
5750// Format implements the Datum interface.
5751func (d *DOid) Format(ctx *FmtCtx) {
5752 if ctx.HasFlags(FmtPgwireText) && d.semanticType.Oid() != oid.T_oid && d.Oid == UnknownOidValue {
5753 // Special case for the "unknown" oid.
5754 ctx.WriteString(UnknownOidName)
5755 } else if d.semanticType.Oid() == oid.T_oid || d.name == "" {
5756 ctx.Write(strconv.AppendUint(ctx.scratch[:0], uint64(d.Oid), 10))
5757 } else if ctx.HasFlags(fmtDisambiguateDatumTypes) {
5758 ctx.WriteString("crdb_internal.create_")
5759 ctx.WriteString(d.semanticType.SQLStandardName())
5760 ctx.WriteByte('(')
5761 ctx.Write(strconv.AppendUint(ctx.scratch[:0], uint64(d.Oid), 10))
5762 ctx.WriteByte(',')
5763 lexbase.EncodeSQLStringWithFlags(&ctx.Buffer, d.name, lexbase.EncNoFlags)
5764 ctx.WriteByte(')')
5765 } else {
5766 // This is used to print the name of pseudo-procedures in e.g.
5767 // pg_catalog.pg_type.typinput
5768 lexbase.EncodeSQLStringWithFlags(&ctx.Buffer, d.name, lexbase.EncBareStrings)
5769 }
5770}
5771
5772// IsMax implements the Datum interface.
5773func (d *DOid) IsMax(ctx context.Context, cmpCtx CompareContext) bool {

Callers

nothing calls this directly

Calls 5

EncodeSQLStringWithFlagsFunction · 0.92
OidMethod · 0.80
WriteMethod · 0.80
SQLStandardNameMethod · 0.80
HasFlagsMethod · 0.45

Tested by

no test coverage detected