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

Method Compare

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

Compare implements the Datum interface.

(ctx *EvalContext, other Datum)

Source from the content-addressed store, hash-verified

766
767// Compare implements the Datum interface.
768func (d *DFloat) Compare(ctx *EvalContext, other Datum) int {
769 if other == DNull {
770 // NULL is less than any non-NULL value.
771 return 1
772 }
773 var v DFloat
774 switch t := UnwrapDatum(ctx, other).(type) {
775 case *DFloat:
776 v = *t
777 case *DInt:
778 v = DFloat(MustBeDInt(t))
779 case *DDecimal:
780 return -t.Compare(ctx, d)
781 default:
782 panic(makeUnsupportedComparisonMessage(d, other))
783 }
784 if *d < v {
785 return -1
786 }
787 if *d > v {
788 return 1
789 }
790 // NaN sorts before non-NaN (#10109).
791 if *d == v {
792 return 0
793 }
794 if math.IsNaN(float64(*d)) {
795 if math.IsNaN(float64(v)) {
796 return 0
797 }
798 return -1
799 }
800 return 1
801}
802
803// Prev implements the Datum interface.
804func (d *DFloat) Prev(_ *EvalContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 5

UnwrapDatumFunction · 0.85
DFloatTypeAlias · 0.85
MustBeDIntFunction · 0.85
CompareMethod · 0.65

Tested by

no test coverage detected