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

Method Compare

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

Compare implements the Datum interface.

(
	ctx context.Context, cmpCtx CompareContext, other Datum,
)

Source from the content-addressed store, hash-verified

1409
1410// Compare implements the Datum interface.
1411func (d *DCollatedString) Compare(
1412 ctx context.Context, cmpCtx CompareContext, other Datum,
1413) (int, error) {
1414 if other == DNull {
1415 // NULL is less than any non-NULL value.
1416 return 1, nil
1417 }
1418 v, ok := cmpCtx.UnwrapDatum(ctx, other).(*DCollatedString)
1419 if !ok || !lex.LocaleNamesAreEqual(d.Locale, v.Locale) {
1420 return 0, makeUnsupportedComparisonMessage(d, other)
1421 }
1422 res := bytes.Compare(d.Key, v.Key)
1423 return res, nil
1424}
1425
1426// Prev implements the Datum interface.
1427func (d *DCollatedString) Prev(ctx context.Context, cmpCtx CompareContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 4

LocaleNamesAreEqualFunction · 0.92
UnwrapDatumMethod · 0.80
CompareMethod · 0.65

Tested by

no test coverage detected