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

Method Compare

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

Compare implements the Datum interface.

(ctx *EvalContext, other Datum)

Source from the content-addressed store, hash-verified

2939
2940// Compare implements the Datum interface.
2941func (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.
2970func (d *DTuple) Prev(ctx *EvalContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 3

UnwrapDatumFunction · 0.85
CompareMethod · 0.65

Tested by

no test coverage detected