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_database.go alter_index.go alter_schema.go alter_sequence.go alter_table.go alter_type.go analyze.go annotation.go as_of.go backup.go casts.go changefeed.go col_name.go comment_on_column.go comment_on_database.go comment_on_index.go comment_on_table.go constant.go constant_eval.go constants.go copy.go create.go createtypevariety_string.go datum.go decimal.go delete.go discard.go drop.go drop_owned_by.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 object_name.go operators.go overload.go parse_array.go parse_string.go persistence.go pgwire_encode.go placeholders.go prepare.go pretty.go reassign_owned_by.go regexp_cache.go region.go rename.go returning.go revoke.go run_control.go schedule.go scrub.go select.go set.go show.go split.go statementtype_string.go stmt.go survive.go table_name.go table_pattern.go table_ref.go testutils.go time.go truncate.go txn.go type_check.go type_name.go union.go update.go values.go var_name.go volatility.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 (
    // SizeOfDatum is the memory size of a Datum reference.
    SizeOfDatum = int64(unsafe.Sizeof(Datum(nil)))
    // SizeOfDatums is the memory size of a Datum slice.
    SizeOfDatums = int64(unsafe.Sizeof(Datums(nil)))
)
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 = sessiondata.PublicSchemaName
    // 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 FollowerReadTimestampExperimentalFunctionName = "experimental_follower_read_timestamp"

FollowerReadTimestampExperimentalFunctionName is the name of the old "experimental_" function, which we keep for backwards compatibility.

const FollowerReadTimestampFunctionName = "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 LikeTableOptAll = ^likeTableOptInvalid

LikeTableOptAll is the full LikeTableOpt bitmap.

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 NoColumnIdx = -1

NoColumnIdx is a special value that can be used as a "column index" to indicate that the column is not present.

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.StringArray,
        types.IntArray,
        types.FloatArray,
        types.DecimalArray,
        types.BoolArray,
        types.Box2D,
        types.Geography,
        types.Geometry,
        types.Time,
        types.TimeTZ,
        types.Timestamp,
        types.TimestampTZ,
        types.Interval,
        types.Uuid,
        types.DateArray,
        types.TimeArray,
        types.TimeTZArray,
        types.TimestampArray,
        types.TimestampTZArray,
        types.IntervalArray,
        types.UUIDArray,
        types.INet,
        types.Jsonb,
        types.VarBit,
        types.AnyEnum,
        types.INetArray,
        types.VarBitArray,
    }
    // StrValAvailBytes is the set of types convertible to byte array.
    StrValAvailBytes = []*types.T{types.Bytes, types.Uuid, types.String, types.AnyEnum}
)
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)

    // DTimeMaxTimeRegex is a compiled regex for parsing the 24:00 time value.
    DTimeMaxTimeRegex = regexp.MustCompile(`^([0-9-]*(\s|T))?\s*24:00(:00(.0+)?)?\s*$`)

    // MaxSupportedTime is the maximum time we support parsing.
    MaxSupportedTime = timeutil.Unix(9224318016000-1, 999999000) // 294276-12-31 23:59:59.999999
    // MinSupportedTime is the minimum time we support parsing.
    MinSupportedTime = timeutil.Unix(-210866803200, 0) // 4714-11-24 00:00:00+00 BC
)
var (

    // DMinTimeTZ is the min TimeTZ.
    DMinTimeTZ = NewDTimeTZFromOffset(timeofday.Min, timetz.MinTimeTZOffsetSecs)
    // DMaxTimeTZ is the max TimeTZ.
    DMaxTimeTZ = NewDTimeTZFromOffset(timeofday.Max, timetz.MaxTimeTZOffsetSecs)
)
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 (
    // ErrIntOutOfRange is reported when integer arithmetic overflows.
    ErrIntOutOfRange = pgerror.New(pgcode.NumericValueOutOfRange, "integer out of range")
    // ErrFloatOutOfRange is reported when float arithmetic overflows.
    ErrFloatOutOfRange = pgerror.New(pgcode.NumericValueOutOfRange, "float out of range")

    // ErrDivByZero is reported on a division by zero.
    ErrDivByZero = pgerror.New(pgcode.DivisionByZero, "division by zero")

    // ErrShiftArgOutOfRange is reported when a shift argument is out of range.
    ErrShiftArgOutOfRange = pgerror.New(pgcode.InvalidParameterValue, "shift argument out of range")
)
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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(r))
                _, err := ExactCtx.Add(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(l))
                _, err := ExactCtx.Add(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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

            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Time,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTime, err := left.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := time.Duration(*right.(*DTime)) * time.Microsecond
                return MakeDTimestamp(leftTime.Add(t), time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Time,
            RightType:  types.Date,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rightTime, err := right.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := time.Duration(*left.(*DTime)) * time.Microsecond
                return MakeDTimestamp(rightTime.Add(t), time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.TimeTZ,
            ReturnType: types.TimestampTZ,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTime, err := left.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := leftTime.Add(right.(*DTimeTZ).ToDuration())
                return MakeDTimestampTZ(t, time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.TimeTZ,
            RightType:  types.Date,
            ReturnType: types.TimestampTZ,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rightTime, err := right.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := rightTime.Add(left.(*DTimeTZ).ToDuration())
                return MakeDTimestampTZ(t, time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.TimeTZ,
            RightType:  types.Interval,
            ReturnType: types.TimeTZ,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := left.(*DTimeTZ)
                duration := right.(*DInterval).Duration
                return NewDTimeTZFromOffset(t.Add(duration), t.OffsetSecs), nil
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.TimeTZ,
            ReturnType: types.TimeTZ,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := right.(*DTimeTZ)
                duration := left.(*DInterval).Duration
                return NewDTimeTZFromOffset(t.Add(duration), t.OffsetSecs), nil
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.Interval,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(
                    left.(*DTimestamp).Time, right.(*DInterval).Duration), time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Timestamp,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(
                    right.(*DTimestamp).Time, left.(*DInterval).Duration), time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.TimestampTZ,
            RightType:  types.Interval,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {

                t := duration.Add(left.(*DTimestampTZ).Time.In(ctx.GetLocation()), right.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond)
            },
            Volatility: VolatilityStable,
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.TimestampTZ,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {

                t := duration.Add(right.(*DTimestampTZ).Time.In(ctx.GetLocation()), left.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond)
            },
            Volatility: VolatilityStable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Interval,
            ReturnType: types.Timestamp,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTime, err := left.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := duration.Add(leftTime, right.(*DInterval).Duration)
                return MakeDTimestamp(t, time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Interval,
            RightType:  types.Date,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rightTime, err := right.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := duration.Add(rightTime, left.(*DInterval).Duration)
                return MakeDTimestamp(t, time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(r))
                _, err := ExactCtx.Sub(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(l))
                _, err := ExactCtx.Sub(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Time,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTime, err := left.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := time.Duration(*right.(*DTime)) * time.Microsecond
                return MakeDTimestamp(leftTime.Add(-1*t), time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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.MakeNormalizedDuration(nanos, 0, 0)}, nil
            },
            Volatility: VolatilityImmutable,
        },
        &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.MakeNormalizedDuration(nanos, 0, 0)}, nil
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.TimestampTZ,
            ReturnType: types.Interval,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {

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

                stripped, err := left.(*DTimestampTZ).stripTimeZone(ctx)
                if err != nil {
                    return nil, err
                }
                nanos := stripped.Sub(right.(*DTimestamp).Time).Nanoseconds()
                return &DInterval{Duration: duration.MakeNormalizedDuration(nanos, 0, 0)}, nil
            },
            Volatility: VolatilityStable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.TimeTZ,
            RightType:  types.Interval,
            ReturnType: types.TimeTZ,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := left.(*DTimeTZ)
                duration := right.(*DInterval).Duration
                return NewDTimeTZFromOffset(t.Add(duration.Mul(-1)), t.OffsetSecs), nil
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.Timestamp,
            RightType:  types.Interval,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(
                    left.(*DTimestamp).Time, right.(*DInterval).Duration.Mul(-1)), time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &BinOp{
            LeftType:   types.TimestampTZ,
            RightType:  types.Interval,
            ReturnType: types.TimestampTZ,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(
                    left.(*DTimestampTZ).Time.In(ctx.GetLocation()),
                    right.(*DInterval).Duration.Mul(-1),
                )
                return MakeDTimestampTZ(t, time.Microsecond)
            },
            Volatility: VolatilityStable,
        },
        &BinOp{
            LeftType:   types.Date,
            RightType:  types.Interval,
            ReturnType: types.Timestamp,
            Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTime, err := left.(*DDate).ToTime()
                if err != nil {
                    return nil, err
                }
                t := duration.Add(leftTime, right.(*DInterval).Duration.Mul(-1))
                return MakeDTimestamp(t, time.Microsecond)
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },

        &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.SetInt64(int64(r))
                _, err := ExactCtx.Mul(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(l))
                _, err := ExactCtx.Mul(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    Div: {
        &BinOp{
            LeftType:   types.Int,
            RightType:  types.Int,
            ReturnType: types.Decimal,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                if rInt == 0 {
                    return nil, ErrDivByZero
                }
                div := ctx.getTmpDec().SetInt64(int64(rInt))
                dd := &DDecimal{}
                dd.SetInt64(int64(MustBeDInt(left)))
                _, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, div)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
                if r.IsZero() {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                _, err := DecimalCtx.Quo(&dd.Decimal, l, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(r))
                _, err := DecimalCtx.Quo(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.IsZero() {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                dd.SetInt64(int64(l))
                _, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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))
                if r == 0.0 {
                    return nil, ErrDivByZero
                }
                return NewDFloat(DFloat(math.Trunc(l / r))), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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
                if r.IsZero() {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, l, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(r))
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.IsZero() {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                dd.SetInt64(int64(l))
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
    },

    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, ErrDivByZero
                }
                return NewDInt(MustBeDInt(left) % r), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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))
                if r == 0.0 {
                    return nil, ErrDivByZero
                }
                return NewDFloat(DFloat(math.Mod(l, r))), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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
                if r.IsZero() {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, l, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(r))
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.IsZero() {
                    return nil, ErrDivByZero
                }
                dd := &DDecimal{}
                dd.SetInt64(int64(l))
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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, ErrShiftArgOutOfRange
                }
                return NewDInt(MustBeDInt(left) << uint(rval)), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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, ErrShiftArgOutOfRange
                }
                return NewDInt(MustBeDInt(left) >> uint(rval)), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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))
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(r))
                _, err := DecimalCtx.Pow(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
        &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.SetInt64(int64(l))
                _, err := DecimalCtx.Pow(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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))
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
    },
}

BinOps contains the binary operations indexed by operation type.

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

        makeEqFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
        makeEqFn(types.Bool, types.Bool, VolatilityLeakProof),
        makeEqFn(types.Bytes, types.Bytes, VolatilityLeakProof),
        makeEqFn(types.Date, types.Date, VolatilityLeakProof),
        makeEqFn(types.Decimal, types.Decimal, VolatilityImmutable),

        makeEqFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),
        makeEqFn(types.Float, types.Float, VolatilityLeakProof),
        makeEqFn(types.Box2D, types.Box2D, VolatilityLeakProof),
        makeEqFn(types.Geography, types.Geography, VolatilityLeakProof),
        makeEqFn(types.Geometry, types.Geometry, VolatilityLeakProof),
        makeEqFn(types.INet, types.INet, VolatilityLeakProof),
        makeEqFn(types.Int, types.Int, VolatilityLeakProof),
        makeEqFn(types.Interval, types.Interval, VolatilityLeakProof),
        makeEqFn(types.Jsonb, types.Jsonb, VolatilityImmutable),
        makeEqFn(types.Oid, types.Oid, VolatilityLeakProof),
        makeEqFn(types.String, types.String, VolatilityLeakProof),
        makeEqFn(types.Time, types.Time, VolatilityLeakProof),
        makeEqFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
        makeEqFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
        makeEqFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
        makeEqFn(types.Uuid, types.Uuid, VolatilityLeakProof),
        makeEqFn(types.VarBit, types.VarBit, VolatilityLeakProof),

        makeEqFn(types.Date, types.Timestamp, VolatilityImmutable),
        makeEqFn(types.Date, types.TimestampTZ, VolatilityStable),
        makeEqFn(types.Decimal, types.Float, VolatilityLeakProof),
        makeEqFn(types.Decimal, types.Int, VolatilityLeakProof),
        makeEqFn(types.Float, types.Decimal, VolatilityLeakProof),
        makeEqFn(types.Float, types.Int, VolatilityLeakProof),
        makeEqFn(types.Int, types.Decimal, VolatilityLeakProof),
        makeEqFn(types.Int, types.Float, VolatilityLeakProof),
        makeEqFn(types.Int, types.Oid, VolatilityLeakProof),
        makeEqFn(types.Oid, types.Int, VolatilityLeakProof),
        makeEqFn(types.Timestamp, types.Date, VolatilityImmutable),
        makeEqFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
        makeEqFn(types.TimestampTZ, types.Date, VolatilityStable),
        makeEqFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
        makeEqFn(types.Time, types.TimeTZ, VolatilityStable),
        makeEqFn(types.TimeTZ, types.Time, VolatilityStable),

        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    LT: {

        makeLtFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
        makeLtFn(types.Bool, types.Bool, VolatilityLeakProof),
        makeLtFn(types.Bytes, types.Bytes, VolatilityLeakProof),
        makeLtFn(types.Date, types.Date, VolatilityLeakProof),
        makeLtFn(types.Decimal, types.Decimal, VolatilityImmutable),
        makeLtFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),

        makeLtFn(types.Float, types.Float, VolatilityLeakProof),
        makeLtFn(types.Box2D, types.Box2D, VolatilityLeakProof),
        makeLtFn(types.Geography, types.Geography, VolatilityLeakProof),
        makeLtFn(types.Geometry, types.Geometry, VolatilityLeakProof),
        makeLtFn(types.INet, types.INet, VolatilityLeakProof),
        makeLtFn(types.Int, types.Int, VolatilityLeakProof),
        makeLtFn(types.Interval, types.Interval, VolatilityLeakProof),
        makeLtFn(types.Oid, types.Oid, VolatilityLeakProof),
        makeLtFn(types.String, types.String, VolatilityLeakProof),
        makeLtFn(types.Time, types.Time, VolatilityLeakProof),
        makeLtFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
        makeLtFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
        makeLtFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
        makeLtFn(types.Uuid, types.Uuid, VolatilityLeakProof),
        makeLtFn(types.VarBit, types.VarBit, VolatilityLeakProof),

        makeLtFn(types.Date, types.Timestamp, VolatilityImmutable),
        makeLtFn(types.Date, types.TimestampTZ, VolatilityStable),
        makeLtFn(types.Decimal, types.Float, VolatilityLeakProof),
        makeLtFn(types.Decimal, types.Int, VolatilityLeakProof),
        makeLtFn(types.Float, types.Decimal, VolatilityLeakProof),
        makeLtFn(types.Float, types.Int, VolatilityLeakProof),
        makeLtFn(types.Int, types.Decimal, VolatilityLeakProof),
        makeLtFn(types.Int, types.Float, VolatilityLeakProof),
        makeLtFn(types.Int, types.Oid, VolatilityLeakProof),
        makeLtFn(types.Oid, types.Int, VolatilityLeakProof),
        makeLtFn(types.Timestamp, types.Date, VolatilityImmutable),
        makeLtFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
        makeLtFn(types.TimestampTZ, types.Date, VolatilityStable),
        makeLtFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
        makeLtFn(types.Time, types.TimeTZ, VolatilityStable),
        makeLtFn(types.TimeTZ, types.Time, VolatilityStable),

        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    LE: {

        makeLeFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
        makeLeFn(types.Bool, types.Bool, VolatilityLeakProof),
        makeLeFn(types.Bytes, types.Bytes, VolatilityLeakProof),
        makeLeFn(types.Date, types.Date, VolatilityLeakProof),
        makeLeFn(types.Decimal, types.Decimal, VolatilityImmutable),

        makeLeFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),
        makeLeFn(types.Float, types.Float, VolatilityLeakProof),
        makeLeFn(types.Box2D, types.Box2D, VolatilityLeakProof),
        makeLeFn(types.Geography, types.Geography, VolatilityLeakProof),
        makeLeFn(types.Geometry, types.Geometry, VolatilityLeakProof),
        makeLeFn(types.INet, types.INet, VolatilityLeakProof),
        makeLeFn(types.Int, types.Int, VolatilityLeakProof),
        makeLeFn(types.Interval, types.Interval, VolatilityLeakProof),
        makeLeFn(types.Oid, types.Oid, VolatilityLeakProof),
        makeLeFn(types.String, types.String, VolatilityLeakProof),
        makeLeFn(types.Time, types.Time, VolatilityLeakProof),
        makeLeFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
        makeLeFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
        makeLeFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
        makeLeFn(types.Uuid, types.Uuid, VolatilityLeakProof),
        makeLeFn(types.VarBit, types.VarBit, VolatilityLeakProof),

        makeLeFn(types.Date, types.Timestamp, VolatilityImmutable),
        makeLeFn(types.Date, types.TimestampTZ, VolatilityStable),
        makeLeFn(types.Decimal, types.Float, VolatilityLeakProof),
        makeLeFn(types.Decimal, types.Int, VolatilityLeakProof),
        makeLeFn(types.Float, types.Decimal, VolatilityLeakProof),
        makeLeFn(types.Float, types.Int, VolatilityLeakProof),
        makeLeFn(types.Int, types.Decimal, VolatilityLeakProof),
        makeLeFn(types.Int, types.Float, VolatilityLeakProof),
        makeLeFn(types.Int, types.Oid, VolatilityLeakProof),
        makeLeFn(types.Oid, types.Int, VolatilityLeakProof),
        makeLeFn(types.Timestamp, types.Date, VolatilityImmutable),
        makeLeFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
        makeLeFn(types.TimestampTZ, types.Date, VolatilityStable),
        makeLeFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
        makeLeFn(types.Time, types.TimeTZ, VolatilityStable),
        makeLeFn(types.TimeTZ, types.Time, VolatilityStable),

        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

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

            isPreferred: true,
            Volatility:  VolatilityLeakProof,
        },

        makeIsFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
        makeIsFn(types.Bool, types.Bool, VolatilityLeakProof),
        makeIsFn(types.Bytes, types.Bytes, VolatilityLeakProof),
        makeIsFn(types.Date, types.Date, VolatilityLeakProof),
        makeIsFn(types.Decimal, types.Decimal, VolatilityImmutable),

        makeIsFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),
        makeIsFn(types.Float, types.Float, VolatilityLeakProof),
        makeIsFn(types.Box2D, types.Box2D, VolatilityLeakProof),
        makeIsFn(types.Geography, types.Geography, VolatilityLeakProof),
        makeIsFn(types.Geometry, types.Geometry, VolatilityLeakProof),
        makeIsFn(types.INet, types.INet, VolatilityLeakProof),
        makeIsFn(types.Int, types.Int, VolatilityLeakProof),
        makeIsFn(types.Interval, types.Interval, VolatilityLeakProof),
        makeIsFn(types.Jsonb, types.Jsonb, VolatilityImmutable),
        makeIsFn(types.Oid, types.Oid, VolatilityLeakProof),
        makeIsFn(types.String, types.String, VolatilityLeakProof),
        makeIsFn(types.Time, types.Time, VolatilityLeakProof),
        makeIsFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
        makeIsFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
        makeIsFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
        makeIsFn(types.Uuid, types.Uuid, VolatilityLeakProof),
        makeIsFn(types.VarBit, types.VarBit, VolatilityLeakProof),

        makeIsFn(types.Date, types.Timestamp, VolatilityImmutable),
        makeIsFn(types.Date, types.TimestampTZ, VolatilityStable),
        makeIsFn(types.Decimal, types.Float, VolatilityLeakProof),
        makeIsFn(types.Decimal, types.Int, VolatilityLeakProof),
        makeIsFn(types.Float, types.Decimal, VolatilityLeakProof),
        makeIsFn(types.Float, types.Int, VolatilityLeakProof),
        makeIsFn(types.Int, types.Decimal, VolatilityLeakProof),
        makeIsFn(types.Int, types.Float, VolatilityLeakProof),
        makeIsFn(types.Int, types.Oid, VolatilityLeakProof),
        makeIsFn(types.Oid, types.Int, VolatilityLeakProof),
        makeIsFn(types.Timestamp, types.Date, VolatilityImmutable),
        makeIsFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
        makeIsFn(types.TimestampTZ, types.Date, VolatilityStable),
        makeIsFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
        makeIsFn(types.Time, types.TimeTZ, VolatilityStable),
        makeIsFn(types.TimeTZ, types.Time, VolatilityStable),

        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

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

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

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

    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)
            },
            Volatility: VolatilityLeakProof,
        },
    },

    RegMatch: append(
        cmpOpOverload{
            &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)
                },
                Volatility: VolatilityImmutable,
            },
        },
        makeBox2DComparisonOperators(
            func(lhs, rhs *geo.CartesianBoundingBox) bool {
                return lhs.Covers(rhs)
            },
        )...,
    ),

    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)
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
    },

    JSONSomeExists: {
        &CmpOp{
            LeftType:  types.Jsonb,
            RightType: types.StringArray,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return JSONExistsAny(ctx, MustBeDJSON(left), MustBeDArray(right))
            },
            Volatility: VolatilityImmutable,
        },
    },

    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
            },
            Volatility: VolatilityImmutable,
        },
    },

    Contains: {
        &CmpOp{
            LeftType:  types.AnyArray,
            RightType: types.AnyArray,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                haystack := MustBeDArray(left)
                needles := MustBeDArray(right)
                return ArrayContains(ctx, haystack, needles)
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    ContainedBy: {
        &CmpOp{
            LeftType:  types.AnyArray,
            RightType: types.AnyArray,
            Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                needles := MustBeDArray(left)
                haystack := MustBeDArray(right)
                return ArrayContains(ctx, haystack, needles)
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },
    Overlaps: append(
        cmpOpOverload{
            &CmpOp{
                LeftType:  types.AnyArray,
                RightType: types.AnyArray,
                Fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                    array := MustBeDArray(left)
                    other := MustBeDArray(right)
                    if !array.ParamTyp.Equivalent(other.ParamTyp) {
                        return nil, pgerror.New(pgcode.DatatypeMismatch, "cannot compare arrays with different element types")
                    }
                    for _, needle := range array.Array {

                        if needle == DNull {
                            continue
                        }
                        for _, hay := range other.Array {
                            if needle.Compare(ctx, hay) == 0 {
                                return DBoolTrue, nil
                            }
                        }
                    }
                    return DBoolFalse, nil
                },
                Volatility: VolatilityImmutable,
            },
            &CmpOp{
                LeftType:  types.INet,
                RightType: types.INet,
                Fn: func(_ *EvalContext, left, right Datum) (Datum, error) {
                    ipAddr := MustBeDIPAddr(left).IPAddr
                    other := MustBeDIPAddr(right).IPAddr
                    return MakeDBool(DBool(ipAddr.ContainsOrContainedBy(&other))), nil
                },
                Volatility: VolatilityImmutable,
            },
        },
        makeBox2DComparisonOperators(
            func(lhs, rhs *geo.CartesianBoundingBox) bool {
                return lhs.Intersects(rhs)
            },
        )...,
    ),
})

CmpOps contains the comparison operations indexed by operation type.

var DMaxIPAddr = NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv6family, Addr: dIPv6max, Mask: 128}})

DMaxIPAddr is the max DIPaddr.

var DMaxUUID = NewDUuid(DUuid{uuid.UUID{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}})

DMaxUUID is the max UUID.

var DMinIPAddr = NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv4family, Addr: dIPv4min, Mask: 0}})

DMinIPAddr is the min DIPAddr.

var DMinUUID = NewDUuid(DUuid{uuid.UUID{}})

DMinUUID is the min UUID.

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
            },
            Volatility: VolatilityImmutable,
        },
        &UnaryOp{
            Typ:        types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return NewDFloat(-*d.(*DFloat)), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
    },

    UnaryComplement: {
        &UnaryOp{
            Typ:        types.Int,
            ReturnType: types.Int,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return NewDInt(^MustBeDInt(d)), nil
            },
            Volatility: VolatilityImmutable,
        },
        &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
            },
            Volatility: VolatilityImmutable,
        },
        &UnaryOp{
            Typ:        types.INet,
            ReturnType: types.INet,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                ipAddr := MustBeDIPAddr(d).IPAddr
                return NewDIPAddr(DIPAddr{ipAddr.Complement()}), nil
            },
            Volatility: VolatilityImmutable,
        },
    },

    UnarySqrt: {
        &UnaryOp{
            Typ:        types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return Sqrt(float64(*d.(*DFloat)))
            },
            Volatility: VolatilityImmutable,
        },
        &UnaryOp{
            Typ:        types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                dec := &d.(*DDecimal).Decimal
                return DecimalSqrt(dec)
            },
            Volatility: VolatilityImmutable,
        },
    },

    UnaryCbrt: {
        &UnaryOp{
            Typ:        types.Float,
            ReturnType: types.Float,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return Cbrt(float64(*d.(*DFloat)))
            },
            Volatility: VolatilityImmutable,
        },
        &UnaryOp{
            Typ:        types.Decimal,
            ReturnType: types.Decimal,
            Fn: func(_ *EvalContext, d Datum) (Datum, error) {
                dec := &d.(*DDecimal).Decimal
                return DecimalCbrt(dec)
            },
            Volatility: VolatilityImmutable,
        },
    },
})

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, loc *time.Location) (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) (size uintptr, isVarlen 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 return value 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(
    ctx context.Context, asOf AsOfClause, semaCtx *SemaContext, evalCtx *EvalContext,
) (tsss hlc.Timestamp, err error)

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

func ExprDebugString Uses

func ExprDebugString(expr Expr) string

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

func FoldComparisonExpr Uses

func FoldComparisonExpr(
    op ComparisonOperator, left, right Expr,
) (newOp ComparisonOperator, newLeft Expr, newRight Expr, flipped bool, not bool)

FoldComparisonExpr folds a given comparison operation and its expressions into an equivalent operation that will hit in the CmpOps map, returning this new operation, along with potentially flipped operands and "flipped" and "not" flags.

func GetEnumComponentsFromPhysicalRep Uses

func GetEnumComponentsFromPhysicalRep(typ *types.T, rep []byte) ([]byte, string, error)

GetEnumComponentsFromPhysicalRep returns the physical and logical components for an enum of the requested type. It returns an error if it cannot find a matching physical representation.

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 GetStaticallyKnownType Uses

func GetStaticallyKnownType(ref ResolvableTypeReference) (typ *types.T, ok bool)

GetStaticallyKnownType possibly promotes a ResolvableTypeReference into a *types.T if the reference is a statically known type. It is only safe to access the returned type if ok is true.

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 TypedExpr) bool

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

func IsReferenceSerialType Uses

func IsReferenceSerialType(ref ResolvableTypeReference) bool

IsReferenceSerialType returns whether the input reference is a known serial type. It should only be used during parsing.

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 MustBeStaticallyKnownType Uses

func MustBeStaticallyKnownType(ref ResolvableTypeReference) *types.T

MustBeStaticallyKnownType does the same thing as GetStaticallyKnownType but panics in the case that the reference is not statically known. This function is intended to be used in tests or in cases where it is not possible to have any unresolved type references.

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 NewCannotMixBitArraySizesError Uses

func NewCannotMixBitArraySizesError(op string) error

NewCannotMixBitArraySizesError creates an error for the case when a bitwise aggregate function is called on bit arrays with different sizes.

func NewContextDependentOpsNotAllowedError Uses

func NewContextDependentOpsNotAllowedError(context string) error

NewContextDependentOpsNotAllowedError creates an error for the case when context-dependent operators are not allowed in the given context.

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(
    semaCtx *SemaContext, 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 ResolveExisting Uses

func ResolveExisting(
    ctx context.Context,
    u *UnresolvedObjectName,
    r ObjectNameExistingResolver,
    lookupFlags ObjectLookupFlags,
    curDb string,
    searchPath sessiondata.SearchPath,
) (bool, ObjectNamePrefix, NameResolutionResult, error)

ResolveExisting performs name resolution for an object name when the target object is expected to exist already. It does not mutate the input name. It additionally returns the resolved prefix qualification for the object. For example, if the unresolved name was "a.b" and the name was resolved to "a.public.b", the prefix "a.public" is returned.

func ResolveTarget Uses

func ResolveTarget(
    ctx context.Context,
    u *UnresolvedObjectName,
    r ObjectNameTargetResolver,
    curDb string,
    searchPath sessiondata.SearchPath,
) (found bool, namePrefix ObjectNamePrefix, scMeta SchemaMeta, err error)

ResolveTarget performs name resolution for an object name when the target object is not expected to exist already. It does not mutate the input name. It additionally returns the resolved prefix qualification for the object. For example, if the unresolved name was "a.b" and the name was resolved to "a.public.b", the prefix "a.public" is returned.

func ResolveType Uses

func ResolveType(
    ctx context.Context, ref ResolvableTypeReference, resolver TypeReferenceResolver,
) (*types.T, error)

ResolveType converts a ResolvableTypeReference into a *types.T.

func Serialize Uses

func Serialize(n NodeFormatter) string

Serialize pretty prints a node to a string using FmtSerializable; it is appropriate when we store expressions into strings that are stored on disk and may be later parsed back into expressions.

func SerializeForDisplay Uses

func SerializeForDisplay(n NodeFormatter) string

SerializeForDisplay pretty prints a node to a string using FmtParsable. It is appropriate when printing expressions that are visible to end users.

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 TimeFamilyPrecisionToRoundDuration Uses

func TimeFamilyPrecisionToRoundDuration(precision int32) time.Duration

TimeFamilyPrecisionToRoundDuration takes in a type's precision, and returns the duration to use to pass into time.Truncate to truncate to that duration. Panics if the precision is not supported.

func TimestampToDecimal Uses

func TimestampToDecimal(ts hlc.Timestamp) apd.Decimal

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 WalkExprConst Uses

func WalkExprConst(v Visitor, expr Expr)

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

func WindowModeName Uses

func WindowModeName(mode WindowFrameMode) string

WindowModeName returns the name of the window frame mode.

type AggType Uses

type AggType int

AggType specifies the type of aggregation.

const (

    // GeneralAgg is used for general-purpose aggregate functions.
    // array_agg(col1 ORDER BY col2)
    GeneralAgg AggType
    // OrderedSetAgg is used for ordered-set aggregate functions.
    // percentile_disc(fraction) WITHIN GROUP (ORDER BY col1)
    OrderedSetAgg
)

FuncExpr.AggType

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(
    _ context.Context, _ *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 {
    ObjectNamePrefix
}

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 AlterDatabaseAddRegion Uses

type AlterDatabaseAddRegion struct {
    Name    Name
    Regions NameList
}

AlterDatabaseAddRegion represents a ALTER DATABASE ADD REGION(S) statement.

func (*AlterDatabaseAddRegion) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterDatabaseAddRegion) StatementTag Uses

func (*AlterDatabaseAddRegion) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDatabaseAddRegion) StatementType Uses

func (*AlterDatabaseAddRegion) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDatabaseAddRegion) String Uses

func (n *AlterDatabaseAddRegion) String() string

type AlterDatabaseDropRegion Uses

type AlterDatabaseDropRegion struct {
    Name    Name
    Regions NameList
}

AlterDatabaseDropRegion represents a ALTER DATABASE DROP REGION(S) statement.

func (*AlterDatabaseDropRegion) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterDatabaseDropRegion) StatementTag Uses

func (*AlterDatabaseDropRegion) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDatabaseDropRegion) StatementType Uses

func (*AlterDatabaseDropRegion) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDatabaseDropRegion) String Uses

func (n *AlterDatabaseDropRegion) String() string

type AlterDatabaseOwner Uses

type AlterDatabaseOwner struct {
    Name  Name
    Owner Name
}

AlterDatabaseOwner represents a ALTER DATABASE OWNER TO statement.

func (*AlterDatabaseOwner) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterDatabaseOwner) StatementTag Uses

func (*AlterDatabaseOwner) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDatabaseOwner) StatementType Uses

func (*AlterDatabaseOwner) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDatabaseOwner) String Uses

func (n *AlterDatabaseOwner) String() string

type AlterDatabaseSurvive Uses

type AlterDatabaseSurvive struct {
    Name    Name
    Survive Survive
}

AlterDatabaseSurvive represents a ALTER DATABASE SURVIVE ... statement.

func (*AlterDatabaseSurvive) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterDatabaseSurvive) StatementTag Uses

func (*AlterDatabaseSurvive) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDatabaseSurvive) StatementType Uses

func (*AlterDatabaseSurvive) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDatabaseSurvive) String Uses

func (n *AlterDatabaseSurvive) 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 AlterRole Uses

type AlterRole struct {
    Name      Expr
    IfExists  bool
    IsRole    bool
    KVOptions KVOptions
}

AlterRole represents an ALTER ROLE statement.

func (*AlterRole) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterRole) StatementTag Uses

func (*AlterRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterRole) StatementType Uses

func (*AlterRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterRole) String Uses

func (n *AlterRole) String() string

type AlterSchema Uses

type AlterSchema struct {
    Schema Name
    Cmd    AlterSchemaCmd
}

AlterSchema represents an ALTER SCHEMA statement.

func (*AlterSchema) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterSchema) StatementTag Uses

func (*AlterSchema) StatementTag() string

StatementTag implements the Statement interface.

func (*AlterSchema) StatementType Uses

func (*AlterSchema) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterSchema) String Uses

func (n *AlterSchema) String() string

type AlterSchemaCmd Uses

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

AlterSchemaCmd represents a schema modification operation.

type AlterSchemaOwner Uses

type AlterSchemaOwner struct {
    Owner Name
}

AlterSchemaOwner represents an ALTER SCHEMA OWNER TO command.

func (*AlterSchemaOwner) Format Uses

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

Format implements the NodeFormatter interface.

type AlterSchemaRename Uses

type AlterSchemaRename struct {
    NewName Name
}

AlterSchemaRename represents an ALTER SCHEMA RENAME command.

func (*AlterSchemaRename) Format Uses

func (node *AlterSchemaRename) 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

func (*AlterTableAddColumn) TelemetryCounter Uses

func (node *AlterTableAddColumn) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

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

func (*AlterTableAddConstraint) TelemetryCounter Uses

func (node *AlterTableAddConstraint) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterTableAlterColumnType Uses

type AlterTableAlterColumnType struct {
    Collation string
    Column    Name
    ToType    ResolvableTypeReference
    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

func (*AlterTableAlterColumnType) TelemetryCounter Uses

func (node *AlterTableAlterColumnType) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterTableAlterPrimaryKey Uses

type AlterTableAlterPrimaryKey struct {
    Columns    IndexElemList
    Interleave *InterleaveDef
    Sharded    *ShardedIndexDef
}

AlterTableAlterPrimaryKey represents an ALTER TABLE ALTER PRIMARY KEY command.

func (*AlterTableAlterPrimaryKey) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTableAlterPrimaryKey) TelemetryCounter Uses

func (node *AlterTableAlterPrimaryKey) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterTableCmd Uses

type AlterTableCmd interface {
    NodeFormatter
    // TelemetryCounter returns the telemetry counter to increment
    // when this command is used.
    TelemetryCounter() telemetry.Counter
    // 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

func (*AlterTableDropColumn) TelemetryCounter Uses

func (node *AlterTableDropColumn) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

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

func (*AlterTableDropConstraint) TelemetryCounter Uses

func (node *AlterTableDropConstraint) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

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

func (*AlterTableDropNotNull) TelemetryCounter Uses

func (node *AlterTableDropNotNull) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

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

func (*AlterTableDropStored) TelemetryCounter Uses

func (node *AlterTableDropStored) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

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.

func (*AlterTableInjectStats) TelemetryCounter Uses

func (node *AlterTableInjectStats) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterTableOwner Uses

type AlterTableOwner struct {
    Owner Name
}

AlterTableOwner represents an ALTER TABLE OWNER TO command.

func (*AlterTableOwner) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTableOwner) TelemetryCounter Uses

func (node *AlterTableOwner) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd 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.

func (*AlterTablePartitionBy) TelemetryCounter Uses

func (node *AlterTablePartitionBy) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterTableRegionalAffinity Uses

type AlterTableRegionalAffinity struct {
    Name             *UnresolvedObjectName
    IfExists         bool
    RegionalAffinity RegionalAffinity
}

AlterTableRegionalAffinity represents an ALTER TABLE SET REGIONAL AFFINITY command.

func (*AlterTableRegionalAffinity) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTableRegionalAffinity) StatementTag Uses

func (*AlterTableRegionalAffinity) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTableRegionalAffinity) StatementType Uses

func (*AlterTableRegionalAffinity) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTableRegionalAffinity) String Uses

func (n *AlterTableRegionalAffinity) String() string

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.

func (*AlterTableRenameColumn) TelemetryCounter Uses

func (node *AlterTableRenameColumn) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd 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.

func (*AlterTableRenameConstraint) TelemetryCounter Uses

func (node *AlterTableRenameConstraint) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd 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.

func (*AlterTableSetAudit) TelemetryCounter Uses

func (node *AlterTableSetAudit) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd 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

func (*AlterTableSetDefault) TelemetryCounter Uses

func (node *AlterTableSetDefault) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

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

func (*AlterTableSetNotNull) TelemetryCounter Uses

func (node *AlterTableSetNotNull) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterTableSetSchema Uses

type AlterTableSetSchema struct {
    Name           *UnresolvedObjectName
    Schema         Name
    IfExists       bool
    IsView         bool
    IsMaterialized bool
    IsSequence     bool
}

AlterTableSetSchema represents an ALTER TABLE SET SCHEMA command.

func (*AlterTableSetSchema) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTableSetSchema) StatementTag Uses

func (*AlterTableSetSchema) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTableSetSchema) StatementType Uses

func (*AlterTableSetSchema) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTableSetSchema) String Uses

func (n *AlterTableSetSchema) 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.

func (*AlterTableValidateConstraint) TelemetryCounter Uses

func (node *AlterTableValidateConstraint) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTableCmd interface.

type AlterType Uses

type AlterType struct {
    Type *UnresolvedObjectName
    Cmd  AlterTypeCmd
}

AlterType represents an ALTER TYPE statement.

func (*AlterType) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterType) StatementTag Uses

func (*AlterType) StatementTag() string

StatementTag implements the Statement interface.

func (*AlterType) StatementType Uses

func (*AlterType) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterType) String Uses

func (n *AlterType) String() string

type AlterTypeAddValue Uses

type AlterTypeAddValue struct {
    NewVal      EnumValue
    IfNotExists bool
    Placement   *AlterTypeAddValuePlacement
}

AlterTypeAddValue represents an ALTER TYPE ADD VALUE command.

func (*AlterTypeAddValue) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTypeAddValue) TelemetryCounter Uses

func (node *AlterTypeAddValue) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTypeCmd interface.

type AlterTypeAddValuePlacement Uses

type AlterTypeAddValuePlacement struct {
    Before      bool
    ExistingVal EnumValue
}

AlterTypeAddValuePlacement represents the placement clause for an ALTER TYPE ADD VALUE command ([BEFORE | AFTER] value).

type AlterTypeCmd Uses

type AlterTypeCmd interface {
    NodeFormatter

    // TelemetryCounter returns the telemetry counter to increment
    // when this command is used.
    TelemetryCounter() telemetry.Counter
    // contains filtered or unexported methods
}

AlterTypeCmd represents a type modification operation.

type AlterTypeOwner Uses

type AlterTypeOwner struct {
    Owner Name
}

AlterTypeOwner represents an ALTER TYPE OWNER TO command.

func (*AlterTypeOwner) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTypeOwner) TelemetryCounter Uses

func (node *AlterTypeOwner) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTypeCmd interface.

type AlterTypeRename Uses

type AlterTypeRename struct {
    NewName Name
}

AlterTypeRename represents an ALTER TYPE RENAME command.

func (*AlterTypeRename) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTypeRename) TelemetryCounter Uses

func (node *AlterTypeRename) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTypeCmd interface.

type AlterTypeRenameValue Uses

type AlterTypeRenameValue struct {
    OldVal EnumValue
    NewVal EnumValue
}

AlterTypeRenameValue represents an ALTER TYPE RENAME VALUE command.

func (*AlterTypeRenameValue) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTypeRenameValue) TelemetryCounter Uses

func (node *AlterTypeRenameValue) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTypeCmd interface.

type AlterTypeSetSchema Uses

type AlterTypeSetSchema struct {
    Schema Name
}

AlterTypeSetSchema represents an ALTER TYPE SET SCHEMA command.

func (*AlterTypeSetSchema) Format Uses

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

Format implements the NodeFormatter interface.

func (*AlterTypeSetSchema) TelemetryCounter Uses

func (node *AlterTypeSetSchema) TelemetryCounter() telemetry.Counter

TelemetryCounter implements the AlterTypeCmd interface.

type Analyze Uses

type Analyze struct {
    Table TableExpr
}

Analyze represents an ANALYZE statement.

func (*Analyze) Format Uses

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

Format implements the NodeFormatter interface.

func (*Analyze) StatementTag Uses

func (*Analyze) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Analyze) StatementType Uses

func (*Analyze) StatementType() StatementType

StatementType implements the Statement interface.

func (*Analyze) String Uses

func (n *Analyze) 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 context.Context, semaCtx *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 ResolvableTypeReference

    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 context.Context, semaCtx *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 context.Context, semaCtx *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 context.Context, semaCtx *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 ArrayTypeReference Uses

type ArrayTypeReference struct {
    ElementType ResolvableTypeReference
}

ArrayTypeReference represents an array of possibly unknown type references.

func (*ArrayTypeReference) SQLString Uses

func (node *ArrayTypeReference) SQLString() string

SQLString implements the ResolvableTypeReference 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

func (AuditMode) TelemetryName Uses

func (m AuditMode) TelemetryName() string

TelemetryName returns a friendly string for use in telemetry that represents the AuditMode.

type Backup Uses

type Backup struct {
    Targets         *TargetList
    To              StringOrPlaceholderOptList
    IncrementalFrom Exprs
    AsOf            AsOfClause
    Options         BackupOptions
    Nested          bool
    AppendToLatest  bool
    // Subdir may be set by the parser when the SQL query is of the form
    // `BACKUP INTO 'subdir' IN...`. Alternatively, if Nested is true but a subdir
    // was not explicitly specified by the user, then this will be set during
    // BACKUP planning once the destination has been resolved.
    Subdir Expr
}

Backup represents a BACKUP statement.

func (Backup) Coverage Uses

func (node Backup) Coverage() DescriptorCoverage

Coverage return the coverage (all vs requested).

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 BackupOptions Uses

type BackupOptions struct {
    CaptureRevisionHistory bool
    EncryptionPassphrase   Expr
    Detached               bool
    EncryptionKMSURI       StringOrPlaceholderOptList
}

BackupOptions describes options for the BACKUP execution.

func (*BackupOptions) CombineWith Uses

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

CombineWith merges other backup options into this backup options struct. An error is returned if the same option merged multiple times.

func (*BackupOptions) Format Uses

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

Format implements the NodeFormatter interface

func (BackupOptions) IsDefault Uses

func (o BackupOptions) IsDefault() bool

IsDefault returns true if this backup options struct has default value.

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           TwoArgFn
    Volatility   Volatility
    // contains filtered or unexported fields
}

BinOp is a binary operator.

type BinaryExpr Uses

type BinaryExpr struct {
    Operator    BinaryOperator
    Left, Right Expr

    Fn  *BinOp
    // 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 context.Context, semaCtx *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
    Mtr  MaterializeClause
    Stmt Statement
}

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

type CallbackValueGenerator Uses

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

CallbackValueGenerator is a ValueGenerator that calls a supplied callback for producing the values. To be used with EvalContextTestingKnobs.CallbackGenerators.

func NewCallbackValueGenerator Uses

func NewCallbackValueGenerator(
    cb func(ctx context.Context, prev int, txn *kv.Txn) (int, error),
) *CallbackValueGenerator

NewCallbackValueGenerator creates a new CallbackValueGenerator.

func (*CallbackValueGenerator) Close Uses

func (c *CallbackValueGenerator) Close()

Close is part of the ValueGenerator interface.

func (*CallbackValueGenerator) Next Uses

func (c *CallbackValueGenerator) Next(ctx context.Context) (bool, error)

Next is part of the ValueGenerator interface.

func (*CallbackValueGenerator) ResolvedType Uses

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

ResolvedType is part of the ValueGenerator interface.

func (*CallbackValueGenerator) Start Uses

func (c *CallbackValueGenerator) Start(_ context.Context, txn *kv.Txn) error

Start is part of the ValueGenerator interface.

func (*CallbackValueGenerator) Values Uses

func (c *CallbackValueGenerator) Values() (Datums, error)

Values is part of the ValueGenerator interface.

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 context.Context, semaCtx *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 ResolvableTypeReference

    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

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 context.Context, semaCtx *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
    Hidden bool
}

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 ConstraintTableDef interface.

type ClientNoticeSender Uses

type ClientNoticeSender interface {
    // BufferClientNotice buffers the notice to send to the client.
    // This is flushed before the connection is closed.
    BufferClientNotice(ctx context.Context, notice pgnotice.Notice)
}

ClientNoticeSender is a limited interface to send notices to the client.

TODO(knz): as of this writing, the implementations of this interface only work on the gateway node (i.e. not from distributed processors).

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  TwoArgFn

    Volatility Volatility
    // 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 context.Context, semaCtx *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 context.Context, semaCtx *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

    // ByIndex, if set, indicates that the access is using a numeric
    // column reference and ColIndex below is already set.
    ByIndex bool

    // ColName is the name of the column to access. Empty if ByIndex is
    // set.
    ColName string

    // ColIndex indicates the index of the column in the tuple. This is
    // either:
    // - set during type checking based on the label in ColName if
    //   ByIndex is false,
    // - or checked for validity during type checking if ByIndex is true.
    // The first column in the tuple is at index 0. The input
    // syntax (E).@N populates N-1 in this field.
    ColIndex int
    // contains filtered or unexported fields
}

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

func NewTypedColumnAccessExpr Uses

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

NewTypedColumnAccessExpr creates a pre-typed ColumnAccessExpr. A by-index ColumnAccessExpr can be specified by passing an empty string as colName.

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 context.Context, semaCtx *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.

func (ColumnID) SafeValue Uses

func (ColumnID) SafeValue()

SafeValue implements the redact.SafeValue interface.

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
}

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. If this is updated, then dummyColumnItem.Format should be updated as well.

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(
    _ context.Context, _ *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     ResolvableTypeReference
    IsSerial bool
    Nullable struct {
        Nullability    Nullability
        ConstraintName Name
    }
    PrimaryKey struct {
        IsPrimaryKey bool
        Sharded      bool
        ShardBuckets Expr
    }
    Unique struct {
        IsUnique       bool
        WithoutIndex   bool
        ConstraintName 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,
    typRef ResolvableTypeReference,
    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) 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 CommentOnIndex Uses

type CommentOnIndex struct {
    Index   TableIndexName
    Comment *string
}

CommentOnIndex represents a COMMENT ON INDEX statement.

func (*CommentOnIndex) Format Uses

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

Format implements the NodeFormatter interface.

func (*CommentOnIndex) StatementTag Uses

func (*CommentOnIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommentOnIndex) StatementType Uses

func (*CommentOnIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommentOnIndex) String Uses

func (n *CommentOnIndex) 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 CommonLookupFlags Uses

type CommonLookupFlags struct {
    // if required is set, lookup will return an error if the item is not found.
    Required bool
    // RequireMutable specifies whether to return a mutable descriptor.
    RequireMutable bool
    // if AvoidCached is set, lookup will avoid the cache (if any).
    AvoidCached bool
    // IncludeOffline specifies if offline descriptors should be visible.
    IncludeOffline bool
    // IncludeOffline specifies if dropped descriptors should be visible.
    IncludeDropped bool
}

CommonLookupFlags is the common set of flags for the various accessor interfaces.

type ComparisonExpr Uses

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

    Fn  *CmpOp
    // 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. Note: if you're modifying this function, please make sure to adjust colexec.comparisonExprAdapter implementations accordingly.

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 context.Context, semaCtx *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
    Overlaps

    // 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) HasSubOperator Uses

func (i ComparisonOperator) HasSubOperator() bool

HasSubOperator returns if the ComparisonOperator is used with a sub-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 colinfo.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 specified type, 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.
    //
    // The returned expression is either a Datum or a CastExpr wrapping a Datum;
    // the latter is necessary for cases where the result would depend on the
    // context (like the timezone or the current time).
    ResolveAsType(context.Context, *SemaContext, *types.T) (TypedExpr, 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

    // SetName replaces the name of the definition in-place. Used in the parser.
    SetName(name Name)
    // 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 ControlJobsForSchedules Uses

type ControlJobsForSchedules struct {
    Schedules *Select
    Command   JobCommand
}

ControlJobsForSchedules represents PAUSE/RESUME/CANCEL clause which applies job command to the jobs matching specified schedule(s).

func (*ControlJobsForSchedules) Format Uses

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

Format implements NodeFormatter interface

func (*ControlJobsForSchedules) StatementTag Uses

func (n *ControlJobsForSchedules) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ControlJobsForSchedules) StatementType Uses

func (*ControlJobsForSchedules) StatementType() StatementType

StatementType implements the Statement interface.

func (*ControlJobsForSchedules) String Uses

func (n *ControlJobsForSchedules) String() string

type ControlSchedules Uses

type ControlSchedules struct {
    Schedules *Select
    Command   ScheduleCommand
}

ControlSchedules represents PAUSE/RESUME SCHEDULE statement.

func (*ControlSchedules) Format Uses

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

Format implements NodeFormatter interface

func (*ControlSchedules) StatementTag Uses

func (n *ControlSchedules) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ControlSchedules) StatementType Uses

func (*ControlSchedules) StatementType() StatementType

StatementType implements the Statement interface.

func (*ControlSchedules) String Uses

func (n *ControlSchedules) String() string

type CopyFormat Uses

type CopyFormat int

CopyFormat identifies a COPY data format.

const (
    CopyFormatText CopyFormat = iota
    CopyFormatBinary
)

Valid values for CopyFormat.

type CopyFrom Uses

type CopyFrom struct {
    Table   TableName
    Columns NameList
    Stdin   bool
    Options CopyOptions
}

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 CopyOptions Uses

type CopyOptions struct {
    Destination Expr
    CopyFormat  CopyFormat
}

CopyOptions describes options for COPY execution.

func (*CopyOptions) CombineWith Uses

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

CombineWith merges other options into this struct. An error is returned if the same option merged multiple times.

func (*CopyOptions) Format Uses

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

Format implements the NodeFormatter interface

func (CopyOptions) IsDefault Uses

func (o CopyOptions) IsDefault() bool

IsDefault returns true if this struct has default value.

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
    ConnectionLimit int32
    Regions         NameList
    Survive         Survive
}

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 CreateExtension Uses

type CreateExtension struct {
    Name        string
    IfNotExists bool
}

CreateExtension represents a CREATE EXTENSION statement.

func (*CreateExtension) Format Uses

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

Format implements the NodeFormatter interface.

func (*CreateExtension) StatementTag Uses

func (*CreateExtension) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateExtension) StatementType Uses

func (*CreateExtension) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateExtension) String Uses

func (n *CreateExtension) String() string

type CreateIndex