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

Method SetString

postgres/parser/sem/tree/datum.go:489–509  ·  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

487// SetString sets d to s. Any non-standard NaN values are converted to a
488// normal NaN. Any negative zero is converted to positive.
489func (d *DDecimal) SetString(s string) error {
490 // ExactCtx should be able to handle any decimal, but if there is any rounding
491 // or other inexact conversion, it will result in an error.
492 //_, res, err := HighPrecisionCtx.SetString(&d.Decimal, s)
493 _, res, err := ExactCtx.SetString(&d.Decimal, s)
494 if res != 0 || err != nil {
495 return makeParseError(s, types.Decimal, nil)
496 }
497 switch d.Form {
498 case apd.NaNSignaling:
499 d.Form = apd.NaN
500 d.Negative = false
501 case apd.NaN:
502 d.Negative = false
503 case apd.Finite:
504 if d.IsZero() && d.Negative {
505 d.Negative = false
506 }
507 }
508 return nil
509}
510
511// ResolvedType implements the TypedExpr interface.
512func (*DDecimal) ResolvedType() *types.T {

Callers 4

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

Calls 1

makeParseErrorFunction · 0.85

Tested by

no test coverage detected