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

Function CompareDecimals

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

CompareDecimals compares 2 apd.Decimals according to the SQL comparison rules, making sure that NaNs sort first.

(d *apd.Decimal, v *apd.Decimal)

Source from the content-addressed store, hash-verified

969// CompareDecimals compares 2 apd.Decimals according to the SQL comparison
970// rules, making sure that NaNs sort first.
971func CompareDecimals(d *apd.Decimal, v *apd.Decimal) int {
972 // NaNs sort first in SQL.
973 if dn, vn := d.Form == apd.NaN, v.Form == apd.NaN; dn && !vn {
974 return -1
975 } else if !dn && vn {
976 return 1
977 } else if dn && vn {
978 return 0
979 }
980 return d.Cmp(v)
981}
982
983// Prev implements the Datum interface.
984func (d *DDecimal) Prev(_ *EvalContext) (Datum, bool) {

Callers 1

CompareMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…