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

Function MakeDecimal

pkg/sql/types/types.go:666–687  ·  view source on GitHub ↗

MakeDecimal constructs a new instance of a DECIMAL type (oid = T_numeric) that has at most "precision" # of decimal digits (0 = unspecified number of digits) and at most "scale" # of decimal digits after the decimal point (0 = unspecified number of digits). scale must be <= precision.

(precision, scale int32)

Source from the content-addressed store, hash-verified

664// digits) and at most "scale" # of decimal digits after the decimal point
665// (0 = unspecified number of digits). scale must be <= precision.
666func MakeDecimal(precision, scale int32) *T {
667 if precision == 0 && scale == 0 {
668 return Decimal
669 }
670 if precision < 0 {
671 panic(errors.AssertionFailedf("precision %d cannot be negative", precision))
672 }
673 if scale < 0 {
674 panic(errors.AssertionFailedf("scale %d cannot be negative", scale))
675 }
676 if scale > precision {
677 panic(errors.AssertionFailedf(
678 "scale %d cannot be larger than precision %d", scale, precision))
679 }
680 return &T{InternalType: InternalType{
681 Family: DecimalFamily,
682 Oid: oid.T_numeric,
683 Precision: precision,
684 Width: scale,
685 Locale: &emptyLocale,
686 }}
687}
688
689// MakeTime constructs a new instance of a TIME type (oid = T_time) that has at
690// most the given number of fractional second digits.

Callers 1

newDecimalFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…