DatumNext returns a datum that is "next" to the given one. For many types it just delegates to Datum.Next, but for some types that don't have an implementation of that function this method makes the best effort to come up with a reasonable next datum that is greater than the given one. The return v
( ctx context.Context, datum Datum, cmpCtx CompareContext, collationEnv *CollationEnvironment, )
| 6642 | // The return value is undefined if Datum.IsMax returns true or if the value is |
| 6643 | // NaN or an infinity (for floats and decimals). |
| 6644 | func DatumNext( |
| 6645 | ctx context.Context, datum Datum, cmpCtx CompareContext, collationEnv *CollationEnvironment, |
| 6646 | ) (Datum, bool) { |
| 6647 | datum = UnwrapDOidWrapper(datum) |
| 6648 | switch d := datum.(type) { |
| 6649 | case *DDecimal: |
| 6650 | var next DDecimal |
| 6651 | var add apd.Decimal |
| 6652 | _, err := add.SetFloat64(1e-6) |
| 6653 | if err != nil { |
| 6654 | return nil, false |
| 6655 | } |
| 6656 | _, err = ExactCtx.Add(&next.Decimal, &d.Decimal, &add) |
| 6657 | if err != nil { |
| 6658 | return nil, false |
| 6659 | } |
| 6660 | return &next, true |
| 6661 | case *DInterval: |
| 6662 | next := d.Add(duration.MakeDuration(1000000 /* nanos */, 0 /* days */, 0 /* months */)) |
| 6663 | return NewDInterval(next, types.DefaultIntervalTypeMetadata), true |
| 6664 | default: |
| 6665 | // TODO(yuzefovich): consider adding support for other datums that don't |
| 6666 | // have Datum.Next implementation (DCollatedString, DGeography, |
| 6667 | // DGeometry, DBox2D, DJSON). |
| 6668 | return datum.Next(ctx, cmpCtx) |
| 6669 | } |
| 6670 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…