Compare implements the Datum interface.
(ctx *EvalContext, other Datum)
| 2939 | |
| 2940 | // Compare implements the Datum interface. |
| 2941 | func (d *DTuple) Compare(ctx *EvalContext, other Datum) int { |
| 2942 | if other == DNull { |
| 2943 | // NULL is less than any non-NULL value. |
| 2944 | return 1 |
| 2945 | } |
| 2946 | v, ok := UnwrapDatum(ctx, other).(*DTuple) |
| 2947 | if !ok { |
| 2948 | panic(makeUnsupportedComparisonMessage(d, other)) |
| 2949 | } |
| 2950 | n := len(d.D) |
| 2951 | if n > len(v.D) { |
| 2952 | n = len(v.D) |
| 2953 | } |
| 2954 | for i := 0; i < n; i++ { |
| 2955 | c := d.D[i].Compare(ctx, v.D[i]) |
| 2956 | if c != 0 { |
| 2957 | return c |
| 2958 | } |
| 2959 | } |
| 2960 | if len(d.D) < len(v.D) { |
| 2961 | return -1 |
| 2962 | } |
| 2963 | if len(d.D) > len(v.D) { |
| 2964 | return 1 |
| 2965 | } |
| 2966 | return 0 |
| 2967 | } |
| 2968 | |
| 2969 | // Prev implements the Datum interface. |
| 2970 | func (d *DTuple) Prev(ctx *EvalContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected