Compare implements the Datum interface.
(ctx context.Context, cmpCtx CompareContext, other Datum)
| 5466 | |
| 5467 | // Compare implements the Datum interface. |
| 5468 | func (d *DEnum) Compare(ctx context.Context, cmpCtx CompareContext, other Datum) (int, error) { |
| 5469 | if other == DNull { |
| 5470 | return 1, nil |
| 5471 | } |
| 5472 | v, ok := cmpCtx.UnwrapDatum(ctx, other).(*DEnum) |
| 5473 | if !ok { |
| 5474 | return 0, makeUnsupportedComparisonMessage(d, other) |
| 5475 | } |
| 5476 | |
| 5477 | // Different enums count as different types. |
| 5478 | if v.EnumTyp.Oid() != d.EnumTyp.Oid() { |
| 5479 | return 0, makeUnsupportedComparisonMessage(d, other) |
| 5480 | } |
| 5481 | |
| 5482 | // We should never be comparing two different versions of the same enum. |
| 5483 | if v.EnumTyp.TypeMeta.Version != d.EnumTyp.TypeMeta.Version { |
| 5484 | var gist redact.SafeString |
| 5485 | if PlanGistFromCtx != nil { |
| 5486 | // Plan gist, by construction, doesn't contain any PII, so it's a |
| 5487 | // safe string. |
| 5488 | gist = redact.SafeString(PlanGistFromCtx(ctx)) |
| 5489 | } |
| 5490 | return 0, errors.AssertionFailedf( |
| 5491 | "comparison of two different versions of enum %s oid %d: versions %d and %d, gist %q", |
| 5492 | d.EnumTyp.SQLStringForError(), errors.Safe(d.EnumTyp.Oid()), d.EnumTyp.TypeMeta.Version, |
| 5493 | v.EnumTyp.TypeMeta.Version, gist, |
| 5494 | ) |
| 5495 | } |
| 5496 | |
| 5497 | res := bytes.Compare(d.PhysicalRep, v.PhysicalRep) |
| 5498 | return res, nil |
| 5499 | } |
| 5500 | |
| 5501 | // Prev implements the Datum interface. |
| 5502 | func (d *DEnum) Prev(ctx context.Context, cmpCtx CompareContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected