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

Method SetString

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

SetString sets d to s. Any non-standard NaN values are converted to a normal NaN. Any negative zero is converted to positive.

(s string)

Source from the content-addressed store, hash-verified

918// SetString sets d to s. Any non-standard NaN values are converted to a
919// normal NaN. Any negative zero is converted to positive.
920func (d *DDecimal) SetString(s string) error {
921 // ExactCtx should be able to handle any decimal, but if there is any rounding
922 // or other inexact conversion, it will result in an error.
923 //_, res, err := HighPrecisionCtx.SetString(&d.Decimal, s)
924 _, res, err := ExactCtx.SetString(&d.Decimal, s)
925 if res != 0 || err != nil {
926 return makeParseError(s, types.Decimal, nil)
927 }
928 switch d.Form {
929 case apd.NaNSignaling:
930 d.Form = apd.NaN
931 d.Negative = false
932 case apd.NaN:
933 d.Negative = false
934 case apd.Finite:
935 if d.IsZero() && d.Negative {
936 d.Negative = false
937 }
938 }
939 return nil
940}
941
942// ResolvedType implements the TypedExpr interface.
943func (*DDecimal) ResolvedType() *types.T {

Callers 5

ParseDDecimalFunction · 0.95
PerformCastFunction · 0.95
ResolveAsTypeMethod · 0.80
makeDecimalFromMandEFunction · 0.80
FromNumberFunction · 0.80

Calls 1

makeParseErrorFunction · 0.85

Tested by

no test coverage detected