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

Function setDecimalString

pkg/sql/sem/tree/datum.go:1037–1057  ·  view source on GitHub ↗
(s string, d *apd.Decimal)

Source from the content-addressed store, hash-verified

1035}
1036
1037func setDecimalString(s string, d *apd.Decimal) error {
1038 // ExactCtx should be able to handle any decimal, but if there is any rounding
1039 // or other inexact conversion, it will result in an error.
1040 // _, res, err := HighPrecisionCtx.SetString(&d.Decimal, s)
1041 _, res, err := ExactCtx.SetString(d, s)
1042 if res != 0 || err != nil {
1043 return MakeParseError(s, types.Decimal, err)
1044 }
1045 switch d.Form {
1046 case apd.NaNSignaling:
1047 d.Form = apd.NaN
1048 d.Negative = false
1049 case apd.NaN:
1050 d.Negative = false
1051 case apd.Finite:
1052 if d.IsZero() && d.Negative {
1053 d.Negative = false
1054 }
1055 }
1056 return nil
1057}
1058
1059// ResolvedType implements the TypedExpr interface.
1060func (*DDecimal) ResolvedType() *types.T {

Callers 2

SetStringMethod · 0.85

Calls 2

MakeParseErrorFunction · 0.85
SetStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…