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

Method Next

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

Next implements the Datum interface.

(ctx context.Context, cmpCtx CompareContext)

Source from the content-addressed store, hash-verified

4646
4647// Next implements the Datum interface.
4648func (d *DTuple) Next(ctx context.Context, cmpCtx CompareContext) (Datum, bool) {
4649 // Note: (a:decimal, b:int, c:int) has a next value; that's (a, b,
4650 // c+1). With an exception if c is MaxInt64, in which case the next
4651 // value is (a, b+1, min(_ *EvalContext)). However, (a:int, b:decimal) does not
4652 // have a next value, because decimal doesn't have one.
4653 //
4654 // In general, a tuple has a next value if and only if it ends with
4655 // zero or more values that are a maximum and a minimum value of the
4656 // same type exists, and the first element before that has a next
4657 // value.
4658 res := NewDTupleWithLen(d.typ, len(d.D))
4659 copy(res.D, d.D)
4660 for i := len(res.D) - 1; i >= 0; i-- {
4661 if !res.D[i].IsMax(ctx, cmpCtx) {
4662 nextVal, ok := res.D[i].Next(ctx, cmpCtx)
4663 if !ok {
4664 return nil, false
4665 }
4666 res.D[i] = nextVal
4667 break
4668 }
4669 // TODO(#12022): temporary workaround; see the interface comment.
4670 res.D[i] = DNull
4671 }
4672 return res, true
4673}
4674
4675// Max implements the Datum interface.
4676func (d *DTuple) Max(ctx context.Context, cmpCtx CompareContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 3

NewDTupleWithLenFunction · 0.85
IsMaxMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected