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

Function MakeDecimal

pkg/sql/types/types.go:1014–1035  ·  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

1012// digits) and at most "scale" # of decimal digits after the decimal point
1013// (0 = unspecified number of digits). scale must be <= precision.
1014func MakeDecimal(precision, scale int32) *T {
1015 if precision == 0 && scale == 0 {
1016 return Decimal
1017 }
1018 if precision < 0 {
1019 panic(errors.AssertionFailedf("precision %d cannot be negative", precision))
1020 }
1021 if scale < 0 {
1022 panic(errors.AssertionFailedf("scale %d cannot be negative", scale))
1023 }
1024 if scale > precision {
1025 panic(errors.AssertionFailedf(
1026 "scale %d cannot be larger than precision %d", scale, precision))
1027 }
1028 return &T{InternalType: InternalType{
1029 Family: DecimalFamily,
1030 Oid: oid.T_numeric,
1031 Precision: precision,
1032 Width: scale,
1033 Locale: &emptyLocale,
1034 }}
1035}
1036
1037// MakeTime constructs a new instance of a TIME type (oid = T_time) that has at
1038// 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…