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

Method Compare

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

Compare implements the Datum interface.

(ctx *EvalContext, other Datum)

Source from the content-addressed store, hash-verified

946
947// Compare implements the Datum interface.
948func (d *DDecimal) Compare(ctx *EvalContext, other Datum) int {
949 if other == DNull {
950 // NULL is less than any non-NULL value.
951 return 1
952 }
953 v := ctx.getTmpDec()
954 switch t := UnwrapDatum(ctx, other).(type) {
955 case *DDecimal:
956 v = &t.Decimal
957 case *DInt:
958 v.SetFinite(int64(*t), 0)
959 case *DFloat:
960 if _, err := v.SetFloat64(float64(*t)); err != nil {
961 panic(errors.NewAssertionErrorWithWrappedErrf(err, "decimal compare, unexpected error"))
962 }
963 default:
964 panic(makeUnsupportedComparisonMessage(d, other))
965 }
966 return CompareDecimals(&d.Decimal, v)
967}
968
969// CompareDecimals compares 2 apd.Decimals according to the SQL comparison
970// rules, making sure that NaNs sort first.

Callers

nothing calls this directly

Calls 4

UnwrapDatumFunction · 0.85
CompareDecimalsFunction · 0.85
getTmpDecMethod · 0.80

Tested by

no test coverage detected