Compare implements the Datum interface.
(ctx context.Context, cmpCtx CompareContext, other Datum)
| 5717 | |
| 5718 | // Compare implements the Datum interface. |
| 5719 | func (d *DOid) Compare(ctx context.Context, cmpCtx CompareContext, other Datum) (int, error) { |
| 5720 | if other == DNull { |
| 5721 | // NULL is less than any non-NULL value. |
| 5722 | return 1, nil |
| 5723 | } |
| 5724 | var v oid.Oid |
| 5725 | switch t := cmpCtx.UnwrapDatum(ctx, other).(type) { |
| 5726 | case *DOid: |
| 5727 | v = t.Oid |
| 5728 | case *DInt: |
| 5729 | // OIDs are always unsigned 32-bit integers. Some languages, like Java, |
| 5730 | // compare OIDs to signed 32-bit integers, so we implement the comparison |
| 5731 | // by converting to a uint32 first. This matches Postgres behavior. |
| 5732 | var err error |
| 5733 | v, err = IntToOid(*t) |
| 5734 | if err != nil { |
| 5735 | return 0, err |
| 5736 | } |
| 5737 | default: |
| 5738 | return 0, makeUnsupportedComparisonMessage(d, other) |
| 5739 | } |
| 5740 | |
| 5741 | if d.Oid < v { |
| 5742 | return -1, nil |
| 5743 | } |
| 5744 | if d.Oid > v { |
| 5745 | return 1, nil |
| 5746 | } |
| 5747 | return 0, nil |
| 5748 | } |
| 5749 | |
| 5750 | // Format implements the Datum interface. |
| 5751 | func (d *DOid) Format(ctx *FmtCtx) { |
nothing calls this directly
no test coverage detected