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

Method Format

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

Format implements the Datum interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

3606
3607// Format implements the Datum interface.
3608func (d *DOid) Format(ctx *FmtCtx) {
3609 if d.semanticType.Oid() == oid.T_oid || d.name == "" {
3610 // If we call FormatNode directly when the disambiguateDatumTypes flag
3611 // is set, then we get something like 123:::INT:::OID. This is the
3612 // important flag set by FmtParsable which is supposed to be
3613 // roundtrippable. Since in this branch, a DOid is a thin wrapper around
3614 // a DInt, I _think_ it's correct to just delegate to the DInt's Format.
3615 d.DInt.Format(ctx)
3616 } else if ctx.HasFlags(fmtDisambiguateDatumTypes) {
3617 ctx.WriteString("crdb_internal.create_")
3618 ctx.WriteString(d.semanticType.SQLStandardName())
3619 ctx.WriteByte('(')
3620 d.DInt.Format(ctx)
3621 ctx.WriteByte(',')
3622 lex.EncodeSQLStringWithFlags(&ctx.Buffer, d.name, lex.EncNoFlags)
3623 ctx.WriteByte(')')
3624 } else {
3625 // This is used to print the name of pseudo-procedures in e.g.
3626 // pg_catalog.pg_type.typinput
3627 lex.EncodeSQLStringWithFlags(&ctx.Buffer, d.name, lex.EncBareStrings)
3628 }
3629}
3630
3631// IsMax implements the Datum interface.
3632func (d *DOid) IsMax(ctx *EvalContext) bool { return d.DInt.IsMax(ctx) }

Callers

nothing calls this directly

Calls 5

EncodeSQLStringWithFlagsFunction · 0.92
OidMethod · 0.80
SQLStandardNameMethod · 0.80
FormatMethod · 0.65
HasFlagsMethod · 0.45

Tested by

no test coverage detected