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

Method Next

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

Next implements the Datum interface.

(ctx *EvalContext)

Source from the content-addressed store, hash-verified

2999
3000// Next implements the Datum interface.
3001func (d *DTuple) Next(ctx *EvalContext) (Datum, bool) {
3002 // Note: (a:decimal, b:int, c:int) has a next value; that's (a, b,
3003 // c+1). With an exception if c is MaxInt64, in which case the next
3004 // value is (a, b+1, min(_ *EvalContext)). However, (a:int, b:decimal) does not
3005 // have a next value, because decimal doesn't have one.
3006 //
3007 // In general, a tuple has a next value if and only if it ends with
3008 // zero or more values that are a maximum and a minimum value of the
3009 // same type exists, and the first element before that has a next
3010 // value.
3011 res := NewDTupleWithLen(d.typ, len(d.D))
3012 copy(res.D, d.D)
3013 for i := len(res.D) - 1; i >= 0; i-- {
3014 if !res.D[i].IsMax(ctx) {
3015 nextVal, ok := res.D[i].Next(ctx)
3016 if !ok {
3017 return nil, false
3018 }
3019 res.D[i] = nextVal
3020 break
3021 }
3022 // TODO(#12022): temporary workaround; see the interface comment.
3023 res.D[i] = DNull
3024 }
3025 return res, true
3026}
3027
3028// Max implements the Datum interface.
3029func (d *DTuple) Max(ctx *EvalContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 3

NewDTupleWithLenFunction · 0.85
IsMaxMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected