Compare implements the Datum interface.
(ctx *EvalContext, other Datum)
| 946 | |
| 947 | // Compare implements the Datum interface. |
| 948 | func (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. |
nothing calls this directly
no test coverage detected