cockroach: github.com/cockroachdb/cockroach/pkg/sql/sem/tree Index | Files

package tree

import "github.com/cockroachdb/cockroach/pkg/sql/sem/tree"

Index

Package Files

aggregate_funcs.go alter_index.go alter_sequence.go alter_table.go annotation.go as_of.go backup.go changefeed.go col_name.go comment_on_column.go comment_on_database.go comment_on_table.go constant.go constant_eval.go copy.go create.go datum.go decimal.go delete.go discard.go drop.go eval.go explain.go export.go expr.go format.go function_definition.go function_name.go generators.go grant.go hide_constants.go import.go indexed_vars.go insert.go interval.go name_part.go name_resolution.go normalize.go operators.go overload.go parse_array.go parse_string.go pgwire_encode.go placeholders.go prepare.go pretty.go regexp_cache.go rename.go returning.go revoke.go run_control.go scrub.go select.go set.go show.go split.go statementtype_string.go stmt.go table_name.go table_pattern.go table_ref.go testutils.go truncate.go txn.go type_check.go union.go update.go values.go var_name.go walk.go window_funcs.go window_funcs_util.go with.go zone.go

Constants

const (
    SeqOptAs        = "AS"
    SeqOptCycle     = "CYCLE"
    SeqOptNoCycle   = "NO CYCLE"
    SeqOptOwnedBy   = "OWNED BY"
    SeqOptCache     = "CACHE"
    SeqOptIncrement = "INCREMENT"
    SeqOptMinValue  = "MINVALUE"
    SeqOptMaxValue  = "MAXVALUE"
    SeqOptStart     = "START"
    SeqOptVirtual   = "VIRTUAL"
)

Names of options on CREATE SEQUENCE.

const (
    ExplainFlagVerbose = iota
    ExplainFlagSymVars
    ExplainFlagTypes
    ExplainFlagNoExpand
    ExplainFlagNoNormalize
    ExplainFlagNoOptimize
    ExplainFlagAnalyze
    ExplainFlagEnv
    ExplainFlagCatalog
)

Explain flags.

const (
    DistinctFuncType funcType
    AllFuncType
)

FuncExpr.Type

const (
    CastExplicit castSyntaxMode = iota
    CastShort
    CastPrepend
)

These constants separate the syntax X::Y from CAST(X AS Y).

const (
    AnnotateExplicit annotateSyntaxMode = iota
    AnnotateShort
)

These constants separate the syntax X:::Y from ANNOTATE_TYPE(X, Y)

const (
    // PublicSchema is the name of the physical schema in every
    // database/catalog.
    PublicSchema string = "public"
    // PublicSchemaName is the same, typed as Name.
    PublicSchemaName Name = Name(PublicSchema)
)
const (
    // PrettyNoAlign disables alignment.
    PrettyNoAlign PrettyAlignMode = 0
    // PrettyAlignOnly aligns sub-clauses only and preserves the
    // hierarchy of logical operators.
    PrettyAlignOnly = 1
    // PrettyAlignAndDeindent does the work of PrettyAlignOnly and also
    // de-indents AND and OR operators.
    PrettyAlignAndDeindent = 2
    // PrettyAlignAndExtraIndent does the work of PrettyAlignOnly and
    // also extra indents the operands of AND and OR operators so
    // that they appear aligned but also indented.
    PrettyAlignAndExtraIndent = 3
)
const (
    // ScrubTable describes the SCRUB operation SCRUB TABLE.
    ScrubTable = iota
    // ScrubDatabase describes the SCRUB operation SCRUB DATABASE.
    ScrubDatabase = iota
)
const (
    AstFull  = "FULL"
    AstLeft  = "LEFT"
    AstRight = "RIGHT"
    AstCross = "CROSS"
    AstInner = "INNER"
)

JoinTableExpr.Join

const (
    AstHash   = "HASH"
    AstLookup = "LOOKUP"
    AstMerge  = "MERGE"
)

JoinTableExpr.Hint

const (
    AstWhere  = "WHERE"
    AstHaving = "HAVING"
)

Where.Type

const FollowerReadTimestampFunctionName = "experimental_follower_read_timestamp"

FollowerReadTimestampFunctionName is the name of the function which can be used with AOST clauses to generate a timestamp likely to be safe for follower reads.

const MaxPlaceholderIdx = math.MaxUint16

MaxPlaceholderIdx is the maximum allowed value of a PlaceholderIdx. The pgwire protocol is limited to 2^16 placeholders, so we limit the IDs to this range as well.

const (
    // TimestampOutputFormat is used to output all timestamps.
    TimestampOutputFormat = "2006-01-02 15:04:05.999999-07:00"
)

time.Time formats.

Variables

var (

    // NumValAvailInteger is the set of available integer types.
    NumValAvailInteger = append(intLikeTypes, decimalLikeTypes...)
    // NumValAvailDecimalNoFraction is the set of available integral numeric types.
    NumValAvailDecimalNoFraction = append(decimalLikeTypes, intLikeTypes...)
    // NumValAvailDecimalWithFraction is the set of available fractional numeric types.
    NumValAvailDecimalWithFraction = decimalLikeTypes
)
var (
    // StrValAvailAllParsable is the set of parsable string types.
    StrValAvailAllParsable = []*types.T{
        types.String,
        types.Bytes,
        types.Bool,
        types.Int,
        types.Float,
        types.Decimal,
        types.Date,
        types.Time,
        types.Timestamp,
        types.TimestampTZ,
        types.Interval,
        types.Uuid,
        types.INet,
        types.Jsonb,
        types.VarBit,
    }
    // StrValAvailBytes is the set of types convertible to byte array.
    StrValAvailBytes = []*types.T{types.Bytes, types.Uuid, types.String}
)
var (

    // DBoolTrue is a pointer to the DBool(true) value and can be used in
    // comparisons against Datum types.
    DBoolTrue = &constDBoolTrue
    // DBoolFalse is a pointer to the DBool(false) value and can be used in
    // comparisons against Datum types.
    DBoolFalse = &constDBoolFalse

    // DNull is the NULL Datum.
    DNull Datum = dNull{}

    // DZero is the zero-valued integer Datum.
    DZero = NewDInt(0)

    // DTimeRegex is a compiled regex for parsing the 24:00 time value
    DTimeRegex = regexp.MustCompile("^24:00($|(:00$)|(:00.0+$))")
)
var (
    // DecimalCtx is the default context for decimal operations. Any change
    // in the exponent limits must still guarantee a safe conversion to the
    // postgres binary decimal format in the wire protocol, which uses an
    // int16. See pgwire/types.go.
    DecimalCtx = &apd.Context{
        Precision:   20,
        Rounding:    apd.RoundHalfUp,
        MaxExponent: 2000,
        MinExponent: -2000,

        Traps: apd.DefaultTraps &^ apd.InvalidOperation,
    }
    // ExactCtx is a decimal context with exact precision.
    ExactCtx = DecimalCtx.WithPrecision(0)
    // HighPrecisionCtx is a decimal context with high precision.
    HighPrecisionCtx = DecimalCtx.WithPrecision(2000)
    // IntermediateCtx is a decimal context with additional precision for
    // intermediate calculations to protect against order changes that can
    // happen in dist SQL. The additional 5 allows the stress test to pass.
    // See #13689 for more analysis and other algorithms.
    IntermediateCtx = DecimalCtx.WithPrecision(DecimalCtx.Precision + 5)
    // RoundCtx is a decimal context with high precision and RoundHalfEven
    // rounding.
    RoundCtx = func() *apd.Context {
        ctx := *HighPrecisionCtx
        ctx.Rounding = apd.RoundHalfEven
        return &ctx
    }()
)
var (

    // ErrDivByZero is reported on a division by zero.
    ErrDivByZero = pgerror.New(pgcode.DivisionByZero, "division by zero")
    // ErrZeroModulus is reported when computing the rest of a division by zero.
    ErrZeroModulus = pgerror.New(pgcode.DivisionByZero, "zero modulus")
)
var AbsentReturningClause = &NoReturningClause{}

AbsentReturningClause is a ReturningClause variant representing the absence of a RETURNING clause.

var BinOps = map[BinaryOperator]binOpOverload{
    Bitand: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) & MustBeDInt(right)), nil
            },
        },
        &BinOp{
            LeftType:   types.VarBit,
            RightType:  types.VarBit,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                lhs := MustBeDBitArray(left)
                rhs := MustBeDBitArray(right)
                if lhs.BitLen() != rhs.BitLen() {
                    return nil, newCannotMixBitArraySizesError("AND")
                }
                return &DBitArray{
                    BitArray: bitarray.And(lhs.BitArray, rhs.BitArray),
                }, nil
            },
        },
        &BinOp{
            LeftType:   types.INet,
            RightType:  types.INet,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                other := MustBeDIPAddr(right).IPAddr
                newIPAddr, err := ipAddr.And(&other)
                return NewDIPAddr(DIPAddr{newIPAddr}), err
            },
        },
    },

    Bitor: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) | MustBeDInt(right)), nil
            },
        },
        &BinOp{
            LeftType:   types.VarBit,
            RightType:  types.VarBit,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                lhs := MustBeDBitArray(left)
                rhs := MustBeDBitArray(right)
                if lhs.BitLen() != rhs.BitLen() {
                    return nil, newCannotMixBitArraySizesError("OR")
                }
                return &DBitArray{
                    BitArray: bitarray.Or(lhs.BitArray, rhs.BitArray),
                }, nil
            },
        },
        &BinOp{
            LeftType:   types.INet,
            RightType:  types.INet,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                other := MustBeDIPAddr(right).IPAddr
                newIPAddr, err := ipAddr.Or(&other)
                return NewDIPAddr(DIPAddr{newIPAddr}), err
            },
        },
    },

    Bitxor: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) ^ MustBeDInt(right)), nil
            },
        },
        &BinOp{
            LeftType:   types.VarBit,
            RightType:  types.VarBit,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                lhs := MustBeDBitArray(left)
                rhs := MustBeDBitArray(right)
                if lhs.BitLen() != rhs.BitLen() {
                    return nil, newCannotMixBitArraySizesError("XOR")
                }
                return &DBitArray{
                    BitArray: bitarray.Xor(lhs.BitArray, rhs.BitArray),
                }, nil
            },
        },
    },

    Plus: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                a, b := MustBeDInt(left), MustBeDInt(right)
                r, ok := arith.AddWithOverflow(int64(a), int64(b))
                if !ok {
                    return nil, errIntOutOfRange
                }
                return NewDInt(DInt(r)), nil
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(*left.(*DFloat) + *right.(*DFloat)), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := ExactCtx.Add(&dd.Decimal, l, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                _, err := ExactCtx.Add(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                _, err := ExactCtx.Add(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Int,
            ReturnType: types.Date,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                d, err := left.(*DDate).AddDays(int64(MustBeDInt(right)))
                if err != nil {
                    return nil, err
                }
                return NewDDate(d), nil
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Date,
            ReturnType: types.Date,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                d, err := right.(*DDate).AddDays(int64(MustBeDInt(left)))
                if err != nil {
                    return nil, err
                }
                return NewDDate(d), nil

            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Time,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                d, err := MakeDTimestampTZFromDate(time.UTC, left.(*DDate))
                if err != nil {
                    return nil, err
                }
                t := time.Duration(*right.(*DTime)) * time.Microsecond
                return MakeDTimestamp(d.Add(t), time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Time,
            RightType:  types.Date,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                d, err := MakeDTimestampTZFromDate(time.UTC, right.(*DDate))
                if err != nil {
                    return nil, err
                }
                t := time.Duration(*left.(*DTime)) * time.Microsecond
                return MakeDTimestamp(d.Add(t), time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Time,
            RightType:  types.Interval,
            ReturnType: types.Time,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := timeofday.TimeOfDay(*left.(*DTime))
                return MakeDTime(t.Add(right.(*DInterval).Duration)), nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Time,
            ReturnType: types.Time,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := timeofday.TimeOfDay(*right.(*DTime))
                return MakeDTime(t.Add(left.(*DInterval).Duration)), nil
            },
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.Interval,
            ReturnType: types.Timestamp,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(ctx,
                    left.(*DTimestamp).Time, right.(*DInterval).Duration), time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Timestamp,
            ReturnType: types.Timestamp,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(ctx,
                    right.(*DTimestamp).Time, left.(*DInterval).Duration), time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.TimestampTZ,
            RightType:  types.Interval,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(ctx, left.(*DTimestampTZ).Time, right.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.TimestampTZ,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(ctx, right.(*DTimestampTZ).Time, left.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Interval,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: left.(*DInterval).Duration.Add(right.(*DInterval).Duration)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Interval,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTZ, err := MakeDTimestampTZFromDate(ctx.GetLocation(), left.(*DDate))
                if err != nil {
                    return nil, err
                }
                t := duration.Add(ctx, leftTZ.Time, right.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Date,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                rightTZ, err := MakeDTimestampTZFromDate(ctx.GetLocation(), right.(*DDate))
                if err != nil {
                    return nil, err
                }
                t := duration.Add(ctx, rightTZ.Time, left.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.INet,
            RightType:  types.Int,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                i := MustBeDInt(right)
                newIPAddr, err := ipAddr.Add(int64(i))
                return NewDIPAddr(DIPAddr{newIPAddr}), err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.INet,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                i := MustBeDInt(left)
                ipAddr := MustBeDIPAddr(right).IPAddr
                newIPAddr, err := ipAddr.Add(int64(i))
                return NewDIPAddr(DIPAddr{newIPAddr}), err
            },
        },
    },

    Minus: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                a, b := MustBeDInt(left), MustBeDInt(right)
                r, ok := arith.SubWithOverflow(int64(a), int64(b))
                if !ok {
                    return nil, errIntOutOfRange
                }
                return NewDInt(DInt(r)), nil
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(*left.(*DFloat) - *right.(*DFloat)), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := ExactCtx.Sub(&dd.Decimal, l, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                _, err := ExactCtx.Sub(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                _, err := ExactCtx.Sub(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Int,
            ReturnType: types.Date,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                d, err := left.(*DDate).SubDays(int64(MustBeDInt(right)))
                if err != nil {
                    return nil, err
                }
                return NewDDate(d), nil
            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Date,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l, r := left.(*DDate).Date, right.(*DDate).Date
                if !l.IsFinite() || !r.IsFinite() {
                    return nil, pgerror.New(pgcode.DatetimeFieldOverflow, "cannot subtract infinite dates")
                }
                a := l.PGEpochDays()
                b := r.PGEpochDays()

                return NewDInt(DInt(int64(a) - int64(b))), nil
            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Time,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                d, err := MakeDTimestampTZFromDate(time.UTC, left.(*DDate))
                if err != nil {
                    return nil, err
                }
                t := time.Duration(*right.(*DTime)) * time.Microsecond
                return MakeDTimestamp(d.Add(-1*t), time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Time,
            RightType:  types.Time,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t1 := timeofday.TimeOfDay(*left.(*DTime))
                t2 := timeofday.TimeOfDay(*right.(*DTime))
                diff := timeofday.Difference(t1, t2)
                return &DInterval{Duration: diff}, nil
            },
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.Timestamp,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                nanos := left.(*DTimestamp).Sub(right.(*DTimestamp).Time).Nanoseconds()
                return &DInterval{Duration: duration.MakeDuration(nanos, 0, 0)}, nil
            },
        },
        &BinOp{
            LeftType:   types.TimestampTZ,
            RightType:  types.TimestampTZ,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                nanos := left.(*DTimestampTZ).Sub(right.(*DTimestampTZ).Time).Nanoseconds()
                return &DInterval{Duration: duration.MakeDuration(nanos, 0, 0)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.TimestampTZ,
            ReturnType: types.Interval,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {

                nanos := left.(*DTimestamp).Sub(right.(*DTimestampTZ).stripTimeZone(ctx).Time).Nanoseconds()
                return &DInterval{Duration: duration.MakeDuration(nanos, 0, 0)}, nil
            },
        },
        &BinOp{
            LeftType:   types.TimestampTZ,
            RightType:  types.Timestamp,
            ReturnType: types.Interval,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {

                nanos := left.(*DTimestampTZ).stripTimeZone(ctx).Sub(right.(*DTimestamp).Time).Nanoseconds()
                return &DInterval{Duration: duration.MakeDuration(nanos, 0, 0)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Time,
            RightType:  types.Interval,
            ReturnType: types.Time,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := timeofday.TimeOfDay(*left.(*DTime))
                return MakeDTime(t.Add(right.(*DInterval).Duration.Mul(-1))), nil
            },
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.Interval,
            ReturnType: types.Timestamp,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(ctx,
                    left.(*DTimestamp).Time, right.(*DInterval).Duration.Mul(-1)), time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.TimestampTZ,
            RightType:  types.Interval,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(ctx,
                    left.(*DTimestampTZ).Time, right.(*DInterval).Duration.Mul(-1))
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Interval,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTZ, err := MakeDTimestampTZFromDate(ctx.GetLocation(), left.(*DDate))
                if err != nil {
                    return nil, err
                }
                t := duration.Add(ctx,
                    leftTZ.Time, right.(*DInterval).Duration.Mul(-1))
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Interval,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: left.(*DInterval).Duration.Sub(right.(*DInterval).Duration)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.String,
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                j, _, err := left.(*DJSON).JSON.RemoveString(string(MustBeDString(right)))
                if err != nil {
                    return nil, err
                }
                return &DJSON{j}, nil
            },
        },
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.Int,
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                j, _, err := left.(*DJSON).JSON.RemoveIndex(int(MustBeDInt(right)))
                if err != nil {
                    return nil, err
                }
                return &DJSON{j}, nil
            },
        },
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.MakeArray(types.String),
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                j := left.(*DJSON).JSON
                arr := *MustBeDArray(right)

                for _, str := range arr.Array {
                    if str == DNull {
                        continue
                    }
                    var err error
                    j, _, err = j.RemoveString(string(MustBeDString(str)))
                    if err != nil {
                        return nil, err
                    }
                }
                return &DJSON{j}, nil
            },
        },
        &BinOp{
            LeftType:   types.INet,
            RightType:  types.INet,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                other := MustBeDIPAddr(right).IPAddr
                diff, err := ipAddr.SubIPAddr(&other)
                return NewDInt(DInt(diff)), err
            },
        },
        &BinOp{

            LeftType:   types.INet,
            RightType:  types.Int,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                i := MustBeDInt(right)
                newIPAddr, err := ipAddr.Sub(int64(i))
                return NewDIPAddr(DIPAddr{newIPAddr}), err
            },
        },
    },

    Mult: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {

                a, b := MustBeDInt(left), MustBeDInt(right)
                c := a * b
                if a == 0 || b == 0 || a == 1 || b == 1 {

                } else if a == math.MinInt64 || b == math.MinInt64 {

                    return nil, errIntOutOfRange
                } else if c/b != a {
                    return nil, errIntOutOfRange
                }
                return NewDInt(c), nil
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(*left.(*DFloat) * *right.(*DFloat)), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := ExactCtx.Mul(&dd.Decimal, l, r)
                return dd, err
            },
        },

        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                _, err := ExactCtx.Mul(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                _, err := ExactCtx.Mul(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Interval,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: right.(*DInterval).Duration.Mul(int64(MustBeDInt(left)))}, nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Int,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: left.(*DInterval).Duration.Mul(int64(MustBeDInt(right)))}, nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Float,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := float64(*right.(*DFloat))
                return &DInterval{Duration: left.(*DInterval).Duration.MulFloat(r)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Interval,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := float64(*left.(*DFloat))
                return &DInterval{Duration: right.(*DInterval).Duration.MulFloat(l)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Interval,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                t, err := l.Float64()
                if err != nil {
                    return nil, err
                }
                return &DInterval{Duration: right.(*DInterval).Duration.MulFloat(t)}, nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Decimal,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := &right.(*DDecimal).Decimal
                t, err := r.Float64()
                if err != nil {
                    return nil, err
                }
                return &DInterval{Duration: left.(*DInterval).Duration.MulFloat(t)}, nil
            },
        },
    },

    Div: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                div := ctx.getTmpDec().SetFinite(int64(rInt), 0)
                dd := &DDecimal{}
                dd.SetFinite(int64(MustBeDInt(left)), 0)
                cond, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, div)
                if cond.DivisionByZero() {
                    return dd, ErrDivByZero
                }
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := *right.(*DFloat)
                if r == 0.0 {
                    return nil, ErrDivByZero
                }
                return NewDFloat(*left.(*DFloat) / r), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                cond, err := DecimalCtx.Quo(&dd.Decimal, l, r)
                if cond.DivisionByZero() {
                    return dd, ErrDivByZero
                }
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                cond, err := DecimalCtx.Quo(&dd.Decimal, l, &dd.Decimal)
                if cond.DivisionByZero() {
                    return dd, ErrDivByZero
                }
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                cond, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, r)
                if cond.DivisionByZero() {
                    return dd, ErrDivByZero
                }
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Int,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                if rInt == 0 {
                    return nil, ErrDivByZero
                }
                return &DInterval{Duration: left.(*DInterval).Duration.Div(int64(rInt))}, nil
            },
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Float,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := float64(*right.(*DFloat))
                if r == 0.0 {
                    return nil, ErrDivByZero
                }
                return &DInterval{Duration: left.(*DInterval).Duration.DivFloat(r)}, nil
            },
        },
    },

    FloorDiv: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                if rInt == 0 {
                    return nil, ErrDivByZero
                }
                return NewDInt(MustBeDInt(left) / rInt), nil
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := float64(*left.(*DFloat))
                r := float64(*right.(*DFloat))
                return NewDFloat(DFloat(math.Trunc(l / r))), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, l, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                if r == 0 {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                if r.Sign() == 0 {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
    },

    Mod: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := MustBeDInt(right)
                if r == 0 {
                    return nil, ErrZeroModulus
                }
                return NewDInt(MustBeDInt(left) % r), nil
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(DFloat(math.Mod(float64(*left.(*DFloat)), float64(*right.(*DFloat))))), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, l, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
    },

    Concat: {
        &BinOp{
            LeftType:   types.String,
            RightType:  types.String,
            ReturnType: types.String,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDString(string(MustBeDString(left) + MustBeDString(right))), nil
            },
        },
        &BinOp{
            LeftType:   types.Bytes,
            RightType:  types.Bytes,
            ReturnType: types.Bytes,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDBytes(*left.(*DBytes) + *right.(*DBytes)), nil
            },
        },
        &BinOp{
            LeftType:   types.VarBit,
            RightType:  types.VarBit,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                lhs := MustBeDBitArray(left)
                rhs := MustBeDBitArray(right)
                return &DBitArray{
                    BitArray: bitarray.Concat(lhs.BitArray, rhs.BitArray),
                }, nil
            },
        },
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.Jsonb,
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                j, err := MustBeDJSON(left).JSON.Concat(MustBeDJSON(right).JSON)
                if err != nil {
                    return nil, err
                }
                return &DJSON{j}, nil
            },
        },
    },

    LShift: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rval := MustBeDInt(right)
                if rval < 0 || rval >= 64 {
                    telemetry.Inc(sqltelemetry.LargeLShiftArgumentCounter)
                    return nil, pgerror.Newf(pgcode.InvalidParameterValue, "shift argument out of range")
                }
                return NewDInt(MustBeDInt(left) << uint(rval)), nil
            },
        },
        &BinOp{
            LeftType:   types.VarBit,
            RightType:  types.Int,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                lhs := MustBeDBitArray(left)
                rhs := MustBeDInt(right)
                return &DBitArray{
                    BitArray: lhs.BitArray.LeftShiftAny(int64(rhs)),
                }, nil
            },
        },
        &BinOp{
            LeftType:   types.INet,
            RightType:  types.INet,
            ReturnType: types.Bool,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                other := MustBeDIPAddr(right).IPAddr
                return MakeDBool(DBool(ipAddr.ContainedBy(&other))), nil
            },
        },
    },

    RShift: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rval := MustBeDInt(right)
                if rval < 0 || rval >= 64 {
                    telemetry.Inc(sqltelemetry.LargeRShiftArgumentCounter)
                    return nil, pgerror.Newf(pgcode.InvalidParameterValue, "shift argument out of range")
                }
                return NewDInt(MustBeDInt(left) >> uint(rval)), nil
            },
        },
        &BinOp{
            LeftType:   types.VarBit,
            RightType:  types.Int,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                lhs := MustBeDBitArray(left)
                rhs := MustBeDInt(right)
                return &DBitArray{
                    BitArray: lhs.BitArray.LeftShiftAny(-int64(rhs)),
                }, nil
            },
        },
        &BinOp{
            LeftType:   types.INet,
            RightType:  types.INet,
            ReturnType: types.Bool,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(left).IPAddr
                other := MustBeDIPAddr(right).IPAddr
                return MakeDBool(DBool(ipAddr.Contains(&other))), nil
            },
        },
    },

    Pow: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return IntPow(MustBeDInt(left), MustBeDInt(right))
            },
        },
        &BinOp{
            LeftType:   types.Float,
            RightType:  types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                f := math.Pow(float64(*left.(*DFloat)), float64(*right.(*DFloat)))
                return NewDFloat(DFloat(f)), nil
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := DecimalCtx.Pow(&dd.Decimal, l, r)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Decimal,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetFinite(int64(r), 0)
                _, err := DecimalCtx.Pow(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetFinite(int64(l), 0)
                _, err := DecimalCtx.Pow(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
    },

    JSONFetchVal: {
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.String,
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                j, err := left.(*DJSON).JSON.FetchValKey(string(MustBeDString(right)))
                if err != nil {
                    return nil, err
                }
                if j == nil {
                    return DNull, nil
                }
                return &DJSON{j}, nil
            },
        },
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.Int,
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                j, err := left.(*DJSON).JSON.FetchValIdx(int(MustBeDInt(right)))
                if err != nil {
                    return nil, err
                }
                if j == nil {
                    return DNull, nil
                }
                return &DJSON{j}, nil
            },
        },
    },

    JSONFetchValPath: {
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.MakeArray(types.String),
            ReturnType: types.Jsonb,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return getJSONPath(*left.(*DJSON), *MustBeDArray(right))
            },
        },
    },

    JSONFetchText: {
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.String,
            ReturnType: types.String,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                res, err := left.(*DJSON).JSON.FetchValKey(string(MustBeDString(right)))
                if err != nil {
                    return nil, err
                }
                if res == nil {
                    return DNull, nil
                }
                text, err := res.AsText()
                if err != nil {
                    return nil, err
                }
                if text == nil {
                    return DNull, nil
                }
                return NewDString(*text), nil
            },
        },
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.Int,
            ReturnType: types.String,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                res, err := left.(*DJSON).JSON.FetchValIdx(int(MustBeDInt(right)))
                if err != nil {
                    return nil, err
                }
                if res == nil {
                    return DNull, nil
                }
                text, err := res.AsText()
                if err != nil {
                    return nil, err
                }
                if text == nil {
                    return DNull, nil
                }
                return NewDString(*text), nil
            },
        },
    },

    JSONFetchTextPath: {
        &BinOp{
            LeftType:   types.Jsonb,
            RightType:  types.MakeArray(types.String),
            ReturnType: types.String,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                res, err := getJSONPath(*left.(*DJSON), *MustBeDArray(right))
                if err != nil {
                    return nil, err
                }
                if res == DNull {
                    return DNull, nil
                }
                text, err := res.(*DJSON).JSON.AsText()
                if err != nil {
                    return nil, err
                }
                if text == nil {
                    return DNull, nil
                }
                return NewDString(*text), nil
            },
        },
    },
}

BinOps contains the binary operations indexed by operation type.

var CmpOps = cmpOpFixups(map[ComparisonOperator]cmpOpOverload{
    EQ: {

        makeEqFn(types.Bool, types.Bool),
        makeEqFn(types.Bytes, types.Bytes),
        makeEqFn(types.Date, types.Date),
        makeEqFn(types.Decimal, types.Decimal),
        makeEqFn(types.AnyCollatedString, types.AnyCollatedString),
        makeEqFn(types.Float, types.Float),
        makeEqFn(types.INet, types.INet),
        makeEqFn(types.Int, types.Int),
        makeEqFn(types.Interval, types.Interval),
        makeEqFn(types.Jsonb, types.Jsonb),
        makeEqFn(types.Oid, types.Oid),
        makeEqFn(types.String, types.String),
        makeEqFn(types.Time, types.Time),
        makeEqFn(types.Timestamp, types.Timestamp),
        makeEqFn(types.TimestampTZ, types.TimestampTZ),
        makeEqFn(types.Uuid, types.Uuid),
        makeEqFn(types.VarBit, types.VarBit),

        makeEqFn(types.Date, types.Timestamp),
        makeEqFn(types.Date, types.TimestampTZ),
        makeEqFn(types.Decimal, types.Float),
        makeEqFn(types.Decimal, types.Int),
        makeEqFn(types.Float, types.Decimal),
        makeEqFn(types.Float, types.Int),
        makeEqFn(types.Int, types.Decimal),
        makeEqFn(types.Int, types.Float),
        makeEqFn(types.Timestamp, types.Date),
        makeEqFn(types.Timestamp, types.TimestampTZ),
        makeEqFn(types.TimestampTZ, types.Date),
        makeEqFn(types.TimestampTZ, types.Timestamp),

        &CmpOp{
            LeftType:  types.AnyTuple,
            RightType: types.AnyTuple,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), EQ), nil
            },
        },
    },

    LT: {

        makeLtFn(types.Bool, types.Bool),
        makeLtFn(types.Bytes, types.Bytes),
        makeLtFn(types.Date, types.Date),
        makeLtFn(types.Decimal, types.Decimal),
        makeLtFn(types.AnyCollatedString, types.AnyCollatedString),
        makeLtFn(types.Float, types.Float),
        makeLtFn(types.INet, types.INet),
        makeLtFn(types.Int, types.Int),
        makeLtFn(types.Interval, types.Interval),
        makeLtFn(types.Oid, types.Oid),
        makeLtFn(types.String, types.String),
        makeLtFn(types.Time, types.Time),
        makeLtFn(types.Timestamp, types.Timestamp),
        makeLtFn(types.TimestampTZ, types.TimestampTZ),
        makeLtFn(types.Uuid, types.Uuid),
        makeLtFn(types.VarBit, types.VarBit),

        makeLtFn(types.Date, types.Timestamp),
        makeLtFn(types.Date, types.TimestampTZ),
        makeLtFn(types.Decimal, types.Float),
        makeLtFn(types.Decimal, types.Int),
        makeLtFn(types.Float, types.Decimal),
        makeLtFn(types.Float, types.Int),
        makeLtFn(types.Int, types.Decimal),
        makeLtFn(types.Int, types.Float),
        makeLtFn(types.Timestamp, types.Date),
        makeLtFn(types.Timestamp, types.TimestampTZ),
        makeLtFn(types.TimestampTZ, types.Date),
        makeLtFn(types.TimestampTZ, types.Timestamp),

        &CmpOp{
            LeftType:  types.AnyTuple,
            RightType: types.AnyTuple,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), LT), nil
            },
        },
    },

    LE: {

        makeLeFn(types.Bool, types.Bool),
        makeLeFn(types.Bytes, types.Bytes),
        makeLeFn(types.Date, types.Date),
        makeLeFn(types.Decimal, types.Decimal),
        makeLeFn(types.AnyCollatedString, types.AnyCollatedString),
        makeLeFn(types.Float, types.Float),
        makeLeFn(types.INet, types.INet),
        makeLeFn(types.Int, types.Int),
        makeLeFn(types.Interval, types.Interval),
        makeLeFn(types.Oid, types.Oid),
        makeLeFn(types.String, types.String),
        makeLeFn(types.Time, types.Time),
        makeLeFn(types.Timestamp, types.Timestamp),
        makeLeFn(types.TimestampTZ, types.TimestampTZ),
        makeLeFn(types.Uuid, types.Uuid),
        makeLeFn(types.VarBit, types.VarBit),

        makeLeFn(types.Date, types.Timestamp),
        makeLeFn(types.Date, types.TimestampTZ),
        makeLeFn(types.Decimal, types.Float),
        makeLeFn(types.Decimal, types.Int),
        makeLeFn(types.Float, types.Decimal),
        makeLeFn(types.Float, types.Int),
        makeLeFn(types.Int, types.Decimal),
        makeLeFn(types.Int, types.Float),
        makeLeFn(types.Timestamp, types.Date),
        makeLeFn(types.Timestamp, types.TimestampTZ),
        makeLeFn(types.TimestampTZ, types.Date),
        makeLeFn(types.TimestampTZ, types.Timestamp),

        &CmpOp{
            LeftType:  types.AnyTuple,
            RightType: types.AnyTuple,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), LE), nil
            },
        },
    },

    IsNotDistinctFrom: {
        &CmpOp{
            LeftType:     types.Unknown,
            RightType:    types.Unknown,
            Fn:           cmpOpScalarIsFn,
            NullableArgs: true,

            isPreferred: true,
        },

        makeIsFn(types.Bool, types.Bool),
        makeIsFn(types.Bytes, types.Bytes),
        makeIsFn(types.Date, types.Date),
        makeIsFn(types.Decimal, types.Decimal),
        makeIsFn(types.AnyCollatedString, types.AnyCollatedString),
        makeIsFn(types.Float, types.Float),
        makeIsFn(types.INet, types.INet),
        makeIsFn(types.Int, types.Int),
        makeIsFn(types.Interval, types.Interval),
        makeIsFn(types.Jsonb, types.Jsonb),
        makeIsFn(types.Oid, types.Oid),
        makeIsFn(types.String, types.String),
        makeIsFn(types.Time, types.Time),
        makeIsFn(types.Timestamp, types.Timestamp),
        makeIsFn(types.TimestampTZ, types.TimestampTZ),
        makeIsFn(types.Uuid, types.Uuid),
        makeIsFn(types.VarBit, types.VarBit),

        makeIsFn(types.Date, types.Timestamp),
        makeIsFn(types.Date, types.TimestampTZ),
        makeIsFn(types.Decimal, types.Float),
        makeIsFn(types.Decimal, types.Int),
        makeIsFn(types.Float, types.Decimal),
        makeIsFn(types.Float, types.Int),
        makeIsFn(types.Int, types.Decimal),
        makeIsFn(types.Int, types.Float),
        makeIsFn(types.Timestamp, types.Date),
        makeIsFn(types.Timestamp, types.TimestampTZ),
        makeIsFn(types.TimestampTZ, types.Date),
        makeIsFn(types.TimestampTZ, types.Timestamp),

        &CmpOp{
            LeftType:     types.AnyTuple,
            RightType:    types.AnyTuple,
            NullableArgs: true,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                if left == DNull || right == DNull {
                    return MakeDBool(left == DNull && right == DNull), nil
                }
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), IsNotDistinctFrom), nil
            },
        },
    },

    In: {
        makeEvalTupleIn(types.Bool),
        makeEvalTupleIn(types.Bytes),
        makeEvalTupleIn(types.Date),
        makeEvalTupleIn(types.Decimal),
        makeEvalTupleIn(types.AnyCollatedString),
        makeEvalTupleIn(types.AnyTuple),
        makeEvalTupleIn(types.Float),
        makeEvalTupleIn(types.INet),
        makeEvalTupleIn(types.Int),
        makeEvalTupleIn(types.Interval),
        makeEvalTupleIn(types.Jsonb),
        makeEvalTupleIn(types.Oid),
        makeEvalTupleIn(types.String),
        makeEvalTupleIn(types.Time),
        makeEvalTupleIn(types.Timestamp),
        makeEvalTupleIn(types.TimestampTZ),
        makeEvalTupleIn(types.Uuid),
        makeEvalTupleIn(types.VarBit),
    },

    Like: {
        &CmpOp{
            LeftType:  types.String,
            RightType: types.String,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return matchLike(ctx, left, right, false)
            },
        },
    },

    ILike: {
        &CmpOp{
            LeftType:  types.String,
            RightType: types.String,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return matchLike(ctx, left, right, true)
            },
        },
    },

    SimilarTo: {
        &CmpOp{
            LeftType:  types.String,
            RightType: types.String,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                key := similarToKey{s: string(MustBeDString(right)), escape: '\\'}
                return matchRegexpWithKey(ctx, left, key)
            },
        },
    },

    RegMatch: {
        &CmpOp{
            LeftType:  types.String,
            RightType: types.String,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                key := regexpKey{s: string(MustBeDString(right)), caseInsensitive: false}
                return matchRegexpWithKey(ctx, left, key)
            },
        },
    },

    RegIMatch: {
        &CmpOp{
            LeftType:  types.String,
            RightType: types.String,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                key := regexpKey{s: string(MustBeDString(right)), caseInsensitive: true}
                return matchRegexpWithKey(ctx, left, key)
            },
        },
    },

    JSONExists: {
        &CmpOp{
            LeftType:  types.Jsonb,
            RightType: types.String,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                e, err := left.(*DJSON).JSON.Exists(string(MustBeDString(right)))
                if err != nil {
                    return nil, err
                }
                if e {
                    return DBoolTrue, nil
                }
                return DBoolFalse, nil
            },
        },
    },

    JSONSomeExists: {
        &CmpOp{
            LeftType:  types.Jsonb,
            RightType: types.StringArray,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {

                for _, k := range MustBeDArray(right).Array {
                    if k == DNull {
                        continue
                    }
                    e, err := left.(*DJSON).JSON.Exists(string(MustBeDString(k)))
                    if err != nil {
                        return nil, err
                    }
                    if e {
                        return DBoolTrue, nil
                    }
                }
                return DBoolFalse, nil
            },
        },
    },

    JSONAllExists: {
        &CmpOp{
            LeftType:  types.Jsonb,
            RightType: types.StringArray,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {

                for _, k := range MustBeDArray(right).Array {
                    if k == DNull {
                        continue
                    }
                    e, err := left.(*DJSON).JSON.Exists(string(MustBeDString(k)))
                    if err != nil {
                        return nil, err
                    }
                    if !e {
                        return DBoolFalse, nil
                    }
                }
                return DBoolTrue, nil
            },
        },
    },

    Contains: {
        &CmpOp{
            LeftType:  types.Jsonb,
            RightType: types.Jsonb,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                c, err := json.Contains(left.(*DJSON).JSON, right.(*DJSON).JSON)
                if err != nil {
                    return nil, err
                }
                return MakeDBool(DBool(c)), nil
            },
        },
    },

    ContainedBy: {
        &CmpOp{
            LeftType:  types.Jsonb,
            RightType: types.Jsonb,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                c, err := json.Contains(right.(*DJSON).JSON, left.(*DJSON).JSON)
                if err != nil {
                    return nil, err
                }
                return MakeDBool(DBool(c)), nil
            },
        },
    },
})

CmpOps contains the comparison operations indexed by operation type.

var (

    // ErrAsOfSpecifiedWithReadWrite is returned when a statement attempts to set
    // a historical query to READ WRITE which conflicts with its implied READ ONLY
    // mode.
    ErrAsOfSpecifiedWithReadWrite = pgerror.New(pgcode.Syntax, "AS OF SYSTEM TIME specified with READ WRITE mode")
)
var FunDefs map[string]*FunctionDefinition

FunDefs holds pre-allocated FunctionDefinition instances for every builtin function. Initialized by builtins.init().

var IsolationLevelMap = map[string]IsolationLevel{
    "serializable": SerializableIsolation,
}

IsolationLevelMap is a map from string isolation level name to isolation level, in the lowercase format that set isolation_level supports.

var JobCommandToStatement = map[JobCommand]string{
    PauseJob:  "PAUSE",
    CancelJob: "CANCEL",
    ResumeJob: "RESUME",
}

JobCommandToStatement translates a job command integer to a statement prefix.

var ReturningNothingClause = &ReturningNothing{}

ReturningNothingClause is a shared instance to avoid unnecessary allocations.

var UnaryOps = unaryOpFixups(map[UnaryOperator]unaryOpOverload{
    UnaryMinus: {
        &UnaryOp{
            Typ:        types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                i := MustBeDInt(d)
                if i == math.MinInt64 {
                    return nil, errIntOutOfRange
                }
                return NewDInt(-i), nil
            },
        },
        &UnaryOp{
            Typ:        types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return NewDFloat(-*d.(*DFloat)), nil
            },
        },
        &UnaryOp{
            Typ:        types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                dec := &d.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.Decimal.Neg(dec)
                return dd, nil
            },
        },
        &UnaryOp{
            Typ:        types.Interval,
            ReturnType: types.Interval,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                i := d.(*DInterval).Duration
                i.SetNanos(-i.Nanos())
                i.Days = -i.Days
                i.Months = -i.Months
                return &DInterval{Duration: i}, nil
            },
        },
    },

    UnaryComplement: {
        &UnaryOp{
            Typ:        types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return NewDInt(^MustBeDInt(d)), nil
            },
        },
        &UnaryOp{
            Typ:        types.VarBit,
            ReturnType: types.VarBit,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                p := MustBeDBitArray(d)
                return &DBitArray{BitArray: bitarray.Not(p.BitArray)}, nil
            },
        },
        &UnaryOp{
            Typ:        types.INet,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(d).IPAddr
                return NewDIPAddr(DIPAddr{ipAddr.Complement()}), nil
            },
        },
    },
})

UnaryOps contains the unary operations indexed by operation type.

var UnknownReturnType *types.T

UnknownReturnType is returned from ReturnTypers when the arguments provided are not sufficient to determine a return type. This is necessary for cases like overload resolution, where the argument types are not resolved yet so the type-level function will be called without argument types. If a ReturnTyper returns unknownReturnType, then the candidate function set cannot be refined. This means that only ReturnTypers that never return unknownReturnType, like those created with FixedReturnType, can help reduce overload ambiguity.

func AsJSON Uses

func AsJSON(d Datum) (json.JSON, error)

AsJSON converts a datum into our standard json representation.

func AsString Uses

func AsString(n NodeFormatter) string

AsString pretty prints a node to a string.

func AsStringWithFQNames Uses

func AsStringWithFQNames(n NodeFormatter, ann *Annotations) string

AsStringWithFQNames pretty prints a node to a string with the FmtAlwaysQualifyTableNames flag (which requires annotations).

func AsStringWithFlags Uses

func AsStringWithFlags(n NodeFormatter, fl FmtFlags) string

AsStringWithFlags pretty prints a node to a string given specific flags; only flags that don't require Annotations can be used.

func CanModifySchema Uses

func CanModifySchema(stmt Statement) bool

CanModifySchema returns true if the statement can modify the database schema.

func CanWriteData Uses

func CanWriteData(stmt Statement) bool

CanWriteData returns true if the statement can modify data.

func CheckIsWindowOrAgg Uses

func CheckIsWindowOrAgg(def *FunctionDefinition) error

CheckIsWindowOrAgg returns an error if the function definition is not a window function or an aggregate.

func CompareBools Uses

func CompareBools(d, v bool) int

CompareBools compares the input bools according to the SQL comparison rules.

func CompareDecimals Uses

func CompareDecimals(d *apd.Decimal, v *apd.Decimal) int

CompareDecimals compares 2 apd.Decimals according to the SQL comparison rules, making sure that NaNs sort first.

func ComputeColNameInternal Uses

func ComputeColNameInternal(sp sessiondata.SearchPath, target Expr) (int, string, error)

ComputeColNameInternal is the workhorse for GetRenderColName. The return value indicates the strength of the confidence in the result: 0 - no information 1 - second-best name choice 2 - good name choice

The algorithm is borrowed from FigureColnameInternal in PostgreSQL 10, to be found in src/backend/parser/parse_target.c.

func ContainsVars Uses

func ContainsVars(expr Expr) bool

ContainsVars returns true if the expression contains any variables. (variables = sub-expressions, placeholders, indexed vars, etc.)

func ConvertLikeToRegexp Uses

func ConvertLikeToRegexp(
    ctx *EvalContext, pattern string, caseInsensitive bool, escape rune,
) (*regexp.Regexp, error)

ConvertLikeToRegexp compiles the specified LIKE pattern as an equivalent regular expression.

func DatumToHLC Uses

func DatumToHLC(evalCtx *EvalContext, stmtTimestamp time.Time, d Datum) (hlc.Timestamp, error)

DatumToHLC performs the conversion from a Datum to an HLC timestamp.

func DatumTypeSize Uses

func DatumTypeSize(t *types.T) (uintptr, bool)

DatumTypeSize returns a lower bound on the total size of a Datum of the given type in bytes, including memory that is pointed at (even if shared between Datum instances) but excluding allocation overhead.

The second argument indicates whether data of this type have different sizes.

It holds for every Datum d that d.Size() >= DatumSize(d.ResolvedType())

func DecimalToHLC Uses

func DecimalToHLC(d *apd.Decimal) (hlc.Timestamp, error)

DecimalToHLC performs the conversion from an inputted DECIMAL datum for an AS OF SYSTEM TIME query to an HLC timestamp.

func ErrNameString Uses

func ErrNameString(s string) string

ErrNameString escapes an identifier stored a string to a SQL identifier suitable for printing in error messages.

func ErrNameStringP Uses

func ErrNameStringP(s *string) string

ErrNameStringP escapes an identifier stored a string to a SQL identifier suitable for printing in error messages, avoiding a heap allocation.

func ErrString Uses

func ErrString(n NodeFormatter) string

ErrString pretty prints a node to a string. Identifiers are not quoted.

func EvalAsOfTimestamp Uses

func EvalAsOfTimestamp(
    asOf AsOfClause, semaCtx *SemaContext, evalCtx *EvalContext,
) (tsss hlc.Timestamp, err error)

EvalAsOfTimestamp evaluates the timestamp argument to an AS OF SYSTEM TIME query.

func ExplainModeName Uses

func ExplainModeName(mode ExplainMode) (string, error)

ExplainModeName returns the human-readable name of a given ExplainMode.

func ExprDebugString Uses

func ExprDebugString(expr Expr) string

ExprDebugString generates a multi-line debug string with one node per line in Go format.

func FindEqualComparisonFunction Uses

func FindEqualComparisonFunction(
    leftType, rightType *types.T,
) (func(*EvalContext, Datum, Datum) (Datum, error), bool)

FindEqualComparisonFunction looks up an overload of the "=" operator for a given pair of input operand types.

func GetParamsAndReturnType Uses

func GetParamsAndReturnType(impl overloadImpl) (TypeList, ReturnTyper)

GetParamsAndReturnType gets the parameters and return type of an overloadImpl.

func GetRenderColName Uses

func GetRenderColName(searchPath sessiondata.SearchPath, target SelectExpr) (string, error)

GetRenderColName computes a name for a result column. A name specified with AS takes priority, otherwise a name is derived from the expression.

This function is meant to be used on untransformed syntax trees.

The algorithm is borrowed from FigureColName() in PostgreSQL 10, to be found in src/backend/parser/parse_target.c. We reuse this algorithm to provide names more compatible with PostgreSQL.

func HasReturningClause Uses

func HasReturningClause(clause ReturningClause) bool

HasReturningClause determines if a ReturningClause is present, given a variant of the ReturningClause interface.

func IsConst Uses

func IsConst(evalCtx *EvalContext, expr Expr) bool

IsConst returns whether the expression is constant. A constant expression does not contain variables, as defined by ContainsVars, nor impure functions.

func IsStmtParallelized Uses

func IsStmtParallelized(stmt Statement) bool

IsStmtParallelized determines if a given statement's execution should be parallelized. This means that its results should be mocked out, and that it should be run asynchronously and in parallel with other statements that are independent.

func LimitDecimalWidth Uses

func LimitDecimalWidth(d *apd.Decimal, precision, scale int) error

LimitDecimalWidth limits d's precision (total number of digits) and scale (number of digits after the decimal point). Note that this any limiting will modify the decimal in-place.

func MockNameTypes Uses

func MockNameTypes(types map[string]*types.T) func()

MockNameTypes populates presetTypesForTesting for a test.

func NameString Uses

func NameString(s string) string

NameString escapes an identifier stored in a string to a SQL identifier.

func NameStringP Uses

func NameStringP(s *string) string

NameStringP escapes an identifier stored in a heap string to a SQL identifier, avoiding a heap allocation.

func NewAggInAggError Uses

func NewAggInAggError() error

NewAggInAggError creates an error for the case when an aggregate function is contained within another aggregate function.

func NewInvalidFunctionUsageError Uses

func NewInvalidFunctionUsageError(class FunctionClass, context string) error

NewInvalidFunctionUsageError creates a rejection for a special function.

func NewInvalidNestedSRFError Uses

func NewInvalidNestedSRFError(context string) error

NewInvalidNestedSRFError creates a rejection for a nested SRF.

func NewTypeIsNotCompositeError Uses

func NewTypeIsNotCompositeError(resolvedType *types.T) error

NewTypeIsNotCompositeError generates an error suitable to report when a ColumnAccessExpr or TupleStar is applied to a non-composite type.

func Pretty Uses

func Pretty(stmt NodeFormatter) string

Pretty pretty prints stmt with default options.

func ProcessPlaceholderAnnotations Uses

func ProcessPlaceholderAnnotations(stmt Statement, typeHints PlaceholderTypes) error

ProcessPlaceholderAnnotations performs an order-independent global traversal of the provided Statement, annotating all placeholders with a type in either of the following situations:

- the placeholder is the subject of an explicit type annotation in at least one
  of its occurrences. If it is subject to multiple explicit type annotations
  where the types are not all in agreement, or if the placeholder already has
  a type hint in the placeholder map which conflicts with the explicit type
  annotation type, an error will be thrown.

- the placeholder is the subject to a cast of the same type in all
  occurrences of the placeholder. If the placeholder is subject to casts of
  multiple types, or if it has occurrences without a cast, no error will be
  thrown but the type will not be inferred. If the placeholder already has a
  type hint, that type will be kept regardless of any casts.

See docs/RFCS/20160203_typing.md for more details on placeholder typing (in particular section "First pass: placeholder annotations").

The typeHints slice contains the client-provided hints and is populated with any newly assigned types. It is assumed to be pre-sized to the number of placeholders in the statement and is populated accordingly.

TODO(nvanbenschoten): Can this visitor and map be preallocated (like normalizeVisitor)?

func Serialize Uses

func Serialize(n NodeFormatter) string

Serialize pretty prints a node to a string using FmtParsable; it is appropriate when we store expressions into strings that are later parsed back into expressions.

func SimilarEscape Uses

func SimilarEscape(pattern string) string

SimilarEscape converts a SQL:2008 regexp pattern to POSIX style, so it can be used by our regexp engine.

func SizeOfDecimal Uses

func SizeOfDecimal(d apd.Decimal) uintptr

SizeOfDecimal returns the size in bytes of an apd.Decimal.

func StmtDebugString Uses

func StmtDebugString(stmt Statement) string

StmtDebugString generates multi-line debug strings in Go format for the expressions that are part of the given statement.

func WalkExprConst Uses

func WalkExprConst(v Visitor, expr Expr)

WalkExprConst is a variant of WalkExpr for visitors that do not modify the expression.

type AggregateFunc Uses

type AggregateFunc interface {
    // Add accumulates the passed datums into the AggregateFunc.
    // Most implementations require one and only one firstArg argument.
    // If an aggregate function requires more than one argument,
    // all additional arguments (after firstArg) are passed in as a
    // variadic collection, otherArgs.
    // This interface (as opposed to `args ...Datum`) avoids unnecessary
    // allocation of otherArgs in the majority of cases.
    Add(_ context.Context, firstArg Datum, otherArgs ...Datum) error

    // Result returns the current value of the accumulation. This value
    // will be a deep copy of any AggregateFunc internal state, so that
    // it will not be mutated by additional calls to Add.
    Result() (Datum, error)

    // Reset resets the aggregate function which allows for reusing the same
    // instance for computation without the need to create a new instance.
    // Any memory is kept, if possible.
    Reset(context.Context)

    // Close closes out the AggregateFunc and allows it to release any memory it
    // requested during aggregation, and must be called upon completion of the
    // aggregation.
    Close(context.Context)

    // Size returns the size of the AggregateFunc implementation in bytes. It does
    // not account for additional memory used during accumulation.
    Size() int64
}

AggregateFunc accumulates the result of a function of a Datum.

type AliasClause Uses

type AliasClause struct {
    Alias Name
    Cols  NameList
}

AliasClause represents an alias, optionally with a column list: "AS name" or "AS name(col1, col2)".

func (*AliasClause) Format Uses

func (a *AliasClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AliasedTableExpr Uses

type AliasedTableExpr struct {
    Expr       TableExpr
    IndexFlags *IndexFlags
    Ordinality bool
    Lateral    bool
    As         AliasClause
}

AliasedTableExpr represents a table expression coupled with an optional alias.

func (*AliasedTableExpr) Format Uses

func (node *AliasedTableExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AliasedTableExpr) String Uses

func (node *AliasedTableExpr) String() string

type AllColumnsSelector Uses

type AllColumnsSelector struct {
    // TableName corresponds to the table prefix, before the star.
    TableName *UnresolvedObjectName
}

AllColumnsSelector corresponds to a selection of all columns in a table when used in a SELECT clause. (e.g. `table.*`).

func (*AllColumnsSelector) Eval Uses

func (expr *AllColumnsSelector) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*AllColumnsSelector) Format Uses

func (a *AllColumnsSelector) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AllColumnsSelector) NormalizeVarName Uses

func (a *AllColumnsSelector) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (*AllColumnsSelector) Resolve Uses

func (a *AllColumnsSelector) Resolve(
    ctx context.Context, r ColumnItemResolver,
) (srcName *TableName, srcMeta ColumnSourceMeta, err error)

Resolve performs name resolution for a qualified star using a resolver.

func (*AllColumnsSelector) ResolvedType Uses

func (*AllColumnsSelector) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*AllColumnsSelector) String Uses

func (a *AllColumnsSelector) String() string

func (*AllColumnsSelector) TypeCheck Uses

func (expr *AllColumnsSelector) TypeCheck(_ *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*AllColumnsSelector) Variable Uses

func (a *AllColumnsSelector) Variable()

Variable implements the VariableExpr interface. Although, the AllColumnsSelector ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.

func (*AllColumnsSelector) Walk Uses

func (expr *AllColumnsSelector) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type AllTablesSelector Uses

type AllTablesSelector struct {
    TableNamePrefix
}

AllTablesSelector corresponds to a selection of all tables in a database, e.g. when used with GRANT.

func (*AllTablesSelector) Format Uses

func (at *AllTablesSelector) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AllTablesSelector) NormalizeTablePattern Uses

func (at *AllTablesSelector) NormalizeTablePattern() (TablePattern, error)

NormalizeTablePattern implements the TablePattern interface.

func (*AllTablesSelector) String Uses

func (at *AllTablesSelector) String() string

type AlterIndex Uses

type AlterIndex struct {
    IfExists bool
    Index    TableIndexName
    Cmds     AlterIndexCmds
}

AlterIndex represents an ALTER INDEX statement.

func (*AlterIndex) Format Uses

func (node *AlterIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterIndex) StatementTag Uses

func (*AlterIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterIndex) StatementType Uses

func (*AlterIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterIndex) String Uses

func (n *AlterIndex) String() string

type AlterIndexCmd Uses

type AlterIndexCmd interface {
    NodeFormatter
    // contains filtered or unexported methods
}

AlterIndexCmd represents an index modification operation.

type AlterIndexCmds Uses

type AlterIndexCmds []AlterIndexCmd

AlterIndexCmds represents a list of index alterations.

func (*AlterIndexCmds) Format Uses

func (node *AlterIndexCmds) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterIndexPartitionBy Uses

type AlterIndexPartitionBy struct {
    *PartitionBy
}

AlterIndexPartitionBy represents an ALTER INDEX PARTITION BY command.

func (*AlterIndexPartitionBy) Format Uses

func (node *AlterIndexPartitionBy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterSequence Uses

type AlterSequence struct {
    IfExists bool
    Name     *UnresolvedObjectName
    Options  SequenceOptions
}

AlterSequence represents an ALTER SEQUENCE statement, except in the case of ALTER SEQUENCE <seqName> RENAME TO <newSeqName>, which is represented by a RenameTable node.

func (*AlterSequence) Format Uses

func (node *AlterSequence) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterSequence) StatementTag Uses

func (*AlterSequence) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterSequence) StatementType Uses

func (*AlterSequence) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterSequence) String Uses

func (n *AlterSequence) String() string

type AlterTable Uses

type AlterTable struct {
    IfExists bool
    Table    *UnresolvedObjectName
    Cmds     AlterTableCmds
}

AlterTable represents an ALTER TABLE statement.

func (*AlterTable) Format Uses

func (node *AlterTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTable) HoistAddColumnConstraints Uses

func (node *AlterTable) HoistAddColumnConstraints()

HoistAddColumnConstraints converts column constraints in ADD COLUMN commands, stored in node.Cmds, into top-level commands to add those constraints. Currently, this only applies to checks. For example, the ADD COLUMN in

ALTER TABLE t ADD COLUMN a INT CHECK (a < 1)

is transformed into two commands, as in

ALTER TABLE t ADD COLUMN a INT, ADD CONSTRAINT check_a CHECK (a < 1)

(with an auto-generated name).

Note that some SQL databases require that a constraint attached to a column to refer only to the column it is attached to. We follow Postgres' behavior, however, in omitting this restriction by blindly hoisting all column constraints. For example, the following statement is accepted in CockroachDB and Postgres, but not necessarily other SQL databases:

ALTER TABLE t ADD COLUMN a INT CHECK (a < b)

func (*AlterTable) StatementTag Uses

func (*AlterTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTable) StatementType Uses

func (*AlterTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTable) String Uses

func (n *AlterTable) String() string

type AlterTableAddColumn Uses

type AlterTableAddColumn struct {
    IfNotExists bool
    ColumnDef   *ColumnTableDef
}

AlterTableAddColumn represents an ADD COLUMN command.

func (*AlterTableAddColumn) Format Uses

func (node *AlterTableAddColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableAddColumn) String Uses

func (n *AlterTableAddColumn) String() string

type AlterTableAddConstraint Uses

type AlterTableAddConstraint struct {
    ConstraintDef      ConstraintTableDef
    ValidationBehavior ValidationBehavior
}

AlterTableAddConstraint represents an ADD CONSTRAINT command.

func (*AlterTableAddConstraint) Format Uses

func (node *AlterTableAddConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableAddConstraint) String Uses

func (n *AlterTableAddConstraint) String() string

type AlterTableAlterColumnType Uses

type AlterTableAlterColumnType struct {
    Collation string
    Column    Name
    ToType    *types.T
    Using     Expr
}

AlterTableAlterColumnType represents an ALTER TABLE ALTER COLUMN TYPE command.

func (*AlterTableAlterColumnType) Format Uses

func (node *AlterTableAlterColumnType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableAlterColumnType) GetColumn Uses

func (node *AlterTableAlterColumnType) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableAlterColumnType) String Uses

func (n *AlterTableAlterColumnType) String() string

type AlterTableCmd Uses

type AlterTableCmd interface {
    NodeFormatter
    // contains filtered or unexported methods
}

AlterTableCmd represents a table modification operation.

type AlterTableCmds Uses

type AlterTableCmds []AlterTableCmd

AlterTableCmds represents a list of table alterations.

func (*AlterTableCmds) Format Uses

func (node *AlterTableCmds) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableCmds) String Uses

func (n *AlterTableCmds) String() string

type AlterTableDropColumn Uses

type AlterTableDropColumn struct {
    IfExists     bool
    Column       Name
    DropBehavior DropBehavior
}

AlterTableDropColumn represents a DROP COLUMN command.

func (*AlterTableDropColumn) Format Uses

func (node *AlterTableDropColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableDropColumn) String Uses

func (n *AlterTableDropColumn) String() string

type AlterTableDropConstraint Uses

type AlterTableDropConstraint struct {
    IfExists     bool
    Constraint   Name
    DropBehavior DropBehavior
}

AlterTableDropConstraint represents a DROP CONSTRAINT command.

func (*AlterTableDropConstraint) Format Uses

func (node *AlterTableDropConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableDropConstraint) String Uses

func (n *AlterTableDropConstraint) String() string

type AlterTableDropNotNull Uses

type AlterTableDropNotNull struct {
    Column Name
}

AlterTableDropNotNull represents an ALTER COLUMN DROP NOT NULL command.

func (*AlterTableDropNotNull) Format Uses

func (node *AlterTableDropNotNull) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableDropNotNull) GetColumn Uses

func (node *AlterTableDropNotNull) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableDropNotNull) String Uses

func (n *AlterTableDropNotNull) String() string

type AlterTableDropStored Uses

type AlterTableDropStored struct {
    Column Name
}

AlterTableDropStored represents an ALTER COLUMN DROP STORED command to remove the computed-ness from a column.

func (*AlterTableDropStored) Format Uses

func (node *AlterTableDropStored) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableDropStored) GetColumn Uses

func (node *AlterTableDropStored) GetColumn() Name

GetColumn implemnets the ColumnMutationCmd interface.

func (*AlterTableDropStored) String Uses

func (n *AlterTableDropStored) String() string

type AlterTableInjectStats Uses

type AlterTableInjectStats struct {
    Stats Expr
}

AlterTableInjectStats represents an ALTER TABLE INJECT STATISTICS statement.

func (*AlterTableInjectStats) Format Uses

func (node *AlterTableInjectStats) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTablePartitionBy Uses

type AlterTablePartitionBy struct {
    *PartitionBy
}

AlterTablePartitionBy represents an ALTER TABLE PARTITION BY command.

func (*AlterTablePartitionBy) Format Uses

func (node *AlterTablePartitionBy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableRenameColumn Uses

type AlterTableRenameColumn struct {
    Column  Name
    NewName Name
}

AlterTableRenameColumn represents an ALTER TABLE RENAME [COLUMN] command.

func (*AlterTableRenameColumn) Format Uses

func (node *AlterTableRenameColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableRenameConstraint Uses

type AlterTableRenameConstraint struct {
    Constraint Name
    NewName    Name
}

AlterTableRenameConstraint represents an ALTER TABLE RENAME CONSTRAINT command.

func (*AlterTableRenameConstraint) Format Uses

func (node *AlterTableRenameConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableRenameTable Uses

type AlterTableRenameTable struct {
    NewName TableName
}

AlterTableRenameTable represents an ALTE RTABLE RENAME TO command.

func (*AlterTableRenameTable) Format Uses

func (node *AlterTableRenameTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableSetAudit Uses

type AlterTableSetAudit struct {
    Mode AuditMode
}

AlterTableSetAudit represents an ALTER TABLE AUDIT SET statement.

func (*AlterTableSetAudit) Format Uses

func (node *AlterTableSetAudit) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableSetDefault Uses

type AlterTableSetDefault struct {
    Column  Name
    Default Expr
}

AlterTableSetDefault represents an ALTER COLUMN SET DEFAULT or DROP DEFAULT command.

func (*AlterTableSetDefault) Format Uses

func (node *AlterTableSetDefault) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetDefault) GetColumn Uses

func (node *AlterTableSetDefault) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableSetDefault) String Uses

func (n *AlterTableSetDefault) String() string

type AlterTableSetNotNull Uses

type AlterTableSetNotNull struct {
    Column Name
}

AlterTableSetNotNull represents an ALTER COLUMN SET NOT NULL command.

func (*AlterTableSetNotNull) Format Uses

func (node *AlterTableSetNotNull) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetNotNull) GetColumn Uses

func (node *AlterTableSetNotNull) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableSetNotNull) String Uses

func (n *AlterTableSetNotNull) String() string

type AlterTableValidateConstraint Uses

type AlterTableValidateConstraint struct {
    Constraint Name
}

AlterTableValidateConstraint represents a VALIDATE CONSTRAINT command.

func (*AlterTableValidateConstraint) Format Uses

func (node *AlterTableValidateConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterUserSetPassword Uses

type AlterUserSetPassword struct {
    Name     Expr
    Password Expr
    IfExists bool
}

AlterUserSetPassword represents an ALTER USER ... WITH PASSWORD statement.

func (*AlterUserSetPassword) Format Uses

func (node *AlterUserSetPassword) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterUserSetPassword) StatementTag Uses

func (*AlterUserSetPassword) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterUserSetPassword) StatementType Uses

func (*AlterUserSetPassword) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterUserSetPassword) String Uses

func (n *AlterUserSetPassword) String() string

type AndExpr Uses

type AndExpr struct {
    Left, Right Expr
    // contains filtered or unexported fields
}

AndExpr represents an AND expression.

func NewTypedAndExpr Uses

func NewTypedAndExpr(left, right TypedExpr) *AndExpr

NewTypedAndExpr returns a new AndExpr that is verified to be well-typed.

func (*AndExpr) Eval Uses

func (expr *AndExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*AndExpr) Format Uses

func (node *AndExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (AndExpr) ResolvedType Uses

func (ta AndExpr) ResolvedType() *types.T

func (*AndExpr) String Uses

func (node *AndExpr) String() string

func (*AndExpr) TypeCheck Uses

func (expr *AndExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*AndExpr) TypedLeft Uses

func (node *AndExpr) TypedLeft() TypedExpr

TypedLeft returns the AndExpr's left expression as a TypedExpr.

func (*AndExpr) TypedRight Uses

func (node *AndExpr) TypedRight() TypedExpr

TypedRight returns the AndExpr's right expression as a TypedExpr.

func (*AndExpr) Walk Uses

func (expr *AndExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type AnnotateTypeExpr Uses

type AnnotateTypeExpr struct {
    Expr Expr
    Type *types.T

    SyntaxMode annotateSyntaxMode
}

AnnotateTypeExpr represents a ANNOTATE_TYPE(expr, type) expression.

func (*AnnotateTypeExpr) Format Uses

func (node *AnnotateTypeExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AnnotateTypeExpr) String Uses

func (node *AnnotateTypeExpr) String() string

func (*AnnotateTypeExpr) TypeCheck Uses

func (expr *AnnotateTypeExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*AnnotateTypeExpr) TypedInnerExpr Uses

func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the AnnotateTypeExpr's inner expression as a TypedExpr.

func (*AnnotateTypeExpr) Walk Uses

func (expr *AnnotateTypeExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type AnnotatedNode Uses

type AnnotatedNode struct {
    AnnIdx AnnotationIdx
}

AnnotatedNode is embedded in AST nodes that have an annotation.

func (AnnotatedNode) GetAnnotation Uses

func (n AnnotatedNode) GetAnnotation(ann *Annotations) interface{}

GetAnnotation retrieves the annotation associated with this node.

func (AnnotatedNode) SetAnnotation Uses

func (n AnnotatedNode) SetAnnotation(ann *Annotations, annotation interface{})

SetAnnotation sets the annotation associated with this node.

type AnnotationIdx Uses

type AnnotationIdx int32

AnnotationIdx is the 1-based index of an annotation. AST nodes that can be annotated store such an index (unique within that AST).

const NoAnnotation AnnotationIdx = 0

NoAnnotation is the uninitialized annotation index.

type Annotations Uses

type Annotations []interface{}

Annotations is a container for AST annotations.

func MakeAnnotations Uses

func MakeAnnotations(numAnnotations AnnotationIdx) Annotations

MakeAnnotations allocates an annotations container of the given size.

func (*Annotations) Get Uses

func (a *Annotations) Get(idx AnnotationIdx) interface{}

Get an annotation from the container.

func (*Annotations) Set Uses

func (a *Annotations) Set(idx AnnotationIdx, annotation interface{})

Set an annotation in the container.

type ArgTypes Uses

type ArgTypes []struct {
    Name string
    Typ  *types.T
}

ArgTypes is very similar to ArgTypes except it allows keeping a string name for each argument as well and using those when printing the human-readable signature.

func (ArgTypes) GetAt Uses

func (a ArgTypes) GetAt(i int) *types.T

GetAt is part of the TypeList interface.

func (ArgTypes) Length Uses

func (a ArgTypes) Length() int

Length is part of the TypeList interface.

func (ArgTypes) Match Uses

func (a ArgTypes) Match(types []*types.T) bool

Match is part of the TypeList interface.

func (ArgTypes) MatchAt Uses

func (a ArgTypes) MatchAt(typ *types.T, i int) bool

MatchAt is part of the TypeList interface.

func (ArgTypes) MatchLen Uses

func (a ArgTypes) MatchLen(l int) bool

MatchLen is part of the TypeList interface.

func (ArgTypes) String Uses

func (a ArgTypes) String() string

func (ArgTypes) Types Uses

func (a ArgTypes) Types() []*types.T

Types is part of the TypeList interface.

type Array Uses

type Array struct {
    Exprs Exprs
    // contains filtered or unexported fields
}

Array represents an array constructor.

func NewTypedArray Uses

func NewTypedArray(typedExprs TypedExprs, typ *types.T) *Array

NewTypedArray returns an Array that is well-typed.

func (*Array) Eval Uses

func (t *Array) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*Array) Format Uses

func (node *Array) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (Array) ResolvedType Uses

func (ta Array) ResolvedType() *types.T

func (*Array) String Uses

func (node *Array) String() string

func (*Array) TypeCheck Uses

func (expr *Array) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Array) Walk Uses

func (expr *Array) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ArrayFlatten Uses

type ArrayFlatten struct {
    Subquery Expr
    // contains filtered or unexported fields
}

ArrayFlatten represents a subquery array constructor.

func NewTypedArrayFlattenExpr Uses

func NewTypedArrayFlattenExpr(input Expr) *ArrayFlatten

NewTypedArrayFlattenExpr returns a new ArrayFlattenExpr that is verified to be well-typed.

func (*ArrayFlatten) Eval Uses

func (t *ArrayFlatten) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*ArrayFlatten) Format Uses

func (node *ArrayFlatten) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ArrayFlatten) ResolvedType Uses

func (ta ArrayFlatten) ResolvedType() *types.T

func (*ArrayFlatten) String Uses

func (node *ArrayFlatten) String() string

func (*ArrayFlatten) TypeCheck Uses

func (expr *ArrayFlatten) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ArrayFlatten) Walk Uses

func (expr *ArrayFlatten) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ArraySubscript Uses

type ArraySubscript struct {
    Begin Expr
    End   Expr
    Slice bool
}

ArraySubscript corresponds to the syntax `<name>[ ... ]`.

func (*ArraySubscript) Format Uses

func (a *ArraySubscript) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type ArraySubscripts Uses

type ArraySubscripts []*ArraySubscript

ArraySubscripts represents a sequence of one or more array subscripts.

func (*ArraySubscripts) Format Uses

func (a *ArraySubscripts) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AsOfClause Uses

type AsOfClause struct {
    Expr Expr
}

AsOfClause represents an as of time.

func (*AsOfClause) Format Uses

func (a *AsOfClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AuditMode Uses

type AuditMode int

AuditMode represents a table audit mode

const (
    // AuditModeDisable is the default mode - no audit.
    AuditModeDisable AuditMode = iota
    // AuditModeReadWrite enables audit on read or write statements.
    AuditModeReadWrite
)

func (AuditMode) String Uses

func (m AuditMode) String() string

type Backup Uses

type Backup struct {
    Targets         TargetList
    To              Expr
    IncrementalFrom Exprs
    AsOf            AsOfClause
    Options         KVOptions
}

Backup represents a BACKUP statement.

func (*Backup) Format Uses

func (node *Backup) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Backup) StatementTag Uses

func (*Backup) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Backup) StatementType Uses

func (*Backup) StatementType() StatementType

StatementType implements the Statement interface.

func (*Backup) String Uses

func (n *Backup) String() string

type BackupDetails Uses

type BackupDetails int

BackupDetails represents the type of details to display for a SHOW BACKUP statement.

const (
    // BackupDefaultDetails identifies a bare SHOW BACKUP statement.
    BackupDefaultDetails BackupDetails = iota
    // BackupRangeDetails identifies a SHOW BACKUP RANGES statement.
    BackupRangeDetails
    // BackupFileDetails identifies a SHOW BACKUP FILES statement.
    BackupFileDetails
)

type BeginTransaction Uses

type BeginTransaction struct {
    Modes TransactionModes
}

BeginTransaction represents a BEGIN statement

func (*BeginTransaction) Format Uses

func (node *BeginTransaction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*BeginTransaction) StatementTag Uses

func (*BeginTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*BeginTransaction) StatementType Uses

func (*BeginTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*BeginTransaction) String Uses

func (n *BeginTransaction) String() string

type BinOp Uses

type BinOp struct {
    LeftType     *types.T
    RightType    *types.T
    ReturnType   *types.T
    NullableArgs bool
    Fn           func(*EvalContext, Datum, Datum) (Datum, error)
    // contains filtered or unexported fields
}

BinOp is a binary operator.

type BinaryExpr Uses

type BinaryExpr struct {
    Operator    BinaryOperator
    Left, Right Expr
    // contains filtered or unexported fields
}

BinaryExpr represents a binary value expression.

func NewTypedBinaryExpr Uses

func NewTypedBinaryExpr(op BinaryOperator, left, right TypedExpr, typ *types.T) *BinaryExpr

NewTypedBinaryExpr returns a new BinaryExpr that is well-typed.

func (*BinaryExpr) Eval Uses

func (expr *BinaryExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*BinaryExpr) Format Uses

func (node *BinaryExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*BinaryExpr) ResolvedBinOp Uses

func (node *BinaryExpr) ResolvedBinOp() *BinOp

ResolvedBinOp returns the resolved binary op overload; can only be called after Resolve (which happens during TypeCheck).

func (BinaryExpr) ResolvedType Uses

func (ta BinaryExpr) ResolvedType() *types.T

func (*BinaryExpr) String Uses

func (node *BinaryExpr) String() string

func (*BinaryExpr) TypeCheck Uses

func (expr *BinaryExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*BinaryExpr) TypedLeft Uses

func (node *BinaryExpr) TypedLeft() TypedExpr

TypedLeft returns the BinaryExpr's left expression as a TypedExpr.

func (*BinaryExpr) TypedRight Uses

func (node *BinaryExpr) TypedRight() TypedExpr

TypedRight returns the BinaryExpr's right expression as a TypedExpr.

func (*BinaryExpr) Walk Uses

func (expr *BinaryExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type BinaryOperator Uses

type BinaryOperator int

BinaryOperator represents a binary operator.

const (
    Bitand BinaryOperator = iota
    Bitor
    Bitxor
    Plus
    Minus
    Mult
    Div
    FloorDiv
    Mod
    Pow
    Concat
    LShift
    RShift
    JSONFetchVal
    JSONFetchText
    JSONFetchValPath
    JSONFetchTextPath

    NumBinaryOperators
)

BinaryExpr.Operator

func (BinaryOperator) String Uses

func (i BinaryOperator) String() string

type CCLOnlyStatement Uses

type CCLOnlyStatement interface {
    // contains filtered or unexported methods
}

CCLOnlyStatement is a marker interface for statements that require a CCL binary for successful planning or execution. It is used to enhance error messages when attempting to use these statements in non-CCL binaries.

type CTE Uses

type CTE struct {
    Name AliasClause
    Stmt Statement
}

CTE represents a common table expression inside of a WITH clause.

type CancelQueries Uses

type CancelQueries struct {
    Queries  *Select
    IfExists bool
}

CancelQueries represents a CANCEL QUERIES statement.

func (*CancelQueries) Format Uses

func (node *CancelQueries) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CancelQueries) StatementTag Uses

func (*CancelQueries) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CancelQueries) StatementType Uses

func (*CancelQueries) StatementType() StatementType

StatementType implements the Statement interface.

func (*CancelQueries) String Uses

func (n *CancelQueries) String() string

type CancelSessions Uses

type CancelSessions struct {
    Sessions *Select
    IfExists bool
}

CancelSessions represents a CANCEL SESSIONS statement.

func (*CancelSessions) Format Uses

func (node *CancelSessions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CancelSessions) StatementTag Uses

func (*CancelSessions) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CancelSessions) StatementType Uses

func (*CancelSessions) StatementType() StatementType

StatementType implements the Statement interface.

func (*CancelSessions) String Uses

func (n *CancelSessions) String() string

type CannedOptPlan Uses

type CannedOptPlan struct {
    Plan string
}

CannedOptPlan is used as the AST for a PREPARE .. AS OPT PLAN statement. This is a testing facility that allows execution (and benchmarking) of specific plans. See exprgen package for more information on the syntax.

func (*CannedOptPlan) Format Uses

func (node *CannedOptPlan) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CannedOptPlan) StatementTag Uses

func (*CannedOptPlan) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CannedOptPlan) StatementType Uses

func (*CannedOptPlan) StatementType() StatementType

StatementType implements the Statement interface.

func (*CannedOptPlan) String Uses

func (n *CannedOptPlan) String() string

type CaseExpr Uses

type CaseExpr struct {
    Expr  Expr
    Whens []*When
    Else  Expr
    // contains filtered or unexported fields
}

CaseExpr represents a CASE expression.

func NewTypedCaseExpr Uses

func NewTypedCaseExpr(
    expr TypedExpr, whens []*When, elseStmt TypedExpr, typ *types.T,
) (*CaseExpr, error)

NewTypedCaseExpr returns a new CaseExpr that is verified to be well-typed.

func (*CaseExpr) Eval Uses

func (expr *CaseExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*CaseExpr) Format Uses

func (node *CaseExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CaseExpr) ResolvedType Uses

func (ta CaseExpr) ResolvedType() *types.T

func (*CaseExpr) String Uses

func (node *CaseExpr) String() string

func (*CaseExpr) TypeCheck Uses

func (expr *CaseExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CaseExpr) Walk Uses

func (expr *CaseExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CastExpr Uses

type CastExpr struct {
    Expr Expr
    Type *types.T

    SyntaxMode castSyntaxMode
    // contains filtered or unexported fields
}

CastExpr represents a CAST(expr AS type) expression.

func NewTypedCastExpr Uses

func NewTypedCastExpr(expr TypedExpr, typ *types.T) (*CastExpr, error)

NewTypedCastExpr returns a new CastExpr that is verified to be well-typed.

func (*CastExpr) Eval Uses

func (expr *CastExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*CastExpr) Format Uses

func (node *CastExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CastExpr) ResolvedType Uses

func (ta CastExpr) ResolvedType() *types.T

func (*CastExpr) String Uses

func (node *CastExpr) String() string

func (*CastExpr) TypeCheck Uses

func (expr *CastExpr) TypeCheck(ctx *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CastExpr) Walk Uses

func (expr *CastExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CheckConstraintTableDef Uses

type CheckConstraintTableDef struct {
    Name Name
    Expr Expr
}

CheckConstraintTableDef represents a check constraint within a CREATE TABLE statement.

func (*CheckConstraintTableDef) Format Uses

func (node *CheckConstraintTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CheckConstraintTableDef) SetName Uses

func (node *CheckConstraintTableDef) SetName(name Name)

SetName implements the TableDef interface.

type CmpOp Uses

type CmpOp struct {
    LeftType  *types.T
    RightType *types.T

    // If NullableArgs is false, the operator returns NULL
    // whenever either argument is NULL.
    NullableArgs bool

    // Datum return type is a union between *DBool and dNull.
    Fn  func(*EvalContext, Datum, Datum) (Datum, error)
    // contains filtered or unexported fields
}

CmpOp is a comparison operator.

type CoalesceExpr Uses

type CoalesceExpr struct {
    Name  string
    Exprs Exprs
    // contains filtered or unexported fields
}

CoalesceExpr represents a COALESCE or IFNULL expression.

func NewTypedCoalesceExpr Uses

func NewTypedCoalesceExpr(typedExprs TypedExprs, typ *types.T) *CoalesceExpr

NewTypedCoalesceExpr returns a CoalesceExpr that is well-typed.

func (*CoalesceExpr) Eval Uses

func (expr *CoalesceExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*CoalesceExpr) Format Uses

func (node *CoalesceExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CoalesceExpr) ResolvedType Uses

func (ta CoalesceExpr) ResolvedType() *types.T

func (*CoalesceExpr) String Uses

func (node *CoalesceExpr) String() string

func (*CoalesceExpr) TypeCheck Uses

func (expr *CoalesceExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CoalesceExpr) TypedExprAt Uses

func (node *CoalesceExpr) TypedExprAt(idx int) TypedExpr

TypedExprAt returns the expression at the specified index as a TypedExpr.

func (*CoalesceExpr) Walk Uses

func (expr *CoalesceExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CollateExpr Uses

type CollateExpr struct {
    Expr   Expr
    Locale string
    // contains filtered or unexported fields
}

CollateExpr represents an (expr COLLATE locale) expression.

func NewTypedCollateExpr Uses

func NewTypedCollateExpr(expr TypedExpr, locale string) *CollateExpr

NewTypedCollateExpr returns a new CollateExpr that is verified to be well-typed.

func (*CollateExpr) Eval Uses

func (expr *CollateExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*CollateExpr) Format Uses

func (node *CollateExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CollateExpr) ResolvedType Uses

func (ta CollateExpr) ResolvedType() *types.T

func (*CollateExpr) String Uses

func (node *CollateExpr) String() string

func (*CollateExpr) TypeCheck Uses

func (expr *CollateExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CollateExpr) Walk Uses

func (expr *CollateExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CollationEnvironment Uses

type CollationEnvironment struct {
    // contains filtered or unexported fields
}

CollationEnvironment stores the state needed by NewDCollatedString to construct collation keys efficiently.

type ColumnAccessExpr Uses

type ColumnAccessExpr struct {
    Expr    Expr
    ColName string

    // ColIndex indicates the index of the column in the tuple. This is
    // set during type checking based on the label in ColName.
    ColIndex int
    // contains filtered or unexported fields
}

ColumnAccessExpr represents (E).x expressions. Specifically, it allows accessing the column(s) from a Set Retruning Function.

func NewTypedColumnAccessExpr Uses

func NewTypedColumnAccessExpr(expr TypedExpr, colName string, colIdx int) *ColumnAccessExpr

NewTypedColumnAccessExpr creates a pre-typed ColumnAccessExpr.

func (*ColumnAccessExpr) Eval Uses

func (expr *ColumnAccessExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*ColumnAccessExpr) Format Uses

func (node *ColumnAccessExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ColumnAccessExpr) ResolvedType Uses

func (ta ColumnAccessExpr) ResolvedType() *types.T

func (*ColumnAccessExpr) String Uses

func (node *ColumnAccessExpr) String() string

func (*ColumnAccessExpr) TypeCheck Uses

func (expr *ColumnAccessExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ColumnAccessExpr) Walk Uses

func (expr *ColumnAccessExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ColumnCheckConstraint Uses

type ColumnCheckConstraint struct {
    Expr Expr
}

ColumnCheckConstraint represents either a check on a column.

type ColumnCollation Uses

type ColumnCollation string

ColumnCollation represents a COLLATE clause for a column.

type ColumnComputedDef Uses

type ColumnComputedDef struct {
    Expr Expr
}

ColumnComputedDef represents the description of a computed column.

type ColumnDefault Uses

type ColumnDefault struct {
    Expr Expr
}

ColumnDefault represents a DEFAULT clause for a column.

type ColumnFKConstraint Uses

type ColumnFKConstraint struct {
    Table   TableName
    Col     Name // empty-string means use PK
    Actions ReferenceActions
    Match   CompositeKeyMatchMethod
}

ColumnFKConstraint represents a FK-constaint on a column.

type ColumnFamilyConstraint Uses

type ColumnFamilyConstraint struct {
    Family      Name
    Create      bool
    IfNotExists bool
}

ColumnFamilyConstraint represents FAMILY on a column.

type ColumnID Uses

type ColumnID uint32

ColumnID is a custom type for ColumnDescriptor IDs.

type ColumnItem Uses

type ColumnItem struct {
    // TableName holds the table prefix, if the name refers to a column. It is
    // optional.
    //
    // This uses UnresolvedObjectName because we need to preserve the
    // information about which parts were initially specified in the SQL
    // text. ColumnItems are intermediate data structures anyway, that
    // still need to undergo name resolution.
    TableName *UnresolvedObjectName
    // ColumnName names the designated column.
    ColumnName Name

    // This column is a selector column expression used in a SELECT
    // for an UPDATE/DELETE.
    // TODO(vivek): Do not artificially create such expressions
    // when scanning columns for an UPDATE/DELETE.
    ForUpdateOrDelete bool
}

ColumnItem corresponds to the name of a column in an expression.

func MakeColumnItem Uses

func MakeColumnItem(tn *TableName, colName Name) ColumnItem

MakeColumnItem constructs a column item from an already valid TableName. This can be used for e.g. pretty-printing.

func NewColumnItem Uses

func NewColumnItem(tn *TableName, colName Name) *ColumnItem

NewColumnItem constructs a column item from an already valid TableName. This can be used for e.g. pretty-printing.

func (*ColumnItem) Column Uses

func (c *ColumnItem) Column() string

Column retrieves the unqualified column name.

func (*ColumnItem) Eval Uses

func (expr *ColumnItem) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*ColumnItem) Format Uses

func (c *ColumnItem) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ColumnItem) NormalizeVarName Uses

func (c *ColumnItem) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (*ColumnItem) Resolve Uses

func (c *ColumnItem) Resolve(
    ctx context.Context, r ColumnItemResolver,
) (ColumnResolutionResult, error)

Resolve performs name resolution for a column item using a resolver.

func (*ColumnItem) ResolvedType Uses

func (c *ColumnItem) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*ColumnItem) String Uses

func (c *ColumnItem) String() string

func (*ColumnItem) TypeCheck Uses

func (expr *ColumnItem) TypeCheck(_ *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. This function has a valid implementation only for testing within this package. During query execution, ColumnItems are replaced to IndexedVars prior to type checking.

func (*ColumnItem) Variable Uses

func (c *ColumnItem) Variable()

Variable implements the VariableExpr interface.

Note that in common uses, ColumnItem ought to be replaced to an IndexedVar prior to evaluation.

func (*ColumnItem) Walk Uses

func (expr *ColumnItem) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type ColumnItemResolver Uses

type ColumnItemResolver interface {
    // FindSourceMatchingName searches for a data source with name tn.
    //
    // This must error out with "ambiguous table name" if there is more
    // than one data source matching tn. The srcMeta is subsequently
    // passed to Resolve() if resolution succeeds. The prefix will not be
    // modified.
    FindSourceMatchingName(ctx context.Context, tn TableName) (res NumResolutionResults, prefix *TableName, srcMeta ColumnSourceMeta, err error)

    // FindSourceProvidingColumn searches for a data source providing
    // a column with the name given.
    //
    // This must error out with "ambiguous column name" if there is more
    // than one data source matching tn, "column not found" if there is
    // none. The srcMeta and colHints are subsequently passed to
    // Resolve() if resolution succeeds. The prefix will not be
    // modified.
    FindSourceProvidingColumn(ctx context.Context, col Name) (prefix *TableName, srcMeta ColumnSourceMeta, colHint int, err error)

    // Resolve() is called if resolution succeeds.
    Resolve(ctx context.Context, prefix *TableName, srcMeta ColumnSourceMeta, colHint int, col Name) (ColumnResolutionResult, error)
}

ColumnItemResolver is the helper interface to resolve column items.

type ColumnMutationCmd Uses

type ColumnMutationCmd interface {
    AlterTableCmd
    GetColumn() Name
}

ColumnMutationCmd is the subset of AlterTableCmds that modify an existing column.

type ColumnQualification Uses

type ColumnQualification interface {
    // contains filtered or unexported methods
}

ColumnQualification represents a constraint on a column.

type ColumnResolutionResult Uses

type ColumnResolutionResult interface {
    // ColumnResolutionResult is the interface anchor.
    ColumnResolutionResult()
}

ColumnResolutionResult is an opaque reference returned by ColumnItemResolver.Resolve().

type ColumnSourceMeta Uses

type ColumnSourceMeta interface {
    // ColumnSourcMeta is the interface anchor.
    ColumnSourceMeta()
}

ColumnSourceMeta is an opaque reference passed through column item resolution.

type ColumnTableDef Uses

type ColumnTableDef struct {
    Name     Name
    Type     *types.T
    IsSerial bool
    Nullable struct {
        Nullability    Nullability
        ConstraintName Name
    }
    PrimaryKey           bool
    Unique               bool
    UniqueConstraintName Name
    DefaultExpr          struct {
        Expr           Expr
        ConstraintName Name
    }
    CheckExprs []ColumnTableDefCheckExpr
    References struct {
        Table          *TableName
        Col            Name
        ConstraintName Name
        Actions        ReferenceActions
        Match          CompositeKeyMatchMethod
    }
    Computed struct {
        Computed bool
        Expr     Expr
    }
    Family struct {
        Name        Name
        Create      bool
        IfNotExists bool
    }
}

ColumnTableDef represents a column definition within a CREATE TABLE statement.

func NewColumnTableDef Uses

func NewColumnTableDef(
    name Name, typ *types.T, isSerial bool, qualifications []NamedColumnQualification,
) (*ColumnTableDef, error)

NewColumnTableDef constructs a column definition for a CreateTable statement.

func (*ColumnTableDef) Format Uses

func (node *ColumnTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ColumnTableDef) HasColumnFamily Uses

func (node *ColumnTableDef) HasColumnFamily() bool

HasColumnFamily returns if the ColumnTableDef has a column family.

func (*ColumnTableDef) HasDefaultExpr Uses

func (node *ColumnTableDef) HasDefaultExpr() bool

HasDefaultExpr returns if the ColumnTableDef has a default expression.

func (*ColumnTableDef) HasFKConstraint Uses

func (node *ColumnTableDef) HasFKConstraint() bool

HasFKConstraint returns if the ColumnTableDef has a foreign key constraint.

func (*ColumnTableDef) IsComputed Uses

func (node *ColumnTableDef) IsComputed() bool

IsComputed returns if the ColumnTableDef is a computed column.

func (*ColumnTableDef) SetName Uses

func (node *ColumnTableDef) SetName(name Name)

SetName implements the TableDef interface.

func (*ColumnTableDef) String Uses

func (node *ColumnTableDef) String() string

String implements the fmt.Stringer interface.

type ColumnTableDefCheckExpr Uses

type ColumnTableDefCheckExpr struct {
    Expr           Expr
    ConstraintName Name
}

ColumnTableDefCheckExpr represents a check constraint on a column definition within a CREATE TABLE statement.

type CommentOnColumn Uses

type CommentOnColumn struct {
    *ColumnItem
    Comment *string
}

CommentOnColumn represents an COMMENT ON COLUMN statement.

func (*CommentOnColumn) Format Uses

func (n *CommentOnColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CommentOnColumn) StatementTag Uses

func (*CommentOnColumn) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommentOnColumn) StatementType Uses

func (*CommentOnColumn) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommentOnColumn) String Uses

func (n *CommentOnColumn) String() string

type CommentOnDatabase Uses

type CommentOnDatabase struct {
    Name    Name
    Comment *string
}

CommentOnDatabase represents an COMMENT ON DATABASE statement.

func (*CommentOnDatabase) Format Uses

func (n *CommentOnDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CommentOnDatabase) StatementTag Uses

func (*CommentOnDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommentOnDatabase) StatementType Uses

func (*CommentOnDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommentOnDatabase) String Uses

func (n *CommentOnDatabase) String() string

type CommentOnTable Uses

type CommentOnTable struct {
    Table   *UnresolvedObjectName
    Comment *string
}

CommentOnTable represents an COMMENT ON TABLE statement.

func (*CommentOnTable) Format Uses

func (n *CommentOnTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CommentOnTable) StatementTag Uses

func (*CommentOnTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommentOnTable) StatementType Uses

func (*CommentOnTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommentOnTable) String Uses

func (n *CommentOnTable) String() string

type CommitTransaction Uses

type CommitTransaction struct{}

CommitTransaction represents a COMMIT statement.

func (*CommitTransaction) Format Uses

func (node *CommitTransaction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CommitTransaction) StatementTag Uses

func (*CommitTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommitTransaction) StatementType Uses

func (*CommitTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommitTransaction) String Uses

func (n *CommitTransaction) String() string

type ComparisonExpr Uses

type ComparisonExpr struct {
    Operator    ComparisonOperator
    SubOperator ComparisonOperator // used for array operators (when Operator is Any, Some, or All)
    Left, Right Expr
    // contains filtered or unexported fields
}

ComparisonExpr represents a two-value comparison expression.

func NewTypedComparisonExpr Uses

func NewTypedComparisonExpr(op ComparisonOperator, left, right TypedExpr) *ComparisonExpr

NewTypedComparisonExpr returns a new ComparisonExpr that is verified to be well-typed.

func NewTypedComparisonExprWithSubOp Uses

func NewTypedComparisonExprWithSubOp(
    op, subOp ComparisonOperator, left, right TypedExpr,
) *ComparisonExpr

NewTypedComparisonExprWithSubOp returns a new ComparisonExpr that is verified to be well-typed.

func (*ComparisonExpr) Eval Uses

func (expr *ComparisonExpr) Eval(ctx *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*ComparisonExpr) Format Uses

func (node *ComparisonExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ComparisonExpr) ResolvedType Uses

func (ta ComparisonExpr) ResolvedType() *types.T

func (*ComparisonExpr) String Uses

func (node *ComparisonExpr) String() string

func (*ComparisonExpr) TypeCheck Uses

func (expr *ComparisonExpr) TypeCheck(ctx *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ComparisonExpr) TypedLeft Uses

func (node *ComparisonExpr) TypedLeft() TypedExpr

TypedLeft returns the ComparisonExpr's left expression as a TypedExpr.

func (*ComparisonExpr) TypedRight Uses

func (node *ComparisonExpr) TypedRight() TypedExpr

TypedRight returns the ComparisonExpr's right expression as a TypedExpr.

func (*ComparisonExpr) Walk Uses

func (expr *ComparisonExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ComparisonOperator Uses

type ComparisonOperator int

ComparisonOperator represents a binary operator.

const (
    EQ  ComparisonOperator = iota
    LT
    GT
    LE
    GE
    NE
    In
    NotIn
    Like
    NotLike
    ILike
    NotILike
    SimilarTo
    NotSimilarTo
    RegMatch
    NotRegMatch
    RegIMatch
    NotRegIMatch
    IsDistinctFrom
    IsNotDistinctFrom
    Contains
    ContainedBy
    JSONExists
    JSONSomeExists
    JSONAllExists

    // The following operators will always be used with an associated SubOperator.
    // If Go had algebraic data types they would be defined in a self-contained
    // manner like:
    //
    // Any(ComparisonOperator)
    // Some(ComparisonOperator)
    // ...
    //
    // where the internal ComparisonOperator qualifies the behavior of the primary
    // operator. Instead, a secondary ComparisonOperator is optionally included in
    // ComparisonExpr for the cases where these operators are the primary op.
    //
    // ComparisonOperator.hasSubOperator returns true for ops in this group.
    Any
    Some
    All

    NumComparisonOperators
)

ComparisonExpr.Operator

func (ComparisonOperator) Inverse Uses

func (i ComparisonOperator) Inverse() (ComparisonOperator, bool)

Inverse returns the inverse of this comparison operator if it exists. The second return value is true if it exists, and false otherwise.

func (ComparisonOperator) String Uses

func (i ComparisonOperator) String() string

type CompositeDatum Uses

type CompositeDatum interface {
    Datum
    // IsComposite returns true if this datum is not round-tripable in a key
    // encoding.
    IsComposite() bool
}

CompositeDatum is a Datum that may require composite encoding in indexes. Any Datum implementing this interface must also add itself to sqlbase/HasCompositeKeyEncoding.

type CompositeKeyMatchMethod Uses

type CompositeKeyMatchMethod int

CompositeKeyMatchMethod is the algorithm use when matching composite keys. See https://github.com/cockroachdb/cockroach/issues/20305 or https://www.postgresql.org/docs/11/sql-createtable.html for details on the different composite foreign key matching methods.

const (
    MatchSimple CompositeKeyMatchMethod = iota
    MatchFull
    MatchPartial // Note: PARTIAL not actually supported at this point.
)

The values for CompositeKeyMatchMethod.

func (CompositeKeyMatchMethod) String Uses

func (c CompositeKeyMatchMethod) String() string

type Constant Uses

type Constant interface {
    Expr
    // AvailableTypes returns the ordered set of types that the Constant is able to
    // be resolved into. The order of the type slice provides a notion of precedence,
    // with the first element in the ordering being the Constant's "natural type".
    AvailableTypes() []*types.T
    // DesirableTypes returns the ordered set of types that the constant would
    // prefer to be resolved into. As in AvailableTypes, the order of the returned
    // type slice provides a notion of precedence, with the first element in the
    // ordering being the Constant's "natural type." The function is meant to be
    // differentiated from AvailableTypes in that it will exclude certain types
    // that are possible, but not desirable.
    //
    // An example of this is a floating point numeric constant without a value
    // past the decimal point. It is possible to resolve this constant as a
    // decimal, but it is not desirable.
    DesirableTypes() []*types.T
    // ResolveAsType resolves the Constant as the Datum type specified, or returns an
    // error if the Constant could not be resolved as that type. The method should only
    // be passed a type returned from AvailableTypes and should never be called more than
    // once for a given Constant.
    ResolveAsType(*SemaContext, *types.T) (Datum, error)
}

Constant is an constant literal expression which may be resolved to more than one type.

type ConstantEvalVisitor Uses

type ConstantEvalVisitor struct {
    // contains filtered or unexported fields
}

ConstantEvalVisitor replaces constant TypedExprs with the result of Eval.

func MakeConstantEvalVisitor Uses

func MakeConstantEvalVisitor(ctx *EvalContext) ConstantEvalVisitor

MakeConstantEvalVisitor creates a ConstantEvalVisitor instance.

func (*ConstantEvalVisitor) Err Uses

func (v *ConstantEvalVisitor) Err() error

Err retrieves the error field in the ConstantEvalVisitor.

func (*ConstantEvalVisitor) VisitPost Uses

func (v *ConstantEvalVisitor) VisitPost(expr Expr) Expr

VisitPost implements the Visitor interface.

func (*ConstantEvalVisitor) VisitPre Uses

func (v *ConstantEvalVisitor) VisitPre(expr Expr) (recurse bool, newExpr Expr)

VisitPre implements the Visitor interface.

type ConstraintTableDef Uses

type ConstraintTableDef interface {
    TableDef
    // contains filtered or unexported methods
}

ConstraintTableDef represents a constraint definition within a CREATE TABLE statement.

type ControlJobs Uses

type ControlJobs struct {
    Jobs    *Select
    Command JobCommand
}

ControlJobs represents a PAUSE/RESUME/CANCEL JOBS statement.

func (*ControlJobs) Format Uses

func (n *ControlJobs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ControlJobs) StatementTag Uses

func (n *ControlJobs) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ControlJobs) StatementType Uses

func (*ControlJobs) StatementType() StatementType

StatementType implements the Statement interface.

func (*ControlJobs) String Uses

func (n *ControlJobs) String() string

type CopyFrom Uses

type CopyFrom struct {
    Table   TableName
    Columns NameList
    Stdin   bool
}

CopyFrom represents a COPY FROM statement.

func (*CopyFrom) Format Uses

func (node *CopyFrom) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CopyFrom) StatementTag Uses

func (*CopyFrom) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CopyFrom) StatementType Uses

func (*CopyFrom) StatementType() StatementType

StatementType implements the Statement interface.

func (*CopyFrom) String Uses

func (n *CopyFrom) String() string

type CreateChangefeed Uses

type CreateChangefeed struct {
    Targets TargetList
    SinkURI Expr
    Options KVOptions
}

CreateChangefeed represents a CREATE CHANGEFEED statement.

func (*CreateChangefeed) Format Uses

func (node *CreateChangefeed) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateChangefeed) StatementTag Uses

func (n *CreateChangefeed) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateChangefeed) StatementType Uses

func (*CreateChangefeed) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateChangefeed) String Uses

func (n *CreateChangefeed) String() string

type CreateDatabase Uses

type CreateDatabase struct {
    IfNotExists bool
    Name        Name
    Template    string
    Encoding    string
    Collate     string
    CType       string
}

CreateDatabase represents a CREATE DATABASE statement.

func (*CreateDatabase) Format Uses

func (node *CreateDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateDatabase) StatementTag Uses

func (*CreateDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateDatabase) StatementType Uses

func (*CreateDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateDatabase) String Uses

func (n *CreateDatabase) String() string

type CreateIndex Uses

type CreateIndex struct {
    Name        Name
    Table       TableName
    Unique      bool
    Inverted    bool
    IfNotExists bool
    Columns     IndexElemList
    // Extra columns to be stored together with the indexed ones as an optimization
    // for improved reading performance.
    Storing     NameList
    Interleave  *InterleaveDef
    PartitionBy *PartitionBy
}

CreateIndex represents a CREATE INDEX statement.

func (*CreateIndex) Format Uses

func (node *CreateIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateIndex) StatementTag Uses

func (*CreateIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateIndex) StatementType Uses

func (*CreateIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateIndex) String Uses

func (n *CreateIndex) String() string

type CreateRole Uses

type CreateRole struct {
    Name        Expr
    IfNotExists bool
}

CreateRole represents a CREATE ROLE statement.

func (*CreateRole) Format Uses

func (node *CreateRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateRole) StatementTag Uses

func (*CreateRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateRole) StatementType Uses

func (*CreateRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateRole) String Uses

func (n *CreateRole) String() string

type CreateSequence Uses

type CreateSequence struct {
    IfNotExists bool
    Name        TableName
    Options     SequenceOptions
}

CreateSequence represents a CREATE SEQUENCE statement.

func (*CreateSequence) Format Uses

func (node *CreateSequence) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateSequence) StatementTag Uses

func (*CreateSequence) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateSequence) StatementType Uses

func (*CreateSequence) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateSequence) String Uses

func (n *CreateSequence) String() string

type CreateStats Uses

type CreateStats struct {
    Name        Name
    ColumnNames NameList
    Table       TableExpr
    Options     CreateStatsOptions
}

CreateStats represents a CREATE STATISTICS statement.

func (*CreateStats) Format Uses

func (node *CreateStats) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateStats) StatementTag Uses

func (*CreateStats) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateStats) StatementType Uses

func (*CreateStats) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateStats) String Uses

func (n *CreateStats) String() string

type CreateStatsOptions Uses

type CreateStatsOptions struct {
    // Throttling enables throttling and indicates the fraction of time we are
    // idling (between 0 and 1).
    Throttling float64

    // AsOf performs a historical read at the given timestamp.
    // Note that the timestamp will be moved up during the operation if it gets
    // too old (in order to avoid problems with TTL expiration).
    AsOf AsOfClause
}

CreateStatsOptions contains options for CREATE STATISTICS.

func (*CreateStatsOptions) CombineWith Uses

func (o *CreateStatsOptions) CombineWith(other *CreateStatsOptions) error

CombineWith combines two options, erroring out if the two options contain incompatible settings.

func (*CreateStatsOptions) Empty Uses

func (o *CreateStatsOptions) Empty() bool

Empty returns true if no options were provided.

func (*CreateStatsOptions) Format Uses

func (o *CreateStatsOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CreateTable Uses

type CreateTable struct {
    IfNotExists bool
    Table       TableName
    Interleave  *InterleaveDef
    PartitionBy *PartitionBy
    // In CREATE...AS queries, Defs represents a list of ColumnTableDefs, one for
    // each column, and a ConstraintTableDef for each constraint on a subset of
    // these columns.
    Defs     TableDefs
    AsSource *Select
}

CreateTable represents a CREATE TABLE statement.

func (*CreateTable) As Uses

func (node *CreateTable) As() bool

As returns true if this table represents a CREATE TABLE ... AS statement, false otherwise.

func (*CreateTable) AsHasUserSpecifiedPrimaryKey Uses

func (node *CreateTable) AsHasUserSpecifiedPrimaryKey() bool

AsHasUserSpecifiedPrimaryKey returns true if a CREATE TABLE ... AS statement has a PRIMARY KEY constraint specified.

func (*CreateTable) Format Uses

func (node *CreateTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateTable) FormatBody Uses

func (node *CreateTable) FormatBody(ctx *FmtCtx)

FormatBody formats the "body" of the create table definition - everything but the CREATE TABLE tableName part.

func (*CreateTable) HoistConstraints Uses

func (node *CreateTable) HoistConstraints()

HoistConstraints finds column check and foreign key constraints defined inline with their columns and makes them table-level constraints, stored in n.Defs. For example, the foreign key constraint in

CREATE TABLE foo (a INT REFERENCES bar(a))

gets pulled into a top-level constraint like:

CREATE TABLE foo (a INT, FOREIGN KEY (a) REFERENCES bar(a))

Similarly, the CHECK constraint in

CREATE TABLE foo (a INT CHECK (a < 1), b INT)

gets pulled into a top-level constraint like:

CREATE TABLE foo (a INT, b INT, CHECK (a < 1))

Note that some SQL databases require that a constraint attached to a column to refer only to the column it is attached to. We follow Postgres' behavior, however, in omitting this restriction by blindly hoisting all column constraints. For example, the following table definition is accepted in CockroachDB and Postgres, but not necessarily other SQL databases:

CREATE TABLE foo (a INT CHECK (a < b), b INT)

Unique constraints are not hoisted.

func (*CreateTable) StatementTag Uses

func (n *CreateTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateTable) StatementType Uses

func (n *CreateTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateTable) String Uses

func (n *CreateTable) String() string

type CreateUser Uses

type CreateUser struct {
    Name        Expr
    Password    Expr // nil if no password specified
    IfNotExists bool
}

CreateUser represents a CREATE USER statement.

func (*CreateUser) Format Uses

func (node *CreateUser) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateUser) HasPassword Uses

func (node *CreateUser) HasPassword() bool

HasPassword returns if the CreateUser has a password.

func (*CreateUser) StatementTag Uses

func (*CreateUser) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateUser) StatementType Uses

func (*CreateUser) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateUser) String Uses

func (n *CreateUser) String() string

type CreateView Uses

type CreateView struct {
    Name        TableName
    ColumnNames NameList
    AsSource    *Select
}

CreateView represents a CREATE VIEW statement.

func (*CreateView) Format Uses

func (node *CreateView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateView) StatementTag Uses

func (*CreateView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateView) StatementType Uses

func (*CreateView) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateView) String Uses

func (n *CreateView) String() string

type DArray Uses

type DArray struct {
    ParamTyp *types.T
    Array    Datums
    // HasNulls is set to true if any of the datums within the array are null.
    // This is used in the binary array serialization format.
    HasNulls bool
    // HasNonNulls is set to true if any of the datums within the are non-null.
    // This is used in expression serialization (FmtParsable).
    HasNonNulls bool
    // contains filtered or unexported fields
}

DArray is the array Datum. Any Datum inserted into a DArray are treated as text during serialization.

func AsDArray Uses

func AsDArray(e Expr) (*DArray, bool)

AsDArray attempts to retrieve a *DArray from an Expr, returning a *DArray and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DArray wrapped by a *DOidWrapper is possible.

func MustBeDArray Uses

func MustBeDArray(e Expr) *DArray

MustBeDArray attempts to retrieve a *DArray from an Expr, panicking if the assertion fails.

func NewDArray Uses

func NewDArray(paramTyp *types.T) *DArray

NewDArray returns a DArray containing elements of the specified type.

func ParseDArrayFromString Uses

func ParseDArrayFromString(evalCtx *EvalContext, s string, t *types.T) (*DArray, error)

ParseDArrayFromString parses the string-form of constructing arrays, handling cases such as `'{1,2,3}'::INT[]`.

func (*DArray) AmbiguousFormat Uses

func (d *DArray) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DArray) Append Uses

func (d *DArray) Append(v Datum) error

Append appends a Datum to the array, whose parameterized type must be consistent with the type of the Datum.

func (*DArray) Compare Uses

func (d *DArray) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DArray) Eval Uses

func (t *DArray) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DArray) Format Uses

func (d *DArray) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DArray) IsMax Uses

func (d *DArray) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DArray) IsMin Uses

func (d *DArray) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DArray) Len Uses

func (d *DArray) Len() int

Len returns the length of the Datum array.

func (*DArray) Max Uses

func (d *DArray) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DArray) Min Uses

func (d *DArray) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DArray) Next Uses

func (d *DArray) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DArray) Prev Uses

func (d *DArray) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DArray) ResolvedType Uses

func (d *DArray) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DArray) Size Uses

func (d *DArray) Size() uintptr

Size implements the Datum interface.

func (*DArray) String Uses

func (node *DArray) String() string

func (*DArray) TypeCheck Uses

func (d *DArray) TypeCheck(_ *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DArray) Validate Uses

func (d *DArray) Validate() error

Validate checks that the given array is valid, for example, that it's not too big.

func (*DArray) Walk Uses

func (expr *DArray) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBitArray Uses

type DBitArray struct {
    bitarray.BitArray
}

DBitArray is the BIT/VARBIT Datum.

func AsDBitArray Uses

func AsDBitArray(e Expr) (*DBitArray, bool)

AsDBitArray attempts to retrieve a *DBitArray from an Expr, returning a *DBitArray and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions.

func MakeDBitArray Uses

func MakeDBitArray(bitLen uint) DBitArray

MakeDBitArray returns a DBitArray.

func MustBeDBitArray Uses

func MustBeDBitArray(e Expr) *DBitArray

MustBeDBitArray attempts to retrieve a DBitArray from an Expr, panicking if the assertion fails.

func NewDBitArray Uses

func NewDBitArray(bitLen uint) *DBitArray

NewDBitArray returns a DBitArray.

func NewDBitArrayFromInt Uses

func NewDBitArrayFromInt(i int64, width uint) (*DBitArray, error)

NewDBitArrayFromInt creates a bit array from the specified integer at the specified width. If the width is zero, only positive integers can be converted. If the width is nonzero, the value is truncated to that width. Negative values are encoded using two's complement.

func ParseDBitArray Uses

func ParseDBitArray(s string) (*DBitArray, error)

ParseDBitArray parses a string representation of binary digits.

func (*DBitArray) AmbiguousFormat Uses

func (*DBitArray) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBitArray) AsDInt Uses

func (d *DBitArray) AsDInt(n uint) *DInt

AsDInt computes the integer value of the given bit array. The value is assumed to be encoded using two's complement. The result is truncated to the given integer number of bits, if specified. The given width must be 64 or smaller. The results are undefined if n is greater than 64.

func (*DBitArray) Compare Uses

func (d *DBitArray) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DBitArray) Eval Uses

func (t *DBitArray) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DBitArray) Format Uses

func (d *DBitArray) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBitArray) IsMax Uses

func (d *DBitArray) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DBitArray) IsMin Uses

func (d *DBitArray) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DBitArray) Max Uses

func (d *DBitArray) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DBitArray) Min Uses

func (d *DBitArray) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DBitArray) Next Uses

func (d *DBitArray) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DBitArray) Prev Uses

func (d *DBitArray) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DBitArray) ResolvedType Uses

func (*DBitArray) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBitArray) Size Uses

func (d *DBitArray) Size() uintptr

Size implements the Datum interface.

func (*DBitArray) String Uses

func (node *DBitArray) String() string

func (*DBitArray) TypeCheck Uses

func (d *DBitArray) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBitArray) Walk Uses

func (expr *DBitArray) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBool Uses

type DBool bool

DBool is the boolean Datum.

func AsDBool Uses

func AsDBool(e Expr) (DBool, bool)

AsDBool attempts to retrieve a *DBool from an Expr, returning a *DBool and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions.

func GetBool Uses

func GetBool(d Datum) (DBool, error)

GetBool gets DBool or an error (also treats NULL as false, not an error).

func MakeDBool Uses

func MakeDBool(d DBool) *DBool

MakeDBool converts its argument to a *DBool, returning either DBoolTrue or DBoolFalse.

func MustBeDBool Uses

func MustBeDBool(e Expr) DBool

MustBeDBool attempts to retrieve a DBool from an Expr, panicking if the assertion fails.

func ParseDBool Uses

func ParseDBool(s string) (*DBool, error)

ParseDBool parses and returns the *DBool Datum value represented by the provided string, or an error if parsing is unsuccessful. See https://github.com/postgres/postgres/blob/90627cf98a8e7d0531789391fd798c9bfcc3bc1a/src/backend/utils/adt/bool.c#L36

func (*DBool) AmbiguousFormat Uses

func (*DBool) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBool) Compare Uses

func (d *DBool) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DBool) Eval Uses

func (t *DBool) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DBool) Format Uses

func (d *DBool) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBool) IsMax Uses

func (d *DBool) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DBool) IsMin Uses

func (d *DBool) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DBool) Max Uses

func (d *DBool) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DBool) Min Uses

func (d *DBool) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DBool) Next Uses

func (*DBool) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DBool) Prev Uses

func (*DBool) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DBool) ResolvedType Uses

func (*DBool) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBool) Size Uses

func (d *DBool) Size() uintptr

Size implements the Datum interface.

func (*DBool) String Uses

func (node *DBool) String() string

func (*DBool) TypeCheck Uses

func (d *DBool) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBool) Walk Uses

func (expr *DBool) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBytes Uses

type DBytes string

DBytes is the bytes Datum. The underlying type is a string because we want the immutability, but this may contain arbitrary bytes.

func AsDBytes Uses

func AsDBytes(e Expr) (DBytes, bool)

AsDBytes attempts to convert an Expr into a DBytes, returning a flag indicating whether it was successful.

func MustBeDBytes Uses

func MustBeDBytes(e Expr) DBytes

MustBeDBytes attempts to convert an Expr into a DBytes, panicking if unsuccessful.

func NewDBytes Uses

func NewDBytes(d DBytes) *DBytes

NewDBytes is a helper routine to create a *DBytes initialized from its argument.

func ParseDByte Uses

func ParseDByte(s string) (*DBytes, error)

ParseDByte parses a string representation of hex encoded binary data. It supports both the hex format, with "\x" followed by a string of hexadecimal digits (the "\x" prefix occurs just once at the beginning), and the escaped format, which supports "\\" and octal escapes.

func (*DBytes) AmbiguousFormat Uses

func (*DBytes) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBytes) Compare Uses

func (d *DBytes) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DBytes) Eval Uses

func (t *DBytes) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DBytes) Format Uses

func (d *DBytes) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBytes) IsMax Uses

func (*DBytes) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DBytes) IsMin Uses

func (d *DBytes) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DBytes) Max Uses

func (d *DBytes) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DBytes) Min Uses

func (d *DBytes) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DBytes) Next Uses

func (d *DBytes) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DBytes) Prev Uses

func (d *DBytes) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DBytes) ResolvedType Uses

func (*DBytes) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBytes) Size Uses

func (d *DBytes) Size() uintptr

Size implements the Datum interface.

func (*DBytes) String Uses

func (node *DBytes) String() string

func (*DBytes) TypeCheck Uses

func (d *DBytes) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBytes) Walk Uses

func (expr *DBytes) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DCollatedString Uses

type DCollatedString struct {
    Contents string
    Locale   string
    // Key is the collation key.
    Key []byte
}

DCollatedString is the Datum for strings with a locale. The struct members are intended to be immutable.

func NewDCollatedString Uses

func NewDCollatedString(
    contents string, locale string, env *CollationEnvironment,
) *DCollatedString

NewDCollatedString is a helper routine to create a *DCollatedString. Panics if locale is invalid. Not safe for concurrent use.

func (*DCollatedString) AmbiguousFormat Uses

func (*DCollatedString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DCollatedString) Compare Uses

func (d *DCollatedString) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DCollatedString) Eval Uses

func (t *DCollatedString) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DCollatedString) Format Uses

func (d *DCollatedString) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DCollatedString) IsComposite Uses

func (d *DCollatedString) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DCollatedString) IsMax Uses

func (*DCollatedString) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DCollatedString) IsMin Uses

func (d *DCollatedString) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DCollatedString) Max Uses

func (d *DCollatedString) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DCollatedString) Min Uses

func (d *DCollatedString) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DCollatedString) Next Uses

func (d *DCollatedString) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DCollatedString) Prev Uses

func (d *DCollatedString) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DCollatedString) ResolvedType Uses

func (d *DCollatedString) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DCollatedString) Size Uses

func (d *DCollatedString) Size() uintptr

Size implements the Datum interface.

func (*DCollatedString) String Uses

func (node *DCollatedString) String() string

func (*DCollatedString) TypeCheck Uses

func (d *DCollatedString) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DCollatedString) Walk Uses

func (expr *DCollatedString) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DDate Uses

type DDate struct {
    pgdate.Date
}

DDate is the date Datum represented as the number of days after the Unix epoch.

func MakeDDate Uses

func MakeDDate(d pgdate.Date) DDate

MakeDDate makes a DDate from a pgdate.Date.

func NewDDate Uses

func NewDDate(d pgdate.Date) *DDate

NewDDate is a helper routine to create a *DDate initialized from its argument.

func NewDDateFromTime Uses

func NewDDateFromTime(t time.Time) (*DDate, error)

NewDDateFromTime constructs a *DDate from a time.Time.

func ParseDDate Uses

func ParseDDate(ctx ParseTimeContext, s string) (*DDate, error)

ParseDDate parses and returns the *DDate Datum value represented by the provided string in the provided location, or an error if parsing is unsuccessful.

func (*DDate) AmbiguousFormat Uses

func (*DDate) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDate) Compare Uses

func (d *DDate) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DDate) Eval Uses

func (t *DDate) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DDate) Format Uses

func (d *DDate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DDate) IsMax Uses

func (d *DDate) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DDate) IsMin Uses

func (d *DDate) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DDate) Max Uses

func (d *DDate) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DDate) Min Uses

func (d *DDate) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DDate) Next Uses

func (d *DDate) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DDate) Prev Uses

func (d *DDate) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DDate) ResolvedType Uses

func (*DDate) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DDate) Size Uses

func (d *DDate) Size() uintptr

Size implements the Datum interface.

func (*DDate) String Uses

func (node *DDate) String() string

func (*DDate) TypeCheck Uses

func (d *DDate) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DDate) Walk Uses

func (expr *DDate) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DDecimal Uses

type DDecimal struct {
    apd.Decimal
}

DDecimal is the decimal Datum.

var DecimalOne DDecimal

DecimalOne represents the constant 1 as DECIMAL.

func ParseDDecimal Uses

func ParseDDecimal(s string) (*DDecimal, error)

ParseDDecimal parses and returns the *DDecimal Datum value represented by the provided string, or an error if parsing is unsuccessful.

func TimestampToDecimal Uses

func TimestampToDecimal(ts hlc.Timestamp) *DDecimal

TimestampToDecimal converts the logical timestamp into a decimal value with the number of nanoseconds in the integer part and the logical counter in the decimal part.

func (*DDecimal) AmbiguousFormat Uses

func (*DDecimal) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDecimal) Compare Uses

func (d *DDecimal) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DDecimal) Eval Uses

func (t *DDecimal) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DDecimal) Format Uses

func (d *DDecimal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DDecimal) IsComposite Uses

func (d *DDecimal) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DDecimal) IsMax Uses

func (d *DDecimal) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DDecimal) IsMin Uses

func (d *DDecimal) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DDecimal) Max Uses

func (d *DDecimal) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DDecimal) Min Uses

func (d *DDecimal) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DDecimal) Next Uses

func (d *DDecimal) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DDecimal) Prev Uses

func (d *DDecimal) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DDecimal) ResolvedType Uses

func (*DDecimal) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DDecimal) SetString Uses

func (d *DDecimal) SetString(s string) error

SetString sets d to s. Any non-standard NaN values are converted to a normal NaN. Any negative zero is converted to positive.

func (*DDecimal) Size Uses

func (d *DDecimal) Size() uintptr

Size implements the Datum interface.

func (*DDecimal) String Uses

func (node *DDecimal) String() string

func (*DDecimal) TypeCheck Uses

func (d *DDecimal) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DDecimal) Walk Uses

func (expr *DDecimal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DFloat Uses

type DFloat float64

DFloat is the float Datum.

func NewDFloat Uses

func NewDFloat(d DFloat) *DFloat

NewDFloat is a helper routine to create a *DFloat initialized from its argument.

func ParseDFloat Uses

func ParseDFloat(s string) (*DFloat, error)

ParseDFloat parses and returns the *DFloat Datum value represented by the provided string, or an error if parsing is unsuccessful.

func (*DFloat) AmbiguousFormat Uses

func (*DFloat) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DFloat) Compare Uses

func (d *DFloat) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DFloat) Eval Uses

func (t *DFloat) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DFloat) Format Uses

func (d *DFloat) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DFloat) IsComposite Uses

func (d *DFloat) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DFloat) IsMax Uses

func (d *DFloat) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DFloat) IsMin Uses

func (d *DFloat) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DFloat) Max Uses

func (d *DFloat) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DFloat) Min Uses

func (d *DFloat) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DFloat) Next Uses

func (d *DFloat) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DFloat) Prev Uses

func (d *DFloat) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DFloat) ResolvedType Uses

func (*DFloat) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DFloat) Size Uses

func (d *DFloat) Size() uintptr

Size implements the Datum interface.

func (*DFloat) String Uses

func (node *DFloat) String() string

func (*DFloat) TypeCheck Uses

func (d *DFloat) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DFloat) Walk Uses

func (expr *DFloat) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DIPAddr Uses

type DIPAddr struct {
    ipaddr.IPAddr
}

DIPAddr is the IPAddr Datum.

func AsDIPAddr Uses

func AsDIPAddr(e Expr) (DIPAddr, bool)

AsDIPAddr attempts to retrieve a *DIPAddr from an Expr, returning a *DIPAddr and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DIPAddr wrapped by a *DOidWrapper is possible.

func MustBeDIPAddr Uses

func MustBeDIPAddr(e Expr) DIPAddr

MustBeDIPAddr attempts to retrieve a DIPAddr from an Expr, panicking if the assertion fails.

func NewDIPAddr Uses

func NewDIPAddr(d DIPAddr) *DIPAddr

NewDIPAddr is a helper routine to create a *DIPAddr initialized from its argument.

func ParseDIPAddrFromINetString Uses

func ParseDIPAddrFromINetString(s string) (*DIPAddr, error)

ParseDIPAddrFromINetString parses and returns the *DIPAddr Datum value represented by the provided input INet string, or an error.

func (*DIPAddr) AmbiguousFormat Uses

func (*DIPAddr) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DIPAddr) Compare Uses

func (d *DIPAddr) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DIPAddr) Eval Uses

func (t *DIPAddr) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DIPAddr) Format Uses

func (d *DIPAddr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DIPAddr) IsMax Uses

func (d *DIPAddr) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DIPAddr) IsMin Uses

func (d *DIPAddr) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DIPAddr) Max Uses

func (*DIPAddr) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DIPAddr) Min Uses

func (*DIPAddr) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DIPAddr) Next Uses

func (d *DIPAddr) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DIPAddr) Prev Uses

func (d *DIPAddr) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DIPAddr) ResolvedType Uses

func (*DIPAddr) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DIPAddr) Size Uses

func (d *DIPAddr) Size() uintptr

Size implements the Datum interface.

func (*DIPAddr) String Uses

func (node *DIPAddr) String() string

func (*DIPAddr) TypeCheck Uses

func (d *DIPAddr) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DIPAddr) Walk Uses

func (expr *DIPAddr) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DInt Uses

type DInt int64

DInt is the int Datum.

func AsDInt Uses

func AsDInt(e Expr) (DInt, bool)

AsDInt attempts to retrieve a DInt from an Expr, returning a DInt and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DInt wrapped by a *DOidWrapper is possible.

func IntPow Uses

func IntPow(x, y DInt) (*DInt, error)

IntPow computes the value of x^y.

func MustBeDInt Uses

func MustBeDInt(e Expr) DInt

MustBeDInt attempts to retrieve a DInt from an Expr, panicking if the assertion fails.

func NewDInt Uses

func NewDInt(d DInt) *DInt

NewDInt is a helper routine to create a *DInt initialized from its argument.

func ParseDInt Uses

func ParseDInt(s string) (*DInt, error)

ParseDInt parses and returns the *DInt Datum value represented by the provided string, or an error if parsing is unsuccessful.

func (*DInt) AmbiguousFormat Uses

func (*DInt) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInt) Compare Uses

func (d *DInt) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DInt) Eval Uses

func (t *DInt) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DInt) Format Uses

func (d *DInt) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DInt) IsMax Uses

func (d *DInt) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DInt) IsMin Uses

func (d *DInt) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DInt) Max Uses

func (d *DInt) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DInt) Min Uses

func (d *DInt) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DInt) Next Uses

func (d *DInt) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DInt) Prev Uses

func (d *DInt) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DInt) ResolvedType Uses

func (*DInt) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DInt) Size Uses

func (d *DInt) Size() uintptr

Size implements the Datum interface.

func (*DInt) String Uses

func (node *DInt) String() string

func (*DInt) TypeCheck Uses

func (d *DInt) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DInt) Walk Uses

func (expr *DInt) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DInterval Uses

type DInterval struct {
    duration.Duration
}

DInterval is the interval Datum.

func ParseDInterval Uses

func ParseDInterval(s string) (*DInterval, error)

ParseDInterval parses and returns the *DInterval Datum value represented by the provided string, or an error if parsing is unsuccessful.

func ParseDIntervalWithField Uses

func ParseDIntervalWithField(s string, field DurationField) (*DInterval, error)

ParseDIntervalWithField is like ParseDInterval, but it also takes a DurationField that both specifies the units for unitless, numeric intervals and also specifies the precision of the interval. Any precision in the input interval that's higher than the DurationField value will be truncated downward.

func (*DInterval) AmbiguousFormat Uses

func (*DInterval) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInterval) Compare Uses

func (d *DInterval) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DInterval) Eval Uses

func (t *DInterval) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DInterval) Format Uses

func (d *DInterval) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DInterval) IsMax Uses

func (d *DInterval) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DInterval) IsMin Uses

func (d *DInterval) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DInterval) Max Uses

func (d *DInterval) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DInterval) Min Uses

func (d *DInterval) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DInterval) Next Uses

func (d *DInterval) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DInterval) Prev Uses

func (d *DInterval) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DInterval) ResolvedType Uses

func (*DInterval) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DInterval) Size Uses

func (d *DInterval) Size() uintptr

Size implements the Datum interface.

func (*DInterval) String Uses

func (node *DInterval) String() string

func (*DInterval) TypeCheck Uses

func (d *DInterval) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DInterval) ValueAsString Uses

func (d *DInterval) ValueAsString() string

ValueAsString returns the interval as a string (e.g. "1h2m").

func (*DInterval) Walk Uses

func (expr *DInterval) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DJSON Uses

type DJSON struct{ json.JSON }

DJSON is the JSON Datum.

func AsDJSON Uses

func AsDJSON(e Expr) (*DJSON, bool)

AsDJSON attempts to retrieve a *DJSON from an Expr, returning a *DJSON and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DJSON wrapped by a *DOidWrapper is possible.

func MustBeDJSON Uses

func MustBeDJSON(e Expr) DJSON

MustBeDJSON attempts to retrieve a DJSON from an Expr, panicking if the assertion fails.

func NewDJSON Uses

func NewDJSON(j json.JSON) *DJSON

NewDJSON is a helper routine to create a DJSON initialized from its argument.

func (*DJSON) AmbiguousFormat Uses

func (*DJSON) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DJSON) Compare Uses

func (d *DJSON) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DJSON) Eval Uses

func (t *DJSON) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*DJSON) Format Uses

func (d *DJSON) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DJSON) IsMax Uses

func (d *DJSON) IsMax(_ *EvalContext) bool

IsMax implements the Datum interface.

func (*DJSON) IsMin Uses

func (d *DJSON) IsMin(_ *EvalContext) bool

IsMin implements the Datum interface.

func (*DJSON) Max Uses

func (d *DJSON) Max(_ *EvalContext) (Datum, bool)

Max implements the Datum interface.

func (*DJSON) Min Uses

func (d *DJSON) Min(_ *EvalContext) (Datum, bool)

Min implements the Datum interface.

func (*DJSON) Next Uses

func (d *DJSON) Next(_ *EvalContext) (Datum, bool)

Next implements the Datum interface.

func (*DJSON) Prev Uses

func (d *DJSON) Prev(_ *EvalContext) (Datum, bool)

Prev implements the Datum interface.

func (*DJSON) ResolvedType Uses

func (*DJSON) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DJSON) Size Uses

func (d *DJSON) Size() uintptr

Size implements the Datum interface. TODO(justin): is this a frequently-called method? Should we be caching the computed size?

func (*DJSON) String Uses

func (node *DJSON) String() string

func (*DJSON) TypeCheck Uses

func (d *DJSON) TypeCheck(_ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DJSON) Walk Uses

func (expr *DJSON) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DOid Uses

type DOid struct {
    // A DOid embeds a DInt, the underlying integer OID for this OID datum.
    DInt
    // contains filtered or unexported fields
}

DOid is the Postgres OID datum. It can represent either an OID type or any of the reg* types, such as regproc or regclass.