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

Method Compare

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

Compare implements the Datum interface.

(ctx *EvalContext, other Datum)

Source from the content-addressed store, hash-verified

3355
3356// Compare implements the Datum interface.
3357func (d *DArray) Compare(ctx *EvalContext, other Datum) int {
3358 if other == DNull {
3359 // NULL is less than any non-NULL value.
3360 return 1
3361 }
3362 v, ok := UnwrapDatum(ctx, other).(*DArray)
3363 if !ok {
3364 panic(makeUnsupportedComparisonMessage(d, other))
3365 }
3366 n := d.Len()
3367 if n > v.Len() {
3368 n = v.Len()
3369 }
3370 for i := 0; i < n; i++ {
3371 c := d.Array[i].Compare(ctx, v.Array[i])
3372 if c != 0 {
3373 return c
3374 }
3375 }
3376 if d.Len() < v.Len() {
3377 return -1
3378 }
3379 if d.Len() > v.Len() {
3380 return 1
3381 }
3382 return 0
3383}
3384
3385// Prev implements the Datum interface.
3386func (d *DArray) Prev(_ *EvalContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 5

LenMethod · 0.95
UnwrapDatumFunction · 0.85
LenMethod · 0.65
CompareMethod · 0.65

Tested by

no test coverage detected