MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Format

Method Format

postgres/parser/sem/tree/datum.go:520–540  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

518
519// Format implements the NodeFormatter interface.
520func (d *DDecimal) Format(ctx *FmtCtx) {
521 // If the number is negative, we need to use parens or the `:::INT` type hint
522 // will take precedence over the negation sign.
523 disambiguate := ctx.flags.HasFlags(fmtDisambiguateDatumTypes)
524 parsable := ctx.flags.HasFlags(FmtParsableNumerics)
525 quote := parsable && d.Decimal.Form != apd.Finite
526 needParens := !quote && (disambiguate || parsable) && d.Negative
527 if needParens {
528 ctx.WriteByte('(')
529 }
530 if quote {
531 ctx.WriteByte('\'')
532 }
533 ctx.WriteString(d.Decimal.String())
534 if quote {
535 ctx.WriteByte('\'')
536 }
537 if needParens {
538 ctx.WriteByte(')')
539 }
540}
541
542// SizeOfDecimal returns the size in bytes of an apd.Decimal.
543func SizeOfDecimal(d apd.Decimal) uintptr {

Callers

nothing calls this directly

Calls 3

WriteStringMethod · 0.80
StringMethod · 0.65
HasFlagsMethod · 0.45

Tested by

no test coverage detected